package com.ltkj.web.controller.system; import java.io.*; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; import cn.hutool.core.date.DateUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 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.*; import com.ltkj.web.controller.his.HisApiGetMethodService; import com.ltkj.web.wxUtils.HttpClientUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import jodd.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.ibatis.jdbc.Null; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.ConvertingCursor; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import com.ltkj.common.annotation.Log; import com.ltkj.common.constant.UserConstants; import com.ltkj.common.core.controller.BaseController; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.core.domain.entity.SysDept; import com.ltkj.common.enums.BusinessType; import com.ltkj.common.utils.StringUtils; import javax.annotation.Resource; /** * 部门信息 * * @author ltkj */ @RestController @RequestMapping("/system/dept") @Api(tags = "科室部门信息") @Slf4j public class SysDeptController extends BaseController implements Serializable { @Resource private ISysDeptService deptService; @Resource private ITjCustomerService customerService; @Resource private ITjProjectService projectService; @Autowired private ITjRuleAdviceService tjRuleAdviceService; @Resource private ITjOrderService orderService; @Resource private ITjOrderRemarkService remarkService; @Resource private ITjOrderDetailService detailService; @Resource private ISysUserService userService; @Resource private ITjStandardService tjStandardService; @Resource private ITjAdviceService tjAdviceService; @Resource private ITjCustomerService tjCustomerService; @Resource private ISysUserPostService userPostService; @Resource private ISysPostService postService; @Resource private TjAsyncService asyncService; @Resource private RedisCache redisCache; @Autowired private ITjOrderDetailRulesService tjOrderDetailRulesService; @Autowired private ITjRulesService tjRulesService; @Autowired public RedisTemplate redisTemplate; @Resource private TestMapper testMapper; @Autowired private ISysConfigService configService; @Autowired private ITjFlowingWaterService tjFlowingWaterService; @Autowired private HisApiGetMethodService hisApiGetMethodService; @Autowired private LtkjJianchajianyanTreeService ltkjJianchajianyanTreeService; @GetMapping("/getdangqiandengluyuanqu") @ApiOperation("获取当前登录人对应的院区名") public AjaxResult getdangqiandengluyuanqu() { Long deptId = SecurityUtils.getDeptId(); if (null != deptId) { SysDept dept = deptService.getById(deptId); if (null != dept) { String hospName = dept.getHospName(); return AjaxResult.success(hospName); } } return AjaxResult.success(); } /** * 该体检科室下客户列表显示接口 */ @GetMapping("/getProList") @ApiOperation("该体检科室下客户列表显示接口") public AjaxResult getProList(@ApiParam(value = "体检单号") @RequestParam(required = false) String tjNumber, @ApiParam(value = "0未检,1已检") @RequestParam(defaultValue = "0") Integer type, @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"); } //根据当前登陆的人的科室id,获取该科室下的所有项目 List postIds = sysUser.getPostIds(); List ksproList = null; if (postIds != null) { for (Long postId : postIds) { LambdaQueryWrapper 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 (ksproList == null || ksproList.size() == 0) { return AjaxResult.error("请完善科室项目信息"); } List customerLis = new ArrayList<>(); if (null == name) name = ""; if (null == tjNumber) tjNumber = ""; // //根据体检号查 // if (null != tjNumber) { // List orderList = orderService.getOrderListByLikeTjNum(tjNumber); // if (null == orderList) { // return AjaxResult.success("暂时没有数据"); // } // for (TjOrder order : orderList) { // List list = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get(); // if (list.size() == 0) { // continue; // } // LambdaQueryWrapper wqs = new LambdaQueryWrapper<>(); // wqs.eq(TjOrderRemark::getTjNumber, order.getTjNumber()); // wqs.in(TjOrderRemark::getType, 0,3); // List 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 customerList = customerLis.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); // Collections.reverse(customerList); // Map 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 wq = new LambdaQueryWrapper<>(); // wq.like(TjCustomer::getCusName, name); // List list = customerService.list(wq); // List 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 orderList = orderService.getOrderListByCusId(String.valueOf(customer.getCusId())); // if (null != orderList && orderList.size() > 0) { // for (TjOrder order : orderList) { // List 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 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 map = new HashMap<>(); // List 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 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 redisSerializer = (RedisSerializer) redisTemplate.getKeySerializer(); // 0未检,1已检 Map map = null; if (type == 0) { // Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize)); // List 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.getSysDeptYjWjCustomerList13(String.valueOf(ksId), name, tjNumber, 0, page, pageSize); // customerLists = customers; } if (type == 1) { // Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize)); // List 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.getSysDeptYjWjCustomerList13(String.valueOf(ksId), name, tjNumber, 1, page, pageSize); // customerLists = customers; } return AjaxResult.success(map); // asyncService.dockerSetCustomerLisByRedis(ksproList, String.valueOf(ksId)); // if (null !=customerLists && customerLists.size() > 0) { // Collections.reverse(customerLists); // List customerList = customerLists.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); // Map map = new HashMap<>(); // map.put("date", customerList); // 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("暂时没有数据"); // } } private AjaxResult getAjaxResult(Integer type, Integer page, Integer pageSize, List ksproList, List customerLis) { LambdaQueryWrapper wq1 = new LambdaQueryWrapper<>(); wq1.eq(TjOrderDetail::getTjStatus, type); wq1.in(TjOrderDetail::getProId, ksproList); wq1.isNotNull(TjOrderDetail::getFlowingWaterId); wq1.orderByDesc(TjOrderDetail::getCreateTime); List detailList = detailService.list(wq1); if (null != detailList && detailList.size() > 0) { //收集orderId并去重 List orderIds = detailList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection( () -> new TreeSet<>(Comparator.comparing(TjOrderDetail::getOrderId)) ), ArrayList::new)).stream().map(TjOrderDetail::getOrderId).collect(Collectors.toList()); for (Long orderId : orderIds) { if (null != orderId) { TjOrder order = orderService.getById(orderId); if (null == order) { continue; } if (type == 1) { List list = detailService.getTjOrderDetailListByOrderIdAndStatus(String.valueOf(orderId)); if (null != list && list.size() > 0) { continue; } } TjCustomer customer = customerService.getById(order.getUserId()); if (null != customer) { if (order.getTjType().equals("1")) { customer.setTjType("团体"); } if (order.getTjType().equals("2")) { customer.setTjType("个人"); } customer.setTjTime(order.getCreateTime()); customer.setTjNumber(order.getTjNumber()); customer.setOrderId(orderId); customer.setIsHz(order.getIsHz()); customer.setTjStatus(Long.valueOf(type)); List list = remarkService.getTjOrderRemarkListByYjNum(order.getTjNumber()); if (null != list && list.size() > 0) { StringBuilder stringBuilder = new StringBuilder(); for (TjOrderRemark remark : list) { TjProject byId = projectService.getById(remark.getProId()); if (null != byId) { stringBuilder.append(byId.getProName()).append(";"); } } customer.setNotCheckeds(String.valueOf(stringBuilder)); if (null == customer.getNotCheckeds()) customer.setNotCheckeds("全部已检"); } customerLis.add(customer); } } } if (customerLis.size() > 0) { List customerList = customerLis.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); Collections.reverse(customerList); Map map = new HashMap<>(); map.put("date", customerList); map.put("total", customerLis.size()); return AjaxResult.success(map); } } return null; } /** * 化验检查页面列表 */ @GetMapping("/huaYangetProList") @ApiOperation("化验检查页面列表") public AjaxResult huaYangetProList(@ApiParam(value = "体检单号") @RequestParam(required = false) String tjNumber, @ApiParam(value = "0未检,1已检") @RequestParam(defaultValue = "0") Integer type, @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"); // } //A30化验 //根据当前登陆的人的科室id,获取该科室下的所有项目 // List postIds = sysUser.getPostIds(); List ksproList = null; // if (postIds != null) { // for (Long postId : postIds) { // LambdaQueryWrapper 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()); List customerLis = new ArrayList<>(); /* //根据体检号查 if (null != tjNumber) { List orderList = orderService.getOrderListByLikeTjNum(tjNumber); if (null == orderList) { return AjaxResult.success("暂时没有数据"); } for (TjOrder order : orderList) { List list = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get(); if (list.size() == 0) { continue; } LambdaQueryWrapper wqs = new LambdaQueryWrapper<>(); wqs.eq(TjOrderRemark::getTjNumber, order.getTjNumber()); wqs.in(TjOrderRemark::getType, 0,3); List 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 customerList = customerLis.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); Collections.reverse(customerList); Map 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 wq = new LambdaQueryWrapper<>(); wq.like(TjCustomer::getCusName, name); List list = customerService.list(wq); List 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 orderList = orderService.getOrderListByCusId(String.valueOf(customer.getCusId())); if (null != orderList && orderList.size() > 0) { for (TjOrder order : orderList) { List 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 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 map = new HashMap<>(); List 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 customerLists = null;*/ // //根据体检号查 // if (null != tjNumber) { // List orderList = orderService.getOrderListByLikeTjNum(tjNumber); // if (null == orderList) { // return AjaxResult.success("暂时没有数据"); // } // for (TjOrder order : orderList) { // List list = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get(); // if (list.size() == 0) { // continue; // } // LambdaQueryWrapper wqs = new LambdaQueryWrapper<>(); // wqs.eq(TjOrderRemark::getTjNumber, order.getTjNumber()); // wqs.in(TjOrderRemark::getType, 0,3); // List 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 customerList = customerLis.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); // Collections.reverse(customerList); // Map 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 wq = new LambdaQueryWrapper<>(); // wq.like(TjCustomer::getCusName, name); // List list = customerService.list(wq); // List 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 orderList = orderService.getOrderListByCusId(String.valueOf(customer.getCusId())); // if (null != orderList && orderList.size() > 0) { // for (TjOrder order : orderList) { // List 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 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 map = new HashMap<>(); // List 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 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 redisSerializer = (RedisSerializer) redisTemplate.getKeySerializer(); // 0未检,1已检 Map map = null; if (type == 0) { // Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize)); // List 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 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(map); } /** * 影像检查页面列表 */ @GetMapping("/yingXiangGetProList") @ApiOperation("影像检查页面列表") public AjaxResult yingXiangGetProList(@ApiParam(value = "体检单号") @RequestParam(required = false) String tjNumber, @ApiParam(value = "0未检,1已检") @RequestParam(defaultValue = "0") Integer type, @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"); } //根据当前登陆的人的科室id,获取该科室下的所有项目 List postIds = sysUser.getPostIds(); List ksproList = null; if (postIds != null) { for (Long postId : postIds) { LambdaQueryWrapper 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(); } //筛选影像的项目。 A32影像 if (ksproList.size() == 0) { return AjaxResult.error("请完善科室项目信息"); } ksproList = ksproList.stream() .filter(element -> element ==1633660948860522589L // || element ==1633660948860522504L // || // element ==1633660948860522507L|| element ==1633660948860522508L // || // element ==1633660948860522515L|| element ==1633660948860522516L // || // element ==1633660948860522517L|| element ==1633660948860522519L // || // element ==1633660948860522524L|| element ==1633660948860522530L // || // element ==1633660948860522531L|| element ==1633660948860522533L ) .collect(Collectors.toList());*/ // List ksproList = projectService.getYingXiangProId(); // List customerLis = new ArrayList<>(); // // //根据体检号查 // if (null != tjNumber) { // List orderList = orderService.getOrderListByLikeTjNum(tjNumber); // if (null == orderList) { // return AjaxResult.success("暂时没有数据"); // } // for (TjOrder order : orderList) { // List list = Optional.ofNullable(detailService.getTjOrderDetailListByOrderId(String.valueOf(order.getOrderId()))).get(); // if (list.size() == 0) { // continue; // } // LambdaQueryWrapper wqs = new LambdaQueryWrapper<>(); // wqs.eq(TjOrderRemark::getTjNumber, order.getTjNumber()); // wqs.in(TjOrderRemark::getType, 0,3); // List 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 customerList = customerLis.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); // Collections.reverse(customerList); // Map 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 wq = new LambdaQueryWrapper<>(); // wq.like(TjCustomer::getCusName, name); // List list = customerService.list(wq); // List 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 orderList = orderService.getOrderListByCusId(String.valueOf(customer.getCusId())); // if (null != orderList && orderList.size() > 0) { // for (TjOrder order : orderList) { // List 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 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 map = new HashMap<>(); // List 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 customerLists = null; Map map = null; if (type == 0) { // Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize)); // List 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 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) { // Collections.reverse(customerLists); // List customerList = customerLists.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); // Map map = new HashMap<>(); // map.put("date", customerList); // 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("暂时没有数据"); 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> 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> tjYxjcList = testMapper.getTjYxjcList(patname,sex,null,null); // return AjaxResult.success(tjYxjcList); // } /** * 查询客户体检历史记录 * * @param cusId * @return */ @GetMapping("/getHistory") @ApiOperation("查询客户体检历史记录") //@PreAuthorize("@ss.hasPermi('system:dept:getHistory')") public AjaxResult getHistory(@RequestParam @ApiParam(value = "体检客户id") Long cusId) { Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId()); Integer ksId = null; SysUser sysUser = userService.getById(userId); if (null != sysUser) { ksId = Math.toIntExact(sysUser.getDeptId()); } if (ksId == null) { return AjaxResult.error("请输入科室id"); } LambdaQueryWrapper wq0 = new LambdaQueryWrapper<>(); if (!sysUser.getUserName().equals("10001")) { wq0.eq(TjProject::getDeptId, ksId); } wq0.in(TjProject::getDeleted, 0, 1); List projectList = projectService.list(wq0); if (projectList == null || projectList.size() <= 0) { return AjaxResult.error("请完善科室项目信息"); } List ksproList = projectList.stream().map(TjProject::getProId).collect(Collectors.toList()); LambdaQueryWrapper wq1 = new LambdaQueryWrapper<>(); wq1.eq(TjOrder::getUserId, cusId); List orderList = orderService.list(wq1); if (null != orderList && orderList.size() > 0) { List orderList0 = new ArrayList<>(); for (TjOrder tjOrder : orderList) { LambdaQueryWrapper wq2 = new LambdaQueryWrapper<>(); wq2.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId()); wq2.eq(TjOrderDetail::getTjStatus, 1); wq2.in(TjOrderDetail::getProId, ksproList); List detailList = detailService.list(wq2); tjOrder.setTjOrderList(detailList); orderList0.add(tjOrder); } return AjaxResult.success(orderList0); } return AjaxResult.success("暂时没有历史数据"); } /** * 查询客户体检历史记录 */ @GetMapping("/getHistoryDetail") @ApiOperation("查询客户体检历史记录详情") //@PreAuthorize("@ss.hasPermi('system:dept:getHistoryDetail')") public AjaxResult getHistoryDetail(@RequestParam @ApiParam(value = "体检客户id") Integer orderId) { Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId()); Integer ksId = null; SysUser sysUser = null; if (null != userId) { sysUser = userService.getById(userId); if (null != sysUser) { ksId = Math.toIntExact(sysUser.getDeptId()); } } if (ksId == null) { return AjaxResult.error("请输入科室id"); } LambdaQueryWrapper wq0 = new LambdaQueryWrapper<>(); if (!sysUser.getUserName().equals("10001")) { wq0.eq(TjProject::getDeptId, ksId); } List projectList = projectService.list(wq0); List ksproList = projectList.stream().map(TjProject::getProId).collect(Collectors.toList()); if (projectList == null) { return AjaxResult.error("请完善科室项目信息"); } LambdaQueryWrapper wq1 = new LambdaQueryWrapper<>(); wq1.eq(TjOrderDetail::getOrderId, orderId); wq1.in(TjOrderDetail::getProId, ksproList); wq1.eq(TjOrderDetail::getTjStatus, 1); List detailList = detailService.list(wq1); return AjaxResult.success(detailList); } /** * 获取科室部门列表 */ //@PreAuthorize("@ss.hasPermi('system:dept:list')") @GetMapping("/list") @ApiOperation(value = "获取科室部门列表") public AjaxResult list(SysDept dept) { List depts = deptService.selectDeptList(dept); if (depts != null) { for (SysDept sysDept : depts) { Long parentId = sysDept.getParentId(); if (parentId != 0) { SysDept sysDept1 = deptService.getById(parentId); String name = sysDept1.getDeptName(); if (null != name) sysDept.setParentName(name); } else { sysDept.setParentName(null); } } } return success(depts); } /** * 查询科室部门列表(排除节点) */ //@PreAuthorize("@ss.hasPermi('system:dept:excludeChild')") @GetMapping("/list/exclude/{deptId}") @ApiOperation(value = "查询科室部门列表(排除节点)") public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { List depts = deptService.selectDeptList(new SysDept()); depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); return success(depts); } /** * 根据科室部门编号获取详细信息 */ //@PreAuthorize("@ss.hasPermi('system:dept:getInfo')") @GetMapping(value = "/{deptId}") @ApiOperation(value = "根据科室部门编号获取详细信息") public AjaxResult getInfo(@PathVariable Long deptId) { deptService.checkDeptDataScope(deptId); return success(deptService.selectDeptById(deptId)); } /** * 新增科室部门 */ //@PreAuthorize("@ss.hasPermi('system:dept:add')") @Log(title = "部门管理", businessType = BusinessType.INSERT) @PostMapping @ApiOperation(value = "新增科室部门") public AjaxResult add(@Validated @RequestBody SysDept dept) { if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } dept.setCreateBy(getUsername()); return toAjax(deptService.insertDept(dept)); } @Resource private IDictHospService dictHospService; /** * 修改科室部门 */ //@PreAuthorize("@ss.hasPermi('system:dept:edit')") @Log(title = "部门管理", businessType = BusinessType.UPDATE) @PutMapping @ApiOperation(value = "修改科室部门") public AjaxResult edit(@Validated @RequestBody SysDept dept) { Long deptId = dept.getDeptId(); deptService.checkDeptDataScope(deptId); if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } else if (dept.getParentId().equals(deptId)) { return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) { 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)); } /** * 删除科室部门 */ //@PreAuthorize("@ss.hasPermi('system:dept:remove')") @Log(title = "部门管理", businessType = BusinessType.DELETE) @DeleteMapping("/{deptId}") @ApiOperation(value = "删除科室部门") public AjaxResult remove(@PathVariable Long deptId) { if (deptService.hasChildByDeptId(deptId)) { return warn("存在下级部门,不允许删除"); } if (deptService.checkDeptExistUser(deptId)) { return warn("部门存在用户,不允许删除"); } deptService.checkDeptDataScope(deptId); return toAjax(deptService.deleteDeptById(deptId)); } /** * 提交该科室下客户体检结果接口 */ @PostMapping("/addRemark") @ApiOperation("提交该科室下客户体检结果接口") @Transactional public AjaxResult addRemark(@ApiParam(value = "体检父项目备注集合") @RequestBody List remarklList) { Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId()); SysUser sysUser = userService.getById(userId); if (remarklList == null || remarklList.isEmpty()) { return AjaxResult.success("操作失败"); } for (TjOrderRemark orderRemark : remarklList) { List summaryList = orderRemark.getSummaryList(); if (null != summaryList && !summaryList.isEmpty() && !summaryList.contains(null)) { orderRemark.setSummary(Joiner.on(";").join(orderRemark.getSummaryList())); } else { orderRemark.setSummary(null); } if (StringUtils.isBlank(orderRemark.getRemark())) orderRemark.setRemark(null); LambdaQueryWrapper qw = new LambdaQueryWrapper<>(); qw.eq(TjOrder::getTjNumber, orderRemark.getTjNumber()); TjOrder order = orderService.getOne(qw); orderRemark.setDeptId(sysUser.getDeptId()); if (orderRemark.getDoctorName() == null) { orderRemark.setDoctorName(String.valueOf(sysUser.getUserId())); } List tjOrderDetailList = orderRemark.getTjOrderDetailList(); final TjCustomer byId1 = customerService.getById(order.getUserId()); if (null != tjOrderDetailList && !tjOrderDetailList.isEmpty()) { //----------------------------------start // for (TjOrderDetail tjOrderDetail : tjOrderDetailList) { // final TjProject byId = projectService.getById(tjOrderDetail.getProId()); // //给病种记录表存 方便统计病种和客户信息之间的关系 // if (tjOrderDetail.getRulesList()!=null){ // for (TjRules tjRules : tjOrderDetail.getRulesList()) { // TjOrderDetailRules orderDetailRules=new TjOrderDetailRules(); // orderDetailRules.setAid(tjRules.getAid()); // if (byId1!=null){ // orderDetailRules.setCusName(byId1.getCusName()); // orderDetailRules.setCusSex(String.valueOf(byId1.getCusSex())); // orderDetailRules.setCusAge(String.valueOf(MatchUtils.getAgeByIdCard(byId1.getCusIdcard()))); // orderDetailRules.setCusId(String.valueOf(byId1.getCusId())); // } // orderDetailRules.setBingzhong(tjRules.getBingzhong()); // orderDetailRules.setDoctorName(sysUser.getNickName()); // orderDetailRules.setTjNumber(order.getTjNumber()); // if (byId!=null){ // orderDetailRules.setProId(String.valueOf(byId.getProId())); // orderDetailRules.setProName(byId.getProName()); // } // orderDetailRules.setDoctorId(String.valueOf(sysUser.getUserId())); // tjOrderDetailRulesService.save(orderDetailRules); // } // } // } asyncService.updateOrdeltile(tjOrderDetailList, sysUser, order); LambdaQueryWrapper qww = new LambdaQueryWrapper<>(); qww.eq(TjOrderDetail::getOrderId, order.getOrderId()); qww.eq(TjOrderDetail::getProId, orderRemark.getProId()); TjOrderDetail detail = detailService.getOne(qww); detail.setTjStatus(1L); detailService.updateById(detail); orderRemark.setType(1); LambdaQueryWrapper wq1 = new LambdaQueryWrapper<>(); wq1.eq(TjOrderRemark::getTjNumber, orderRemark.getTjNumber()); wq1.eq(TjOrderRemark::getProId, orderRemark.getProId()); TjOrderRemark one = remarkService.getOne(wq1); if (one == null) { TjOrderRemark remark = new TjOrderRemark(); BeanUtils.copyBeanProp(orderRemark, remark); remarkService.save(remark); } else { one.setRemark(orderRemark.getRemark()); if (null != summaryList && !summaryList.isEmpty() && !summaryList.contains(null)) { one.setSummary(Joiner.on(";").join(orderRemark.getSummaryList())); } else { one.setSummary(null); } one.setDoctorName(orderRemark.getDoctorName()); one.setType(1); remarkService.updateById(one); } asyncService.updateCheckType(orderRemark.getTjNumber()); asyncService.getOrderDetailByProParentId(orderRemark.getTjNumber(), null, String.valueOf(orderRemark.getProId())); return AjaxResult.success("操作成功"); } // asyncService.updateCheckType(orderRemark.getTjNumber()); // asyncService.getOrderDetailByProParentId(orderRemark.getTjNumber(),null, String.valueOf(orderRemark.getProId())); } remarkService.tjYishengjianchajianyi(null, null, null, null); return AjaxResult.success("操作成功"); } /** * 医生点击体检信息详情(只显示父项目列表) * * @param tjNumber * @return */ // @Transactional @GetMapping("/getParentList") @ApiOperation(value = "医生点击体检信息详情(只显示父项目列表)") public AjaxResult getParentList(@ApiParam(value = "客户体检号") @RequestParam String tjNumber) { String userId = SecurityUtils.getLoginUser().getUserId(); Integer ksId = null; SysUser sysUser = null; if (null != userId) { sysUser = userService.getById(Long.valueOf(userId)); if (null == sysUser) { return AjaxResult.error(); } ksId = Math.toIntExact(sysUser.getDeptId()); } String configByKey = configService.selectConfigByKey("sfkqdyhis"); // 判断是否收费 请求接口 TjOrder tjOrder = orderService.getOrderByTjNum(tjNumber); if (null == tjOrder) { return AjaxResult.error("未找到体检记录"); } LambdaQueryWrapper tjFlowingWaterLambdaQueryWrapper = new LambdaQueryWrapper<>(); tjFlowingWaterLambdaQueryWrapper.eq(TjFlowingWater::getOrderId, tjOrder.getOrderId()); tjFlowingWaterLambdaQueryWrapper.eq(TjFlowingWater::getIsAddition, "N"); TjFlowingWater tjFlowingWater = tjFlowingWaterService.getOne(tjFlowingWaterLambdaQueryWrapper); if (null != tjFlowingWater) { if (tjFlowingWater.getPayStasus() != 1 && tjFlowingWater.getPayStasus() != 3) { if (configByKey.equals("Y")) { HashMap hisRequestParams = new HashMap<>(); // 不在需要身份证号 hisRequestParams.put("patientId", tjOrder.getCardId()); log.info("ltkj--- " + DateUtil.date() + "操作人id: " + userId + "操作科室: " + sysUser.getDeptId() + "操作的体检人: " + tjNumber); AjaxResult queryPay = hisApiGetMethodService.getHISDataNew("QueryPay", hisRequestParams); if (Integer.parseInt(queryPay.get("code").toString()) == 200) { int sfsf = ltkjJianchajianyanTreeService.getSfsfByCardId(tjOrder.getCardId()); if (sfsf > 0) { log.error("路泰科技--- " + DateUtil.date() + " 存在未缴费项目的 就单数 " + sfsf); log.error("路泰科技--- " + DateUtil.date() + " 存在未缴费项目的 就诊号 " + tjOrder.getCardId() + " 体检号 " + tjOrder.getTjNumber()); return AjaxResult.error("存在未缴费项目"); } extracted(tjOrder, tjFlowingWater); } else { log.error("路泰科技--- " + DateUtil.date() + " 未查询到缴费记录的 就诊号 " + tjOrder.getCardId() + " 体检号 " + tjOrder.getTjNumber()); return AjaxResult.error("未查询到缴费记录"); } } // String s = configService.selectConfigByKey("is_request_common_his_api"); // if (null != s && s.equals("Y")) { // LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); // wrapper1.eq(TjFlowingWater::getOrderId, tjOrder.getOrderId()); // wrapper1.eq(TjFlowingWater::getPayStasus, 0L); // List list = tjFlowingWaterService.list(wrapper1); // if (!list.isEmpty()) { // return AjaxResult.error("存在未缴费项目"); // } // } } } else { log.error("路泰科技--- " + DateUtil.date() + " 未对接his接口 " + " 体检号 " + tjOrder.getTjNumber()); return AjaxResult.error("未查询到缴费记录"); } String config = configService.selectConfigByKey("qt_open_xdt"); String byKey = configService.selectConfigByKey("qt_kjksid"); List split = new ArrayList<>(); // 存放转换后的integer类型结果 if ("Y".equals(config)) { List roles = SecurityUtils.getLoginUser().getUser().getRoles(); if (null != roles && !roles.isEmpty()) { List list = roles.stream().filter(item -> item.getRoleName().contains("前台")).collect(Collectors.toList()); if (!list.isEmpty()) { // if (null != ksId && ksId == 100) { // ksId = 999; // } if (null != byKey && !byKey.isEmpty()) { 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); } // LambdaQueryWrapper wq2 = new LambdaQueryWrapper<>(); // if ((null != sysUser && !sysUser.getUserName().equals("10001")) && 100!=ksId) { // wq2.in(TjProject::getDeptId,split); // } // //判断该项目是否需要打印报告 // wq2.eq(TjProject::getNeedReport,"Y"); // List Deptlist = projectService.list(wq2); // List proIdList = Deptlist.stream().map(TjProject::getProId).collect(Collectors.toList()); // if (Deptlist.isEmpty() || proIdList.isEmpty()) { // return AjaxResult.error("该科室下无项目!"); // } List list; if(null != sysUser && sysUser.getUserName().equals("10001")){ list=remarkService.yiShengJianChaGetPrentProCJGLY(tjNumber); }else { list= remarkService.yiShengJianChaGetPrentPro(tjNumber, split); } if (null ==list || list.isEmpty()) { return AjaxResult.error("该科室下无项目!"); } for (TjOrderRemark tjOrderRemark : list) { TjProject tjProject = projectService.getById(tjOrderRemark.getProId()); if (null != tjProject) { tjOrderRemark.setProName(tjProject.getProName()); } } return AjaxResult.success(list); // LambdaQueryWrapper wqq = new LambdaQueryWrapper<>(); // wqq.eq(TjOrderDetail::getOrderId, one.getOrderId()); // wqq.isNotNull(TjOrderDetail::getFlowingWaterId); // wqq.in(TjOrderDetail::getProId, proIdList); // wqq.notIn(TjOrderDetail::getProId, proIdList,projectService.getNneedReprotProId()); // List detailList = detailService.list(wqq); // if (detailList != null && !detailList.isEmpty()) { // List collect = detailList.stream().map(TjOrderDetail::getProId).collect(Collectors.toList()); // QueryWrapper wq = new QueryWrapper<>(); // 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 list = remarkService.list(wq); // if (list.isEmpty()) { // return AjaxResult.success("该科室下无项目!"); // } // for (TjOrderRemark tjOrderRemark : list) { // TjProject tjProject = projectService.getById(tjOrderRemark.getProId()); // if (null != tjProject) { // tjOrderRemark.setProName(tjProject.getProName()); // } // } // return AjaxResult.success(list); // } // return AjaxResult.success(); // } } @Transactional public void extracted(TjOrder tjOrder, TjFlowingWater tjFlowingWater) { tjFlowingWater.setPayStasus(1L); tjFlowingWater.setPayType(0L); tjFlowingWater.setTollCollectorId("148"); tjFlowingWaterService.updateById(tjFlowingWater); Long tjSerialNumber = tjFlowingWater.getTjSerialNumber(); LambdaQueryWrapper tjOrderDetailLambdaQueryWrapper = new LambdaQueryWrapper<>(); tjOrderDetailLambdaQueryWrapper.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId()); List tjOrderDetails = detailService.list(tjOrderDetailLambdaQueryWrapper); List detailIds = tjOrderDetails.stream().map(TjOrderDetail::getOrderDetailId).collect(Collectors.toList()); LambdaUpdateWrapper tjOrderDetailLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); tjOrderDetailLambdaUpdateWrapper.set(TjOrderDetail::getFlowingWaterId, tjSerialNumber); tjOrderDetailLambdaUpdateWrapper.in(TjOrderDetail::getOrderDetailId, detailIds); detailService.update(tjOrderDetailLambdaUpdateWrapper); remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(),tjFlowingWater.getTjSerialNumber().toString()); } /** * 点击父项目显示子项目详情 * * @return */ @GetMapping("/getOrderDetailByProParentId") @ApiOperation("点击父项目显示子项目详情") public AjaxResult getOrderDetailByProParentId(@ApiParam(value = "父项目id") @RequestParam String proParentId, @ApiParam(value = "体检号") @RequestParam String tjNumber) { if (null == SecurityUtils.getLoginUser().getUserId() || null == userService.getById(SecurityUtils.getLoginUser().getUserId())) { return AjaxResult.error("获取用户信息错误"); } TjOrderRemark remark = remarkService.getTjOrderRemarkByTjNumAndProParentId(tjNumber, proParentId); List proParentList = projectService.getTjProjectListByTbTransition(proParentId, tjNumber); if (null == proParentList || proParentList.isEmpty()) { Map map = new HashMap<>(); map.put("xiaoJieIds", null); map.put("sons", projectService.list(new LambdaQueryWrapper().eq(TjProject::getProId, proParentId))); map.put("xiaoJie", null); map.put("remark", remark.getRemark()); return AjaxResult.success(map); } List proParentIdList = proParentList.stream().map(TjProject::getProId).collect(Collectors.toList()); TjOrder one = orderService.getOrderByTjNum(tjNumber); if (null == one) { return AjaxResult.success("该用户暂时没有体检数据"); } List tjOrderDetails = detailService.getTjOrderDetailListInProParentIdList(String.valueOf(one.getOrderId()), proParentIdList); List tjOrderDetailList = new ArrayList<>(); // TjCustomer customer = tjCustomerService.getById(one.getUserId()); if (null != tjOrderDetails && !tjOrderDetails.isEmpty()) { for (TjOrderDetail tjOrderDetail : tjOrderDetails) { TjProject project = projectService.getById(tjOrderDetail.getProId()); if(null != project){ //判断该项目是否需要打印报告 if ("N".equals(project.getNeedReport())) { continue; } List rulesList = tjRulesService.getTjRulesListByTjNumAndProId(tjNumber, tjOrderDetail.getProId()); tjOrderDetail.setRulesList(rulesList); tjOrderDetail.setProject(project); if (null != remark.getDoctorName()) { SysUser byId = userService.getById(remark.getDoctorName()); if (byId != null) { tjOrderDetail.setDoctorName(userService.getById(remark.getDoctorName()).getNickName()); } } else { tjOrderDetail.setDoctorName(null); } if(StringUtil.isBlank(tjOrderDetail.getProResult())){ tjOrderDetail.setProResult(project.getProDefault()); } tjOrderDetailList.add(tjOrderDetail); } } } Map map = new HashMap<>(); List adviceList = new ArrayList<>(); if (null != remark) { String[] strings = StringUtils.split(remark.getSummary(), ";"); if (null != strings && strings.length > 0) { List list = tjAdviceService.getAdviceStringByIds(strings); adviceList.addAll(list); } map.put("xiaoJieIds", StringUtils.split(remark.getSummary(), ";")); } else { map.put("xiaoJieIds", null); } map.put("sons", tjOrderDetailList); map.put("xiaoJie", adviceList); map.put("remark", remark.getRemark()); // asyncService.getOrderDetailByProParentId(tjNumber,map,proParentId); return AjaxResult.success(map); } /** * 状态修改 */ @PutMapping("/changeStatus") @ApiOperation("部门状态修改") public AjaxResult changeStatus(@RequestBody SysDept dept) { //判断是启用还是 if ("1".equals(dept.getStatus())) { //判断用户表中有没有人在该科室下 LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); wq.eq(SysUser::getDeptId, dept.getDeptId()); List list = userService.list(wq); if (!list.isEmpty()) { return AjaxResult.error("该科室下有工作人员,不能停用!"); } } dept.setUpdateBy(getUsername()); int i = deptService.updateDeptStatus(dept); if (i == 0) { return AjaxResult.error("修改失败"); } return AjaxResult.success("修改成功"); } /** * 根据项目id获取建议 */ @GetMapping("/getDeptAdvice") @ApiOperation(value = "根据项目id获取建议") public AjaxResult getDeptAdvice(@ApiParam(value = "父项目项目id") @RequestParam(required = false) String proId, @ApiParam(value = "内容") @RequestParam(required = false) String nr, @ApiParam(value = "拼音码") @RequestParam(required = false) String pym, @ApiParam(value = "页码") @RequestParam(defaultValue = "1") int page, @ApiParam(value = "每页展示条数") @RequestParam(defaultValue = "10") int pageSize) { LambdaQueryWrapper wq1 = new LambdaQueryWrapper<>(); if (null != proId) { wq1.eq(TjAdvice::getProId, proId); } if (null != nr && !nr.isEmpty()) { wq1.like(TjAdvice::getTitle, nr); } else if (null != pym && !pym.isEmpty()) { wq1.like(TjAdvice::getTitle, pym); } // else { // wq1.last("limit 20"); // } Page pages = new Page<>(page, pageSize); Page advicePage = tjAdviceService.page(pages, wq1); Map map = new HashMap<>(); map.put("list", advicePage.getRecords()); map.put("total", advicePage.getTotal()); // List list = tjAdviceService.list(wq1); return AjaxResult.success(map); } @GetMapping("/getAdviceByTjNumAndPro") @ApiOperation(value = "根据项目id和体检号获取建议") public AjaxResult getAdviceByTjNumAndPro(@ApiParam(value = "父项目项目id") @RequestParam String proId, @ApiParam(value = "体检号") @RequestParam String tjNum) { LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); wq.eq(TjOrderRemark::getProId, proId); wq.eq(TjOrderRemark::getTjNumber, tjNum); TjOrderRemark remark = remarkService.getOne(wq); List list = null; if (null != remark && !StringUtils.isBlank(remark.getSummary())) { String[] strings = StringUtils.split(remark.getSummary(), ";"); if (null != strings && strings.length > 0) { list = tjAdviceService.getAdviceStringByIds(strings); } } return AjaxResult.success(list); } /** * 获取部门树列表 */ //@PreAuthorize("@ss.hasPermi('system:dept:list')") @GetMapping("/deptTree") @ApiOperation("获取部门树列表") public AjaxResult deptTree(SysDept dept) { return success(deptService.selectDeptTreeList(dept)); } @GetMapping("/deptTree111") @ApiOperation("获取部门树列表1111111111") public AjaxResult deptTree111(SysDept dept) { final List treeSelects = deptService.selectDeptTreeList1(dept); return success(treeSelects); } /** * 获取子科室部门列表 */ @GetMapping("/getChildList") @ApiOperation(value = "获取子科室部门列表") public AjaxResult getChildList(String deptName) { LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); wq.ne(SysDept::getParentId, 0); if (deptName != null) { wq.like(SysDept::getDeptName, deptName); } List depts = deptService.list(wq); return success(depts); } }