| | |
| | | import com.sinata.common.core.domain.entity.SysDictData; |
| | | import com.sinata.common.utils.CollUtils; |
| | | import com.sinata.common.utils.DateUtils; |
| | | import com.sinata.system.domain.MedicalWasteStaticsVO; |
| | | import com.sinata.system.config.AutoColumnWidthStrategy; |
| | | import com.sinata.system.domain.MwCollectRecord; |
| | | import com.sinata.system.domain.MwWarningRecord; |
| | | import com.sinata.system.domain.SysDepartment; |
| | |
| | | import com.sinata.system.domain.vo.MwMedicalWasteBoxVO; |
| | | import com.sinata.system.domain.vo.SysDictDataVO; |
| | | import com.sinata.system.domain.vo.TransformVO; |
| | | import com.sinata.system.enums.DepartmentEnum; |
| | | import com.sinata.system.enums.MedicalWasteStatusEnum; |
| | | import com.sinata.system.service.ISysDictDataService; |
| | | import com.sinata.system.service.MwCheckoutRecordService; |
| | | import com.sinata.system.service.MwCollectRecordService; |
| | |
| | | import com.sinata.system.service.MwDisposalRecordService; |
| | | import com.sinata.system.service.MwWarningRecordService; |
| | | import com.sinata.system.service.SysDepartmentService; |
| | | import com.sinata.system.utils.ImageToBase64; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private final MwDisposalRecordService mwDisposalRecordService; |
| | | private final MwDisposalHandleRecordService mwDisposalHandleRecordService; |
| | | |
| | | /** |
| | | * 机构分布-获取机构列表 |
| | | * |
| | | * @param type 1:全部 2:医院 3:处置单位 |
| | | * @return |
| | | */ |
| | | public List<SysDepartment> departmentList(Integer type) { |
| | | return sysDepartmentService.lambdaQuery().eq(type != 1, SysDepartment::getOrgType, type).list(); |
| | | } |
| | | |
| | | public MedicalWasteStaticsVO medicalWaste() { |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 医院报表 |
| | |
| | | */ |
| | | public DepartmentReportVO hospitalReport(HospitalReportQuery query) { |
| | | DepartmentReportVO vo = new DepartmentReportVO(); |
| | | SysDepartment department = sysDepartmentService.getById(query.getDepartmentId()); |
| | | if (Objects.nonNull(department)) { |
| | | vo.setDepartmentName(department.getDepartmentName()); |
| | | } |
| | | List<SysDictDataVO> wasteTypeList = sysDictDataService.medicalWasteTypeList(); |
| | | |
| | | if (CollUtils.isEmpty(wasteTypeList)) { |
| | |
| | | } |
| | | vo.setLegend(wasteTypeList.stream().map(SysDictDataVO::getDictLabel).collect(Collectors.toList())); |
| | | vo.getLegend().add("小计"); |
| | | List<MwCollectRecord> collectRecordList = mwCollectRecordService.lambdaQuery().eq(query.getReportType().equals(1), MwCollectRecord::getStatus, MedicalWasteStatusEnum.TEMPORARILY_STORED.getCode()) |
| | | .ne(query.getReportType().equals(2), MwCollectRecord::getStatus, MedicalWasteStatusEnum.TEMPORARILY_STORED.getCode()) |
| | | List<MwCollectRecord> collectRecordList = mwCollectRecordService.lambdaQuery()/*.eq(query.getReportType().equals(1), MwCollectRecord::getStatus, MedicalWasteStatusEnum.TEMPORARILY_STORED.getCode()) |
| | | .ne(query.getReportType().equals(2), MwCollectRecord::getStatus, MedicalWasteStatusEnum.TEMPORARILY_STORED.getCode())*/ |
| | | .eq(MwCollectRecord::getDepartmentId, query.getDepartmentId()) |
| | | .between(query.getReportType().equals(1), MwCollectRecord::getCollectTime, query.getStartTime(), query.getEndTime()) |
| | | .between(query.getReportType().equals(2), MwCollectRecord::getCheckoutTime, query.getStartTime(), query.getEndTime()) |
| | |
| | | totalCount = totalCount.add(currentCount); |
| | | totalWeight = totalWeight.add(weight); |
| | | } |
| | | itemVO.getData().add(totalCount); |
| | | itemVO.getData().add(totalWeight); |
| | | //查询预警记录判断是否超时 |
| | | if (query.getDateType().equals(1)) { |
| | | itemVO.setOverTimeFlag("否"); |
| | | List<Long> collectIdList = collectRecordList.stream().filter(e -> finalSdf.format(e.getCollectTime()).equals(date)).map(MwCollectRecord::getId).collect(Collectors.toList()); |
| | | List<MwWarningRecord> warningRecordList = mwWarningRecordService.lambdaQuery().in(MwWarningRecord::getWarningTargetId, collectIdList).list(); |
| | | if (CollUtils.isNotEmpty(warningRecordList)) { |
| | | itemVO.setOverTimeFlag("是"); |
| | | if (CollUtils.isNotEmpty(collectIdList)) { |
| | | List<MwWarningRecord> warningRecordList = mwWarningRecordService.lambdaQuery().in(MwWarningRecord::getWarningTargetId, collectIdList).list(); |
| | | if (CollUtils.isNotEmpty(warningRecordList)) { |
| | | itemVO.setOverTimeFlag("是"); |
| | | } |
| | | } |
| | | } |
| | | list.add(itemVO); |
| | |
| | | FastExcel.write(response.getOutputStream()) |
| | | .head(head) |
| | | .autoCloseStream(Boolean.TRUE) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .sheet("医院报表") |
| | | .doWrite(getHospitalReportStaticsData(query)); |
| | | } |
| | |
| | | public DepartmentReportVO transformList(TransformQuery query) { |
| | | DepartmentReportVO vo = new DepartmentReportVO(); |
| | | SysDepartment department = sysDepartmentService.getById(query.getDepartmentId()); |
| | | if (Objects.nonNull(department)) { |
| | | vo.setDepartmentName(department.getDepartmentName()); |
| | | } |
| | | SysDepartment region = sysDepartmentService.getDepartmentByParentId(department.getParentId()); |
| | | List<SysDepartment> hospitalList = sysDepartmentService.lambdaQuery().likeRight(SysDepartment::getTreeCode, region.getTreeCode()).eq(SysDepartment::getOrgType, DepartmentEnum.MEDICAL_INSTITUTION.getCode()).list(); |
| | | if (CollUtils.isNotEmpty(hospitalList)) { |
| | | List<TransformVO> checkoutRecordVOList = mwCheckoutRecordService.getCheckoutRecordList(query, region.getTreeCode()); |
| | | if (CollUtils.isNotEmpty(checkoutRecordVOList)) { |
| | | //查询医废类型 |
| | | List<SysDictData> wasteTypeList = sysDictDataService.lambdaQuery().in(SysDictData::getDictCode, query.getWasteTypeCodeList()).list(); |
| | | if (CollUtils.isNotEmpty(wasteTypeList)) { |
| | | vo.setLegend(wasteTypeList.stream().map(SysDictData::getDictLabel).collect(Collectors.toList())); |
| | | vo.getLegend().add("小计"); |
| | | for (TransformVO transformVO : checkoutRecordVOList) { |
| | | BigDecimal totalCount = BigDecimal.ZERO; |
| | | BigDecimal totalWeight = BigDecimal.ZERO; |
| | | DepartmentReportItemVO departmentReportItemVO = new DepartmentReportItemVO(); |
| | | departmentReportItemVO.setName(transformVO.getHospitalName()); |
| | | departmentReportItemVO.setData(new ArrayList<>()); |
| | | departmentReportItemVO.setDriverName(transformVO.getDriverName()); |
| | | departmentReportItemVO.setHospitalSignature(transformVO.getHospitalSignature()); |
| | | departmentReportItemVO.setHandoverTime(transformVO.getCheckoutTime()); |
| | | for (SysDictData sysDictData : wasteTypeList) { |
| | | BigDecimal count = BigDecimal.valueOf(transformVO.getCollectRecordList().stream().filter(item -> item.getWasteType().equals(sysDictData.getDictCode())).count()); |
| | | BigDecimal weight = transformVO.getCollectRecordList().stream().filter(item -> item.getWasteType().equals(sysDictData.getDictCode())).map(MwMedicalWasteBoxVO::getTotalWeight).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | departmentReportItemVO.getData().add(count); |
| | | departmentReportItemVO.getData().add(weight); |
| | | totalCount = totalCount.add(count); |
| | | totalWeight = totalWeight.add(weight); |
| | | } |
| | | departmentReportItemVO.getData().add(totalCount); |
| | | departmentReportItemVO.getData().add(totalWeight); |
| | | } |
| | | //List<SysDepartment> hospitalList = sysDepartmentService.lambdaQuery().likeRight(SysDepartment::getTreeCode, region.getTreeCode()).eq(SysDepartment::getOrgType, DepartmentEnum.MEDICAL_INSTITUTION.getCode()).list(); |
| | | List<TransformVO> checkoutRecordVOList = mwCheckoutRecordService.getCheckoutRecordList(query, region.getTreeCode()); |
| | | //查询医废类型 |
| | | List<SysDictData> wasteTypeList = sysDictDataService.lambdaQuery().in(SysDictData::getDictCode, query.getWasteTypeCodeList()).orderByDesc(SysDictData::getDictCode).list(); |
| | | if (CollUtils.isNotEmpty(wasteTypeList)) { |
| | | vo.setLegend(wasteTypeList.stream().map(SysDictData::getDictLabel).collect(Collectors.toList())); |
| | | vo.getLegend().add("小计"); |
| | | List<DepartmentReportItemVO> list = new ArrayList<>(); |
| | | for (TransformVO transformVO : checkoutRecordVOList) { |
| | | BigDecimal totalCount = BigDecimal.ZERO; |
| | | BigDecimal totalWeight = BigDecimal.ZERO; |
| | | DepartmentReportItemVO departmentReportItemVO = new DepartmentReportItemVO(); |
| | | departmentReportItemVO.setName(transformVO.getHospitalName()); |
| | | departmentReportItemVO.setData(new ArrayList<>()); |
| | | departmentReportItemVO.setDriverName(transformVO.getDriverName()); |
| | | departmentReportItemVO.setHospitalSignature(ImageToBase64.convertImageToBase64(transformVO.getHospitalSignature())); |
| | | departmentReportItemVO.setHandoverTime(transformVO.getCheckoutTime()); |
| | | for (SysDictData sysDictData : wasteTypeList) { |
| | | BigDecimal count = BigDecimal.valueOf(transformVO.getCollectRecordList().stream().filter(item -> item.getWasteType().equals(sysDictData.getDictCode())).count()); |
| | | BigDecimal weight = transformVO.getCollectRecordList().stream().filter(item -> item.getWasteType().equals(sysDictData.getDictCode())).map(MwMedicalWasteBoxVO::getTotalWeight).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | departmentReportItemVO.getData().add(count); |
| | | departmentReportItemVO.getData().add(weight); |
| | | totalCount = totalCount.add(count); |
| | | totalWeight = totalWeight.add(weight); |
| | | } |
| | | departmentReportItemVO.getData().add(totalCount); |
| | | departmentReportItemVO.getData().add(totalWeight); |
| | | list.add(departmentReportItemVO); |
| | | } |
| | | vo.setList(list); |
| | | } |
| | | return vo; |
| | | } |
| | |
| | | FastExcel.write(response.getOutputStream()) |
| | | .head(head) |
| | | .autoCloseStream(Boolean.TRUE) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .sheet("转运联单") |
| | | .doWrite(getTransformReportStaticsData(query)); |
| | | } |
| | |
| | | */ |
| | | public DepartmentReportVO disposalReport(DisposalReportQuery query) { |
| | | DepartmentReportVO vo = new DepartmentReportVO(); |
| | | SysDepartment department = sysDepartmentService.getById(query.getDepartmentId()); |
| | | if (Objects.nonNull(department)) { |
| | | vo.setDepartmentName(department.getDepartmentName()); |
| | | } |
| | | //已接收 |
| | | List<MwDisposalRecordReportVO> receivedList = mwDisposalRecordService.disposalReceiveReport(query); |
| | | //已处置 |
| | |
| | | SimpleDateFormat finalSdf = sdf; |
| | | //接收 |
| | | for (SysDictData sysDictData : wasteTypeList) { |
| | | departmentReportItemVO.getData().add(BigDecimal.ZERO); |
| | | if (CollUtils.isNotEmpty(receivedList)) { |
| | | BigDecimal totalWeight = receivedList.stream().filter(item -> item.getWasteType().equals(sysDictData.getDictCode()) && |
| | | finalSdf.format(item.getReceiveTime()).equals(date)).map(MwDisposalRecordReportVO::getWeight) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | departmentReportItemVO.getData().add(totalWeight); |
| | | } |
| | | BigDecimal totalWeight = receivedList.stream().filter(item -> item.getWasteType().equals(sysDictData.getDictCode()) && |
| | | finalSdf.format(item.getReceiveTime()).equals(date)).map(MwDisposalRecordReportVO::getWeight) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | departmentReportItemVO.getData().add(totalWeight); |
| | | } |
| | | //处置 |
| | | for (SysDictData sysDictData : wasteTypeList) { |
| | | departmentReportItemVO.getData().add(BigDecimal.ZERO); |
| | | if (CollUtils.isNotEmpty(disposaledList)) { |
| | | BigDecimal totalWeight = disposaledList.stream().filter(item -> item.getWasteType().equals(sysDictData.getDictCode()) && |
| | | finalSdf.format(item.getReceiveTime()).equals(date)).map(MwDisposalRecordReportVO::getWeight) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | departmentReportItemVO.getData().add(totalWeight); |
| | | } |
| | | BigDecimal totalWeight = disposaledList.stream().filter(item -> item.getWasteType().equals(sysDictData.getDictCode()) && |
| | | finalSdf.format(item.getDisposalTime()).equals(date)).map(MwDisposalRecordReportVO::getWeight) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | departmentReportItemVO.getData().add(totalWeight); |
| | | } |
| | | list.add(departmentReportItemVO); |
| | | } |
| | |
| | | FastExcel.write(response.getOutputStream()) |
| | | .head(head) |
| | | .autoCloseStream(Boolean.TRUE) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .sheet("处置报表") |
| | | .doWrite(getDisposalReportStaticsData(query)); |
| | | } |
| | |
| | | */ |
| | | public DepartmentReportVO regulationReport(DisposalReportQuery query) { |
| | | DepartmentReportVO vo = new DepartmentReportVO(); |
| | | SysDepartment department = sysDepartmentService.getById(query.getDepartmentId()); |
| | | if (Objects.nonNull(department)) { |
| | | vo.setDepartmentName(department.getDepartmentName()); |
| | | } |
| | | //医废产生量 |
| | | List<MwCollectRecordVO> collectRecordList = mwCollectRecordService.getRegulationReportList(query); |
| | | //医废转移量 |
| | |
| | | for (String date : dateList) { |
| | | DepartmentReportItemVO departmentReportItemVO = new DepartmentReportItemVO(); |
| | | departmentReportItemVO.setName(date); |
| | | departmentReportItemVO.setData(new ArrayList<>()); |
| | | SimpleDateFormat finalSdf = sdf; |
| | | for (SysDictData sysDictData : wasteTypeList) { |
| | | BigDecimal weight = collectRecordList.stream().filter(e -> e.getWasteType().equals(sysDictData.getDictCode()) && |
| | |
| | | } |
| | | for (SysDictData sysDictData : wasteTypeList) { |
| | | BigDecimal weight = checkoutRecordList.stream().filter(e -> e.getWasteType().equals(sysDictData.getDictCode()) && |
| | | finalSdf.format(e.getCollectTime()).equals(date)).map(MwCollectRecordVO::getWeight).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | finalSdf.format(e.getCheckoutTime()).equals(date)).map(MwCollectRecordVO::getWeight).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | departmentReportItemVO.getData().add(weight); |
| | | } |
| | | for (SysDictData sysDictData : wasteTypeList) { |
| | |
| | | FastExcel.write(response.getOutputStream()) |
| | | .head(head) |
| | | .autoCloseStream(Boolean.TRUE) |
| | | .registerWriteHandler(new AutoColumnWidthStrategy()) |
| | | .sheet("监管报表") |
| | | .doWrite(getRegulationReportStaticsData(query)); |
| | | } |