From f0968dbdfd956ae035cbc994ccb4eb374b6c8074 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期三, 05 三月 2025 16:47:39 +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 |  141 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 98 insertions(+), 43 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 c41cd09..f06dda0 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
@@ -219,7 +219,7 @@
         return map;
     }
 
-    public Object selectPrintFlowCardSv(Date selectTime1, Date selectTime2, String orderId, String project, String userId, FlowCard flowCard) {
+    public Object selectPrintFlowCardSv(Date selectTime1, Date selectTime2, String orderId, String project, String userId, Integer state, FlowCard flowCard) {
         if ("null".equals(orderId)) {
             orderId = "";
         }
@@ -227,7 +227,7 @@
             project = "";
         }
         Map<String, Object> map = new HashMap<>();
-        map.put("data", flowCardMapper.selectPrintFlowCardMp(selectTime1, selectTime2, orderId, project, flowCard));
+        map.put("data", flowCardMapper.selectPrintFlowCardMp(selectTime1, selectTime2, orderId, project,state, flowCard));
         String roleId = flowCardMapper.selectUserMp(userId);
         map.put("user", roleId);
         return map;
@@ -776,10 +776,12 @@
         if (!flowCardList.isEmpty()) {
             for (FlowCard flowCard : flowCardList) {
                 Map<String, Object> itemmap = new HashMap<>();
-                if (type == 1) {
+                if (type == 1) {//鏄庣粏鎵撳嵃
                     itemmap.put("detail", flowCardMapper.selectPrintDetailsMp(flowCard.getOrderId()));
-                } else if (type == 2) {
+                } else if (type == 2) {//鏄庣粏鍒嗘灦鎵撳嵃
                     itemmap.put("detail", flowCardMapper.selectPrintDetailsMp1(flowCard.getOrderId()));
+                }else if (type == 3) {//璁㈠崟鎵撳嵃
+                    itemmap.put("detail", flowCardMapper.selectPrintDetailsMp2(flowCard.getOrderId()));
                 }
 
                 list.add(itemmap);
@@ -799,20 +801,28 @@
 
             if (lableType != 2) {//鎴愬搧鏍囩
                 for (FlowCard flowCard : flowCardList) {
+                    String orderId = flowCard.getOrderId();
                     String processId = flowCard.getProcessId();
                     String orderNumber = flowCard.getOrderNumber().toString();
+                       if (processId!=null){
+                           // 妫�鏌ユ槸鍚﹀凡缁忓鐞嗚繃璇� processId锛屽鏋滃鐞嗚繃鍒欒烦杩�
+                           if (processedProcessIds.contains(processId) && processedProcessIds.contains(orderNumber)) {
+                               continue;
+                           }
+                           Map<String, Object> itemmap = new HashMap<>();
+                           itemmap.put("data", flowCardMapper.getPrintCustomDataDetails(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity()));
+                           list.add(itemmap);
 
-                    // 妫�鏌ユ槸鍚﹀凡缁忓鐞嗚繃璇� processId锛屽鏋滃鐞嗚繃鍒欒烦杩�
-                    if (processedProcessIds.contains(processId) && processedProcessIds.contains(orderNumber)) {
-                        continue;
-                    }
-                    Map<String, Object> itemmap = new HashMap<>();
-                    itemmap.put("data", flowCardMapper.getPrintCustomDataDetails(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity()));
-                    list.add(itemmap);
+                           // 灏嗚 processId 鍔犲叆宸插鐞嗛泦鍚�
+                           processedProcessIds.add(processId);
+                           processedProcessIds.add(orderNumber);
+                       } else{
 
-                    // 灏嗚 processId 鍔犲叆宸插鐞嗛泦鍚�
-                    processedProcessIds.add(processId);
-                    processedProcessIds.add(orderNumber);
+                           Map<String, Object> itemmap = new HashMap<>();
+                           itemmap.put("data", flowCardMapper.getPrintOrderDataDetails(flowCard.getOrderId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity()));
+                           list.add(itemmap);
+                       }
+
                 }
             } else {//灏忕墖鏍囩
                 for (FlowCard flowCard : flowCardList) {
@@ -1052,27 +1062,37 @@
     }
 
     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());
-        */
+        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 = 100.0f;
+        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);
 
+        //鎴愬搧鐜荤拑鎬诲帤搴�
         Float glassTotalThickness = Float.parseFloat(thickness.get("totalThickness").toString());
+        //鎴愬搧鐜荤拑鍘氬害
         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);
+        List<OrderDetail> orderDetailsNotScope = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"notScope",inLenMax,inLenMin,inShortMax,inShortMin);
 
         //鏍规嵁鐜荤拑鍘氬害鍜屽灚鐗囧帤搴﹀綋鍓嶆灦瀛愭渶澶у彲鏀炬暟閲�
         Integer shelfMaxQuantityByThickness = (int) (shelfThickness / (glassTotalThickness + spacerThickness));
@@ -1094,58 +1114,72 @@
             );
             //褰撳墠璁㈠崟鏄庣粏鍓╀綑鏁伴噺
             if (shelfQuantity == 0) {
-                shelfQuantity = shelfQuantityByWeight;
-            }else if(shelfQuantity>0){
-                String FlowCardId = orderDetailList.get(orderDetailList.size() - 1).getFlowCardId();
+                shelfQuantity =Math.min( Math.min(shelfMaxQuantityByThickness,inMaxQuantity),shelfQuantityByWeight);
+            }else if(shelfQuantity>0){//鏋跺瓙鍓╀綑鏁伴噺澶т簬0鏃讹紝鍒ゆ柇褰撳墠鏋跺瓙鍓╀綑閲嶉噺锛屾槸鍚︽敮鎸佹渶鏂板簭鍙风殑鐨勬垚鍝侀噸閲�
+                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){
-                    //System.out.println(inWeight+","+flowCardWeight);
                     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));
-                /*System.out.println(shelfQuantity + "," + inMaxQuantity + "," + shelfMaxQuantityByThickness);
+                //maxQuantity = Math.min(shelfQuantity, Math.min(inMaxQuantity, shelfMaxQuantityByThickness));
+                //maxQuantity = Math.min(shelfQuantity,  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());
@@ -1157,12 +1191,33 @@
             }
 
         }
-
-
-        return orderDetailList;
+        Map<String, Object> map = new HashMap<>();
+        Collections.reverse(orderDetailList);
+        map.put("orderDetailList", orderDetailList);
+        map.put("orderDetailsNotScope", orderDetailsNotScope);
+        return map;
     }
 
 
+    public Boolean revokeComposingSv(Map<String, Object> object) {
+        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("composing")), FlowCard.class);
+        if (!flowCardList.isEmpty()) {
+            for (FlowCard flowCard : flowCardList) {
+                //鑾峰彇娌℃湁宸ョ▼鍙风殑鏉℃暟锛屽凡鐢熸垚宸ョ▼鍙蜂笉鑳芥挙鍥�
+              Integer count =  flowCardMapper.selectProjectNo(flowCard.getProcessId());
+              if (count == 0){
+                  flowCardMapper.revokeComposing(flowCard.getProcessId());
+              } else {
+                  return false;
+              }
+
+            }
+            return true;
+        } else {
+            return false;
+
+        }
+    }
 }
 
 

--
Gitblit v1.8.0