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