Browse Source

Merge branch 'lingshan_master' into dev

master
wxz 2 years ago
parent
commit
89e04c670f
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ZhzlResiCategoryEnum.java
  2. 92
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/DangerousChemicalsImportListener.java
  3. 29
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcDangerousChemicalsServiceImpl.java
  4. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/LingShanSpecialCrowdController.java
  5. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/LingshanSpecialCrowdPersonTypeDao.java
  6. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/LingShanSpecialCrowdService.java
  7. 23
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/LingShanSpecialCrowdServiceImpl.java
  8. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/LingshanSpecialCrowdPersonTypeDao.xml

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ZhzlResiCategoryEnum.java

@ -20,7 +20,7 @@ public enum ZhzlResiCategoryEnum {
buliangqingshaonian("buliangqingshaonian", "不良青少年", "list_equal", "ic_special", "SPECIAL_RQLB", "buliangqingshaonian", 4),
shequjiaozheng("shequjiaozheng", "社区矫正", "list_equal", "ic_special", "SPECIAL_RQLB", "shequjiaozheng", 5),
zhaoshizhaohuojingshenbing("zhaoshizhaohuojingshenbing", "肇事肇祸精神病", "list_equal", "ic_special", "SPECIAL_RQLB", "zhaoshizhaohuojingshenbing", 6),
xidurenyuan("jiedurenyuan", "戒毒人员", "list_equal", "ic_special", "SPECIAL_RQLB", "xidurenyuan", 7);
jiedurenyuan("jiedurenyuan", "戒毒人员", "list_equal", "ic_special", "SPECIAL_RQLB", "xidurenyuan", 7);
private String code;
private String name;

92
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/DangerousChemicalsImportListener.java

@ -2,32 +2,20 @@ package com.epmet.model;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.CoveragePlaceTypeEnum;
import com.epmet.commons.tools.enums.DictTypeEnum;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.ValidateException;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dao.IcDangerousChemicalsDao;
import com.epmet.dto.result.IcCoverageCategoryDictListResultDTO;
import com.epmet.entity.IcDangerousChemicalsEntity;
import com.epmet.excel.IcCityManagementExcel;
import com.epmet.feign.EpmetAdminOpenFeignClient;
import com.epmet.service.CoverageService;
import com.epmet.service.CustomerGridService;
import com.epmet.service.IcDangerousChemicalsService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -42,24 +30,48 @@ import java.util.stream.Collectors;
public class DangerousChemicalsImportListener extends AnalysisEventListener<DangerousChemicalsModel> {
private IcDangerousChemicalsService icDangerousChemicalsService;
private EpmetAdminOpenFeignClient adminOpenFeignClient;
private CoverageService coverageService;
private AgencyInfoCache agencyInfo;
private IcDangerousChemicalsDao icDangerousChemicalsDao;
private CustomerGridService customerGridService;
private String currentUserId;
private String customerId;
private String staffAgencyId;
private String staffAgencyPath;
private List<DangerousChemicalsModel.RowRemarkMessage> errorRows = new ArrayList<>();
private List<DangerousChemicalsModel.RowRemarkMessage> otherRows = new ArrayList<>();
private List<IcDangerousChemicalsEntity> insertList = new ArrayList<>();
private Map<String,String> existMap = null;
/**
* 危化品种类
*/
private Map<String, String> dangerTypeMap;
/**
* 企业类别
*/
private Map<String, String> categoryDictMap;
/**
* key网格id
* value:网格名称
*/
private Map<String, String> gridMap;
public DangerousChemicalsImportListener(String currentUserId, AgencyInfoCache agencyInfo, IcDangerousChemicalsService icDangerousChemicalsService, CoverageService coverageService, EpmetAdminOpenFeignClient adminOpenFeignClient, IcDangerousChemicalsDao icDangerousChemicalsDao){
public DangerousChemicalsImportListener(String currentUserId,
String customerId,
String staffAgencyId,
String staffAgencyPath,
IcDangerousChemicalsService icDangerousChemicalsService,
CoverageService coverageService,
CustomerGridService customerGridService,
Map<String, String> dangerTypeMap,
Map<String, String> categoryDictMap){
this.currentUserId = currentUserId;
this.agencyInfo = agencyInfo;
this.customerId=customerId;
this.staffAgencyId=staffAgencyId;
this.staffAgencyPath=staffAgencyPath;
this.icDangerousChemicalsService = icDangerousChemicalsService;
this.coverageService = coverageService;
this.adminOpenFeignClient = adminOpenFeignClient;
this.icDangerousChemicalsDao = icDangerousChemicalsDao;
this.customerGridService=customerGridService;
this.dangerTypeMap=dangerTypeMap;
this.categoryDictMap=categoryDictMap;
}
@Override
@ -68,18 +80,13 @@ public class DangerousChemicalsImportListener extends AnalysisEventListener<Dang
data.setRowNum(rowNum);
try {
ValidatorUtils.validateEntity(data);
/*existMap = null == existMap ? getExistMap(agencyInfo.getId()) : existMap;
if (StringUtils.isNotBlank(existMap.get(data.getName()))){
DangerousChemicalsModel.RowRemarkMessage errorRow = ConvertUtils.sourceToTarget(data, DangerousChemicalsModel.RowRemarkMessage.class);
errorRow.setErrorInfo("数据库存在该条数据");
errorRows.add(errorRow);
return;
}*/
//todo
// 所属组织,orgIdPath等等。。。。
IcDangerousChemicalsEntity e = ConvertUtils.sourceToTarget(data, IcDangerousChemicalsEntity.class);
e.setSourceType("import");
e.setAgencyId(agencyInfo.getId());
e.setCustomerId(agencyInfo.getCustomerId());
e.setAgencyIdPath(agencyInfo.getPids().equals(NumConstant.ZERO_STR) || agencyInfo.getPids().equals("") ? agencyInfo.getId() : agencyInfo.getPids().concat(":").concat(agencyInfo.getId()));
e.setAgencyId(staffAgencyId);
e.setCustomerId(customerId);
e.setAgencyIdPath(staffAgencyPath);
e.setCreatedBy(currentUserId);
e.setUpdatedBy(currentUserId);
insertList.add(e);
@ -105,38 +112,19 @@ public class DangerousChemicalsImportListener extends AnalysisEventListener<Dang
execPersist();
}
public Map<String,String> getExistMap(String agencyId){
LambdaQueryWrapper<IcDangerousChemicalsEntity> tWrapper = new LambdaQueryWrapper<>();
tWrapper.eq(IcDangerousChemicalsEntity::getAgencyId, agencyId);
List<IcDangerousChemicalsEntity> entityList = icDangerousChemicalsDao.selectList(tWrapper);
Map<String,String> existMap = new HashMap<>(16);
if (CollectionUtils.isNotEmpty(entityList)){
existMap = entityList.stream().collect(Collectors.toMap(IcDangerousChemicalsEntity::getName,IcDangerousChemicalsEntity::getId,(v1,v2) -> v1));
}
return existMap;
}
/**
* Desc: 数据库插入
*/
private void execPersist() {
try {
if (CollectionUtils.isNotEmpty(insertList)) {
//危化品种类字典
Result<Map<String, String>> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode());
if (!statusRes.success()){
throw new EpmetException("获取IC_DANGER_TYPE字典表失败");
}
Map<String, String> statusMap = statusRes.success() && MapUtils.isNotEmpty(statusRes.getData()) ? statusRes.getData() : new HashMap<>(16);
//企业类别字典数据
List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(agencyInfo.getCustomerId(), CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode());
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getValue, IcCoverageCategoryDictListResultDTO::getLabel));
insertList.forEach(i -> {
statusMap.forEach((k,v) -> {
dangerTypeMap.forEach((k,v) -> {
if (i.getDangerTypeName().equals(v)){
i.setDangerType(k);
}
});
dictMap.forEach((k,v) -> {
categoryDictMap.forEach((k,v) -> {
if (i.getCategoryName().equals(v)){
i.setCategory(k);
}

29
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcDangerousChemicalsServiceImpl.java

@ -8,15 +8,14 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.CoveragePlaceTypeEnum;
import com.epmet.commons.tools.enums.DictTypeEnum;
import com.epmet.commons.tools.enums.OrgTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.*;
import com.epmet.constants.ImportTaskConstants;
@ -86,7 +85,7 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl<IcDangerous
@Autowired
private OssFeignClient ossFeignClient;
@Autowired
private IcDangerousChemicalsDao icDangerousChemicalsDao;
private CustomerGridService customerGridService;
@Override
public PageData<IcDangerousChemicalsListResultDTO> list(IcDangerousChemicalsListFormDTO formDTO) {
@ -237,15 +236,31 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl<IcDangerous
@Async
public void dangerousChemicalsImport(Path filePath, String importTaskId, TokenDto tokenDto) {
try {
// 获取当前登录用户所属组织id、组织全路径
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
if (null == staffInfo){
throw new EpmetException("查询工作人员信息失败:"+tokenDto.getUserId());
}
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfo.getAgencyId());
if (null == agencyInfo){
throw new EpmetException("查询所属组织失败:"+staffInfo.getAgencyId());
CustomerAgencyDTO staffAgencyInfo=SpringContextUtils.getBean(CustomerAgencyService.class).get(staffInfo.getAgencyId());
String staffAgencyPath=PidUtils.convertPid2OrgIdPath(staffInfo.getAgencyId(),staffAgencyInfo.getPids());
//危化品种类字典
Result<Map<String, String>> statusRes = adminOpenFeignClient.dictMap(DictTypeEnum.IC_DANGER_TYPE.getCode());
if (!statusRes.success() || MapUtils.isNotEmpty(statusRes.getData())) {
throw new EpmetException("获取IC_DANGER_TYPE字典表失败");
}
DangerousChemicalsImportListener listener = new DangerousChemicalsImportListener(tokenDto.getUserId(), agencyInfo,this,coverageService,adminOpenFeignClient,icDangerousChemicalsDao);
Map<String, String> dangerTypeMap = statusRes.getData();
//企业类别字典数据
List<IcCoverageCategoryDictListResultDTO> dictList = coverageService.dictMap(tokenDto.getCustomerId(), CoveragePlaceTypeEnum.DANGEROUS_CHEMICALS.getCode());
Map<String, String> categoryDictMap = dictList.stream().collect(Collectors.toMap(IcCoverageCategoryDictListResultDTO::getValue, IcCoverageCategoryDictListResultDTO::getLabel));
DangerousChemicalsImportListener listener = new DangerousChemicalsImportListener(tokenDto.getUserId(), tokenDto.getCustomerId(),
staffInfo.getAgencyId(),staffAgencyPath,
this,
coverageService,
customerGridService,
dangerTypeMap,
categoryDictMap);
EasyExcel.read(filePath.toFile(), DangerousChemicalsModel.class, listener).headRowNumber(1).sheet(0).doRead();
String errorDesFileUrl = null;
List<DangerousChemicalsModel.RowRemarkMessage> errorRows = listener.getErrorRows();

5
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/LingShanSpecialCrowdController.java

@ -251,14 +251,13 @@ public class LingShanSpecialCrowdController {
*/
@PostMapping("deleteByType")
public Result deleteByType(@RequestBody Map<String, String> params) {
String specialType = params.get("specialType");
String resiId = params.get("resiId");
if (StringUtils.isAnyBlank(specialType, resiId)) {
if (StringUtils.isAnyBlank(resiId, resiId)) {
throw new ValidateException("特殊人群类型或身份证不能为空");
}
lingShanSpecialCrowdService.deleteByType(specialType, resiId);
lingShanSpecialCrowdService.deleteByType(resiId);
return new Result();
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/LingshanSpecialCrowdPersonTypeDao.java

@ -27,5 +27,5 @@ public interface LingshanSpecialCrowdPersonTypeDao extends BaseDao<LingshanSpeci
@Param("mobile") String mobile,
@Param("idCard") String idCard);
void deletePhysical(@Param("specialType") String specialType, @Param("resiId") String resiId);
void deletePhysical(@Param("resiId") String resiId);
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/LingShanSpecialCrowdService.java

@ -82,7 +82,7 @@ public interface LingShanSpecialCrowdService {
PageData<LingShanSpecialCrowdListResultDTO> listSpecialCrowds(String orgId, String orgType, String specialType, String name, String mobile,
String idCard, Integer pageNo, Integer pageSize);
void deleteByType(String specialType, String resiId);
void deleteByType(String resiId);
/**
* @description: 保存或修改

23
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/LingShanSpecialCrowdServiceImpl.java

@ -608,24 +608,17 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ
@Transactional
@Override
public void deleteByType(String specialType, String resiId) {
LambdaQueryWrapper<LingshanSpecialCrowdPersonTypeEntity> q = new LambdaQueryWrapper<>();
q.eq(LingshanSpecialCrowdPersonTypeEntity::getSpecialType, specialType);
q.eq(LingshanSpecialCrowdPersonTypeEntity::getResiId, resiId);
public void deleteByType(String resiId) {
// 先删除type
specialCrowdPersonTypeDao.deletePhysical(specialType, resiId);
specialCrowdPersonTypeDao.deletePhysical(resiId);
LingshanSpecialCrowdPersonTypeEntity personType = specialCrowdPersonTypeDao.selectOne(q);
if (personType == null) {
return;
}
IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId);
// 再删除detail
specialCrowdDetailAzbjDao.deletePhysical(personType.getIdCard());
specialCrowdDetailXfryDao.deletePhysical(personType.getIdCard());
specialCrowdDetailJdryDao.deletePhysical(personType.getIdCard());
specialCrowdDetailSqjzDao.deletePhysical(personType.getIdCard());
specialCrowdDetailJzhzDao.deletePhysical(personType.getIdCard());
specialCrowdDetailAzbjDao.deletePhysical(resiInfo.getIdCard());
specialCrowdDetailXfryDao.deletePhysical(resiInfo.getIdCard());
specialCrowdDetailJdryDao.deletePhysical(resiInfo.getIdCard());
specialCrowdDetailSqjzDao.deletePhysical(resiInfo.getIdCard());
specialCrowdDetailJzhzDao.deletePhysical(resiInfo.getIdCard());
}
}

2
epmet-user/epmet-user-server/src/main/resources/mapper/LingshanSpecialCrowdPersonTypeDao.xml

@ -32,7 +32,7 @@
, UPDATED_TIME = values(UPDATED_TIME)
</insert>
<delete id="deletePhysical">
delete from lingshan_special_crowd_person_type where RESI_ID = #{resiId} and SPECIAL_TYPE = #{specialType}
delete from lingshan_special_crowd_person_type where RESI_ID = #{resiId}
</delete>
<select id="listSpecialCrowds"

Loading…
Cancel
Save