From 220f7b818bb9399391830fbbb9fb2028a21b938f Mon Sep 17 00:00:00 2001
From: yyt <306727702@qq.com>
Date: 星期三, 21 二月 2024 00:23:34 +0800
Subject: [PATCH] 批量数据采集方法更新

---
 jcdm-main/src/main/java/com/jcdm/main/om/productionOrde/controller/OmProductionOrdeInfoController.java |   67 +++++++++++++++++++++++++--------
 1 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/om/productionOrde/controller/OmProductionOrdeInfoController.java b/jcdm-main/src/main/java/com/jcdm/main/om/productionOrde/controller/OmProductionOrdeInfoController.java
index 9fd7ff5..4e82039 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/om/productionOrde/controller/OmProductionOrdeInfoController.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/om/productionOrde/controller/OmProductionOrdeInfoController.java
@@ -7,6 +7,8 @@
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.jcdm.main.bs.modelNumber.domain.BsModelNumber;
+import com.jcdm.main.bs.modelNumber.service.IBsModelNumberService;
 import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
 import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
 import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
@@ -47,6 +49,9 @@
 
     @Autowired
     private IBsOrderSchedulingService bsOrderSchedulingService;
+
+    @Autowired
+    private IBsModelNumberService bsModelNumberService;
 
     /**
      * 鏌ヨ鐢熶骇宸ュ崟鍒楄〃
@@ -95,7 +100,7 @@
     }
 
     /**
-     * 鏂板鐢熶骇宸ュ崟
+     * 鐢熸垚鎸夐挳
      */
     @PostMapping("/orderSchedulingForBoxCode")
     public AjaxResult addOrderSchedulingForBoxCode(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
@@ -106,24 +111,43 @@
         DateTimeFormatter formatter= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         //灏嗘椂闂磋浆鍖栦负瀵瑰簲鏍煎紡鐨勫瓧绗︿覆
         String fomateDate=date.format(formatter).toString();
+
+
         Integer startCode = Integer.parseInt(omProductionOrdeInfo.getStartCode());//寮�濮嬬紪鍙�
         Integer planQty = Math.toIntExact(omProductionOrdeInfo.getPlanQty());//璁″垝鏁伴噺
         String dateTimeRule = omProductionOrdeInfo.getDateTimeRule();
 
-        for(int i=0;i<planQty;i++){
-            BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
-            bsOrderScheduling.setOrderNo(omProductionOrdeInfo.getWorkOrderNo());
-            bsOrderScheduling.setModel(omProductionOrdeInfo.getTypeZ());
-            bsOrderScheduling.setEngineNo(omProductionOrdeInfo.getTypeZ() + " "+dateTimeRule+ StringUtils.leftPad(String.valueOf(startCode),3, "0"));
-            bsOrderScheduling.setProductionStatus("1");
-            bsOrderScheduling.setOperator(getUserName());
-            bsOrderScheduling.setOperateTime(fomateDate);
-            bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling);
-            startCode ++;
-        }
+        String engineNo = "";
+        if(planQty>0) {
+            for (int i = 0; i < planQty; i++) {
+                engineNo = omProductionOrdeInfo.getTypeZ() + " " + dateTimeRule + StringUtils.leftPad(String.valueOf(startCode), 3, "0");
+                BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
+                bsOrderScheduling.setOrderNo(omProductionOrdeInfo.getWorkOrderNo());
+                bsOrderScheduling.setModel(omProductionOrdeInfo.getTypeZ());
+                bsOrderScheduling.setEngineNo(engineNo);
+                bsOrderScheduling.setProductionStatus("1");
+                bsOrderScheduling.setOperator(getUserName());
+                bsOrderScheduling.setOperateTime(fomateDate);
+                bsOrderScheduling.setProductType(omProductionOrdeInfo.getTypeL());//浜у搧绫诲瀷
+                bsOrderScheduling.setWhetherOrPrint("0");
+                bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling);
+                startCode++;
+            }
 
-        omProductionOrdeInfo.setOrderStatus("2");//鏇存柊宸ュ崟鐘舵��
+            //鏂板鏈哄瀷搴忓彿
+            BsModelNumber bsModelNumber = new BsModelNumber();
+            bsModelNumber.setModel(omProductionOrdeInfo.getTypeZ());
+            bsModelNumber.setModelDate(dateTimeRule);
+            bsModelNumber.setMaxnumValue((startCode - 1) + "");
+            bsModelNumber.setSaveTime(fomateDate);
+            bsModelNumber.setLastNumber((startCode - 1) + "");
+            bsModelNumberService.insertBsModelNumber(bsModelNumber);
+        }
+        //鏇存柊宸ュ崟鐘舵��
+        omProductionOrdeInfo.setOrderStatus("2");
         return toAjax(omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo));
+
+
     }
 
     /**
@@ -159,12 +183,23 @@
     }
 
     /**
-     * table鍒椾笂绉讳笅绉�
+     * 鎺ユ敹宸ュ崟
      */
+    @PreAuthorize("@ss.hasPermi('om:productionOrde:receive')")
     @GetMapping("/getProductionNotice")
     public AjaxResult getProductionNotice(OmProductionOrdeInfo omProductionOrdeInfo)
     {
-        ReceivingServices.insertWebserviceData(omProductionOrdeInfo.getProductionNotice());
-        return AjaxResult.success();
+        String productionNotice = omProductionOrdeInfo.getProductionNotice();
+        List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
+        if(omProductionOrdeInfos.size() == 0){
+            try {
+                ReceivingServices.insertWebserviceData(productionNotice);
+            } catch (Exception e) {
+                return error("鎺ユ敹澶辫触锛佽妫�鏌ラ�氱煡鍗曞彿");
+            }
+        }else {
+            return warn("璇ラ�氱煡鍗曞凡缁忔帴鏀跺畬姣曪紝涓嶈兘閲嶅鎺ユ敹锛�");
+        }
+        return AjaxResult.success("鎺ユ敹鎴愬姛锛�");
     }
 }

--
Gitblit v1.9.3