czh 2 лет назад
Родитель
Сommit
5ef3acaa66

+ 52 - 5
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/RegularUtils.java

@@ -24,10 +24,15 @@ public class RegularUtils {
      */
     public static final String DECIMAL_REG1 = "^\\d+(\\.\\d+)?$";
     /**
-     *  数字和字母
+     * 数字和字母
      */
     public static final String NUMBER_AND_LATTER = "[0-9A-Za-z]{18}";
 
+    /**
+     * 数字和大写字母
+     */
+    public static final String NUMBER_AND_UPPERCASE_LATTER = "[0-9A-Z]";
+
     /**
      * 正整数和0
      */
@@ -61,26 +66,68 @@ public class RegularUtils {
      * 车牌校验  六位数车牌
      */
     public static final String TRUCK_NUMBER_SIX = "^[京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云渝藏陕甘青宁新使]{1}[a-zA-Z]{1}[0-9a-zA-Z]{6}$";
+
     /**
      * 中文汉字
      */
     public static final String CHINESE = "^[\\u4e00-\\u9fa5]{2,4}$";
 
     /**
+     * 姓名相关
+     * (企业法人、企业代表、员工姓名、司机姓名)
+     */
+    public static final String NAME = "^[\\u4e00-\\u9fa5]{1,25}$";
+
+
+    /**
+     * 道路运输许可证号
+     */
+    public static final String ROAD_LICENCE = "(^\\d{12})";
+
+    /**
+     * @param
+     * @return
      * @description 校验
      * @author zk
      * @date 2020/5/9 14:38
-     * @param
-     * @return
      **/
-    public static boolean matchs(String regular, String str){
+    public static boolean matchs(String regular, String str) {
         Pattern p = Pattern.compile(regular);
         Matcher m = p.matcher(str);
         boolean isMatch = m.matches();
         return isMatch;
     }
 
+    /**
+     * @param regular 正则 str匹配字符串 min 最小长度 max最大长度
+     * @desc: 校验(限制长度范围)
+     * @author: czh
+     * @date: 2023/7/25
+     */
+    public static boolean matchWithRange(String regular, String str, Integer min, Integer max) {
+        StringBuilder stringBuilder = new StringBuilder();
+        stringBuilder.append(regular).append("{").append(min).append(",").append(max).append("}$");
+        Pattern p = Pattern.compile(stringBuilder.toString());
+        Matcher m = p.matcher(str);
+        return m.matches();
+    }
+
+    /**
+     * @param regular 正则 str匹配字符串 fixLength 固定长度
+     * @desc: 校验(限制固定长度)
+     * @author: czh
+     * @date: 2023/7/25
+     */
+    public static boolean matchWithFix(String regular, String str, Integer fixLength) {
+        StringBuilder stringBuilder = new StringBuilder();
+        stringBuilder.append(regular).append("{").append(fixLength).append("}$");
+        Pattern p = Pattern.compile(stringBuilder.toString());
+        Matcher m = p.matcher(str);
+        return m.matches();
+    }
+
+
     public static void main(String[] args) {
-        System.out.println(matchs(DECIMAL_REG, "111.00"));
+        System.out.println(matchs("(^\\d{12})", "123456789112"));
     }
 }

+ 1 - 1
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/controller/KwcCheckedController.java

@@ -49,7 +49,7 @@ public class KwcCheckedController {
      * @date 2023/7/13
      */
     @RequestMapping("add")
-    public HttpResult addCheckedContract(@Valid @RequestBody ContractLogisticsReqVo reqVo) throws SystemException {
+    public HttpResult addCheckedContract(@RequestBody ContractLogisticsReqVo reqVo) throws SystemException {
         kwcContractLogisticsService.addCheckedContract(reqVo);
         return HttpResult.ok(HttpStatus.MSG_003);
     }

+ 1 - 1
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/controller/KwcContractSaleController.java

@@ -47,7 +47,7 @@ public class KwcContractSaleController {
      * @date: 2023/7/18
      */
     @RequestMapping("add")
-    public HttpResult addTradeContract(@Valid @RequestBody ContractTradeReqVo reqVo) throws SystemException {
+    public HttpResult addTradeContract(@RequestBody ContractTradeReqVo reqVo) throws SystemException {
         kwcContractTradeService.addTradeContract(reqVo);
         return HttpResult.ok(HttpStatus.MSG_003);
     }