From ab63141eaf175c6c544d2ef37833dea9016d0d26 Mon Sep 17 00:00:00 2001
From: cl <418351270@qq.com>
Date: 星期五, 12 七月 2024 08:42:08 +0800
Subject: [PATCH] 修改参数采集

---
 jcdm-main/src/main/java/com/jcdm/main/om/productionOrde/controller/OmProductionOrdeInfoController.java |   56 +++++++++++---------------------------------------------
 1 files changed, 11 insertions(+), 45 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 46cc0fe..abe3e3b 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
@@ -121,17 +121,16 @@
         util.exportExcel(response, list, "鐢熶骇宸ュ崟鏁版嵁");
     }
 
-    @GetMapping("/receivingWorkOrders")
-    public AjaxResult receivingWorkOrders()
-    {
+    @GetMapping("/mozuReceivingWorkOrders")
+    public AjaxResult mozuReceivingWorkOrders(OmProductionOrdeInfo paramOrder) throws Exception {
         String paramProductNum = "";
-        Object productTypeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ProductType").getValue();//浜у搧绫诲瀷
+        Object productTypeObjcet = miloService.readFromOpcUa("MOZU1." + paramOrder.getLineCode() + ".ProductType").getValue();//浜у搧绫诲瀷
         if (ObjectUtil.isNull(productTypeObjcet)) {
             return AjaxResult.error("鎺ュ崟澶辫触,PLC鏈紶杈撶敓浜х被鍨嬶紝璇疯仈绯荤鐞嗗憳");
         }
         String productType = productTypeObjcet.toString();//浜у搧绫诲瀷
         String materialCode = Constants.materialMap.get(productType);
-        // 鏌ヨ鏈�鏂扮殑宸ュ崟淇℃伅
+
         OmProductionOrdeInfo lastOrder = omProductionOrdeInfoService.getLastOrder();
         String orderJsonString = RestfulService.getProductionWorkOrderRequest(lastOrder.getProductNum(), "M1OP100",materialCode);
         JSONObject jsonObject = new JSONObject(orderJsonString);
@@ -142,44 +141,7 @@
         if(code.equals("success")){
             logger.info("璇锋眰宸ュ巶MES宸ュ崟锛氬叆鍙俻ack{}鍑哄弬pack锛歿}",paramProductNum,dataObject.getStr("productNum"));
             List<OmProductionOrdeInfo> check = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum,dataObject.getStr("productNum")));
-            if(check.size() == 0){
-                OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo();
-                omProductionOrdeInfo.setWorkOrderNo(dataObject.getStr("productionOrderNum"));
-                omProductionOrdeInfo.setProductNum(dataObject.getStr("productNum"));
-                omProductionOrdeInfo.setStationCode(dataObject.getStr("stationCode"));
-                omProductionOrdeInfo.setMaterialCode(dataObject.getStr("materialCode"));
-                omProductionOrdeInfo.setOnlineCompletionMark("0");
-                omProductionOrdeInfo.setSfResult("0");
-                if(dataObject.getStr("model").equals("PE01A")){
-                    omProductionOrdeInfo.setProductCode("1P102S");
-                }else {
-                    omProductionOrdeInfo.setProductCode(dataObject.getStr("model"));
-                }
-                omProductionOrdeInfo.setCreateTime(new Date());
-                omProductionOrdeInfo.setCreateUser("宸ュ巶MES");
-                omProductionOrdeInfoService.save(omProductionOrdeInfo);
-            }
-        }else {
-            return AjaxResult.error("鎺ュ崟澶辫触,璇疯仈绯荤鐞嗗憳");
-        }
-        return AjaxResult.success(dataObject.getStr("productNum"));
-    }
-
-    @GetMapping("/mozuReceivingWorkOrders")
-    public AjaxResult mozuReceivingWorkOrders(OmProductionOrdeInfo paramOrder)
-    {
-        String paramProductNum = "";
-        OmProductionOrdeInfo lastOrder = omProductionOrdeInfoService.getLastOrder();
-        String orderJsonString = RestfulService.getProductionWorkOrderRequest(lastOrder.getProductNum(), "OP230");
-        JSONObject jsonObject = new JSONObject(orderJsonString);
-        // 浠嶫SONObject涓幏鍙杁ata瀵硅薄
-        JSONObject dataObject = jsonObject.getJSONObject("data");
-        String code = jsonObject.getStr("code");
-        // 鍒ゆ柇鎺ュ崟鏄惁鎴愬姛
-        if(code.equals("success")){
-            logger.info("璇锋眰宸ュ巶MES宸ュ崟锛氬叆鍙俻ack{}鍑哄弬pack锛歿}",paramProductNum,dataObject.getStr("productNum"));
-            List<OmProductionOrdeInfo> check = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().eq(OmProductionOrdeInfo::getProductNum,dataObject.getStr("productNum")));
-            if(check.size() == 0){
+            if(check.isEmpty()){
                 try {
                     log.info("璇锋眰宸ュ巶MES宸ュ崟锛氬叆鍙俻ack{}鍑哄弬pack锛歿}", paramProductNum, dataObject.getStr("productNum"));
                     OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo();
@@ -187,18 +149,22 @@
                     omProductionOrdeInfo.setProductNum(dataObject.getStr("productNum"));
                     omProductionOrdeInfo.setStationCode(dataObject.getStr("stationCode"));
                     omProductionOrdeInfo.setMaterialCode(dataObject.getStr("materialCode"));
+                    omProductionOrdeInfo.setPlanQty(Long.valueOf(dataObject.getStr("plannedQuantity")));
                     omProductionOrdeInfo.setOnlineCompletionMark("0");
                     omProductionOrdeInfo.setSfResult("0");
                     omProductionOrdeInfo.setProductCode(dataObject.getStr("model"));
                     omProductionOrdeInfo.setCreateTime(new Date());
                     omProductionOrdeInfo.setCreateUser("宸ュ巶MES");
                     omProductionOrdeInfoService.save(omProductionOrdeInfo);
+
                     //鍐橮LC
-                    miloService.writeToOpcUa(ReadWriteEntity.builder().identifier("MOZU1." + paramOrder.getLineCode() + ".MES_WorkOrderNumber").value(dataObject.getStr("productionOrderNum")).build());
-                    miloService.writeToOpcUa(ReadWriteEntity.builder().identifier("MOZU1." + paramOrder.getLineCode() + ".MES_ModuleCode").value(dataObject.getStr("productNum")).build());
+                    miloService.writeToOpcUa(ReadWriteEntity.builder().identifier("MOZU1." + paramOrder.getLineCode() + ".WorkOrderNumber").value(dataObject.getStr("productionOrderNum")).build());
+                    miloService.writeToOpcUa(ReadWriteEntity.builder().identifier("MOZU1." + paramOrder.getLineCode() + ".ModuleCode").value(dataObject.getStr("productNum")).build());
                 } catch (Exception e) {
                     throw new RuntimeException(e);
                 }
+            }else{
+                return AjaxResult.error("宸ュ崟閲嶅,璇烽噸鏂版帴鏀�");
             }
         }else {
             return AjaxResult.error("鎺ュ崟澶辫触,璇疯仈绯荤鐞嗗憳");

--
Gitblit v1.9.3