lige
2024-04-18 ed277ece348dae9bc6e36c0fc9f69ae8a3825912
ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java
@@ -10,18 +10,20 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import com.ltkj.common.core.domain.TreeSelect;
import com.ltkj.common.core.domain.entity.SysRole;
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.common.core.redis.RedisCache;
import com.ltkj.common.core.text.Convert;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.common.utils.bean.BeanUtils;
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.mapper.TestMapper;
import com.ltkj.hosp.service.*;
import com.ltkj.system.domain.SysPost;
import com.ltkj.system.domain.SysUserPost;
import com.ltkj.system.service.ISysPostService;
import com.ltkj.system.service.ISysUserPostService;
import com.ltkj.system.service.ISysUserService;
import com.ltkj.system.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -44,7 +46,6 @@
import com.ltkj.common.core.domain.entity.SysDept;
import com.ltkj.common.enums.BusinessType;
import com.ltkj.common.utils.StringUtils;
import com.ltkj.system.service.ISysDeptService;
import javax.annotation.Resource;
@@ -97,7 +98,10 @@
    private ITjRulesService tjRulesService;
    @Autowired
    public RedisTemplate<Object,Object> redisTemplate;
    @Resource
    private TestMapper testMapper;
    @Autowired
    private ISysConfigService configService;
    /**
     * 该体检科室下客户列表显示接口
@@ -391,7 +395,9 @@
                            StringBuilder stringBuilder = new StringBuilder();
                            for (TjOrderRemark remark : list) {
                                TjProject byId = projectService.getById(remark.getProId());
                                stringBuilder.append(byId.getProName()).append(";");
                                if(null !=byId){
                                    stringBuilder.append(byId.getProName()).append(";");
                                }
                            }
                            customer.setNotCheckeds(String.valueOf(stringBuilder));
                            if (null == customer.getNotCheckeds()) customer.setNotCheckeds("全部已检");
@@ -422,47 +428,57 @@
                                 @ApiParam(value = "姓名)") @RequestParam(required = false) String name,
                                 @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
                                 @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize) {
        String userId = SecurityUtils.getLoginUser().getUserId();
        Integer ksId = null;
        SysUser sysUser = null;
        if (null != userId) {
            sysUser = userService.getById(Long.valueOf(userId));
            if (null != sysUser) {
                ksId = Math.toIntExact(sysUser.getDeptId());
            }
        }
        if (ksId == null) {
            return AjaxResult.error("请输入科室id");
        }
//        String userId = SecurityUtils.getLoginUser().getUserId();
//        Integer ksId = null;
//        SysUser sysUser = null;
//        if (null != userId) {
//            sysUser = userService.getById(Long.valueOf(userId));
//            if (null != sysUser) {
//                ksId = Math.toIntExact(sysUser.getDeptId());
//            }
//        }
//        if (ksId == null) {
//            return AjaxResult.error("请输入科室id");
//        }
        //A30化验
        //根据当前登陆的人的科室id,获取该科室下的所有项目
        List<Long> postIds = sysUser.getPostIds();
//        List<Long> postIds = sysUser.getPostIds();
        List<Long> ksproList = null;
        if (postIds != null) {
            for (Long postId : postIds) {
                LambdaQueryWrapper<SysUserPost> wq111 = new LambdaQueryWrapper<>();
                wq111.eq(SysUserPost::getPostId, postId);
                SysUserPost one = userPostService.getOne(wq111);
                if (one != null) {
                    SysPost byId = postService.getById(one.getPostId());
                    if (byId.getPostName().equals("录入员")) {
                        ksproList = projectService.getKsTjProjectIdListBydeptId(String.valueOf(ksId));
                    }
                }
            }
        } else {
            ksproList = projectService.getKsTjProjectIdList();
        }
//        if (postIds != null) {
//            for (Long postId : postIds) {
//                LambdaQueryWrapper<SysUserPost> wq111 = new LambdaQueryWrapper<>();
//                wq111.eq(SysUserPost::getPostId, postId);
//                SysUserPost one = userPostService.getOne(wq111);
//                if (one != null) {
//                    SysPost byId = postService.getById(one.getPostId());
//                    if (byId.getPostName().equals("录入员")) {
//                        ksproList = projectService.getKsTjProjectIdListBydeptId(String.valueOf(ksId));
//                    }
//                }
//            }
//        } else {
//            ksproList = projectService.getKsTjProjectIdList();
//        }
//        if(sysUser.getUserName().equals("10001")){
            ksproList = projectService.getHuaYanProId();
//        }
//        else {
//            ksproList = projectService.getKsTjProjectIdListBydeptId(String.valueOf(ksId));
//        }
        if (ksproList == null || ksproList.size() == 0) {
            return AjaxResult.error("请完善科室项目信息");
        }
        //筛选化验的项目。
        ksproList = ksproList.stream()
                .filter(element -> element ==1633660948860522629L)
                .collect(Collectors.toList());
//        ksproList = ksproList.stream()
//                .filter(element -> element ==1633660948860522629L)
//                .collect(Collectors.toList());
        List<TjCustomer> customerLis = new ArrayList<>();
        //根据体检号查
/*        //根据体检号查
        if (null != tjNumber) {
            List<TjOrder> orderList = orderService.getOrderListByLikeTjNum(tjNumber);
            if (null == orderList) {
@@ -598,17 +614,197 @@
                return AjaxResult.success("暂无数据");
            }
        }
        List<TjCustomer> customerLists = null;
        List<TjCustomer> customerLists = null;*/
//        //根据体检号查
//        if (null != tjNumber) {
//            List<TjOrder> orderList = orderService.getOrderListByLikeTjNum(tjNumber);
//            if (null == orderList) {
//                return AjaxResult.success("暂时没有数据");
//            }
//            for (TjOrder order : orderList) {
//                List<TjOrderDetail> list = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get();
//                if (list.size() == 0) {
//                    continue;
//                }
//                LambdaQueryWrapper<TjOrderRemark> wqs = new LambdaQueryWrapper<>();
//                wqs.eq(TjOrderRemark::getTjNumber, order.getTjNumber());
//                wqs.in(TjOrderRemark::getType, 0,3);
//                List<TjOrderRemark> lists = remarkService.list(wqs);
//                TjCustomer customer = customerService.getById(order.getUserId());
//
//                //遍历项目 判断是否有重大阳性  标记
//                for (TjOrderDetail tjOrderDetail11 : list) {
//                    customer.setIsPositive(tjOrderDetail11.getIsPositive());
//                    if (tjOrderDetail11.getIsPositive()==1){
//                        break;
//                    }
//                }
//
//                customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
//                customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
//                customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
//                if (null != lists && lists.size() > 0) {
//                    StringBuilder stringBuilder = new StringBuilder();
//                    for (TjOrderRemark remark : lists) {
//                        TjProject byId = projectService.selectTjProjectByProId(remark.getProId());
//                        TjOrderDetail one = detailService.getTjOrderDetailByOrderId(String.valueOf(order.getOrderId()), String.valueOf(byId.getProId()));
//                        if (one.getFlowingWaterId() != null) {
//                            stringBuilder.append(byId.getProName()).append(";");
//                        }
//
//                    }
//                    customer.setNotCheckeds(String.valueOf(stringBuilder));
//                    customer.setTjStatus(0L);
//                } else {
//                    customer.setTjStatus(1L);
//                    customer.setNotCheckeds("无");
//                }
//                if (order.getTjType().equals("1")) {
//                    customer.setTjType("团体");
//                }
//                if (order.getTjType().equals("2")) {
//                    customer.setTjType("个人");
//                }
//                customer.setTjTime(order.getCreateTime());
//                customer.setTjNumber(order.getTjNumber());
//                customer.setOrderId(order.getOrderId());
//                customer.setIsHz(order.getIsHz());
//                customer.setTjCategory(order.getTjCategory());
//                customerLis.add(customer);
//            }
//            if (customerLis.size() > 0) {
//                List<TjCustomer> customerList = customerLis.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
//                Collections.reverse(customerList);
//                Map<String, Object> map = new HashMap<>();
//                map.put("date", customerList);
//                map.put("total", customerLis.size());
//                return AjaxResult.success(map);
//            } else {
//                return AjaxResult.success("暂无数据");
//            }
//        }
//
//        //根据姓名查询
//        if (null != name && !"".equals(name)) {
//            LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
//            wq.like(TjCustomer::getCusName, name);
//            List<TjCustomer> list = customerService.list(wq);
//            List<TjCustomer> list11111 = new ArrayList<>();
//            if (null != list && list.size() > 0) {
//                for (TjCustomer customer : list) {
//                    customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
//                    customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
//                    customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
//                    List<TjOrder> orderList = orderService.getOrderListByCusId(String.valueOf(customer.getCusId()));
//                    if (null != orderList && orderList.size() > 0) {
//                        for (TjOrder order : orderList) {
//                            List<TjOrderDetail> list111 = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get();
//                            if (list111.size() == 0) {
//                                continue;
//                            }
//                            //遍历项目 判断是否有重大阳性  标记
//                            for (TjOrderDetail tjOrderDetail11 : list111) {
//                                customer.setIsPositive(tjOrderDetail11.getIsPositive());
//                                if (tjOrderDetail11.getIsPositive()==1){
//                                    break;
//                                }
//                            }
//                            List<TjOrderRemark> lists = remarkService.getTjOrderRemarkListByYjNum(order.getTjNumber());
//                            if (null != lists && lists.size() > 0) {
//                                StringBuilder stringBuilder = new StringBuilder();
//                                for (TjOrderRemark remark : lists) {
//                                    TjProject byId = projectService.selectTjProjectByProId(remark.getProId());
//                                    TjOrderDetail one = detailService.getTjOrderDetailByOrderId(String.valueOf(order.getOrderId()), String.valueOf(byId.getProId()));
//                                    if (one.getFlowingWaterId() != null) {
//                                        stringBuilder.append(byId.getProName()).append(";");
//                                    }
//                                }
//                                customer.setNotCheckeds(String.valueOf(stringBuilder));
//                                if (null == customer.getNotCheckeds()) customer.setNotCheckeds("全部已检");
//                                customer.setTjStatus(0L);
//                            } else {
//                                customer.setNotCheckeds("无");
//                                customer.setTjStatus(1L);
//                            }
//                            if (order.getTjType().equals("1")) {
//                                customer.setTjType("团体");
//                            }
//                            if (order.getTjType().equals("2")) {
//                                customer.setTjType("个人");
//                            }
//                            customer.setTjTime(order.getCreateTime());
//                            customer.setTjNumber(order.getTjNumber());
//                            customer.setOrderId(order.getOrderId());
//                            customer.setIsHz(order.getIsHz());
//                            customer.setTjCategory(order.getTjCategory());
//                            list11111.add(customer);
//                        }
//                    }
//                }
//                if (list11111.size() == 0) {
//                    return AjaxResult.success("暂无数据");
//                }
//                Map<String, Object> map = new HashMap<>();
//                List<TjCustomer> customers = list11111.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
//                Collections.reverse(customers);
//                map.put("customers", customers);
//                map.put("total", list11111.size());
//                return AjaxResult.success(map);
//            } else {
//                return AjaxResult.success("暂无数据");
//            }
//        }
//        List<TjCustomer> customerLists = new ArrayList<>();
//        String key="*";
//        if(sysUser.isAdmin()){
//            key="ks"+":*";
//        }else {
//            key="ks:"+ksId+":*";
//        }
//        ScanOptions options = ScanOptions.scanOptions()
//                //这里指定每次扫描key的数量(很多博客瞎说要指定Integer.MAX_VALUE,这样的话跟        keys有什么区别?)
//                .count(10000)
//                .match(key).build();
//        RedisSerializer<String> redisSerializer = (RedisSerializer<String>) redisTemplate.getKeySerializer();
//        0未检,1已检
        Map<String,Object> map=null;
        if (type == 0) {
//            Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize));
//            List<TjCustomer> customers = new ArrayList<>();
//            while(cursor.hasNext()){
//                String s = cursor.next().toString();
//                TjCustomer wj = redisCache.getCacheMapValue(s,"0");
//                if(null !=wj){
//                    customers.add(wj);
//                }
//            }
////            //切记这里一定要关闭,否则会耗尽连接数。报Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a
//            cursor.close();
//            customerLists = redisCache.getCacheMapValue(ksId + "ks", "wj");
            map = deptService.getSysDeptHyAndYxYjWjCustomerList13("A30", name, tjNumber, 0, page, pageSize);
//            customerLists = customers;
        }
        if (type == 1) {
//            Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize));
//            List<TjCustomer> customers = new ArrayList<>();
//            while(cursor.hasNext()){
//                String s = cursor.next().toString();
//                TjCustomer wj = redisCache.getCacheMapValue(s,"1");
//                if(null !=wj){
//                    customers.add(wj);
//                }
//            }
////            //切记这里一定要关闭,否则会耗尽连接数。报Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a
//            cursor.close();
//            customerLists = redisCache.getCacheMapValue(ksId + "ks", "yj");
            map = deptService.getSysDeptHyAndYxYjWjCustomerList13("A30", name, tjNumber, 1, page, pageSize);
//            customerLists = customers;
        }
        asyncService.dockerSetCustomerLisByRedis(ksproList, String.valueOf(ksId));
        AjaxResult map = getAjaxResult(type, page, pageSize, ksproList, customerLis);
        if (map != null) return map;
        return AjaxResult.success("暂时没有数据");
//        asyncService.dockerSetCustomerLisByRedis(ksproList, String.valueOf(ksId));
//        AjaxResult map = getAjaxResult(type, page, pageSize, ksproList, customerLis);
//        if (map != null) return map;
        return AjaxResult.success(map);
    }
@@ -622,7 +818,7 @@
                                       @ApiParam(value = "姓名)") @RequestParam(required = false) String name,
                                       @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
                                       @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize) {
        String userId = SecurityUtils.getLoginUser().getUserId();
/*        String userId = SecurityUtils.getLoginUser().getUserId();
        Integer ksId = null;
        SysUser sysUser = null;
        if (null != userId) {
@@ -653,7 +849,7 @@
        } else {
            ksproList = projectService.getKsTjProjectIdList();
        }
        //筛选影像的项目。
        //筛选影像的项目。 A32影像
        if (ksproList.size() == 0) {
            return AjaxResult.error("请完善科室项目信息");
        }
@@ -671,151 +867,181 @@
//                        ||
//                        element ==1633660948860522531L||  element ==1633660948860522533L
                )
                .collect(Collectors.toList());
        List<TjCustomer> customerLis = new ArrayList<>();
                .collect(Collectors.toList());*/
        //根据体检号查
        if (null != tjNumber) {
            List<TjOrder> orderList = orderService.getOrderListByLikeTjNum(tjNumber);
            if (null == orderList) {
                return AjaxResult.success("暂时没有数据");
            }
            for (TjOrder order : orderList) {
                List<TjOrderDetail> list = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get();
                if (list.size() == 0) {
                    continue;
                }
                LambdaQueryWrapper<TjOrderRemark> wqs = new LambdaQueryWrapper<>();
                wqs.eq(TjOrderRemark::getTjNumber, order.getTjNumber());
                wqs.in(TjOrderRemark::getType, 0,3);
                List<TjOrderRemark> lists = remarkService.list(wqs);
                TjCustomer customer = customerService.getById(order.getUserId());
                //遍历项目 判断是否有重大阳性  标记
                for (TjOrderDetail tjOrderDetail11 : list) {
                    customer.setIsPositive(tjOrderDetail11.getIsPositive());
                    if (tjOrderDetail11.getIsPositive()==1){
                        break;
                    }
                }
                customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
                customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
                customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
                if (null != lists && lists.size() > 0) {
                    StringBuilder stringBuilder = new StringBuilder();
                    for (TjOrderRemark remark : lists) {
                        TjProject byId = projectService.selectTjProjectByProId(remark.getProId());
                        TjOrderDetail one = detailService.getTjOrderDetailByOrderId(String.valueOf(order.getOrderId()), String.valueOf(byId.getProId()));
                        if (one.getFlowingWaterId() != null) {
                            stringBuilder.append(byId.getProName()).append(";");
                        }
                    }
                    customer.setNotCheckeds(String.valueOf(stringBuilder));
                    customer.setTjStatus(0L);
                } else {
                    customer.setTjStatus(1L);
                    customer.setNotCheckeds("无");
                }
                if (order.getTjType().equals("1")) {
                    customer.setTjType("团体");
                }
                if (order.getTjType().equals("2")) {
                    customer.setTjType("个人");
                }
                customer.setTjTime(order.getCreateTime());
                customer.setTjNumber(order.getTjNumber());
                customer.setOrderId(order.getOrderId());
                customer.setIsHz(order.getIsHz());
                customerLis.add(customer);
            }
            if (customerLis.size() > 0) {
                List<TjCustomer> customerList = customerLis.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                Collections.reverse(customerList);
                Map<String, Object> map = new HashMap<>();
                map.put("date", customerList);
                map.put("total", customerLis.size());
                return AjaxResult.success(map);
            } else {
                return AjaxResult.success("暂无数据");
            }
        }
        //根据姓名查询
        if (null != name && !"".equals(name)) {
            LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
            wq.like(TjCustomer::getCusName, name);
            List<TjCustomer> list = customerService.list(wq);
            List<TjCustomer> list11111 = new ArrayList<>();
            if (null != list && list.size() > 0) {
                for (TjCustomer customer : list) {
                    customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
                    customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
                    customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
                    List<TjOrder> orderList = orderService.getOrderListByCusId(String.valueOf(customer.getCusId()));
                    if (null != orderList && orderList.size() > 0) {
                        for (TjOrder order : orderList) {
                            List<TjOrderDetail> list111 = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get();
                            if (list111.size() == 0) {
                                continue;
                            }
                            //遍历项目 判断是否有重大阳性  标记
                            for (TjOrderDetail tjOrderDetail11 : list111) {
                                customer.setIsPositive(tjOrderDetail11.getIsPositive());
                                if (tjOrderDetail11.getIsPositive()==1){
                                    break;
                                }
                            }
                            List<TjOrderRemark> lists = remarkService.getTjOrderRemarkListByYjNum(order.getTjNumber());
                            if (null != lists && lists.size() > 0) {
                                StringBuilder stringBuilder = new StringBuilder();
                                for (TjOrderRemark remark : lists) {
                                    TjProject byId = projectService.selectTjProjectByProId(remark.getProId());
                                    TjOrderDetail one = detailService.getTjOrderDetailByOrderId(String.valueOf(order.getOrderId()), String.valueOf(byId.getProId()));
                                    if (one.getFlowingWaterId() != null) {
                                        stringBuilder.append(byId.getProName()).append(";");
                                    }
                                }
                                customer.setNotCheckeds(String.valueOf(stringBuilder));
                                if (null == customer.getNotCheckeds()) customer.setNotCheckeds("全部已检");
                                customer.setTjStatus(0L);
                            } else {
                                customer.setNotCheckeds("无");
                                customer.setTjStatus(1L);
                            }
                            if (order.getTjType().equals("1")) {
                                customer.setTjType("团体");
                            }
                            if (order.getTjType().equals("2")) {
                                customer.setTjType("个人");
                            }
                            customer.setTjTime(order.getCreateTime());
                            customer.setTjNumber(order.getTjNumber());
                            customer.setOrderId(order.getOrderId());
                            customer.setIsHz(order.getIsHz());
                            list11111.add(customer);
                        }
                    }
                }
                if (list11111.size() == 0) {
                    return AjaxResult.success("暂无数据");
                }
                Map<String, Object> map = new HashMap<>();
                List<TjCustomer> customers = list11111.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                Collections.reverse(customers);
                map.put("customers", customers);
                map.put("total", list11111.size());
                return AjaxResult.success(map);
            } else {
                return AjaxResult.success("暂无数据");
            }
        }
        List<TjCustomer> customerLists = null;
//        List<Long> ksproList  = projectService.getYingXiangProId();
//        List<TjCustomer> customerLis = new ArrayList<>();
//
//        //根据体检号查
//        if (null != tjNumber) {
//            List<TjOrder> orderList = orderService.getOrderListByLikeTjNum(tjNumber);
//            if (null == orderList) {
//                return AjaxResult.success("暂时没有数据");
//            }
//            for (TjOrder order : orderList) {
//                List<TjOrderDetail> list = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get();
//                if (list.size() == 0) {
//                    continue;
//                }
//                LambdaQueryWrapper<TjOrderRemark> wqs = new LambdaQueryWrapper<>();
//                wqs.eq(TjOrderRemark::getTjNumber, order.getTjNumber());
//                wqs.in(TjOrderRemark::getType, 0,3);
//                List<TjOrderRemark> lists = remarkService.list(wqs);
//                TjCustomer customer = customerService.getById(order.getUserId());
//                //遍历项目 判断是否有重大阳性  标记
//                for (TjOrderDetail tjOrderDetail11 : list) {
//                    customer.setIsPositive(tjOrderDetail11.getIsPositive());
//                    if (tjOrderDetail11.getIsPositive()==1){
//                        break;
//                    }
//                }
//                customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
//                customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
//                customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
//                if (null != lists && lists.size() > 0) {
//                    StringBuilder stringBuilder = new StringBuilder();
//                    for (TjOrderRemark remark : lists) {
//                        TjProject byId = projectService.selectTjProjectByProId(remark.getProId());
//                        TjOrderDetail one = detailService.getTjOrderDetailByOrderId(String.valueOf(order.getOrderId()), String.valueOf(byId.getProId()));
//                        if (one.getFlowingWaterId() != null) {
//                            stringBuilder.append(byId.getProName()).append(";");
//                        }
//
//                    }
//                    customer.setNotCheckeds(String.valueOf(stringBuilder));
//                    customer.setTjStatus(0L);
//                } else {
//                    customer.setTjStatus(1L);
//                    customer.setNotCheckeds("无");
//                }
//                if (order.getTjType().equals("1")) {
//                    customer.setTjType("团体");
//                }
//                if (order.getTjType().equals("2")) {
//                    customer.setTjType("个人");
//                }
//                customer.setTjTime(order.getCreateTime());
//                customer.setTjNumber(order.getTjNumber());
//                customer.setOrderId(order.getOrderId());
//                customer.setIsHz(order.getIsHz());
//                customerLis.add(customer);
//
//            }
//            if (customerLis.size() > 0) {
//                List<TjCustomer> customerList = customerLis.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
//                Collections.reverse(customerList);
//                Map<String, Object> map = new HashMap<>();
//                map.put("date", customerList);
//                map.put("total", customerLis.size());
//                return AjaxResult.success(map);
//            } else {
//                return AjaxResult.success("暂无数据");
//            }
//        }
//
//        //根据姓名查询
//        if (null != name && !"".equals(name)) {
//            LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
//            wq.like(TjCustomer::getCusName, name);
//            List<TjCustomer> list = customerService.list(wq);
//            List<TjCustomer> list11111 = new ArrayList<>();
//            if (null != list && list.size() > 0) {
//                for (TjCustomer customer : list) {
//                    customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
//                    customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
//                    customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
//                    List<TjOrder> orderList = orderService.getOrderListByCusId(String.valueOf(customer.getCusId()));
//                    if (null != orderList && orderList.size() > 0) {
//                        for (TjOrder order : orderList) {
//                            List<TjOrderDetail> list111 = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get();
//                            if (list111.size() == 0) {
//                                continue;
//                            }
//                            //遍历项目 判断是否有重大阳性  标记
//                            for (TjOrderDetail tjOrderDetail11 : list111) {
//                                customer.setIsPositive(tjOrderDetail11.getIsPositive());
//                                if (tjOrderDetail11.getIsPositive()==1){
//                                    break;
//                                }
//                            }
//                            List<TjOrderRemark> lists = remarkService.getTjOrderRemarkListByYjNum(order.getTjNumber());
//                            if (null != lists && lists.size() > 0) {
//                                StringBuilder stringBuilder = new StringBuilder();
//                                for (TjOrderRemark remark : lists) {
//                                    TjProject byId = projectService.selectTjProjectByProId(remark.getProId());
//                                    TjOrderDetail one = detailService.getTjOrderDetailByOrderId(String.valueOf(order.getOrderId()), String.valueOf(byId.getProId()));
//                                    if (one.getFlowingWaterId() != null) {
//                                        stringBuilder.append(byId.getProName()).append(";");
//                                    }
//                                }
//                                customer.setNotCheckeds(String.valueOf(stringBuilder));
//                                if (null == customer.getNotCheckeds()) customer.setNotCheckeds("全部已检");
//                                customer.setTjStatus(0L);
//                            } else {
//                                customer.setNotCheckeds("无");
//                                customer.setTjStatus(1L);
//                            }
//                            if (order.getTjType().equals("1")) {
//                                customer.setTjType("团体");
//                            }
//                            if (order.getTjType().equals("2")) {
//                                customer.setTjType("个人");
//                            }
//                            customer.setTjTime(order.getCreateTime());
//                            customer.setTjNumber(order.getTjNumber());
//                            customer.setOrderId(order.getOrderId());
//                            customer.setIsHz(order.getIsHz());
//                            list11111.add(customer);
//                        }
//                    }
//                }
//                if (list11111.size() == 0) {
//                    return AjaxResult.success("暂无数据");
//                }
//                Map<String, Object> map = new HashMap<>();
//                List<TjCustomer> customers = list11111.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
//                Collections.reverse(customers);
//                map.put("customers", customers);
//                map.put("total", list11111.size());
//                return AjaxResult.success(map);
//            } else {
//                return AjaxResult.success("暂无数据");
//            }
//        }
//        List<TjCustomer> customerLists = null;
        Map<String,Object> map=null;
        if (type == 0) {
//            Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize));
//            List<TjCustomer> customers = new ArrayList<>();
//            while(cursor.hasNext()){
//                String s = cursor.next().toString();
//                TjCustomer wj = redisCache.getCacheMapValue(s,"0");
//                if(null !=wj){
//                    customers.add(wj);
//                }
//            }
////            //切记这里一定要关闭,否则会耗尽连接数。报Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a
//            cursor.close();
//            customerLists = redisCache.getCacheMapValue(ksId + "ks", "wj");
            map = deptService.getSysDeptHyAndYxYjWjCustomerList13("A32", name, tjNumber, 0, page, pageSize);
//            customerLists = customers;
        }
        if (type == 1) {
//            Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize));
//            List<TjCustomer> customers = new ArrayList<>();
//            while(cursor.hasNext()){
//                String s = cursor.next().toString();
//                TjCustomer wj = redisCache.getCacheMapValue(s,"1");
//                if(null !=wj){
//                    customers.add(wj);
//                }
//            }
////            //切记这里一定要关闭,否则会耗尽连接数。报Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a
//            cursor.close();
//            customerLists = redisCache.getCacheMapValue(ksId + "ks", "yj");
            map = deptService.getSysDeptHyAndYxYjWjCustomerList13("A32", name, tjNumber, 1, page, pageSize);
//            customerLists = customers;
        }
//        asyncService.dockerSetCustomerLisByRedis(ksproList, String.valueOf(ksId));
//        if (customerLists.size() > 0) {
@@ -826,11 +1052,39 @@
//            map.put("total", customerLists.size());
//            return AjaxResult.success(map);
//        } else {
            AjaxResult map = getAjaxResult(type, page, pageSize, ksproList, customerLis);
            if (map != null) return map;
            return AjaxResult.success("暂时没有数据");
//            AjaxResult map = getAjaxResult(type, page, pageSize, ksproList, customerLis);
//            if (map != null) return map;
//            return AjaxResult.success("暂时没有数据");
        return AjaxResult.success(map);
//        }
    }
    @GetMapping("/getTjYxjcList")
    @ApiOperation("查询个人影响检查项目结果集")
    public AjaxResult getTjYxjcList(@ApiParam(value = "姓名") @RequestParam String patname,
                                    @ApiParam(value = "性别") @RequestParam String sex,
                                    @ApiParam(value = "年龄") @RequestParam String patage,
                                    @ApiParam(value = "年龄单位") @RequestParam String patagename,
                                    @ApiParam(value = "生日)") @RequestParam Date patbirth) {
        String format = DateUtil.format(patbirth, "yyyy.MM.dd");
        List<Map<String, Object>> tjYxjcList = testMapper.getTjYxjcList(patname,sex,null);
        return AjaxResult.success(tjYxjcList);
    }
//    @GetMapping("/getSsTjYxjcList")
//    @ApiOperation("查询个人影响检查项目结果集(搜素用)")
//    public AjaxResult getSsTjYxjcList(@ApiParam(value = "姓名") @RequestParam String patname,
//                                    @ApiParam(value = "性别") @RequestParam String sex,
//                                    @ApiParam(value = "年龄") @RequestParam String patage) {
//
//
//        List<Map<String, Object>> tjYxjcList = testMapper.getTjYxjcList(patname,sex,null,null);
//        return AjaxResult.success(tjYxjcList);
//    }
@@ -983,6 +1237,10 @@
        return toAjax(deptService.insertDept(dept));
    }
    @Resource
    private IDictHospService dictHospService;
    /**
     * 修改科室部门
     */
@@ -1001,6 +1259,16 @@
            return error("该部门包含未停用的子部门!");
        }
        dept.setUpdateBy(getUsername());
        //查询院区名字赋值
        if (dept.getHospId()!=null){
            final DictHosp byId = dictHospService.getById(dept.getHospId());
            if (byId!=null){
                dept.setHospName(byId.getHospAreaName());
            }
        }
        return toAjax(deptService.updateDept(dept));
    }
@@ -1098,7 +1366,7 @@
                    if (null != summaryList && summaryList.size()>0 && !summaryList.contains(null)) {
                        one.setSummary(Joiner.on(";").join(orderRemark.getSummaryList()));
                    }
                    one.setDeptId(orderRemark.getDeptId());
//                    one.setDeptId(orderRemark.getDeptId());
                    one.setDoctorName(orderRemark.getDoctorName());
                    one.setType(1);
                    remarkService.updateById(one);
@@ -1132,6 +1400,35 @@
            }
            ksId = Math.toIntExact(sysUser.getDeptId());
        }
        String config = configService.selectConfigByKey("qt_open_xdt");
        String byKey = configService.selectConfigByKey("qt_kjksid");
        List<Integer> split = new ArrayList<>(); // 存放转换后的integer类型结果
        if("Y".equals(config)){
            List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
            if(null !=roles && roles.size()>0){
                List<SysRole> list = roles.stream().filter(item -> item.getRoleName().contains("前台")).collect(Collectors.toList());
                if(list.size()>0){
                    if(null !=ksId && ksId==100){
                        ksId=999;
                    }
                    if(null !=byKey && !"".equals(byKey)){
                        String[] arr = byKey.split(","); // 根据逗号进行切割
                        for (String s : arr) {
                            int num = Integer.parseInt(s); // 将每个子字符串转换为integer类型
                            split.add(num); // 添加到列表中
                        }
                    }
                }else {
                    split.add(ksId);
                }
            }else {
                split.add(ksId);
            }
        }else {
            split.add(ksId);
        }
        //判断当前登陆的人是不是管理员。管理员可以看当前体检号下所有项目
//        if (sysUser.getUserName().equals("10001")) {
//            QueryWrapper<TjOrderRemark> wqq = new QueryWrapper<>();
@@ -1150,7 +1447,7 @@
//        }
        LambdaQueryWrapper<TjProject> wq2 = new LambdaQueryWrapper<>();
        if ((null != sysUser && !sysUser.getUserName().equals("10001")) && 100!=ksId) {
            wq2.eq(TjProject::getDeptId, ksId);
            wq2.in(TjProject::getDeptId,split);
        }
        //判断该项目是否需要打印报告
        wq2.eq(TjProject::getNeedReport,"Y");
@@ -1167,6 +1464,7 @@
            wqq.eq(TjOrderDetail::getOrderId, one.getOrderId());
            wqq.isNotNull(TjOrderDetail::getFlowingWaterId);
            wqq.in(TjOrderDetail::getProId, proIdList);
            wqq.notIn(TjOrderDetail::getProId, proIdList,projectService.getNneedReprotProId());
            List<TjOrderDetail> detailList = detailService.list(wqq);
            if (detailList != null && detailList.size() > 0) {
                List<Long> collect = detailList.stream().map(TjOrderDetail::getProId).collect(Collectors.toList());
@@ -1174,6 +1472,8 @@
                wq.eq("tj_number", tjNumber);
                wq.in("pro_id", collect);
                wq.ne("type", 2);
                wq.ne("dept_id",241);
                wq.notIn("pro_id", proIdList,projectService.getNneedReprotProId());
                List<TjOrderRemark> list = remarkService.list(wq);
                if (list.size() == 0) {
                    return AjaxResult.success("该科室下无项目!");
@@ -1210,7 +1510,10 @@
//        }
        TjOrderRemark remark = remarkService.getTjOrderRemarkByTjNumAndProParentId(tjNumber, proParentId);
        List<TjProject> proParentList = projectService.getTjProjectListBySoneId(proParentId);
//        List<TjProject> proParentList = projectService.getTjProjectListBySoneId(proParentId);
        List<TjProject> proParentList = projectService.getTjProjectListByTbTransition(proParentId,tjNumber);
        if (null == proParentList || proParentList.size()==0) {
            Map<String, Object> map = new HashMap<>();
            map.put("xiaoJieIds", null);
@@ -1387,7 +1690,8 @@
    @GetMapping("/deptTree111")
    @ApiOperation("获取部门树列表1111111111")
    public AjaxResult deptTree111(SysDept dept) {
        return success(deptService.selectDeptTreeList1(dept));
        final List<TreeSelect> treeSelects = deptService.selectDeptTreeList1(dept);
        return success(treeSelects);
    }