|
|
@@ -28,6 +28,7 @@ import com.jzg.organization.state.UserState;
|
|
|
import com.jzg.organization.state.listener.CostStateListener;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.statemachine.StateMachine;
|
|
|
@@ -73,11 +74,10 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
if (costAddList.isEmpty()) {
|
|
|
return HttpResult.error("保存数据不能为空");
|
|
|
}
|
|
|
- List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
|
|
|
for (CostAdd costAdd : costAddList) {
|
|
|
for (PtlAgreementCostAdd ptlAgreementCostAdd : costAdd.getPtlAgreementCostAddList()){
|
|
|
if (ListUtils.hasDuplicates(ptlAgreementCostAdd.getRuleConditions())){
|
|
|
- return HttpResult.error("存在相同费用规则,请检查");
|
|
|
+ throw new SystemException("添加数据存在相同费用规则,请检查");
|
|
|
}
|
|
|
ptlAgreementCostAdd.setPtlAgreementId(costAdd.getPtlAgreementId());
|
|
|
ptlAgreementCostAdd.setProductId(costAdd.getProductId());
|
|
|
@@ -85,10 +85,10 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
ptlAgreementCostAdd.setCoverRuleId(costAdd.getCoverRuleId());
|
|
|
boolean verify = verify(ptlAgreementCostAdd);
|
|
|
if (verify){
|
|
|
- return HttpResult.error("已存在相同且有效的费用规则,请检查");
|
|
|
+ throw new SystemException("已存在相同且有效的费用规则,请检查");
|
|
|
}
|
|
|
PtlAgreementCost ptlAgreementCost = BeanUtil.copyProperties(ptlAgreementCostAdd, PtlAgreementCost.class);
|
|
|
- ptlAgreementCost.setCostRules(BuildDescUtils.buildDesc(BeanUtil.copyToList(ptlAgreementCostAdd.getRuleConditions(), PtlAgreementUndwrtRulesAttr.class), undwrtRulesAttrList));
|
|
|
+ ptlAgreementCost.setCostRules(buildDescString(ptlAgreementCostAdd.getRuleConditions()));
|
|
|
if (baseMapper.insert(ptlAgreementCost) <= 0) {
|
|
|
log.error("插入操作失败");
|
|
|
throw new RuntimeException(ReturnInformation.FAILURE_MESSAGE);
|
|
|
@@ -108,11 +108,12 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public HttpResult update(PtlAgreementCostEnd ptlAgreementCostEnd) {
|
|
|
+ if (ListUtils.hasDuplicates(ptlAgreementCostEnd.getRuleConditions())){
|
|
|
+ return HttpResult.error("已存在相同且有效的费用规则,请检查");
|
|
|
+ }
|
|
|
|
|
|
-// if (ListUtils.hasDuplicates(ptlAgreementCostEnd.getRuleConditions())){
|
|
|
-// return HttpResult.error("已存在相同且有效的费用规则,请检查");
|
|
|
-// }
|
|
|
PtlAgreementCost ptlAgreementCost = BeanUtil.copyProperties(ptlAgreementCostEnd, PtlAgreementCost.class);
|
|
|
+ ptlAgreementCost.setCostRules(buildDescString(ptlAgreementCostEnd.getRuleConditions()));
|
|
|
if (baseMapper.updateById(ptlAgreementCost) <= 0) {
|
|
|
throw new RuntimeException(ReturnInformation.UPDATE_FAILED);
|
|
|
}
|
|
|
@@ -122,10 +123,17 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
if (!CollectionUtils.isEmpty(ptlAgreementCostEnd.getRuleConditions())) {
|
|
|
costRuleService.saveOrUpdateCostRule(BeanUtil.copyToList(ptlAgreementCostEnd.getRuleConditions(), PtlAgreementCostRule.class), ptlAgreementCost.getId());
|
|
|
}
|
|
|
-
|
|
|
return HttpResult.ok(ReturnInformation.UPDATE_SUCCESS);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public String buildDescString(List<?> list){
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return BuildDescUtils.buildDesc(BeanUtil.copyToList(list, PtlAgreementUndwrtRulesAttr.class), agreementUndwrtRulesAttrService.getUndwrtRulesAttrList());
|
|
|
+ }
|
|
|
+
|
|
|
public boolean verify(PtlAgreementCostAdd ptlAgreementCostAdd){
|
|
|
CostAgreementParam costAgreementParam = new CostAgreementParam();
|
|
|
costAgreementParam.setPtlAgreementId(ptlAgreementCostAdd.getPtlAgreementId());
|
|
|
@@ -134,8 +142,8 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
if (CollectionUtils.isEmpty(voList)){
|
|
|
return false;
|
|
|
}
|
|
|
- // 先比较规则是否相同
|
|
|
- Map<String, List<PtlAgreementCostVo>> listMap = voList.stream().filter(v -> Constants.ENABLE == v.getIsEnabled() && Constants.NOT_DELETED == v.getIsValid()).collect(Collectors.groupingBy(PtlAgreementCostVo::getProductId));
|
|
|
+ // 比较规则是否相同
|
|
|
+ Map<String, List<PtlAgreementCostVo>> listMap = voList.stream().filter(v -> Constants.ENABLE == v.getIsEnabled() && Constants.EFFECTIVE == v.getIsValid()).collect(Collectors.groupingBy(PtlAgreementCostVo::getProductId));
|
|
|
List<PtlAgreementCostVo> ptlAgreementCostVos = listMap.get(ptlAgreementCostAdd.getProductId());
|
|
|
if (CollectionUtils.isEmpty(ptlAgreementCostVos)){
|
|
|
return false;
|