From 04b8eff075a04db23e6f908855699b4d2954588c Mon Sep 17 00:00:00 2001
From: yyt <306727702@qq.com>
Date: 星期四, 23 五月 2024 18:47:01 +0800
Subject: [PATCH] 380新产品,优化

---
 jcdm-main/src/main/java/com/jcdm/main/om/productionOrde/controller/OmProductionOrdeInfoController.java |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 105 insertions(+), 0 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 63a195d..77c10e9 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
@@ -1,9 +1,20 @@
 package com.jcdm.main.om.productionOrde.controller;
 
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
 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;
 import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
+import com.jcdm.main.webservice.service.ReceivingServices;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -21,6 +32,8 @@
 import com.jcdm.common.utils.poi.ExcelUtil;
 import com.jcdm.common.core.page.TableDataInfo;
 
+import static org.apache.commons.lang3.SystemUtils.getUserName;
+
 /**
  * 鐢熶骇宸ュ崟Controller
  * 
@@ -33,6 +46,12 @@
 {
     @Autowired
     private IOmProductionOrdeInfoService omProductionOrdeInfoService;
+
+    @Autowired
+    private IBsOrderSchedulingService bsOrderSchedulingService;
+
+    @Autowired
+    private IBsModelNumberService bsModelNumberService;
 
     /**
      * 鏌ヨ鐢熶骇宸ュ崟鍒楄〃
@@ -70,6 +89,16 @@
     }
 
     /**
+     * 鑾峰彇鐢熶骇宸ュ崟璇︾粏淇℃伅
+     */
+    @PreAuthorize("@ss.hasPermi('om:productionOrde:query')")
+    @GetMapping("/ids/{ids}")
+    public AjaxResult getInfo(@PathVariable Long[] ids)
+    {
+        return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoByIds(ids));
+    }
+
+    /**
      * 鏂板鐢熶骇宸ュ崟
      */
     @PreAuthorize("@ss.hasPermi('om:productionOrde:add')")
@@ -78,6 +107,61 @@
     public AjaxResult add(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
     {
         return toAjax(omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo));
+    }
+
+    /**
+     * 鐢熸垚鎸夐挳
+     */
+    @PostMapping("/orderSchedulingForBoxCode")
+    public AjaxResult addOrderSchedulingForBoxCode(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
+    {
+
+        //鑾峰彇褰撳墠鏃堕棿
+        LocalDateTime date= LocalDateTime.now();
+        //鍒涘缓鏃ユ湡鏃堕棿瀵硅薄鏍煎紡鍖栧櫒锛屾棩鏈熸牸寮忕被浼硷細 2023-05-23 22:18:38
+        DateTimeFormatter formatter= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        //灏嗘椂闂磋浆鍖栦负瀵瑰簲鏍煎紡鐨勫瓧绗︿覆
+        String fomateDate=date.format(formatter).toString();
+
+        Integer startCode = Integer.parseInt(omProductionOrdeInfo.getStartCode());//寮�濮嬬紪鍙�
+
+        String dateTimeRule = omProductionOrdeInfo.getDateTimeRule();
+
+        Long[] id=omProductionOrdeInfo.getIdNums();
+        OmProductionOrdeInfo ProductionOrde;
+        for (int a=0;a<id.length;a++){
+            ProductionOrde=omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id[a]);
+            Integer planQty = Math.toIntExact(ProductionOrde.getPlanQty());//璁″垝鏁伴噺
+            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(ProductionOrde.getWorkOrderNo());
+                    bsOrderScheduling.setModel(ProductionOrde.getTypeZ());
+                    bsOrderScheduling.setEngineNo(engineNo);
+                    bsOrderScheduling.setProductionStatus("1");
+                    bsOrderScheduling.setOperator(getUserName());
+                    bsOrderScheduling.setOperateTime(fomateDate);
+                    bsOrderScheduling.setProductType(ProductionOrde.getTypeL());//浜у搧绫诲瀷
+                    bsOrderScheduling.setWhetherOrPrint("0");
+                    bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling);
+                    startCode++;
+                }
+            }
+            //鏇存柊宸ュ崟鐘舵��
+            ProductionOrde.setOrderStatus("2");
+            omProductionOrdeInfoService.updateOmProductionOrdeInfo(ProductionOrde);
+        }
+        //鏂板鏈哄瀷搴忓彿
+        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);
+        return toAjax(1);
     }
 
     /**
@@ -111,4 +195,25 @@
     {
         return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo);
     }
+
+    /**
+     * 鎺ユ敹宸ュ崟
+     */
+    @PreAuthorize("@ss.hasPermi('om:productionOrde:receive')")
+    @GetMapping("/getProductionNotice")
+    public AjaxResult getProductionNotice(OmProductionOrdeInfo omProductionOrdeInfo)
+    {
+        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