Browse Source

生产企业类型统计-饼图

master
yinzuomei 2 years ago
parent
commit
09d2005fb8
  1. 36
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/OrgCommonFormDTO.java
  2. 17
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/lingshan/DangerousChemicalsTypeStatResultDTO.java
  3. 13
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcDangerousChemicalsController.java
  4. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcDangerousChemicalsService.java
  5. 64
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcDangerousChemicalsServiceImpl.java

36
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;
}

17
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;
}

13
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.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant; 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.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils; 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.form.ImportTaskCommonFormDTO;
import com.epmet.dto.result.IcDangerousChemicalsListResultDTO; import com.epmet.dto.result.IcDangerousChemicalsListResultDTO;
import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO;
import com.epmet.dto.result.lingshan.DangerousChemicalsTypeStatResultDTO;
import com.epmet.excel.IcDangerousChemicalsExcel; import com.epmet.excel.IcDangerousChemicalsExcel;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.service.IcDangerousChemicalsService; import com.epmet.service.IcDangerousChemicalsService;
@ -288,5 +290,14 @@ public class IcDangerousChemicalsController {
return new Result(); return new Result();
} }
/**
* 灵山大屏-安全生产-生产企业类型统计
*
* @param formDto
* @return
*/
@PostMapping("type-stat")
public Result<List<DangerousChemicalsTypeStatResultDTO>> typeStat(@RequestBody OrgCommonFormDTO formDto) {
return new Result<List<DangerousChemicalsTypeStatResultDTO>>().ok(icDangerousChemicalsService.typeStat(formDto.getOrgId(), formDto.getOrgType()));
}
} }

9
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.IcDangerousChemicalsAddEditFormDTO;
import com.epmet.dto.form.IcDangerousChemicalsListFormDTO; import com.epmet.dto.form.IcDangerousChemicalsListFormDTO;
import com.epmet.dto.result.IcDangerousChemicalsListResultDTO; import com.epmet.dto.result.IcDangerousChemicalsListResultDTO;
import com.epmet.dto.result.lingshan.DangerousChemicalsTypeStatResultDTO;
import com.epmet.entity.IcDangerousChemicalsEntity; import com.epmet.entity.IcDangerousChemicalsEntity;
import java.nio.file.Path; import java.nio.file.Path;
@ -82,4 +83,12 @@ public interface IcDangerousChemicalsService extends BaseService<IcDangerousChem
void importInsert(List<IcDangerousChemicalsEntity> entityList); void importInsert(List<IcDangerousChemicalsEntity> entityList);
IcDangerousChemicalsEntity get(String orgId, String name); IcDangerousChemicalsEntity get(String orgId, String name);
/**
* 灵山大屏-安全生产-生产企业类型统计
* @param orgId
* @param orgType
* @return
*/
List<DangerousChemicalsTypeStatResultDTO> typeStat(String orgId, String orgType);
} }

64
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.IcCoverageCategoryDictListResultDTO;
import com.epmet.dto.result.IcDangerousChemicalsListResultDTO; import com.epmet.dto.result.IcDangerousChemicalsListResultDTO;
import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.dto.result.lingshan.DangerousChemicalsTypeStatResultDTO;
import com.epmet.entity.IcDangerousChemicalsEntity; import com.epmet.entity.IcDangerousChemicalsEntity;
import com.epmet.feign.EpmetAdminOpenFeignClient; import com.epmet.feign.EpmetAdminOpenFeignClient;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
@ -59,10 +60,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -115,7 +113,7 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl<IcDangerous
Result<Map<String, String>> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode()); Result<Map<String, String>> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode());
Map<String, String> statusMap = statusRes.success() && MapUtils.isNotEmpty(statusRes.getData()) ? statusRes.getData() : new HashMap<>(); Map<String, String> statusMap = statusRes.success() && MapUtils.isNotEmpty(statusRes.getData()) ? statusRes.getData() : new HashMap<>();
//企业类别字典数据 //企业类别字典数据
List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(formDTO.getCustomerId(), "dangerous_chemicals"); List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(formDTO.getCustomerId(), CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode());
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getValue, IcCoverageCategoryDictListResultDTO::getLabel)); Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getValue, IcCoverageCategoryDictListResultDTO::getLabel));
for (IcDangerousChemicalsListResultDTO v : list) { for (IcDangerousChemicalsListResultDTO v : list) {
if (StringUtils.isNotBlank(v.getCategory())) { if (StringUtils.isNotBlank(v.getCategory())) {
@ -225,7 +223,7 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl<IcDangerous
Result<Map<String, String>> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode()); Result<Map<String, String>> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode());
Map<String, String> statusMap = statusRes.success() && MapUtils.isNotEmpty(statusRes.getData()) ? statusRes.getData() : new HashMap<>(); Map<String, String> statusMap = statusRes.success() && MapUtils.isNotEmpty(statusRes.getData()) ? statusRes.getData() : new HashMap<>();
//企业类别字典数据 //企业类别字典数据
List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(formDTO.getCustomerId(), "city_management"); List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(formDTO.getCustomerId(), CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode());
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getValue, IcCoverageCategoryDictListResultDTO::getLabel)); Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getValue, IcCoverageCategoryDictListResultDTO::getLabel));
if (StringUtils.isNotBlank(resultDTO.getCategory())) { if (StringUtils.isNotBlank(resultDTO.getCategory())) {
resultDTO.setCategoryName(dictMap.get(resultDTO.getCategory())); resultDTO.setCategoryName(dictMap.get(resultDTO.getCategory()));
@ -355,4 +353,58 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl<IcDangerous
queryWrapper.eq(IcDangerousChemicalsEntity::getOrgId,orgId).eq(IcDangerousChemicalsEntity::getName,name); queryWrapper.eq(IcDangerousChemicalsEntity::getOrgId,orgId).eq(IcDangerousChemicalsEntity::getName,name);
return baseDao.selectOne(queryWrapper); return baseDao.selectOne(queryWrapper);
} }
/**
* 灵山大屏-安全生产-生产企业类型统计
*
* @param orgId
* @param orgType
* @return
*/
@Override
public List<DangerousChemicalsTypeStatResultDTO> typeStat(String orgId, String orgType) {
// 企业类别字典数据
List<IcCoverageCategoryDictListResultDTO> 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<DangerousChemicalsTypeStatResultDTO> resultList = new ArrayList<>();
for (IcCoverageCategoryDictListResultDTO dto : dictList) {
DangerousChemicalsTypeStatResultDTO resultDTO = new DangerousChemicalsTypeStatResultDTO();
resultDTO.setName(dto.getLabel());
LambdaQueryWrapper<IcDangerousChemicalsEntity> 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;
}
} }
Loading…
Cancel
Save