From 8943a4e9f5ee1455c56ac4af60d941fa23731051 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期一, 13 四月 2026 13:20:38 +0800
Subject: [PATCH] 重量

---
 rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java |   75 ++++++++++++++++++++++++++++---------
 1 files changed, 57 insertions(+), 18 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
index ab2a30a..96611bd 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -51,6 +51,8 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -143,7 +145,7 @@
 
         // 绌烘澘鍏ュ簱锛氫笌闈炵┖鏉垮悓涓�鍏ュ彛锛屼粎涓嶆牎楠岀粍鎵橈紝鍙仛鍒嗛厤搴撲綅銆佸缓浠诲姟銆佹洿鏂板簱浣�
         if (param.getIoType() != null && param.getIoType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
-            return createInTaskForEmptyPallet(param.getBarcode(), param.getSourceStaNo(), param.getLocType1());
+            return createInTaskForEmptyPallet(param);
         }
 
         // 鎻愬墠瀹氫箟 waitPakin / waitPakinItems锛屼緵鍚庣画鍏朵粬鍏ュ簱閫昏緫浣跨敤
@@ -262,6 +264,12 @@
                     log.warn("鏇存柊鎷f枡鍏ュ簱浠诲姟鐨勫叆搴撶珯鐐瑰け璐� - 浠诲姟缂栫爜锛歿}", pickInTask.getTaskCode());
                 }
             }
+            if (param.getWeight() != null) {
+                pickInTask.setWeight(param.getWeight());
+                if (!taskService.updateById(pickInTask)) {
+                    log.warn("鏇存柊鎷f枡鍏ュ簱浠诲姟閲嶉噺澶辫触 - 浠诲姟缂栫爜锛歿}", pickInTask.getTaskCode());
+                }
+            }
 
             // 杩斿洖鎷f枡鍏ュ簱浠诲姟鐨勪俊鎭�
             InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -313,6 +321,12 @@
                 checkInTask.setOrgSite(param.getSourceStaNo());
                 if (!taskService.updateById(checkInTask)) {
                     log.warn("鏇存柊鐩樼偣鍏ュ簱浠诲姟鐨勫叆搴撶珯鐐瑰け璐� - 浠诲姟缂栫爜锛歿}", checkInTask.getTaskCode());
+                }
+            }
+            if (param.getWeight() != null) {
+                checkInTask.setWeight(param.getWeight());
+                if (!taskService.updateById(checkInTask)) {
+                    log.warn("鏇存柊鐩樼偣鍏ュ簱浠诲姟閲嶉噺澶辫触 - 浠诲姟缂栫爜锛歿}", checkInTask.getTaskCode());
                 }
             }
 
@@ -395,6 +409,12 @@
                     log.warn("鏇存柊鍏ュ簱浠诲姟鐨勫叆搴撶珯鐐瑰け璐� - 浠诲姟缂栫爜锛歿}", existingInTask.getTaskCode());
                 }
             }
+            if (param.getWeight() != null) {
+                existingInTask.setWeight(param.getWeight());
+                if (!taskService.updateById(existingInTask)) {
+                    log.warn("鏇存柊鍏ュ簱浠诲姟閲嶉噺澶辫触 - 浠诲姟缂栫爜锛歿}", existingInTask.getTaskCode());
+                }
+            }
 
             // 鐩存帴杩斿洖宸叉湁浠诲姟淇℃伅锛屼笉鍐嶆柊寤轰换鍔�
             InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -424,10 +444,11 @@
         }
         // 鍒涘缓骞朵繚瀛樹换鍔�
         Task task = createTask(ruleCode, locNo.getLocNo(), waitPakin.getBarcode(),
-                deviceSite.getDeviceSite(), param.getSourceStaNo().toString(), param.getUser());
+                deviceSite.getDeviceSite(), param.getSourceStaNo().toString(), param.getUser(),
+                TaskType.TASK_TYPE_IN.type, param.getWeight());
 
         // 鏇存柊搴撲綅鐘舵��
-        updateLocStatus(task.getTargLoc(), waitPakin.getBarcode());
+        updateLocStatus(task.getTargLoc(), waitPakin.getBarcode(), param.getWeight());
 
         // 鑾峰彇骞堕獙璇佺粍鎷栨槑缁�
         waitPakinItems = getWaitPakinItems(waitPakin.getId());
@@ -584,16 +605,16 @@
     /**
      * 鍒涘缓骞朵繚瀛樹换鍔�
      */
-    private Task createTask(String ruleCode, String targetLoc, String barcode,
-                            String targetSite, String sourceSiteNo, Long loginUserId) {
-        return createTask(ruleCode, targetLoc, barcode, targetSite, sourceSiteNo, loginUserId, TaskType.TASK_TYPE_IN.type);
-    }
+//    private Task createTask(String ruleCode, String targetLoc, String barcode,
+//                            String targetSite, String sourceSiteNo, Long loginUserId) {
+//        return createTask(ruleCode, targetLoc, barcode, targetSite, sourceSiteNo, loginUserId, TaskType.TASK_TYPE_IN.type, null);
+//    }
 
     /**
      * 鍒涘缓骞朵繚瀛樹换鍔★紙鏀寔鎸囧畾浠诲姟绫诲瀷锛屽绌烘澘鍏ュ簱锛�
      */
     private Task createTask(String ruleCode, String targetLoc, String barcode,
-                            String targetSite, String sourceSiteNo, Long loginUserId, Integer taskType) {
+                            String targetSite, String sourceSiteNo, Long loginUserId, Integer taskType, BigDecimal weight) {
         Task task = new Task();
         task.setTaskCode(ruleCode)
                 .setTaskStatus(TaskStsType.GENERATE_IN.id)
@@ -605,6 +626,9 @@
                 .setCreateBy(loginUserId)
                 .setUpdateBy(loginUserId)
                 .setOrgSite(sourceSiteNo);
+        if (weight != null) {
+            task.setWeight(weight);
+        }
 
         if (!taskService.save(task)) {
             throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
@@ -615,11 +639,13 @@
     /**
      * 鏇存柊搴撲綅鐘舵��
      */
-    private void updateLocStatus(String locCode, String barcode) {
-        boolean updated = locService.update(new LambdaUpdateWrapper<Loc>()
+    private void updateLocStatus(String locCode, String barcode, BigDecimal weight) {
+        LambdaUpdateWrapper<Loc> uw = new LambdaUpdateWrapper<Loc>()
                 .eq(Loc::getCode, locCode)
                 .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
-                .set(Loc::getBarcode, barcode));
+                .set(Loc::getBarcode, barcode)
+                .set(Loc::getWeight, weight);
+        boolean updated = locService.update(uw);
         if (!updated) {
             throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
         }
@@ -629,13 +655,16 @@
      * 绌烘澘鍏ュ簱锛氫笌闈炵┖鏉垮悓涓�娴佺▼锛堟牎楠岀珯鐐广�佸垎閰嶅簱浣嶃�佸缓浠诲姟銆佹洿鏂板簱浣嶏級锛屼粎涓嶆牎楠岀粍鎵樸�佷笉鍐欎换鍔℃槑缁嗐�佷笉鏇存柊缁勬墭鐘舵�併��
      * 鐢� createInTask 鍦� ioType=绌烘澘鏃惰皟鐢紱闇�鍦ㄨ澶囩珯鐐逛腑閰嶇疆 type=10锛堢┖鏉垮叆搴擄級鐨勭珯鐐硅矾寰勩��
      */
-    private InTaskMsgDto createInTaskForEmptyPallet(String barcode, String staNo, Integer type) {
+    private InTaskMsgDto createInTaskForEmptyPallet(TaskInParam sourceParam) {
         TaskInParam param = new TaskInParam();
+        String barcode = sourceParam.getBarcode();
+        String staNo = sourceParam.getSourceStaNo();
         param.setBarcode(barcode);
         param.setSourceStaNo(staNo);
-        param.setLocType1(type != null ? type : 1);
+        param.setLocType1(sourceParam.getLocType1() != null ? sourceParam.getLocType1() : 1);
         param.setIoType(TaskType.TASK_TYPE_EMPITY_IN.type);
-        param.setUser(1L);
+        param.setUser(sourceParam.getUser() != null ? sourceParam.getUser() : 1L);
+        param.setWeight(sourceParam.getWeight());
 
         // 鏍¢獙璁惧绔欑偣锛堥渶閰嶇疆 type=10 绌烘澘鍏ュ簱鐨勭珯鐐癸級
         DeviceSite deviceSite = validateDeviceSite(param);
@@ -650,6 +679,10 @@
             log.info("鎵惧埌璇ユ墭鐩樺彿宸叉湁绌烘澘鍏ュ簱浠诲姟锛屽鐢� - 浠诲姟缂栫爜锛歿}锛岀鍙凤細{}", existingInTask.getTaskCode(), barcode);
             if (StringUtils.isNotBlank(staNo) && !staNo.equals(existingInTask.getOrgSite())) {
                 existingInTask.setOrgSite(staNo);
+                taskService.updateById(existingInTask);
+            }
+            if (param.getWeight() != null) {
+                existingInTask.setWeight(param.getWeight());
                 taskService.updateById(existingInTask);
             }
             InTaskMsgDto msgDto = new InTaskMsgDto();
@@ -686,8 +719,8 @@
         }
         String ruleCode = generateTaskCode();
         String targetSite = StringUtils.isNotBlank(deviceSite.getDeviceSite()) ? deviceSite.getDeviceSite() : staNo;
-        Task task = createTask(ruleCode, locNo.getLocNo(), barcode, targetSite, staNo, param.getUser(), TaskType.TASK_TYPE_EMPITY_IN.type);
-        updateLocStatus(task.getTargLoc(), barcode);
+        Task task = createTask(ruleCode, locNo.getLocNo(), barcode, targetSite, staNo, param.getUser(), TaskType.TASK_TYPE_EMPITY_IN.type, param.getWeight());
+        updateLocStatus(task.getTargLoc(), barcode, param.getWeight());
         locNo.setWorkNo(ruleCode);
         locNo.setTaskId(task.getId());
         log.info("[绌烘澘鍏ュ簱] 宸插垱寤轰换鍔�: {}, 搴撲綅: {}, 鏂欑: {}", ruleCode, locNo.getLocNo(), barcode);
@@ -1561,9 +1594,14 @@
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public R allocateLocation(String barcode, String staNo, Integer type, Boolean full) {
+    public R allocateLocation(String barcode, String staNo, Integer type, Boolean full, BigDecimal weight) {
         log.info("========== 寮�濮嬬敵璇峰叆搴撲换鍔★紝鍒嗛厤搴撲綅 ==========");
-        log.info("鏂欑鐮侊細{}锛屽叆搴撶珯鐐癸細{}锛屽叆搴撶被鍨嬶細{}锛岀┖鏉匡細{}", barcode, staNo, type, full);
+        log.info("鏂欑鐮侊細{}锛屽叆搴撶珯鐐癸細{}锛屽叆搴撶被鍨嬶細{}锛岀┖鏉匡細{}锛岄噸閲忥細{}", barcode, staNo, type, full, weight);
+
+        BigDecimal weightScaled = null;
+        if (weight != null) {
+            weightScaled = weight.setScale(4, RoundingMode.HALF_UP);
+        }
 
         // 缁熶竴璧� createInTask锛氱┖鏉�(full=true)浠呬笉鏍¢獙缁勬墭锛屼粛鏍¢獙绔欑偣銆佸垎閰嶅簱浣嶃�佸缓浠诲姟锛涢潪绌烘澘闇�缁勬墭
         TaskInParam param = new TaskInParam();
@@ -1572,6 +1610,7 @@
         param.setLocType1(type != null ? type : 1);
         param.setUser(1L);
         param.setIoType(Boolean.TRUE.equals(full) ? TaskType.TASK_TYPE_EMPITY_IN.type : TaskType.TASK_TYPE_IN.type);
+        param.setWeight(weightScaled);
 
         InTaskMsgDto msgDto = createInTask(param);
 

--
Gitblit v1.9.1