From 515e2261aff774cd73a49ead5b8e1c2d0382b817 Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Sat, 31 Aug 2024 05:07:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=85=E5=A3=B0=20?= =?UTF-8?q?=E5=BD=B1=E5=83=8F=20=E8=AF=8A=E6=96=AD=E6=A8=A1=E7=89=88?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ultrasonic/ultrasonicController.java | 39 +++++++++++++++---- .../dal/ultrasonic/ultrasonicMapper.java | 1 + .../ultrasonic/ultrasonicServiceImpl.java | 1 + 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/controller/admin/ultrasonic/ultrasonicController.java b/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/controller/admin/ultrasonic/ultrasonicController.java index 3244ae70c..c6e549a22 100644 --- a/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/controller/admin/ultrasonic/ultrasonicController.java +++ b/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/controller/admin/ultrasonic/ultrasonicController.java @@ -79,10 +79,12 @@ public class ultrasonicController { @DataPermission(enable = false) @PreAuthorize("@ss.hasPermission('ultrasoniccom:ultrasonic:create')") public CommonResult> getreporttemplatelist(@RequestParam("orgID") String orgID, @RequestParam("type") String type, @RequestParam("isprivate") String isprivate) throws Exception { - List devicelist = ultrasonicService.getreporttemplate(); - List filteredList = new ArrayList<>(); //当前登陆用户 AdminUserDO user = userService.getUser(getLoginUserId()); + orgID= user.getOrgId(); + List devicelist = ultrasonicService.getreporttemplate(); + List filteredList = new ArrayList<>(); + // 按照 updateTime 字段降序排列,空值放在最后 List sortedList = devicelist.stream() .sorted(Comparator.comparing(ultrasonicDO::getUpdateTime, Comparator.nullsLast(Comparator.reverseOrder()))) @@ -91,8 +93,9 @@ public class ultrasonicController { if (!orgID.isEmpty()) { + String finalOrgID = orgID; filteredList = devicelist.stream() - .filter(ultrasonicDO -> (ultrasonicDO.getOrgId().equals(orgID))) + .filter(ultrasonicDO -> (ultrasonicDO.getOrgId().equals(finalOrgID))) .collect(Collectors.toList()); } if (filteredList.isEmpty()) { @@ -104,13 +107,29 @@ public class ultrasonicController { .filter(ultrasonicDO -> (ultrasonicDO.getTemplateType().equals(type))) .collect(Collectors.toList()); } +// 私有 if (isprivate.equals("1")) { - // 筛选条件: + // 筛选条件: 私有不需要排序 没有父节点 filteredList = filteredList.stream() .filter(ultrasonicDO -> Objects.equals(ultrasonicDO.getPrivateDoctorId(), user.getDoctorID())) .collect(Collectors.toList()); - } + } + else// 共有 + { + // 筛选条件: + filteredList = filteredList.stream() + .filter(ultrasonicDO -> ultrasonicDO.getPrivateDoctorId().isEmpty()) + .collect(Collectors.toList()); + + // 定义一个比较器,先按pid是否为"0"排序,然后按pid的自然顺序排序 + Comparator comparator = Comparator + .comparing((ultrasonicDO u) -> u.getPid().equals("0") ? "0" : "1") + .thenComparing(ultrasonicDO::getPid); + + // 对过滤后的列表进行排序 + filteredList.sort(comparator); + } ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeValueAsString(filteredList); @@ -132,10 +151,11 @@ public class ultrasonicController { } Map treeMap = new HashMap<>(); - + List treeList = new ArrayList<>(); for (Map data : dataList) { String pid = (String) data.get("pid"); String id = (String) data.get("id"); + String privateId = (String) data.get("privateDoctorId"); Tree tree = new Tree(); tree.id = id; @@ -153,9 +173,14 @@ public class ultrasonicController { } parent.children.add(tree); } + else if(privateId!=null && !privateId.isEmpty())//判断是否是私有模版 私有的直接加到树里面 + { + treeList.add(tree); + } + } - List treeList = new ArrayList<>(); + for (Tree tree : treeMap.values()) { if ("0".equals(tree.pid)) { treeList.add(tree); diff --git a/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/dal/ultrasonic/ultrasonicMapper.java b/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/dal/ultrasonic/ultrasonicMapper.java index bf200bca8..1efc6219b 100644 --- a/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/dal/ultrasonic/ultrasonicMapper.java +++ b/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/dal/ultrasonic/ultrasonicMapper.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.ultrasoniccom.dal.ultrasonic; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; diff --git a/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/service/ultrasonic/ultrasonicServiceImpl.java b/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/service/ultrasonic/ultrasonicServiceImpl.java index c1618ba82..dcc71e125 100644 --- a/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/service/ultrasonic/ultrasonicServiceImpl.java +++ b/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/service/ultrasonic/ultrasonicServiceImpl.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.ultrasoniccom.dal.ultrasonic.medicalimg.medicalim import cn.iocoder.yudao.module.ultrasoniccom.dal.ultrasonic.ultrasonicDO; import cn.iocoder.yudao.module.ultrasoniccom.dal.ultrasonic.ultrasonicMapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import cn.iocoder.yudao.module.ultrasoniccom.dal.ultrasonic.medicalimg.medicalimgMapper;