diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcDangerousChemicalsDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcDangerousChemicalsDTO.java index 8afffa5726..92e3ecf439 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcDangerousChemicalsDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcDangerousChemicalsDTO.java @@ -1,8 +1,9 @@ package com.epmet.dto; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; /** @@ -21,6 +22,11 @@ public class IcDangerousChemicalsDTO implements Serializable { */ private String id; + /** + * 灵山:所属网格 + */ + private String gridId; + /** * 客户Id */ @@ -36,6 +42,11 @@ public class IcDangerousChemicalsDTO implements Serializable { */ private String agencyIdPath; + /** + * 灵山:GRID_ID的全路径;包含grid_id + */ + private String orgIdPath; + /** * 来源【新增:add 导入:import 】 */ @@ -62,19 +73,19 @@ public class IcDangerousChemicalsDTO implements Serializable { private String dangerType; /** - * 负责人姓名 + * 负责人姓名;灵山项目中此列叫联系人 */ - private String principalName; + private String principalName; /** - * 负责人电话 + * 负责人电话;灵山项目中此列叫联系电话 */ - private String principalMobile; + private String principalMobile; /** - * 经营地址 + * 经营地址;灵山项目中此列叫企业地址 */ - private String address; + private String address; /** * 经度 @@ -91,6 +102,36 @@ public class IcDangerousChemicalsDTO implements Serializable { */ private String remark; + /** + * 灵山:是否重点安全企业;1是;0不是;必填 + */ + private Boolean securityFlag; + + /** + * 灵山:安全负责人姓名 + */ + private String securityPrincipalName; + + /** + * 灵山:手机号 + */ + private String securityPrincipalMobile; + + /** + * 灵山:包企领导 + */ + private String bqLd; + + /** + * 灵山:包企干部 + */ + private String bqGb; + + /** + * 灵山:企业介绍 + */ + private String companyProfile; + /** * 删除标识 */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcDangerousChemicalsAddEditFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcDangerousChemicalsAddEditFormDTO.java index c67cb48fb2..8a0747d5f1 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcDangerousChemicalsAddEditFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcDangerousChemicalsAddEditFormDTO.java @@ -1,12 +1,11 @@ package com.epmet.dto.form; -import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; /** @@ -21,22 +20,36 @@ public class IcDangerousChemicalsAddEditFormDTO implements Serializable { public interface Del extends CustomerClientShowGroup { } + public interface LingShanAddGroup extends CustomerClientShowGroup { + } + + public interface LingShanEditGroup extends CustomerClientShowGroup { + } + + /** + * 灵山:所属网格 + */ + @NotBlank(message = "所属网格不能为空", groups = {LingShanAddGroup.class, LingShanEditGroup.class}) + private String gridId; + /** * 场所Id */ - @NotBlank(message = "场所Id不能为空", groups = {UpdateGroup.class, Del.class}) + @NotBlank(message = "企业Id不能为空", groups = {LingShanEditGroup.class, Del.class}) private String icDangerousChemicalsId; /** * 企业名称 */ - @NotBlank(message = "企业名称不能为空", groups = {AddGroup.class}) - @Length(max = 50, message = "场所名称不能超过50位", groups = AddGroup.class) + @NotBlank(message = "企业名称不能为空", groups = {LingShanAddGroup.class, LingShanEditGroup.class}) + @Length(max = 35, message = "企业名称最多输入35字", groups = LingShanAddGroup.class) private String name; + /** * 企业类型值 */ - @NotBlank(message = "企业类型不能为空", groups = {AddGroup.class}) + @NotBlank(message = "企业类型不能为空", groups = {LingShanAddGroup.class, LingShanEditGroup.class}) private String category; + /** * 周边安全距离 */ @@ -46,36 +59,70 @@ public class IcDangerousChemicalsAddEditFormDTO implements Serializable { */ private String dangerType; /** - * 负责人 + * 负责人姓名;灵山项目中此列叫联系人 */ private String principalName; + /** - * 联系电话 + * 负责人电话;灵山项目中此列叫联系电话 */ private String principalMobile; + /** * 经度 */ - @NotBlank(message = "经度不能为空", groups = {AddGroup.class}) + @NotBlank(message = "请完善经度信息", groups = {LingShanAddGroup.class, LingShanEditGroup.class}) private String longitude; /** * 维度 */ - @NotBlank(message = "维度不能为空", groups = {AddGroup.class}) + @NotBlank(message = "请完善纬度信息", groups = {LingShanAddGroup.class, LingShanEditGroup.class}) private String latitude; + /** - * 地址 + * 经营地址;灵山项目中此列叫企业地址 */ - @NotBlank(message = "地址不能为空", groups = {AddGroup.class}) - @Length(max = 50, message = "地址不能超过50位", groups = AddGroup.class) + @NotBlank(message = "企业地址不能为空", groups = {LingShanAddGroup.class, LingShanEditGroup.class}) + @Length(max = 200, message = "企业地址最多输入200字", groups = {LingShanAddGroup.class, LingShanEditGroup.class}) private String address; + /** * 备注 */ private String remark; + /** + * 灵山:是否重点安全企业;1是;0不是;必填 + */ + @NotNull(message = "是否重点安全企业不能为空", groups = {LingShanAddGroup.class, LingShanEditGroup.class}) + private Boolean securityFlag; + + /** + * 灵山:安全负责人姓名 + */ + private String securityPrincipalName; + + /** + * 灵山:手机号 + */ + private String securityPrincipalMobile; + + /** + * 灵山:包企领导 + */ + private String bqLd; + + /** + * 灵山:包企干部 + */ + private String bqGb; + + /** + * 灵山:企业介绍 + */ + private String companyProfile; + private String customerId; private String userId; - } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcDangerousChemicalsListFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcDangerousChemicalsListFormDTO.java index b0b7e589f4..3c03625cd8 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcDangerousChemicalsListFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcDangerousChemicalsListFormDTO.java @@ -1,5 +1,6 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.dto.form.PageFormDTO; import lombok.Data; import java.io.Serializable; @@ -9,34 +10,67 @@ import java.io.Serializable; * @Author sun */ @Data -public class IcDangerousChemicalsListFormDTO implements Serializable { +public class IcDangerousChemicalsListFormDTO extends PageFormDTO implements Serializable { private static final long serialVersionUID = 9156247659994638103L; /** - * 场所名称 + * 组织或者网格id + */ + private String orgId; + /** + * 组织:agency + * 网格:grid + */ + private String orgType; + + /** + * 灵山:GRID_ID的全路径;包含grid_id + * 接口内部赋值,用于sql + */ + private String orgIdPath; + + /** + * 企业名称 */ private String name; + /** - * 场所分类,字典表值 + * 企业类型,字典表值 */ private String category; + /** * 危化品种类字典值 + * 灵山界面暂无此列 */ private String dangerType; + /** - * 页码 + * 企业地址 + * 经营地址;灵山项目中此列叫企业地址 */ - private Integer pageNo = 1; + private String address; + + /** + * 联系人 + * 负责人姓名;灵山项目中此列叫联系人 + */ + private String principalName; + /** - * 每页显示数量 + * 灵山:安全负责人姓名 */ - private Integer pageSize = 20; + private String securityPrincipalName; - private Boolean isPage = true; private String icDangerousChemicalsId; + + /** + * tokenDto.customerId + */ private String customerId; + /** + * tokenDto.userId + */ private String staffId; - private String agencyId; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcDangerousChemicalsListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcDangerousChemicalsListResultDTO.java index bf00d9205e..5d11141ab9 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcDangerousChemicalsListResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcDangerousChemicalsListResultDTO.java @@ -16,6 +16,14 @@ public class IcDangerousChemicalsListResultDTO implements Serializable { * 企业Id */ private String icDangerousChemicalsId; + /** + * 灵山:所属网格 + */ + private String gridId; + /** + * xxx社区-网格名称 + */ + private String gridName; /** * 组织Id */ @@ -53,13 +61,15 @@ public class IcDangerousChemicalsListResultDTO implements Serializable { */ private String dangerTypeName; /** - * 负责人 + * 负责人姓名;灵山项目中此列叫联系人 */ private String principalName; + /** - * 联系电话 + * 负责人电话;灵山项目中此列叫联系电话 */ private String principalMobile; + /** * 经度 */ @@ -69,7 +79,7 @@ public class IcDangerousChemicalsListResultDTO implements Serializable { */ private String latitude; /** - * 地址 + * 经营地址;灵山项目中此列叫企业地址 */ private String address; /** @@ -77,4 +87,33 @@ public class IcDangerousChemicalsListResultDTO implements Serializable { */ private String remark; + /** + * 灵山:是否重点安全企业;1是;0不是;必填 + */ + private Boolean securityFlag; + + /** + * 灵山:安全负责人姓名 + */ + private String securityPrincipalName; + + /** + * 灵山:手机号 + */ + private String securityPrincipalMobile; + + /** + * 灵山:包企领导 + */ + private String bqLd; + + /** + * 灵山:包企干部 + */ + private String bqGb; + + /** + * 灵山:企业介绍 + */ + private String companyProfile; } 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 d69c856fb1..522bd55c3a 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,7 +10,6 @@ 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.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; @@ -19,9 +18,6 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.DefaultGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcDangerousChemicalsDTO; import com.epmet.dto.form.IcDangerousChemicalsAddEditFormDTO; @@ -32,7 +28,6 @@ import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.excel.IcDangerousChemicalsExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcDangerousChemicalsService; -import com.epmet.utils.ImportTaskUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; @@ -72,6 +67,12 @@ public class IcDangerousChemicalsController { @Autowired private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + /** + * 重点危化品企业 列表分页 + * @param tokenDto + * @param formDTO + * @return + */ @RequestMapping("list") public Result> list(@LoginUser TokenDto tokenDto, @RequestBody IcDangerousChemicalsListFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); @@ -85,26 +86,44 @@ public class IcDangerousChemicalsController { return new Result().ok(data); } + /** + * 重点危化品企业 新增 + * @param tokenDto + * @param dto + * @return + */ @NoRepeatSubmit @PostMapping("add") public Result save(@LoginUser TokenDto tokenDto, @RequestBody IcDangerousChemicalsAddEditFormDTO dto) { - ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + ValidatorUtils.validateEntity(dto, IcDangerousChemicalsAddEditFormDTO.LingShanAddGroup.class); dto.setCustomerId(tokenDto.getCustomerId()); dto.setUserId(tokenDto.getUserId()); icDangerousChemicalsService.save(dto); return new Result(); } + /** + * 重点危化品企业 编辑 + * @param tokenDto + * @param formDTO + * @return + */ @NoRepeatSubmit @PostMapping("edit") public Result update(@LoginUser TokenDto tokenDto, @RequestBody IcDangerousChemicalsAddEditFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, UpdateGroup.class, DefaultGroup.class); + ValidatorUtils.validateEntity(formDTO, IcDangerousChemicalsAddEditFormDTO.LingShanEditGroup.class); formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); icDangerousChemicalsService.update(formDTO); return new Result(); } + /** + * 重点危化品企业 删除 + * @param tokenDto + * @param formDTO + * @return + */ @PostMapping("del") public Result delete(@LoginUser TokenDto tokenDto, @RequestBody IcDangerousChemicalsAddEditFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, IcDangerousChemicalsAddEditFormDTO.Del.class); @@ -114,11 +133,21 @@ public class IcDangerousChemicalsController { return new Result(); } + /** + * 重点危化品企业 查看详情 + * @param formDTO + * @return + */ @RequestMapping("detail") public Result detail(@RequestBody IcDangerousChemicalsListFormDTO formDTO) { return new Result().ok(icDangerousChemicalsService.detail(formDTO)); } + /** + * 重点危化品企业 下载导入模板 + * @param response + * @throws IOException + */ @RequestMapping(value = "download", method = {RequestMethod.GET, RequestMethod.POST}) public void downloadTemplate(HttpServletResponse response) throws IOException { response.setCharacterEncoding("UTF-8"); @@ -137,6 +166,13 @@ public class IcDangerousChemicalsController { } } + /** + * 重点危化品企业 导出 + * @param tokenDto + * @param formDTO + * @param response + * @throws IOException + */ @PostMapping("export") public void export(@LoginUser TokenDto tokenDto, @RequestBody IcDangerousChemicalsListFormDTO formDTO, HttpServletResponse response) throws IOException { formDTO.setCustomerId(tokenDto.getCustomerId()); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcDangerousChemicalsDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcDangerousChemicalsDao.java index 83adfa87b8..1cc152c5f5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcDangerousChemicalsDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcDangerousChemicalsDao.java @@ -20,9 +20,8 @@ public interface IcDangerousChemicalsDao extends BaseDao selectDangerousChemicalsList(IcDangerousChemicalsListFormDTO formDTO); - void del(IcDangerousChemicalsEntity entity); + void del(@Param("id") String id,@Param("updatedBy") String updatedBy); void importInsert(@Param("entityList") List entityList); - void delByAgencyAndName(IcDangerousChemicalsEntity entity); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcDangerousChemicalsEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcDangerousChemicalsEntity.java index 413cba21d6..edf0054d58 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcDangerousChemicalsEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/IcDangerousChemicalsEntity.java @@ -24,6 +24,11 @@ public class IcDangerousChemicalsEntity extends BaseEpmetEntity { */ private String customerId; + /** + * 灵山:所属网格 + */ + private String gridId; + /** * 所属组织机构Id */ @@ -34,6 +39,11 @@ public class IcDangerousChemicalsEntity extends BaseEpmetEntity { */ private String agencyIdPath; + /** + * 灵山:GRID_ID的全路径;包含grid_id + */ + private String orgIdPath; + /** * 来源【新增:add 导入:import 】 */ @@ -59,19 +69,19 @@ public class IcDangerousChemicalsEntity extends BaseEpmetEntity { */ private String dangerType; - /** - * 负责人姓名 - */ + /** + * 负责人姓名;灵山项目中此列叫联系人 + */ private String principalName; - /** - * 负责人电话 - */ + /** + * 负责人电话;灵山项目中此列叫联系电话 + */ private String principalMobile; - /** - * 经营地址 - */ + /** + * 经营地址;灵山项目中此列叫企业地址 + */ private String address; /** @@ -89,6 +99,36 @@ public class IcDangerousChemicalsEntity extends BaseEpmetEntity { */ private String remark; + /** + * 灵山:是否重点安全企业;1是;0不是;必填 + */ + private Boolean securityFlag; + + /** + * 灵山:安全负责人姓名 + */ + private String securityPrincipalName; + + /** + * 灵山:手机号 + */ + private String securityPrincipalMobile; + + /** + * 灵山:包企领导 + */ + private String bqLd; + + /** + * 灵山:包企干部 + */ + private String bqGb; + + /** + * 灵山:企业介绍 + */ + private String companyProfile; + @TableField(exist = false) private String dangerTypeName; 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 c62bad0456..e8fa1a32ed 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 @@ -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 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 list = baseDao.selectDangerousChemicalsList(formDTO); @@ -138,60 +148,56 @@ public class IcDangerousChemicalsServiceImpl extends BaseServiceImpl tWrapper = new LambdaQueryWrapper<>(); - tWrapper.eq(IcDangerousChemicalsEntity::getAgencyId, staffInfo.getAgencyId()); - tWrapper.eq(IcDangerousChemicalsEntity::getName, formDTO.getName()); - List 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 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 tWrapper = new LambdaQueryWrapper<>(); - tWrapper.eq(IcDangerousChemicalsEntity::getAgencyId, staffInfo.getAgencyId()); - tWrapper.ne(IcDangerousChemicalsEntity::getId, formDTO.getIcDangerousChemicalsId()); - tWrapper.eq(IcDangerousChemicalsEntity::getName, formDTO.getName()); - List 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 diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcDangerousChemicalsDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcDangerousChemicalsDao.xml index 99d3138558..4a37272196 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcDangerousChemicalsDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcDangerousChemicalsDao.xml @@ -67,48 +67,75 @@ updated_time = NOW() - SELECT - id icDangerousChemicalsId, - agency_id agencyId, - source_type sourceType, - `name` name, - category category, - safe_distance safeDistance, - CONCAT(safe_distance,'公里') safeDistanceName, - danger_type dangerType, - principal_name principalName, - principal_mobile principalMobile, - address address, - longitude longitude, - latitude latitude, - remark remark + dc.id icDangerousChemicalsId, + dc.grid_id gridId, + concat(ORGANIZATION_NAME,'-',cg.GRID_NAME)as gridName, + dc.agency_id agencyId, + dc.source_type sourceType, + dc.`name` name, + dc.category category, + dc.safe_distance safeDistance, + CONCAT(dc.safe_distance,'公里') safeDistanceName, + dc.danger_type dangerType, + dc.principal_name principalName, + dc.principal_mobile principalMobile, + dc.address address, + dc.longitude longitude, + dc.latitude latitude, + dc.remark remark, + dc.SECURITY_FLAG securityFlag, + dc.SECURITY_PRINCIPAL_NAME securityPrincipalName, + dc.BQ_LD bqLd, + dc.BQ_GB bqGb, + dc.COMPANY_PROFILE companyProfile FROM - ic_dangerous_chemicals + ic_dangerous_chemicals dc + left join customer_grid cg + on(dc.grid_id=cg.id) + left join customer_agency ca + on(cg.pid=ca.id) WHERE - del_flag = '0' + dc.del_flag = '0' - AND id = #{icDangerousChemicalsId} + AND dc.id = #{icDangerousChemicalsId} - AND customer_id = #{customerId} + AND dc.customer_id = #{customerId} - - AND agency_id_path LIKE CONCAT('%',#{agencyId},'%') + + + AND dc.org_id_path like concat(#{orgIdPath},'%') + + + + + AND dc.grid_id=#{orgId} + - AND name LIKE CONCAT('%', #{name}, '%') + AND dc.name LIKE CONCAT('%', #{name}, '%') - AND category = #{category} + AND dc.category = #{category} - AND danger_type = #{dangerType} + AND dc.danger_type = #{dangerType} + + + AND dc.ADDRESS LIKE CONCAT('%',#{address},'%') + + + AND dc.PRINCIPAL_NAME LIKE CONCAT('%',#{principalName},'%') + + + AND dc.SECURITY_PRINCIPAL_NAME LIKE CONCAT('%',#{securityPrincipalName},'%') - ORDER BY created_time DESC + ORDER BY dc.created_time DESC - + UPDATE ic_dangerous_chemicals SET del_flag = '1', updated_by = #{updatedBy}, @@ -118,14 +145,5 @@ AND del_flag = '0' - - DELETE - FROM - ic_dangerous_chemicals - WHERE - del_flag != '0' - AND agency_id = #{agencyId} - AND `name` = #{name} - \ No newline at end of file