From 9e2f3b91a51c181cb4a0d247419c58daa3937b7b Mon Sep 17 00:00:00 2001
From: hdy <1105738590@qq.com>
Date: 星期六, 28 十二月 2024 14:16:38 +0800
Subject: [PATCH] 工单bom下发接口

---
 billion-main/src/main/java/com/billion/main/api/RestfulAPI.java |   88 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 87 insertions(+), 1 deletions(-)

diff --git a/billion-main/src/main/java/com/billion/main/api/RestfulAPI.java b/billion-main/src/main/java/com/billion/main/api/RestfulAPI.java
index 216cc01..2553861 100644
--- a/billion-main/src/main/java/com/billion/main/api/RestfulAPI.java
+++ b/billion-main/src/main/java/com/billion/main/api/RestfulAPI.java
@@ -1,17 +1,103 @@
 package com.billion.main.api;
 
+import cn.hutool.core.collection.CollUtil;
+import com.billion.main.api.domain.OutPutParameters;
+import com.billion.main.api.domain.OutPutParametersChild;
+import com.billion.main.api.domain.WorkOrdersInfo;
+import com.billion.main.api.domain.WorkOrdersInfoChild;
+import com.billion.main.bs.domain.BsBomChildInfo;
+import com.billion.main.bs.domain.BsBomInfo;
+import com.billion.main.bs.service.IBsBomChildInfoService;
+import com.billion.main.bs.service.IBsBomInfoService;
+import com.billion.main.om.domain.OmProductionOrderInfo;
+import com.billion.main.om.service.IOmProductionOrderInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
+import java.util.List;
+
+@RestController
+//@Component
+@RequestMapping("/dmMes")
 public class RestfulAPI {
 
+    @Autowired
+    private IOmProductionOrderInfoService OmProductionOrderInfoService;
+    @Autowired
+    private IBsBomInfoService bsBomInfoService;
+    @Autowired
+    private IBsBomChildInfoService bsBomChildInfoService;
+
+    public static final String getQualityData = "IP鍦板潃/CollectQualityData";
     /**
      * 鎺ユ敹宸ュ崟淇℃伅
      * 1銆佸伐鍘侻ES璋冪敤鎺ユ敹宸ュ崟鎺ュ彛锛屽皢宸ュ崟淇℃伅鍙戦�佺粰浜х嚎MES
      * 2銆佷骇绾縈ES灏嗘帴鏀跺埌鐨勫伐鍗曚俊鎭瓨鍏ュ埌宸ュ崟琛ㄥ拰BOM琛�
      */
     @PostMapping("/receiveWorkOrdersInfo")
-    public void receiveWorkOrdersInfo(@RequestBody Object object){
+    public  OutPutParameters receiveWorkOrdersInfo(@RequestBody WorkOrdersInfo workOrdersInfo) {
+        //淇濆瓨鍙傛暟
+        List<OmProductionOrderInfo> productionOrderInfoList = new ArrayList<>();
+        List<BsBomInfo> bomInfoList = new ArrayList<>();
+        List<BsBomChildInfo> bomChildInfoList = new ArrayList<>();
+        List<WorkOrdersInfoChild> data = workOrdersInfo.getData();
+        for (WorkOrdersInfoChild workOrdersInfoChild : data) {
+            OmProductionOrderInfo omProductionOrderInfo = new OmProductionOrderInfo();
+            BsBomInfo bsBomInfo = new BsBomInfo();
+            BsBomChildInfo bsBomChildInfo = new BsBomChildInfo();
+            //淇濆瓨宸ュ崟淇℃伅
+            omProductionOrderInfo.setWorkOrderNo(workOrdersInfo.getOrderNumber());
+            omProductionOrderInfo.setSalesOrderCode(workOrdersInfo.getBatchNumber());
+            omProductionOrderInfo.setProductCode(workOrdersInfo.getMaterialNumber());
+            omProductionOrderInfo.setEngineTye(workOrdersInfo.getEngineType());
+            omProductionOrderInfo.setEngineName(workOrdersInfo.getEngineName());
+            omProductionOrderInfo.setPlanQty(Long.valueOf(workOrdersInfo.getProduction_Plan()));
+            omProductionOrderInfo.setPlanStartTime(workOrdersInfo.getStartTime());
+            omProductionOrderInfo.setRemarks(workOrdersInfo.getDescription());
+            omProductionOrderInfo.setOrderStatus(workOrdersInfo.getState());
+            omProductionOrderInfo.setFlag(workOrdersInfo.getFLAG());
+            //淇濆瓨BOM涓昏〃淇℃伅
+            bsBomInfo.setBomCode(workOrdersInfo.getBomName());
+            bsBomInfo.setBomName(workOrdersInfo.getBomName());
+            bsBomInfo.setProductCode(workOrdersInfo.getMaterialNumber());
+            bsBomInfo.setProductName(workOrdersInfo.getMaterialNumber());
+            //淇濆瓨BOM瀛愯〃淇℃伅
+            bsBomChildInfo.setProductCode(workOrdersInfo.getMaterialNumber());
+            bsBomChildInfo.setProductName(workOrdersInfo.getMaterialNumber());
+            bsBomChildInfo.setBomCode(workOrdersInfo.getBomName());
+            bsBomChildInfo.setLocationCode(workOrdersInfoChild.getStationName());
+            bsBomChildInfo.setLocationName(workOrdersInfoChild.getStationName());
+            bsBomChildInfo.setMaterialCode(workOrdersInfoChild.getMaterial());
+            bsBomChildInfo.setCostQty(workOrdersInfoChild.getCount());
+            bsBomChildInfo.setChecked(workOrdersInfoChild.getChecked());
+            bsBomChildInfo.setMaterialName(workOrdersInfoChild.getMaterialName());
+            //
+        }
+        OutPutParameters outputParams = new OutPutParameters();
+        //鍒ゆ柇淇濆瓨鐨勪笁涓猯ist鏄惁涓虹┖
+        if (CollUtil.isNotEmpty(productionOrderInfoList) && CollUtil.isNotEmpty(bomInfoList) && CollUtil.isNotEmpty(bomChildInfoList)) {
+            //鎻掑叆鏁版嵁搴�
+            OmProductionOrderInfoService.insertBatch(productionOrderInfoList);
+            bsBomInfoService.insertBatch(bomInfoList);
+            bsBomChildInfoService.insertBatch(bomChildInfoList);
+            //鍑哄弬
+            OutPutParametersChild child = new OutPutParametersChild(workOrdersInfo.getMaterialNumber(), "S", "閲囬泦瀹屾垚");
+            outputParams.addData(child);
+            outputParams.toJson();
+        } else {
+            OutPutParametersChild child = new OutPutParametersChild(workOrdersInfo.getMaterialNumber(), "F", "閲囬泦澶辫触");
+            outputParams.addData(child);
+            outputParams.toJson();
+        }
 
+        return outputParams;
     }
+
+
+
 }
+

--
Gitblit v1.9.3