wangxichen 2 недель назад
Родитель
Сommit
9f9691941a

+ 7 - 7
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -678,7 +678,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 					if(paramsResp.getCraft().equals(mesProductRecord.getCraft())){
 						mesProductRecord.setContent(paramsResp.getResult());
 						mesProductRecord.setMaterielSn(paramsResp.getVal());
-						if(oldOprno.length() == 6){
+						if(!oldOprno.equals(oprno)){
 							mesProductRecord.setOprno(oldOprno);
 						}
 						mesProductRecord.setSource("0");
@@ -690,14 +690,14 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 
 			// 更新设备及工装
 			if(mesProductRecord.getCraft().equals("400002")){
-				if(oldOprno.length() == 6){
+				if(!oldOprno.equals(oprno)){
 					mesProductRecord.setOprno(oldOprno);
 				}
 				mesProductRecord.setMaterielSn(mesLineProcess1.getDevices());
 				mesProductRecord.setContent("OK");
 				super.update(mesProductRecord);
 			}else if(mesProductRecord.getCraft().equals("400003")){
-				if(oldOprno.length() == 6){
+				if(!oldOprno.equals(oprno)){
 					mesProductRecord.setOprno(oldOprno);
 				}
 				mesProductRecord.setMaterielSn(mesLineProcess1.getGzs());
@@ -707,7 +707,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 
 			// 更新主结果
 			if(mesProductRecord.getCraft().equals(craft)){
-				if(oldOprno.length() == 6){
+				if(!oldOprno.equals(oprno)){
 					mesProductRecord.setOprno(oldOprno);
 				}
 
@@ -1041,7 +1041,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 		}
 	}
 
-		if(oldOprno.length() == 6){
+		if(!oldOprno.equals(oprno)){
 			mesProductRecord.setOprno(oldOprno);
 		}
 
@@ -1131,7 +1131,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 			throw new ServiceException(text("记录不存在!"));
 		}
 
-		if(oldOprno.length() == 6){
+		if(!oldOprno.equals(oprno)){
 			mesProductRecord.setOprno(oldOprno);
 		}
 
@@ -1162,7 +1162,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 			throw new ServiceException(text("记录不存在!"));
 		}
 
-		if(oldOprno.length() == 6){
+		if(!oldOprno.equals(oprno)){
 			mesProductRecord.setOprno(oldOprno);
 		}
 

+ 10 - 14
src/main/java/com/jeesite/modules/mes/util/CommonUitl.java

@@ -53,23 +53,19 @@ public class CommonUitl {
     }
 
     /**
-     * 格式化工位号
-     * @param oprno
-     * @return
+     * 格式化工位号:去掉末尾的子工位字母后缀(前一位必须是数字)
+     * 例:OP070A → OP070、INSP110A → INSP110、INSP030 → INSP030(不动)
+     * 长度无关,兼容 5/6/7/8 字符工位号
      */
     public static String formatOprno(String oprno){
-        List<String> lists = new ArrayList<>();
-//        lists.add("OP180"); // 只有OP180和OP240带ABC
-//        lists.add("OP240");
-
-        if(oprno.length() == 6){
-            String ysoprno = oprno.substring(0,5).trim();
-            if(!lists.contains(ysoprno)){
-                oprno = ysoprno;
-            }
+        if(oprno == null) return "";
+        int len = oprno.length();
+        while(len > 1
+                && Character.isLetter(oprno.charAt(len - 1))
+                && Character.isDigit(oprno.charAt(len - 2))){
+            len--;
         }
-
-        return  oprno;
+        return oprno.substring(0, len);
     }
 
     /**