From 6edb8b29c0b4ab9dd81f824eb5f24fa17cf6fe13 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期三, 02 七月 2025 14:07:18 +0800
Subject: [PATCH] 可编辑标签打印添加订单总数字段

---
 north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java |  152 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 122 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 d8aef81..ccc6c70 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
@@ -7,16 +7,14 @@
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.example.erp.common.Constants;
 import com.example.erp.entity.pp.FlowCard;
-import com.example.erp.entity.sd.OrderDetail;
-import com.example.erp.entity.sd.OrderGlassDetail;
-import com.example.erp.entity.sd.OrderProcessDetail;
+import com.example.erp.entity.sd.*;
 import com.example.erp.entity.userInfo.Log;
 import com.example.erp.exception.ServiceException;
 import com.example.erp.mapper.pp.FlowCardMapper;
-import com.example.erp.mapper.sd.OrderGlassDetailMapper;
-import com.example.erp.mapper.sd.OrderProcessDetailMapper;
+import com.example.erp.mapper.sd.*;
 import com.example.erp.service.userInfo.LogService;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDate;
@@ -45,12 +43,21 @@
     OrderProcessDetailMapper orderProcessDetailMapper;
     final
     LogService logService;
+    private final ProductMapper productMapper;
+    private final ProductDetailMapper productDetailMapper;
 
-    public FlowCardService(FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, LogService logService) {
+    private final OrderDetailMapper orderDetailMapper;
+    private final OrderMapper orderMapper;
+
+    public FlowCardService(FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, LogService logService, ProductMapper productMapper, ProductDetailMapper productDetailMapper, OrderDetailMapper orderDetailMapper, OrderMapper orderMapper) {
         this.flowCardMapper = flowCardMapper;
         this.orderGlassDetailMapper = orderGlassDetailMapper;
         this.orderProcessDetailMapper = orderProcessDetailMapper;
         this.logService = logService;
+        this.productMapper = productMapper;
+        this.productDetailMapper = productDetailMapper;
+        this.orderDetailMapper = orderDetailMapper;
+        this.orderMapper = orderMapper;
     }
 
     //娴佺▼鍗$鐞嗘煡璇�
@@ -304,8 +311,11 @@
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//鏈�缁堢粨鏋�
         List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
         if (!flowCardList.isEmpty()) {
-            Set<String> processedProcessIds = new HashSet<>();  // 鐢ㄦ潵瀛樻斁宸插鐞嗚繃鐨� processId
+            Set<String> processedKeys = new HashSet<>();
             for (FlowCard flowCard : flowCardList) {
+                String processId = flowCard.getProcessId();
+                Integer orderNumber = flowCard.getOrderNumber();
+                String uniqueKey = processId + "|" + orderNumber;  // 鐢ㄧ壒娈婂瓧绗﹁繛鎺ラ槻姝㈠啿绐�
                 Map<String, Object> itemmap = new HashMap<>();
                 //娴佺▼鍗¤〃澶磋〃灏炬暟鎹�
                 //鏄惁浼犲叆鍚堝苟灞傛暟
@@ -313,7 +323,9 @@
                     //鏄惁鍖呭惈鍒囧壊
                     //boolean containsCutting = flowCard.getProcess().contains("鍒囧壊");
                     String processSub = flowCard.getProcess().substring(0, 2);
-                    if (processSub.equals("澶硅兌") || processSub.equals("涓┖")) {//宸ヨ壓鏄惁鍖呭惈澶硅兌涓┖
+                    //鑾峰彇宸ュ簭瀵瑰簲鐨勫埆绉�
+                    String processName = flowCardMapper.getProcessName(processSub);
+                    if (processName.equals("stepC") || processName.equals("stepD")) {//宸ヨ壓鏄惁鍖呭惈澶硅兌涓┖
                         itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
 
                         List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess());
@@ -321,11 +333,11 @@
                     } else {
                         if (merge.equals("1") && flowCard.getMerge().equals(1)) {
                             // 妫�鏌ユ槸鍚﹀凡缁忓鐞嗚繃璇� processId锛屽鏋滃鐞嗚繃鍒欒烦杩�
-                            if (processedProcessIds.contains(flowCard.getProcessId())) {
+                            if (processedKeys.contains(uniqueKey)) {
                                 continue;
                             }
                             // 灏嗚 processId 鍔犲叆宸插鐞嗛泦鍚�
-                            processedProcessIds.add(flowCard.getProcessId());
+                            processedKeys.add(uniqueKey);
                             itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
 
                             List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), flowCard.getProcess());
@@ -398,15 +410,20 @@
         }
         List<FlowCard> flowCardList = flowCardMapper.getFlowCardListPrintProject(printProject);
         if (!flowCardList.isEmpty()) {
-            Set<String> processedProcessIds = new HashSet<>();  // 鐢ㄦ潵瀛樻斁宸插鐞嗚繃鐨� processId
+            Set<String> processedKeys = new HashSet<>();
+
             for (FlowCard flowCard : flowCardList) {
                 Map<String, Object> itemmap = new HashMap<>();
 
-
+                String processId = flowCard.getProcessId();
+                Integer orderNumber = flowCard.getOrderNumber();
+                String uniqueKey = processId + "|" + orderNumber;  // 鐢ㄧ壒娈婂瓧绗﹁繛鎺ラ槻姝㈠啿绐�
                 //鏄惁鍖呭惈鍒囧壊
                 //boolean containsCutting = flowCard.getProcess().contains("鍒囧壊");
                 String processSub = flowCard.getProcess().substring(0, 2);
-                if (processSub.equals("澶硅兌") || processSub.equals("涓┖")) {
+                //鑾峰彇宸ュ簭瀵瑰簲鐨勫埆绉�
+                String processName = flowCardMapper.getProcessName(processSub);
+                if (processName.equals("stepC") || processName.equals("stepD")) {//宸ヨ壓鏄惁鍖呭惈澶硅兌涓┖
                     itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                     if (flowCard.getPatchState().equals(0)) {
                         List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess());
@@ -421,11 +438,11 @@
                     if (flowCard.getPatchState().equals(0)) {
                         if (merge.equals("1") && flowCard.getMerge().equals(1)) {
                             // 妫�鏌ユ槸鍚﹀凡缁忓鐞嗚繃璇� processId锛屽鏋滃鐞嗚繃鍒欒烦杩�
-                            if (processedProcessIds.contains(flowCard.getProcessId())) {
+                            if (processedKeys.contains(uniqueKey)) {
                                 continue;
                             }
                             // 灏嗚 processId 鍔犲叆宸插鐞嗛泦鍚�
-                            processedProcessIds.add(flowCard.getProcessId());
+                            processedKeys.add(uniqueKey);
                             itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
 
                             List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), flowCard.getProcess());
@@ -585,14 +602,15 @@
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//鏈�缁堢粨鏋�
         List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
         if (!flowCardList.isEmpty()) {
-            Set<String> processedProcessIds = new HashSet<>();  // 鐢ㄦ潵瀛樻斁宸插鐞嗚繃鐨� processId
 
+            Set<String> processedKeys = new HashSet<>();
             if (lableType != 2) {//鎴愬搧鏍囩
                 for (FlowCard flowCard : flowCardList) {
                     String processId = flowCard.getProcessId();
-
+                    Integer orderNumber = flowCard.getOrderNumber();
+                    String uniqueKey = processId + "|" + orderNumber;  // 鐢ㄧ壒娈婂瓧绗﹁繛鎺ラ槻姝㈠啿绐�
                     // 妫�鏌ユ槸鍚﹀凡缁忓鐞嗚繃璇� processId锛屽鏋滃鐞嗚繃鍒欒烦杩�
-                    if (processedProcessIds.contains(processId)) {
+                    if (processedKeys.contains(uniqueKey)) {
                         continue;
                     }
                     Map<String, Object> itemmap = new HashMap<>();
@@ -600,7 +618,7 @@
                     list.add(itemmap);
 
                     // 灏嗚 processId 鍔犲叆宸插鐞嗛泦鍚�
-                    processedProcessIds.add(processId);
+                    processedKeys.add(uniqueKey);
                 }
             } else {//灏忕墖鏍囩
                 for (FlowCard flowCard : flowCardList) {
@@ -620,14 +638,15 @@
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//鏈�缁堢粨鏋�
         List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
         if (!flowCardList.isEmpty()) {
-            Set<String> processedProcessIds = new HashSet<>();  // 鐢ㄦ潵瀛樻斁宸插鐞嗚繃鐨� processId
-
+            Set<String> processedKeys = new HashSet<>();
             if (lableType != 2) {//鎴愬搧鏍囩
                 for (FlowCard flowCard : flowCardList) {
                     String processId = flowCard.getProcessId();
+                    Integer orderNumber = flowCard.getOrderNumber();
+                    String uniqueKey = processId + "|" + orderNumber;  // 鐢ㄧ壒娈婂瓧绗﹁繛鎺ラ槻姝㈠啿绐�
 
                     // 妫�鏌ユ槸鍚﹀凡缁忓鐞嗚繃璇� processId锛屽鏋滃鐞嗚繃鍒欒烦杩�
-                    if (processedProcessIds.contains(processId)) {
+                    if (processedKeys.contains(uniqueKey)) {
                         continue;
                     }
                     Map<String, Object> itemmap = new HashMap<>();
@@ -635,7 +654,7 @@
                     list.add(itemmap);
 
                     // 灏嗚 processId 鍔犲叆宸插鐞嗛泦鍚�
-                    processedProcessIds.add(processId);
+                    processedKeys.add(uniqueKey);
                 }
             } else {//灏忕墖鏍囩
                 for (FlowCard flowCard : flowCardList) {
@@ -723,8 +742,10 @@
 
                 //宸ヨ壓娴佺▼
                 List<Map<String, Object>> processList = flowCardMapper.getProcessList(flowCard.getProcessId(), flowCard.getTechnologyNumber());
-
+                //宸ュ簭鍒楄〃
+                List<Map<String, Object>> processNameList = flowCardMapper.getProcessNameList();
                 itemmap.put("processList", processList);
+                itemmap.put("processNameList", processNameList);
                 //  itemmap.put("numberList", numberList);
                 list.add(itemmap);
 
@@ -814,25 +835,31 @@
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//鏈�缁堢粨鏋�
         List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
         if (!flowCardList.isEmpty()) {
-            Set<String> processedProcessIds = new HashSet<>();  // 鐢ㄦ潵瀛樻斁宸插鐞嗚繃鐨� processId
+            Set<String> processedKeys = new HashSet<>();
 
             if (lableType != 2) {//鎴愬搧鏍囩
                 for (FlowCard flowCard : flowCardList) {
                     String orderId = flowCard.getOrderId();
                     String processId = flowCard.getProcessId();
                     String orderNumber = flowCard.getOrderNumber().toString();
+                    String uniqueKey = processId + "|" + orderNumber;  // 鐢ㄧ壒娈婂瓧绗﹁繛鎺ラ槻姝㈠啿绐�
                        if (processId!=null){
                            // 妫�鏌ユ槸鍚﹀凡缁忓鐞嗚繃璇� processId锛屽鏋滃鐞嗚繃鍒欒烦杩�
-                           if (processedProcessIds.contains(processId) && processedProcessIds.contains(orderNumber)) {
+                           if (processedKeys.contains(uniqueKey)) {
                                continue;
                            }
                            Map<String, Object> itemmap = new HashMap<>();
-                           itemmap.put("data", flowCardMapper.getPrintCustomDataDetails(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity()));
+                           Integer sumQuantity = flowCardMapper.getSumQuantity(flowCard.getOrderId());
+                           List<Map<String, Object>> details = flowCardMapper.getPrintCustomDataDetails(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity());
+
+                           for (Map<String, Object> detail : details) {
+                               detail.put("sumQuantity", sumQuantity);
+                           }
+                           itemmap.put("data", details);
                            list.add(itemmap);
 
                            // 灏嗚 processId 鍔犲叆宸插鐞嗛泦鍚�
-                           processedProcessIds.add(processId);
-                           processedProcessIds.add(orderNumber);
+                           processedKeys.add(uniqueKey);
                        } else{
 
                            Map<String, Object> itemmap = new HashMap<>();
@@ -943,6 +970,66 @@
         return flowCardList;
     }
 
+    public Map<String,Object> getProcessCardAll(Map<String, String> processCards) {
+        String processCard = processCards.get("processCard");
+        if (!processCard.contains("/")) {
+            throw new ServiceException(Constants.Code_600, "閿欒鐨勬祦绋嬪崱鍙凤紝璇锋鏌�!");
+        }
+
+        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])
+                        .in("technology_number", result)
+        );
+        for (FlowCard flowCard : flowCardList) {
+            flowCard.setOrderGlassDetail(
+                    orderGlassDetailMapper.selectOne(
+                            new QueryWrapper<OrderGlassDetail>()
+                                    .eq("order_id", flowCard.getOrderId())
+                                    .eq("order_number", flowCard.getOrderNumber())
+                                    .eq("technology_number", flowCard.getTechnologyNumber())
+                    )
+            );
+            String str = flowCard.getOrderGlassDetail().getGlassChild();
+            String delimiter = "mm";
+            int index = str.indexOf(delimiter);
+            Integer subString = Integer.valueOf(str.substring(0, index).trim());
+            flowCard.getOrderGlassDetail().setThickness(subString);
+        }
+        OrderDetail orderDetail = orderDetailMapper
+                .selectOne(new QueryWrapper<OrderDetail>()
+                        .eq("order_id", flowCardList.get(0).getOrderId())
+                        .eq("order_number", flowCardList.get(0).getOrderNumber())
+        );
+        Product product = productMapper
+                .selectOne(new QueryWrapper<Product>()
+                        .eq("id",orderDetail.getProductId()));
+        product.setProductDetails(productDetailMapper
+                .selectList(new QueryWrapper<ProductDetail>()
+                        .eq("prod_id",orderDetail.getProductId())
+                )
+        );
+
+        Order order = orderMapper.
+                selectOne(new QueryWrapper<Order>()
+                        .eq("order_id", flowCardList.get(0).getOrderId()));
+        order.setMoney(null);
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("product",product);
+        map.put("flowCard",flowCardList);
+        map.put("order",order);
+
+
+        return map;
+    }
+
+
     public Boolean checkboxDeleteSv(Map<String, Object> object) {
         String userName = "";
         if (object.get("userName") != null) {
@@ -1002,7 +1089,6 @@
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//鏈�缁堢粨鏋�
         List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
         if (!flowCardList.isEmpty()) {
-            Set<String> processedProcessIds = new HashSet<>();  // 鐢ㄦ潵瀛樻斁宸插鐞嗚繃鐨� processId
             for (FlowCard flowCard : flowCardList) {
                 Map<String, Object> itemmap = new HashMap<>();
                 //鏄惁鏄伐绋嬫槑缁嗘墦鍗�
@@ -1244,6 +1330,12 @@
 
         }
     }
+
+
+    public List exportDateProcessSv(Map<String, Object> dates) {
+        List<LocalDate> date= (List<LocalDate>) dates.get("date");
+        return flowCardMapper.exportDateProcessMp(date);
+    }
 }
 
 

--
Gitblit v1.8.0