| | |
| | | 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; |
| | |
| | | */ |
| | | public DepartmentTagInfoVO getTagInfo(Long id) { |
| | | SysDepartment department = sysDepartmentService.getById(id); |
| | | DepartmentTagInfoVO vo = null; |
| | | DepartmentTagInfoVO vo = new DepartmentTagInfoVO(); |
| | | if (Objects.isNull(department)) { |
| | | throw new ServiceException("单位不存在"); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | //查询医废类型 |
| | | List<SysDictDataVO> medicalWasteTypeList = sysDictDataService.medicalWasteTypeList(); |
| | | |
| | | vo.setWasteTypeList(medicalWasteTypeList); |
| | | //查询南宁市下面的医疗机构 |
| | | List<SysDepartment> list = sysDepartmentService.lambdaQuery() |
| | | .likeRight(SysDepartment::getTreeCode, nanNingDepartment.getTreeCode()) |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | */ |
| | | 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(); |
| | | } |
| | |
| | | */ |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | | /** |