From 05628d269dff7ad4f2e9d3419b05b4e7e5768797 Mon Sep 17 00:00:00 2001 From: luoyisheng <yangdongji@argo-ai.cn> Date: 星期三, 12 二月 2025 14:19:28 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- medicalWaste-system/src/main/java/com/sinata/system/service/biz/ScreenService.java | 80 ++++++++++++++++++++++++++++------------ 1 files changed, 56 insertions(+), 24 deletions(-) diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/biz/ScreenService.java b/medicalWaste-system/src/main/java/com/sinata/system/service/biz/ScreenService.java index f4878b3..d4c1a32 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/biz/ScreenService.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/service/biz/ScreenService.java @@ -1,12 +1,15 @@ package com.sinata.system.service.biz; +import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson2.JSONArray; import com.sinata.common.exception.ServiceException; import com.sinata.common.utils.BeanUtils; import com.sinata.common.utils.CollUtils; import com.sinata.common.utils.DateUtils; import com.sinata.system.domain.MedicalWasteStaticsVO; import com.sinata.system.domain.MwCollectRecord; +import com.sinata.system.domain.MwTransitCarCollectPoint; import com.sinata.system.domain.MwWarningRecord; import com.sinata.system.domain.SysDepartment; import com.sinata.system.domain.vo.CarDistributionVO; @@ -74,7 +77,7 @@ */ public DepartmentTagInfoVO getTagInfo(Long id) { SysDepartment department = sysDepartmentService.getById(id); - DepartmentTagInfoVO vo = null; + DepartmentTagInfoVO vo = new DepartmentTagInfoVO(); if (Objects.isNull(department)) { throw new ServiceException("单位不存在"); } @@ -127,18 +130,20 @@ return todayMedicalWastePieVOList; } int total = collectRecordList.size(); - // 分组并统计每个 wasteTypeStr 对应的记录数 - Map<String, Long> resultMap = collectRecordList.stream() - .collect(Collectors.groupingBy(MwCollectRecord::getWasteTypeStr, Collectors.counting())); - - todayMedicalWastePieVOList = resultMap.entrySet().stream().map(entry -> { + //查询医废类型列表 + List<SysDictDataVO> sysDictDataVOS = sysDictDataService.medicalWasteTypeList(); + // 分组并统计每个 wasteType 对应的记录数 + Map<Long, Long> resultMap = collectRecordList.stream() + .collect(Collectors.groupingBy(MwCollectRecord::getWasteType, Collectors.counting())); + todayMedicalWastePieVOList = sysDictDataVOS.stream().map(sysDictDataVO -> { + Long count = resultMap.getOrDefault(sysDictDataVO.getDictCode(), 0L); TodayMedicalWastePieVO todayMedicalWastePieVO = new TodayMedicalWastePieVO(); - todayMedicalWastePieVO.setMedicalWasteStr(entry.getKey()); - todayMedicalWastePieVO.setCount(entry.getValue().intValue()); - todayMedicalWastePieVO.setProportion(BigDecimal.valueOf(entry.getValue()).divide(BigDecimal.valueOf(total), RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100))); + todayMedicalWastePieVO.setMedicalWasteStr(sysDictDataVO.getDictLabel()); + todayMedicalWastePieVO.setCssClass(sysDictDataVO.getCssClass()); + todayMedicalWastePieVO.setCount(count.intValue()); + todayMedicalWastePieVO.setProportion(BigDecimal.valueOf(count).divide(BigDecimal.valueOf(total), 4, RoundingMode.FLOOR).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.FLOOR)); return todayMedicalWastePieVO; }).collect(Collectors.toList()); - return todayMedicalWastePieVOList; } @@ -174,7 +179,7 @@ } //查询医废类型 List<SysDictDataVO> medicalWasteTypeList = sysDictDataService.medicalWasteTypeList(); - + vo.setWasteTypeList(medicalWasteTypeList); //查询南宁市下面的医疗机构 List<SysDepartment> list = sysDepartmentService.lambdaQuery() .likeRight(SysDepartment::getTreeCode, nanNingDepartment.getTreeCode()) @@ -273,16 +278,12 @@ medicalWasteCollectVO.setWasteTypeStr(sysDictDataVO.getDictLabel()); // 获取当前类型的医废记录 - List<MwCollectRecord> mwCollectRecords = collectRecordGroupByWasteType.get(sysDictDataVO.getDictCode()); - if (CollUtils.isNotEmpty(mwCollectRecords)) { - medicalWasteCollectVO.setBagNum(mwCollectRecords.size()); - medicalWasteCollectVO.setWeight(mwCollectRecords.stream() - .map(MwCollectRecord::getWeight) - .reduce(BigDecimal.ZERO, BigDecimal::add)); - } else { - medicalWasteCollectVO.setBagNum(0); - medicalWasteCollectVO.setWeight(BigDecimal.ZERO); - } + List<MwCollectRecord> mwCollectRecords = collectRecordGroupByWasteType.getOrDefault(sysDictDataVO.getDictCode(), CollUtils.emptyList()); + medicalWasteCollectVO.setCssClass(sysDictDataVO.getCssClass()); + medicalWasteCollectVO.setBagNum(mwCollectRecords.size()); + medicalWasteCollectVO.setWeight(mwCollectRecords.stream() + .map(MwCollectRecord::getWeight) + .reduce(BigDecimal.ZERO, BigDecimal::add)); return medicalWasteCollectVO; } @@ -293,7 +294,15 @@ */ public List<MwWarningRecordStaticsVO> warningRecordStaticsList() { SysDepartment nanNingDepartment = getNanNingDepartment(); - List<MwWarningRecord> warningRecordList = mwWarningRecordService.lambdaQuery().eq(MwWarningRecord::getDepartmentId, nanNingDepartment.getId()).list(); + //查询南宁的所有单位 + List<SysDepartment> list = sysDepartmentService.lambdaQuery() + .likeRight(SysDepartment::getTreeCode, nanNingDepartment.getTreeCode()) + .in(SysDepartment::getOrgType, DepartmentEnum.MEDICAL_INSTITUTION.getCode(), DepartmentEnum.DISPOSAL_UNIT.getCode()).list(); + if (CollUtils.isEmpty(list)) { + return CollUtils.emptyList(); + } + List<Long> departmentIds = list.stream().map(SysDepartment::getId).collect(Collectors.toList()); + List<MwWarningRecord> warningRecordList = mwWarningRecordService.lambdaQuery().in(MwWarningRecord::getDepartmentId, departmentIds).list(); if (CollUtils.isEmpty(warningRecordList)) { return CollUtils.emptyList(); } @@ -323,7 +332,13 @@ */ public List<MwWarningRecordVO> queryWarningRecordDetailByType(Integer type) { SysDepartment nanNingDepartment = getNanNingDepartment(); - List<MwWarningRecord> warningRecordList = mwWarningRecordService.lambdaQuery().eq(MwWarningRecord::getDepartmentId, nanNingDepartment.getId()).eq(MwWarningRecord::getType, type).list(); + //查询南宁市所有单位信息 + List<SysDepartment> list = sysDepartmentService.lambdaQuery().likeRight(SysDepartment::getTreeCode, nanNingDepartment.getTreeCode()).list(); + if (CollUtils.isEmpty(list)) { + return CollUtils.emptyList(); + } + List<Long> departmentIds = list.stream().map(SysDepartment::getId).collect(Collectors.toList()); + List<MwWarningRecord> warningRecordList = mwWarningRecordService.lambdaQuery().in(MwWarningRecord::getDepartmentId, departmentIds).eq(MwWarningRecord::getType, type).list(); return BeanUtils.copyToList(warningRecordList, MwWarningRecordVO.class); } @@ -335,7 +350,24 @@ public List<CarDistributionVO> queryCarDistribution() { SysDepartment nanNingDepartment = getNanNingDepartment(); //查询车辆分布列表 - return mwTransitCarCollectPointService.queryCarListByTreeCode(nanNingDepartment.getTreeCode()); + List<CarDistributionVO> carDistributionVOS = mwTransitCarCollectPointService.queryCarListByTreeCode(nanNingDepartment.getTreeCode()); + if (CollUtils.isNotEmpty(carDistributionVOS)) { + for (CarDistributionVO carDistributionVO : carDistributionVOS) { + MwTransitCarCollectPoint point = mwTransitCarCollectPointService.lambdaQuery().eq(MwTransitCarCollectPoint::getCarId, carDistributionVO.getId()).eq(MwTransitCarCollectPoint::getTransitDate, DateUtil.format(DateUtil.date(), DatePattern.NORM_DATE_PATTERN)).last("LIMIT 1").one(); + if (Objects.nonNull(point)) { + String pointList = point.getPointList(); + List<Long> pointIdList = JSONArray.parseArray(pointList, Long.class); + if (CollUtils.isNotEmpty(pointIdList)) { + //查询最后一个点位 + SysDepartment department = sysDepartmentService.getById(pointIdList.get(pointIdList.size() - 1)); + carDistributionVO.setLatitude(department.getLatitude()); + carDistributionVO.setLongitude(department.getLongitude()); + } + } + } + + } + return carDistributionVOS; } /** -- Gitblit v1.7.1