ソースを参照

fix 方案管理基础方案驾意险不做默认 强制限制

Liub 6 日 前
コミット
1fb82f9da8

+ 17 - 13
commons/src/main/java/com/jzg/commons/entity/scheme/vo/PtlSchemeSaveVo.java

@@ -286,20 +286,24 @@ public class PtlSchemeSaveVo {
     public List<PtlSchemeInsuranceDrivingIntention> getPtlSchemeInsuranceDrivingIntentionList(){
         List<PtlSchemeInsuranceDrivingIntention> ptlSchemeInsuranceDrivingIntentionList = new ArrayList<>();
         for (Scheme scheme : schemeList) {
-            // 校验同一方案内驾意险的选中类型:默认选中(1)/强制选中(2)只能出现一种且各最多一条(可选=3)
-            long defaultSelectedCount = scheme.getDrivingList().stream()
-                    .filter(drivingIntention -> "1".equals(drivingIntention.getSelectedStatus())).count();
-            long forceSelectedCount = scheme.getDrivingList().stream()
-                    .filter(drivingIntention -> "2".equals(drivingIntention.getSelectedStatus())).count();
-            if (defaultSelectedCount > 1) {
-                throw new ValidateException("方案[" + scheme.getSchemeName() + "]中默认选中的驾意险只能有一条");
-            }
-            if (forceSelectedCount > 1) {
-                throw new ValidateException("方案[" + scheme.getSchemeName() + "]中强制选中的驾意险只能有一条");
-            }
-            if (defaultSelectedCount > 0 && forceSelectedCount > 0) {
-                throw new ValidateException("方案[" + scheme.getSchemeName() + "]中默认选中与强制选中的驾意险不能同时存在");
+            // 仅自选方案(schemeType 1基础 2自选)才校验驾意险默认/强制选中,基础方案不校验
+            if ("2".equals(this.schemeType)) {
+                // 校验同一方案内驾意险的选中类型:默认选中(1)/强制选中(2)只能出现一种且各最多一条(可选=3)
+                long defaultSelectedCount = scheme.getDrivingList().stream()
+                        .filter(drivingIntention -> "1".equals(drivingIntention.getSelectedStatus())).count();
+                long forceSelectedCount = scheme.getDrivingList().stream()
+                        .filter(drivingIntention -> "2".equals(drivingIntention.getSelectedStatus())).count();
+                if (defaultSelectedCount > 1) {
+                    throw new ValidateException("方案[" + scheme.getSchemeName() + "]中默认选中的驾意险只能有一条");
+                }
+                if (forceSelectedCount > 1) {
+                    throw new ValidateException("方案[" + scheme.getSchemeName() + "]中强制选中的驾意险只能有一条");
+                }
+                if (defaultSelectedCount > 0 && forceSelectedCount > 0) {
+                    throw new ValidateException("方案[" + scheme.getSchemeName() + "]中默认选中与强制选中的驾意险不能同时存在");
+                }
             }
+
             scheme.getDrivingList().forEach(drivingIntention -> {
                 PtlSchemeInsuranceDrivingIntention ptlSchemeInsuranceDrivingIntention = new PtlSchemeInsuranceDrivingIntention();
                 ptlSchemeInsuranceDrivingIntention.setId(IdGenerate.nextId());