Kaynağa Gözat

排序修改

jihs 4 yıl önce
ebeveyn
işleme
4f6d6ecbcb

+ 1 - 1
src/main/java/org/jeecg/modules/archives/controller/ProjectManageArchivesController.java

@@ -317,9 +317,9 @@ public class ProjectManageArchivesController {
 			QueryWrapper<ProjectManageBusinessOther> queryWrapper = new QueryWrapper<>();
 			queryWrapper.eq("del_flag", "0").eq("pro_archives_id", reqDTO.getId())
 					.eq("plan_type", reqDTO.getPlanType());
+			queryWrapper.orderByAsc("sort");
 
 			   List<ProjectManageBusinessOther> list = projectManageBusinessOtherService.list(queryWrapper);
-			   list.sort((x, y) -> Integer.compare(x.getSort(), y.getSort()));
 			   List<ProPlanListRespDTO> respDTOS = getTreeList(list);
 				result.setResult(respDTOS);
 				result.setSuccess(true);

+ 7 - 2
src/main/java/org/jeecg/modules/archives/service/impl/ProjectManageArchivesServiceImpl.java

@@ -136,7 +136,10 @@ public class ProjectManageArchivesServiceImpl extends ServiceImpl<ProjectManageA
      * @desc 将里程碑计划数据转成树状结构
      */
     private List<ProBusinessOtherListRespDTO> getPlanList(List<ProjectManageBusinessOther> otherList) {
-        otherList.sort((x, y) -> Integer.compare(x.getSort(), y.getSort()));
+        if(!CollectionUtils.isEmpty(otherList)){
+            otherList.sort((x, y) -> Integer.compare(x.getSort(), y.getSort()));
+        }
+
         List<ProBusinessOtherListRespDTO> resp = Lists.newArrayList();
         //根据parentId分组
         Map<String, List<ProjectManageBusinessOther>> postMap = otherList.stream().collect(Collectors.groupingBy(ProjectManageBusinessOther :: getParentId));
@@ -190,7 +193,9 @@ public class ProjectManageArchivesServiceImpl extends ServiceImpl<ProjectManageA
      * @desc 获取里程碑数据
      */
     private List<ProArchivesAndBusinessAddReqDTO> getBsInfoData(List<ProjectManageArchivesAndBusiness> businessList, int planType) {
-        businessList.sort((x, y) -> Integer.compare(x.getSort(), y.getSort()));
+        if(!CollectionUtils.isEmpty(businessList)){
+            businessList.sort((x, y) -> Integer.compare(x.getSort(), y.getSort()));
+        }
         List<ProArchivesAndBusinessAddReqDTO> reqDTOS = Lists.newArrayList();
         for(ProjectManageArchivesAndBusiness business : businessList){
            int currentPlanType = business.getPlanType();