Bladeren bron

修改校验非车信息bug

785834757 2 jaren geleden
bovenliggende
commit
76878b0e9f

+ 13 - 3
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java

@@ -280,9 +280,9 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
     @Override
     public boolean costsAdd(AgreementProductCosts agreementProductCosts) {
         //校验非车信息是否存在
-        PtlAgreementProductCostsAttrLink nonMotorInsurance = agreementProductCosts.getCostsAttrLinks().stream().filter(x -> x.getAttrCode().equals("NonMotorInsurance")).findFirst().get();
-        if (nonMotorInsurance != null) {
-            if((!nonMotorInsurance.getMin().equals("0") || !nonMotorInsurance.getMax().equals("0"))) {
+        List<PtlAgreementProductCostsAttrLink> nonMotorInsurance = agreementProductCosts.getCostsAttrLinks().stream().filter(x -> x.getAttrCode().equals("NonMotorInsurance")).collect(Collectors.toList());
+        if (nonMotorInsurance.size() > 0) {
+            if((!nonMotorInsurance.get(0).getMin().equals("0") || !nonMotorInsurance.get(0).getMax().equals("0"))) {
                 if((agreementProductCosts.getNoCostsProportion() == null || agreementProductCosts.getNoCostsProportion().equals("0"))){
                     throw new SystemException("检测到存在非车费用因子,请填写非车费用!");
                 }
@@ -373,6 +373,16 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
     @Transactional
     @Override
     public boolean costsUpdate(AgreementProductCosts agreementProductCosts) {
+        //校验非车信息是否存在
+        List<PtlAgreementProductCostsAttrLink> nonMotorInsurance = agreementProductCosts.getCostsAttrLinks().stream().filter(x -> x.getAttrCode().equals("NonMotorInsurance")).collect(Collectors.toList());
+        if (nonMotorInsurance.size() > 0) {
+            if((!nonMotorInsurance.get(0).getMin().equals("0") || !nonMotorInsurance.get(0).getMax().equals("0"))) {
+                if((agreementProductCosts.getNoCostsProportion() == null || agreementProductCosts.getNoCostsProportion().equals("0"))){
+                    throw new SystemException("检测到存在非车费用因子,请填写非车费用!");
+                }
+            }
+        }
+
         //更新费用主表信息
         PtlAgreementProductCostsNew ptlAgreementProductCostsNew = new PtlAgreementProductCostsNew();
         BeanUtils.copyProperties(agreementProductCosts, ptlAgreementProductCostsNew);