From 1717a12c83db01e3b31ea9ed913e5bacaf9edbf3 Mon Sep 17 00:00:00 2001
From: hdy <1105738590@qq.com>
Date: 星期六, 29 三月 2025 14:24:06 +0800
Subject: [PATCH] 修改

---
 billion-main/src/main/java/com/billion/main/da/service/impl/DaMaterialCollectionServiceImpl.java |   98 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 65 insertions(+), 33 deletions(-)

diff --git a/billion-main/src/main/java/com/billion/main/da/service/impl/DaMaterialCollectionServiceImpl.java b/billion-main/src/main/java/com/billion/main/da/service/impl/DaMaterialCollectionServiceImpl.java
index 58a7270..445a12c 100644
--- a/billion-main/src/main/java/com/billion/main/da/service/impl/DaMaterialCollectionServiceImpl.java
+++ b/billion-main/src/main/java/com/billion/main/da/service/impl/DaMaterialCollectionServiceImpl.java
@@ -1,6 +1,7 @@
 package com.billion.main.da.service.impl;
 
 import java.text.SimpleDateFormat;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Objects;
 
@@ -71,15 +72,16 @@
     public void insertDaMaterialCollection(DaMaterialCollection daMaterialCollection)
     {
         String url = "http://172.40.161.71:8890/Interaction/CollectMT";
-
         CollectMT collectMT = new CollectMT();
         DaMaterialCollection  daMaterialCollection1 = new DaMaterialCollection();
         BsBomChildInfo bsBomChildInfo = new BsBomChildInfo();
         OmOrderScheduling omOrderScheduling = new OmOrderScheduling();
+
         daMaterialCollection1.setSfcCode(daMaterialCollection.getSfcCode());
         daMaterialCollection1.setLocationCode(daMaterialCollection.getLocationCode());
         daMaterialCollection1.setParamValue(daMaterialCollection.getParamValue());
         daMaterialCollection1.setCollectTime(daMaterialCollection.getCollectTime());
+
         omOrderScheduling.setSfcCode(daMaterialCollection.getSfcCode());
         if(     Constants.PLC1.contains(daMaterialCollection.getLocationCode()) ||
                 Constants.C005.equals(daMaterialCollection.getLocationCode()) ||
@@ -87,33 +89,27 @@
         {omOrderScheduling.setRemarks("Head");}
         else if(
                 Constants.PLC2.contains(daMaterialCollection.getLocationCode()) ||
-                        Constants.OP005.equals(daMaterialCollection.getLocationCode()) ||
-                        Constants.OP310.equals(daMaterialCollection.getLocationCode()))
+                Constants.OP005.equals(daMaterialCollection.getLocationCode()) ||
+                Constants.OP310.equals(daMaterialCollection.getLocationCode()))
         {omOrderScheduling.setRemarks("Body");}
         else if(Constants.P010.equals(daMaterialCollection.getLocationCode()))
         {omOrderScheduling.setRemarks("Pre");}
         List<OmOrderScheduling> omOrderSchedulingList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling);
         String OrderNumber = omOrderSchedulingList.get(0).getWorkOrderNo();
-        //瑕佹敼锛侊紒锛侊紒
-        if(Objects.equals(daMaterialCollection.getLocationCode(), "OP130") || Objects.equals(daMaterialCollection.getLocationCode(), "OP020")){
-            daMaterialCollection1.setMaterialCode("0");
-            daMaterialCollection1.setMaterialName("0");
-            collectMT.setMaterial1("0");
-        }else{
-//            bsBomChildInfo.setLocationCode(daMaterialCollection.getLocationCode());
-//            bsBomChildInfo.setBomCode(OrderNumber);
-//            List<BsBomChildInfo> bsBomChildInfoList = bsBomChildInfoService.selectBsBomChildInfoList(bsBomChildInfo);
-//            String MaterialCode = bsBomChildInfoList.get(0).getMaterialCode();
-//            String MaterialName = bsBomChildInfoList.get(0).getMaterialName();
-//            daMaterialCollection1.setMaterialCode(MaterialCode);
-//            daMaterialCollection1.setMaterialName(MaterialName);
-//            collectMT.setMaterial1(MaterialName);
-            daMaterialCollection1.setMaterialCode("0");
-            daMaterialCollection1.setMaterialName("0");
-            collectMT.setMaterial1("0");
-        }
+
+            bsBomChildInfo.setLocationCode(daMaterialCollection.getLocationCode());
+            bsBomChildInfo.setBomCode(OrderNumber);
+            String[] parts = daMaterialCollection.getParamValue().split("#");
+            String targetValue = parts[1]; // 鍙栫浜屼釜鍏冪礌锛堢储寮�1锛�
+            bsBomChildInfo.setMaterialCode(targetValue);
+            List<BsBomChildInfo> bsBomChildInfoList = bsBomChildInfoService.selectBsBomChildInfoList(bsBomChildInfo);
+            String MaterialCode = bsBomChildInfoList.get(0).getMaterialCode();
+            String MaterialName = bsBomChildInfoList.get(0).getMaterialName();
+            daMaterialCollection1.setMaterialCode(MaterialCode);
+            daMaterialCollection1.setMaterialName(MaterialName);
 
         this.save(daMaterialCollection1);
+        collectMT.setMaterial1(MaterialName);
         collectMT.setOrderNumber(OrderNumber);
         collectMT.setEngineNumber(daMaterialCollection.getSfcCode());
         collectMT.setStationName(daMaterialCollection.getLocationCode());
@@ -131,13 +127,53 @@
     }
 
 
-//    @Override
-//    public void insertDaMaterialCollectionOP020OP130(DaMaterialCollection DaMaterialCollection)
-//    {
-//
-////        this.save(daMaterialCollection);
-//    }
-//
+    @Override
+    public void plusSave(DaMaterialCollection daMaterialCollection) {
+        String url = "http://172.40.161.71:8890/Interaction/CollectMT";
+        CollectMT collectMT = new CollectMT();
+        DaMaterialCollection  daMaterialCollection1 = new DaMaterialCollection();
+        BsBomChildInfo bsBomChildInfo = new BsBomChildInfo();
+        OmOrderScheduling omOrderScheduling = new OmOrderScheduling();
+        daMaterialCollection1.setSfcCode(daMaterialCollection.getSfcCode());
+        daMaterialCollection1.setLocationCode(daMaterialCollection.getLocationCode());
+        daMaterialCollection1.setParamValue(daMaterialCollection.getParamValue());
+        daMaterialCollection1.setCollectTime(daMaterialCollection.getCollectTime());
+        omOrderScheduling.setSfcCode(daMaterialCollection.getSfcCode());
+        omOrderScheduling.setSfcCode(daMaterialCollection.getSfcCode());
+        if(     Constants.PLC1.contains(daMaterialCollection.getLocationCode()) ||
+                Constants.C005.equals(daMaterialCollection.getLocationCode()) ||
+                Constants.C060.equals(daMaterialCollection.getLocationCode()) )
+        {omOrderScheduling.setRemarks("Head");}
+        else if(
+                Constants.PLC2.contains(daMaterialCollection.getLocationCode()) ||
+                        Constants.OP005.equals(daMaterialCollection.getLocationCode()) ||
+                        Constants.OP310.equals(daMaterialCollection.getLocationCode()))
+        {omOrderScheduling.setRemarks("Body");}
+        else if(Constants.P010.equals(daMaterialCollection.getLocationCode()))
+        {omOrderScheduling.setRemarks("Pre");}
+        List<OmOrderScheduling> omOrderSchedulingList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling);
+        String OrderNumber = omOrderSchedulingList.get(0).getWorkOrderNo();
+        String[] parts = daMaterialCollection.getParamValue().split("#");
+        String targetValue = parts[1]; // 鍙栫浜屼釜鍏冪礌锛堢储寮�1锛�
+        daMaterialCollection1.setMaterialCode(targetValue);
+        daMaterialCollection1.setMaterialName(daMaterialCollection.getParamName());
+        this.save(daMaterialCollection1);
+        collectMT.setMaterial1(daMaterialCollection.getMaterialName());
+        collectMT.setOrderNumber(OrderNumber);
+        collectMT.setEngineNumber(daMaterialCollection.getSfcCode());
+        collectMT.setStationName(daMaterialCollection.getLocationCode());
+        collectMT.setPartsNumber(daMaterialCollection.getParamValue());
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        collectMT.setInsertTime(sdf.format(daMaterialCollection.getCollectTime()));
+        try {
+            HttpResponse response = HttpRequest.post(url).body(JSONUtil.toJsonStr(collectMT)).execute();
+            log.info("鎺ㄩ�佹垚鍔燂紝鍝嶅簲鎶ユ枃: {}", response);
+        } catch (Exception e) {
+            // 璁板綍鏃ュ織
+            log.error("鎺ㄩ�佸け璐�");
+        }
+    }
+
 
     /**
      * 淇敼鐗╂枡閲囬泦
@@ -175,8 +211,4 @@
         return daMaterialCollectionMapper.deleteDaMaterialCollectionById(id);
     }
 
-    @Override
-    public void plusSave(DaMaterialCollection daMaterialCollection) {
-        this.save(daMaterialCollection);
-    }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3