From c2c26a11ab68ffda8587bebfb789bfc8fe6c034f Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期三, 05 六月 2024 15:24:50 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 11 ++++++-----
src/main/java/com/zy/asrs/utils/CodeDetectionUtil.java | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index 13036b1..8ead280 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -10,6 +10,7 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.mapper.*;
import com.zy.asrs.service.*;
+import com.zy.asrs.utils.CodeDetectionUtil;
import com.zy.asrs.utils.RouteUtils;
import com.zy.asrs.utils.Utils;
import com.zy.asrs.utils.VersionUtils;
@@ -125,7 +126,7 @@
if (!Cools.isEmpty(barcode)) {
// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
- if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+ if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
continue;
}
} else {
@@ -294,7 +295,7 @@
if (!Cools.isEmpty(barcode)) {
// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
- if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+ if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
continue;
}
} else {
@@ -366,7 +367,7 @@
&& staProtocol.getWorkNo() == 0
&& staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) {
- if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+ if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
// //鏉$爜涓虹┖鎴栬�呬笉绗﹀悎锛岄��搴撳埌172绔欑偣
// staProtocol.setWorkNo((short)32222);
@@ -463,7 +464,7 @@
if (!Cools.isEmpty(barcode)) {
// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
- if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+ if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
continue;
}
} else {
@@ -535,7 +536,7 @@
&& staProtocol.getWorkNo() == 0
&& staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) {
- if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+ if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
// //鏉$爜涓虹┖鎴栬�呬笉绗﹀悎锛岄��搴撳埌172绔欑偣
// staProtocol.setWorkNo((short)32222);
diff --git a/src/main/java/com/zy/asrs/utils/CodeDetectionUtil.java b/src/main/java/com/zy/asrs/utils/CodeDetectionUtil.java
new file mode 100644
index 0000000..261f5de
--- /dev/null
+++ b/src/main/java/com/zy/asrs/utils/CodeDetectionUtil.java
@@ -0,0 +1,38 @@
+package com.zy.asrs.utils;
+
+import java.util.regex.Pattern;
+
+public class CodeDetectionUtil {
+
+ /**
+ * 妫�娴嬭揣鏋剁爜
+ */
+ public static boolean barcodeDetection(String barcode){
+ Pattern pattern = Pattern.compile("\\d{8}");//8浣嶆暟瀛�
+ return pattern.matcher(barcode).matches();
+ }
+
+ /**
+ * 妫�娴嬪皬杞﹀湴鐮�
+ */
+ public static boolean carCodeDetection(String carCode){
+ return carCode.contains("_");
+ }
+
+ public static void main(String[] args) {
+ System.out.println("barcodeDetection:"+"22222222===>"+barcodeDetection("22222222"));
+ System.out.println("barcodeDetection:"+"222222===>"+barcodeDetection("222222"));
+ System.out.println("barcodeDetection:"+"111===>"+barcodeDetection("111"));
+ System.out.println("barcodeDetection:"+"DB_123ss===>"+barcodeDetection("DB_123ss"));
+ System.out.println("barcodeDetection:"+"12_1231===>"+barcodeDetection("12_1231"));
+ System.out.println("barcodeDetection:"+"DB_123456===>"+barcodeDetection("DB_123456"));
+
+ System.out.println("carCodeDetection:"+"22222222===>"+carCodeDetection("22222222"));
+ System.out.println("carCodeDetection:"+"222222===>"+carCodeDetection("222222"));
+ System.out.println("carCodeDetection:"+"111===>"+carCodeDetection("111"));
+ System.out.println("carCodeDetection:"+"DB_123ss===>"+carCodeDetection("DB_123ss"));
+ System.out.println("carCodeDetection:"+"12_1231===>"+carCodeDetection("12_1231"));
+ System.out.println("carCodeDetection:"+"DB_123456===>"+carCodeDetection("DB_123456"));
+ }
+
+}
--
Gitblit v1.9.1