diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/OrgCommonFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/OrgCommonFormDTO.java new file mode 100644 index 0000000000..d4be5e3011 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/OrgCommonFormDTO.java @@ -0,0 +1,36 @@ +package com.epmet.commons.tools.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @Author yzm + * @Date 2023/5/15 13:44 + */ +@Data +public class OrgCommonFormDTO implements Serializable { + private static final long serialVersionUID = 2261315322260807610L; + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + /** + * 组织id或者网格id + */ + @NotBlank(message = "orgId不能为空", groups = AddUserInternalGroup.class) + private String orgId; + /** + * agency + * grid + */ + @NotBlank(message = "orgType不能为空", groups = AddUserInternalGroup.class) + private String orgType; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/lingshan/DangerousChemicalsTypeStatResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/lingshan/DangerousChemicalsTypeStatResultDTO.java new file mode 100644 index 0000000000..3c814adf9b --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/lingshan/DangerousChemicalsTypeStatResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result.lingshan; + +import lombok.Data; + +/** + * @Description 灵山大屏-安全生产-生产企业类型统计 + * @Author yzm + * @Date 2023/5/15 13:48 + */ +@Data +public class DangerousChemicalsTypeStatResultDTO { + private String name; + private Integer value; + private String typeCode; + +} + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcDangerousChemicalsController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcDangerousChemicalsController.java index 5561fdcbaf..0d4bab7d0b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcDangerousChemicalsController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcDangerousChemicalsController.java @@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.form.OrgCommonFormDTO; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; @@ -25,6 +26,7 @@ import com.epmet.dto.form.IcDangerousChemicalsListFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.result.IcDangerousChemicalsListResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.dto.result.lingshan.DangerousChemicalsTypeStatResultDTO; import com.epmet.excel.IcDangerousChemicalsExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcDangerousChemicalsService; @@ -288,5 +290,14 @@ public class IcDangerousChemicalsController { return new Result(); } - + /** + * 灵山大屏-安全生产-生产企业类型统计 + * + * @param formDto + * @return + */ + @PostMapping("type-stat") + public Result> typeStat(@RequestBody OrgCommonFormDTO formDto) { + return new Result>().ok(icDangerousChemicalsService.typeStat(formDto.getOrgId(), formDto.getOrgType())); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcDangerousChemicalsService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcDangerousChemicalsService.java index be86798fd5..d3963172c3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcDangerousChemicalsService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcDangerousChemicalsService.java @@ -7,6 +7,7 @@ import com.epmet.dto.IcDangerousChemicalsDTO; import com.epmet.dto.form.IcDangerousChemicalsAddEditFormDTO; import com.epmet.dto.form.IcDangerousChemicalsListFormDTO; import com.epmet.dto.result.IcDangerousChemicalsListResultDTO; +import com.epmet.dto.result.lingshan.DangerousChemicalsTypeStatResultDTO; import com.epmet.entity.IcDangerousChemicalsEntity; import java.nio.file.Path; @@ -82,4 +83,12 @@ public interface IcDangerousChemicalsService extends BaseService entityList); IcDangerousChemicalsEntity get(String orgId, String name); + + /** + * 灵山大屏-安全生产-生产企业类型统计 + * @param orgId + * @param orgType + * @return + */ + List typeStat(String orgId, String orgType); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcDangerousChemicalsServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcDangerousChemicalsServiceImpl.java index 4bb95cf9a0..8f0567c01c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcDangerousChemicalsServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcDangerousChemicalsServiceImpl.java @@ -28,6 +28,7 @@ import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.result.IcCoverageCategoryDictListResultDTO; import com.epmet.dto.result.IcDangerousChemicalsListResultDTO; import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.dto.result.lingshan.DangerousChemicalsTypeStatResultDTO; import com.epmet.entity.IcDangerousChemicalsEntity; import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; @@ -59,10 +60,7 @@ import java.io.IOException; import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; /** @@ -115,7 +113,7 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode()); Map statusMap = statusRes.success() && MapUtils.isNotEmpty(statusRes.getData()) ? statusRes.getData() : new HashMap<>(); //企业类别字典数据 - List dictList = coverageService.dictMap(formDTO.getCustomerId(), "dangerous_chemicals"); + List dictList = coverageService.dictMap(formDTO.getCustomerId(), CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode()); Map dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getValue, IcCoverageCategoryDictListResultDTO::getLabel)); for (IcDangerousChemicalsListResultDTO v : list) { if (StringUtils.isNotBlank(v.getCategory())) { @@ -225,7 +223,7 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode()); Map statusMap = statusRes.success() && MapUtils.isNotEmpty(statusRes.getData()) ? statusRes.getData() : new HashMap<>(); //企业类别字典数据 - List dictList = coverageService.dictMap(formDTO.getCustomerId(), "city_management"); + List dictList = coverageService.dictMap(formDTO.getCustomerId(), CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode()); Map dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getValue, IcCoverageCategoryDictListResultDTO::getLabel)); if (StringUtils.isNotBlank(resultDTO.getCategory())) { resultDTO.setCategoryName(dictMap.get(resultDTO.getCategory())); @@ -355,4 +353,58 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl typeStat(String orgId, String orgType) { + // 企业类别字典数据 + List dictList = coverageService.dictMap(EpmetRequestHolder.getLoginUserCustomerId(), CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode()); + if (CollectionUtils.isEmpty(dictList)) { + return new ArrayList<>(); + } + String orgIdPath = queryOrgIdPath(orgId, orgType); + if (StringUtils.isBlank(orgIdPath)) { + return new ArrayList<>(); + } + List resultList = new ArrayList<>(); + for (IcCoverageCategoryDictListResultDTO dto : dictList) { + DangerousChemicalsTypeStatResultDTO resultDTO = new DangerousChemicalsTypeStatResultDTO(); + resultDTO.setName(dto.getLabel()); + LambdaQueryWrapper countWrapper = new LambdaQueryWrapper<>(); + countWrapper.eq(IcDangerousChemicalsEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()) + .likeRight(IcDangerousChemicalsEntity::getOrgIdPath, orgIdPath) + .eq(IcDangerousChemicalsEntity::getCategory, dto.getValue()); + resultDTO.setValue(baseDao.selectCount(countWrapper)); + resultDTO.setTypeCode(dto.getValue()); + resultList.add(resultDTO); + } + return resultList; + } + + private String queryOrgIdPath(String orgId, String orgType) { + String orgIdPath = ""; + // 如果没传,默认查询当前工作人员所属组织 + if (StringUtils.isBlank(orgId) && StringUtils.isBlank(orgType)) { + CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), EpmetRequestHolder.getLoginUserId()); + orgId = staffInfoCacheResult.getAgencyId(); + orgType = OrgTypeEnum.AGENCY.getCode(); + } + if (OrgTypeEnum.AGENCY.getCode().equals(orgType)) { + CustomerAgencyDTO customerAgencyDTO = SpringContextUtils.getBean(CustomerAgencyService.class).get(orgId); + orgIdPath = PidUtils.convertPid2OrgIdPath(customerAgencyDTO.getId(), customerAgencyDTO.getPids()); + } else if (OrgTypeEnum.GRID.getCode().equals(orgType)) { + CustomerGridDTO customerGridDTO = SpringContextUtils.getBean(CustomerGridService.class).get(orgId); + orgIdPath = PidUtils.convertPid2OrgIdPath(customerGridDTO.getId(), customerGridDTO.getPids()); + } + return orgIdPath; + } + + } \ No newline at end of file