ソースを参照

任务流程排序优化

lvy 4 日 前
コミット
653b98486a

+ 18 - 19
blade-service/blade-business/src/main/java/org/springblade/business/controller/FixedFlowController.java

@@ -383,7 +383,6 @@ public class FixedFlowController extends BladeController {
             fixedFlow.setCreateDept(fixedFlow.getId());
             fixedFlow.setUpdateTime(new Date());
             fixedFlow.setCreateUser(AuthUtil.getUserId());
-            fixedFlow.setSort(null);
         });
         boolean flow = this.fixedFlowService.saveBatch(fixedFlowList);
         if (flow && !newFixedFolwLinkList.isEmpty()) {
@@ -515,7 +514,7 @@ public class FixedFlowController extends BladeController {
         IPage<FixedFlow> fixedFlowsPage = fixedFlowService.getBaseMapper().selectPage(page,
                 Wrappers.<FixedFlow>lambdaQuery()
                         .eq(FixedFlow::getContractId, dto.getContractId())
-                        .eq(FixedFlow::getProjectId, dto.getProjectId()).last(" and (is_meter is null or is_meter != 1) order by sort"));
+                        .eq(FixedFlow::getProjectId, dto.getProjectId()).last(" and (is_meter is null or is_meter != 1) order by sort, fixed_flow_name, create_time desc"));
         List<FixedFlow> fixedFlows = fixedFlowsPage.getRecords();
         List<Long> collect = fixedFlows.stream().map(FixedFlow::getId).collect(Collectors.toList());
         if (!collect.isEmpty()) {
@@ -569,23 +568,23 @@ public class FixedFlowController extends BladeController {
             resultMap.setSize(fixedFlowsPage.getSize());
             resultMap.setTotal(fixedFlowsPage.getTotal());
             resultMap.setRecords(fixedFlowVOList);
-            Map<Boolean, List<FixedFlowVO>> groupMap = fixedFlowVOList.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName() != null && record.getFixedFlowName().contains("_") && record.getSort() == null));
-            List<FixedFlowVO> copyFixedFlowVOS = groupMap.get(true);
-            List<FixedFlowVO> fixedFlowVOS = groupMap.get(false);
-            if (copyFixedFlowVOS ==  null || copyFixedFlowVOS.isEmpty() || fixedFlowVOS ==  null || fixedFlowVOS.isEmpty()) {
-                return R.data(resultMap);
-            }
-            Map<String, List<FixedFlowVO>> nameMap = copyFixedFlowVOS.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName().split("_")[0]));
-            List<FixedFlowVO> newData = new ArrayList<>(fixedFlowVOList);
-            for (FixedFlowVO flowVO : fixedFlowVOS) {
-//                newData.add(flowVO);
-                List<FixedFlowVO> flowVOS = nameMap.get(flowVO.getFixedFlowName());
-                if (flowVOS != null && !flowVOS.isEmpty()) {
-                    flowVOS.sort(Comparator.comparing(FixedFlow::getFixedFlowName));
-                    newData.addAll(flowVOS);
-                }
-            }
-            resultMap.setRecords(newData);
+//            Map<Boolean, List<FixedFlowVO>> groupMap = fixedFlowVOList.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName() != null && record.getFixedFlowName().contains("_") && record.getSort() == null));
+//            List<FixedFlowVO> copyFixedFlowVOS = groupMap.get(true);
+//            List<FixedFlowVO> fixedFlowVOS = groupMap.get(false);
+//            if (copyFixedFlowVOS ==  null || copyFixedFlowVOS.isEmpty() || fixedFlowVOS ==  null || fixedFlowVOS.isEmpty()) {
+//                return R.data(resultMap);
+//            }
+//            Map<String, List<FixedFlowVO>> nameMap = copyFixedFlowVOS.stream().collect(Collectors.groupingBy(record -> record.getFixedFlowName().split("_")[0]));
+//            List<FixedFlowVO> newData = new ArrayList<>(fixedFlowVOList);
+//            for (FixedFlowVO flowVO : fixedFlowVOS) {
+////                newData.add(flowVO);
+//                List<FixedFlowVO> flowVOS = nameMap.get(flowVO.getFixedFlowName());
+//                if (flowVOS != null && !flowVOS.isEmpty()) {
+//                    flowVOS.sort(Comparator.comparing(FixedFlow::getFixedFlowName));
+//                    newData.addAll(flowVOS);
+//                }
+//            }
+//            resultMap.setRecords(newData);
             return R.data(resultMap);
         }
         return R.fail("暂无数据");