| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.github.pagehelper.ISelect; |
| | | import com.ruoyi.common.annotation.AddOrgId; |
| | | import com.ruoyi.common.annotation.Anonymous; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.entity.SysUserDept; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | |
| | | import com.ruoyi.task.domain.VO.TransferDeptVO; |
| | | import com.ruoyi.task.domain.ServiceSubtaskExport; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import com.ruoyi.system.service.ISysUserDeptService; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private ISysConfigService sysConfigService; |
| | | |
| | | @Autowired |
| | | private ISysDeptService sysDeptService; |
| | | |
| | | /** |
| | | * 任务运维触发能力。 |
| | |
| | | return getDataTable4(CollectionUtils.isEmpty(sfStatistics) ? sfStatistics.size() : 0, serviceSubtaskService.getSfStatistics(serviceSubtaskCountReq)); |
| | | } |
| | | |
| | | // ===================================================================================== |
| | | // 免登录随访统计(供 public/html/sfstat.html 独立页面使用,@Anonymous 即 SecurityConfig 的 permitAll) |
| | | // 口径与 /getSfStatistics 完全一致,区别只有两点: |
| | | // 1. 不依赖登录用户,orgid / campusid 由请求体显式传入; |
| | | // 2. 未指定病区(科室)时,取该机构(院区)下的全部病区(科室),而非当前登录用户的权限范围。 |
| | | // ===================================================================================== |
| | | |
| | | /** |
| | | * 免登录:随访统计(首次 / 再次) |
| | | */ |
| | | @Anonymous |
| | | @PostMapping("/publicSfStatistics") |
| | | public Map<String, Object> publicSfStatistics(@RequestBody ServiceSubtaskCountReq serviceSubtaskCountReq) { |
| | | if (CollectionUtils.isEmpty(serviceSubtaskCountReq.getServiceType())) { |
| | | return error("服务类型不能为空"); |
| | | } |
| | | if (StringUtils.isEmpty(serviceSubtaskCountReq.getOrgid())) { |
| | | return error("缺少机构参数 orgid"); |
| | | } |
| | | Integer statisticaltype = serviceSubtaskCountReq.getStatisticaltype(); |
| | | if (statisticaltype != null && statisticaltype == 1) { |
| | | List<String> wardCodes = isAllSelected(serviceSubtaskCountReq.getLeavehospitaldistrictcodes()) |
| | | ? listDeptCodesByType(serviceSubtaskCountReq.getOrgid(), serviceSubtaskCountReq.getCampusid(), "2") |
| | | : serviceSubtaskCountReq.getLeavehospitaldistrictcodes(); |
| | | if (CollectionUtils.isEmpty(wardCodes)) { |
| | | return getDataTable4(0, new ArrayList<>()); |
| | | } |
| | | serviceSubtaskCountReq.setLeavehospitaldistrictcodes(wardCodes); |
| | | serviceSubtaskCountReq.setDeptcodes(null); |
| | | } else if (statisticaltype != null && statisticaltype == 2) { |
| | | List<String> deptCodes = isAllSelected(serviceSubtaskCountReq.getDeptcodes()) |
| | | ? listDeptCodesByType(serviceSubtaskCountReq.getOrgid(), serviceSubtaskCountReq.getCampusid(), "1") |
| | | : serviceSubtaskCountReq.getDeptcodes(); |
| | | if (CollectionUtils.isEmpty(deptCodes)) { |
| | | return getDataTable4(0, new ArrayList<>()); |
| | | } |
| | | serviceSubtaskCountReq.setDeptcodes(deptCodes); |
| | | serviceSubtaskCountReq.setLeavehospitaldistrictcodes(null); |
| | | } |
| | | String followUpCountStyle = sysConfigService.selectConfigByKey("followUpCountStyle", serviceSubtaskCountReq.getOrgid()); |
| | | if (ObjectUtils.isNotEmpty(followUpCountStyle)) { |
| | | serviceSubtaskCountReq.setFollowUpCountStyle(followUpCountStyle); |
| | | } else { |
| | | serviceSubtaskCountReq.setFollowUpCountStyle("1"); |
| | | } |
| | | if (serviceSubtaskCountReq.getRateDay() == null) { |
| | | serviceSubtaskCountReq.setRateDay(7); |
| | | } |
| | | serviceSubtaskCountReq.setPageNum(null); |
| | | serviceSubtaskCountReq.setPageSize(null); |
| | | List<ServiceSubtaskStatistic> sfStatistics = serviceSubtaskService.getSfStatistics(serviceSubtaskCountReq); |
| | | return getDataTable4(CollectionUtils.isEmpty(sfStatistics) ? 0 : sfStatistics.size(), sfStatistics); |
| | | } |
| | | |
| | | /** |
| | | * 免登录:随访统计筛选项(病区列表 / 科室列表) |
| | | * |
| | | * @param orgid 机构ID,必填 |
| | | * @param campusid 院区ID,可为空;为空时取该机构全部院区 |
| | | */ |
| | | @Anonymous |
| | | @GetMapping("/publicSfStatisticsOptions") public AjaxResult publicSfStatisticsOptions(@RequestParam(value = "orgid", required = false) String orgid, |
| | | @RequestParam(value = "campusid", required = false) String campusid) { |
| | | if (StringUtils.isEmpty(orgid)) { |
| | | return error("缺少机构参数 orgid"); |
| | | } |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("orgid", orgid); |
| | | result.put("campusid", campusid); |
| | | result.put("wards", listDepts(orgid, campusid, "2")); |
| | | result.put("depts", listDepts(orgid, campusid, "1")); |
| | | return success(result); |
| | | } |
| | | |
| | | /** |
| | | * 免登录:延续护理统计(口径与 /getContinueNerseCount 一致,orgid / campusid 由请求体传入) |
| | | */ |
| | | @Anonymous |
| | | @PostMapping("/publicContinueNerseCount") |
| | | public AjaxResult publicContinueNerseCount(@RequestBody ServiceSubtaskCotinueCountVO serviceSubtaskCotinueCountVO) { |
| | | if (StringUtils.isEmpty(serviceSubtaskCotinueCountVO.getOrgid())) { |
| | | return error("缺少机构参数 orgid"); |
| | | } |
| | | List<String> districts = serviceSubtaskCotinueCountVO.getLeavehospitaldistrictcodes(); |
| | | List<String> depts = serviceSubtaskCotinueCountVO.getDeptcodes(); |
| | | boolean hasDistrict = !CollectionUtils.isEmpty(districts) && !districts.contains("all"); |
| | | boolean hasDept = !CollectionUtils.isEmpty(depts) && !depts.contains("all"); |
| | | if (hasDistrict && hasDept) { |
| | | return error("病区Code集合与科室Code集合互斥,不能同时传入"); |
| | | } |
| | | if (!hasDistrict && !hasDept) { |
| | | // 未指定病区/科室:按该机构(院区)下全部病区统计 |
| | | List<String> wardCodes = listDeptCodesByType(serviceSubtaskCotinueCountVO.getOrgid(), |
| | | serviceSubtaskCotinueCountVO.getCampusid(), "2"); |
| | | if (CollectionUtils.isEmpty(wardCodes)) { |
| | | return success(new LinkedHashMap<>()); |
| | | } |
| | | serviceSubtaskCotinueCountVO.setLeavehospitaldistrictcodes(wardCodes); |
| | | serviceSubtaskCotinueCountVO.setDeptcodes(null); |
| | | } else if (hasDistrict) { |
| | | serviceSubtaskCotinueCountVO.setDeptcodes(null); |
| | | } else { |
| | | serviceSubtaskCotinueCountVO.setLeavehospitaldistrictcodes(null); |
| | | } |
| | | return success(serviceSubtaskService.getContinueNurseCount(serviceSubtaskCotinueCountVO)); |
| | | } |
| | | |
| | | /** |
| | | * 前端未选择具体病区/科室(或选择了 all)时,视为“全部” |
| | | */ |
| | | private boolean isAllSelected(List<String> codes) { |
| | | return CollectionUtils.isEmpty(codes) || codes.contains("all"); |
| | | } |
| | | |
| | | private List<String> listDeptCodesByType(String orgid, String campusid, String deptType) { |
| | | List<String> codes = new ArrayList<>(); |
| | | for (Map<String, String> item : listDepts(orgid, campusid, deptType)) { |
| | | codes.add(item.get("code")); |
| | | } |
| | | return codes; |
| | | } |
| | | |
| | | /** |
| | | * 查询机构(院区)下指定类型的部门:deptType=2 病区,deptType=1 科室 |
| | | */ |
| | | private List<Map<String, String>> listDepts(String orgid, String campusid, String deptType) { |
| | | List<Map<String, String>> result = new ArrayList<>(); |
| | | SysDept query = new SysDept(); |
| | | query.setOrgid(orgid); |
| | | query.setDeptType(deptType); |
| | | if (StringUtils.isNotEmpty(campusid) && !"all".equalsIgnoreCase(campusid)) { |
| | | query.setCampusid(campusid); |
| | | } |
| | | List<SysDept> depts = sysDeptService.selectSysDeptList(query); |
| | | if (CollectionUtils.isEmpty(depts)) { |
| | | return result; |
| | | } |
| | | for (SysDept dept : depts) { |
| | | if (StringUtils.isEmpty(dept.getDeptCode())) { |
| | | continue; |
| | | } |
| | | Map<String, String> item = new LinkedHashMap<>(); |
| | | item.put("code", dept.getDeptCode()); |
| | | item.put("name", dept.getDeptName()); |
| | | result.add(item); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取专病随访统计比例 |
| | | */ |