|
|
@ -71,7 +71,7 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void addPolicy(IcPolicyFormDTO formDTO) { |
|
|
|
public void addOrUpdatePolicy(IcPolicyFormDTO formDTO) { |
|
|
|
// 校验参数
|
|
|
|
checkAddFormDTO(formDTO); |
|
|
|
// 设置所属组织
|
|
|
@ -82,8 +82,17 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn |
|
|
|
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); |
|
|
|
if(StringUtils.isNotBlank(formDTO.getPolicyId())){ |
|
|
|
icPolicyEntity.setId(formDTO.getPolicyId()); |
|
|
|
baseDao.updateById(icPolicyEntity); |
|
|
|
}else{ |
|
|
|
// 插入政策主表
|
|
|
|
baseDao.insert(icPolicyEntity); |
|
|
|
//删除规则、规则明细、分类、附件
|
|
|
|
icPolicyRuleDao.deleteByIcPolicyId(icPolicyEntity.getId()); |
|
|
|
icPolicyCategoryDao.deleteByIcPolicyId(icPolicyEntity.getId()); |
|
|
|
heartAttachmentDao.deleteByBusinessId(icPolicyEntity.getId()); |
|
|
|
} |
|
|
|
// 插入细则
|
|
|
|
int ruleSort = 1; |
|
|
|
for (IcPolicyRuleFormDTO rule : formDTO.getRuleList()) { |
|
|
@ -93,6 +102,9 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn |
|
|
|
ruleEntity.setRuleName(rule.getRuleName()); |
|
|
|
ruleEntity.setSort(ruleSort); |
|
|
|
icPolicyRuleDao.insert(ruleEntity); |
|
|
|
//删除规则明细
|
|
|
|
icPolicyRuleDetailDao.deleteByRuleId(ruleEntity.getId()); |
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(rule.getResiRuleList())) { |
|
|
|
int resiRuleSort = 1; |
|
|
|
for (IcPolicyRuleDetailDTO ruleDetailDTO : rule.getResiRuleList()) { |
|
|
@ -148,17 +160,17 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getAttachmentList())) { |
|
|
|
int sort = 1; |
|
|
|
for (FileCommonDTO fileCommonDTO : formDTO.getAttachmentList()) { |
|
|
|
HeartAttachmentEntity heartAttachment = new HeartAttachmentEntity(); |
|
|
|
HeartAttachmentEntity heartAttachment = ConvertUtils.sourceToTarget(fileCommonDTO,HeartAttachmentEntity.class); |
|
|
|
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.setName(fileCommonDTO.getName());
|
|
|
|
// heartAttachment.setFormat(fileCommonDTO.getFormat());
|
|
|
|
// heartAttachment.setType(fileCommonDTO.getType());
|
|
|
|
// heartAttachment.setUrl(fileCommonDTO.getUrl());
|
|
|
|
heartAttachment.setSort(sort); |
|
|
|
heartAttachment.setStatus(Constant.AUTO_PASSED); |
|
|
|
heartAttachment.setDuration(fileCommonDTO.getDuration()); |
|
|
|
// heartAttachment.setDuration(fileCommonDTO.getDuration());
|
|
|
|
heartAttachmentDao.insert(heartAttachment); |
|
|
|
sort++; |
|
|
|
} |
|
|
@ -178,13 +190,4 @@ public class IcPolicyServiceImpl extends BaseServiceImpl<IcPolicyDao, IcPolicyEn |
|
|
|
// 政策文件最多3个先不限制了吧,前端控制下
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改政策 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void updatePolicy(IcPolicyFormDTO formDTO) { |
|
|
|
// todo
|
|
|
|
} |
|
|
|
} |