package com.ltkj.web.controller.system; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ltkj.common.core.controller.BaseController; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.core.domain.entity.SysUser; import com.ltkj.common.core.redis.RedisCache; import com.ltkj.framework.config.MatchUtils; import com.ltkj.hosp.domain.*; import com.ltkj.hosp.service.*; import com.ltkj.system.service.ISysConfigService; import com.ltkj.system.service.ISysDeptService; import com.ltkj.system.service.ISysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; /** * @Company: 西安路泰科技有限公司 * @Author: lige * @Date: 2023/4/12 11:57 */ @RestController @RequestMapping("/hosp/return") @Api(tags = "复检接口") @Slf4j public class TjReturnController extends BaseController { @Resource private ITjOrderService tjOrderService; @Resource private ITjOrderDetailService tjOrderDetailService; @Resource private IDictCompService iDictCompService; @Resource private ITjPackageService tjPackageService; @Resource private ITjCustomerService tjCustomerService; @Resource private ITjProjectService projectService; @Resource private ITjOrderRemarkService orderRemarkService; @Resource private ISysUserService userService; @GetMapping("/getReturnOrderList") @ApiOperation(value = "查询体检记录列表") public AjaxResult getOrderList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum, @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize, @ApiParam(value = "体检号)") @RequestParam(required = false) String tjNum, @ApiParam(value = "姓名)") @RequestParam(required = false) String name, @ApiParam(value = "登记开始时间") @RequestParam(required = false) Date djbeginTime, @ApiParam(value = "登记结束时间") @RequestParam(required = false) Date djendTime, @ApiParam(value = "报告开始时间") @RequestParam(required = false) Date bgbeginTime, @ApiParam(value = "报告结束时间") @RequestParam(required = false) Date bgendTime){ Map map=new HashMap<>(); if(null !=name){ LambdaQueryWrapper wqq=new LambdaQueryWrapper<>(); wqq.like(TjCustomer::getCusName,name); List customerList = tjCustomerService.list(wqq); if(null !=customerList && customerList.size()>0){ List list=new ArrayList<>(); for (TjCustomer customer : customerList) { LambdaQueryWrapper wq=new LambdaQueryWrapper<>(); if(null !=djbeginTime && null !=djendTime){ wq.between(TjOrder::getCreateTime, DateUtil.beginOfDay(djbeginTime),DateUtil.endOfDay(djendTime)); } wq.eq(TjOrder::getUserId,customer.getCusId()); list.addAll(tjOrderService.list(wq)); } List collect =null; if(list.size()>0){ for (TjOrder order : list) { TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId()); if (null != tjCustomer) { order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName())); order.setTjCustomerSex(tjCustomer.getCusSex()); order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday())); order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone())); order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); } String firmId = order.getFirmId(); if (firmId != null && null !=iDictCompService.getById(String.valueOf(order.getFirmId()))) { order.setDictCompName(iDictCompService.getById(String.valueOf(order.getFirmId())).getCnName()); } if (null != order.getPacId() && null !=tjPackageService.getById(order.getPacId())) { order.setPacName(tjPackageService.getById(order.getPacId()).getPacName()); } } collect = list.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); } if (null != collect) { map.put("total", collect.size()); } else { map.put("total",0); } map.put("list",collect); return AjaxResult.success(map); } } Page page1=new Page<>(pageNum,pageSize); LambdaQueryWrapper wq=new LambdaQueryWrapper<>(); if(null !=djbeginTime && null !=djendTime){ wq.between(TjOrder::getCreateTime,DateUtil.beginOfDay(djbeginTime),DateUtil.endOfDay(djendTime)); } if(null !=bgbeginTime && null !=bgendTime){ wq.between(TjOrder::getCreateTime,DateUtil.beginOfDay(bgbeginTime),DateUtil.endOfDay(bgendTime)); } if(null !=tjNum){ wq.eq(TjOrder::getTjNumber,tjNum); } Page page2 = tjOrderService.page(page1,wq); List list =page2.getRecords(); if (list != null) { for (TjOrder order : list) { TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId()); if (null != tjCustomer) { order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName())); order.setTjCustomerSex(tjCustomer.getCusSex()); order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday())); order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone())); order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard())); } String firmId = order.getFirmId(); if (firmId != null && null !=iDictCompService.getById(String.valueOf(order.getFirmId()))) { order.setDictCompName(iDictCompService.getById(String.valueOf(order.getFirmId())).getCnName()); } if (null != order.getPacId() && null !=tjPackageService.getById(order.getPacId())) { order.setPacName(tjPackageService.getById(order.getPacId()).getPacName()); } } } map.put("list",list); map.put("total",page2.getTotal()); return AjaxResult.success(map); } /** * 根据获取复检详细项目列表 */ @GetMapping(value = "/{orderId}") @ApiOperation(value = "获取复检详细项目列表") public AjaxResult getListByOrderId(@PathVariable("orderId") Long orderId) { LambdaQueryWrapper wq=new LambdaQueryWrapper<>(); wq.eq(TjOrderDetail::getOrderId,orderId); wq.eq(TjOrderDetail::getIsReturn,1); List list = tjOrderDetailService.list(wq); if (list!=null&&list.size()>0){ for (TjOrderDetail tjOrderDetail : list) { final TjProject byId = projectService.getById(tjOrderDetail.getProId()); if (byId!=null){ tjOrderDetail.setProject(byId); tjOrderDetail.setProName(byId.getProName()); //根据父项目再remark表里查到医生名字 LambdaQueryWrapper wqq=new LambdaQueryWrapper<>(); wqq.eq(TjOrderRemark::getProId,byId.getProParentId()); wqq.eq(TjOrderRemark::getTjNumber,tjOrderService.getById(orderId).getTjNumber()); TjOrderRemark one = orderRemarkService.getOne(wqq); if (one!=null){ SysUser byId1 = userService.getById(one.getDoctorName()); if (byId1!=null){ tjOrderDetail.setDoctorName(byId1.getNickName()); } }else { tjOrderDetail.setDoctorName(tjOrderDetail.getUpdateBy()); } } } } return AjaxResult.success(list); } }