From ee03f78ceb74f81afff6f5dbcc0398b5d021fe37 Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期日, 18 一月 2026 15:41:19 +0800
Subject: [PATCH] 倾斜度

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  348 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 313 insertions(+), 35 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index 1867759..8ee6f4b 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -9,18 +9,25 @@
 import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.*;
 import com.zy.asrs.enums.LocStsType;
+import com.zy.asrs.enums.TaskIOType;
+import com.zy.asrs.mapper.BasDevpMapper;
+import com.zy.asrs.mapper.BasStationMapper;
 import com.zy.asrs.mapper.LocMastMapper;
 import com.zy.asrs.mapper.ManLocDetlMapper;
 import com.zy.asrs.service.*;
+import com.zy.asrs.task.core.ReturnT;
 import com.zy.asrs.utils.MatUtils;
+import com.zy.common.constant.ApiInterfaceConstant;
 import com.zy.common.constant.MesConstant;
 import com.zy.common.entity.Parameter;
 import com.zy.common.model.DetlDto;
 import com.zy.common.model.MesCombParam;
 import com.zy.common.model.enums.WorkNoType;
+import com.zy.common.properties.AgvProperties;
 import com.zy.common.service.CommonService;
 import com.zy.common.utils.HttpHandler;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -30,6 +37,8 @@
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 /**
@@ -109,6 +118,275 @@
     private BasStationService basStationService;
     @Autowired
     private BasContainerService basContainerService;
+
+    @Resource
+    private BasStationMapper basStationMapper;
+
+    @Resource
+    private BasDevpMapper basDevpMapper;
+
+    @Resource
+    private AgvProperties agvProperties;
+
+    /**
+     * 绔欑偣杞璁℃暟鍣紝鐢ㄤ簬骞冲潎鍒嗛厤绔欑偣
+     * Key: 绔欑偣缁勬爣璇嗭紙濡� "east" 鎴� "west"锛夛紝Value: 褰撳墠杞绱㈠紩
+     */
+    private final Map<String, AtomicInteger> siteRoundRobinCounters = new ConcurrentHashMap<>();
+
+    @Override
+    public R inLocCallAgv(CallAgvParam param,Long userId) {
+        int type = param.getType();
+        String sourceSite = param.getSourceSite();
+        String barcode = param.getBarcode();
+        int ioType;
+        // 鏌ヨ婧愮珯鐐癸紙搴撲綅锛変俊鎭紝浣嗕笉妫�鏌ユ槸鍚﹀瓨鍦紝鍏佽涓嬪崟鎴愬姛
+        // 绔欑偣涓嶅瓨鍦ㄧ殑妫�鏌ュ皢鍦ㄥ畾鏃朵换鍔★紙AgvHandler.callAgv锛変腑杩涜
+        LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", sourceSite));
+        switch (type) {
+            case 1:
+                // 鍒ゆ柇鏈夋病鏈夌粍鎵�
+                int count = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
+                if (count == 0) {
+                    throw new CoolException("鏉$爜鏈粍鎵橈細" + barcode);
+                }
+                ioType = 1; // AGV瀹瑰櫒鍏ュ簱锛堝疄鎵樺叆搴擄級
+
+                // 濡傛灉搴撲綅瀛樺湪锛屾洿鏂扮姸鎬佷负鍏ュ簱棰勭害锛涗笉瀛樺湪鍒欒烦杩囷紝鐢卞畾鏃朵换鍔″鐞�
+                if (locCache != null) {
+                    locCache.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
+                    locCacheService.updateById(locCache);
+                }
+                break;
+            case 2:
+                // 鍒ゆ柇鏄嫞閫夊洖搴撴墭鐩�
+                WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", barcode));
+                if (wrkMast == null) {
+                    throw new CoolException("鏉$爜涓嶅瓨鍦細" + barcode);
+                }
+                if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 107) {
+                    throw new CoolException("鏉$爜涓嶉渶瑕佸洖搴擄細" + barcode);
+                }
+                ioType = wrkMast.getIoType() - 50; // 103->53(鎷f枡鍏ュ簱), 107->57(鐩樼偣鍏ュ簱)
+
+                // 濡傛灉搴撲綅瀛樺湪锛屾洿鏂扮姸鎬佷负鍏ュ簱棰勭害锛涗笉瀛樺湪鍒欒烦杩囷紝鐢卞畾鏃朵换鍔″鐞�
+                if (locCache != null) {
+                    locCache.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害锛堝鍣ㄥ洖搴撴槸鍏ュ簱鎿嶄綔锛�
+                    locCacheService.updateById(locCache);
+                }
+                break;
+            case 3:
+                // 鍒ゆ柇鏄惁涓虹┖鎵樺叆搴擄細妫�鏌ユ潯鐮佸湪wms涓笉瀛樺湪锛岀‘璁や负绌烘墭鐩�
+                log.info("寮�濮嬪垽鏂槸鍚︿负绌烘墭鍏ュ簱锛屾潯鐮侊細{}", barcode);
+                
+                // 妫�鏌ユ槸鍚﹀凡缁勬墭
+                int waitPakInCount = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
+                if (waitPakInCount != 0) {
+                    log.warn("鏉$爜缁勬墭妗e凡瀛樺湪锛屼笉鏄┖鎵樼洏锛歿}", barcode);
+                    throw new CoolException("鏉$爜缁勬墭妗e凡瀛樺湪锛�" + barcode);
+                }
+                
+                // 妫�鏌ユ槸鍚︽湁浠诲姟
+                int wrkMastCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("barcode", barcode));
+                if (wrkMastCount != 0) {
+                    log.warn("鏉$爜浠诲姟妗e凡瀛樺湪锛屼笉鏄┖鎵樼洏锛歿}", barcode);
+                    throw new CoolException("鏉$爜浠诲姟妗e凡瀛樺湪锛�" + barcode);
+                }
+                
+                // 妫�鏌ユ槸鍚︽湁搴撳瓨
+                int locDetlCount = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", barcode));
+                if (locDetlCount != 0) {
+                    log.warn("鏉$爜搴撳瓨宸插瓨鍦紝涓嶆槸绌烘墭鐩橈細{}", barcode);
+                    throw new CoolException("鏉$爜搴撳瓨宸插瓨鍦細" + barcode);
+                }
+                
+                // 閫氳繃鎵�鏈夋鏌ワ紝纭涓虹┖鎵樼洏锛岃缃负绌烘墭鍏ュ簱
+                ioType = 10;
+                log.info("纭涓虹┖鎵樼洏锛岃缃负绌烘墭鍏ュ簱锛屾潯鐮侊細{}锛宨oType锛歿}", barcode, ioType);
+                break;
+            default:
+                throw new CoolException("鍏ュ簱绫诲瀷閿欒,type锛�" + type);
+        }
+        // 鏉$爜瀛樺湪agv浠诲姟
+        int count = taskService.selectCount(new EntityWrapper<Task>().eq("barcode", barcode));
+        if (count > 0) {
+            throw new CoolException(barcode+ "锛氭潯鐮佸瓨鍦╝gv鎼繍浠诲姟!");
+        }
+
+        // 鏍规嵁whs_type鍜屽簱浣嶇紪鍙峰墠缂�閫夋嫨绔欑偣鍜屾満鍣ㄤ汉缁�
+        // 濡傛灉搴撲綅涓嶅瓨鍦紝浣跨敤榛樿閫昏緫锛堟牴鎹畉ype鍒ゆ柇锛夛紝绔欑偣涓嶅瓨鍦ㄧ殑妫�鏌ュ皢鍦ㄥ畾鏃朵换鍔′腑杩涜
+        Long whsType = locCache != null ? locCache.getWhsType() : null;
+        String locNo = locCache != null ? locCache.getLocNo() : sourceSite;
+        List<String> targetStations;
+        String robotGroup;
+        
+        // 鍒ゆ柇搴撲綅缂栧彿鍓嶇紑锛欳A寮�澶村彧鍋氬叆搴擄紝WA寮�澶存墠浼氳鍑哄簱鍒嗛厤缂撳瓨鍖猴紙浠庨厤缃鍙栵級
+        String inboundOnlyPrefix = agvProperties.getLocationPrefix().getInboundOnly();
+        String cacheAreaPrefix = agvProperties.getLocationPrefix().getCacheArea();
+        boolean isCA = locNo != null && locNo.startsWith(inboundOnlyPrefix);
+        boolean isWA = locNo != null && locNo.startsWith(cacheAreaPrefix);
+        
+        if (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getInboundArea())) {
+            // whs_type = 1: 鍏ュ簱鍖猴紝浣跨敤涓滀晶绔欑偣鍜孏roup-001
+            targetStations = agvProperties.getEastStations();
+            robotGroup = agvProperties.getRobotGroupEast();
+            log.info("搴撲綅whs_type={}锛屽簱浣嶇紪鍙�={}锛坽}锛夛紝浣跨敤鍏ュ簱鍖洪厤缃紙{}绔欑偣鍜寋}锛�", 
+                whsType, locNo, isCA ? "CA" : (isWA ? "WA" : "鍏朵粬"), 
+                agvProperties.getEastDisplayName(), robotGroup);
+        } else if (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getCacheArea())) {
+            // whs_type = 2: 缂撳瓨鍖猴紝浣跨敤瑗夸晶绔欑偣鍜孏roup-002
+            // 娉ㄦ剰锛氬鏋滄湁CA寮�澶寸殑鍏ュ簱锛屼絾鏄爣璁板湪瑗夸晶鐨勶紙whs_type=2锛夛紝涔熶細鍒嗛厤鍒拌タ渚х殑绔欑偣鍏ュ簱
+            targetStations = agvProperties.getWestStations();
+            robotGroup = agvProperties.getRobotGroupWest();
+            log.info("搴撲綅whs_type={}锛屽簱浣嶇紪鍙�={}锛坽}锛夛紝浣跨敤缂撳瓨鍖洪厤缃紙{}绔欑偣鍜寋}锛�", 
+                whsType, locNo, isCA ? "CA" : (isWA ? "WA" : "鍏朵粬"),
+                agvProperties.getWestDisplayName(), robotGroup);
+        } else {
+            // whs_type涓虹┖鎴栧叾浠栧�硷紝鏍规嵁type鍒ゆ柇锛堝吋瀹规棫閫昏緫锛�
+            // 濡傛灉搴撲綅涓嶅瓨鍦紝涔熶娇鐢ㄦ閫昏緫
+            if (type == 1) {
+                targetStations = agvProperties.getEastStations();
+                robotGroup = agvProperties.getRobotGroupEast();
+            } else {
+                targetStations = agvProperties.getWestStations();
+                robotGroup = agvProperties.getRobotGroupWest();
+            }
+            if (locCache == null) {
+                log.warn("婧愮珯鐐癸紙搴撲綅锛墈}涓嶅瓨鍦紝浣跨敤type={}鐨勯粯璁ら�昏緫锛岀珯鐐规鏌ュ皢鍦ㄥ畾鏃朵换鍔′腑杩涜", sourceSite, type);
+            } else {
+                log.warn("搴撲綅whs_type={}鏈厤缃垨涓嶅湪鏄犲皠鑼冨洿鍐咃紝浣跨敤type={}鐨勯粯璁ら�昏緫", whsType, type);
+            }
+        }
+        
+        // 灏嗙珯鐐瑰瓧绗︿覆鍒楄〃杞崲涓烘暣鏁板垪琛�
+        List<Integer> siteIntList = targetStations.stream()
+                .map(Integer::parseInt)
+                .collect(Collectors.toList());
+        
+        // 鍒ゆ柇鑳藉叆绔欑偣锛坕n_enable="Y"琛ㄧず鑳藉叆锛夛紝鎺掗櫎dev_no=0鐨勬棤鏁堢珯鐐�
+        // 娉ㄦ剰锛氫笉鍦ㄦ澶勬鏌ョ珯鐐规槸鍚﹀瓨鍦ㄦ垨鍙敤锛屽厑璁镐笅鍗曟垚鍔�
+        // 绔欑偣妫�鏌ュ拰鍒嗛厤灏嗗湪瀹氭椂浠诲姟锛圓gvHandler.callAgv锛変腑杩涜
+        List<Integer> sites = basDevpMapper.selectList(
+                new EntityWrapper<BasDevp>()
+                        .eq("in_enable", "Y") // in_enable鏄兘鍏�
+                        .in("dev_no", siteIntList)
+                        .ne("dev_no", 0) // 鎺掗櫎dev_no=0鐨勬棤鏁堢珯鐐�
+        ).stream()
+                .map(BasDevp::getDevNo)
+                .filter(devNo -> devNo != null && devNo != 0) // 鍐嶆杩囨护锛岀‘淇濅笉涓簄ull鎴�0
+                .collect(Collectors.toList());
+
+        // 鑾峰彇娌℃湁鍑哄簱浠诲姟鐨勭珯鐐�
+        List<Integer> canInSites = sites.isEmpty() ? new ArrayList<>() : basDevpMapper.getCanInSites(sites);
+
+        // 瀵绘壘鍏ュ簱浠诲姟鏈�灏戠殑绔欑偣锛堜笖蹇呴』in_enable="Y"鑳藉叆 鍜� canining="Y"鍙叆锛夛紝鎺掗櫎dev_no=0鐨勬棤鏁堢珯鐐�
+        // 娉ㄦ剰锛氫笉鍦ㄦ澶勬鏌ユ湭瀹屾垚鐨凙GV浠诲姟锛屽厑璁窹DA鎸佺画鐢宠涓嬪崟
+        // 鏈畬鎴愪换鍔$殑妫�鏌ュ皢鍦ㄥ彂閫丄GV璇锋眰鏃惰繘琛岋紙AgvHandler.callAgv锛�
+        List<BasDevp> devList = canInSites.isEmpty() ? new ArrayList<>() : basDevpMapper.selectList(new EntityWrapper<BasDevp>()
+                .in("dev_no", canInSites)
+                .eq("in_enable", "Y") // in_enable鏄兘鍏�
+                .eq("canining", "Y") // canining鏄彲鍏�
+                .ne("dev_no", 0) // 鎺掗櫎dev_no=0鐨勬棤鏁堢珯鐐�
+        ).stream()
+                .filter(dev -> dev.getDevNo() != null && dev.getDevNo() != 0) // 鍐嶆杩囨护锛岀‘淇濅笉涓簄ull鎴�0
+                .collect(Collectors.toList());
+        
+        // 閫夋嫨绔欑偣锛堝鏋滃彲鍏ョ珯鐐逛负绌猴紝鍒欎笉鍦ㄥ垱寤轰换鍔℃椂鍒嗛厤绔欑偣锛岀敱瀹氭椂浠诲姟鍒嗛厤锛�
+        Integer endSite = null;
+        if (!devList.isEmpty()) {
+            // 鍏ュ簱浠诲姟鏁版帓搴�
+            devList.sort(Comparator.comparing(BasDevp::getInQty));
+
+            // 閫夋嫨绔欑偣
+            BasDevp basDevp;
+            
+            // 鑾峰彇鏈�灏戜换鍔℃暟
+            int minInQty = devList.get(0).getInQty();
+            
+            // 绛涢�夊嚭浠诲姟鏁版渶灏戠殑绔欑偣鍒楄〃
+            List<BasDevp> minTaskSites = devList.stream()
+                    .filter(dev -> dev.getInQty() == minInQty)
+                    .collect(Collectors.toList());
+            
+            // 鏍规嵁閰嶇疆閫夋嫨鍒嗛厤绛栫暐
+            String strategy = agvProperties.getSiteAllocation().getStrategy();
+            boolean enableRoundRobin = agvProperties.getSiteAllocation().isEnableRoundRobin();
+            
+            if (minTaskSites.size() > 1 && enableRoundRobin && "round-robin".equals(strategy)) {
+                // 杞鍒嗛厤锛氬綋澶氫釜绔欑偣浠诲姟鏁扮浉鍚屾椂锛屼娇鐢ㄨ疆璇�
+                String groupKey = (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getInboundArea())) 
+                        ? "east" : "west";
+                AtomicInteger counter = siteRoundRobinCounters.computeIfAbsent(groupKey, k -> new AtomicInteger(0));
+                int index = counter.getAndIncrement() % minTaskSites.size();
+                basDevp = minTaskSites.get(index);
+                log.info("浣跨敤杞鍒嗛厤绛栫暐锛岀珯鐐圭粍锛歿}锛岃疆璇㈢储寮曪細{}锛岄�変腑绔欑偣锛歿}", groupKey, index, basDevp.getDevNo());
+            } else if (minTaskSites.size() > 1 && enableRoundRobin && "random".equals(strategy)) {
+                // 闅忔満鍒嗛厤
+                Random random = new Random();
+                int index = random.nextInt(minTaskSites.size());
+                basDevp = minTaskSites.get(index);
+                log.info("浣跨敤闅忔満鍒嗛厤绛栫暐锛岄�変腑绔欑偣锛歿}", basDevp.getDevNo());
+            } else {
+                // 榛樿锛氶�夋嫨绗竴涓紙浠诲姟鏈�灏戠殑锛�
+                basDevp = devList.get(0);
+                if (minTaskSites.size() > 1) {
+                    log.info("澶氫釜绔欑偣浠诲姟鏁扮浉鍚岋紙{}锛夛紝浣嗘湭鍚敤杞锛岄�夋嫨绗竴涓珯鐐癸細{}", minInQty, basDevp.getDevNo());
+                }
+            }
+            
+            endSite = basDevp.getDevNo();
+            
+            // 妫�鏌ョ珯鐐规槸鍚︽湁鏁堬紙涓嶈兘涓�0鎴杗ull锛�
+            if (endSite == null || endSite == 0) {
+                log.error("鍒嗛厤鐨勭珯鐐规棤鏁堬紙dev_no={}锛夛紝涓嶅垎閰嶇珯鐐癸紝灏嗗湪瀹氭椂浠诲姟涓垎閰�", endSite);
+                endSite = null; // 璁剧疆涓簄ull锛岀敱瀹氭椂浠诲姟鍒嗛厤
+            } else {
+                // 鍏ュ簱鏆傚瓨+1
+                basDevpMapper.incrementInQty(endSite);
+            }
+        } else {
+            // 娌℃湁鍙叆绔欑偣锛岃褰曟棩蹇椾絾涓嶉樆姝笅鍗曪紝绔欑偣鍒嗛厤灏嗗湪瀹氭椂浠诲姟涓鐞�
+            String groupName = (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getInboundArea())) 
+                    ? agvProperties.getEastDisplayName() : agvProperties.getWestDisplayName();
+//            log.warn("{}鍙敤绔欑偣锛坽}锛変腑娌℃湁鍙叆绔欑偣锛坕n_enable='Y'涓攃anining='Y'锛夛紝鏆備笉鍒嗛厤绔欑偣锛屽皢鍦ㄥ畾鏃朵换鍔′腑鍒嗛厤", groupName, canInSites);
+        }
+
+
+        // 鑾峰彇宸ヤ綔鍙�
+        int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+        // 淇濆瓨宸ヤ綔妗�
+        Task task = new Task();
+        Date now = new Date();
+        task.setWrkNo(workNo)
+                .setIoTime(now)
+                .setWrkSts(7L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+                .setIoType(ioType) // 鍏ュ嚭搴撶姸鎬侊細 1.鍏ュ簱
+                .setTaskType("agv")
+                .setIoPri(10D)
+                .setStaNo(endSite != null ? String.valueOf(endSite) : null) // 濡傛灉鍒嗛厤浜嗙珯鐐瑰垯璁剧疆锛屽惁鍒欎负null锛岀敱瀹氭椂浠诲姟鍒嗛厤
+                .setSourceStaNo(sourceSite) // 璁剧疆婧愮珯鐐�
+                .setInvWh(robotGroup) // 鏍规嵁whs_type璁剧疆鏈哄櫒浜虹粍
+                .setFullPlt(ioType == 10 ? "N" : "Y")// 绌烘墭鍏ュ簱(ioType=10)璁剧疆涓篘锛屽叾浠栧叆搴撹缃负Y锛堟弧鏉匡級
+                .setPicking("N") // 鎷f枡
+                .setExitMk("N")// 閫�鍑�
+                .setSourceLocNo(locCache != null ? locCache.getLocNo() : sourceSite) // 璁剧疆婧愬簱浣嶇紪鍙凤紝鐢ㄤ簬AGV fromBin锛屽鏋滃簱浣嶄笉瀛樺湪鍒欎娇鐢╯ourceSite
+                .setEmptyMk(ioType == 10 ? "Y" : "N")// 绌烘墭鍏ュ簱(ioType=10)璁剧疆涓篩锛屽叾浠栬缃负N
+                .setBarcode(barcode)// 鎵樼洏鐮�
+                .setLinkMis("N")
+                .setAppeTime(now)
+                .setModiTime(now);
+        if (!taskService.insert(task)) {
+            throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+        }
+
+        // 濡傛灉搴撲綅瀛樺湪锛屾牴鎹甶oType鏇存柊鏆傚瓨浣嶇姸鎬侊細鍏ュ簱浠诲姟璁剧疆涓篠锛堝叆搴撻绾︼級锛屽嚭搴撲换鍔¤缃负R锛堝嚭搴撻绾︼級
+        if (locCache != null) {
+            String locSts = (ioType < 100) ? "S" : "R"; // 鍏ュ簱浠诲姟锛坕oType < 100锛夎缃负S锛屽嚭搴撲换鍔¤缃负R
+            basStationMapper.updateLocStsBatch( Collections.singletonList(String.valueOf(sourceSite)), locSts);
+        }
+        return R.ok("agv浠诲姟鐢熸垚鎴愬姛!");
+
+    }
 
     @Override
     @Transactional
@@ -601,9 +879,9 @@
                 if (Cools.isEmpty(mat)) {
                     throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
                 }
-                if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) {
-                    throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟鏈�澶х粍鎵樹笂闄愪负锛�" + mat.getUpQty());
-                }
+//                if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) {
+//                    throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟鏈�澶х粍鎵樹笂闄愪负锛�" + mat.getUpQty());
+//                }
                 WaitPakin waitPakin = new WaitPakin();
                 BeanUtils.copyProperties(mat, waitPakin);
                 waitPakin.setBatch(detlDto.getBatch());
@@ -626,7 +904,7 @@
             param.getCombMats().forEach(elem -> {
                 OrderPakin order = orderPakinService.selectByNo(elem.getOrderNo());
                 if (Cools.isEmpty(order) || order.getSettle() > 2) {
-                    throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
+                    throw new CoolException("鍗曟嵁姝e湪浣滀笟涓�");
                 }
                 // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
                 OrderDetlPakin detls = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
@@ -655,38 +933,38 @@
                 }
             });
 
-            BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
-            if (Objects.isNull(container)) {
-                throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
-            }
-            if (container.getMixMax() < detlDtos.size()) {
-                throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
-            }
-            Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet());
-            List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
-            Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet());
-            if (tagIds.size() > 1) {
-                throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
-            }
-            //杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
-            Integer suplus = container.getMixMax();
+//            BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
+//            if (Objects.isNull(container)) {
+//                throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
+//            }
+//            if (container.getMixMax() < detlDtos.size()) {
+//                throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
+//            }
+//            Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet());
+//            List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
+//            Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet());
+//            if (tagIds.size() > 1) {
+//                throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
+//            }
+//            //杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
+//            Integer suplus = container.getMixMax();
             for (DetlDto detlDto : detlDtos) {
                 Mat mat = matService.selectByMatnr(detlDto.getMatnr());
                 if (Cools.isEmpty(mat)) {
                     throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
                 }
-                //鏈�澶氬彲鏀炬暟閲�
-                Double singleMax = mat.getUpQty() * suplus;
-                if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
-                    throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
-                }
-                BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
-                //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
-                Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
-                suplus = suplus - curr;
-                if (suplus < 0) {
-                    throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
-                }
+//                //鏈�澶氬彲鏀炬暟閲�
+//                Double singleMax = mat.getUpQty() * suplus;
+//                if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
+//                    throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
+//                }
+//                BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
+//                //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
+//                Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
+//                suplus = suplus - curr;
+//                if (suplus < 0) {
+//                    throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+//                }
 
                 WaitPakin waitPakin = new WaitPakin();
                 BeanUtils.copyProperties(mat, waitPakin);
@@ -914,7 +1192,7 @@
                 boolean success = false;
                 try {
                     response = new HttpHandler.Builder()
-                            .setUri(MesConstant.URL)
+                            .setUri(MesConstant.URI)
                             .setPath(MesConstant.PACK_DOWN_URL)
                             .setJson(JSON.toJSONString(mesCombParam))
                             .build()
@@ -923,10 +1201,10 @@
                     if (jsonObject.getInteger("code").equals(200)) {
                         success = true;
                     } else if (jsonObject.getInteger("code").equals(500)) {
-                        log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response);
+                        log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URI + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response);
                         throw new CoolException(jsonObject.getString("msg"));
                     } else {
-                        log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response);
+                        log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URI + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response);
                         throw new CoolException("涓婃姤mes绯荤粺澶辫触");
                     }
                 } catch (Exception e) {
@@ -937,7 +1215,7 @@
                         // 淇濆瓨鎺ュ彛鏃ュ織
                         apiLogService.save(
                                 "鎵撳寘涓嬬嚎甯墭涓婃姤",
-                                MesConstant.URL + MesConstant.PACK_DOWN_URL,
+                                MesConstant.URI + MesConstant.PACK_DOWN_URL,
                                 null,
                                 "127.0.0.1",
                                 JSON.toJSONString(mesCombParam),

--
Gitblit v1.9.1