From c1d88895501846c4ad1ba2b16f4a8ae10ca2b061 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期二, 26 三月 2024 15:32:35 +0800
Subject: [PATCH] 代码更新

---
 springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

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 7b49fa8..e259214 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
@@ -8,7 +8,6 @@
 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;
@@ -21,6 +20,10 @@
      //璇诲彇DB105鍖烘枃浠�
     private PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
 public Short selectAll(GlassInfo glassInfo) {
+    if(glassInfo==null){
+        //鏈夎繘鐗囪姹備絾鏄祴閲忓彴娌℃湁鐜荤拑
+        return 400;
+    }
     //瀹氫箟鍒濆瀛楁
     int cageid;
     String glassid=glassInfo.getGlassid();
@@ -36,6 +39,8 @@
     //濡傛灉鏈夊悓绫诲瀷鏃剁洿鎺ュ鍔�
     if(cageid!=Integer.MIN_VALUE){
         //鍙戦�乸lc浠诲姟
+        Mestast(glassid, 1001, cageid, 1,"MESID1");
+        //浠诲姟鍙戦�佸瓧
         //Mestast(glassid,1001,cageid,1);
         
     }else{ 
@@ -48,7 +53,7 @@
         }
         //褰撹繑鍥炵殑鏍煎瓙鍙蜂负绌烘椂,杩斿洖400绗煎瓙宸叉弧
         if(cageid!=Integer.MIN_VALUE){
-            Mestast(glassid,1001,cageid,1);
+            Mestast(glassid,1001,cageid,1,"MESID1");
             //鍙戦�乸lc浠诲姟
             
         }else{
@@ -72,27 +77,32 @@
            
             for(int i=1;i<=7;i++){
                 glassmate= albaniaMapper.SelectOutGlass(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);
+                  if(glass!=null){
                     //鍙戦�侀厤鐗囨暟鎹�
-                    Mestast(glassmate.getGlasstype()+"i", glass.getId(),2002, 0);
+                    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){
+                      if(tier==sumid){//褰撻厤鐗囨暟閲忕瓑浜庢垚鍝佸皬鐗囨�荤墖鏁版椂
                         //鏈閰嶇墖瀹屾垚鍙戦�佸惎鍔ㄥ懡浠�
                         S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)2);//鍑虹墖浠诲姟鍚姩
                         return (200);//缁撴潫
+                         }
                     }
+                    
                 
+                }
             }
-           
-     
-       
         return(200);// 缁撴潫
     }
 
@@ -107,8 +117,12 @@
             glassidlist.add((byte) iditem);
         }
         byte[] bytes = Bytes.toArray(glassidlist);
+        //writeString
         System.out.println("outmesidbytes:" + bytes.length);
-        S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(),bytes);
+        System.out.println(plcmes.getPlcParameter(address).getAddress());
+        System.out.println();
+        
+        //S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(),bytes);
         //S7control.getinstance().WriteByte(address, bytes);// 娲惧彂鍑虹墖id
 
     }
@@ -146,15 +160,14 @@
     }
 
     //涓嬪彂鐞嗙墖浠诲姟
-    public void Mestast(String glassid,int MESToPLCStart1,int MESToPLCTarget1,int MESToPLC) {
-        outmesid(glassid, "MESID1");//涓嬪彂鐜荤拑id
+    public void Mestast(String glassid,int MESToPLCStart1,int MESToPLCTarget1,int MESToPLC,String address) {
+        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);//鐩爣浣嶇疆
         if(MESToPLC!=0){
             S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)MESToPLC);//mes鐞嗙墖浠诲姟绫诲瀷
-        }
-        
-        
+        }    
     }
 
+
 }

--
Gitblit v1.8.0