From 3ab330b8aefb3cd781c9b8730b4ab7ac65e7e9d7 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期五, 07 三月 2025 09:14:08 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override

---
 north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java |   87 ++++++++++++++++++++++++++++---------------
 1 files changed, 57 insertions(+), 30 deletions(-)

diff --git a/north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java b/north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
index 057678f..f7aa975 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
@@ -29,6 +29,7 @@
 import java.sql.Date;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 import static com.example.erp.service.sd.OrderService.getOrderProcessDetails;
 
@@ -895,11 +896,14 @@
         }
 
         String[] processCardList = processCard.split("/");
+        List<String> result = IntStream.range(0, processCardList[1].length())
+                .mapToObj(i -> String.valueOf(processCardList[1].charAt(i)))
+                .collect(Collectors.toList());
 
         List<FlowCard> flowCardList = flowCardMapper.selectList(
                 new QueryWrapper<FlowCard>()
                         .eq("process_id", processCardList[0])
-                        .eq("technology_number", processCardList[1])
+                        .in("technology_number", result)
         );
         for (FlowCard flowCard : flowCardList) {
             flowCard.setOrderGlassDetail(
@@ -1062,20 +1066,27 @@
     }
 
     public Object processCardAutoRack(Map<String, Object> object) {
-        String orderId = "NG25000004";
-        String productionId = "NG25000004B";
-        /*String orderId = object.get("orderId").toString();
+        String orderId = object.get("orderId").toString();
         String productionId = object.get("productionId").toString();
         Integer inMaxQuantity = Integer.parseInt(object.get("inMaxQuantity").toString());
         Float inWeight =  Float.parseFloat(object.get("inWeight").toString());
-        Float shelfThickness =  Float.parseFloat(object.get("shelfThickness").toString())*1000;
+        Float shelfThickness =  Float.parseFloat(object.get("shelfThickness").toString());
         Float spacerThickness =  Float.parseFloat(object.get("spacerThickness").toString());
-        */
-        //Integer inMaxQuantity = 1;
-        Float inWeight = 100.0f;
+        Float inLenMax = Float.parseFloat(object.get("inLenMax").toString());
+        Float inLenMin = Float.parseFloat(object.get("inLenMin").toString());
+        Float inShortMax = Float.parseFloat(object.get("inShortMax").toString());
+        Float inShortMin = Float.parseFloat(object.get("inShortMin").toString());
+
+        /*String orderId = "NG25000004";
+        String productionId = "NG25000004A";
+        Integer inMaxQuantity = 1;
+        Float inWeight = 4000.0f;
         Float shelfThickness = 2000.0f;
-        /*鍨墖鍘氬害*/
-        Float spacerThickness = 0.0f;
+        Float maxHeight = 1520.0f;
+        Float maxWid = 400.0f;
+        Float spacerThickness = 0.0f;//鍨墖鍘氬害*/
+
+
         Map<String, Object> thickness = flowCardMapper.getGlassThicknessByProdutionId(orderId, productionId);
 
         //鎴愬搧鐜荤拑鎬诲帤搴�
@@ -1084,7 +1095,8 @@
         Float glassThickness = Float.parseFloat(thickness.get("thickness").toString());
 
         //鑾峰彇姝ゅ伐绋嬪彿璁㈠崟鏄庣粏淇℃伅
-        List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId, productionId);
+        List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"scope",inLenMax,inLenMin,inShortMax,inShortMin,glassThickness);
+        List<OrderDetail> orderDetailsNotScope = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"notScope",inLenMax,inLenMin,inShortMax,inShortMin,glassThickness);
 
         //鏍规嵁鐜荤拑鍘氬害鍜屽灚鐗囧帤搴﹀綋鍓嶆灦瀛愭渶澶у彲鏀炬暟閲�
         Integer shelfMaxQuantityByThickness = (int) (shelfThickness / (glassTotalThickness + spacerThickness));
@@ -1106,59 +1118,72 @@
             );
             //褰撳墠璁㈠崟鏄庣粏鍓╀綑鏁伴噺
             if (shelfQuantity == 0) {
-                shelfQuantity = shelfQuantityByWeight;
+                shelfQuantity =Math.min( Math.min(shelfMaxQuantityByThickness,inMaxQuantity),shelfQuantityByWeight);
             }else if(shelfQuantity>0){//鏋跺瓙鍓╀綑鏁伴噺澶т簬0鏃讹紝鍒ゆ柇褰撳墠鏋跺瓙鍓╀綑閲嶉噺锛屾槸鍚︽敮鎸佹渶鏂板簭鍙风殑鐨勬垚鍝侀噸閲�
-                String FlowCardId = orderDetailList.get(orderDetailList.size() - 1).getFlowCardId();
+                String FlowCardId = orderDetailList.get(orderDetailList.size() - 1).getProcessId();
                 double flowCardWeight = 0.0;
                 for (OrderDetail orderDetail1 : orderDetailList) {
-                    if (orderDetail1.getFlowCardId().equals(FlowCardId)) {
+                    if (orderDetail1.getProcessId().equals(FlowCardId)) {
                         flowCardWeight += orderDetail1.getHeight()*orderDetail1.getQuantity()* orderDetail1.getWidth()* glassThickness* 2.5 / 1000000;
                     }
                 }
                 if(flowCardWeight>0){
                     flowCardWeight = inWeight - flowCardWeight;
-                    shelfQuantity = (int) (flowCardWeight /
+                    //鎸夌収褰撳墠娴佺▼鍗″墿浣欓噸閲忥紝璁$畻褰撳墠娴佺▼鍗″墿浣欐暟閲�
+                    int remainingQuantity = (int) (flowCardWeight /
                             (orderDetail.getHeight()
                                     * orderDetail.getWidth()
                                     * glassThickness
                                     * 2.5 / 1000000));
+                    shelfQuantity =Math.min(Math.min(Math.min(shelfQuantityByWeight, Math.min(inMaxQuantity, shelfMaxQuantityByThickness)),shelfQuantity),remainingQuantity);
                     if (shelfQuantity == 0) {
-                        shelfQuantity = shelfQuantityByWeight;
+                        shelfQuantity = Math.min(shelfQuantityByWeight, Math.min(inMaxQuantity, shelfMaxQuantityByThickness));
                         flowCardNo += 1;
                     }
                 }
 
             }
             //鍙栨渶灏忓��
-            Integer maxQuantity = 0;
+            //Integer maxQuantity = 0;
             while (orderDetail.getQuantity() > 0) {
                 OrderDetail newOrderDetail = new OrderDetail();
                 //褰撴寰幆涓紝褰撳墠鏋跺瓙鍓╀綑鏁伴噺涓�0鏃讹紝閲嶆柊璁$畻鏋跺瓙鍓╀綑鏁伴噺
                 if (shelfQuantity == 0) {
-                    shelfQuantity = shelfQuantityByWeight;
+                    shelfQuantity = Math.min(Math.min(shelfMaxQuantityByThickness,inMaxQuantity),shelfQuantityByWeight);
                 }
-                String processId = productionId + String.format("%05d", flowCardNo);
+                String processId = productionId + String.format("%03d", flowCardNo);
                 //鍙栨渶灏忓��
-               // maxQuantity = Math.min(shelfQuantity, Math.min(inMaxQuantity, shelfMaxQuantityByThickness));
-                maxQuantity = Math.min(shelfQuantity,  shelfMaxQuantityByThickness);
+                //maxQuantity = Math.min(shelfQuantity, Math.min(inMaxQuantity, shelfMaxQuantityByThickness));
+                //maxQuantity = Math.min(shelfQuantity,  shelfMaxQuantityByThickness);
 
-                /*System.out.println(shelfQuantity + "," + inMaxQuantity + "," + shelfMaxQuantityByThickness);
+                /*System.out.println("璁㈠崟搴忓彿锛�"+orderDetail.getOrderNumber());
+                System.out.println(shelfQuantity + ","  + "," + shelfMaxQuantityByThickness);
                 System.out.println(flowCardNo + "," + maxQuantity);
                 System.out.println("------");*/
+                if(shelfQuantity<=0){
+                    return false;
+                }
 
-                if (orderDetail.getQuantity() > maxQuantity) {
-                    newOrderDetail.setFlowCardId(processId);
-                    newOrderDetail.setQuantity(Long.valueOf(maxQuantity));
+                if (orderDetail.getQuantity() > shelfQuantity) {
+                    newOrderDetail.setProcessId(processId);
+                    newOrderDetail.setQuantity(Long.valueOf(shelfQuantity));
                     newOrderDetail.setHeight(orderDetail.getHeight());
                     newOrderDetail.setWidth(orderDetail.getWidth());
+                    newOrderDetail.setOrderNumber(orderDetail.getOrderNumber());
+                    newOrderDetail.setShape(orderDetail.getShape());
+                    newOrderDetail.setLandingSequence(flowCardNo);
                     orderDetailList.add(newOrderDetail);
-                    orderDetail.setQuantity(orderDetail.getQuantity() - maxQuantity);
+                    orderDetail.setQuantity(orderDetail.getQuantity() - shelfQuantity);
                     flowCardNo += 1;
+                    shelfQuantity = shelfQuantity - shelfQuantity;
                 } else {
-                    newOrderDetail.setFlowCardId(processId);
+                    newOrderDetail.setProcessId(processId);
                     newOrderDetail.setQuantity(orderDetail.getQuantity());
                     newOrderDetail.setHeight(orderDetail.getHeight());
                     newOrderDetail.setWidth(orderDetail.getWidth());
+                    newOrderDetail.setOrderNumber(orderDetail.getOrderNumber());
+                    newOrderDetail.setShape(orderDetail.getShape());
+                    newOrderDetail.setLandingSequence(flowCardNo);
                     orderDetailList.add(newOrderDetail);
                     //褰撳墠鏋跺瓙鍓╀綑鏁伴噺
                     shelfQuantity = shelfQuantity - Math.toIntExact(orderDetail.getQuantity());
@@ -1170,9 +1195,11 @@
             }
 
         }
-
-
-        return orderDetailList;
+        Map<String, Object> map = new HashMap<>();
+        Collections.reverse(orderDetailList);
+        map.put("orderDetailList", orderDetailList);
+        map.put("orderDetailsNotScope", orderDetailsNotScope);
+        return map;
     }
 
 

--
Gitblit v1.8.0