| | |
| | | spread INT NULL, |
| | | |
| | | -- èç¹æ¯å¦ä¸ºå±ç¤º (0为å±ç¤ºï¼1为ä¸å±ç¤º) |
| | | disabled INT NULL |
| | | disabled INT NULL, |
| | | |
| | | -- è½®ææ¶é´ |
| | | lbtime INT NULL |
| | | ); |
| | | |
| | | -- æ·»å 表注éï¼SQL Serverä½¿ç¨æ©å±å±æ§ï¼ |
| | |
| | | @level2type=N'COLUMN', |
| | | @level2name=N'disabled'; |
| | | |
| | | -- å建å¤é®çº¦æï¼èªå
³èï¼ |
| | | ALTER TABLE dbo.MES_SIMPLE |
| | | ADD CONSTRAINT FK_MES_SIMPLE_FID |
| | | FOREIGN KEY (fid) REFERENCES dbo.MES_SIMPLE(id); |
| | | EXEC sys.sp_addextendedproperty |
| | | @name=N'MS_Description', |
| | | @value=N'è½®ææ¶é´', |
| | | @level0type=N'SCHEMA', |
| | | @level0name=N'dbo', |
| | | @level1type=N'TABLE', |
| | | @level1name=N'MES_SIMPLE', |
| | | @level2type=N'COLUMN', |
| | | @level2name=N'lbtime'; |
| | | |
| | | -- åå»ºç´¢å¼æé«æ¥è¯¢æ§è½ |
| | | CREATE INDEX IX_MES_SIMPLE_FID ON dbo.MES_SIMPLE(fid); |
| | |
| | | CREATE INDEX IX_MES_SIMPLE_DISABLED ON dbo.MES_SIMPLE(disabled); |
| | | |
| | | -- æå
¥ç¤ºä¾æ°æ® |
| | | INSERT INTO dbo.MES_SIMPLE (is_top, fid, title, field, href, spread, disabled) VALUES |
| | | (0, NULL, 'ç³»ç»ç®¡ç', 'system', '#', 1, 0), |
| | | (1, 1, 'èå管ç', 'menu', '/menu/list', 0, 0), |
| | | (1, 1, 'ç¨æ·ç®¡ç', 'user', '/user/list', 0, 0), |
| | | (0, NULL, 'æ°æ®ç®¡ç', 'data', '#', 0, 0), |
| | | (1, 4, 'æ°æ®å¯¼å
¥', 'import', '/data/import', 0, 0), |
| | | (1, 4, 'æ°æ®å¯¼åº', 'export', '/data/export', 0, 0); |
| | | INSERT INTO dbo.MES_SIMPLE (is_top, fid, title, field, href, spread, disabled, lbtime) VALUES |
| | | (0, NULL, 'ç³»ç»ç®¡ç', 'system', '#', 1, 0, NULL), |
| | | (1, 1, 'èå管ç', 'menu', '/menu/list', 0, 0, NULL), |
| | | (1, 1, 'ç¨æ·ç®¡ç', 'user', '/user/list', 0, 0, NULL), |
| | | (0, NULL, 'æ°æ®ç®¡ç', 'data', '#', 0, 0, NULL), |
| | | (1, 4, 'æ°æ®å¯¼å
¥', 'import', '/data/import', 0, 0, NULL), |
| | | (1, 4, 'æ°æ®å¯¼åº', 'export', '/data/export', 0, 0, NULL); |
| | | |
| | | -- æ¥çåå»ºç»æ |
| | | SELECT |
| | |
| | | field, |
| | | href, |
| | | spread, |
| | | disabled |
| | | disabled, |
| | | lbtime |
| | | FROM dbo.MES_SIMPLE |
| | | ORDER BY id; |
| | |
| | | package com.gs.simple.controller; |
| | | |
| | | |
| | | import com.gs.simple.common.ResultDto; |
| | | import com.gs.simple.domain.BiView; |
| | | import com.gs.simple.domain.MesSimplesimple; |
| | | import com.gs.simple.domain.TreeView; |
| | | import com.gs.simple.service.MesSimpleService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | private final MesSimpleService simpleService; |
| | | |
| | | |
| | | @PostMapping("/getTree") |
| | | public ResultDto<List<TreeView>> getTree() { |
| | | return simpleService.getTree(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("list") |
| | | @PostMapping("/list") |
| | | public ResultDto<List<MesSimplesimple>> getList() { |
| | | return simpleService.getMenuList(); |
| | | } |
| | | |
| | | @GetMapping("/listByMenuId/{menuId}") |
| | | public ResultDto<List<BiView>> getBiViews(@PathVariable Integer menuId) { |
| | | return simpleService.getBiViewsByMenuId(menuId); |
| | | } |
| | | } |
| | |
| | | |
| | | import java.io.Serial; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * èåç»´æ¤è¡¨ |
| | |
| | | * èç¹æ¯å¦ä¸ºå±ç¤º 0为å±ç¤ºï¼1为ä¸å±ç¤º |
| | | */ |
| | | private Integer disabled; |
| | | |
| | | /* |
| | | * è½®ææ¶é´ |
| | | * */ |
| | | private Integer lbtime; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.gs.simple.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.gs.simple.domain.BiView; |
| | | import com.gs.simple.domain.MesSimplesimple; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author 28567 |
| | | * @description é对表ãMES_SIMPLE(èåç»´æ¤è¡¨)ãçæ°æ®åºæä½Mapper |
| | | * @createDate 2023-11-08 14:19:52 |
| | | * @Entity com.gs.simple.domain.MesSimplesimple |
| | | */ |
| | | public interface BiViewMapper extends BaseMapper<BiView> { |
| | | } |
| | | |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.gs.simple.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.gs.simple.common.ResultDto; |
| | | import com.gs.simple.domain.BiView; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author 28567 |
| | | * @description é对表ãMES_SIMPLE_CCB(BiView表)ãçæ°æ®åºæä½Service |
| | | * @createDate 2023-11-08 14:19:52 |
| | | */ |
| | | public interface BiViewService extends IService<BiView> { |
| | | |
| | | /** |
| | | * æ ¹æ®ç¶èç¹IDè·åBiViewå表 |
| | | * @param pid ç¶èç¹ID |
| | | * @return BiViewå表 |
| | | */ |
| | | ResultDto<List<BiView>> getListByPid(Integer pid); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¶èç¹IDè·åæhrefçBiViewå表 |
| | | * @param pid ç¶èç¹ID |
| | | * @return BiViewå表 |
| | | */ |
| | | ResultDto<List<BiView>> getListByPidWithHref(Integer pid); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.gs.simple.common.ResultDto; |
| | | import com.gs.simple.domain.BiView; |
| | | import com.gs.simple.domain.MesSimplesimple; |
| | | import com.gs.simple.domain.TreeView; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author 28567 |
| | | * @description é对表ãMES_SIMPLE(èåç»´æ¤è¡¨)ãçæ°æ®åºæä½Service |
| | | * @createDate 2023-11-08 14:19:52 |
| | | */ |
| | | public interface MesSimpleService extends IService<MesSimplesimple> { |
| | | |
| | | |
| | | ResultDto<List<TreeView>> getTree(); |
| | | |
| | | List<TreeView> toTree(); |
| | | |
| | | ResultDto<List<MesSimplesimple>> getMenuList(); |
| | | |
| | | ResultDto<List<BiView>> getBiViewsByMenuId(Integer menuId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.gs.simple.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gs.simple.common.ResultDto; |
| | | import com.gs.simple.domain.BiView; |
| | | import com.gs.simple.mapper.BiViewMapper; |
| | | import com.gs.simple.service.BiViewService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author 28567 |
| | | * @description é对表ãMES_SIMPLE_CCB(BiView表)ãçæ°æ®åºæä½Serviceå®ç° |
| | | * @createDate 2023-11-08 14:19:52 |
| | | */ |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @RequiredArgsConstructor |
| | | public class BiViewServiceImpl extends ServiceImpl<BiViewMapper, BiView> implements BiViewService { |
| | | |
| | | @Override |
| | | public ResultDto<List<BiView>> getListByPid(Integer pid) { |
| | | LambdaQueryWrapper<BiView> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(BiView::getPid, pid); |
| | | List<BiView> list = list(wrapper); |
| | | return ResultDto.ok(list, list.size()); |
| | | } |
| | | |
| | | @Override |
| | | public ResultDto<List<BiView>> getListByPidWithHref(Integer pid) { |
| | | LambdaQueryWrapper<BiView> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(BiView::getPid, pid) |
| | | .isNotNull(BiView::getHref); |
| | | List<BiView> list = list(wrapper); |
| | | return ResultDto.ok(list, list.size()); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gs.simple.common.ResultDto; |
| | | import com.gs.simple.domain.Children; |
| | | import com.gs.simple.domain.MesSimplesimple; |
| | | import com.gs.simple.domain.TreeView; |
| | | import com.gs.simple.domain.*; |
| | | import com.gs.simple.mapper.BiViewMapper; |
| | | import com.gs.simple.mapper.MesSimpleMapper; |
| | | import com.gs.simple.service.MesSimpleService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.gs.simple.domain.BiView; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | import java.util.concurrent.Executors; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author 28567 |
| | | * @description é对表ãMES_SIMPLE(èåç»´æ¤è¡¨)ãçæ°æ®åºæä½Serviceå®ç° |
| | | * @createDate 2023-11-08 14:19:52 |
| | | */ |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @RequiredArgsConstructor |
| | | public class MesSimpleServiceImpl extends ServiceImpl<MesSimpleMapper, MesSimplesimple> implements MesSimpleService { |
| | | |
| | | |
| | | // å建ä¸ä¸ªå
å«10个线ç¨ççº¿ç¨æ± ï¼ç¨äºæ°æ®åºæä½ |
| | | private final BiViewMapper biViewMapper; |
| | | private final Executor dbExecutor = Executors.newFixedThreadPool(10); |
| | | |
| | | @Override |
| | | public ResultDto<List<TreeView>> getTree() { |
| | | List<TreeView> tree = toTree(); |
| | |
| | | return convertToTreeViewList(getTopList()); |
| | | } |
| | | |
| | | //GetTreeæ å½¢ |
| | | @Override |
| | | public ResultDto<List<MesSimplesimple>> getMenuList() { |
| | | public ResultDto getMenuList() { |
| | | LambdaQueryWrapper<MesSimplesimple> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(MesSimplesimple::getDisabled, 0).gt(MesSimplesimple::getIsTop, 0); |
| | | List<MesSimplesimple> list = list(wrapper); |
| | | return ResultDto.ok(list, list.size()); |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * è·åæ ¹èç¹ |
| | | * </p> |
| | | * |
| | | * @return java.util.List<com.gs.simple.domain.MesSimplesimple> |
| | | * @author tjx |
| | | * @date 2023/11/8 14:39 |
| | | */ |
| | | //Listå表 |
| | | // @Override |
| | | // public ResultDto<List<MesSimplesimple>> getMenuList() { |
| | | // LambdaQueryWrapper<MesSimplesimple> wrapper = new LambdaQueryWrapper<>(); |
| | | // wrapper.eq(MesSimplesimple::getDisabled, 0) |
| | | // .gt(MesSimplesimple::getIsTop, 0) |
| | | // .orderByAsc(MesSimplesimple::getIsTop); |
| | | // |
| | | // List<MesSimplesimple> list = list(wrapper); |
| | | // |
| | | // |
| | | // return ResultDto.ok(list, list.size()); |
| | | // } |
| | | |
| | | |
| | | @Override |
| | | public ResultDto<List<BiView>> getBiViewsByMenuId(Integer menuId) { |
| | | |
| | | LambdaQueryWrapper<BiView> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(BiView::getPid, menuId) |
| | | .isNotNull(BiView::getHref); |
| | | List<BiView> list = biViewMapper.selectList(wrapper); |
| | | |
| | | if (!list.isEmpty()) { |
| | | LambdaQueryWrapper<MesSimplesimple> simpleWrapper = new LambdaQueryWrapper<>(); |
| | | simpleWrapper.eq(MesSimplesimple::getId, menuId); |
| | | MesSimplesimple simple = getOne(simpleWrapper); |
| | | if (simple != null) { |
| | | list.forEach(biView -> biView.setLbtime(simple.getLbtime())); |
| | | } |
| | | } |
| | | return ResultDto.ok(list, list.size()); |
| | | } |
| | | |
| | | private List<MesSimplesimple> getTopList() { |
| | | LambdaQueryWrapper<MesSimplesimple> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(MesSimplesimple::getIsTop, 0).eq(MesSimplesimple::getDisabled, 0); |
| | | return list(queryWrapper); |
| | | } |
| | | |
| | | // å°MesSimplesimpleå表转æ¢ä¸ºTreeViewå表 |
| | | private List<TreeView> convertToTreeViewList(List<MesSimplesimple> mesSimplesimpleList) { |
| | | // 使ç¨CompletableFuture弿¥å¤çæ¯ä¸ªMesSimplesimple对象ï¼å¹¶æ¶é为ä¸ä¸ªCompletableFutureå表 |
| | | List<CompletableFuture<TreeView>> treeViewFutures = mesSimplesimpleList.stream().map(mesSimplesimple -> convertToTreeViewAsync(mesSimplesimple, dbExecutor)).toList(); |
| | | List<CompletableFuture<TreeView>> treeViewFutures = mesSimplesimpleList.stream() |
| | | .map(mesSimplesimple -> convertToTreeViewAsync(mesSimplesimple, dbExecutor)) |
| | | .toList(); |
| | | |
| | | // å建ä¸ä¸ªCompletableFutureï¼çå¾
ææå¼æ¥ä»»å¡å®æ |
| | | CompletableFuture<Void> allFutures = CompletableFuture.allOf(treeViewFutures.toArray(new CompletableFuture[0])); |
| | | |
| | | // 卿æå¼æ¥ä»»å¡å®æåï¼å°ç»ææ¶é为ä¸ä¸ªTreeViewå表 |
| | | return allFutures.thenApply(v -> treeViewFutures.stream().map(CompletableFuture::join).collect(Collectors.toList())).join(); |
| | | return allFutures.thenApply(v -> treeViewFutures.stream() |
| | | .map(CompletableFuture::join) |
| | | .collect(Collectors.toList())) |
| | | .join(); |
| | | } |
| | | |
| | | // å°MesSimplesimple对象转æ¢ä¸ºTreeView对象ï¼å¹¶ä½¿ç¨èªå®ä¹çº¿ç¨æ± æ§è¡å¼æ¥ä»»å¡ |
| | | private CompletableFuture<TreeView> convertToTreeViewAsync(MesSimplesimple mesSimplesimple, Executor executor) { |
| | | return CompletableFuture.supplyAsync(() -> convertToTreeView(mesSimplesimple), executor); |
| | | } |
| | |
| | | treeView.setField(mesSimplesimple.getField()); |
| | | treeView.setSpread(mesSimplesimple.getSpread() == 1); |
| | | |
| | | //æç´¢åèç¹ |
| | | LambdaQueryWrapper<MesSimplesimple> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(MesSimplesimple::getDisabled, 0).eq(MesSimplesimple::getFid, mesSimplesimple.getId()); |
| | | List<MesSimplesimple> list = list(wrapper); |
| | |
| | | children.setId(s.getId()); |
| | | children.setTitle(s.getTitle()); |
| | | children.setField(s.getField()); |
| | | if ("è½®æ".equals(s.getHref())) { |
| | | children.setHref("bi_view.html?menuId=" + s.getId() + "&lbsj=" + s.getLbtime()); // 跳转å°ä¸é´é¡µé¢ |
| | | } else { |
| | | children.setHref(s.getHref()); |
| | | } |
| | | childrenList.add(children); |
| | | }); |
| | | treeView.setChildren(childrenList); |
| | |
| | | return treeView; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
| | | # æ¯å¦å¼å¯èªå¨é©¼å³°å½åè§åæ å°:仿°æ®åºååå°Java屿§é©¼å³°å½åç类似æ å° |
| | | map-underscore-to-camel-case: true |
| | | # è§£å³SQL Serveræ´æ°æ°æ®ä¸ºnullæ¶æ æ³è½¬æ¢æ¥é |
| | | # è§£å³oracleæ´æ°æ°æ®ä¸ºnullæ¶æ æ³è½¬æ¢æ¥éï¼mysqlä¸ä¼åºç°æ¤æ
åµ |
| | | jdbc-type-for-null: 'null' |
| | | #å®ä½ç±»æå¨å
|
| | | type-aliases-package: com.gs.simple.domain.* |
| | | type-aliases-package: com.gs.mes.entity.* |
| | | # xmlæ«æï¼å¤ä¸ªç®å½ç¨éå·æè
åå·åéï¼åè¯ Mapper æå¯¹åºç XML æä»¶ä½ç½®ï¼ |
| | | mapper-locations: classpath:mapper/*.xml |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.gs.simple.mapper.BiViewMapper"> |
| | | |
| | | |
| | | |
| | | </mapper> |