From fc80e4040d6bf39b8657f94df1f957732bae26fe Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期三, 22 四月 2026 22:02:31 +0800
Subject: [PATCH] 电视机入库出库显示耗时、托数功能修改: 1.入库耗时改成当前订单第一托入库任务创建时间到后续入库的创建时间相减转换成分钟 2.出库耗时改成当前订订单任务创建时间减去到达出库口的耗时时间 3.入库托数改成当前入库订单号累计入库数量

---
 src/main/java/com/zy/asrs/controller/BasDevpController.java |  166 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 160 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/BasDevpController.java b/src/main/java/com/zy/asrs/controller/BasDevpController.java
index 59319a1..112ed73 100644
--- a/src/main/java/com/zy/asrs/controller/BasDevpController.java
+++ b/src/main/java/com/zy/asrs/controller/BasDevpController.java
@@ -6,23 +6,56 @@
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.zy.asrs.entity.BasDevp;
+import com.zy.asrs.entity.param.BasDevpInitParam;
+import com.zy.asrs.service.BasCrnpService;
 import com.zy.asrs.service.BasDevpService;
+import com.zy.asrs.utils.Utils;
 import com.zy.common.web.BaseController;
 import com.core.annotations.ManagerAuth;
 import com.core.common.BaseRes;
 import com.core.common.Cools;
 import com.core.common.DateUtils;
 import com.core.common.R;
+import com.core.exception.CoolException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.nio.charset.Charset;
 import java.util.*;
 
 @RestController
 public class BasDevpController extends BaseController {
 
+    private static final Charset SQL_SERVER_VARCHAR_CHARSET = Charset.forName("GBK");
+
     @Autowired
     private BasDevpService basDevpService;
+    @Autowired
+    private BasCrnpService basCrnpService;
+
+    @RequestMapping(value = "/basDevp/init/auth")
+    @ManagerAuth(memo = "鍒濆鍖栫珯鐐�")
+    public R init(BasDevpInitParam param) {
+        List<BasDevp> list = new ArrayList<>();
+        for (int devNo = param.getStartDev() ; devNo<=param.getEndDev() ; devNo++){
+            BasDevp basDevp = basDevpService.selectById(devNo);
+            if (Cools.isEmpty(basDevp)){
+                BasDevp basDevp1 = new BasDevp();
+                basDevp1.setDevNo(devNo);
+                basDevp1.setInEnable("Y");
+                basDevp1.setOutEnable("Y");
+                basDevp1.setAutoing("Y");
+                basDevp1.setLoading("Y");
+                basDevp1.setCanining("Y");
+                basDevp1.setCanouting("Y");
+                basDevp1.setModiUser(getUserId());
+                basDevp1.setModiTime(new Date());
+                list.add(basDevp1);
+            }
+        }
+        basDevpService.insertBatch(list);
+        return R.ok("鍒濆鍖栨垚鍔�");
+    }
 
     @RequestMapping(value = "/basDevp/{id}/auth")
     @ManagerAuth
@@ -44,14 +77,15 @@
         return R.ok(basDevpService.selectPage(new Page<>(curr, limit), wrapper));
     }
 
-    private void convert(Map<String, Object> map, EntityWrapper wrapper){
+    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
         for (Map.Entry<String, Object> entry : map.entrySet()){
-            if (entry.getKey().endsWith(">")) {
-                wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue())));
-            } else if (entry.getKey().endsWith("<")) {
-                wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue())));
+            String val = String.valueOf(entry.getValue());
+            if (val.contains(RANGE_TIME_LINK)){
+                String[] dates = val.split(RANGE_TIME_LINK);
+                wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
+                wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
             } else {
-                wrapper.eq(entry.getKey(), String.valueOf(entry.getValue()));
+                wrapper.like(entry.getKey(), val);
             }
         }
     }
@@ -59,6 +93,8 @@
     @RequestMapping(value = "/basDevp/add/auth")
     @ManagerAuth(memo = "绔欑偣娣诲姞")
     public R add(BasDevp basDevp) {
+        normalizeInboundPriority(basDevp, null);
+        normalizeAndValidateForSave(basDevp);
         basDevp.setModiUser(getUserId());
         basDevp.setModiTime(new Date());
         basDevp.setAppeUser(getUserId());
@@ -73,6 +109,12 @@
         if (Cools.isEmpty(basDevp) || null==basDevp.getDevNo()){
             return R.error();
         }
+        BasDevp existing = basDevpService.selectById(basDevp.getDevNo());
+        if (existing == null) {
+            return R.error("绔欑偣涓嶅瓨鍦�");
+        }
+        normalizeInboundPriority(basDevp, existing);
+        normalizeAndValidateForSave(basDevp);
         basDevp.setModiUser(getUserId());
         basDevp.setModiTime(new Date());
         basDevpService.updateById(basDevp);
@@ -129,4 +171,116 @@
         return R.ok();
     }
 
+    private void normalizeAndValidateForSave(BasDevp basDevp) {
+        if (basDevp == null) {
+            return;
+        }
+        basDevp.setInEnable(normalizeYn("鍙叆", basDevp.getInEnable()));
+        basDevp.setOutEnable(normalizeYn("鍙嚭", basDevp.getOutEnable()));
+        basDevp.setAutoing(normalizeYn("鑷姩", basDevp.getAutoing()));
+        basDevp.setLoading(normalizeYn("鏈夌墿", basDevp.getLoading()));
+        basDevp.setCanining(normalizeYn("鑳藉叆", basDevp.getCanining()));
+        basDevp.setCanouting(normalizeYn("鑳藉嚭", basDevp.getCanouting()));
+        basDevp.setFronting(normalizeYn("fronting", basDevp.getFronting()));
+        basDevp.setRearing(normalizeYn("rearing", basDevp.getRearing()));
+        basDevp.setUping(normalizeYn("uping", basDevp.getUping()));
+        basDevp.setDowning(normalizeYn("downing", basDevp.getDowning()));
+        basDevp.setInreq1(normalizeYn("闇�姹�1", basDevp.getInreq1()));
+        basDevp.setInreq2(normalizeYn("闇�姹�2", basDevp.getInreq2()));
+        basDevp.setInOk(normalizeYn("in_ok", basDevp.getInOk()));
+        basDevp.setOutOk(normalizeYn("out_ok", basDevp.getOutOk()));
+
+        validateVarcharLength("璁惧鎻忚堪", basDevp.getDecDesc(), 30);
+        validateVarcharLength("澶囨敞", basDevp.getDevMk(), 1);
+        validateVarcharLength("鏉″舰鐮�", basDevp.getBarcode(), 255);
+        validateVarcharLength("缁戝畾搴撳尯", basDevp.getArea(), 255);
+        validateVarcharLength("绗竴浼樺厛姹�", basDevp.getInFirstCrnCsv(), 255);
+        validateVarcharLength("绗簩浼樺厛姹�", basDevp.getInSecondCrnCsv(), 255);
+    }
+
+    private String normalizeYn(String label, String value) {
+        if (Cools.isEmpty(value)) {
+            return null;
+        }
+        String normalized = value.trim().toUpperCase(Locale.ROOT);
+        if ("Y".equals(normalized) || "1".equals(normalized) || "TRUE".equals(normalized) || "YES".equals(normalized)) {
+            return "Y";
+        }
+        if ("N".equals(normalized) || "0".equals(normalized) || "FALSE".equals(normalized) || "NO".equals(normalized) || "OFF".equals(normalized) || "ON".equals(normalized)) {
+            return "N";
+        }
+        throw new CoolException(label + "鍙兘涓篩鎴朜");
+    }
+
+    private void validateVarcharLength(String label, String value, int maxBytes) {
+        if (value == null) {
+            return;
+        }
+        int bytes = value.getBytes(SQL_SERVER_VARCHAR_CHARSET).length;
+        if (bytes > maxBytes) {
+            throw new CoolException(label + "闀垮害涓嶈兘瓒呰繃" + maxBytes + "瀛楄妭");
+        }
+    }
+
+    private void normalizeInboundPriority(BasDevp basDevp, BasDevp existing) {
+        if (basDevp == null) {
+            return;
+        }
+        String firstCsv = resolveCsvValue(basDevp.getInFirstCrnCsv(), existing == null ? null : existing.getInFirstCrnCsv());
+        String secondCsv = resolveCsvValue(basDevp.getInSecondCrnCsv(), existing == null ? null : existing.getInSecondCrnCsv());
+
+        List<Integer> firstCrnNos = parseCrnPool("绗竴浼樺厛姹�", firstCsv);
+        List<Integer> secondCrnNos = parseCrnPool("绗簩浼樺厛姹�", secondCsv);
+        Set<Integer> duplicateCrnNos = new LinkedHashSet<>(firstCrnNos);
+        duplicateCrnNos.retainAll(secondCrnNos);
+        if (!duplicateCrnNos.isEmpty()) {
+            throw new CoolException("绗竴浼樺厛姹犲拰绗簩浼樺厛姹犱笉鑳介噸澶嶉厤缃悓涓�鍙板爢鍨涙満锛�" + duplicateCrnNos);
+        }
+
+        basDevp.setInFirstCrnCsv(Utils.normalizeCrnCsv(firstCrnNos));
+        basDevp.setInSecondCrnCsv(Utils.normalizeCrnCsv(secondCrnNos));
+
+        if (existing == null) {
+            basDevp.setInFirstCrnCurrentNo(null);
+            basDevp.setInSecondCrnCurrentNo(null);
+            return;
+        }
+
+        basDevp.setInFirstCrnCurrentNo(resolveCurrentNo(existing.getInFirstCrnCurrentNo(), firstCrnNos));
+        basDevp.setInSecondCrnCurrentNo(resolveCurrentNo(existing.getInSecondCrnCurrentNo(), secondCrnNos));
+    }
+
+    private String resolveCsvValue(String incoming, String existing) {
+        if (incoming == null) {
+            return existing;
+        }
+        return incoming;
+    }
+
+    private List<Integer> parseCrnPool(String label, String csv) {
+        List<Integer> crnNos;
+        try {
+            crnNos = Utils.parseCrnNos(csv);
+        } catch (CoolException e) {
+            throw new CoolException(label + e.getMessage());
+        }
+        List<Integer> distinctCrnNos = Utils.distinctCrnNos(crnNos);
+        if (crnNos.size() != distinctCrnNos.size()) {
+            throw new CoolException(label + "瀛樺湪閲嶅鍫嗗灈鏈哄彿");
+        }
+        for (Integer crnNo : distinctCrnNos) {
+            if (basCrnpService.selectById(crnNo) == null) {
+                throw new CoolException(label + "鍖呭惈涓嶅瓨鍦ㄧ殑鍫嗗灈鏈哄彿锛�" + crnNo);
+            }
+        }
+        return distinctCrnNos;
+    }
+
+    private Integer resolveCurrentNo(Integer currentNo, List<Integer> crnNos) {
+        if (currentNo == null || Cools.isEmpty(crnNos) || !crnNos.contains(currentNo)) {
+            return null;
+        }
+        return currentNo;
+    }
+
 }

--
Gitblit v1.9.1