|  | @ -6,8 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.FieldConstant; |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.NumConstant; |  |  | 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.dto.result.CustomerStaffInfoCacheResult; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.enums.DictTypeEnum; |  |  | 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.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; | 
			
		
	
	
		
		
			
				
					|  | @ -16,27 +18,27 @@ import com.epmet.commons.tools.redis.common.CustomerOrgRedis; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |  |  | import com.epmet.commons.tools.redis.common.CustomerStaffRedis; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |  |  | import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.security.dto.TokenDto; |  |  | import com.epmet.commons.tools.security.dto.TokenDto; | 
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.commons.tools.utils.ConvertUtils; |  |  | import com.epmet.commons.tools.utils.*; | 
			
				
				
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.FileUtils; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.Result; |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  | import com.epmet.constants.ImportTaskConstants; |  |  | import com.epmet.constants.ImportTaskConstants; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.IcDangerousChemicalsDao; |  |  | import com.epmet.dao.IcDangerousChemicalsDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.CustomerAgencyDTO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.CustomerGridDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.IcDangerousChemicalsDTO; |  |  | 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.form.ImportTaskCommonFormDTO; |  |  | import com.epmet.dto.form.ImportTaskCommonFormDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.result.IcCityManagementListResultDTO; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 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.entity.IcDangerousChemicalsEntity; |  |  | import com.epmet.entity.IcDangerousChemicalsEntity; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.IcSuperiorResourceEntity; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.feign.EpmetAdminOpenFeignClient; |  |  | import com.epmet.feign.EpmetAdminOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |  |  | import com.epmet.feign.EpmetCommonServiceOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.feign.OssFeignClient; |  |  | import com.epmet.feign.OssFeignClient; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.model.DangerousChemicalsImportListener; |  |  | import com.epmet.model.DangerousChemicalsImportListener; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.model.DangerousChemicalsModel; |  |  | import com.epmet.model.DangerousChemicalsModel; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.CoverageService; |  |  | import com.epmet.service.CoverageService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.service.CustomerAgencyService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.service.CustomerGridService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.IcDangerousChemicalsService; |  |  | import com.epmet.service.IcDangerousChemicalsService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.utils.ImportTaskUtils; |  |  | import com.epmet.utils.ImportTaskUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.github.pagehelper.PageHelper; |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
	
		
		
			
				
					|  | @ -88,12 +90,20 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl<IcDangerous | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     public PageData<IcDangerousChemicalsListResultDTO> list(IcDangerousChemicalsListFormDTO formDTO) { |  |  |     public PageData<IcDangerousChemicalsListResultDTO> list(IcDangerousChemicalsListFormDTO formDTO) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isBlank(formDTO.getOrgId())||StringUtils.isBlank(formDTO.getOrgType())){ | 
			
		
	
		
		
			
				
					|  |  |             CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); |  |  |             CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); | 
			
		
	
		
		
			
				
					|  |  |             if (null == staffInfo) { |  |  |             if (null == staffInfo) { | 
			
		
	
		
		
			
				
					|  |  |                 throw new EpmetException("获取工作人员信息失败"); |  |  |                 throw new EpmetException("获取工作人员信息失败"); | 
			
		
	
		
		
			
				
					|  |  |             } |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |             //查询当前组织及下级数据
 |  |  |             //查询当前组织及下级数据
 | 
			
		
	
		
		
			
				
					
					|  |  |         formDTO.setAgencyId(staffInfo.getAgencyId()); |  |  |             formDTO.setOrgId(staffInfo.getAgencyId()); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |             formDTO.setOrgType(OrgTypeEnum.AGENCY.getCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(OrgTypeEnum.AGENCY.getCode().equals(formDTO.getOrgType())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             CustomerAgencyDTO agencyDTO=SpringContextUtils.getBean(CustomerAgencyService.class).get(formDTO.getOrgId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             formDTO.setOrgIdPath(PidUtils.convertPid2OrgIdPath(agencyDTO.getId(),agencyDTO.getPids())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         //列表/导出查询
 |  |  |         //列表/导出查询
 | 
			
		
	
		
		
			
				
					|  |  |         PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); |  |  |         PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); | 
			
		
	
		
		
			
				
					|  |  |         List<IcDangerousChemicalsListResultDTO> list = baseDao.selectDangerousChemicalsList(formDTO); |  |  |         List<IcDangerousChemicalsListResultDTO> list = baseDao.selectDangerousChemicalsList(formDTO); | 
			
		
	
	
		
		
			
				
					|  | @ -138,60 +148,56 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl<IcDangerous | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     @Transactional(rollbackFor = Exception.class) |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |     public void save(IcDangerousChemicalsAddEditFormDTO formDTO) { |  |  |     public void save(IcDangerousChemicalsAddEditFormDTO formDTO) { | 
			
		
	
		
		
			
				
					
					|  |  |         //1.获取当前工作人员缓存信息
 |  |  |         //1.获取网格信息
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |  |  |         CustomerGridDTO customerGridDTO=SpringContextUtils.getBean(CustomerGridService.class).get(formDTO.getGridId()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         if (null == staffInfo) { |  |  |         // 2.同一网格下,企业名称唯一
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); |  |  |         checkNameUnqiue(formDTO.getGridId(),formDTO.getName(), StrConstant.EPMETY_STR,customerGridDTO.getGridName()); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         //2.校验同组织下服务组织名称不能重复
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         LambdaQueryWrapper<IcDangerousChemicalsEntity> tWrapper = new LambdaQueryWrapper<>(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         tWrapper.eq(IcDangerousChemicalsEntity::getAgencyId, staffInfo.getAgencyId()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         tWrapper.eq(IcDangerousChemicalsEntity::getName, formDTO.getName()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         List<IcDangerousChemicalsEntity> entityList = baseDao.selectList(tWrapper); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         if (!CollectionUtils.isEmpty(entityList)) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "当前组织下已存在相同名称的场所"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |         //3.新增服务组织数据
 |  |  |         //3.新增服务组织数据
 | 
			
		
	
		
		
			
				
					|  |  |         IcDangerousChemicalsEntity entity = ConvertUtils.sourceToTarget(formDTO, IcDangerousChemicalsEntity.class); |  |  |         IcDangerousChemicalsEntity entity = ConvertUtils.sourceToTarget(formDTO, IcDangerousChemicalsEntity.class); | 
			
		
	
		
		
			
				
					|  |  |         entity.setSourceType("add"); |  |  |         entity.setSourceType("add"); | 
			
		
	
		
		
			
				
					
					|  |  |         entity.setAgencyId(staffInfo.getAgencyId()); |  |  |         entity.setAgencyId(customerGridDTO.getPid()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         entity.setAgencyIdPath(StringUtils.isEmpty(staffInfo.getAgencyPIds()) ? staffInfo.getAgencyId() : staffInfo.getAgencyPIds() + ":" + staffInfo.getAgencyId()); |  |  |         entity.setAgencyIdPath(customerGridDTO.getPids()); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         entity.setOrgIdPath(PidUtils.convertPid2OrgIdPath(customerGridDTO.getId(),customerGridDTO.getPids())); | 
			
		
	
		
		
			
				
					|  |  |         insert(entity); |  |  |         insert(entity); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * 同一网格下,企业名称唯一 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param gridId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param name | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param icDangerousChemicalsId | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private void checkNameUnqiue(String gridId, String name, String icDangerousChemicalsId,String gridName) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         LambdaQueryWrapper<IcDangerousChemicalsEntity> tWrapper = new LambdaQueryWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         tWrapper.eq(IcDangerousChemicalsEntity::getGridId, gridId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         tWrapper.eq(IcDangerousChemicalsEntity::getName, name) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 .ne(StringUtils.isNotBlank(icDangerousChemicalsId),IcDangerousChemicalsEntity::getId,icDangerousChemicalsId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (baseDao.selectCount(tWrapper) > NumConstant.ZERO) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String msg = String.format("%下已存在%s", gridName, name); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     @Transactional(rollbackFor = Exception.class) |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |     public void update(IcDangerousChemicalsAddEditFormDTO formDTO) { |  |  |     public void update(IcDangerousChemicalsAddEditFormDTO formDTO) { | 
			
		
	
		
		
			
				
					
					|  |  |         //1.获取当前工作人员缓存信息
 |  |  |         //1.获取网格信息
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |  |  |         CustomerGridDTO customerGridDTO=SpringContextUtils.getBean(CustomerGridService.class).get(formDTO.getGridId()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         if (null == staffInfo) { |  |  |         // 2.同一网格下,企业名称唯一
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); |  |  |         checkNameUnqiue(formDTO.getGridId(),formDTO.getName(), formDTO.getIcDangerousChemicalsId(),customerGridDTO.getGridName()); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         //2.校验同组织下服务组织名称不能重复
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         LambdaQueryWrapper<IcDangerousChemicalsEntity> tWrapper = new LambdaQueryWrapper<>(); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         tWrapper.eq(IcDangerousChemicalsEntity::getAgencyId, staffInfo.getAgencyId()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         tWrapper.ne(IcDangerousChemicalsEntity::getId, formDTO.getIcDangerousChemicalsId()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         tWrapper.eq(IcDangerousChemicalsEntity::getName, formDTO.getName()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         List<IcDangerousChemicalsEntity> entityList = baseDao.selectList(tWrapper); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         if (!CollectionUtils.isEmpty(entityList)) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "当前组织下已存在相同名称的服务组织"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |         //3.更新服务组织数据
 |  |  |         //3.更新服务组织数据
 | 
			
		
	
		
		
			
				
					|  |  |         IcDangerousChemicalsEntity entity = ConvertUtils.sourceToTarget(formDTO, IcDangerousChemicalsEntity.class); |  |  |         IcDangerousChemicalsEntity entity = ConvertUtils.sourceToTarget(formDTO, IcDangerousChemicalsEntity.class); | 
			
		
	
		
		
			
				
					|  |  |         entity.setId(formDTO.getIcDangerousChemicalsId()); |  |  |         entity.setId(formDTO.getIcDangerousChemicalsId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         entity.setAgencyId(customerGridDTO.getPid()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         entity.setAgencyIdPath(customerGridDTO.getPids()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         entity.setOrgIdPath(PidUtils.convertPid2OrgIdPath(customerGridDTO.getId(),customerGridDTO.getPids())); | 
			
		
	
		
		
			
				
					|  |  |         updateById(entity); |  |  |         updateById(entity); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     @Transactional(rollbackFor = Exception.class) |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |     public void delete(IcDangerousChemicalsAddEditFormDTO formDTO) { |  |  |     public void delete(IcDangerousChemicalsAddEditFormDTO formDTO) { | 
			
		
	
		
		
			
				
					
					|  |  |         IcDangerousChemicalsEntity entity = baseDao.selectById(formDTO.getIcDangerousChemicalsId()); |  |  |         baseDao.del(formDTO.getIcDangerousChemicalsId(),formDTO.getUserId()); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         //先删除本组织先可能存在的名称相同的已经是无效的历史数据,为了表中的唯一索引不失效
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         baseDao.delByAgencyAndName(entity); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         //再把当前数据置为无效数据
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         entity.setId(formDTO.getIcDangerousChemicalsId()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         entity.setUpdatedBy(formDTO.getUserId()); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         baseDao.del(entity); |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
	
		
		
			
				
					|  | 
 |