From 6db39c1dfb1dca966983652e4360672cb58a96f6 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期日, 31 三月 2024 12:40:45 +0800
Subject: [PATCH] 代码更新

---
 springboot-vue3/src/main/java/com/example/springboot/mapper/AlbaniaMapper.java             |   18 ++-
 Albania_Mes-ui/src/views/home/index.vue                                                    |   15 ++-
 springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java             |   93 ++++++++++++------
 springboot-vue3/src/main/java/com/example/springboot/entity/GlassInfo.java                 |    1 
 springboot-vue3/src/main/java/com/example/springboot/entity/glassinfo.java                 |    1 
 springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java                |   30 ++++--
 springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java                |    2 
 springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java       |   10 +
 springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java           |   28 +----
 springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java |    3 
 springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterInfo.java   |    6 +
 springboot-vue3/src/main/resources/application.properties                                  |    4 
 springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java          |   84 +++++++++-------
 13 files changed, 177 insertions(+), 118 deletions(-)

diff --git a/Albania_Mes-ui/src/views/home/index.vue b/Albania_Mes-ui/src/views/home/index.vue
index 76e5c23..e8888ea 100644
--- a/Albania_Mes-ui/src/views/home/index.vue
+++ b/Albania_Mes-ui/src/views/home/index.vue
@@ -521,10 +521,10 @@
                 <div style="width:1000px;height: 720px;border: 2px solid #d1d1d1;">
                     <!--鐜荤拑鍥�  #81b337-->
                     <div :style="'top:10px;bottom: 10px;left: 10px;right: 10px;margin:auto auto;position:absolute;width:'
-                        + (this.LastQueue.glasswidth / 25 * 7) + 'px;height:'
-                        + (this.LastQueue.glassheight / 25 * 7) + 'px;line-height: '
-                        + (this.LastQueue.glassheight / 25 * 7) + 'px;background-color: #93d2f3;text-align: center;'">
-                        {{ this.LastQueue.glasswidth }}*{{ this.LastQueue.glassheight }}
+                        +(this.LastQueue.glasswidth==null?0:(this.LastQueue.glasswidth / 25 * 7)) + 'px;height:'
+                        + (this.LastQueue.glassheight==null?0:(this.LastQueue.glassheight / 25 * 7)) + 'px;line-height: '
+                        + (this.LastQueue.glassheight==null?0:(this.LastQueue.glassheight / 25 * 7)) + 'px;background-color: #93d2f3;text-align: center;'">
+                        {{(this.LastQueue.glasswidth==null?0: this.LastQueue.glasswidth) }}*{{ (this.LastQueue.glassheight==null?0:this.LastQueue.glassheight) }}
                     </div>
 
                 </div>
@@ -1071,13 +1071,16 @@
             })
         },
         Change(event) {
+            
             // 鑾峰彇鍒版枃浠跺す
             let fileList = event.target.files;
             // 濡傛灉鏁版嵁涓嶄负绌�
             if (fileList) {
+                
                 // FileReader鏄竴绉嶅紓姝ユ枃浠惰鍙栨満鍒讹紝缁撳悎input:file鍙互寰堟柟渚跨殑璇诲彇鏈湴鏂囦欢銆�
                 let reader = new FileReader();
                 let file = fileList[0]; //鎷垮埌绗竴鏉℃暟鎹�
+                
                 reader.readAsBinaryString(file)// 灏嗘枃浠朵互浜岃繘鍒跺舰寮忚鍏ラ〉闈�
                 let _this = this //鎶奷ata閲岀殑鏁版嵁璧嬪�肩粰鏂扮殑鍙橀噺
                 // wb:wordbook 宸ヤ綔琛�  
@@ -1088,13 +1091,15 @@
                     let sheetName = wb.SheetNames[0]; //鏄幏鍙朣heets涓涓�涓猄heet鐨勫悕瀛�
                     let sheets = wb.Sheets[sheetName];
                     let dataList2 = JSON.stringify(XLSX.utils.sheet_to_json(sheets));
+                    //alert(dataList2);
                     let dataList3 = (JSON.parse(dataList2));
                     _this.dataList = dataList3;//璧嬪��
                     //console.log(dataList2);  
-                    console.log(dataList3);
+                    //console.log(dataList3);
 
                 })
             }
+            
         },
         Add() {
 
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 513af57..5cc729d 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,25 +1,21 @@
 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.SpianServiceNew;
-import com.example.springboot.entity.north_glass_buffer1;
+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.AlbaniaMapper;
-import com.example.springboot.mapper.SpianMapper;
+
 
 public class PlcHoldNew extends Thread {
 
   private AlarmMapper alarmMapper;
 
   @Autowired
-  private JdbcConnections jdbcConnections;
   private AlbaniaMapper albaniaMapper;
   private SpianServiceNew spianService;
+  private StorageCageService storageCageService;
   int aaa;
 
   @Override
@@ -33,63 +29,94 @@
         // \\ TODO Auto-generated catch block
         e.printStackTrace();
       }
-     
+
+      
+      storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class);
       spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class);
       albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class);
-      //spianService.selectAll(albaniaMapper.SelectGlass());
+      
       //璇诲彇DB14鍖烘枃浠�
       PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
-      
+      if(plcmes.getPlcParameter("PLCToMES").getValue()!=null){
+        
+      // spianService.Mestast("1234567890123",40,0,2,"MESID1");
+      // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)2);//鍑虹墖浠诲姟鍚姩
     
       String ExportTOMES1=plcmes.getPlcParameter("ExportTOMES1").getValue();//鍑虹墖璇锋眰涓�绾�
       String ExportToMES2=plcmes.getPlcParameter("ExportToMES2").getValue();//鍑虹墖璇锋眰浜岀嚎
-      String PLCToMES=plcmes.getPlcParameter("PLCToMES").getValue();//杩涚墖璇锋眰
-      String B01State=plcmes.getPlcParameter("B01State").getValue();//杩愰�佽溅璇锋眰
-      String TastState=plcmes.getPlcParameter("MESToPLCStatus1").getValue();//浠诲姟瀹屾垚
-  
+      String PLCToMES=plcmes.getPlcParameter("PLCToMES").getValue();//杩愰�佽溅璇锋眰
+      //String B01State=plcmes.getPlcParameter("B01State").getValue();//杩愰�佽溅璇锋眰
+      String IDStatus1=plcmes.getPlcParameter("IDStatus1").getValue();//1鍙蜂换鍔″畬鎴�
+      String MESToPLCStatus1=plcmes.getPlcParameter("MESToPLCStatus1").getValue();//1鍙风‘璁ゅ瓧
       
       //涓�鍙风嚎璇锋眰
-      if (ExportTOMES1.equals("1") == true&&B01State.equals("0")==true) {
+      if(ExportTOMES1!=null){
+      if (ExportTOMES1.equals("1") == true&&PLCToMES.equals("1")==true) {
         //灏嗚繍杈撹溅鐘舵�佹敼涓哄繖纰�
-        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
         spianService.selectout(1);
       }
+    }
       // //浜岀嚎鍙疯姹傛椂
-      if (ExportToMES2.equals("1") == true&&B01State.equals("0")==true) {
+      if(ExportToMES2!=null ){
+      if (ExportToMES2.equals("1") == true&&PLCToMES.equals("1")==true) {
         //灏嗚繍杈撹溅鐘舵�佹敼涓哄繖纰�
         S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
         spianService.selectout(2);
       }
+    }
       //杩涚墖璇锋眰鏃�
-      if(PLCToMES!=null && B01State!=null){
-      if(PLCToMES.equals("1")==true&&B01State.equals("0")==true){
-        //灏嗚繍杈撹溅鐘舵�佹敼涓哄繖纰�
-        //S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
-        
-        spianService.selectAll(albaniaMapper.SelectGlass());
+      GlassInfo glass=albaniaMapper.SelectGlass();
+      if(PLCToMES!=null && glass!=null){
+      if(PLCToMES.equals("1")==true&&glass!=null){        
+        spianService.selectAll(glass);
       }
+    }
     
 
       //浠诲姟瀹屾垚鏃�
-      if(TastState.equals("1")==true){
-        
+      if(IDStatus1.equals("1")==true && MESToPLCStatus1.equals("0")==true){
         //瀹屾垚纭瀛�
         for(int i=1;i<7;i++){
-          String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//渚濇鑾峰彇浠诲姟绫诲瀷
-          String Glassid=plcmes.getPlcParameter("MESID"+i).getValue();//渚濇鑾峰彇浠诲姟绫诲瀷
+          
+          String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//PLC鐞嗙墖浠诲姟鐘舵�佹眹鎶�
+          String Glassid=plcmes.getPlcParameter("MESID"+i).getValueString();//MES鐜荤拑ID
+          
+          GlassInfo id=albaniaMapper.SelectTaskId(Glassid);
           if(Tastover.equals("1")){
-
-            //璋冪敤瀹屾垚浠诲姟 Glassid
-            S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//瀹屾垚纭瀛�
+            if(id!=null){
+              //璋冪敤瀹屾垚浠诲姟 Glassid
+              storageCageService.FinishTask(id.getId());
+            }    
+              S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short) 0);//娓呴櫎浠诲姟瀛�
+              S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//瀹屾垚纭瀛�
+             
+            }
+          
+          
+          
+        }
+      }
+      //姹囨姤鍙栨秷鏃�
+      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("IDStatus"+i).getAddress(), (short) 0);//娓呴櫎纭瀛�
+            S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 0);//娓呴櫎纭瀛�
+            // System.out.println(plcmes.getPlcParameter("MESToPLCStatus1").getValue());
+            // System.out.println(S7control.getinstance().ReadWord("DB14.158", 1));
           }
         }
       }
-    }
+    
+  }
   
       // 鏌ヨ鏁版嵁搴�
       // 鎺ㄩ�佸埌鍓嶇
 
-      // }
+    
     }
   }
 
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
index 592c4b3..113e5ad 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -116,10 +116,10 @@
                 //璇诲彇DB105鍖烘枃浠�
                 PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
       
-                // String PlcRequest=plcmes.getPlcParameter("GaToMES").getValue();//璇锋眰
-                // String MesSend=plcmes.getPlcParameter("MESToGaStatus").getValue();//鍙戦��
-                // double width=Double.valueOf(plcmes.getPlcParameter("Height").getValue());//瀹�
-                // double height=Double.valueOf(plcmes.getPlcParameter("width").getValue());//楂�
+                String PlcRequest=plcmes.getPlcParameter("GaToMES").getValue();//璇锋眰
+                String MesSend=plcmes.getPlcParameter("MESToGaStatus").getValue();//鍙戦��
+                double width=Double.valueOf(plcmes.getPlcParameter("width").getValue());//瀹�
+                double height=Double.valueOf(plcmes.getPlcParameter("Height").getValue());//楂�
 
                 // String PlcRequest=S7control.getinstance().ReadWord("DB14.26", 1).get(0)+"";
                 // double width=Double.parseDouble(S7control.getinstance().ReadWord("DB14.28", 1).get(0)+"");
@@ -127,11 +127,11 @@
                 // String MesSend=S7control.getinstance().ReadWord("DB14.170", 1).get(0)+"";
 
                 //鑾峰彇娴嬮噺鐨勯暱锛屽
-                boolean istest = false;
-                String PlcRequest = "1";
-                String MesSend = "0";
-                double width = 402;
-                double height = 402;
+                 boolean istest = true;
+                // String PlcRequest = "1";
+                // String MesSend = "0";
+                // double width = 402;
+                // double height = 402;
                 
                 //鍖归厤
                 //System.err.println(PlcRequest+","+MesSend+","+width+","+height);
@@ -150,11 +150,21 @@
                     }
 
                 }
+                 //S7control.getinstance().WriteWord("DB14.170", (short)0);
                 Queue LastQueue= QueueMapper.selectLastQueue();
+                if(LastQueue==null){
+                    Queue nullQueue=new Queue();
+                    nullQueue.setglassId("");
+                    nullQueue.setglassheight(0);
+                    nullQueue.setglasswidth(0);
+                    jsonObject.append("LastQueue", nullQueue);
+                }else{
+                    jsonObject.append("LastQueue", LastQueue);
+                }
                 // String E01id = new String( S7controlLK.getinstance().ReadByte("DB17.0",16));
                 // String J01id = new String( S7controlLK.getinstance().ReadByte("DB17.22",14));
 
-                jsonObject.append("LastQueue", LastQueue);
+                
                 //鏌ヨ鐞嗙墖绗间俊鎭�
                 List<StorageCage> StorageCageInfo = storageCageService.SelectStorageCageInfo();
                 jsonObject.append("StorageCageInfo", StorageCageInfo);
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 d71b64f..dc4a9d0 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
@@ -16,29 +16,11 @@
         // TODO Auto-generated method stub
         //
         System.out.println("鍚姩瀹屾垚");
-        //new PLCAutoMes().start();
-        // new PlcHold().start();
-        //new PlcHoldNew().start();
+        new PLCAutoMes().start();
+        
+         new PlcHoldNew().start();
 
-        new Plchome().start();
-        // new PlcLayout().start();
-        // new Plcalarm().start();
-        // new Plcsign().start();
-        // new Plcstate().start();
-        // new PlcPositioning1().start();
-        // new PlcParameter2().start();
-        // new PLCAutomaticParameterSetting().start();
-
-        // new PlcManualonePosition().start();
-        // new PlcManualonePosition2().start();
-        // new PlcServoManualone().start();
-        // new PLCManualJog().start();
-        // new Plclog().start();
-
-        // new PlcInteractionState().start();
-        // new PlcParameter1Review().start();
-        // new PLCAutomaticParameterSettingReview2().start();
-
-        // new PLCManualJogReview().start();
+         new Plchome().start();
+       
     }
 }
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/entity/GlassInfo.java b/springboot-vue3/src/main/java/com/example/springboot/entity/GlassInfo.java
index 9a1653b..1c5e3af 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/entity/GlassInfo.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/entity/GlassInfo.java
@@ -23,4 +23,5 @@
   private Integer sumtier;// 瀹屾垚鏁伴噺
   private Integer measurenumber;// 娴嬮噺瀹屾垚鏁伴噺
   private Integer cageno;//绗煎唴鏁伴噺
+  private Integer method;//鍑虹墖鏂瑰紡
 }
diff --git a/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterInfo.java b/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterInfo.java
index dacfd4c..51d6ddf 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterInfo.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterInfo.java
@@ -1,4 +1,7 @@
 package com.example.springboot.entity.device;
+
+import com.example.springboot.component.S7control;
+
 public  class PlcParameterInfo {
       public PlcParameterInfo(String startAddress) {
         this.startAddress = startAddress;
@@ -122,6 +125,9 @@
 
         return addressIndex;
     }
+    public String getValueString() {
+        return S7control.getinstance().readStrings(getAddress());
+    }
     public String getAddress() {
        return getAddress(this.addressIndex);
     }
diff --git a/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java b/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
index dec12e4..a3113fc 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
@@ -97,6 +97,8 @@
     }
 
 
+
+
     public List<String> getAddressListByCodeId(List<String> codeIdList) {
         List<String> addressList = new ArrayList<>();
         for (String codeId : codeIdList) {
@@ -154,6 +156,7 @@
                       plcParameterInfo.setValue(String.valueOf(byte2short(valueList)));
                 }
                 else if (plcParameterInfo.getAddressLength()==14) {
+                    String id=(byteToHexString(valueList));
                     plcParameterInfo.setValue((byteToHexString(valueList)));
                 }
 
diff --git a/springboot-vue3/src/main/java/com/example/springboot/entity/glassinfo.java b/springboot-vue3/src/main/java/com/example/springboot/entity/glassinfo.java
index 9a1653b..1c5e3af 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/entity/glassinfo.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/entity/glassinfo.java
@@ -23,4 +23,5 @@
   private Integer sumtier;// 瀹屾垚鏁伴噺
   private Integer measurenumber;// 娴嬮噺瀹屾垚鏁伴噺
   private Integer cageno;//绗煎唴鏁伴噺
+  private Integer method;//鍑虹墖鏂瑰紡
 }
diff --git a/springboot-vue3/src/main/java/com/example/springboot/mapper/AlbaniaMapper.java b/springboot-vue3/src/main/java/com/example/springboot/mapper/AlbaniaMapper.java
index fb02810..0a746cf 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/mapper/AlbaniaMapper.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/mapper/AlbaniaMapper.java
@@ -13,10 +13,10 @@
 public interface AlbaniaMapper  {
     //鍒ゆ柇绗煎唴鏄惁鏈夊悎閫傜殑绫诲瀷绌烘牸
     @Select("select id from storage_cage where glasstype=#{glasstype} and width>=#{width}+#{widths} and state=0 and disabled=0 order by id limit 1")
-    int SelectCage(int glasstype,Double width,int widths);
+    StorageCage SelectCage(int glasstype,Double width,int widths);
     //鍒ゆ柇绗煎唴娌℃湁鐜荤拑鐨勭┖鏍�
     @Select("select id from storage_cage where number=0 and cage>#{cage} and cage<#{cage2} and disabled=0 order by id limit 1")
-    int SelectNewCell(int cage,int cage2);
+    StorageCage SelectNewCell(int cage,int cage2);
     //澧炲姞鐜荤拑鏁�
     @Update("update storage_cage set number=number+1,width=width-glasswidth where id=#{id}")
     void UpdateCageNumberAdd(int id);
@@ -28,9 +28,9 @@
     void Inserttask(int tasktype, int taskstate, int shelfrack, int loadrack, String glassid, int glasstype,String flowcard,int mateid,int tier);
     //鏂板涓�鏉$瀛愭暟鎹�
     @Update("UPDATE `albania`.`storage_cage` SET `glass_id` =#{glassid}, `width` =width-#{glasswidth}, `glasswidth` =#{glasswidth}, `glassheight` =#{glassheight}, `glasswidthmm` =#{glasswidthmm}, `glassheightmm` = #{glassheightmm},  `state` = #{state}, `glasstype` = #{glasstype}, `number` = #{number} WHERE `id` =#{id};")
-    void AddCage(int id,String glassid,Double glasswidth,Double glassheight,Double glasswidthmm,Double glassheightmm,int state,int glasstype,int number);
+    void AddCage(int id,String glassid,Double glasswidth,Double glassheight,Double glasswidthmm,Double glassheightmm,int state,String glasstype,int number);
     //鑾峰彇杩涚墖鏁版嵁
-    @Select("select glassid,flowcard,glasswidth as width,glassheight as height,glasswidthmm,glassheightmm,glasstype from queue where state=1 limit 1")
+    @Select("select glassid,flowcard,glasswidth as width,glassheight as height,glasswidthmm,glassheightmm,glasstype,thickness  from queue where state=1 limit 1")
     GlassInfo SelectGlass();
     //涓�鍙风嚎鏌ヨ浠诲姟
     @Select("select * from v_cagerelease1 where mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid);")
@@ -48,11 +48,17 @@
     @Update("update glassinfo set finishnumber=finishnumber+1 where flowcard=#{flowcard} and mateid=#{mateid} and tier=#{tier};")
     void AddFinishNumber(String flowcard,int mateid,int tier);
     //鑾峰彇褰撳墠浠诲姟鐨刬d
-    @Select("select id from storage_task where state=0 glassid=#{glassid} LIMIT 1")
-    int SelectTaskId(String glassid);
+    @Select("select id from storage_task where task_state=0 and glass_id=#{glassid} LIMIT 1")
+    GlassInfo SelectTaskId(String glassid);
     //鍒犻櫎娴嬮噺琛ㄧ殑淇℃伅
     @Delete("delete from queue where glassid=#{glassid}")
     int DeleteQueue(String glassid);
+    //鍒ゆ柇鏄惁鏄洿鍑烘ā寮�
+    @Select("select method from flowcard where state=1 and line=#{line} ORDER BY starttime LIMIT 1;")
+    GlassInfo SelectMethod(int line);
+    //鐩村嚭妯″紡浠诲姟鏌ヨ
+    @Select("select b.flowcard,b.glasstype,b.mateid,a.totaltier as id from flowcard a  left join glassinfo b on a.flowcard=b.flowcard where a.line=#{line}")
+    GlassInfo SelectOutGlass2(int line);
 
 
 
diff --git a/springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java b/springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java
index e7e6bb2..3446eb8 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java
@@ -262,7 +262,7 @@
   StorageCage SelectStorageByCell(String cell);
 
   // 鎵嬪姩瀹屾垚浠诲姟
-  @Select("update storage_task set task_state=1 where id=1429")
+  @Select("update storage_task set task_state=1 where id=#{id}")
   void FinishTask(Integer id);
 
   @Select("select gi.* from glassinfo gi inner join flowcard fc on gi.flowcard=fc.flowcard where fc.state!=2 and position(#{width} in gi.width) and position(#{height} in gi.height) and position(#{thickness} in gi.thickness) and position(#{films} in gi.films) group by gi.id")
diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java b/springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java
index e259214..6b18551 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java
@@ -25,35 +25,33 @@
         return 400;
     }
     //瀹氫箟鍒濆瀛楁
-    int cageid;
+    StorageCage cage;
     String glassid=glassInfo.getGlassid();
     Double width=glassInfo.getWidth();
     //int mateid=glassInfo.getMateid();
     String flowcard=glassInfo.getFlowcard();
     int glasstype=glassInfo.getGlasstype();
-    
-    
-
     //鍒ゆ柇鏄惁鏈夊悓绫诲瀷鐨�
-     cageid=albaniaMapper.SelectCage(glasstype,width, 50);
+    cage=albaniaMapper.SelectCage(glasstype,width, 50);
+     
     //濡傛灉鏈夊悓绫诲瀷鏃剁洿鎺ュ鍔�
-    if(cageid!=Integer.MIN_VALUE){
+    if(cage!=null){
         //鍙戦�乸lc浠诲姟
-        Mestast(glassid, 1001, cageid, 1,"MESID1");
+        Mestast(glassid, 40, cage.getId(), 1,"MESID1",1);
         //浠诲姟鍙戦�佸瓧
-        //Mestast(glassid,1001,cageid,1);
         
     }else{ 
          //鍒ゆ柇鐜荤拑鏄惁杩涘叆澶х墖绗�
-        if(glassInfo.getThickness()>=15){
-            cageid=albaniaMapper.SelectNewCell(3,5);
+         if(glassInfo.getThickness()>=15){
+            cage=albaniaMapper.SelectNewCell(3,5);
         }else{
-            cageid=albaniaMapper.SelectNewCell(3,5);
+            cage=albaniaMapper.SelectNewCell(0,5);
             //鍙戦�乸lc浠诲姟
         }
         //褰撹繑鍥炵殑鏍煎瓙鍙蜂负绌烘椂,杩斿洖400绗煎瓙宸叉弧
-        if(cageid!=Integer.MIN_VALUE){
-            Mestast(glassid,1001,cageid,1,"MESID1");
+        if(cage!=null){
+            albaniaMapper.AddCage(cage.getId(), glassid, cage.getGlassWidth(), cage.getGlassHeight(), cage.getGlassWidthMm(), cage.getGlassHeightMm(), 1, cage.getGlasstype(), 0);
+            Mestast(glassid,1001,cage.getId(),1,"MESID1",1);
             //鍙戦�乸lc浠诲姟
             
         }else{
@@ -61,43 +59,55 @@
         }
     }
     //澧炲姞浠诲姟璁板綍
-    albaniaMapper.Inserttask(0, 0, 1001, cageid, glassid,glasstype, flowcard,0,0);
+    albaniaMapper.Inserttask(0, 0, 1001, cage.getId(), glassid,glasstype, flowcard,0,0);
     return(200);
 
 }
 
     //鍑虹墖
     public Short selectout(int line) {
-        int mateid;
-        int glasstype;
-        int tier;
-        int sumid;
-        String flowcard;
         GlassInfo glassmate=new GlassInfo();
-           
+        GlassInfo method=new GlassInfo();
+        StorageCage glass=new StorageCage();
+        method=albaniaMapper.SelectMethod(line);
+        double width=0;
             for(int i=1;i<=7;i++){
-                glassmate= albaniaMapper.SelectOutGlass(line);
+                //濡傛灉涓嶆槸鐩撮�氭ā寮忓彧鍑烘湁瀹屾暣閰嶇墖鐨勬祦绋嬪崱
+                if(method.getMethod()==0){
+                    glassmate= albaniaMapper.SelectOutGlass(line);
+                }else{
+                    //鐩撮�氭ā寮忔椂鎸夐『搴忕洿鍑�
+                    glassmate= albaniaMapper.SelectOutGlass2(line);
+                }
+                
                 if(glassmate==null){ 
                     //鏈鍙栦换鍔�
                     return (400);
                 }else{
-                mateid=glassmate.getMateid();
-                glasstype=glassmate.getGlasstype();
-                tier=glassmate.getTier();
-                sumid=glassmate.getId();
-                flowcard=glassmate.getFlowcard(); 
                     
-                    StorageCage glass= albaniaMapper.SelectCageGlass(glasstype);
+                    glass= albaniaMapper.SelectCageGlass(glassmate.getGlasstype()); 
                   if(glass!=null){
-                    //鍙戦�侀厤鐗囨暟鎹�
-                    Mestast(glassmate.getGlasstype()+"i", glass.getId(),2002, 0,"MESID"+i);
-                    albaniaMapper.AddFinishNumber(flowcard, mateid, tier);
-                    albaniaMapper.Inserttask(1, 0, glass.getId(), 2002, glassmate.getGlassid()+i, glasstype,glass.getFlowcard(),mateid,tier);
-                      if(tier==sumid){//褰撻厤鐗囨暟閲忕瓑浜庢垚鍝佸皬鐗囨�荤墖鏁版椂
+                    //鍙戦�佷换鍔′箣鍓嶅垽鏂溅涓婄殑鍓╀綑瀹藉害鏄惁澶т簬姝ょ幓鐠�
+                    width+=glassmate.getWidth()+50;
+                    //澶т簬杞︿笂绌轰綑瀹藉害鏃舵彁鍓嶅彂閫佸嚭鐗囧惎鍔�
+                    if(width>5000){
                         //鏈閰嶇墖瀹屾垚鍙戦�佸惎鍔ㄥ懡浠�
-                        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)2);//鍑虹墖浠诲姟鍚姩
+                        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)1);//鍑虹墖浠诲姟鍚姩
                         return (200);//缁撴潫
-                         }
+                      }
+                      
+                    //鍙戦�侀厤鐗囨暟鎹�
+                    Mestast(glass.getGlassId(), glass.getId(),7, 0,"MESID"+i,i);
+                    albaniaMapper.AddFinishNumber(glassmate.getFlowcard(), glassmate.getMateid(), glassmate.getTier());
+                    albaniaMapper.Inserttask(1, 0, glass.getId(), 2002, glassmate.getGlassid(), glassmate.getGlasstype(),glass.getFlowcard(),glassmate.getMateid(),glassmate.getTier());
+                      if(glassmate.getTier()==glassmate.getId()){//褰撻厤鐗囨暟閲忕瓑浜庢垚鍝佸皬鐗囨�荤墖鏁版椂
+                        //鏈閰嶇墖瀹屾垚鍙戦�佸惎鍔ㄥ懡浠�
+                        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)1);//鍑虹墖浠诲姟鍚姩
+                        return (200);//缁撴潫
+                      }
+                      
+                    }else{
+                        return (400);//缁撴潫
                     }
                     
                 
@@ -160,10 +170,10 @@
     }
 
     //涓嬪彂鐞嗙墖浠诲姟
-    public void Mestast(String glassid,int MESToPLCStart1,int MESToPLCTarget1,int MESToPLC,String address) {
+    public void Mestast(String glassid,int MESToPLCStart1,int MESToPLCTarget1,int MESToPLC,String address,int i) {
         S7control.getinstance().writeString(plcmes.getPlcParameter(address).getAddress(),glassid);//鐜荤拑id
-        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStart1").getAddress(), (short) MESToPLCStart1);//璧峰浣嶇疆
-        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCTarget1").getAddress(), (short) MESToPLCTarget1);//鐩爣浣嶇疆
+        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStart"+i).getAddress(), (short) MESToPLCStart1);//璧峰浣嶇疆
+        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCTarget"+i).getAddress(), (short) MESToPLCTarget1);//鐩爣浣嶇疆
         if(MESToPLC!=0){
             S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)MESToPLC);//mes鐞嗙墖浠诲姟绫诲瀷
         }    
diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java b/springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java
index ee61e88..18a8576 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java
@@ -319,6 +319,8 @@
         homeMapper.UpdateQueue(glassInfo.getFlowcard(), glassInfo.getWidth(), glassInfo.getHeight(),
                 glassInfo.getGlasstype());
         Map<String, Object> map = new HashMap<>();
+        PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
+        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1);
         map.put("message", "200");
         return Result.success(map);
     }
@@ -399,6 +401,7 @@
 
         System.out.println(RemoveErrorData.size());
         // 澶勭悊瀹屾垚 娣诲姞鏁版嵁搴�
+        int count=1;
         for (Map map : RemoveErrorData) {
             String key = map.get("base").toString() + "_" + map.get("height").toString() + "_"
                        + map.get("thickness").toString() + "_" + map.get("films").toString();
@@ -409,18 +412,23 @@
             Integer glasstype;
             if (TypeData.get(key) == null) {
                 glasstype = homeMapper.SelectMaxType();
+                if (glasstype==null) {
+                    glasstype=1;
+                }
             } else {
                 glasstype = Integer.valueOf(value);
             }
+            //
             homeMapper.AddGlassinfo(map.get("order").toString(), glasstype,
                     Integer.parseInt(map.get("matching").toString()) // 闇�瑕佽绠� 閰嶇墖ID
-                    , glasstype+"" // 闇�瑕佽绠� 鐜荤拑ID
+                    ,map.get("order").toString()+"-"+count+"" // 闇�瑕佽绠� 鐜荤拑ID
                     , Integer.parseInt(map.get("tier").toString()), map.get("films").toString(),
                     Double.parseDouble(map.get("base").toString()), Double.parseDouble(map.get("height").toString()),
                     Double.parseDouble(map.get("thickness").toString()),
                     Integer.parseInt(map.get("quantity").toString()),groupby.get(tierkey));// 闇�瑕佽绠楁�诲眰鏁�
             //璁㈠崟鍐呮�诲眰鏁�
             homeMapper.InsertFlowcard(map.get("order").toString(),OrderFinishedProduct.get(tierkey+"_Sum")); 
+            count++;
         }
         Map<String, Object> ResultCode = new HashMap<>();
         ResultCode.put("message", "200");
diff --git a/springboot-vue3/src/main/resources/application.properties b/springboot-vue3/src/main/resources/application.properties
index 01f54d2..bb1147e 100644
--- a/springboot-vue3/src/main/resources/application.properties
+++ b/springboot-vue3/src/main/resources/application.properties
@@ -6,8 +6,8 @@
 #\u6570\u636E\u5E93\u9A71\u52A8
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 #\u6570\u636E\u5E93\u8FDE\u63A5\u5730\u5740
-#spring.datasource.url=jdbc:mysql://localhost:3306/albania?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
-spring.datasource.url=jdbc:mysql://10.153.19.150:3306/albania?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+spring.datasource.url=jdbc:mysql://localhost:3306/albania?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+#spring.datasource.url=jdbc:mysql://10.153.19.150:3306/albania?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
 #\u6570\u636E\u5E93\u7528\u6237\u540D
 spring.datasource.username=root
 #\u6570\u636E\u5E93\u7528\u6237\u5BC6\u7801  

--
Gitblit v1.8.0