From e7f9b111bc1f7c23936ca9e76762545a3e7d464c Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 19 Jul 2022 15:05:25 +0800 Subject: [PATCH] commityixia --- .../commons/tools/constant/Constant.java | 16 ++ .../dto/form/policy/IcPolicyFormDTO.java | 99 +++++++++++ .../form/policy/IcPolicyRuleDetailDTO.java | 60 +++++++ .../dto/form/policy/IcPolicyRuleFormDTO.java | 37 ++++ .../epmet/controller/IcPolicyController.java | 36 ++++ .../entity/IcPolicyRuleDetailEntity.java | 5 +- .../com/epmet/service/IcPolicyService.java | 15 ++ .../service/impl/IcPolicyServiceImpl.java | 158 +++++++++++++++++- 8 files changed, 416 insertions(+), 10 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyRuleDetailDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyRuleFormDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java index 77875d5415..95cc929784 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java @@ -174,4 +174,20 @@ public interface Constant { String OPITON_SOURCE_REMOTE = "remote"; String OPITON_SOURCE_LOCAL = "local"; + + /** + * 附件状态(审核中:auditing; + auto_passed: 自动通过; + review:结果不确定,需要人工审核; + block: 结果违规; + rejected:人工审核驳回; + approved:人工审核通过) + 现在图片是同步审核的,所以图片只有auto_passed一种状态 + */ + String AUDITING="auditing"; + String AUTO_PASSED="auto_passed"; + String REVIEW="review"; + String BLOCK="block"; + String REJECTED="rejected"; + String APPROVED="approved"; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyFormDTO.java new file mode 100644 index 0000000000..c605e8b062 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyFormDTO.java @@ -0,0 +1,99 @@ +package com.epmet.dto.form.policy; + +import com.epmet.commons.tools.dto.form.FileCommonDTO; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.epmet.dto.IcPolicyCategoryDTO; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @Description + * @Author yzm + * @Date 2022/7/19 13:09 + */ + +@Data +public class IcPolicyFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + public interface UpdateUserInternalGroup { + } + @NotBlank(message = "政策id不能为空",groups = UpdateUserInternalGroup.class) + private String policyId; + /** + * 政策创建人,所属组织id + */ + @NotBlank(message = "orgId不能为空",groups = UpdateUserInternalGroup.class) + private String orgId; + + /** + * AGENCY_ID的全路径,含agency_id + */ + @NotBlank(message = "orgIdPath不能为空",groups = UpdateUserInternalGroup.class) + private String orgIdPath; + + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空", groups = AddUserInternalGroup.class) + private String customerId; + private String staffId; + + /** + * 政策级别,0市级;1区级;2街道级 + */ + @NotBlank(message = "政策级别不能为空", groups = AddUserShowGroup.class) + private String policyLevel; + + /** + * 生效起止日期 + */ + @JsonFormat(pattern="yyyy-MM-dd") + @NotNull(message = "政策开始日期不能为空", groups = AddUserShowGroup.class) + private Date startDate; + + /** + * 截止日期 + */ + @JsonFormat(pattern="yyyy-MM-dd") + @NotNull(message = "政策截止日期不能为空", groups = AddUserShowGroup.class) + private Date endDate; + + /** + * 政策标题 + */ + @NotBlank(message = "政策标题不能为空", groups = AddUserShowGroup.class) + @Length(max = 100, groups = AddUserShowGroup.class, message = "政策标题最多输入100字") + private String title; + + /** + * 政策内容 + */ + @NotBlank(message = "政策内容不能为空", groups = AddUserShowGroup.class) + @Length(max = 2000, groups = AddUserShowGroup.class, message = "政策内容最多输入2000字") + private String content; + + private List categoryList; + + // @Valid + private List attachmentList; + + @Valid + @NotEmpty(message = "政策细则不能为空",groups =AddUserShowGroup.class ) + private List ruleList; +} + diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyRuleDetailDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyRuleDetailDTO.java new file mode 100644 index 0000000000..b88ac693c6 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyRuleDetailDTO.java @@ -0,0 +1,60 @@ +package com.epmet.dto.form.policy; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description + * @Author yzm + * @Date 2022/7/19 13:32 + */ +@Data +public class IcPolicyRuleDetailDTO { + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + /** + * 规则描述文字,例如:基础信息性别等于女 + */ + private String ruleDesc; + + /** + * 与上一条的关系;and、or + */ + private String lastLogicalRel; + + /** + * 分组id;人员信息有值; + */ + private String itemGroupId; + + /** + * 表名;人员信息有值;房屋信息也有值 + */ + private String itemId; + + /** + * 查询类型:等于、不等于....;来源于字典表sql_query_type + */ + @NotBlank(message = "查询类型不能为空", groups = AddUserShowGroup.class) + private String queryType; + + /** + * 表名;人员信息有值; + */ + private String colTable; + + /** + * 人员信息存储组件对应的列名;房屋信息存储ic_house表的列名;统计信息应该是定义到字典表,这里存储字典key就行吧 + */ + @NotBlank(message = "条件不能为空", groups = AddUserShowGroup.class) + private String colKey; + + /** + * 参数值 + */ + @NotBlank(message = "参数值不能为空", groups = AddUserShowGroup.class) + private String colVal; +} + diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyRuleFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyRuleFormDTO.java new file mode 100644 index 0000000000..99ed14eb4e --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/policy/IcPolicyRuleFormDTO.java @@ -0,0 +1,37 @@ +package com.epmet.dto.form.policy; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description + * @Author yzm + * @Date 2022/7/19 13:31 + */ +@Data +public class IcPolicyRuleFormDTO implements Serializable { + + /** + * 细则名称 + */ + @NotBlank(message = "细则名称不能为空", groups = IcPolicyFormDTO.AddUserShowGroup.class) + private String ruleName; + /** + * 人员信息 + */ + // @Valid + // @NotEmpty + private List resiRuleList; + /** + * 房屋信息 + */ + private List houseRuleList; + /** + * 统计信息 + */ + private List statRuleList; +} + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPolicyController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPolicyController.java index 1cebba0484..8b17d4d6ed 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPolicyController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPolicyController.java @@ -1,7 +1,11 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.IcPolicyItemResultDTO; +import com.epmet.dto.form.policy.IcPolicyFormDTO; import com.epmet.service.IcPolicyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -34,4 +38,36 @@ public class IcPolicyController { return new Result>().ok(list); } + /** + * 政策管理-新增/修改 + * + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("add") + public Result add(@LoginUser TokenDto tokenDto, @RequestBody IcPolicyFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO, IcPolicyFormDTO.AddUserShowGroup.class, IcPolicyFormDTO.AddUserInternalGroup.class); + icPolicyService.addPolicy(formDTO); + return new Result(); + } + + /** + * 编辑政策 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("update") + public Result update(@LoginUser TokenDto tokenDto, @RequestBody IcPolicyFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setStaffId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO, IcPolicyFormDTO.AddUserShowGroup.class, IcPolicyFormDTO.AddUserInternalGroup.class,IcPolicyFormDTO.UpdateUserInternalGroup.class); + icPolicyService.updatePolicy(formDTO); + return new Result(); + } + + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcPolicyRuleDetailEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcPolicyRuleDetailEntity.java index 57d8f91ab1..ee959255b0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcPolicyRuleDetailEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcPolicyRuleDetailEntity.java @@ -1,13 +1,10 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 政策匹配规则明细 * @@ -67,7 +64,7 @@ public class IcPolicyRuleDetailEntity extends BaseEpmetEntity { private String queryType; /** - * 表名;人员信息有值; + * 表名;人员信息有值;房屋信息也有值 */ private String colTable; diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPolicyService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPolicyService.java index 86a984760f..b464facd1a 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPolicyService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPolicyService.java @@ -2,6 +2,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.IcPolicyItemResultDTO; +import com.epmet.dto.form.policy.IcPolicyFormDTO; import com.epmet.entity.IcPolicyEntity; import java.util.List; @@ -15,9 +16,23 @@ import java.util.List; public interface IcPolicyService extends BaseService { /** * 房屋信息、统计信息查询有哪些可选项 + * * @param customerId * @param groupType * @return */ List itemList(String customerId, String groupType); + + /** + * 政策管理-新增/修改 + * + * @param formDTO + */ + void addPolicy(IcPolicyFormDTO formDTO); + + /** + * 修改政策 + * @param formDTO + */ + void updatePolicy(IcPolicyFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPolicyServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPolicyServiceImpl.java index 90162b4231..183a1d4cad 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPolicyServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPolicyServiceImpl.java @@ -2,13 +2,26 @@ package com.epmet.service.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.Constant; -import com.epmet.dao.IcPolicyDao; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.dto.form.FileCommonDTO; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.*; +import com.epmet.dto.IcPolicyCategoryDTO; import com.epmet.dto.IcPolicyItemResultDTO; -import com.epmet.entity.IcPolicyEntity; +import com.epmet.dto.form.policy.IcPolicyFormDTO; +import com.epmet.dto.form.policy.IcPolicyRuleDetailDTO; +import com.epmet.dto.form.policy.IcPolicyRuleFormDTO; +import com.epmet.entity.*; import com.epmet.service.IcPolicyService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -22,6 +35,15 @@ import java.util.List; @Service public class IcPolicyServiceImpl extends BaseServiceImpl implements IcPolicyService { + @Autowired + private IcPolicyCategoryDao icPolicyCategoryDao; + @Autowired + private IcPolicyRuleDao icPolicyRuleDao; + @Autowired + private HeartAttachmentDao heartAttachmentDao; + @Autowired + private IcPolicyRuleDetailDao icPolicyRuleDetailDao; + /** * 房屋信息、统计信息查询有哪些可选项 @@ -32,13 +54,137 @@ public class IcPolicyServiceImpl extends BaseServiceImpl itemList(String customerId, String groupType) { - if(StringUtils.isBlank(groupType)){ + if (StringUtils.isBlank(groupType)) { return new ArrayList<>(); } - List resultList=baseDao.selectItemList(customerId,groupType); - if(CollectionUtils.isEmpty(resultList)){ - return baseDao.selectItemList(Constant.DEFAULT_CUSTOMER,groupType); + List resultList = baseDao.selectItemList(customerId, groupType); + if (CollectionUtils.isEmpty(resultList)) { + return baseDao.selectItemList(Constant.DEFAULT_CUSTOMER, groupType); } return resultList; } + + /** + * 政策管理-新增/修改 + * + * @param formDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void addPolicy(IcPolicyFormDTO formDTO) { + // 校验参数 + checkAddFormDTO(formDTO); + // 设置所属组织 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + if (null == staffInfo || StringUtils.isBlank(staffInfo.getAgencyId())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "工作人员缓存信息异常", "工作人员信息异常"); + } + IcPolicyEntity icPolicyEntity = ConvertUtils.sourceToTarget(formDTO, IcPolicyEntity.class); + icPolicyEntity.setOrgId(staffInfo.getAgencyId()); + icPolicyEntity.setOrgIdPath(StringUtils.isNotBlank(staffInfo.getAgencyPIds()) ? staffInfo.getAgencyPIds().concat(StrConstant.COLON).concat(staffInfo.getAgencyId()) : staffInfo.getAgencyId()); + // 插入政策主表 + baseDao.insert(icPolicyEntity); + // 插入细则 + int ruleSort = 1; + for (IcPolicyRuleFormDTO rule : formDTO.getRuleList()) { + IcPolicyRuleEntity ruleEntity = new IcPolicyRuleEntity(); + ruleEntity.setCustomerId(formDTO.getCustomerId()); + ruleEntity.setIcPolicyId(icPolicyEntity.getId()); + ruleEntity.setRuleName(rule.getRuleName()); + ruleEntity.setSort(ruleSort); + icPolicyRuleDao.insert(ruleEntity); + if (CollectionUtils.isNotEmpty(rule.getResiRuleList())) { + int resiRuleSort = 1; + for (IcPolicyRuleDetailDTO ruleDetailDTO : rule.getResiRuleList()) { + IcPolicyRuleDetailEntity icPolicyRuleDetailEntity = ConvertUtils.sourceToTarget(ruleDetailDTO, IcPolicyRuleDetailEntity.class); + icPolicyRuleDetailEntity.setCustomerId(formDTO.getCustomerId()); + icPolicyRuleDetailEntity.setIcPolicyId(icPolicyEntity.getId()); + icPolicyRuleDetailEntity.setRuleId(ruleEntity.getId()); + icPolicyRuleDetailEntity.setSort(resiRuleSort); + icPolicyRuleDetailEntity.setGroupType("resi"); + icPolicyRuleDetailDao.insert(icPolicyRuleDetailEntity); + resiRuleSort++; + } + } + if (CollectionUtils.isNotEmpty(rule.getHouseRuleList())) { + int houseRuleSort = 1; + for (IcPolicyRuleDetailDTO ruleDetailDTO : rule.getHouseRuleList()) { + IcPolicyRuleDetailEntity icPolicyRuleDetailEntity = ConvertUtils.sourceToTarget(ruleDetailDTO, IcPolicyRuleDetailEntity.class); + icPolicyRuleDetailEntity.setCustomerId(formDTO.getCustomerId()); + icPolicyRuleDetailEntity.setIcPolicyId(icPolicyEntity.getId()); + icPolicyRuleDetailEntity.setRuleId(ruleEntity.getId()); + icPolicyRuleDetailEntity.setSort(houseRuleSort); + icPolicyRuleDetailEntity.setGroupType("house"); + icPolicyRuleDetailDao.insert(icPolicyRuleDetailEntity); + houseRuleSort++; + } + } + if (CollectionUtils.isNotEmpty(rule.getStatRuleList())) { + int statRuleSort = 1; + for (IcPolicyRuleDetailDTO ruleDetailDTO : rule.getStatRuleList()) { + IcPolicyRuleDetailEntity icPolicyRuleDetailEntity = ConvertUtils.sourceToTarget(ruleDetailDTO, IcPolicyRuleDetailEntity.class); + icPolicyRuleDetailEntity.setCustomerId(formDTO.getCustomerId()); + icPolicyRuleDetailEntity.setIcPolicyId(icPolicyEntity.getId()); + icPolicyRuleDetailEntity.setRuleId(ruleEntity.getId()); + icPolicyRuleDetailEntity.setSort(statRuleSort); + icPolicyRuleDetailEntity.setGroupType("stat"); + icPolicyRuleDetailDao.insert(icPolicyRuleDetailEntity); + statRuleSort++; + } + } + } + // 插入分类 + if (CollectionUtils.isNotEmpty(formDTO.getCategoryList())) { + for (IcPolicyCategoryDTO categoryDTO : formDTO.getCategoryList()) { + IcPolicyCategoryEntity icPolicyCategoryEntity = new IcPolicyCategoryEntity(); + icPolicyCategoryEntity.setCustomerId(formDTO.getCustomerId()); + icPolicyCategoryEntity.setIcPolicyId(icPolicyEntity.getId()); + icPolicyCategoryEntity.setCategoryCode(categoryDTO.getCategoryCode()); + icPolicyCategoryEntity.setCodePath(categoryDTO.getCodePath()); + icPolicyCategoryDao.insert(icPolicyCategoryEntity); + } + } + // 插入附件 + if (CollectionUtils.isNotEmpty(formDTO.getAttachmentList())) { + int sort = 1; + for (FileCommonDTO fileCommonDTO : formDTO.getAttachmentList()) { + HeartAttachmentEntity heartAttachment = new HeartAttachmentEntity(); + heartAttachment.setCustomerId(formDTO.getCustomerId()); + heartAttachment.setBusinessId(icPolicyEntity.getId()); + heartAttachment.setAttachTo("ic_policy"); + heartAttachment.setAttachmentName(fileCommonDTO.getName()); + heartAttachment.setAttachmentFormat(fileCommonDTO.getFormat()); + heartAttachment.setAttachmentType(fileCommonDTO.getType()); + heartAttachment.setAttachmentUrl(fileCommonDTO.getUrl()); + heartAttachment.setSort(sort); + heartAttachment.setStatus(Constant.AUTO_PASSED); + heartAttachment.setDuration(fileCommonDTO.getDuration()); + heartAttachmentDao.insert(heartAttachment); + sort++; + } + } + } + + + private void checkAddFormDTO(IcPolicyFormDTO formDTO) { + List ruleList = formDTO.getRuleList(); + for (IcPolicyRuleFormDTO rule : ruleList) { + if (CollectionUtils.isEmpty(rule.getResiRuleList()) + && CollectionUtils.isEmpty(rule.getHouseRuleList()) + && CollectionUtils.isEmpty(rule.getStatRuleList())) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员信息、房屋信息、统计信息任意选择一项填写", "请填写细则明细"); + } + } + // 政策文件最多3个先不限制了吧,前端控制下 + } + + /** + * 修改政策 + * + * @param formDTO + */ + @Override + public void updatePolicy(IcPolicyFormDTO formDTO) { + // todo + } } \ No newline at end of file