diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/statistics/impl/StatisticsServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/statistics/impl/StatisticsServiceImpl.java index 739a2865..20c53d30 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/statistics/impl/StatisticsServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/statistics/impl/StatisticsServiceImpl.java @@ -11,6 +11,7 @@ import com.xinelu.manage.domain.department.Department; import com.xinelu.manage.dto.signpatientmanageroutenode.UploadRobotPublishRecordDto; import com.xinelu.manage.dto.statistics.FollowUpRateDto; import com.xinelu.manage.dto.statistics.QuestionnaireTaskStatisticsDto; +import com.xinelu.manage.mapper.department.DepartmentMapper; import com.xinelu.manage.mapper.patientvisitrecord.PatientVisitRecordMapper; import com.xinelu.manage.mapper.phonedialrecord.PhoneDialRecordMapper; import com.xinelu.manage.mapper.shortmessagesendrecord.ShortMessageSendRecordMapper; @@ -24,6 +25,7 @@ import com.xinelu.manage.vo.phonedialrecord.PhoneDialRecordVo; import com.xinelu.manage.vo.signpatientmanageroutenode.PatientFollowUpPlanVo; import com.xinelu.manage.vo.signpatientmanageroutenode.UploadRobotPublishRecordVo; import com.xinelu.manage.vo.statistics.*; +import com.xinelu.system.mapper.SysUserMapper; import com.xinelu.system.service.ISysUserService; import java.math.BigDecimal; import java.math.RoundingMode; @@ -64,6 +66,10 @@ public class StatisticsServiceImpl implements IStatisticsService { private IDepartmentService departmentService; @Resource private ISysUserService userService; + @Resource + private DepartmentMapper departmentMapper; + @Resource + private SysUserMapper sysUserMapper; /** * @description 随访成功率统计 @@ -193,7 +199,12 @@ public class StatisticsServiceImpl implements IStatisticsService { Department deptQuery = new Department(); deptQuery.setHospitalAgencyId(agency.getId()); deptQuery.setNodeType(NodeTypeEnum.DEPARTMENT.getInfo()); - List deptList = departmentService.selectDepartmentList(deptQuery); + //List deptList = departmentService.selectDepartmentList(deptQuery); + //2025/01/23 zh add start + List deptList = departmentMapper.selectDepartmentList(deptQuery); + List departmentIds = deptList.stream().filter(Objects::nonNull).map(Department::getId).distinct().collect(Collectors.toList()); + List sysUsers = sysUserMapper.selectUserListByHospitalAgencyId(agency.getId(), departmentIds); + //2025/01/23 zh add end for (Department dept : deptList) { FollowUpDetailVo followUpDetailVo = new FollowUpDetailVo(); followUpDetailVo.setRowName(dept.getDepartmentName()); @@ -206,10 +217,13 @@ public class StatisticsServiceImpl implements IStatisticsService { getFollowUpDetailVo(deptPlanList, followUpDetailVo); // 查询科室医生 - SysUser userQuery = new SysUser(); - userQuery.setHospitalAgencyId(dept.getHospitalAgencyId()); - userQuery.setDepartmentId(dept.getId()); - List userList = userService.selectUserList(userQuery); +// SysUser userQuery = new SysUser(); +// userQuery.setHospitalAgencyId(dept.getHospitalAgencyId()); +// userQuery.setDepartmentId(dept.getId()); +// List userList = userService.selectUserList(userQuery); + //2025/01/23 zh add start + List userList = sysUsers.stream().filter(Objects::nonNull).filter(item -> item.getDepartmentId().equals(dept.getId())).collect(Collectors.toList()); + //2025/01/23 zh add end List childrenList = new ArrayList<>(); Map> patientGroupByDoctor = new HashMap<>(); @@ -436,16 +450,19 @@ public class StatisticsServiceImpl implements IStatisticsService { private List getTotalRow(FollowUpDetailVo firstRow, List followUpDetailVoList) { firstRow.setRowName("总计"); // 就诊人数 - firstRow.setPatientNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getPatientNum).reduce(Integer::sum).get()); + //firstRow.setPatientNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getPatientNum).reduce(Integer::sum).get()); + firstRow.setPatientNum(followUpDetailVoList.stream().filter(item -> !item.getRowName().equals("总计")).map(FollowUpDetailVo::getPatientNum).reduce(Integer::sum).get());//2025/01/23 zh add // 随访计划人数 - firstRow.setFollowUpNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpNum).reduce(Integer::sum).get()); + //firstRow.setFollowUpNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpNum).reduce(Integer::sum).get()); + firstRow.setFollowUpNum(followUpDetailVoList.stream().filter(item -> !item.getRowName().equals("总计")).map(FollowUpDetailVo::getFollowUpNum).reduce(Integer::sum).get());//2025/01/23 zh add // 随访覆盖率 if (firstRow.getPatientNum() != null && firstRow.getPatientNum() > 0) { firstRow.setFollowUpCoverRate(new BigDecimal(firstRow.getFollowUpNum()).divide(new BigDecimal(firstRow.getPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); } // 随访成功人数 - firstRow.setFollowUpSuccessNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpSuccessNum).reduce(Integer::sum).get()); + //firstRow.setFollowUpSuccessNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpSuccessNum).reduce(Integer::sum).get()); + firstRow.setFollowUpSuccessNum(followUpDetailVoList.stream().filter(item -> !item.getRowName().equals("总计")).map(FollowUpDetailVo::getFollowUpSuccessNum).reduce(Integer::sum).get());//2025/01/23 zh add // 随访成功率 if (firstRow.getPatientNum() != null && firstRow.getPatientNum() > 0) { firstRow.setFollowUpSuccessRate(new BigDecimal(firstRow.getFollowUpSuccessNum()).divide(new BigDecimal(firstRow.getPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); diff --git a/postdischarge-manage/src/main/resources/mapper/manage/patientvisitrecord/PatientVisitRecordMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/patientvisitrecord/PatientVisitRecordMapper.xml index 50238ae1..09a44ca8 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/patientvisitrecord/PatientVisitRecordMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/patientvisitrecord/PatientVisitRecordMapper.xml @@ -506,7 +506,13 @@ select patient_id, hospital_agency_id, hospital_agency_name, campus_agency_id, campus_agency_name, department_id, department_name, ward_id, ward_name, attending_physician_id,attending_physician_name, - date_format(discharge_time, '%Y-%m') as dischargeTimeMonthStr + + + CASE + WHEN discharge_time is not null THEN date_format(discharge_time, '%Y-%m') + WHEN discharge_time is null THEN date_format(visit_date, '%Y-%m') + END AS 'dischargeTimeMonthStr' + from patient_visit_record del_flag = 0 @@ -522,12 +528,21 @@ and ward_id = #{wardId} - - and date_format(discharge_time,'%y%m') >= date_format(#{startDate},'%y%m') - - - and date_format(discharge_time,'%y%m') <= date_format(#{endDate},'%y%m') - + + + + + + + + + and ( + (date_format(discharge_time,'%y%m') >= date_format(#{startDate},'%y%m') and date_format(discharge_time,'%y%m') <= date_format(#{endDate},'%y%m')) + or + (date_format(visit_date,'%y%m') >= date_format(#{startDate},'%y%m') and date_format(visit_date,'%y%m') <= date_format(#{endDate},'%y%m')) + ) + + diff --git a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml index a5bb0f00..40a139ed 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroutenode/SignPatientManageRouteNodeMapper.xml @@ -1091,7 +1091,13 @@ task.attending_physician_id, task.attending_physician_name, task.task_finish_status, - date_format(task.execute_date_time, '%Y-%m') as executeMonthStr + -- date_format(task.execute_date_time, '%Y-%m') as executeMonthStr + + CASE + WHEN task.execute_date_time is not null THEN date_format(task.execute_date_time, '%Y-%m') + WHEN task.execute_date_time is null THEN date_format(task.visit_date, '%Y-%m') + END AS 'executeMonthStr' + from patient_task_view task @@ -1106,13 +1112,22 @@ and task.ward_id = #{wardId} - - and date_format(task.execute_date_time,'%y%m') >= date_format(#{startDate},'%y%m') - - - and date_format(task.execute_date_time,'%y%m') <= date_format(#{endDate},'%y%m') - - + + + + + + + + + and ( + (date_format(task.execute_date_time,'%y%m') >= date_format(#{startDate},'%y%m') and date_format(task.execute_date_time,'%y%m') <= date_format(#{endDate},'%y%m')) + or + (date_format(visit_date,'%y%m') >= date_format(#{startDate},'%y%m') and date_format(visit_date,'%y%m') <= date_format(#{endDate},'%y%m')) + ) + + + + + \ No newline at end of file