|
@@ -521,37 +521,59 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
|
|
|
|
|
boolean isAdd = "ADD".equalsIgnoreCase(param.getOperationType());
|
|
boolean isAdd = "ADD".equalsIgnoreCase(param.getOperationType());
|
|
|
|
|
|
|
|
|
|
+ // 校验:至少传递一种险种的比例
|
|
|
|
|
+ boolean hasJqRatio = param.getJqInletRatio() != null || param.getJqExportRatio() != null;
|
|
|
|
|
+ boolean hasSyRatio = param.getSyInletRatio() != null || param.getSyExportRatio() != null;
|
|
|
|
|
+ boolean hasJyRatio = param.getJyInletRatio() != null || param.getJyExportRatio() != null;
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasJqRatio && !hasSyRatio && !hasJyRatio) {
|
|
|
|
|
+ return HttpResult.error("至少需要传递一种险种的比例(交强险/商业险/驾意险)");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int adjustedCount = 0;
|
|
|
for (PtlAgreementCostType costType : costTypeList) {
|
|
for (PtlAgreementCostType costType : costTypeList) {
|
|
|
String costTypeStr = costType.getCostType();
|
|
String costTypeStr = costType.getCostType();
|
|
|
|
|
+ boolean wasAdjusted = false;
|
|
|
|
|
|
|
|
// 根据费用类型进行调整
|
|
// 根据费用类型进行调整
|
|
|
- if ("交强险".equals(costTypeStr)) {
|
|
|
|
|
- adjustCostType(costType, param.getInletRatio(), param.getInletKeepPointRatio(), isAdd);
|
|
|
|
|
- } else if ("商业险".equals(costTypeStr)) {
|
|
|
|
|
- adjustCostType(costType, param.getInletRatio(), param.getInletKeepPointRatio(), isAdd);
|
|
|
|
|
- } else if ("驾意险".equals(costTypeStr)) {
|
|
|
|
|
- adjustCostType(costType, param.getInletRatio(), param.getInletKeepPointRatio(), isAdd);
|
|
|
|
|
|
|
+ if ("交强险".equals(costTypeStr) && hasJqRatio) {
|
|
|
|
|
+ adjustCostType(costType, param.getJqInletRatio(), param.getJqExportRatio(), isAdd);
|
|
|
|
|
+ wasAdjusted = true;
|
|
|
|
|
+ } else if ("商业险".equals(costTypeStr) && hasSyRatio) {
|
|
|
|
|
+ adjustCostType(costType, param.getSyInletRatio(), param.getSyExportRatio(), isAdd);
|
|
|
|
|
+ wasAdjusted = true;
|
|
|
|
|
+ } else if ("驾意险".equals(costTypeStr) && hasJyRatio) {
|
|
|
|
|
+ adjustCostType(costType, param.getJyInletRatio(), param.getJyExportRatio(), isAdd);
|
|
|
|
|
+ wasAdjusted = true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (wasAdjusted) {
|
|
|
|
|
+ adjustedCount++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (adjustedCount == 0) {
|
|
|
|
|
+ return HttpResult.error("未找到匹配的费用类型记录进行调整");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 批量更新
|
|
// 批量更新
|
|
|
ptlAgreementCostTypeService.updateBatchById(costTypeList);
|
|
ptlAgreementCostTypeService.updateBatchById(costTypeList);
|
|
|
|
|
|
|
|
- return HttpResult.ok("批量调整成功");
|
|
|
|
|
|
|
+ return HttpResult.ok("批量调整成功,共调整 " + adjustedCount + " 条记录");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 调整费用类型的各项比例
|
|
* 调整费用类型的各项比例
|
|
|
*/
|
|
*/
|
|
|
private void adjustCostType(PtlAgreementCostType costType, BigDecimal inlet,
|
|
private void adjustCostType(PtlAgreementCostType costType, BigDecimal inlet,
|
|
|
- BigDecimal keepPointRatio, boolean isAdd) {
|
|
|
|
|
|
|
+ BigDecimal export, boolean isAdd) {
|
|
|
// 入口比例
|
|
// 入口比例
|
|
|
if (inlet != null) {
|
|
if (inlet != null) {
|
|
|
costType.setInlet(calculateNewValue(costType.getInlet(), inlet, isAdd));
|
|
costType.setInlet(calculateNewValue(costType.getInlet(), inlet, isAdd));
|
|
|
}
|
|
}
|
|
|
- // 入口留点比例
|
|
|
|
|
- if (keepPointRatio != null) {
|
|
|
|
|
- costType.setKeepPointRatio(calculateNewValue(costType.getKeepPointRatio(), keepPointRatio, isAdd));
|
|
|
|
|
|
|
+ // 出口比例
|
|
|
|
|
+ if (export != null) {
|
|
|
|
|
+ costType.setExport(calculateNewValue(costType.getExport(), export, isAdd));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|