From db1edf54ea55cf01f8794627b9e38a549afb951f Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期一, 27 十一月 2023 09:15:22 +0800
Subject: [PATCH] 更新理片笼逻辑

---
 springboot-vue3/src/main/java/com/example/springboot/entity/north_glass_buffer1.java |   59 ++++++-
 springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java     |    2 
 springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java    |    9 
 springboot-vue3/src/main/java/com/example/springboot/component/PlcHold.java          |  238 +++++++++++++++-------------
 springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java         |   34 ++-
 springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java       |  103 +++++++-----
 6 files changed, 263 insertions(+), 182 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..ec56e0c 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
@@ -10,6 +10,7 @@
 import com.example.springboot.service.JdbcConnections;
 import com.example.springboot.service.SpianService;
 import com.example.springboot.entity.Glass;
+import com.example.springboot.entity.north_glass_buffer1;
 import com.example.springboot.mapper.AlarmMapper;
 import com.example.springboot.mapper.SpianMapper;
 
@@ -24,8 +25,8 @@
 
   @Override
   public void run() {
-    boolean inglassbegin=false;
-    boolean outglassbegin=false;
+    boolean inglassbegin = false;
+    boolean outglassbegin = false;
     while (this != null) {
       try {
 
@@ -38,35 +39,33 @@
       spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
       jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
 
-      spianService.selectout("1145");
-      //spianService.selectAll2();
-      //澧炲姞闃熷垪琛ㄦ暟鎹�
-      //spianMapper.insertqueue("1",1,1500);
-
+      String str = "Hello";
+      char[] charArray = new char[str.length()];
+      for (int i = 0; i < str.length(); i++) {
+        charArray[i] = str.charAt(i);
+      }
+      System.out.println(charArray);
+      // spianService.selectout("1145");
+      // spianService.selectAll("11");
+      // spianService.selectAll2();
+      // 澧炲姞闃熷垪琛ㄦ暟鎹�
+      // spianMapper.insertqueue("1",1,1500);
 
       // 鏍规嵁鐜荤拑id鑾峰彇璁㈠崟鍙�,鍗曠嫭鏁版嵁婧�
       // try {
 
-      //   Glass glass = jdbcConnections.selectGlass(112);
+      // north_glass_buffer1 glass = jdbcConnections.selectGlass(112);
 
-      //   // System.out.println(glass.getOrderId());
+      // // System.out.println(glass.getOrderId());
       // } catch (SQLException e) {
-      //   // TODO Auto-generated catch block
-      //   e.printStackTrace();
+      // // 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) {
 
@@ -74,127 +73,144 @@
         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);
-       }
+
+        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);
+            // 鑾峰彇宸蹭笅鍙戠殑杩涚墖id 涓巔lc璇锋眰鐨刬d浣滄瘮杈�
+            byte[] writedglassidbytes = S7control.getinstance().ReadByte("DB105.16", 13);
             if (writedglassidbytes != null) { //
               // 鑾峰彇鐜荤拑id
-              for (byte iditem : writedglassidbytes) { 
+              for (byte iditem : writedglassidbytes) {
                 writedstrId.append(iditem);
               }
             }
             // 鑾峰彇杩涚墖id
-            byte[] datas1ListID = S7control.getinstance().ReadByte("DB106.26", 1);
+            byte[] datas1ListID = S7control.getinstance().ReadByte("DB106.26", 13);
             if (datas1ListID != null) {
               // 鑾峰彇鐜荤拑id
-              for (byte list1 : datas1ListID) { 
+              for (byte list1 : datas1ListID) {
                 strId.append(list1);
-                
+
               }
-              if(!writedstrId.toString().equals(strId.toString())) //宸茬粡涓嬪彂鐨刬d涓巔lc璇锋眰鐨刬d涓嶄竴鏍锋椂锛岃涓轰笉鏄噸澶嶇殑浠诲姟锛屾墠鎵ц涓嬪彂浠诲姟鎸囦护
+              if (!writedstrId.toString().equals(strId.toString())) // 宸茬粡涓嬪彂鐨刬d涓巔lc璇锋眰鐨刬d涓嶄竴鏍锋椂锛岃涓轰笉鏄噸澶嶇殑浠诲姟锛屾墠鎵ц涓嬪彂浠诲姟鎸囦护
               {
-                 
-                 int glasslimit=1;//鍒ゆ柇鏄惁鏄鐗囦笂鐗�
-                 if(glasslimit==1){
+
+                int glasslimit = 1;// 鍒ゆ柇鏄惁鏄鐗囦笂鐗�
+                if (glasslimit == 1) {
                   spianService.selectAll(strId.toString());
-                 }else{
+                } else {
                   spianService.selectAll(strId.toString());
-                 }
-                  S7control.getinstance().WriteByte("DB105.16",datas1ListID);//娲惧彂杩涚墖id
-                  
+                }
+                S7control.getinstance().WriteByte("DB105.16", datas1ListID);// 娲惧彂杩涚墖id
+
               }
-              //spianService.selectAll(Short.parseShort(strId.toString()));
+              // 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
-          }  
+        // 涓嬪彂浠诲姟鍚庡皢浠诲姟鍚姩鏀逛负0
+        if (exist1 == false) { // 杩涚墖杞﹀繖纰屾椂
+          if (exist2 == true) { // 浠诲姟宸插惎鍔ㄦ椂
+            S7control.getinstance().WriteWord("DB105.12", (short) 0);// 杩涚墖浠诲姟鍚姩鏀逛负0
+          }
         }
       }
-      
-      //spianService.selectAll((short) 111);
-      
+
       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();//鍒ゆ柇鏄惁鏈夎皟鎷ㄥ悗鐨勫嚭鐗囦换鍔℃湭瀹屾垚
-
-          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
-          }
-         }
+      StringBuilder writedstrIdOut = new StringBuilder();
+      // 鑾峰彇宸蹭笅鍙戠殑鍑虹墖id
+      byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 13);
+      if (writedglassidbytesOut != null) {
+        // 鑾峰彇鐜荤拑id
+        for (byte iditem : writedglassidbytesOut) {
+          writedstrIdOut.append((char) iditem);
+        }
       }
-     
-      
- 
-     
-        if (outstate == true) { // 鍑虹墖杞︾姸鎬佺┖闂叉椂
-            Integer state=spianMapper.Selectoutstate();
-            String orderid = spianMapper.SelectOrderout();
-           
-            if (orderid != null &&state==0) {
-              spianService.selectout(orderid);
-            }      
+      // 鑾峰彇BO1鏁版嵁
+      StringBuilder queueid1 = spianService.queGlassid("DB103.DBB32");
+      // 鑾峰彇BO2鏁版嵁
+      StringBuilder queueid2 = spianService.queGlassid("DB103.DBB46");
+      if (queueid1 != null) {
+        // 鍐欏叆B01鐨勬暟鎹埌涓婄墖闃熷垪琛�
+        spianMapper.insertqueue(queueid1.toString(), 1, 0);
+      }
+      if (queueid2 != null) {
+        // 鍐欏叆B02鐨勬暟鎹埌涓婄墖闃熷垪琛�
+        spianMapper.insertqueue(queueid2.toString(), 2, 0);
+      }
+
+      // 鍑虹墖浠诲姟////////////////////////////////
+      boolean outstate = false;// 鍑虹墖杞︾┖闂插垽鏂�
+      boolean outstate1 = false;// 鍑虹墖杞︿换鍔℃槸鍚﹀惎鍔�
+      if (outlist != null && outlist1 != null) {
+        // 鍒ゆ柇鎸夎鍗曞嚭鐗�
+        outstate = outlist.contains((short) 0);// 鍑虹墖杞︾┖闂插垽鏂�
+        outstate1 = outlist1.contains((short) 1);// 鍑虹墖杞︿换鍔℃槸鍚﹀惎鍔�
+
+        north_glass_buffer1 glass = spianMapper.SelectDBOut();// 鍒ゆ柇鏄惁鏈夎皟鎷ㄥ悗鐨勫嚭鐗囦换鍔℃湭瀹屾垚
+
+        if (!outglassbegin & !outstate)// 褰撲换鍔¤繕鏈紑濮嬶紝涓斿嚭鐗囪溅涓嶇┖闂叉椂,浠诲姟鐘舵�佹敼涓哄紑濮�
+        {
+          outglassbegin = true;
+        }
+        if (outglassbegin & outstate)// 褰撲换鍔″紑濮嬩笖鍑虹墖杞︾┖闂叉椂
+        {
+          outglassbegin = false;
+          spianMapper.UpdatetaskOut(); // 瀹屾垚涓婁竴娆″嚭鐗囨垨鑰呰皟搴︿换鍔�
+          spianMapper.UpdataAddCageState(0, 3);// 灏嗗嚭鐗囦腑鐨勬牸瀛愮姸鎬佹敼鎴�0
         }
 
-      
+        if (outstate == true & glass.getbarcode() != null) { // 褰撳嚭鐗囪溅绌洪棽涓旀湁鍑虹墖浠诲姟寰呭畬鎴愭椂
+          // 鍒ゆ柇鏈変袱涓嚭鐗囨垨璋冩嫧浠诲姟鏃跺苟涓斿嚭鐗噄d鍜屾湭瀹屾垚鐨勫嚭鐗囦换鍔d涓嶄竴鏍锋椂鎵ц鍑虹墖
+          if (glass.getId() == 2 & !writedstrIdOut.toString().equals(glass.getbarcode().toString())) {
+            spianService.selectout2(glass.getbarcode().toString());
+          }
+        }
+        // 鍒ゆ柇褰撳墠鏄惁鏈夋湭鎵ц鐨勪换鍔�
+        int outnum = spianMapper.SelectOutSliceshu();
+        if (outnum == 0) {
+          // 鍒ゆ柇閾濇鍑虹墖闃熷垪琛ㄦ槸鍚︽湁寰呭嚭鐗囩殑鐜荤拑
+          String outglassid = spianMapper.SelectOutSlice();
+          if (outglassid != null) {
+            spianService.selectout2(outglassid);
+          }
+        }
+        if (outstate == false) {// 涓嬪彂浠诲姟鍚庡皢浠诲姟鍚姩鏀逛负0//鍑虹墖杞︾┖闂插垽鏂�
+          if (outstate1 == true) {
+            S7control.getinstance().WriteWord("DB105.14", (short) 0);// 鍑虹墖浠诲姟鍚姩鏀逛负0
+          }
+        }
+      }
+
+      if (outstate == true) { // 鍑虹墖杞︾姸鎬佺┖闂叉椂
+        Integer state = spianMapper.Selectoutstate();
+        String orderid = spianMapper.SelectOrderout();
+
+        if (orderid != null && state == 0) {
+          spianService.selectout(orderid);
+        }
+      }
 
       // 鏌ヨ鏁版嵁搴�
       // 鎺ㄩ�佸埌鍓嶇
diff --git a/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java b/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
index fa0b7d6..988df23 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -25,7 +25,7 @@
     //
     System.out.println("鍚姩瀹屾垚");
 
-    // new PlcHold().start();
+    new PlcHold().start();
 
     new Plcaction().start();
 
diff --git a/springboot-vue3/src/main/java/com/example/springboot/entity/north_glass_buffer1.java b/springboot-vue3/src/main/java/com/example/springboot/entity/north_glass_buffer1.java
index 97842af..370e790 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/entity/north_glass_buffer1.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/entity/north_glass_buffer1.java
@@ -8,8 +8,17 @@
     private String barcode;//鐜荤拑id
     private double glasslength;//鐜荤拑瀹�
     private double glassheight;//鐜荤拑楂�
-    private double glasslength_mm;//鐜荤拑瀹絤m
-    private double glassheight_mm;//鐜荤拑楂榤m
+    private double glasslengthmm;//鐜荤拑瀹絤m
+    private double glassheightmm;//鐜荤拑楂榤m
+
+    private String glassoutside;//
+    private String glassinside;//
+    private String glassbetween;//
+    private String itemtype;//
+    private String slotnumber;//
+    private String datemodified;//
+    private String datecreated;//
+    private String FrameBarcode;//
 
     public Integer id() {
         return id;
@@ -65,20 +74,50 @@
         this.glassheight = glassheight;
     }
 
-    public Double getglasslength_mm() {
-        return glasslength_mm;
+    public Double getglasslengthmm() {
+        return glasslengthmm;
     }
-    public void setglasslength_mm(Double glasslength_mm) {
-        this.glasslength_mm = glasslength_mm;
+    public void setglasslengthmm(Double glasslengthmm) {
+        this.glasslengthmm = glasslengthmm;
     }
 
-    public Double glassheight_mm() {
-        return glassheight_mm;
+    public Double glassheightmm() {
+        return glassheightmm;
     }
-    public void setglassheight_mm(Double glassheight_mm) {
-        this.glassheight_mm = glassheight_mm;
+    public void setglassheightmm(Double glassheightmm) {
+        this.glassheightmm = glassheightmm;
     }
 
+    public String getitemtype() {
+        return itemtype;
+    }
+    public void setitemtype(String itemtype) {
+        this.itemtype = itemtype;
+    }
+    public String getslotnumber() {
+        return slotnumber;
+    }
+    public void setslotnumber(String slotnumber) {
+        this.slotnumber = slotnumber;
+    }
+    public String getdatemodified() {
+        return datemodified;
+    }
+    public void setdatemodified(String datemodified) {
+        this.datemodified = datemodified;
+    }
+    public String getdatecreated() {
+        return datecreated;
+    }
+    public void setdatecreated(String datecreated) {
+        this.datecreated = datecreated;
+    }
+    public String getFrameBarcode() {
+        return FrameBarcode;
+    }
+    public void setFrameBarcode(String FrameBarcode) {
+        this.FrameBarcode = FrameBarcode;
+    }
    
 
 }
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java b/springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java
index 6903be8..86dbe5a 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java
@@ -5,7 +5,7 @@
 import com.example.springboot.entity.Glass;
 import com.example.springboot.entity.StorageCage;
 import com.example.springboot.entity.StorageTask;
-
+import com.example.springboot.entity.north_glass_buffer1;
 
 import java.util.List;
 
@@ -22,9 +22,11 @@
     //鑾峰彇璁㈠崟鍙锋帓搴忕殑绌鸿鍗曠瀛�
      @Select("select a.cage,COUNT(if(a.order_id=#{orderids},a.order_id,null))as orderid,b.shu,c.shu2,a.cell,min(a.state)as state1 from storage_cage a left join (select COUNT(*)shu,cage from storage_cage  where order_id=#{orderids} GROUP BY cage)as b on a.cage=b.cage left join(select cage ,COUNT(glass_id)as shu2 from storage_cage GROUP BY cage)c  on a.cage=c.cage where (order_id=#{orderids} or ''='') GROUP BY cage,cell HAVING state1=0 ORDER BY shu desc,shu2,cage asc; ")
      List<StorageCage> selectAll(String orderids);
-
+    //鑾峰彇鍒ゆ柇璇ユ牸瀛愭槸鍚﹂渶瑕佹妸澶栫墖鎺ㄥ叆鍐呯墖浣嶇疆
+     @Select("select state from storage_cage where  cage=#{cage} and cell=#{cell} and tier=1;")
+     int selectcell(int cage,int cell);
      //鍒ゆ柇璇ョ瀛愭槸鍚︽湁鍚堥�傚搴︾┖鏍�
-     @Select("select cage,cell,tier,id,ROUND(id/2)as prcId,width from storage_cage where cage=#{cage1} and cell=#{cell} and state=0 and width>=#{width} ORDER BY cell asc,tier desc LIMIT 1")
+     @Select("select cage,cell,tier,id,ROUND(id/2)as prcId,width from storage_cage where cage=#{cage1} and cell=#{cell} and state=0 and width>=#{width} ORDER BY cell asc,tier asc LIMIT 1")
      StorageCage selectCage1(int  cage1,int cell,double width);
      //鍒ゆ柇绗煎瓙鍐呯幓鐠冩暟
      @Select("select COUNT(tier)as tier from storage_cage where  cage=#{cage} and cell=#{cell} and state=1;")
@@ -34,8 +36,8 @@
     @Update("update longzi set glass_id =123, width =1600, state =1 where cell =24")
      void  update();
      //鑾峰彇鐜荤拑淇℃伅
-     @Select("select orderid,width from glass where glassid=#{glassid}")
-     Glass selectGlass(String glassid);
+     @Select("select orderid as ordernumber,width as glasslengthmm from glass where glassid=#{glassid}")
+     north_glass_buffer1 selectGlass(String glassid);
     
     @Insert("insert into storage_task(task_type,task_state,shelf_rack,load_rack)values(#{storage_task},#{task_state},#{shelf_rack},#{load_rack})")
      void insert(StorageTask storageTask);
@@ -71,14 +73,15 @@
      @Update("update storage_cage set width=width-#{width} where   cage=#{cage} and cell=#{cell};")
     void UpdataAddCage1(double width,int cage,int cell);
     //淇敼鍚岀瀛愭牸瀛愬搴�
+
      @Update("update storage_cage set state=#{state} where   state=#{oldstate};")
     void UpdataAddCageState(int state,int oldstate);
     //淇敼鍚岀瀛愭牸瀛愬搴�(鍑虹墖)
      @Update("update storage_cage set width=width+#{width} where   cage=#{cage} and cell=#{cell};")
     void UpdataOutCage1(double width,int cage,int cell);
     //璋冩嫧鏇存崲绗煎瓙淇℃伅
-    @Update("update storage_cage as a,(select*from storage_cage b where b.cage=#{cage} and b.cell=#{cell} and b.tier=2)as b set a.glass_id=b.glass_id,a.order_id=b.order_id,a.state=1,a.glasswidth=b.glasswidth where a.id=#{id1}")
-    void UpdateDBCage(int id1,int cage,int cell);
+    @Update("update storage_cage as a,(select*from storage_cage b where b.cage=#{cage} and b.cell=#{cell} and b.tier=#{tier})as b set a.glass_id=b.glass_id,a.order_id=b.order_id,a.state=1,a.glasswidth=b.glasswidth where a.id=#{id1}")
+    void UpdateDBCage(int id1,int cage,int cell,int tier);
     // @Insert("insert into user(name, date, address, user_no) values (#{name}, #{date}, #{address}, #{userNo})")
     // void insert (Spian spian);
     //鏂板浠诲姟琛�
@@ -100,8 +103,8 @@
     @Update("update storage_cage set glass_id='',order_id='',state=0,glasswidth=0 where a.cage=#{cage} and a.cell=#{cell} and a.tier=1;")
     void UpdateDBCage2(int cage,int cell);
     //鍒ゆ柇鏄惁鏈夎皟鎷ㄥ畬鍚庡嚭鐗囩殑浠诲姟
-    @Select("select COUNT(*)as id,glass_id from storage_task where (task_type=1 or task_type=2) and task_state=0;")
-    Glass SelectDBOut();
+    @Select("select COUNT(*)as id,glass_id as barcode from storage_task where (task_type=1 or task_type=2) and task_state=0;")
+    north_glass_buffer1 SelectDBOut();
     //鏍规嵁绗煎瓙鏍煎瓙灞傛暟鑾峰彇鐜荤拑id
      @Select("select glass_id from storage_cage where cage=#{cage} and cell=#{cell} and tier=2;")
      String SelectGlassid(int cage,int cell);
@@ -122,8 +125,8 @@
      @Select("select cage,cell,tier,id,ROUND(id/2)as prcId,width,max(state)state1 from storage_cage where cage=#{cage1} and cell=#{cell} and state=0 and width>=#{width} HAVING state1=0 ORDER BY cell asc,tier desc LIMIT 1")
      StorageCage selectqueCage1(int  cage1,int cell,double width);
      //鑾峰彇搴忓垪琛ㄧ殑鐜荤拑
-     @Select("select glassid,orderid,width from queue where state=0 and type=#{type}")
-     Glass SelectQueueGlass(int type);
+     @Select("select glassid as barcode,orderid as ordernumber,width as glasslengthmm from queue where state=0 and type=#{type}")
+     north_glass_buffer1 SelectQueueGlass(int type);
      //澶氱墖鍑哄簱娓呴櫎涓�鏁翠釜绌烘牸
      @Update("update storage_cage set glass_id='',order_id='',glasswidth=0,width=2750,state=0 where cage=#{cage} and cell=#{cell}")
      void UpdatequeOut(int cage,int cell);
@@ -134,11 +137,16 @@
      @Select("select cage,cell,ROUND(id/2)as prcId,width,count(glass_id)shu from storage_cage where order_id=#{orderid} and (cage!=#{cage} or cell!=#{cell}) GROUP BY cage,cell HAVING shu=1 ORDER BY cage desc,cell desc limit 1")
      StorageCage SelectQueout(String orderid,int cage,int cell);
      //鑾峰彇杩涚墖闃熷垪id
-     @Select("select glassid from queue where type=1 and state=0;")
      @Select("select glassid from queue where type=1")
      String Selectqueueid();
      //鑾峰彇杩涚墖闃熷垪id
      @Select("select state from queue where type=1")
      String Selectqueuestate();
-}
+     //鍒ゆ柇閾濇鍑虹墖琛ㄦ槸鍚︽湁鐜荤拑闇�瑕佸嚭
+     @Select("SELECT * FROM `out_slice` where state=0 or state=0 order by id limit 1;")
+     String SelectOutSlice();
+     //鍒ゆ柇閾濇鍑虹墖琛ㄦ槸鍚︽湁鐜荤拑姝e湪鍑虹墖涓�
+     @Select("SELECT count(*) FROM `out_slice` where state=1 or state=0 order by id limit 1;")
+     int SelectOutSliceshu();
+}   
     
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java b/springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java
index 6dc8f99..f032d87 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/service/JdbcConnections.java
@@ -9,6 +9,7 @@
 import org.springframework.stereotype.Component;
 
 import com.example.springboot.entity.Glass;
+import com.example.springboot.entity.north_glass_buffer1;
 @Component
 public class JdbcConnections {
     /**
@@ -24,15 +25,15 @@
 	private static PreparedStatement ps = null;
 	private static ResultSet rs = null;
 	
-	public  Glass selectGlass(int glassid) throws SQLException {
+	public  north_glass_buffer1 selectGlass(int glassid) throws SQLException {
         conn = getConn();
-        Glass glass=new Glass();
-        String sql = "select orderid from glass where glassid=?";
+        north_glass_buffer1 glass=new north_glass_buffer1();
+        String sql = "select ordernumber from north_glass_buffer1 where glassid=?";
          ps = conn.prepareStatement(sql);
          ps.setInt(1, glassid);
          rs= ps.executeQuery();
          while (rs.next()) {
-			glass.setOrderId(rs.getString("orderid"));
+			glass.setordernumber(rs.getString("ordernumber"));
          }
 		 conn.close();
          return glass;
diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java b/springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
index 9a6cb6a..8bad256 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
@@ -1,6 +1,7 @@
 package com.example.springboot.service;
 
 import java.lang.reflect.Array;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -11,6 +12,7 @@
 import com.example.springboot.component.S7control;
 import com.example.springboot.entity.Glass;
 import com.example.springboot.entity.StorageCage;
+import com.example.springboot.entity.north_glass_buffer1;
 import com.example.springboot.mapper.SpianMapper;
 import com.google.common.primitives.Bytes;
 
@@ -33,12 +35,12 @@
         double width;
         double minwidth = 0;
 
-        Glass glasslist = spianMapper.selectGlass(glassid); // 鑾峰彇鐜荤拑鍙傛暟
+        north_glass_buffer1 glasslist = spianMapper.selectGlass(glassid); // 鑾峰彇鐜荤拑鍙傛暟
         if (glasslist == null) {
             return (300);
         }
-        double widths = glasslist.getwidth();
-        String orderids = glasslist.getOrderId();
+        double widths = glasslist.getglasslengthmm();
+        String orderids = glasslist.getordernumber();
 
         List<String> adddresslist = new ArrayList<>();
         adddresslist.add("DB105.0");// 杩涚墖杞﹁捣濮嬩綅缃�
@@ -74,20 +76,33 @@
                 cells = cages1.getCell();// 鏍煎瓙鍙�
                 prcid = cages1.getPrcId();// 浼犵粰prc鐨勭洰鏍囧湴id
                 width = cages1.getWidth();// 鏍煎瓙鍓╀綑瀹藉害
-                widths = glasslist.getwidth();
+                widths = glasslist.getglasslengthmm();
 
                 // 鎵ц杩涚墖
                 datas.add((short) 1000);
                 datas.add((short) prcid);
                 datas.add((short) prctier);
-                datas.add((short) 1);
-                // 鏁版嵁搴撲慨鏀圭瀛愯〃鏂板涓�鏉$幓鐠�
+                datas.add((short) 1); 
+                //鑾峰彇璇ユ牸瀛愬唴鏄惁鏈夌幓鐠�
+                int cellint=spianMapper.selectcell(cage1,cells);
+                if(cellint==1){
+                    //灏嗗鐗囩幓鐠冪殑鏁版嵁鏇存柊鍒板唴鐗�
+                    spianMapper.UpdateDBCage(ids, cage1, cells,1);
+                    //灏嗘柊鍏ョ殑鐜荤拑瀛樺叆澶栫墖
+                    spianMapper.UpdataAddCage(orderids.toString(), glassid, widths, cage1, cells, ids-1, 2);
+                    spianMapper.UpdataAddCage1(widths, cage1, cells);// 鍑忓皯鏍煎瓙瀹藉害
+                    spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString());// 鏂板浠诲姟
+                    S7control.getinstance().WriteWord(adddresslist, datas);
+                }else{
+                 // 鏁版嵁搴撲慨鏀圭瀛愯〃鏂板涓�鏉$幓鐠�
                 spianMapper.UpdataAddCage(orderids.toString(), glassid, widths, cage1, cells, ids, 2);
                 spianMapper.UpdataAddCage1(widths, cage1, cells);// 鍑忓皯鏍煎瓙瀹藉害
                 spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString());// 鏂板浠诲姟
                 S7control.getinstance().WriteWord(adddresslist, datas);
 
                 // S7control.getinstance().WriteByte("DB105.16",glassid);
+                }
+              
                 return (200);
 
             }
@@ -118,7 +133,6 @@
         double widths = queGlass.getWidth();
         String orderids = queGlass.getOrderId();
         int num = spianMapper.SelectQueOrder();
-
         if (num == 1) {
 
             // 鑾峰彇璁㈠崟鐩稿叧搴︽渶楂樼殑绗煎瓙鎺掑簭
@@ -142,12 +156,12 @@
                     prcid = cages1.getPrcId();// 浼犵粰prc鐨勭洰鏍囧湴id
                     // 鏁版嵁搴撲慨鏀圭瀛愯〃鏂板涓�鏉$幓鐠�
                     for (int i = 2; i > 0; i--) {
-                        Glass qglass = spianMapper.SelectQueueGlass(i);
-                        width = qglass.getwidth();// 鏍煎瓙鍓╀綑瀹藉害
-                        spianMapper.UpdataAddqueCage(qglass.getOrderId(), qglass.getGlassId(), width, cage1, cells, i,
+                        north_glass_buffer1 qglass = spianMapper.SelectQueueGlass(i);
+                        width = qglass.getglasslengthmm();// 鏍煎瓙鍓╀綑瀹藉害
+                        spianMapper.UpdataAddqueCage(qglass.getordernumber(), qglass.getbarcode(), width, cage1, cells, i,
                                 1);
                         spianMapper.UpdataAddCage1(width, cage1, cells);// 鍑忓皯鏍煎瓙瀹藉害
-                        spianMapper.Inserttask(0, 0, 1000, ids, qglass.getGlassId().toString());// 鏂板浠诲姟
+                        spianMapper.Inserttask(0, 0, 1000, ids, qglass.getbarcode().toString());// 鏂板浠诲姟
                     }
                     // 鎵ц杩涚墖
                     datas.add((short) 1000);
@@ -163,10 +177,10 @@
 
         } else {
             for (int i = 2; i > 0; i--) {
-                Glass qglass = spianMapper.SelectQueueGlass(i);
-                String orderid = qglass.getOrderId().toString();
-                String glassid = qglass.getGlassId();
-                widths = qglass.getwidth();
+                north_glass_buffer1 qglass = spianMapper.SelectQueueGlass(i);
+                String orderid = qglass.getordernumber().toString();
+                String glassid = qglass.getbarcode();
+                widths = qglass.getglasslengthmm();
                 List<StorageCage> storageCage = spianMapper.selectAll(orderid);
                 if (storageCage == null) {
                     return (400);
@@ -192,7 +206,7 @@
                         cells = cages1.getCell();// 鏍煎瓙鍙�
                         prcid = cages1.getPrcId();// 浼犵粰prc鐨勭洰鏍囧湴id
                         width = cages1.getWidth();// 鏍煎瓙鍓╀綑瀹藉害
-                        widths = qglass.getwidth();
+                        widths = qglass.getglasslengthmm();
 
                         // 鎵ц杩涚墖
                         datas.add((short) 1000);
@@ -327,7 +341,7 @@
                         datas.add((short) 1);
                         // 鏇存崲鐜荤拑鐨勭瀛�
                         String glassids = spianMapper.SelectGlassid(cage, cell); // 鑾峰彇琚皟鎷ㄧ殑鐜荤拑id
-                        spianMapper.UpdateDBCage(ids, cage, cell);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
+                        spianMapper.UpdateDBCage(ids, cage, cell,2);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
                         spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 鍑忓皯鏂版牸瀛愬搴�
                         spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
                         spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 3);// 娓呴櫎琚皟鎷ㄦ牸瀛愭暟鎹�
@@ -354,7 +368,7 @@
                         datas.add((short) 2);
                         datas.add((short) 1);
                         String glassids = spianMapper.SelectGlassid(cage, cell); // 鑾峰彇琚皟鎷ㄧ殑鐜荤拑id
-                        spianMapper.UpdateDBCage(ids, cage, cell);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
+                        spianMapper.UpdateDBCage(ids, cage, cell,2);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
                         spianMapper.Inserttask(2, 0, cageout.getId(), ids, orderid);// 鏂板璋冨害浠诲姟
                         spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 鍑忓皯鏂版牸瀛愬搴�
                         spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
@@ -373,7 +387,7 @@
 
     }
 
-    // @GetMapping("/all2")
+    
     public Short selectout2(String glassid) {
         // spianMapper.UpdatetaskOut(); //瀹屾垚涓婁竴娆″嚭鐗囨垨鑰呰皟搴︿换鍔�,鏀瑰埌plchold閲岋紝鍑虹墖鎴栬皟搴︿换鍔″畬鎴愮珛鍗虫敼鍙樼粨鏉熶换鍔★紱
         // 瀹氫箟PRC鏁版嵁浼犻�佹暟缁�
@@ -417,7 +431,7 @@
                 spianMapper.UpdateDBCage2(cage, cell);// 娓呴櫎鍐呯墖鏁版嵁
             }
             S7control.getinstance().WriteWord(adddresslist, datas);// 娲惧彂鍑虹墖杞︿换鍔�
-            //outmesid(glassid);// 娲惧彂鍑虹墖ID
+            outmesid(glassid);// 娲惧彂鍑虹墖ID
 
             return (200);// 缁撴潫
         } else {
@@ -433,7 +447,7 @@
                 spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 鏂板浠诲姟
                 spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
                 spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 3);// 娓呴櫎鏍煎瓙鐜荤拑淇℃伅
-                //outmesid(glassid);// 娲惧彂鍑虹墖ID
+                outmesid(glassid);// 娲惧彂鍑虹墖ID
                 S7control.getinstance().WriteWord(adddresslist, datas);// 娲惧彂鍑虹墖杞︿换鍔�
 
                 return (200);// 缁撴潫
@@ -458,7 +472,7 @@
                     datas.add((short) 1);
                     // 鏇存崲鐜荤拑鐨勭瀛�
                     String glassids = spianMapper.SelectGlassid(cage, cell); // 鑾峰彇琚皟鎷ㄧ殑鐜荤拑id
-                    spianMapper.UpdateDBCage(ids, cage, cell);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
+                    spianMapper.UpdateDBCage(ids, cage, cell,2);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
                     spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 鍑忓皯鏂版牸瀛愬搴�
                     spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
                     spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 3);// 娓呴櫎琚皟鎷ㄦ牸瀛愭暟鎹�
@@ -488,7 +502,7 @@
                     String glassids = spianMapper.SelectGlassid(cage, cell); // 鑾峰彇琚皟鎷ㄧ殑鐜荤拑id
                     spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassid);// 鏂板璋冨害浠诲姟
                     spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 鏂板鍑虹墖浠诲姟
-                    spianMapper.UpdateDBCage(ids, cage, cell);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
+                    spianMapper.UpdateDBCage(ids, cage, cell,2);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
                     spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 鍑忓皯鏂版牸瀛愬搴�
                     spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
                     spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, 2, 3);// 娓呴櫎琚皟鎷ㄦ牸瀛愭暟鎹�
@@ -503,7 +517,7 @@
         }
 
     }
-
+    //娲惧彂璋冩嫧浠诲姟鐜荤拑id
     public void outmesid(String glassid) {
         System.out.println("outmesid:" + glassid);
         List<Byte> glassidlist = new ArrayList();
@@ -514,23 +528,26 @@
         System.out.println("outmesidbytes:" + bytes.length);
         S7control.getinstance().WriteByte("DB105.30", bytes);// 娲惧彂鍑虹墖id
     }
-
-    /*** 淇敼鐢ㄦ埛* @throws SQLException */
-    // public static int updateUser(Glass user) throws SQLException {conn =
-    // getConn();
-    // String sql = "update t_user set name=?,gender=?,age=?,score=?"+ " where
-    // id=?";ps = conn.prepareStatement(sql);
-    // ps.setString(1, user.getName());ps.setString(2, user.getGender());
-    // ps.setInt(3, user.getAge());ps.setDouble(4, user.getScore());ps.setInt(5,
-    // user.getId());return ps.executeUpdate();}
-    // /*** 澧炲姞鐢ㄦ埛* @throws SQLException */
-    // public static int insertUser(User user) throws SQLException {
-    // conn = getConn();
-    // String sql = "insert into t_user(name,gender,age,score)"+ " values(?,?,?,?)";
-    // ps = conn.prepareStatement(sql);ps.setString(1,
-    // user.getName());ps.setString(2, user.getGender());
-    // ps.setInt(3, user.getAge());ps.setDouble(4, user.getScore());return
-    // ps.executeUpdate();
-    // }
-
+    //鑾峰彇鍦板潃鍐呯殑鐜荤拑id杞瓧绗︿覆
+    public StringBuilder queGlassid(String address) {
+        StringBuilder writedstrIdOut = new StringBuilder();
+        byte[] writedglassidbytesOut = S7control.getinstance().ReadByte(address, 13);
+      if (writedglassidbytesOut != null) {
+        // 鑾峰彇鐜荤拑id
+        for (byte iditem : writedglassidbytesOut) {
+          writedstrIdOut.append((char) iditem);
+        }
+      }
+        return writedstrIdOut;
+    }
+    //char鏁扮粍杞寲鎴恇it鏁扮粍
+       public static byte[] toBytes(char[] chars) {
+        String s = new String(chars);
+        return s.getBytes(StandardCharsets.UTF_8);
+    }
+    //bit鏁扮粍杞寲鎴恈har鏁扮粍
+    public static char[] toChars(byte[] bytes) {
+        String s = new String(bytes, StandardCharsets.UTF_8);
+        return s.toCharArray();
+    }
 }

--
Gitblit v1.8.0