From d1b1260f2c9f4ed66f8dc4072a032e56280633e5 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期五, 23 二月 2024 11:25:36 +0800
Subject: [PATCH] 代码更新

---
 springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java |  171 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 123 insertions(+), 48 deletions(-)

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 df21932..2988da2 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,5 +1,11 @@
 package com.example.springboot.service;
 
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
@@ -11,6 +17,9 @@
 import com.example.springboot.mapper.SpianMapper;
 import com.google.common.primitives.Bytes;
 
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+
 @Service
 public class SpianService {
     @Autowired
@@ -19,7 +28,7 @@
     // @GetMapping("/all")
     public Short selectAll(String glassid) {
 
-        int cage1;
+        int cage1 = 0;
         int cells;
         int ids;
         int prcid;
@@ -29,11 +38,14 @@
         double minwidth = 0;
 
         north_glass_buffer1 glasslist = spianMapper.selectGlass(glassid); // 鑾峰彇鐜荤拑鍙傛暟
+        // 濡傛灉娌℃湁姝d鏃�
         if (glasslist == null) {
             return (300);
         }
+
         double widths = glasslist.getglasslengthmm();
         String orderids = glasslist.getordernumber();
+        String FrameBarcode = glasslist.getFrameBarcode();
 
         List<String> adddresslist = new ArrayList<>();
         adddresslist.add("DB105.0");// 杩涚墖杞﹁捣濮嬩綅缃�
@@ -45,8 +57,14 @@
         List<Short> datas = new ArrayList<>();
 
         // String orderid="A001";
-        // 鑾峰彇璁㈠崟鐩稿叧搴︽渶楂樼殑绗煎瓙鎺掑簭
-        List<StorageCage> storageCage = spianMapper.selectAll(orderids.toString());
+        // 鑾峰彇閾濇鐩稿叧搴︽渶楂樼殑绗煎瓙鎺掑簭
+        List<StorageCage> storageCage = spianMapper.selectAllFbarcode(FrameBarcode, widths, 400);
+        // 鍒ゆ柇閾濇鎸囧畾绌烘牸鏄惁闇�瑕侀棿闅旂┖闂�
+
+        if (storageCage.size() == 0) {
+            storageCage = spianMapper.selectAll(orderids, FrameBarcode);
+        }
+
         if (storageCage == null) {
             return (400);
         }
@@ -55,7 +73,7 @@
             cage1 = storageCage2.getCage();
             // 鍒ゆ柇璇ョ瀛愬彿鐩搁偦鏈�澶х殑绌烘牸鏁�
             int cages = spianMapper.selectCage(cage1);
-            
+
             // 濡傛灉鐩搁偦绗煎瓙娌℃湁绌烘牸,鎴栬�呮湁姝e湪鎵ц鐨勫嚭鐗囦换鍔℃椂杩斿洖400
             if (cages == 0) {
                 return (400);
@@ -90,23 +108,39 @@
                     // 灏嗗鐗囩幓鐠冪殑鏁版嵁鏇存柊鍒板唴鐗�
                     spianMapper.UpdateDBCage(ids, cage1, cells, 1);
                     // 灏嗘柊鍏ョ殑鐜荤拑瀛樺叆澶栫墖
-                    // spianMapper.UpdataAddCage(orderids, glassid, widths, cage1, cells, ids-1, 2);
+
                     spianMapper.UpdataAddCage2(orderids, glassid, glasslist, cage1, cells, ids - 1, 2);
                     spianMapper.UpdataAddCage1(widths, cage1, cells);// 鍑忓皯鏍煎瓙瀹藉害
-                    spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier);// 鏂板浠诲姟
+
                     S7control.getinstance().WriteWord(adddresslist, datas);
-                    System.out.println("鍑虹墖浠诲姟|" + datas);
+                    boolean qidong = listbool("DB105.16");
+                    int qidong2 = 0;
+                    if (qidong == true) {
+                        qidong2 = 1;
+                    }else{
+                        while (qidong) {
+                            S7control.getinstance().WriteWord("DB105.16", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+                            qidong = listbool("DB105.16");
+                        }
+                    }
+                    spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier,qidong2);// 鏂板浠诲姟
+                    System.out.println("杩涚墖浠诲姟|" + datas);
 
                 } else {
                     // 鏁版嵁搴撲慨鏀圭瀛愯〃鏂板涓�鏉$幓鐠�
-                    // spianMapper.UpdataAddCage(orderids, glassid, widths, cage1, cells, ids, 2);
+
                     spianMapper.UpdataAddCage2(orderids, glassid, glasslist, cage1, cells, ids, 2);
                     spianMapper.UpdataAddCage1(widths, cage1, cells);// 鍑忓皯鏍煎瓙瀹藉害
-                    spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier);// 鏂板浠诲姟
-                    S7control.getinstance().WriteWord(adddresslist, datas);
-                    System.out.println("鍑虹墖浠诲姟|" + datas);
 
-                    // S7control.getinstance().WriteByte("DB105.16",glassid);
+                    S7control.getinstance().WriteWord(adddresslist, datas);
+                    boolean qidong = listbool("DB105.16");
+                    int qidong2 = 0;
+                    if (qidong == true) {
+                        qidong2 = 1;
+                    }
+                    spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier,qidong2);// 鏂板浠诲姟
+                    System.out.println("杩涚墖浠诲姟|" + datas);
+
                 }
                 outmesid(glassid, "DB105.20");
                 return (200);
@@ -144,7 +178,6 @@
         int cells;
         double glasswidth = cageout.getGlassWidth();
 
-       
         // 鍒ゆ柇鐜荤拑鍐呭鐗�
         if (tier == 2) {
             int state = spianMapper.selectGlassState(cage, cell);// 鑾峰彇鏍煎瓙鏁伴噺
@@ -154,18 +187,24 @@
             datas.add((short) 1000);
             datas.add((short) state);
             datas.add((short) 1);
-            spianMapper.OverOutSlice(glassid, 1);// 鏇存柊鍑虹墖闃熷垪浠诲姟鐘舵�佷负杩涜涓�
+            spianMapper.OverOutSlice(glassid.toString(), 1, 0);// 鏇存柊鍑虹墖闃熷垪浠诲姟鐘舵�佷负杩涜涓�
             spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
-            spianMapper.UpdataGlassCageState(glassid, 3);// 鏇存敼绗煎瓙琛ㄧ殑鐜荤拑鐘舵��
+            spianMapper.UpdataGlassCageState(glassid.toString(), 3);// 鏇存敼绗煎瓙琛ㄧ殑鐜荤拑鐘舵��
 
-            spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, state);// 鏂板浠诲姟
-            // int state = spianMapper.selectGlassState(cage, cell);//鑾峰彇鏍煎瓙鏁伴噺
-            if (state == 2) {
-                spianMapper.UpdateDBCage1(cage, cell);// 灏嗗唴鐗囨暟鎹洿鏂板埌澶栫墖閲�
-                spianMapper.UpdateDBCage2(cage, cell);// 娓呴櫎鍐呯墖鏁版嵁
-            }
             System.out.println("鍑虹墖浠诲姟|" + datas);
             S7control.getinstance().WriteWord(adddresslist, datas);// 娲惧彂鍑虹墖杞︿换鍔�
+            S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+            boolean qidong = listbool("DB105.18");
+            int qidong2 = 0;
+            if (qidong == true) {
+                qidong2 = 1;
+            }else{
+                while (qidong) {
+                    S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+                    qidong = listbool("DB105.18");
+                }
+            }
+            spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, state, qidong2);// 鏂板浠诲姟
             outmesid(glassid, "DB105.34");// 娲惧彂鍑虹墖ID
 
             return (200);// 缁撴潫
@@ -179,21 +218,32 @@
                 datas.add((short) 1000);
                 datas.add((short) 1);
                 datas.add((short) 1);
-                spianMapper.OverOutSlice(glassid, 1);// 鏇存柊鍑虹墖闃熷垪浠诲姟鐘舵�佷负杩涜涓�
-                spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, 1);// 鏂板浠诲姟
+                spianMapper.OverOutSlice(glassid.toString(), 1, 0);// 鏇存柊鍑虹墖闃熷垪浠诲姟鐘舵�佷负杩涜涓�
+
                 spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
                 spianMapper.UpdataGlassCageState(glassid, 3);// 鏇存敼绗煎瓙琛ㄧ殑鐜荤拑鐘舵��
-                spianMapper.OverOutSlice(glassid, 1);// 鏇存柊鍑虹墖闃熷垪浠诲姟
+
                 System.out.println("鍑虹墖浠诲姟|" + datas);
                 outmesid(glassid, "DB105.34");// 娲惧彂鍑虹墖ID
                 S7control.getinstance().WriteWord(adddresslist, datas);// 娲惧彂鍑虹墖杞︿换鍔�
-
+                S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+                boolean qidong = listbool("DB105.18");
+                int qidong2 = 0;
+                if (qidong == true) {
+                    qidong2 = 1;
+                }else{
+                    while (qidong) {
+                        S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+                        qidong = listbool("DB105.18");
+                    }
+                }
+                spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, 1, qidong2);// 鏂板浠诲姟
                 return (200);// 缁撴潫
 
             } else {
                 // 鐜荤拑闇�瑕佽皟鎷ㄦ椂锛屽垽鏂睘浜庡摢涓崐鍖虹殑绗煎瓙
                 if (cage < 6) {
-                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 0, 6,cell);
+                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 0, 6, cell);
                     if (cagecell == null) {
                         return (300);
                     }
@@ -214,16 +264,28 @@
                     spianMapper.UpdateDBCage(ids, cage, cell, 2);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
                     spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 鍑忓皯鏂版牸瀛愬搴�
                     spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
-                    spianMapper.Inserttask(2, 0, cageout.getId(), ids, glassids, 2);// 鏂板璋冨害浠诲姟
                     // 浼犺緭mes鏁版嵁,鍧愭爣锛屾暟鎹�
                     System.out.println("鍑虹墖浠诲姟|" + datas);
                     S7control.getinstance().WriteWord(adddresslist, datas);// 娲惧彂鍑虹墖杞︿换鍔�
-
+                    S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
                     outmesid(glassids, "DB105.34");// 娲惧彂璋冩嫧鐜荤拑ID
+
+                    boolean qidong = listbool("DB105.18");
+                    int qidong2 = 0;
+                    if (qidong == true) {
+                        qidong2 = 1;
+                    }else{
+                        while (qidong) {
+                            S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+                            qidong = listbool("DB105.18");
+                        }
+                    }
+                    spianMapper.Inserttask(2, 0, cageout.getId(), ids, glassids, 2, qidong2);// 鏂板璋冨害浠诲姟
+
                     return (200); // 缁撴潫
 
                 } else {// 绗煎瓙鍙峰ぇ浜�5鏃�
-                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 5, 11,cell);
+                    StorageCage cagecell = spianMapper.selectGlassCage(cage, glasswidth, 5, 11, cell);
                     if (cagecell == null) {
                         return (300);
                     }
@@ -238,17 +300,28 @@
                     datas.add((short) 2);
                     datas.add((short) 1);
                     String glassids = spianMapper.SelectGlassid(cage, cell); // 鑾峰彇琚皟鎷ㄧ殑鐜荤拑id
-                    spianMapper.UpdataGlassCageState(glassids, 3);// 鏇存敼绗煎瓙琛ㄧ殑鐜荤拑鐘舵��
-                    spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassids, 2);// 鏂板璋冨害浠诲姟
-                    // spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid);// 鏂板鍑虹墖浠诲姟
-                    spianMapper.UpdateDBCage(ids, cage, cell, 2);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
-                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 鍑忓皯鏂版牸瀛愬搴�
-                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
                     // 浼犺緭mes鏁版嵁,鍧愭爣锛屾暟鎹�
                     System.out.println("鍑虹墖浠诲姟|" + datas);
                     S7control.getinstance().WriteWord(adddresslist, datas);// 娲惧彂鍑虹墖杞︿换鍔�
+                    S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
 
                     outmesid(glassids, "DB105.34");// 娲惧彂璋冩嫧鐜荤拑ID
+                    spianMapper.UpdataGlassCageState(glassids, 3);// 鏇存敼绗煎瓙琛ㄧ殑鐜荤拑鐘舵��
+                    boolean qidong = listbool("DB105.18");
+                    int qidong2 = 2;
+                    if (qidong == true) {
+                        qidong2 = 1;
+                    }else{
+                        while (qidong) {
+                            S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+                            qidong = listbool("DB105.18");
+                        }
+                    }
+                    spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassids, 2, qidong2);// 鏂板璋冨害浠诲姟
+                    spianMapper.UpdateDBCage(ids, cage, cell, 2);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
+                    spianMapper.UpdataAddCage1(glasswidth, cages, cells);// 鍑忓皯鏂版牸瀛愬搴�
+                    spianMapper.UpdataOutCage1(glasswidth, cage, cell);// 澧炲姞鍘熸牸瀛愬搴�
+
                     return (200);// 缁撴潫
 
                 }
@@ -268,6 +341,7 @@
         byte[] bytes = Bytes.toArray(glassidlist);
         System.out.println("outmesidbytes:" + bytes.length);
         S7control.getinstance().WriteByte(address, bytes);// 娲惧彂鍑虹墖id
+
     }
 
     // 鑾峰彇鍦板潃鍐呯殑鐜荤拑id杞瓧绗︿覆
@@ -305,19 +379,20 @@
     // 鏍规嵁鐜荤拑id瀹屾垚鍦ㄨ繘琛屼腑鐨勪换鍔�
     public void overtask(String glassid) {
 
-        spianMapper.UpdatetaskOut(glassid);// 瀹屾垚涓婁竴娆� 鍑虹墖鎴栬�呰繘鐗囦换鍔�
-        spianMapper.OverOutSlice(glassid, 2);// 瀹屾垚鍑虹墖闃熷垪浠诲姟
-        spianMapper.UpdataGlassCage(glassid, 0);// 娓呴櫎鍑虹墖鏍煎瓙鐜荤拑淇℃伅
-        spianMapper.UpdateCageOver(glassid, 0);// 鏇存敼绗煎瓙琛ㄥ嚭鐗囩姸鎬�
-        spianMapper.UpdateCageadd(glassid, 1);// 鏇存敼绗煎瓙琛ㄨ繘鐗囩姸鎬�
-        String barcode = spianMapper.SelectBarcode(glassid);// 鑾峰彇璇ョ幓鐠冪殑閾濇id
-        spianMapper.UpdateAddQueue(glassid);// 鎶婅繘鐗囩殑鐜荤拑鏇存柊鍒板嚭鐗囬槦鍒椾腑
-        if (barcode != null) {
-            int barcodeState = spianMapper.SelectOverState(barcode);// 鑾峰彇璇ラ摑妗嗙殑鐘舵��
-            if (barcodeState == 2) {// 褰撹閾濇鎵�鏈夌殑鐜荤拑閮芥槸瀹屾垚鐘舵�佹椂鍒犻櫎鍦ㄥ嚭鐗囬槦鍒楃殑鏁版嵁
-                spianMapper.DeleteQueue(barcode);
-            }
-        }
+        spianMapper.UpdatetaskOut(glassid.toString());// 瀹屾垚涓婁竴娆� 鍑虹墖鎴栬�呰繘鐗囦换鍔�
+        spianMapper.OverOutSlice(glassid.toString(), 2, 1);// 瀹屾垚鍑虹墖闃熷垪浠诲姟
+        spianMapper.UpdataGlassCage(glassid.toString(), 0);// 娓呴櫎鍑虹墖鏍煎瓙鐜荤拑淇℃伅
+        spianMapper.UpdateCageOver(glassid.toString(), 0);// 鏇存敼绗煎瓙琛ㄥ嚭鐗囩姸鎬�
+        spianMapper.UpdateCageadd(glassid.toString(), 1);// 鏇存敼绗煎瓙琛ㄨ繘鐗囩姸鎬�
+        String barcode = spianMapper.SelectBarcode(glassid.toString());// 鑾峰彇璇ョ幓鐠冪殑閾濇id
+        spianMapper.UpdateAddQueue(glassid.toString());// 鎶婅繘鐗囩殑鐜荤拑鏇存柊鍒板嚭鐗囬槦鍒椾腑
+        // if (barcode != null) {
+        // int barcodeState = spianMapper.SelectOverState(barcode);// 鑾峰彇璇ラ摑妗嗙殑鐘舵��
+        // if (barcodeState == 0) {// 褰撹閾濇鎵�鏈夌殑鐜荤拑閮芥槸瀹屾垚鐘舵�佹椂鍒犻櫎鍦ㄥ嚭鐗囬槦鍒楃殑鏁版嵁
+        // spianMapper.DeleteQueue(barcode);
+        // }
+        // }
 
     }
+
 }

--
Gitblit v1.8.0