From 6356c6e148c854bb60ba1cd51fafdabfa932efff Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期一, 18 三月 2024 08:29:05 +0800
Subject: [PATCH] 逻辑更新

---
 springboot-vue3/src/main/java/com/example/springboot/mapper/AlbaniaMapper.java    |   24 ++++
 springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java     |   68 ++++++------
 springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java |   79 +++++++++++----
 springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java    |   35 ++++--
 springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java    |   22 ++--
 springboot-vue3/src/main/java/com/example/springboot/entity/StorageTask.java      |   36 ++++++
 6 files changed, 176 insertions(+), 88 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
index a10c293..17fbf5a 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
@@ -33,39 +33,38 @@
         // \\ TODO Auto-generated catch block
         e.printStackTrace();
       }
-
+      
       // if (S7control.getinstance().CheckConnected() == false) {
       spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class);
       albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class);
-
+      spianService.selectAll(albaniaMapper.SelectGlass());
       //璇诲彇DB14鍖烘枃浠�
       PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
-    
-      //璇�103
+
       
       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 TastType=plcmes.getPlcParameter("TastType").getValue();//浠诲姟绫诲瀷
+  
       
-      //璋冪敤鍑虹墖浠诲姟
-      if (ExportTOMES1.equals("1") == false&&PLCToMES.equals("0")==true) {
+      //涓�鍙风嚎璇锋眰
+      if (ExportTOMES1.equals("1") == true&&B01State.equals("0")==true) {
         //灏嗚繍杈撹溅鐘舵�佹敼涓哄繖纰�
-        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1);
+        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
         spianService.selectout(1);
       }
-      //浜岀嚎璇锋眰鏃�
-      if (ExportToMES2.equals("1") == false&&PLCToMES.equals("0")==true) {
+      //浜岀嚎鍙疯姹傛椂
+      if (ExportToMES2.equals("1") == true&&B01State.equals("0")==true) {
         //灏嗚繍杈撹溅鐘舵�佹敼涓哄繖纰�
-        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1);
+        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
         spianService.selectout(2);
       }
-      //璋冪敤杩涚墖浠诲姟
+      //杩涚墖璇锋眰鏃�
       if(PLCToMES.equals("1")==true&&B01State.equals("0")==true){
         //灏嗚繍杈撹溅鐘舵�佹敼涓哄繖纰�
-        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1);
+        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
         
         spianService.selectAll(albaniaMapper.SelectGlass());
       }
@@ -73,7 +72,17 @@
 
       //浠诲姟瀹屾垚鏃�
       if(TastState.equals("1")==true){
+        
+        //瀹屾垚纭瀛�
+        for(int i=1;i<7;i++){
+          String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//渚濇鑾峰彇浠诲姟绫诲瀷
+          String Glassid=plcmes.getPlcParameter("MESID"+i).getValue();//渚濇鑾峰彇浠诲姟绫诲瀷
+          if(Tastover.equals("1")){
 
+            //璋冪敤瀹屾垚浠诲姟 Glassid
+            S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//瀹屾垚纭瀛�
+          }
+        }
       }
 
   
diff --git a/springboot-vue3/src/main/java/com/example/springboot/entity/StorageTask.java b/springboot-vue3/src/main/java/com/example/springboot/entity/StorageTask.java
index 76883ce..a9dacfe 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/entity/StorageTask.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/entity/StorageTask.java
@@ -1,5 +1,8 @@
 package com.example.springboot.entity;
+
+
 //鍑虹墖浠诲姟琛�
+
 public class StorageTask{
     private Integer id;//鑷簭
     private String taskType;//绫诲瀷
@@ -8,7 +11,10 @@
     private String shelfRack;//璧峰浣�
     private String loadrack;//鐩爣浣�
     private Integer count;//鐜荤拑鏁伴噺
-    
+    private Integer glasstype;//鐜荤拑绫诲瀷
+    private Integer flowcard;//娴佺▼鍗�
+    private Integer mateid;//閰嶇墖id
+    private Integer tier;//鐗囧簭
 
     public Integer id() {
         return id;
@@ -66,6 +72,32 @@
         this.loadrack = loadrack;
     }
 
-    
+    public Integer getGlasstype() {
+        return glasstype;
+    }
+ 
+    public void setGlasstype(Integer glasstype) {
+        this.glasstype = glasstype;
+    } 
+    public Integer getFlowcard() {
+        return flowcard;
+    }
+ 
+    public void setFlowcard(Integer flowcard) {
+        this.flowcard = flowcard;
+    } public Integer getMateid() {
+        return mateid;
+    }
+ 
+    public void setMateid(Integer mateid) {
+        this.mateid = mateid;
+    }
+    public Integer geTier() {
+        return tier;
+    }
+ 
+    public void setTier(Integer tier) {
+        this.tier = tier;
+    }
 
 }
\ No newline at end of file
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 f53c73e..84b1c7b 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
@@ -5,12 +5,13 @@
 import org.apache.ibatis.annotations.Update;
 import org.springframework.stereotype.Repository;
 import com.example.springboot.entity.GlassInfo;
+import com.example.springboot.entity.StorageCage;
 
 @Mapper
 @Repository
 public interface AlbaniaMapper  {
     //鍒ゆ柇绗煎唴鏄惁鏈夊悎閫傜殑绫诲瀷绌烘牸
-    @Select("select id from storage_cage where glasstype=#{glasstype} and width>=#{width}+#{widths}  order by id limit 1")
+    @Select("select id from storage_cage where glasstype=#{glasstype} and width>=#{width}+#{widths} and state=0  order by id limit 1")
     int SelectCage(int glasstype,Double width,int widths);
     //鍒ゆ柇绗煎唴娌℃湁鐜荤拑鐨勭┖鏍�
     @Select("select id from storage_cage where number=0 and cage>#{cage} and cage<#{cage2} order by id limit 1")
@@ -22,14 +23,29 @@
     @Update("update storage_cage set number=number-1,width=width+glasswidth where id=#{id}")
     void UpdateCageNumberOut(int id);
     //澧炲姞浠诲姟璁板綍
-    @Insert("INSERT INTO `canadames`.`storage_task`(`task_type`, `task_state`, `shelf_rack`, `load_rack`,start_time,glass_id,count,finsh_time) VALUES (#{tasktype},#{taskstate},#{shelfrack},#{loadrack},now(),#{glassid},#{count},#{qidong});")
-    void Inserttask(int tasktype, int taskstate, int shelfrack, int loadrack, String glassid, int count,int qidong);
+    @Insert("INSERT INTO `albania`.`storage_task`(`task_type`, `task_state`, `shelf_rack`, `load_rack`,start_time,glass_id,glasstype,flowcard,mateid,tier) VALUES (#{tasktype},#{taskstate},#{shelfrack},#{loadrack},now(),#{glassid},#{glasstype},#{flowcard},#{mateid},#{tier});")
+    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);
     //鑾峰彇杩涚墖鏁版嵁
-    @Select("select glassid,flowcard,glasswidth as width,glassheight as height,glasswidthmm,glassheightmm,glasstype from queue where glasstype=1")
+    @Select("select glassid,flowcard,glasswidth as width,glassheight as height,glasswidthmm,glassheightmm,glasstype from queue where state=0 limit 1")
     GlassInfo SelectGlass();
+    //涓�鍙风嚎鏌ヨ浠诲姟
+    @Select("select * from v_cagerelease1 where mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid);")
+    GlassInfo SelectOutGlass1();
+    //浜屽彿绾挎煡璇换鍔�
+    @Select("select * from v_cagerelease2 where mateid not in(select mateid from v_cagerelease2 where surplus=0 group by mateid)LIMIT 1;")
+    GlassInfo SelectOutGlass2();
+    //娴佺▼鍗′换鍔℃煡璇�
+    @Select("select G.flowcard,G.glasstype,G.number,G.mateid,G.tier,G.starttime,G.finishnumber,IF((G.number-G.finishnumber-ku.KuCount)<0,G.number,ku.KuCount) as 'surplus',G.totaltier as id from (select Gfd.flowcard,Ggf.glasstype,Ggf.number,Ggf.mateid,Ggf.tier,Ggf.finishnumber,Gfd.starttime,Gfd.totaltier  from flowcard as Gfd LEFT JOIN glassinfo as Ggf on Gfd.flowcard=Ggf.flowcard where Gfd.state=1 and Gfd.line=#{line}) as G left join (select glasstype,sum(number) AS KuCount from storage_cage where flowcard is not null group by glasstype) as ku on G.glasstype=ku.glasstype where G.mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid)order by `g`.`starttime`,`g`.`mateid`,`g`.`finishnumber`,`g`.`tier`LIMIT 1;")
+    GlassInfo SelectOutGlass(int line);
+    //鑾峰彇璇ョ被鍨嬪湪搴撳瓨鐨勪綅缃�
+    @Select("select * from storage_cage where glasstype=#{glasstype} and number>0 limit 1")
+    StorageCage SelectCageGlass(int glasstype);
+    //鍙戦�佸嚭鐗囧悗澧炲姞宸插彂鏁伴噺
+    @Update("update glassinfo set finishnumber=finishnumber+1 where flowcard=#{flowcard} and mateid=#{mateid} and tier=#{tier};")
+    void AddFinishNumber(String flowcard,int mateid,int tier);
     
 
 }
diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java b/springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java
index 452b8eb..2467976 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java
@@ -8,43 +8,43 @@
 
 import com.example.springboot.entity.GlassInfo;
 import com.example.springboot.entity.MeasureSetting;
-import com.example.springboot.mapper.GlassInfoMapper;
-import com.example.springboot.mapper.MeasureSettingMapper;
-import com.example.springboot.mapper.QueueMapper;
+// import com.example.springboot.mapper.GlassInfoMapper;
+// import com.example.springboot.mapper.MeasureSettingMapper;
+// import com.example.springboot.mapper.QueueMapper;
 
 @Service
 public class HomeService {
 
-    @Autowired
-    MeasureSettingMapper MeasureSettingMapper;
-    @Autowired
-    GlassInfoMapper GlassInfoMapper;
-    @Autowired
-    QueueMapper QueueMapper;
+    // @Autowired
+    // MeasureSettingMapper MeasureSettingMapper;
+    // @Autowired
+    // GlassInfoMapper GlassInfoMapper;
+    // @Autowired
+    // QueueMapper QueueMapper;
 
-    // 鍖归厤鐜荤拑 瀹斤紝楂橈紝绾胯矾
-    public List<GlassInfo> NormalGlassInfo(double width, double height, String line) {
-        //
-        List<GlassInfo> Results=new ArrayList<GlassInfo>();
-        // 鑾峰彇鍖归厤璁剧疆
-        MeasureSetting MeasureSetting = MeasureSettingMapper.SelectMeasureSetting(line);
-        if (height > 0 && width > 0 && MeasureSetting != null) {
-            // 鏈夋晥鍙傛暟 璇锋眰=1 闀�/瀹�>0
-            double maxheight = height + MeasureSetting.getErrorHeight();
-            double minheight = height - MeasureSetting.getErrorHeight();
-            double maxwidth = width + MeasureSetting.getErrorWidth();
-            double minwidth = width - MeasureSetting.getErrorWidth();
-            // 鏌ヨ褰撳墠娴嬮噺鏁版嵁
-            List<GlassInfo> GlassInfos = GlassInfoMapper.selectGlassInfos(maxwidth, minwidth, maxheight, minheight);
-            List types = new ArrayList<>();
-            for (int i = 0; i < GlassInfos.size(); i++) {
-                Integer glasstype = GlassInfos.get(i).getGlasstype();
-                if (!types.contains(glasstype)) {
-                    types.add(glasstype);
-                    Results.add(GlassInfos.get(i));
-                }
-            }
-        }
-        return Results;
-    }
+    // // 鍖归厤鐜荤拑 瀹斤紝楂橈紝绾胯矾
+    // public List<GlassInfo> NormalGlassInfo(double width, double height, String line) {
+    //     //
+    //     List<GlassInfo> Results=new ArrayList<GlassInfo>();
+    //     // 鑾峰彇鍖归厤璁剧疆
+    //     MeasureSetting MeasureSetting = MeasureSettingMapper.SelectMeasureSetting(line);
+    //     if (height > 0 && width > 0 && MeasureSetting != null) {
+    //         // 鏈夋晥鍙傛暟 璇锋眰=1 闀�/瀹�>0
+    //         double maxheight = height + MeasureSetting.getErrorHeight();
+    //         double minheight = height - MeasureSetting.getErrorHeight();
+    //         double maxwidth = width + MeasureSetting.getErrorWidth();
+    //         double minwidth = width - MeasureSetting.getErrorWidth();
+    //         // 鏌ヨ褰撳墠娴嬮噺鏁版嵁
+    //         List<GlassInfo> GlassInfos = GlassInfoMapper.selectGlassInfos(maxwidth, minwidth, maxheight, minheight);
+    //         List types = new ArrayList<>();
+    //         for (int i = 0; i < GlassInfos.size(); i++) {
+    //             Integer glasstype = GlassInfos.get(i).getGlasstype();
+    //             if (!types.contains(glasstype)) {
+    //                 types.add(glasstype);
+    //                 Results.add(GlassInfos.get(i));
+    //             }
+    //         }
+    //     }
+    //     return Results;
+    // }
 }
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 2988da2..4d665ce 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
@@ -92,13 +92,13 @@
                 ids = cages1.getId();// 鏁版嵁搴揑D
                 tiers = cages1.getTier();// 鍐呭鐗�
                 cells = cages1.getCell();// 鏍煎瓙鍙�
-                prcid = cages1.getPrcId();// 浼犵粰prc鐨勭洰鏍囧湴id
+                //prcid = cages1.getPrcId();// 浼犵粰prc鐨勭洰鏍囧湴id
                 width = cages1.getWidth();// 鏍煎瓙鍓╀綑瀹藉害
                 widths = glasslist.getglasslengthmm();
 
                 // 鎵ц杩涚墖
                 datas.add((short) 1000);// 璧峰浣嶇疆
-                datas.add((short) prcid);// 鐩爣浣嶇疆
+                datas.add((short) 1);// 鐩爣浣嶇疆
                 datas.add((short) widths);// 杩涚墖鐜荤拑瀹�
                 datas.add((short) prctier); // 鐜荤拑鏁�
                 datas.add((short) 1);// 浠诲姟鍚姩
@@ -171,7 +171,7 @@
         int cage = cageout.getCage(); // 鍌ㄥ瓨鍑虹墖浣嶇疆锛岀瀛愭牸瀛愬嚑鍙风幓鐠�
         int cell = cageout.getCell();// 鍑虹墖鏍煎彿
         int tier = cageout.getTier();// 鍑虹墖鍐呭鐗�
-        int prcid = cageout.getPrcId();// prcid
+        //int prcid = cageout.getPrcId();// prcid
         int prcid2;
         int ids;
         int cages;
@@ -183,7 +183,7 @@
             int state = spianMapper.selectGlassState(cage, cell);// 鑾峰彇鏍煎瓙鏁伴噺
             // 鍒ゆ柇鐜荤拑鍙洿鎺ュ嚭鐗囨椂
             // 淇敼鏁版嵁搴撶瀛愯〃(鍑虹墖)
-            datas.add((short) prcid);
+            datas.add((short) 1);
             datas.add((short) 1000);
             datas.add((short) state);
             datas.add((short) 1);
@@ -214,7 +214,7 @@
             // 鍒ゆ柇鍐呯墖鏄惁闇�瑕佽皟鎷�
             if (state == 1) {
                 // spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 3);
-                datas.add((short) prcid);
+                datas.add((short) 1);
                 datas.add((short) 1000);
                 datas.add((short) 1);
                 datas.add((short) 1);
@@ -248,14 +248,14 @@
                         return (300);
                     }
                     // 鑾峰彇璋冩嫧浣嶇疆杩涜璋冩嫧
-                    prcid2 = cagecell.getPrcId();// 璋冩嫧鐩爣浣峆RCID
+                    //prcid2 = cagecell.getPrcId();// 璋冩嫧鐩爣浣峆RCID
                     ids = cagecell.getId();// 璋冩嫧鐩爣浣岻D
                     cages = cagecell.getCage();// 璋冩嫧鐩爣浣嶇瀛�
                     cells = cagecell.getCell();// 璋冩嫧鐩爣浣嶆牸瀛�
 
                     // 濉叆璋冩嫧鏁版嵁
-                    datas.add((short) prcid);// 璋冩嫧澶栫墖璧峰浣嶇疆
-                    datas.add((short) prcid2);
+                    datas.add((short) 1);// 璋冩嫧澶栫墖璧峰浣嶇疆
+                    datas.add((short) 1);
                     datas.add((short) 2);
                     datas.add((short) 1);
                     // 鏇存崲鐜荤拑鐨勭瀛�
@@ -290,13 +290,13 @@
                         return (300);
                     }
                     // 鑾峰彇璋冩嫧浣嶇疆杩涜璋冩嫧
-                    prcid2 = cagecell.getPrcId();// 璋冩嫧鐩爣浣峱rcID
+                    //prcid2 = cagecell.getPrcId();// 璋冩嫧鐩爣浣峱rcID
                     ids = cagecell.getId();// 璋冩嫧鐩爣浣岻D
                     cages = cagecell.getCage();// 璋冩嫧鐩爣浣嶇瀛�
                     cells = cagecell.getCell();// 璋冩嫧鐩爣浣嶆牸瀛�
                     // 濉叆璋冩嫧鏁版嵁
-                    datas.add((short) prcid);
-                    datas.add((short) prcid2);
+                    datas.add((short) 1);
+                    datas.add((short) 1);
                     datas.add((short) 2);
                     datas.add((short) 1);
                     String glassids = spianMapper.SelectGlassid(cage, cell); // 鑾峰彇琚皟鎷ㄧ殑鐜荤拑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 b9836fa..7b49fa8 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
@@ -7,6 +7,8 @@
 import com.example.springboot.component.PLCAutoMes;
 import com.example.springboot.component.S7control;
 import com.example.springboot.entity.GlassInfo;
+import com.example.springboot.entity.StorageCage;
+import com.example.springboot.entity.GlassInfo;
 import com.example.springboot.entity.device.PlcParameterObject;
 import com.example.springboot.mapper.AlbaniaMapper;
 import com.google.common.primitives.Bytes;
@@ -23,20 +25,20 @@
     int cageid;
     String glassid=glassInfo.getGlassid();
     Double width=glassInfo.getWidth();
-    Double height=glassInfo.getHeight();
+    //int mateid=glassInfo.getMateid();
+    String flowcard=glassInfo.getFlowcard();
     int glasstype=glassInfo.getGlasstype();
     
     
 
     //鍒ゆ柇鏄惁鏈夊悓绫诲瀷鐨�
-     cageid=albaniaMapper.SelectCage(glassInfo.getGlasstype(), glassInfo.getWidth(), 50);
+     cageid=albaniaMapper.SelectCage(glasstype,width, 50);
     //濡傛灉鏈夊悓绫诲瀷鏃剁洿鎺ュ鍔�
     if(cageid!=Integer.MIN_VALUE){
         //鍙戦�乸lc浠诲姟
+        //Mestast(glassid,1001,cageid,1);
         
-        //浠诲姟瀹屾垚鍚庡鍔犳暟閲�
-        albaniaMapper.UpdateCageNumberAdd(cageid);
-    }else{
+    }else{ 
          //鍒ゆ柇鐜荤拑鏄惁杩涘叆澶х墖绗�
         if(glassInfo.getThickness()>=15){
             cageid=albaniaMapper.SelectNewCell(3,5);
@@ -45,23 +47,51 @@
             //鍙戦�乸lc浠诲姟
         }
         //褰撹繑鍥炵殑鏍煎瓙鍙蜂负绌烘椂,杩斿洖400绗煎瓙宸叉弧
-        if(cageid==Integer.MIN_VALUE){
-            return(400);
+        if(cageid!=Integer.MIN_VALUE){
+            Mestast(glassid,1001,cageid,1);
+            //鍙戦�乸lc浠诲姟
+            
         }else{
-            //鍒ゆ柇瀹屾垚浠诲姟鍚庡鍔犳暟閲�
-            albaniaMapper.AddCage(cageid, glassid, width, height, width, height, 0, glasstype, 1);
+            return(400);
         }
     }
     //澧炲姞浠诲姟璁板綍
-    albaniaMapper.Inserttask(0, 0, 0, cageid, glassInfo.getGlassid(), 0, 0);
+    albaniaMapper.Inserttask(0, 0, 1001, cageid, 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();
+           
+            for(int i=1;i<=7;i++){
+                glassmate= albaniaMapper.SelectOutGlass(line);
+                mateid=glassmate.getMateid();
+                glasstype=glassmate.getGlasstype();
+                tier=glassmate.getTier();
+                sumid=glassmate.getId();
+                flowcard=glassmate.getFlowcard(); 
+   
+                    StorageCage glass= albaniaMapper.SelectCageGlass(glasstype);
+                    //鍙戦�侀厤鐗囨暟鎹�
+                    Mestast(glassmate.getGlasstype()+"i", glass.getId(),2002, 0);
+                    albaniaMapper.AddFinishNumber(flowcard, mateid, tier);
+                    albaniaMapper.Inserttask(1, 0, glass.getId(), 2002, glassmate.getGlassid()+i, glasstype,glass.getFlowcard(),mateid,tier);
+                    if(tier==sumid){
+                        //鏈閰嶇墖瀹屾垚鍙戦�佸惎鍔ㄥ懡浠�
+                        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)2);//鍑虹墖浠诲姟鍚姩
+                        return (200);//缁撴潫
+                    }
+                
+            }
+           
+     
        
         return(200);// 缁撴潫
     }
@@ -78,7 +108,7 @@
         }
         byte[] bytes = Bytes.toArray(glassidlist);
         System.out.println("outmesidbytes:" + bytes.length);
-        S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(plcmes.getPlcParameter(address).getAddressIndex()),bytes);
+        S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(),bytes);
         //S7control.getinstance().WriteByte(address, bytes);// 娲惧彂鍑虹墖id
 
     }
@@ -93,7 +123,7 @@
                 writedstrIdOut.append((char) iditem);
             }
         }
-        return writedstrIdOut;
+        return writedstrIdOut;  
     }
 
     // char鏁扮粍杞寲鎴恇it鏁扮粍
@@ -115,15 +145,16 @@
         return listbool;
     }
 
-    // 鏍规嵁鐜荤拑id瀹屾垚鍦ㄨ繘琛屼腑鐨勪换鍔�
-    public void overtask(String glassid) {
-
-        // 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);// 鏇存敼绗煎瓙琛ㄨ繘鐗囩姸鎬�
-        // spianMapper.UpdateAddQueue(glassid.toString());// 鎶婅繘鐗囩殑鐜荤拑鏇存柊鍒板嚭鐗囬槦鍒椾腑
+    //涓嬪彂鐞嗙墖浠诲姟
+    public void Mestast(String glassid,int MESToPLCStart1,int MESToPLCTarget1,int MESToPLC) {
+        outmesid(glassid, "MESID1");//涓嬪彂鐜荤拑id
+        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStart1").getAddress(), (short) MESToPLCStart1);//璧峰浣嶇疆
+        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCTarget1").getAddress(), (short) MESToPLCTarget1);//鐩爣浣嶇疆
+        if(MESToPLC!=0){
+            S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)MESToPLC);//mes鐞嗙墖浠诲姟绫诲瀷
+        }
+        
+        
     }
 
 }

--
Gitblit v1.8.0