liuyc před 2 roky
rodič
revize
a998ce5b63

+ 133 - 105
blade-service/blade-manager/src/main/java/org/springblade/manager/unit/WbsElementUtil.java

@@ -52,135 +52,163 @@ public class WbsElementUtil {
     }
 
     public static String setDefaultElementLength(Integer type) {
-        switch (type) {
-            case 1:  //字符串
-            case 7:  //文件
-            case 6:  //签名
-                return "250";
-            case 2:  //整数
-            case 5:  //数值
-            case 3:  //小数
-            case 4:  //日期
-                return "50";
-            default:
-                return "0";
+        if (type != null) {
+            switch (type) {
+                case 1:  //字符串
+                case 7:  //文件
+                case 6:  //签名
+                    return "250";
+                case 2:  //整数
+                case 5:  //数值
+                case 3:  //小数
+                case 4:  //日期
+                    return "50";
+                default:
+                    return "0";
+            }
+        } else {
+            return "0";
         }
     }
 
     public static Integer getElementLength2(String type) {
-        switch (type) {
-            case "varchar":
-                return 250;
-            case "bigint":
-            case "decimal":
-            case "datetime":
-                return 50;
-            default:
-                return 0;
+        if (type != null) {
+            switch (type) {
+                case "varchar":
+                    return 250;
+                case "bigint":
+                case "decimal":
+                case "datetime":
+                    return 50;
+                default:
+                    return 0;
+            }
+        } else {
+            return 0;
         }
     }
 
     public static Integer getElementLength(String type) {
-        switch (type) {
-            case "字符串":
-            case "签名":
-            case "文件":
-                return 250;
-            case "整数":
-            case "数值":
-            case "小数":
-            case "日期":
-                return 50;
-            default:
-                return 0;
+        if (type != null) {
+            switch (type) {
+                case "字符串":
+                case "签名":
+                case "文件":
+                    return 250;
+                case "整数":
+                case "数值":
+                case "小数":
+                case "日期":
+                    return 50;
+                default:
+                    return 0;
+            }
+        } else {
+            return 0;
         }
     }
 
     public static String getInitTableFiledType(Integer type) {
-        switch (type) {
-            case 2:
-                //整数
-                return "bigint";
-            case 3:
-                //小数
-                return "decimal";
-            case 4:
-                //日期
-                return "datetime";
-            case 5:
-                //数值
-                return "decimal";
-            case 6:
-                //签名
-                return "varchar";
-            case 7:
-                //文件
-                return "varchar";
-            case 1:
-            default:
-                //字符串
-                return "varchar";
+        if (type != null) {
+            switch (type) {
+                case 2:
+                    //整数
+                    return "bigint";
+                case 3:
+                    //小数
+                    return "decimal";
+                case 4:
+                    //日期
+                    return "datetime";
+                case 5:
+                    //数值
+                    return "decimal";
+                case 6:
+                    //签名
+                    return "varchar";
+                case 7:
+                    //文件
+                    return "varchar";
+                case 1:
+                default:
+                    //字符串
+                    return "varchar";
+            }
+        } else {
+            return "varchar";
         }
     }
 
     public static Integer getElementType(String type) {
-        switch (type) {
-            case "字符串":
-                return 1;
-            case "整数":
-                return 2;
-            case "小数":
-                return 3;
-            case "日期":
-                return 4;
-            case "数值":
-                return 5;
-            case "签名":
-                return 6;
-            case "文件":
-                return 7;
-            default:
-                return 0;
+        if (type != null) {
+            switch (type) {
+                case "字符串":
+                    return 1;
+                case "整数":
+                    return 2;
+                case "小数":
+                    return 3;
+                case "日期":
+                    return 4;
+                case "数值":
+                    return 5;
+                case "签名":
+                    return 6;
+                case "文件":
+                    return 7;
+                default:
+                    return 0;
+            }
+        } else {
+            return 0;
         }
     }
 
     public static Integer getTableType(String tableType) {
-        switch (tableType) {
-            case "检验表":
-                return 1;
-            case "记录表":
-                return 2;
-            case "通用表":
-                return 3;
-            case "监表":
-                return 4;
-            case "评定表":
-                return 5;
-            case "测量表":
-                return 6;
-            case "竣工表":
-                return 7;
-            case "汇总表":
-                return 8;
-            case "试验记录表":
-                return 9;
-            case "试验报告表":
-                return 10;
-            default:
-                return 0;
+        if (tableType != null) {
+            switch (tableType) {
+                case "检验表":
+                    return 1;
+                case "记录表":
+                    return 2;
+                case "通用表":
+                    return 3;
+                case "监表":
+                    return 4;
+                case "评定表":
+                    return 5;
+                case "测量表":
+                    return 6;
+                case "竣工表":
+                    return 7;
+                case "汇总表":
+                    return 8;
+                case "试验记录表":
+                    return 9;
+                case "试验报告表":
+                    return 10;
+                default:
+                    return 0;
+            }
+        } else {
+            return 0;
         }
     }
 
     public static String getTypeName(String type) {
-        switch (type) {
-            case "bigint":
-                return "整数或数值";
-            case "decimal":
-                return "小数";
-            case "datetime":
-                return "日期";
-            default:
-                return "字符串";
+        if (type != null) {
+            switch (type) {
+                case "bigint":
+                    return "整数或数值";
+                case "decimal":
+                    return "小数";
+                case "datetime":
+                    return "日期";
+                default:
+                    return "字符串";
+            }
+        } else {
+            return "字符串";
         }
     }