From 557aaaac3832a634b7ecec55a5327dfb9f8c7dff Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期三, 10 四月 2024 09:11:17 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/Albania_Mes

---
 springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java |  218 +++++++++++++++++++-----------------------------------
 1 files changed, 77 insertions(+), 141 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
index 5c979bf..49863c4 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
@@ -1,24 +1,20 @@
 package com.example.springboot.component;
-
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
-import com.example.springboot.service.JdbcConnections;
-import com.example.springboot.service.SpianService;
-import com.example.springboot.entity.north_glass_buffer1;
+import com.example.springboot.service.SpianServiceNew;
+import com.example.springboot.service.StorageCageService;
+import com.example.springboot.entity.GlassInfo;
 import com.example.springboot.entity.device.PlcParameterObject;
-import com.example.springboot.mapper.AlarmMapper;
-import com.example.springboot.mapper.SpianMapper;
+import com.example.springboot.mapper.AlbaniaMapper;
+
 
 public class PlcHoldNew extends Thread {
 
-  private AlarmMapper alarmMapper;
+ 
 
   @Autowired
-  private JdbcConnections jdbcConnections;
-  private SpianMapper spianMapper;
-  private SpianService spianService;
+  private AlbaniaMapper albaniaMapper;
+  private SpianServiceNew spianService;
+  private StorageCageService storageCageService;
   int aaa;
 
   @Override
@@ -27,149 +23,89 @@
     while (this != null) {
       try {
 
-        Thread.sleep(100);
+        Thread.sleep(500);
       } catch (InterruptedException e) {
-        // \\ TODO Auto-generated catch block
         e.printStackTrace();
       }
 
-      // if (S7control.getinstance().CheckConnected() == false) {
-      spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
-      spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
-      jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
-
-      //璇诲彇DB105鍖烘枃浠�
+      
+      storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class);
+      spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class);
+      albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class);
+      
+      //璇诲彇DB14鍖烘枃浠�
       PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
-      //璇�106
-      PlcParameterObject plcread=PLCAutoMes.PlcReadObject;
-      //璇�103
-      PlcParameterObject plcstate=PLCAutoMes.plcStateObject;
-      String OutRequest=plcread.getPlcParameter("OutRequest").getValue();//鍑虹墖璇锋眰
-      String OutActivate=plcmes.getPlcParameter("OutActivate").getValue();//鍑虹墖鍚姩
-      
+      if(plcmes.getPlcParameter("PLCToMES").getValue()!=null){
+        
+      //spianService.Mestast("NG0001-1",1,4,1,"MESID1",1);
 
-     
-      S7control.getinstance().WriteWord( plcmes.getPlcParameter("1231").getAddress(plcmes.getPlcParameter("1231").getAddressIndex()), (short) 0);
-      // 鍑虹墖浠诲姟
+       
+    
+      String ExportTOMES1=plcmes.getPlcParameter("ExportTOMES1").getValue();//鍑虹墖璇锋眰涓�绾�
+      String ExportToMES2=plcmes.getPlcParameter("ExportToMES2").getValue();//鍑虹墖璇锋眰浜岀嚎
+      String PLCToMES=plcmes.getPlcParameter("PLCToMES").getValue();//杩愰�佽溅璇锋眰
+      String IDStatus1=plcmes.getPlcParameter("IDStatus1").getValue();//1鍙蜂换鍔″畬鎴�
+      String MESToPLCStatus1=plcmes.getPlcParameter("MESToPLCStatus1").getValue();//1鍙风‘璁ゅ瓧
+      String MESToPLC=plcmes.getPlcParameter("MESToPLC").getValue();//鍙戦�佷换鍔″瓧
       
-      if (OutActivate.equals("1") == false&&OutRequest.equals("1")==true) {
-        S7control.getinstance().WriteWord("DB105.18", (short) 0);// 鍑虹墖浠诲姟鍚姩鏀逛负0  
+      //涓�鍙风嚎璇锋眰
+      if(ExportTOMES1!=null&&MESToPLC!=null){
+      if (ExportTOMES1.equals("1") == true&&MESToPLC.equals("0")==true) {
+        spianService.selectout(1);
       }
-      String FeedRequest=plcread.getPlcParameter("FeedRequest").getValue();// 杩涚墖璇锋眰瀛�
-      String AddActivate=plcmes.getPlcParameter("AddActivate").getValue();// 杩涚墖鍚姩
-      if (FeedRequest.equals("1") == false&&AddActivate.equals("1")==true) {
-        S7control.getinstance().WriteWord("DB105.16", (short) 0);//杩涚墖浠诲姟鍚姩鏀逛负0
-      }     
-   
-      if (OutActivate.equals("1") == true) {
-        // 鍒ゆ柇褰撳墠鏄惁鏈夋湭鎵ц鐨勪换鍔�
-        int outnum = spianMapper.SelectOutSliceshu();//鏄惁鏈夋鍦ㄥ嚭鐗囩殑浠诲姟
-        int cageoutsum = spianMapper.Selectcageout(3);//绗煎瓙鍐呮槸鍚﹁繕鏈夊湪鍑虹墖鐨勭幓鐠�
-        // 褰撴病鏈変换鍔℃墽琛屽苟涓斿嚭鐗囪溅绌洪棽鏃�
-        if (outnum == 0 &&  Plchome.isAllowQueue == true && cageoutsum == 0) {
-          // 鍒ゆ柇閾濇鍑虹墖闃熷垪琛ㄦ槸鍚︽湁寰呭嚭鐗囩殑鐜荤拑
-          String outglassid = spianMapper.SelectOutSlice();
-          // 褰撴湁寰呭嚭鐗囩殑鐜荤拑鏃�
-          if (outglassid != null) {
-            // 鑾峰彇璇ョ幓鐠冩槸鍚﹁绂佺敤
-            int glassdisabled = spianMapper.SelectCageGlassState(outglassid);
-            // 鏈鐢ㄤ笅鍙戜换鍔�
-            if (glassdisabled == 0) {
-              spianService.selectout2(outglassid);
-              Plchome.isQueueWarning = false;
-            } else { // 绂佺敤鏇存敼鐘舵�佸脊鍑烘彁绀�
-              Plchome.isQueueWarning = true;
-            }
+    }
+      // //浜岀嚎鍙疯姹傛椂
+      if(ExportToMES2!=null &&MESToPLC!=null){
+      if (ExportToMES2.equals("1") == true&&MESToPLC.equals("0")==true) {
+        spianService.selectout(2);
+      }
+    }
+      //杩涚墖璇锋眰鏃�
+      GlassInfo glass=albaniaMapper.SelectGlass();
+      if(PLCToMES!=null && glass!=null&&MESToPLC!=null){
+      if(PLCToMES.equals("1")==true&&MESToPLC.equals("0")==true){        
+        spianService.selectAll(glass);
+      }
+    }
+    
 
+      //浠诲姟瀹屾垚鏃�
+      if(IDStatus1.equals("1")==true && MESToPLCStatus1.equals("0")==true){
+        //瀹屾垚纭瀛�
+        for(int i=1;i<7;i++){
+          
+          String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//PLC鐞嗙墖浠诲姟鐘舵�佹眹鎶�
+          String Glassid=plcmes.getPlcParameter("MESID"+i).getValueString();//MES鐜荤拑ID
+          GlassInfo id=albaniaMapper.SelectTaskId(Glassid);       
+            if(id!=null&&Tastover.equals("1")){
+              //璋冪敤瀹屾垚浠诲姟 Glassid
+              storageCageService.FinishTask(id.getId());
+            }               
+              S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//瀹屾垚纭瀛�
+            }
+              S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short) 0);//娓呴櫎浠诲姟鍙戦�佸瓧
+          }
+          
+        
+      
+      //姹囨姤鍙栨秷鏃�
+      if(IDStatus1.equals("0")==true &&MESToPLCStatus1.equals("1")){
+        
+        //鍙栨秷纭瀛�
+        for(int i=1;i<7;i++){
+          String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//渚濇鑾峰彇浠诲姟姹囨姤
+          if(Tastover.equals("0")){
+            S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 0);//娓呴櫎纭瀛�
           }
         }
-     
       }
-
-      ///////////// 杩涚墖浠诲姟      
-
-      String B01backs = plcread.getPlcParameter("B01CompleteTheReport").getValue();// b01姹囨姤
-      String B02backs = plcread.getPlcParameter("B02CompleteTheReport").getValue();// b02姹囨姤
-      
-      String B01glassid = plcstate.getPlcParameter("B01ID1").getValue();// BO1鐨勭幓鐠僫d
-      String B02glassid = plcstate.getPlcParameter("B02ID1").getValue();// B02鐨勭幓鐠僫d
-
-      // 褰撹繘鐗囧皬杞﹀畬鎴愪换鍔℃椂
-      if (B01backs.equals("1") == true) {
-        // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
-        int HB = spianMapper.SelectHB(B01glassid.toString());
-        if (HB > 0) {
-          // 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
-          S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1);
-          String yingda =plcmes.getPlcParameter("B01report").getValue();// b01姹囨姤
-          if (yingda.equals("1")) {
-            spianService.overtask(B01glassid.toString());// 瀹屾垚浠诲姟
-          }       
-        }
-
-      }else{
-        // 鎭㈠B01灏忚溅搴旂瓟鏀逛负0
-        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 0);
-      }
-
-      // 褰撳嚭鐗囧皬杞﹀畬鎴愪换鍔℃椂
-      if (B02backs.equals("1") == true) {
-        // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
-        int HB = spianMapper.SelectHB(B02glassid);
-        if (HB > 0) {
-          // 鎭㈠B02灏忚溅搴旂瓟鏀逛负1
-          S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 1);
-          String yingda =plcmes.getPlcParameter("B01report").getValue();// b02搴旂瓟
-          if (yingda.equals("1") == true) {
-            spianService.overtask(B02glassid);// 瀹屾垚浠诲姟
-          }    
-        }
-      }else{
-        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 0);
-      }
-
-
-      // 鑾峰彇DO1鏁版嵁
-      String Do1ID=plcread.getPlcParameter("FeedID").getValue();// 鑾峰彇璇锋眰鐨刬d璺烡O1鍚屾椂娓�
-      // 鑾峰彇DO2鏁版嵁
-      String Do2ID=plcread.getPlcParameter("FeedID").getValue();// 鑾峰彇璇锋眰鐨刬d璺烡O1鍚屾椂娓�
-
-
-      int questate = spianMapper.Selectquecount(Do1ID.toString());// 鍒ゆ柇鎵爜浣嶆槸鍚︽湁鐜荤拑宸茬‘璁�
-      // queueid1.toString().isEmpty()
-      north_glass_buffer1 glass1 = spianMapper.selectGlass(Do1ID);// D01鐨勭幓鐠冧俊鎭�
-      north_glass_buffer1 glass2 = spianMapper.selectGlass(Do2ID);// D02鐜荤拑淇℃伅
-      // 褰撴壂鐮佷綅鐜荤拑id涓虹┖鏃� 瀹藉害涓�0
-      if (Do1ID != null && questate == 0) {
-        // 鍐欏叆D01鐨勬暟鎹埌涓婄墖闃熷垪琛�
-        if (glass1 == null) { // 褰撴病鏈夊�兼椂浼犵┖
-          spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1);
-        } else {
-          spianMapper.Updatequeue(Do1ID.toString(), glass1.getordernumber(), glass1.getlistnumber(),
-          glass1.getboxnumber(), 0, glass1.getglasslengthmm().toString(), glass1.getglassheightmm().toString(),
-          glass1.getglasslength().toString(), glass1.getglassheight().toString(), 1);
-        }
-
-      }
-
-      if (Do2ID != null) {
-        // 鍐欏叆D02鐨勬暟鎹埌涓婄墖闃熷垪琛�
-        if (glass2 == null) {
-          spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2);
-        } else {
-          spianMapper.Updatequeue(Do2ID.toString(), glass2.getordernumber(), glass2.getlistnumber(),
-          glass2.getboxnumber(), 0, glass2.getglasslengthmm().toString(), glass2.getglassheightmm().toString(),
-          glass2.getglasslength().toString(), glass2.getglassheight().toString(), 2);
-          spianMapper.overqueue2(Do2ID.toString(), 0, 1);// 鏇存敼鎵爜浣嶄换鍔¤〃鐨勭姸鎬佷负0
-          S7control.getinstance().WriteWord("DB105.16", (short) 0);// 鍏抽棴浠诲姟鍚姩
-        }
-
-      }
-
+    
+  }
+  
       // 鏌ヨ鏁版嵁搴�
       // 鎺ㄩ�佸埌鍓嶇
 
-      // }
+    
     }
   }
 

--
Gitblit v1.8.0