|
|
@@ -1,17 +1,21 @@
|
|
|
package com.jzg.organization.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.jzg.commons.entity.dto.AgreementRulesAddParam;
|
|
|
import com.jzg.commons.entity.dto.AgreementRulesEditParam;
|
|
|
+import com.jzg.commons.entity.dto.CostAgreementParam;
|
|
|
import com.jzg.commons.entity.po.PtlAgreementUndwrtRules;
|
|
|
import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
|
|
|
import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttrLink;
|
|
|
import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
|
|
|
import com.jzg.commons.entity.vo.AgreementRulesVo;
|
|
|
+import com.jzg.commons.entity.vo.PtlAgreementCostVo;
|
|
|
import com.jzg.organization.mapper.PtlAgreementUndwrtRulesAttrLinkMapper;
|
|
|
import com.jzg.organization.mapper.PtlAgreementUndwrtRulesAttrMapper;
|
|
|
import com.jzg.organization.mapper.PtlAgreementUndwrtRulesMapper;
|
|
|
+import com.jzg.organization.service.PtlAgreementCostService;
|
|
|
import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrLinkService;
|
|
|
import com.jzg.organization.service.PtlAgreementUndwrtRulesAttrService;
|
|
|
import com.jzg.organization.service.PtlAgreementUndwrtRulesService;
|
|
|
@@ -23,7 +27,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author dongxin
|
|
|
@@ -43,9 +49,23 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
@Autowired
|
|
|
private PtlAgreementUndwrtRulesAttrLinkService agreementUndwrtRulesAttrLinkService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PtlAgreementCostService ptlAgreementCostService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<AgreementRulesVo> queryList(String agreementId) {
|
|
|
List<AgreementRulesVo> rulesVos = baseMapper.queryList(agreementId);
|
|
|
+ if(CollUtil.isNotEmpty(rulesVos)){
|
|
|
+ for (AgreementRulesVo rulesVo : rulesVos) {
|
|
|
+ CostAgreementParam param = new CostAgreementParam();
|
|
|
+ param.setPtlAgreementId(agreementId);
|
|
|
+ param.setCoverRuleId(rulesVo.getId());
|
|
|
+ List<PtlAgreementCostVo> costVos = ptlAgreementCostService.queryByAgreementId(param);
|
|
|
+ if(CollUtil.isNotEmpty(costVos)){
|
|
|
+ rulesVo.setCostVoList(costVos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return rulesVos;
|
|
|
}
|
|
|
|
|
|
@@ -54,6 +74,8 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
public boolean rulesAdd(AgreementRulesAddParam param) {
|
|
|
// 根据协议id获取最大的序号
|
|
|
LambdaQueryWrapper<PtlAgreementUndwrtRules> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(PtlAgreementUndwrtRules::getAgreementId, param.getAgreementId())
|
|
|
+ .eq(PtlAgreementUndwrtRules::getIsDelete, 0);
|
|
|
queryWrapper.orderByDesc(PtlAgreementUndwrtRules::getOrderNum);
|
|
|
queryWrapper.last("LIMIT 1"); // 只取一个结果
|
|
|
PtlAgreementUndwrtRules maxRules = baseMapper.selectOne(queryWrapper);
|
|
|
@@ -65,8 +87,11 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
List<PtlAgreementUndwrtRulesAttrLink> rulesAttrList = param.getRulesAttrList();
|
|
|
List<PtlAgreementUndwrtRulesAttrLink> costsAttrLink = new ArrayList<>();
|
|
|
rulesAttrList.forEach(attr -> {
|
|
|
- attr.setRulesId(rules.getId());
|
|
|
- costsAttrLink.add(attr);
|
|
|
+ if (null != attr.getMin() || null != attr.getMax()) {
|
|
|
+ attr.setRulesId(rules.getId());
|
|
|
+ attr.setId(null);
|
|
|
+ costsAttrLink.add(attr);
|
|
|
+ }
|
|
|
});
|
|
|
agreementUndwrtRulesAttrLinkMapper.insert(costsAttrLink);
|
|
|
//获取费用属性
|
|
|
@@ -83,7 +108,7 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
|
|
|
// 删除费用因子
|
|
|
agreementUndwrtRulesAttrLinkService.remove(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>()
|
|
|
- .eq(PtlAgreementUndwrtRulesAttrLink::getRulesId, rules.getId()));
|
|
|
+ .eq(PtlAgreementUndwrtRulesAttrLink::getRulesId, param.getId()));
|
|
|
|
|
|
List<PtlAgreementUndwrtRulesAttr> attrList = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
|
|
|
//再添加属性值
|
|
|
@@ -99,13 +124,12 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
if (link.getMin() != null && link.getMin().contains(",")) {
|
|
|
link.setMin(link.getMin().replace(",", ","));
|
|
|
}
|
|
|
-
|
|
|
PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = attrList.stream()
|
|
|
.filter(attr -> attr.getAttrCode().equals(link.getAttrCode()))
|
|
|
.findFirst().orElse(null);
|
|
|
//单独判断radio radio中存在0的属性值
|
|
|
link.setRulesId(rules.getId());
|
|
|
- link.setId("0");
|
|
|
+ link.setId(null);
|
|
|
costsAttrLink.add(link);
|
|
|
});
|
|
|
agreementUndwrtRulesAttrLinkService.saveBatch(costsAttrLink);
|
|
|
@@ -120,36 +144,35 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
PtlAgreementUndwrtRules rules = baseMapper.selectById(ruleId);
|
|
|
AgreementRulesVo rulesVo = new AgreementRulesVo();
|
|
|
BeanUtils.copyProperties(rules, rulesVo);
|
|
|
- List<PtlAgreementUndwrtRulesAttrLink> linkList = agreementUndwrtRulesAttrLinkService.list(
|
|
|
- new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>()
|
|
|
- .eq(PtlAgreementUndwrtRulesAttrLink::getRulesId, ruleId));
|
|
|
+ List<PtlAgreementUndwrtRulesAttrLink> linkList = agreementUndwrtRulesAttrLinkService.queryLinkList(ruleId);
|
|
|
|
|
|
+ List<String> attrIdList = linkList.stream().map(PtlAgreementUndwrtRulesAttrLink::getAttrId).collect(Collectors.toList());
|
|
|
+ rulesVo.setAttrIdList(attrIdList);
|
|
|
// 获取费用因子属性
|
|
|
List<PtlAgreementUndwrtRulesAttr> attrList = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
|
|
|
-
|
|
|
+ Map<String, PtlAgreementUndwrtRulesAttr> attrMap = attrList.stream()
|
|
|
+ .collect(Collectors.toMap(PtlAgreementUndwrtRulesAttr::getAttrCode, attr -> attr));
|
|
|
List<PtlAgreementUndwrtRulesAttr> newAttrList = new ArrayList<>();
|
|
|
- attrList.forEach(attr -> {
|
|
|
- //处理多选和下拉
|
|
|
- if ("checkbox".equals(attr.getAttrType()) || "select".equals(attr.getAttrType())) {
|
|
|
- linkList.stream().filter(link -> link.getAttrCode().equals(attr.getAttrCode()))
|
|
|
- .findFirst().ifPresent(z -> {
|
|
|
- if (null != z.getMin()) {
|
|
|
- attr.setId(z.getId());
|
|
|
- attr.setMinArray(z.getMin().split(","));
|
|
|
- attr.setMax(z.getMax());
|
|
|
- attr.setOperator(z.getOperator());
|
|
|
+ linkList.forEach(link -> {
|
|
|
+ if(attrMap.containsKey(link.getAttrCode())) {
|
|
|
+ PtlAgreementUndwrtRulesAttr attr= attrMap.get(link.getAttrCode());
|
|
|
+ //处理多选和下拉
|
|
|
+ if ("checkbox".equals(attr.getAttrType()) || "select".equals(attr.getAttrType()) || "inputTag".equals(attr.getAttrType())) {
|
|
|
+ if (null != link.getMin()) {
|
|
|
+ attr.setId(link.getId());
|
|
|
+ attr.setMinArray(link.getMin().split(","));
|
|
|
+ attr.setMax(link.getMax());
|
|
|
+ attr.setOperator(link.getOperator());
|
|
|
}
|
|
|
- });
|
|
|
- }else{
|
|
|
- linkList.stream().filter(link -> link.getAttrCode().equals(attr.getAttrCode()))
|
|
|
- .findFirst().ifPresent(z -> {
|
|
|
- attr.setId(z.getId());
|
|
|
- attr.setMin(z.getMin());
|
|
|
- attr.setMax(z.getMax());
|
|
|
- attr.setOperator(z.getOperator());
|
|
|
- });
|
|
|
+ }else{
|
|
|
+ attr.setId(link.getId());
|
|
|
+ attr.setMin(link.getMin());
|
|
|
+ attr.setMax(link.getMax());
|
|
|
+ attr.setOperator(link.getOperator());
|
|
|
+ }
|
|
|
+ newAttrList.add(attr);
|
|
|
}
|
|
|
- newAttrList.add(attr);
|
|
|
+
|
|
|
});
|
|
|
rulesVo.setCostsAttrLinks(newAttrList);
|
|
|
return rulesVo;
|
|
|
@@ -189,7 +212,7 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
if ("checkbox".equals(ptlAgreementUndwrtRulesAttr.getAttrType()) || "select".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
|
|
|
desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(linkList.get(i).getMin()).append("\n");
|
|
|
}
|
|
|
- if ("input".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
|
|
|
+ if ("inputTag".equals(ptlAgreementUndwrtRulesAttr.getAttrType())) {
|
|
|
if (linkList.get(i).getOperator() != null && linkList.get(i).getOperator().equals("1")) {
|
|
|
desc.append(ptlAgreementUndwrtRulesAttr.getAttrName()).append("包含").append(linkList.get(i).getMin()).append("\n");
|
|
|
} else {
|