|
|
@@ -3,16 +3,13 @@ package com.ydtech.modules.protocols.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.ydtech.core.page.PageRequest;
|
|
|
-import com.ydtech.core.page.PageResult;
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
|
-import com.ydtech.modules.protocol.entity.po.PtlAgreement;
|
|
|
import com.ydtech.modules.protocol.entity.po.PtlAreaLicense;
|
|
|
import com.ydtech.modules.protocol.service.PtlAreaLicenseService;
|
|
|
-import com.ydtech.modules.protocols.dao.PtlAgreementProductCostsAttrLinkMapper;
|
|
|
import com.ydtech.modules.protocols.dao.PtlAgreementUndwrtRulesNewMapper;
|
|
|
import com.ydtech.modules.protocols.entity.po.*;
|
|
|
-import com.ydtech.modules.protocols.entity.vo.AgreementProductCostsSave;
|
|
|
import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRules;
|
|
|
import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRulesSave;
|
|
|
import com.ydtech.modules.protocols.service.*;
|
|
|
@@ -22,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.crypto.spec.PSource;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -136,6 +134,9 @@ public class PtlAgreementUndwrtRulesNewServiceImpl extends ServiceImpl<PtlAgreem
|
|
|
|
|
|
//获取费用属性
|
|
|
List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
|
|
|
+ if (ids.isEmpty()) {
|
|
|
+ throw new SystemException("该协议暂无承保规则");
|
|
|
+ }
|
|
|
List<PtlAgreementUndwrtRulesAttrLink> list = ptlAgreementUndwrtRulesAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>()
|
|
|
.in(PtlAgreementUndwrtRulesAttrLink::getRulesId, ids));
|
|
|
|
|
|
@@ -225,7 +226,7 @@ public class PtlAgreementUndwrtRulesNewServiceImpl extends ServiceImpl<PtlAgreem
|
|
|
BeanUtils.copyProperties(agreementUndwrtRules, ptlAgreementUndwrtRulesNew);
|
|
|
ptlAgreementUndwrtRulesNew.setId(null);
|
|
|
int insert = baseMapper.insert(ptlAgreementUndwrtRulesNew);
|
|
|
-
|
|
|
+ agreementUndwrtRules.setId(ptlAgreementUndwrtRulesNew.getId());
|
|
|
//保存承包规则历史记录
|
|
|
PtlAgreementUndwrtRulesNewHistory ptlAgreementUndwrtRulesNewHistory = new PtlAgreementUndwrtRulesNewHistory();
|
|
|
BeanUtils.copyProperties(agreementUndwrtRules, ptlAgreementUndwrtRulesNewHistory);
|
|
|
@@ -431,4 +432,50 @@ public class PtlAgreementUndwrtRulesNewServiceImpl extends ServiceImpl<PtlAgreem
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public boolean copyRules(AgreementUndwrtRules agreementUndwrtRules) {
|
|
|
+ List<PtlAgreementUndwrtRulesNew> list = baseMapper.selectBatchIds(Arrays.asList(agreementUndwrtRules.getIds()));
|
|
|
+ for (PtlAgreementUndwrtRulesNew originalRule : list) {
|
|
|
+ PtlAgreementUndwrtRulesNew clonedRule = new PtlAgreementUndwrtRulesNew();
|
|
|
+ BeanUtils.copyProperties(originalRule, clonedRule, "id","agreementId");
|
|
|
+
|
|
|
+ clonedRule.setId(null);
|
|
|
+ clonedRule.setAgreementId(agreementUndwrtRules.getAgreementId());
|
|
|
+
|
|
|
+ AgreementUndwrtRules convertedAgreementUndwrtRules = convertToAgreementUndwrtRules(clonedRule);
|
|
|
+
|
|
|
+ convertedAgreementUndwrtRules.setRulesAttrList(agreementUndwrtRules.getRulesAttrList());
|
|
|
+
|
|
|
+ //调用承保规则新增方法
|
|
|
+ rulesAdd(convertedAgreementUndwrtRules);
|
|
|
+ List<PtlAgreementUndwrtRulesAttrLink> attrLinks =
|
|
|
+ ptlAgreementUndwrtRulesAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>().eq(PtlAgreementUndwrtRulesAttrLink::getRulesId, originalRule.getId()));
|
|
|
+
|
|
|
+ List<PtlAgreementUndwrtRulesAttrLinkHistory> undwrtRulesAttrLinkHistories = new ArrayList<>();
|
|
|
+ String uuid = IdGenerate.nextId();
|
|
|
+ attrLinks.forEach(x -> {
|
|
|
+ x.setId(null);
|
|
|
+ x.setRulesId(convertedAgreementUndwrtRules.getId());
|
|
|
+ PtlAgreementUndwrtRulesAttrLinkHistory costsAttrLinkHistory = new PtlAgreementUndwrtRulesAttrLinkHistory();
|
|
|
+ BeanUtils.copyProperties(x, costsAttrLinkHistory);
|
|
|
+ //设置承包规则费用因子历史记录
|
|
|
+ costsAttrLinkHistory.setBatch(uuid);
|
|
|
+ costsAttrLinkHistory.setId(null);
|
|
|
+ costsAttrLinkHistory.setOperatorType("add");
|
|
|
+ costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
|
|
|
+ costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
|
|
|
+ undwrtRulesAttrLinkHistories.add(costsAttrLinkHistory);
|
|
|
+ });
|
|
|
+ ptlAgreementUndwrtRulesAttrLinkHistoryService.saveBatch(undwrtRulesAttrLinkHistories);
|
|
|
+ ptlAgreementUndwrtRulesAttrLinkService.saveBatch(attrLinks);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ private AgreementUndwrtRules convertToAgreementUndwrtRules(PtlAgreementUndwrtRulesNew rule) {
|
|
|
+ AgreementUndwrtRules agreementUndwrtRules = new AgreementUndwrtRules();
|
|
|
+ BeanUtils.copyProperties(rule, agreementUndwrtRules,"ids");
|
|
|
+ return agreementUndwrtRules;
|
|
|
+ }
|
|
|
}
|