From 5f2bb7dd02cce1696dcc37d9591830864509eb27 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 19 九月 2025 16:43:10 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/OutController.java |  104 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 69 insertions(+), 35 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/OutController.java b/src/main/java/com/zy/asrs/controller/OutController.java
index 6243ff7..ad89948 100644
--- a/src/main/java/com/zy/asrs/controller/OutController.java
+++ b/src/main/java/com/zy/asrs/controller/OutController.java
@@ -22,6 +22,9 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -162,8 +165,13 @@
                         orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3(), cstateid);
 
                 HashMap<String, Double> locAnfmeMap = new HashMap<>();
+                HashMap<String, Date> locTimeMap = new HashMap<>();
                 HashMap<String, List<LocDetl>> map = new HashMap<>();
                 for (LocDetl locDetl : locDetls) {
+                    if (disableCstateidList.contains(locDetl.getCstateid())) {
+                        continue;
+                    }
+
                     if (map.containsKey(locDetl.getLocNo())) {
                         List<LocDetl> list = map.get(locDetl.getLocNo());
                         list.add(locDetl);
@@ -177,59 +185,85 @@
                         list.add(locDetl);
                         map.put(locDetl.getLocNo(), list);
                         locAnfmeMap.put(locDetl.getLocNo(), locDetl.getAnfme());
+                        locTimeMap.put(locDetl.getLocNo(), locDetl.getAppeTime());
                     }
                 }
 
-                // 浣跨敤Stream API杩涜鎺掑簭骞跺垱寤烘柊鐨凪ap锛屽悓鏃朵繚鎸佹彃鍏ラ『搴忋��
-                Map<String, Double> sortedMap = locAnfmeMap.entrySet().stream()
-                        .sorted(Map.Entry.<String, Double>comparingByValue(Comparator.reverseOrder())) // 鏍规嵁鍊兼帓搴忔潯鐩��
-                        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+                // 浣跨敤 TreeMap锛堣嚜鍔ㄦ寜 key 鍗囧簭鎺掑簭锛�
+                Map<String, List<Map.Entry<String, Date>>> sortedByDayAsc = locTimeMap.entrySet()
+                        .stream()
+                        .collect(Collectors.groupingBy(
+                                entry -> sdf.format(entry.getValue()),
+                                TreeMap::new, // 鑷姩鎸夐敭锛堟棩鏈燂級鍗囧簭鎺掑簭
+                                Collectors.toList()
+                        ));
 
                 //鏈尮閰嶄笂鏁存墭搴撳瓨
                 HashMap<String, Double> lessMap = new HashMap<>();
 
                 List<LocDetl> allLoc = new ArrayList<>();
                 List<LocDetl> lessLoc = new ArrayList<>();
-                //浼樺厛鎵炬暣鎵�
-                for (Map.Entry<String, Double> entry : sortedMap.entrySet()) {
-                    if (issued <= 0) {
-                        break;
-                    }
 
-                    String locNo = entry.getKey();
-                    Double anfme = entry.getValue();
-                    if(anfme > orderDetl.getAnfme()) {
-                        lessMap.put(locNo, anfme);
-                        continue;
-                    }
-                    List<LocDetl> list = map.get(locNo);
-                    allLoc.addAll(list);
+//                //浼樺厛鎵炬暣鎵�
+//                for (Map.Entry<String, List<Map.Entry<String, Date>>> listEntry : sortedByDayAsc.entrySet()) {
+//                    for (Map.Entry<String, Date> dateEntry : listEntry.getValue()) {
+//                        if (issued <= 0) {
+//                            break;
+//                        }
+//                        String locNo = dateEntry.getKey();
+//                        Double anfme = locAnfmeMap.get(locNo);
+//                        if(anfme > orderDetl.getAnfme()) {
+//                            lessMap.put(locNo, anfme);
+//                            continue;
+//                        }
+//                        List<LocDetl> list = map.get(locNo);
+//                        allLoc.addAll(list);
+//
+//                        // 鍓╀綑寰呭嚭鏁伴噺閫掑噺
+//                        issuedBigDecimal = issuedBigDecimal.subtract(BigDecimal.valueOf(anfme));
+//                        issued = issuedBigDecimal.doubleValue();
+//                    }
+//                }
+//
+//                if(issued > 0) {
+//                    //闆舵暎鎼滅储
+//                    for (Map.Entry<String, Double> entry : lessMap.entrySet()) {
+//                        if (issued <= 0) {
+//                            break;
+//                        }
+//
+//                        String locNo = entry.getKey();
+//                        Double anfme = entry.getValue();
+//                        if (anfme >= issued) {
+//                            List<LocDetl> list = map.get(locNo);
+//                            lessLoc.addAll(list);
+//                            // 鍓╀綑寰呭嚭鏁伴噺閫掑噺
+//                            issuedBigDecimal = issuedBigDecimal.subtract(BigDecimal.valueOf(anfme));
+//                            issued = issuedBigDecimal.doubleValue();
+//                        }
+//                    }
+//                }
+//                allLoc.addAll(lessLoc);
 
-                    // 鍓╀綑寰呭嚭鏁伴噺閫掑噺
-                    issuedBigDecimal = issuedBigDecimal.subtract(BigDecimal.valueOf(anfme));
-                    issued = issuedBigDecimal.doubleValue();
-                }
-
-                if(issued > 0) {
-                    //闆舵暎鎼滅储
-                    for (Map.Entry<String, Double> entry : lessMap.entrySet()) {
+                //蹇呴』鎶婂綋澶╁簱瀛樼敤瀹�
+                for (Map.Entry<String, List<Map.Entry<String, Date>>> listEntry : sortedByDayAsc.entrySet()) {
+                    for (Map.Entry<String, Date> dateEntry : listEntry.getValue()) {
                         if (issued <= 0) {
                             break;
                         }
+                        String locNo = dateEntry.getKey();
+                        Double anfme = locAnfmeMap.get(locNo);
 
-                        String locNo = entry.getKey();
-                        Double anfme = entry.getValue();
-                        if (anfme >= issued) {
-                            List<LocDetl> list = map.get(locNo);
-                            lessLoc.addAll(list);
-                            // 鍓╀綑寰呭嚭鏁伴噺閫掑噺
-                            issuedBigDecimal = issuedBigDecimal.subtract(BigDecimal.valueOf(anfme));
-                            issued = issuedBigDecimal.doubleValue();
-                        }
+                        List<LocDetl> list = map.get(locNo);
+                        allLoc.addAll(list);
+
+                        // 鍓╀綑寰呭嚭鏁伴噺閫掑噺
+                        issuedBigDecimal = issuedBigDecimal.subtract(BigDecimal.valueOf(anfme));
+                        issued = issuedBigDecimal.doubleValue();
                     }
                 }
 
-                allLoc.addAll(lessLoc);
                 issuedBigDecimal = Optional.of(BigDecimal.valueOf(orderDetl.getAnfme()).subtract(BigDecimal.valueOf(orderDetl.getWorkQty()))).orElse(new BigDecimal(0));
                 issued = issuedBigDecimal.doubleValue();
                 for (LocDetl locDetl : allLoc) {

--
Gitblit v1.9.1