diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java index 07d16275..3d554ccd 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java @@ -54,7 +54,7 @@ import java.util.stream.Collectors; /** *

- * 服务实现类 + * 服务实现类 *

* * @author super_liu @@ -88,27 +88,27 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl list = dao.selectList(qw); - if(!list.isEmpty()){ - if(StringUtils.isNotBlank(list.get(0).getParentIds())){ + if (!list.isEmpty()) { + if (StringUtils.isNotBlank(list.get(0).getParentIds())) { List topIdList = Arrays.stream(list.get(0).getParentIds().split(",")).map(String::trim).collect(Collectors.toList()); QueryWrapper wrapper = new QueryWrapper(); - wrapper.in("ID",topIdList); - List topList = dao.selectTopList(wrapper,list.get(0).getParentIds()); + wrapper.in("ID", topIdList); + List topList = dao.selectTopList(wrapper, list.get(0).getParentIds()); List filterList = topList.stream().map(SarMenuStandard::getMenuName).collect(Collectors.toList()); - if(!filterList.isEmpty()){ - return StringUtils.join(filterList, "/")+'/'+list.get(0).getMenuName(); + if (!filterList.isEmpty()) { + return StringUtils.join(filterList, "/") + '/' + list.get(0).getMenuName(); } - }else { + } else { return list.get(0).getMenuName(); } @@ -121,7 +121,7 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl roleIdList = tsRoleDao.getRoleByUserId(LoginUserUtil.getUserId()); for (String roleId : roleIdList) { HashMap map = new HashMap<>(); - map.put("resourceId",sarMenuStandard.getId()); - map.put("roleId",roleId); + map.put("resourceId", sarMenuStandard.getId()); + map.put("roleId", roleId); resourceDao.insertTsRoleResource(map); } } @@ -148,11 +148,11 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SarMenuStandard::getId,Arrays.asList(sarMenuStandard.getParentIds().split(","))); + wrapper.in(SarMenuStandard::getId, Arrays.asList(sarMenuStandard.getParentIds().split(","))); List menuStandards = dao.selectList(wrapper); - if(!menuStandards.isEmpty()){ + if (!menuStandards.isEmpty()) { String parentIdsName = menuStandards.stream().map(SarMenuStandard::getMenuName).collect(Collectors.joining(",")); sarMenuStandard.setParentIdsName(parentIdsName); } @@ -186,7 +186,8 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl gbRelations = BeanCopyUtils.copyBeanList(gbStandMenu, StandMenuRelation.class); // 外标 - List fbStandMenu = sarStandMenuDao.getFBStandMenu().stream().filter(item -> item.getStandId() != null).collect(Collectors.toList());; + List fbStandMenu = sarStandMenuDao.getFBStandMenu().stream().filter(item -> item.getStandId() != null).collect(Collectors.toList()); + ; List fbRelations = BeanCopyUtils.copyBeanList(fbStandMenu, StandMenuRelation.class); // 企标 @@ -204,6 +205,7 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl standardSystemList(StandSystemDTO standSystemDTO) { + boolean timeSort = StrUtil.isNotBlank(standSystemDTO.getSortField()); boolean select = standSystemDTO.getSelectIdList() != null; String menuId = standSystemDTO.getMenuId(); // 校验menuId不能为空 @@ -242,6 +244,7 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl pathMap = new HashMap<>(); sarMenuStandard.buildPathMap(pathMap, ""); @@ -266,27 +269,37 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl comparatorReleaseDate = Comparator.comparing(StandSystemDTO::getReleaseDate + , Comparator.nullsLast(Comparator.naturalOrder())); + if (sortField.equals("releaseDate")) { + if (sortMode.equals("desc")) { + resultList.sort(comparatorReleaseDate.reversed()); + } else { + resultList.sort(comparatorReleaseDate); + } } - if (sortField.equals("implementDate") && sortMode.equals("desc")) { - resultList.sort(Comparator.comparing(StandSystemDTO::getStartImplementDate)); - } else { - resultList.sort(Comparator.comparing(StandSystemDTO::getStartImplementDate).reversed()); + Comparator comparatorImplementDate = Comparator.comparing(StandSystemDTO::getImplementDate + , Comparator.nullsLast(Comparator.naturalOrder())); + if (sortField.equals("implementDate")) { + if (sortMode.equals("desc")) { + resultList.sort(comparatorImplementDate.reversed()); + } else { + resultList.sort(comparatorImplementDate); + } } + } else { + // 根据排序字段对 resultList 进行排序 + // 按照标准体系排序 + // 体系内部按照国内/海外/企业排序 + // 每个类别的标准内部按照类别排序 + resultList.sort(Comparator.comparingInt(StandSystemDTO::getSystemSort) + .thenComparingInt(StandSystemDTO::getStandTypeSort) + .thenComparingInt(StandSystemDTO::getStandCategorySort)); } // 手动分页 @@ -345,7 +358,7 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl page = this.standardSystemList(standSystemDTO); @@ -398,39 +411,40 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl getListStandLimit(SarMenuStandardNew sarMenuStandardNew, List access) { List TsResources = new ArrayList<>(); - QueryWrapper queryWrapper =new QueryWrapper<>(); - if(sarMenuStandardNew.getSorDivide()!=null){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (sarMenuStandardNew.getSorDivide() != null) { queryWrapper.eq("sor_divide", sarMenuStandardNew.getSorDivide()); } - if(sarMenuStandardNew.getDicId()!=null){ + if (sarMenuStandardNew.getDicId() != null) { queryWrapper.eq("DIC_ID", sarMenuStandardNew.getDicId()); } - if(access!=null && !access.isEmpty()){ - queryWrapper.in(null!=access && !access.isEmpty(),"ID",access); + if (access != null && !access.isEmpty()) { + queryWrapper.in(null != access && !access.isEmpty(), "ID", access); } - queryWrapper.eq("VALID_FLAG",0); + queryWrapper.eq("VALID_FLAG", 0); queryWrapper.isNull("PARENT_ID"); queryWrapper.orderByAsc("DISPLAY_SEQ"); - TsResources=dao.selectList(queryWrapper); + TsResources = dao.selectList(queryWrapper); - for(SarMenuStandard resource:TsResources){ + for (SarMenuStandard resource : TsResources) { resource.setTreeType("sarMs"); - QueryWrapper TsResourceQueryWrapper=new QueryWrapper<>(); - TsResourceQueryWrapper.like("PARENT_IDS",resource.getId()); - if(access!=null && !access.isEmpty()){ - TsResourceQueryWrapper.in(null!=access && !access.isEmpty(),"ID",access); + QueryWrapper TsResourceQueryWrapper = new QueryWrapper<>(); + TsResourceQueryWrapper.like("PARENT_IDS", resource.getId()); + if (access != null && !access.isEmpty()) { + TsResourceQueryWrapper.in(null != access && !access.isEmpty(), "ID", access); } - TsResourceQueryWrapper.eq("VALID_FLAG",0); + TsResourceQueryWrapper.eq("VALID_FLAG", 0); TsResourceQueryWrapper.orderByAsc("DISPLAY_SEQ"); - List children=dao.selectList(TsResourceQueryWrapper); - resource.setChildren(recursionGetListChildrenStand((resource),(children))); + List children = dao.selectList(TsResourceQueryWrapper); + resource.setChildren(recursionGetListChildrenStand((resource), (children))); } return TsResources; @@ -438,17 +452,18 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl */ - private List recursionGetListChildrenStand(SarMenuStandard resource, List children){ + private List recursionGetListChildrenStand(SarMenuStandard resource, List children) { List tsResources = children.stream() .filter(resource1 -> resource1.getParentId().equals(resource.getId())) .collect(Collectors.toList()); - if(!tsResources.isEmpty()){ + if (!tsResources.isEmpty()) { tsResources = tsResources.stream().sorted(Comparator.comparing(resource1 -> resource1.getDisplaySeq())).collect(Collectors.toList()); tsResources.forEach(resource1 -> { resource1.setTreeType("sarMs"); - resource1.setChildren(recursionGetListChildrenStand((resource1),(children))); + resource1.setChildren(recursionGetListChildrenStand((resource1), (children))); }); } return tsResources;