修改超声 影像 诊断模版获取方法
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled

This commit is contained in:
lxd 2024-08-31 05:07:39 +08:00
parent f176635e4f
commit 515e2261af
3 changed files with 34 additions and 7 deletions

View File

@ -79,10 +79,12 @@ public class ultrasonicController {
@DataPermission(enable = false)
@PreAuthorize("@ss.hasPermission('ultrasoniccom:ultrasonic:create')")
public CommonResult<List<Tree>> getreporttemplatelist(@RequestParam("orgID") String orgID, @RequestParam("type") String type, @RequestParam("isprivate") String isprivate) throws Exception {
List<ultrasonicDO> devicelist = ultrasonicService.getreporttemplate();
List<ultrasonicDO> filteredList = new ArrayList<>();
//当前登陆用户
AdminUserDO user = userService.getUser(getLoginUserId());
orgID= user.getOrgId();
List<ultrasonicDO> devicelist = ultrasonicService.getreporttemplate();
List<ultrasonicDO> filteredList = new ArrayList<>();
// 按照 updateTime 字段降序排列空值放在最后
List<ultrasonicDO> 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<ultrasonicDO> 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<String, Tree> treeMap = new HashMap<>();
List<Tree> treeList = new ArrayList<>();
for (Map<String, Object> 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<Tree> treeList = new ArrayList<>();
for (Tree tree : treeMap.values()) {
if ("0".equals(tree.pid)) {
treeList.add(tree);

View File

@ -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;

View File

@ -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;