package com.ltkj.web.controller.system; import cn.hutool.core.date.DateTime; 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.domain.AjaxResult; import com.ltkj.hosp.domain.*; import com.ltkj.hosp.service.*; import com.ltkj.hosp.vodomain.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; /** * @Company: 西安路泰科技有限公司 * @Author: zjh * @Date: 2023/9/1 09:08 */ @RestController @RequestMapping("/group/inspection") @Api(tags = "团体检查接口集") public class GroupInspectionController { @Resource private ITjOrderService orderService; @Resource private ITjCustomerService customerService; @Resource private ITjDwDeptService dwDeptService; @Resource private ITjDwGroupingService dwGroupingService; @Resource private ITjGroupingProService groupingProService; @Resource private ITjReservationService reservationService; @Resource private ITjRulesService tjRulesService; @Resource private ITjOrderDetailRulesService detailRulesService; @Autowired private ITjOrderDetailService tjOrderDetailService; @Autowired private ITjProjectService tjProjectService; @Autowired private IDictCompService dictCompService; @GetMapping("/getDeptAndDwDeptByComp") @ApiOperation(value = "根据单位查询部门和单位部门信息") public AjaxResult getDeptAndDwDeptByComp(@ApiParam(value = "单位") @RequestParam(required = false) Long compId){ LambdaQueryWrapper wq= new LambdaQueryWrapper<>(); if(null !=compId){ wq.eq(TjDwDept::getDwId,compId); } List groupingList = dwDeptService.list(wq); return AjaxResult.success(groupingList); } @GetMapping("/getDwGroupingByDwDeptId") @ApiOperation(value = "根据单位部门查询单位分组信息信息") public AjaxResult getDwGroupingByDwDeptId(@ApiParam(value = "单位部门id") @RequestParam(required = false) String dwDeptId){ LambdaQueryWrapper wq= new LambdaQueryWrapper<>(); if(null !=dwDeptId){ wq.eq(TjDwGrouping::getDwDeptId,dwDeptId); } List groupingList = dwGroupingService.list(wq); return AjaxResult.success(groupingList); } @GetMapping("/getPeopleList") @ApiOperation(value = "团检病种页面查询人员列表接口") public AjaxResult getPeopleList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page, @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize, @ApiParam(value = "单位") @RequestParam(required = false) Long compId, @ApiParam(value = "部门)") @RequestParam(required = false) String deptName, @ApiParam(value = "部门分组id") @RequestParam(required = false) String groupingId, @ApiParam(value = "开始时间") @RequestParam(required = false) String beginTime, @ApiParam(value = "结束时间") @RequestParam(required = false) String endTime){ LambdaQueryWrapper wq=new LambdaQueryWrapper<>(); wq.isNotNull(TjReservation::getTeamNo); if (null != beginTime && null != endTime) { wq.between(TjReservation::getUpdateTime,DateUtil.beginOfDay(DateUtil.parse(beginTime)),DateUtil.endOfDay(DateUtil.parse(endTime))); } if(null !=compId) wq.eq(TjReservation::getCompanyId,compId); if(null !=deptName)wq.like(TjReservation::getDepartment,deptName); if(null !=groupingId)wq.eq(TjReservation::getGroupingId,groupingId); List reservations = reservationService.list(wq); List reservationPage =new ArrayList<>(); for (TjReservation record : reservations) { TjCustomer customer = customerService.getOne(new LambdaQueryWrapper().eq(TjCustomer::getCusIdcard, record.getIdCard())); if(null !=customer){ TjOrder order = orderService.getOne(new LambdaQueryWrapper().eq(TjOrder::getTeamNo, record.getTeamNo()).eq(TjOrder::getUserId,customer.getCusId())); if(null !=order){ GetPeopleListVo vo=new GetPeopleListVo(); vo.setTjNumber(order.getTjNumber()); vo.setName(record.getName()); vo.setSex(record.getSex()); vo.setDepartment(record.getDepartment()); vo.setAge(record.getAge()); if (record.getCompanyId()!=null){ vo.setCompany(dictCompService.getById(record.getCompanyId()).getCnName()); } reservationPage.add(vo); } } } List voList = reservationPage.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); Map map = new HashMap<>(); map.put("voList", voList); map.put("total", reservationPage.size()); return AjaxResult.success(map); } /** * 查询规则+病种列表 */ @GetMapping("/getTjRulesListByGroupingId") @ApiOperation(value = "团检页面查询病种字典列表") public AjaxResult getTjRulesListByGroupingId(@ApiParam(value = "分组id") @RequestParam(required = false) String groupingId, @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page, @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize) { LambdaQueryWrapper wq= new LambdaQueryWrapper<>(); if(null !=groupingId) wq.eq(TjGroupingPro::getGroupingId, groupingId); List proList = groupingProService.list(wq); Set list=new HashSet<>(); if(null !=proList && proList.size()>0){ for (TjGroupingPro tjGroupingPro : proList) { List rulesList = tjRulesService.getTjRulesListByProId(tjGroupingPro.getProId()); if(null !=rulesList && rulesList.size()>0){ list.addAll(rulesList); } } } List rulesList = list.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); Map map = new HashMap<>(); map.put("rulesList", rulesList); map.put("total", list.size()); return AjaxResult.success(map); } @PostMapping("/getTjRulesStatisticsByTjNumAndAid") @ApiOperation(value = "团检页面统计病种接口") public AjaxResult getTjRulesStatisticsByTjNumAndAid(@ApiParam(value = "体检号集合") @RequestBody TjRulesStatisticsDto dto ) { List tjNums = dto.getTjNums(); List aids = dto.getAids(); if(null==tjNums || tjNums.size()==0){ tjNums= new ArrayList<>(); tjNums.add("0"); } if(null==aids || aids.size()==0){ aids= new ArrayList<>(); aids.add("0"); } List list = detailRulesService.getTjRulesStatisticsByTjNumAndAid(tjNums,aids); return AjaxResult.success(list); } @GetMapping("/getTeamTjDwDeptTreeList") @ApiOperation(value = "团检页面报告管理侧面树节点") public AjaxResult getTeamTjDwDeptTreeList() { List dwDeptList = dwDeptService.getDwDeptNameList(); List list=new ArrayList<>(); if(null !=dwDeptList && dwDeptList.size()>0){ for (TjDwDept dept : dwDeptList) { List deptList = dwDeptService.getDwDeptListByTjDwDeptId(dept.getDwId()); TeamTjDwDeptVo deptVo= new TeamTjDwDeptVo(); deptVo.setDwName(dept.getDwName()); deptVo.setDwDepts(deptList); list.add(deptVo); } } return AjaxResult.success(list); } @GetMapping("/getTeamTjBaoGaoList") @ApiOperation(value = "团检页面报告管理数据查询接口") public AjaxResult getTeamTjBaoGaoList(@ApiParam(value = "单位部门") @RequestParam String dwDeptId, @ApiParam(value = "开始时间") @RequestParam String beginTime, @ApiParam(value = "结束时间") @RequestParam String endTime) { DateTime beginTimes = null; DateTime endTimes = null; if (null != beginTime && null != endTime) { beginTimes = DateUtil.beginOfDay(DateUtil.parse(beginTime)); endTimes = DateUtil.endOfDay(DateUtil.parse(endTime)); } List list = dwDeptService.getTeamTjDwBaoGaoVoByTjDwDeptId(dwDeptId, beginTimes, endTimes); if(null !=list && list.size()>0){ for (TeamTjDwBaoGaoVo gaoVo : list) { gaoVo.setStartTime(beginTimes); gaoVo.setEnfTime(endTimes); } } return AjaxResult.success(list); } @PostMapping("/getJieGuoFenXi") @ApiOperation(value = "结果分析接口") public AjaxResult getJieGuoFenXi(@ApiParam(value = "集合") @RequestBody TjProFenXiDto dto) { List tjNums = dto.getTjNums(); List proIds = dto.getProIds(); if(null==tjNums || tjNums.size()==0){ return AjaxResult.error("请选择人员"); } if(null==proIds || proIds.size()==0){ return AjaxResult.error("请选择项目"); } List orderIds=new ArrayList<>(); for (String tjNum : tjNums) { LambdaQueryWrapper wqtj=new LambdaQueryWrapper<>(); wqtj.eq(TjOrder::getTjNumber,tjNum); final TjOrder one = orderService.getOne(wqtj); orderIds.add(one.getOrderId()); } List> res=new ArrayList<>(); for (Long proId : proIds) { Map map=new HashMap<>(); LambdaQueryWrapper wq1=new LambdaQueryWrapper<>(); wq1.eq(TjOrderDetail::getProId,proId); wq1.in(TjOrderDetail::getOrderId,orderIds); wq1.eq(TjOrderDetail::getExceptionDesc,0); final List list1 = tjOrderDetailService.list(wq1); if (list1!=null){ for (TjOrderDetail tjOrderDetail : list1) { final TjOrder byId = orderService.getById(tjOrderDetail.getOrderId()); if (byId!=null){ tjOrderDetail.setTjNumber(byId.getTjNumber()); final TjCustomer byId1 = customerService.getById(byId.getUserId()); tjOrderDetail.setCusName(byId1.getCusName()); }else { tjOrderDetail.setTjNumber("未知"); tjOrderDetail.setCusName("未知"); } } } LambdaQueryWrapper wq2=new LambdaQueryWrapper<>(); wq2.eq(TjOrderDetail::getProId,proId); wq2.in(TjOrderDetail::getOrderId,orderIds); wq2.eq(TjOrderDetail::getExceptionDesc,1); final List list2 = tjOrderDetailService.list(wq2); if(list2!=null){ for (TjOrderDetail tjOrderDetail : list2) { final TjOrder byId = orderService.getById(tjOrderDetail.getOrderId()); if (byId!=null){ tjOrderDetail.setTjNumber(byId.getTjNumber()); final TjCustomer byId1 = customerService.getById(byId.getUserId()); tjOrderDetail.setCusName(byId1.getCusName()); }else { tjOrderDetail.setTjNumber("未知"); tjOrderDetail.setCusName("未知"); } } } map.put("project",tjProjectService.getById(proId)); map.put("zhengchang",list1); map.put("yichang",list2); res.add(map); } return AjaxResult.success(res); } }