From 0417fafe757f09bfb166b1dd1d9f096e966a30d8 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期六, 11 五月 2024 09:38:43 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes

---
 springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java |  337 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 178 insertions(+), 159 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
index b5023ae..1fc3c55 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java
@@ -1,204 +1,223 @@
 package com.example.springboot.component;
 
 import java.sql.SQLException;
-import java.util.ArrayList;
+import java.time.LocalDateTime;
 import java.util.List;
-
-import org.apache.ibatis.javassist.compiler.ast.Symbol;
+import java.util.ArrayList;
 import org.springframework.beans.factory.annotation.Autowired;
-
 import com.example.springboot.service.JdbcConnections;
 import com.example.springboot.service.SpianService;
-import com.example.springboot.entity.Glass;
-import com.example.springboot.mapper.AlarmMapper;
+import com.example.springboot.entity.StorageCage;
+import com.example.springboot.entity.north_glass_buffer1;
 import com.example.springboot.mapper.SpianMapper;
 
 public class PlcHold extends Thread {
 
-  private AlarmMapper alarmMapper;
 
   @Autowired
   private JdbcConnections jdbcConnections;
   private SpianMapper spianMapper;
   private SpianService spianService;
 
+  int aaa;
+
   @Override
   public void run() {
-    boolean inglassbegin=false;
-    boolean outglassbegin=false;
+
     while (this != null) {
       try {
-
-        Thread.sleep(1000);
-      } catch (InterruptedException e) {
-        // \\ TODO Auto-generated catch block
-        e.printStackTrace();
-      }
+        spianService.result=new ArrayList<>();
+        Thread.sleep(300);
+        // if (S7control.getinstance().CheckConnected() == false) {
       spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
       spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
+      
       jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
-
-      spianService.selectout("1145");
-      //spianService.selectAll2();
-      //澧炲姞闃熷垪琛ㄦ暟鎹�
-      //spianMapper.insertqueue("1",1,1500);
-
-
       // 鏍规嵁鐜荤拑id鑾峰彇璁㈠崟鍙�,鍗曠嫭鏁版嵁婧�
+      
       // try {
-
-      //   Glass glass = jdbcConnections.selectGlass(112);
-
-      //   // System.out.println(glass.getOrderId());
+      //   //spianService.selectAll(jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","",""));
+      //   north_glass_buffer1 aa=jdbcConnections.SelectGlassByGlassIdOrderIdFrameId("X12345610102GV","","");
+      //   spianMapper.UpdataAddCage2("123", "123", aa, 5, 1, 9, 2,2000.00);
       // } catch (SQLException e) {
       //   // TODO Auto-generated catch block
       //   e.printStackTrace();
       // }
-    
-      //鍒ゆ柇杩涚墖璇锋眰
-      List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1);// 鑾峰彇prc杩涚墖璇锋眰鏁版嵁
-      List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1);// 鑾峰彇杩涚墖杞︾姸鎬�
-      List<Short> datas1ListState2 = S7control.getinstance().ReadWord("DB105.12", 1);// 鑾峰彇杩涚墖杞︿换鍔℃槸鍚﹀惎鍔�
-      //娴嬭瘯鍚姩鑷畾涔塸rc鍊�
-      // List<Short> datas1List=new ArrayList<>();
-      // datas1List.add((short)1);
-      // List<Short> datas1ListState=new ArrayList<>();
-      // datas1List.add((short)0);
-      // List<Short> datas1ListState2=new ArrayList<>();
-      // datas1List.add((short)0);
-     
-
-      if (datas1List != null && datas1ListState != null) {
-
-        // 鑾峰彇prc杩涚墖璇锋眰鏁版嵁
-        boolean exist = datas1List.contains((short) 1);
-        // 鑾峰彇杩涚墖杞︾姸鎬�
-        boolean exist1 = datas1ListState.contains((short) 0);
-        //鍒ゆ柇杩涚墖杞︿换鍔℃槸鍚﹀惎鍔�
-        boolean exist2 = datas1ListState2.contains((short) 1);
-       
-        String glassid="";
-        StringBuilder strId=new StringBuilder();
-         StringBuilder writedstrId=new StringBuilder();
-       
-       if(!inglassbegin&!exist1)//褰撹繘鐗囪溅涓嶇┖闂叉椂
-       {
-         inglassbegin=true;
-       }
-       if(inglassbegin&exist1)//褰撹繘鐗囪溅绌洪棽鏃�
-       {
-        inglassbegin=false;
-        spianMapper.Updatetask(1, 0);//绔嬪嵆缁撴潫鏁版嵁搴撹〃涓殑涓婄墖浠诲姟
-        spianMapper.UpdataAddCageState(1,2);
-       }
-        // 杩涚墖璇锋眰涓�1鏃�
-        if (exist == true) {
-          // 褰撹繘鐗囪溅绌洪棽鏃�
-          if (exist1 == true) {
-            //鑾峰彇宸蹭笅鍙戠殑杩涚墖id 涓巔lc璇锋眰鐨刬d浣滄瘮杈�
-              byte[] writedglassidbytes = S7control.getinstance().ReadByte("DB105.16", 1);
-            if (writedglassidbytes != null) { //
-              // 鑾峰彇鐜荤拑id
-              for (byte iditem : writedglassidbytes) { 
-                writedstrId.append(iditem);
-              }
-            }
-            // 鑾峰彇杩涚墖id
-            byte[] datas1ListID = S7control.getinstance().ReadByte("DB106.26", 1);
-            if (datas1ListID != null) {
-              // 鑾峰彇鐜荤拑id
-              for (byte list1 : datas1ListID) { 
-                strId.append(list1);
-                
-              }
-              if(!writedstrId.toString().equals(strId.toString())) //宸茬粡涓嬪彂鐨刬d涓巔lc璇锋眰鐨刬d涓嶄竴鏍锋椂锛岃涓轰笉鏄噸澶嶇殑浠诲姟锛屾墠鎵ц涓嬪彂浠诲姟鎸囦护
-              {
-                 
-                 int glasslimit=1;//鍒ゆ柇鏄惁鏄鐗囦笂鐗�
-                 if(glasslimit==1){
-                  spianService.selectAll(strId.toString());
-                 }else{
-                  spianService.selectAll(strId.toString());
-                 }
-                  S7control.getinstance().WriteByte("DB105.16",datas1ListID);//娲惧彂杩涚墖id
-                  
-              }
-              //spianService.selectAll(Short.parseShort(strId.toString()));
-            }
-
-          }
-          // System.out.println(exist);
-        }
-//涓嬪彂浠诲姟鍚庡皢浠诲姟鍚姩鏀逛负0
-           if(exist1==false){  //杩涚墖杞﹀繖纰屾椂
-          if(exist2==true) {   //浠诲姟宸插惎鍔ㄦ椂
-          S7control.getinstance().WriteWord("DB105.12",(short)0);//杩涚墖浠诲姟鍚姩鏀逛负0
-          }  
-        }
-      }
-      
-      //spianService.selectAll((short) 111);
+      //        spianService.selectout2("X21942610602GV");
       
       List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 鍑虹墖杞︾姸鎬�
-      List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.14", 1); // 鍑虹墖浠诲姟鏄惁鍚姩
-      StringBuilder writedstrIdOut=new StringBuilder();
-       //鑾峰彇宸蹭笅鍙戠殑鍑虹墖id
-              byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 1);
-            if (writedglassidbytesOut != null) {
-              // 鑾峰彇鐜荤拑id
-              for (byte iditem : writedglassidbytesOut) { 
-                writedstrIdOut.append(iditem);
-              }
-            }
-      boolean outstate=false;//鍑虹墖杞︾┖闂插垽鏂�
-      boolean outstate1=false;//鍑虹墖杞︿换鍔℃槸鍚﹀惎鍔�
-       if (outlist != null&&outlist1!=null) {
-        // 鍒ゆ柇鎸夎鍗曞嚭鐗�
-         outstate = outlist.contains((short) 0);//鍑虹墖杞︾┖闂插垽鏂�
-         outstate1 = outlist1.contains((short) 1);//鍑虹墖杞︿换鍔℃槸鍚﹀惎鍔�
-         
-          Glass glass=spianMapper.SelectDBOut();//鍒ゆ柇鏄惁鏈夎皟鎷ㄥ悗鐨勫嚭鐗囦换鍔℃湭瀹屾垚
+      List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.18", 1); // 鍑虹墖浠诲姟鏄惁鍚姩
 
-          if(!outglassbegin&!outstate)//褰撲换鍔¤繕鏈紑濮嬶紝涓斿嚭鐗囪溅涓嶇┖闂叉椂,浠诲姟鐘舵�佹敼涓哄紑濮�
-       {
-         outglassbegin=true;
-       }
-       if(outglassbegin&outstate)//褰撲换鍔″紑濮嬩笖鍑虹墖杞︾┖闂叉椂
-       {
-        outglassbegin=false;
-        spianMapper.UpdatetaskOut(); //瀹屾垚涓婁竴娆″嚭鐗囨垨鑰呰皟搴︿换鍔�
-        spianMapper.UpdataAddCageState(0,3);
-       }
-
-         if(outstate== true &glass.getGlassId()!=null){ //褰撳嚭鐗囪溅绌洪棽涓旀湁鍑虹墖浠诲姟寰呭畬鎴愭椂
-          if(glass.getId()==2&!writedstrIdOut.toString().equals(glass.getGlassId().toString())){ 
-           spianService.selectout2(glass.getGlassId().toString());
-            }
-        } 
-        if(outstate==false){//涓嬪彂浠诲姟鍚庡皢浠诲姟鍚姩鏀逛负0//鍑虹墖杞︾┖闂插垽鏂�
-          if(outstate1==true){
-            S7control.getinstance().WriteWord("DB105.14",(short)0);//鍑虹墖浠诲姟鍚姩鏀逛负0
-          }
-         }
+      boolean Plcout = spianService.listbool("DB106.64"); // 鍑虹墖璇锋眰瀛�
+      boolean Plcout2 = spianService.listbool("DB105.18"); // 鍑虹墖鍚姩
+      if (Plcout == false&&Plcout2==true) {
+        S7control.getinstance().WriteWord("DB105.18", (short) 0);// 鍑虹墖浠诲姟鍚姩鏀逛负0
+        System.out.println("鍏抽棴鍑虹墖鍚姩" + LocalDateTime.now());// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负0
       }
-     
+      boolean Plcadd = spianService.listbool("DB106.24"); // 杩涚墖璇锋眰瀛�
+      boolean Plcadd2 = spianService.listbool("DB105.16"); // 杩涚墖鍚姩
+      if (Plcadd == false&&Plcadd2==true) {
+        S7control.getinstance().WriteWord("DB105.16", (short) 0);//杩涚墖浠诲姟鍚姩鏀逛负0
+        System.out.println("鍏抽棴杩涚墖鍚姩" + LocalDateTime.now());// 杩涚墖浠诲姟鍙戦�佸瓧鏀逛负0
+      }
       
- 
+
+
+      // StringBuilder writedstrIdOut = new StringBuilder();
+      // 鑾峰彇宸蹭笅鍙戠殑鍑虹墖id
+      byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 14);
+      String writedstrIdOut = new String(writedglassidbytesOut);
+
+   
+      if (Plcout == 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) {
+            // 鑾峰彇璇ョ幓鐠冩槸鍚﹁绂佺敤
+            StorageCage glassdisabled = spianMapper.SelectCageGlassState(outglassid);
+            if(glassdisabled!=null){
+              // 鏈鐢ㄤ笅鍙戜换鍔�
+            if (glassdisabled.getDisabled() == 0) {
+              spianService.selectout2(outglassid);
+              Plchome.isQueueWarning = false;
+            } else { // 绂佺敤鏇存敼鐘舵�佸脊鍑烘彁绀�
+              Plchome.isQueueWarning = true;
+              System.out.println("绂佺敤" + outglassid);
+            }
+            }
+            
+
+          }
+        }
      
-        if (outstate == true) { // 鍑虹墖杞︾姸鎬佺┖闂叉椂
-            Integer state=spianMapper.Selectoutstate();
-            String orderid = spianMapper.SelectOrderout();
-           
-            if (orderid != null &&state==0) {
-              spianService.selectout(orderid);
-            }      
+      }
+
+      ///////////// 杩涚墖浠诲姟
+      List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1);// 鑾峰彇prc杩涚墖璇锋眰鏁版嵁
+      List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1);// 鑾峰彇杩涚墖杞︾姸鎬�
+      List<Short> datas1ListState2 = S7control.getinstance().ReadWord("DB105.16", 1);// 鑾峰彇杩涚墖杞︿换鍔℃槸鍚﹀惎鍔�
+
+      boolean B01backs = spianService.listbool("DB106.60");// b01姹囨姤
+      boolean B02backs = spianService.listbool("DB106.62");// b02姹囨姤
+      StringBuilder B01glassid = spianService.queGlassid("DB103.184", 14);// BO1鐨勭幓鐠僫d
+      StringBuilder B02glassid = spianService.queGlassid("DB103.212", 14);// B02鐨勭幓鐠僫d
+
+      // 褰撹繘鐗囧皬杞﹀畬鎴愪换鍔℃椂
+      if (B01backs == true) {
+        // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
+        int HB = spianMapper.SelectHB(B01glassid.toString());
+        if (HB > 0) {
+          // 褰揃01灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬� 涓�1
+          S7control.getinstance().WriteWord("DB105.48", (short) 1);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
+          boolean yingda = spianService.listbool("DB105.48");// b01搴旂瓟
+          if (yingda == true) {
+            spianService.overtask(B01glassid.toString());// 瀹屾垚浠诲姟
+          }
+          System.out.println("姹囨姤鏃禕01|"  + B01glassid + "搴旂瓟" + yingda);
+          Plchome.feedglassid=B01glassid;
+        }else{
+          S7control.getinstance().WriteWord("DB105.48", (short) 1);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
+          System.out.println("HB:|" + HB+"glassid|"+B01glassid);
         }
 
-      
+      }else{
+        S7control.getinstance().WriteWord("DB105.48", (short) 0);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
+      }
+
+      // 褰撳嚭鐗囧皬杞﹀畬鎴愪换鍔℃椂
+      if (B02backs == true) {
+        // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
+        int HB = spianMapper.SelectHB(B02glassid.toString());
+        System.out.println("huibaoshiB02ID|" + B02glassid);
+        if (HB > 0) {
+          // 褰揃02灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬佷负0
+          S7control.getinstance().WriteWord("DB105.50", (short) 1);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负1
+          boolean yingda = spianService.listbool("DB105.50");// b02姹囨姤
+         if (yingda == true) {
+            spianService.overtask(B02glassid.toString());// 瀹屾垚浠诲姟
+          }
+          System.out.println("姹囨姤鏃禕02|" + B02glassid + "搴旂瓟" + yingda);
+          Plchome.feedglassid=B01glassid;
+        }else{
+          S7control.getinstance().WriteWord("DB105.50", (short) 1);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负1
+          System.out.println("HB:|" + HB+"glassid|"+B02glassid);
+        }
+      }else{
+         S7control.getinstance().WriteWord("DB105.50", (short) 0);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负0
+      }
+
+
+      // 鑾峰彇DO1鏁版嵁
+      StringBuilder queueid1 = spianService.queGlassid("DB106.26", 14);// 鑾峰彇璇锋眰鐨刬d璺烡O1鍚屾椂娓�
+      // 鑾峰彇DO2鏁版嵁
+      StringBuilder queueid2 = spianService.queGlassid("DB103.58", 14);
+
+      int questate = spianMapper.Selectquecount(queueid1.toString());// 鍒ゆ柇鎵爜浣嶆槸鍚︽湁鐜荤拑宸茬‘璁�
+      //queueid1.toString().isEmpty();
+      // north_glass_buffer1 glass1 = spianMapper.selectGlass(queueid1.toString());// D01鐨勭幓鐠冧俊鎭�
+      // north_glass_buffer1 glass2 = spianMapper.selectGlass(queueid2.toString());// D02鐜荤拑淇℃伅
+
+      north_glass_buffer1 glass1 =new north_glass_buffer1();
+      north_glass_buffer1 glass2 =new north_glass_buffer1();
+
+      try {
+        if(Plchome.dbconnected==true){
+          if(queueid1.toString()!=""){
+            glass1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIdplchold(queueid1.toString(),"","");// D01鐜荤拑淇℃伅
+          }
+          if(queueid2.toString()!=""){
+            glass2 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIdplchold(queueid2.toString(),"","");// D02鐜荤拑淇℃伅
+          }
+        }
+      } catch (SQLException e) {
+        e.printStackTrace();
+      }
+     
+      // 褰撴壂鐮佷綅鐜荤拑id涓虹┖鏃� 瀹藉害涓�0
+      if (queueid1 != null && questate == 0) {
+        // 鍐欏叆D01鐨勬暟鎹埌涓婄墖闃熷垪琛�
+        if (glass1 == null ||glass1.getordernumber()==null) { // 褰撴病鏈夊�兼椂浼犵┖
+          spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1);
+        } else {
+
+          spianMapper.Updatequeue(queueid1.toString(), glass1.getordernumber(), glass1.getlistnumber(),
+              glass1.getboxnumber(), 0, glass1.getglasslengthmm().toString(), glass1.getglassheightmm().toString(),
+              glass1.getglasslength().toString(), glass1.getglassheight().toString(), 1);
+        }
+
+      }
+
+      if (queueid2 != null) {
+        // 鍐欏叆D02鐨勬暟鎹埌涓婄墖闃熷垪琛�
+        if (glass2 == null ||glass2.getordernumber()==null) {
+          spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2);
+        } else {
+          spianMapper.Updatequeue(queueid2.toString(), glass2.getordernumber(), glass2.getlistnumber(),
+              glass2.getboxnumber(), 0, glass2.getglasslengthmm().toString(), glass2.getglassheightmm().toString(),
+              glass2.getglasslength().toString(), glass2.getglassheight().toString(), 2);
+          spianMapper.overqueue2(queueid2.toString(), 0, 1);// 鏇存敼鎵爜浣嶄换鍔¤〃鐨勭姸鎬佷负0
+          S7control.getinstance().WriteWord("DB105.16", (short) 0);// 鍏抽棴浠诲姟鍚姩
+        }
+
+      }
+      // System.out.println(spianService.result);
 
       // 鏌ヨ鏁版嵁搴�
       // 鎺ㄩ�佸埌鍓嶇
 
+      // }
+      } catch (InterruptedException e) {
+        // \\ TODO Auto-generated catch block
+        e.printStackTrace();
+      }
+      
+      
     }
   }
 

--
Gitblit v1.8.0