From ec4d06c37f948a24f5313b60b4d27327d6975bdc Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期日, 07 七月 2024 18:01:34 +0800
Subject: [PATCH] 修改工程打印以及发货单创建的运费功能添加

---
 north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java |  303 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 265 insertions(+), 38 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 aba88e0..6dbc32a 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
@@ -4,30 +4,50 @@
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.example.erp.entity.pp.FlowCard;
-import com.example.erp.entity.sd.Order;
-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.mapper.pp.FlowCardMapper;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.example.erp.mapper.sd.OrderGlassDetailMapper;
+import com.example.erp.mapper.sd.OrderProcessDetailMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import org.springframework.stereotype.Service;
 
-import java.sql.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import java.io.IOException;
+
+
+import java.sql.Date;
+import java.util.*;
+
+import static com.example.erp.service.sd.OrderService.getOrderProcessDetails;
 
 @Service
 @DS("pp")
 public class FlowCardService {
-    @Autowired
+    final
     FlowCardMapper flowCardMapper;
+    final
+    OrderGlassDetailMapper orderGlassDetailMapper;
+    final
+    OrderProcessDetailMapper orderProcessDetailMapper;
+
+    public FlowCardService(FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper) {
+        this.flowCardMapper = flowCardMapper;
+        this.orderGlassDetailMapper = orderGlassDetailMapper;
+        this.orderProcessDetailMapper = orderProcessDetailMapper;
+    }
 
     //娴佺▼鍗$鐞嗘煡璇�
-    public Map<String, Object> selectProcessCard(Date selectTime1, Date selectTime2, FlowCard flowCard) {
+    public Map<String, Object> selectProcessCard(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, FlowCard flowCard) {
+        Integer offset = (pageNum - 1) * pageSize;
         Map<String, Object> map = new HashMap<>();
-        //System.out.println(flowCardMapper.selectFlowCard( selectTime1,selectTime2, flowCard));
-        map.put("data", flowCardMapper.selectFlowCard(selectTime1, selectTime2, flowCard));
+        map.put("data", flowCardMapper.selectFlowCard(offset, pageSize, selectTime1, selectTime2, flowCard));
+        map.put("total", flowCardMapper.getPageTotal(offset, pageSize, selectTime1, selectTime2, flowCard));
         return map;
     }
 
@@ -39,23 +59,34 @@
     }
 
     //鍒嗘灦鏄庣粏鏌ヨ
-    public Map<String, Object> DetailsSelectSv(String orderId, FlowCard flowCard) {
+    public Map<String, Object> detailsSelectSv(String orderId, FlowCard flowCard) {
         Map<String, Object> map = new HashMap<>();
-        map.put("data", flowCardMapper.DetailsSelectMp(orderId, flowCard));
+        map.put("data", flowCardMapper.detailsSelectMp(orderId, flowCard));
         return map;
     }
 
     //鍒犻櫎娴佺▼鍗�
-    public Boolean DeleteFlowCardSv(String orderId, String processId) {
+    public Boolean deleteFlowCardSv(String orderId, String processId) {
         if (!orderId.isEmpty() && !processId.isEmpty()) {
-            Integer count = flowCardMapper.ReportingWorkCount(processId);
+            //鍒ゆ柇璇ユ祦绋嬪崱鏄惁鎶ュ伐
+            Integer count = flowCardMapper.reportingWorkCount(processId);
             if (count == 0) {
-                //淇敼璁㈠崟琛ㄥ垎鏋剁姸鎬佷负1,鏈叏閮ㄥ垎鏋跺畬鎴�
-                flowCardMapper.UpdateProcessingCard(orderId, 1);
+
                 //淇敼鍒嗘灦鐘舵��
-                flowCardMapper.UpdateDeleteState(orderId, processId);
+                flowCardMapper.updateDeleteState(orderId, processId);
+                //鍒犻櫎鎶ュ伐娴佺▼鏄庣粏琛ㄦ暟鎹�
+                flowCardMapper.deleteReportingWork(processId);
                 //鍒犻櫎鍒嗘灦鏄庣粏
-                flowCardMapper.DeleteFlowCardMp(orderId, processId);
+                flowCardMapper.deleteFlowCardMp(orderId, processId);
+                //鍒ゆ柇璇ヨ鍗曟祦绋嬪崱鏄惁鍏ㄩ儴鍒犻櫎
+                Integer flowNumber = flowCardMapper.selectFlowCardCount(orderId);
+                if (flowNumber == 0) {
+                    //淇敼璁㈠崟琛ㄥ垎鏋剁姸鎬佷负0,鍏ㄩ儴鍒犻櫎
+                    flowCardMapper.updateProcessingCard(orderId, 0);
+                } else {
+                    //淇敼璁㈠崟琛ㄥ垎鏋剁姸鎬佷负1,鍒犻櫎閮ㄥ垎
+                    flowCardMapper.updateProcessingCard(orderId, 1);
+                }
                 return true;
             } else {
                 return false;
@@ -67,23 +98,21 @@
     }
 
     //鍒嗘灦鏂板鏄庣粏鏌ヨ
-    public Map<String, Object> SelectNoCardSv(String orderId, String productionId, FlowCard flowCard) {
+    public Map<String, Object> selectNoCardSv(String orderId, String productionId, FlowCard flowCard) {
         Map<String, Object> map = new HashMap<>();
-        map.put("data", flowCardMapper.SelectNoCardMp(orderId, productionId, flowCard));
+        map.put("data", flowCardMapper.selectNoCardMp(orderId, productionId, flowCard));
         return map;
     }
 
 
     //淇敼鎺掔増鐘舵��
-    public Boolean UpdateLayoutStatusSv(String processId) {
+    public Boolean updateLayoutStatusSv(String processId, Integer state) {
 
         if (!processId.isEmpty()) {
-            Integer Status = flowCardMapper.SelectLayoutStatus(processId);
-            if (Status == 1) {
-                flowCardMapper.UpdateLayoutStatusMp(processId);
-            } else {
-                return false;
-            }
+//            Integer Status = flowCardMapper.selectLayoutStatus(processId);
+
+            flowCardMapper.updateLayoutStatusMp(processId, state);
+
 
             return true;
         } else {
@@ -92,7 +121,7 @@
     }
 
     //淇濆瓨娴佺▼鍗℃暟鎹�
-    public Boolean AddFlowCardSv(Map<String, Object> object) {
+    public Boolean addFlowCardSv(Map<String, Object> object) {
         String userName = "";
         if (object.get("userName") != null) {
             userName = object.get("userName").toString();
@@ -107,34 +136,49 @@
         if (!FlowCardList.isEmpty()) {
             for (FlowCard flowCard : FlowCardList) {
                 //鏌ヨ姣忎釜搴忓彿鐨勫眰鏁�
-                Integer layer = flowCardMapper.SelectLayer(productionId, flowCard.getOrderNumber());
+                Integer layer = flowCardMapper.selectLayer(productionId, flowCard.getOrderNumber());
                 //娣诲姞娴佺▼鍗℃暟鎹�
-                flowCardMapper.AddFlowCardMp(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getLandingSequence(), flowCard.getQuantity(), productionId, userName,layer);
+                flowCardMapper.addFlowCardMp(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getLandingSequence(), flowCard.getQuantity(), productionId, userName, layer);
                 //淇敼鍒嗘灦鐘舵�侊紝灏嗙姸鎬佹敼涓�1
-                flowCardMapper.UpdateFlowState(productionId, flowCard.getOrderNumber());
+                flowCardMapper.updateFlowState(productionId, flowCard.getOrderNumber());
                 //鏌ヨ璇ヨ鍗曟湭鍒嗘灦鏁伴噺
-                Integer FlowCount = flowCardMapper.SelectFlowCount(productionId);
+                Integer FlowCount = flowCardMapper.selectFlowCount(productionId);
                 if (FlowCount == 0) {
                     //淇敼璁㈠崟琛ㄥ垎鏋剁姸鎬佷负2
-                    flowCardMapper.UpdateProcessingCard(productionId, 2);
+                    flowCardMapper.updateProcessingCard(productionId, 2);
                 } else {
                     //淇敼璁㈠崟琛ㄥ垎鏋剁姸鎬佷负1,鏈叏閮ㄥ垎鏋跺畬鎴�
-                    flowCardMapper.UpdateProcessingCard(productionId, 1);
+                    flowCardMapper.updateProcessingCard(productionId, 1);
                 }
+                //鏌ヨ璁㈠崟灏忕墖琛ㄨ幏鍙栧伐鑹轰紶鍏ュ皬鐗囧伐鑹鸿〃
+                List<OrderGlassDetail> orderGlassDetailList =
+                        orderGlassDetailMapper.selectList(
+                                new QueryWrapper<OrderGlassDetail>()
+                                        .eq("order_id", flowCard.getProcessId().substring(0, 10))
+                                        .eq("order_number", flowCard.getOrderNumber())
+                        );
+                List<OrderProcessDetail> orderProcessDetailList = getOrderProcessDetails(orderGlassDetailList);
+                orderProcessDetailList.forEach(
+                        orderGlassDetail -> orderGlassDetail.setProcessId(flowCard.getProcessId()));
+
+
+                //璧嬪�艰鍗曞伐鑹鸿〃
+                orderProcessDetailMapper.insertOrderProcessDetail(orderProcessDetailList);
             }
+
             return true;
         } else {
             return false;
         }
     }
 
-    public Map<String, Object> SelectSchedulingSv(String selectTime1, String selectTime2, String orderId,String processes, Integer state, FlowCard flowCard) {
+    public Map<String, Object> selectSchedulingSv(String selectTime1, String selectTime2, String orderId, String processes, Integer state, FlowCard flowCard) {
         Map<String, Object> map = new HashMap<>();
-        if (state==2){//宸叉帓浜�
-            map.put("data", flowCardMapper.SelectOkSchedulingMp(selectTime1, selectTime2,orderId,processes, flowCard));
+        if (state == 2) {//宸叉帓浜�
+            map.put("data", flowCardMapper.selectOkSchedulingMp(selectTime1, selectTime2, orderId, processes, flowCard));
 
-        }else if (state==1){//鏈帓浜�
-            map.put("data", flowCardMapper.SelectNoSchedulingMp(selectTime1, selectTime2,orderId,processes, flowCard));
+        } else if (state == 1) {//鏈帓浜�
+            map.put("data", flowCardMapper.selectNoSchedulingMp(selectTime1, selectTime2, orderId, processes, flowCard));
 
         }
 
@@ -148,4 +192,187 @@
         map.put("data", flowCardMapper.selectLastSchedulingMp(selectTime1, selectTime2, flowCard));
         return map;
     }
+
+    public Object flowCardDetailSv(String processId, FlowCard flowCard) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", flowCardMapper.flowCardDetailMp(processId, flowCard));
+        return map;
+    }
+
+    public Object selectPrintFlowCardSv(Date selectTime1, Date selectTime2, String orderId, String project, FlowCard flowCard) {
+        if ("null".equals(orderId)) {
+            orderId = "";
+        }
+        if ("null".equals(project)) {
+            project = "";
+        }
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", flowCardMapper.selectPrintFlowCardMp(selectTime1, selectTime2, orderId, project, flowCard));
+        return map;
+    }
+
+    public Object selectPrintFlowCard(Date selectTime1, Date selectTime2) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", flowCardMapper.selectPrintFlowCard(selectTime1, selectTime2));
+        return map;
+    }
+
+    public Object selectPrintSv(String orderId, FlowCard flowCard) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", flowCardMapper.selectPrintMp(orderId, flowCard));
+        map.put("type", flowCardMapper.selectType());
+        return map;
+    }
+
+    private static Map<String, Object> parseJson(String json) {
+        ObjectMapper objectMapper = new ObjectMapper();
+        try {
+            return objectMapper.readValue(json, new TypeReference<Map<String, Object>>() {});
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+    public Map<String, Object> getSelectPrintingSv(Map<String, Object> object) {
+        Map<String, Object> map = new HashMap<>();
+        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()) {
+            for (FlowCard flowCard : flowCardList) {
+                Map<String, Object> itemmap = new HashMap<>();
+                //娴佺▼鍗¤〃澶磋〃灏炬暟鎹�
+                itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), flowCard.getTechnologyNumber()));
+
+
+                //娴佺▼鍗℃槑缁嗘暟鎹�
+                List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber());
+               // List<Map<String, Object>> numberList = flowCardMapper.getGlassNumber(flowCard.getTechnologyNumber(),flowCard.getProcessId());
+                //宸ヨ壓娴佺▼
+                List<Map<String, Object>> processList = flowCardMapper.getProcessList(flowCard.getProcessId(), flowCard.getTechnologyNumber());
+                itemmap.put("detailList", detailList);
+                itemmap.put("processList", processList);
+              //  itemmap.put("numberList", numberList);
+                list.add(itemmap);
+
+            }
+        }
+        map.put("data", list);
+        return map;
+    }
+
+    public Boolean updateComposingSv(Map<String, Object> object) {
+        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("composing")), FlowCard.class);
+        if (!flowCardList.isEmpty()) {
+            for (FlowCard flowCard : flowCardList) {
+                flowCardMapper.updateComposing(flowCard.getProcessId());
+            }
+            return true;
+        }
+        else {
+            return false;
+
+        }
+    }
+
+    public Map<String, Object> getSelectPrintLabelSv(String projectNo) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", flowCardMapper.getPrintLabel(projectNo));
+        return map;
+    }
+
+    public Map<String, Object> getSelectPrintLabelSv1(Map<String, Object> object) {
+        Map<String, Object> map = new HashMap<>();
+
+            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()) {
+                for (FlowCard flowCard : flowCardList) {
+                    // Integer count=flowCardMapper.getPrintLabelCount(flowCard.getProcessId(), flowCard.getTechnologyNumber());
+                    Map<String, Object> itemmap = new HashMap<>();
+                    // for (int i = 0; i < count; i++) {
+                    itemmap.put("data", flowCardMapper.getPrintLabel1(flowCard.getProcessId(), flowCard.getTechnologyNumber()));
+                    list.add(itemmap);
+                    //}
+
+                }
+            }
+            map.put("data", list);
+
+        return map;
+    }
+
+    public Map<String, Object> printFlowCardDetailsSv(String processId, String technologyNumber, FlowCard flowCard) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", flowCardMapper.printFlowCardDetailsMp(processId, technologyNumber, flowCard));
+        return map;
+    }
+
+    public Boolean printSortSv(Map<String, Object> object) {
+        List<FlowCard> FlowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("flowCard")), FlowCard.class);
+        if (!FlowCardList.isEmpty()) {
+            for (FlowCard flowCard : FlowCardList) {
+                flowCardMapper.printSortMp(flowCard.getProcessId(),flowCard.getOrderNumber(),flowCard.getTechnologyNumber(),flowCard.getSort());
+            }
+        }
+        return true;
+    }
+
+
+    public Map<String, Object> getSelectPrintCustomLabelSv(String type, Integer lableType, Map<String, Object> object) {
+        Map<String, Object> map = new HashMap<>();
+        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
+
+            if (lableType != 2){
+                for (FlowCard flowCard : flowCardList) {
+                    String processId = flowCard.getProcessId();
+
+                    // 妫�鏌ユ槸鍚﹀凡缁忓鐞嗚繃璇� processId锛屽鏋滃鐞嗚繃鍒欒烦杩�
+                    if (processedProcessIds.contains(processId)) {
+                        continue;
+                    }
+                    Map<String, Object> itemmap = new HashMap<>();
+                    itemmap.put("data", flowCardMapper.getPrintCustomData(flowCard.getProcessId(),flowCard.getTechnologyNumber()));
+                    list.add(itemmap);
+
+                    // 灏嗚 processId 鍔犲叆宸插鐞嗛泦鍚�
+                    processedProcessIds.add(processId);
+                }
+            }
+            else{
+                for (FlowCard flowCard : flowCardList) {
+                    Map<String, Object> itemmap = new HashMap<>();
+                    itemmap.put("data", flowCardMapper.getPrintCustomData(flowCard.getProcessId(),flowCard.getTechnologyNumber()));
+                    list.add(itemmap);
+                }
+            }
+        }
+        map.put("data", list);
+        map.put("title", flowCardMapper.getPrintTitle(type));
+        return map;
+    }
+
+    public Object getCustomLabelDetailSv(String name, String form, String id, FlowCard flowCard) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", flowCardMapper.getCustomLabelDetailMp(name, form,id, flowCard));
+        return map;
+    }
+
+    public Boolean updatePrintStateSv(Integer printState, Map<String, Object> object) {
+        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
+        if (!flowCardList.isEmpty()) {
+            for (FlowCard flowCard : flowCardList) {
+                // 鏇存柊鎵撳嵃鐘舵��
+                flowCardMapper.updatePrintStateMp(printState,flowCard.getProcessId(),flowCard.getTechnologyNumber());
+            }
+            return true;
+        } else {
+            return false;
+        }
+
+    }
 }
+
+

--
Gitblit v1.8.0