Bläddra i källkod

aps-小卷报工后批次号重新排序bug修复

zhoudazhuang 8 månader sedan
förälder
incheckning
6b8df71a81

+ 16 - 7
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsReportRecordsServiceImpl.java

@@ -30,6 +30,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
@@ -1366,6 +1367,7 @@ public class ApsReportRecordsServiceImpl extends ServiceImpl<ApsReportRecordsDao
             apsReportRecordsDo.setProcessoperationid(apsProcessOperationDo.getId());
             //作业明细ID
             apsReportRecordsDo.setProcessequid(apsProcessOperationProcessEquDo.getId());
+            inputBatchNumberList.sort(Comparator.comparing(this::toSortBatchNumber));
             //输入物料的批次号
             apsReportRecordsDo.setBatchnumber(String.join(",", inputBatchNumberList));
             //实际输入物料
@@ -1661,11 +1663,7 @@ public class ApsReportRecordsServiceImpl extends ServiceImpl<ApsReportRecordsDao
             ApsProcessOperationProcessEquDo needUpdateProcessEqu = new ApsProcessOperationProcessEquDo();
             needUpdateProcessEqu.setId(apsProcessOperationProcessEquDo.getId());
             // 根据批次号列表进行升序排序
-            inputBatchNumberList.sort((e, b)->{
-                LinkedList<String> a1 = new LinkedList<>(Arrays.asList(e.split("-")));
-                LinkedList<String> b1 = new LinkedList<>(Arrays.asList(b.split("-")));
-                return sortAsc(a1,b1);
-            });
+            inputBatchNumberList.sort(Comparator.comparing(this::toSortBatchNumber));
             //该工序作业明细的加工中批次号=“{批次号}-{单个分卷序列号}”逗号拼接
             needUpdateProcessEqu.setDoingbatchnumber(String.join(",", inputBatchNumberList));
 
@@ -1712,6 +1710,17 @@ public class ApsReportRecordsServiceImpl extends ServiceImpl<ApsReportRecordsDao
             startWorkLock.remove(req.getUseDeviceId());
         }
     }
+    @NotNull
+    private String toSortBatchNumber(@NotNull String batchNumber) {
+        String[] parts = batchNumber.split("-");
+        // 去掉第一个字符串
+        String[] remainingParts = Arrays.copyOfRange(parts, 1, parts.length);
+        // 将剩余字符串不足3位的补0后拼起来
+        String joinedString = Arrays.stream(remainingParts)
+                .map(part -> String.format("%03d", Integer.parseInt(part)))
+                .collect(Collectors.joining("-"));
+        return parts[0] + '-' + joinedString;
+    }
 
     @Override
     public R generalMsUpdate(MasterSlaveUpdateVo masterSlaveUpdate) {
@@ -1733,8 +1742,8 @@ public class ApsReportRecordsServiceImpl extends ServiceImpl<ApsReportRecordsDao
         if(length2 == 0){
             return 1;
         }
-        if (Integer.parseInt(parts1.get(0)) != Integer.parseInt(parts2.get(0))) {
-            return Integer.parseInt(parts1.get(0)) - Integer.parseInt(parts2.get(0));
+        if (Integer.parseInt(parts1.get(0).replace("*", "")) != Integer.parseInt(parts2.get(0).replace("*", ""))) {
+            return Integer.parseInt(parts1.get(0).replace("*", "")) - Integer.parseInt(parts2.get(0).replace("*", ""));
         }else {
             parts1.remove(0);
             parts2.remove(0);