From 331e7fc1b8f332ccecb8e9af59a826d6ae80ba10 Mon Sep 17 00:00:00 2001
From: 严智鑫 <test>
Date: 星期一, 18 三月 2024 08:23:24 +0800
Subject: [PATCH] 更新

---
 springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java |  256 ++++++++++++++-------------------------------------
 1 files changed, 70 insertions(+), 186 deletions(-)

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 a849080..26ef695 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
@@ -1,20 +1,15 @@
 package com.example.springboot.component;
-
-import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
-
-import java.io.IOException;
 import java.sql.SQLException;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-
 import com.example.springboot.service.*;
+
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.example.springboot.entity.Glass;
+import com.example.springboot.entity.GlassInfo;
+import com.example.springboot.entity.MeasureSetting;
 import com.example.springboot.entity.Out_slice;
 import com.example.springboot.entity.Queue;
 import com.example.springboot.entity.StorageCage;
@@ -22,17 +17,26 @@
 import com.example.springboot.entity.north_glass_buffer1;
 import com.example.springboot.entity.device.PlcParameterObject;
 import com.example.springboot.mapper.HomeMapper;
+import com.example.springboot.mapper.GlassInfoMapper;
+import com.example.springboot.mapper.MeasureSettingMapper;
+import com.example.springboot.mapper.QueueMapper;
 import com.example.springboot.mapper.SpianMapper;
 
 public class Plchome extends Thread {
 
     @Autowired
     private HomeMapper homeMapper;
+    @Autowired
+    private HomeService HomeService;
+    private QueueMapper QueueMapper;
+    private GlassInfoMapper GlassInfoMapper;
+    private MeasureSettingMapper MeasureSettingMapper;
     private OutSliceServive outSliceServive;
     private SpianMapper spianMapper;
     private SpianService spianService;
     private North_Glass_Buffer1Service north_Glass_Buffer1Service;
     private JdbcConnections dbserve;
+    
     // 鍑虹墖闃熷垪鏄惁鍏佽鍑虹墖
     public static Boolean isAllowQueue = true;
     public static Boolean isAllowReordering = true;
@@ -64,6 +68,8 @@
             try {
                 Thread.sleep(1000);
                 // 娉ㄥ叆mapper
+                HomeService  = WebSocketServer.applicationContext.getBean(HomeService.class);
+                QueueMapper  = WebSocketServer.applicationContext.getBean(QueueMapper.class);
                 homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class);
                 spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
                 spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
@@ -94,11 +100,6 @@
                 List<alarmmg> alarmmg = homeMapper.SelectAlarmmgInfo();
                 jsonObject.append("alarmmg", alarmmg);
 
-                // 浼� 鑾峰彇杩涙槸鍚︽湁寰呯‘璁ょ殑鐜荤拑id
-                String queid = spianMapper.Selectqueueid();
-                int state = spianMapper.Selectqueuestate();
-                jsonObject.append("queid", queid);
-                jsonObject.append("state", state);
                 // 鑾峰彇鎵爜浣嶄笌涓婄墖浣嶇幓鐠冧俊鎭�
                 Queue form2 = homeMapper.GetQueueInfo(2);
                 Queue form3 = homeMapper.GetQueueInfo(1);
@@ -122,187 +123,70 @@
                 // 鏌ヨ褰撳墠閾濇淇℃伅
                 Out_slice CurrentFrame = outSliceServive.SelectCurrentFrame();
                 jsonObject.append("CurrentFrame", CurrentFrame);
+              
+                //璇诲彇DB105鍖烘枃浠�
+                PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
+      
+                //String PlcRequest=plcmes.getPlcParameter("GaToMES").getValue();//璇锋眰
+                //double width=plcmes.getPlcParameter("Height").getValue();//瀹�
+                //double height=plcmes.getPlcParameter("width").getValue();//楂�
+                //鑾峰彇娴嬮噺鐨勯暱锛屽
+                String url="C:\\Users\\SNG-ZDH-012\\Desktop\\闃垮皵宸村凹浜氭暟鎹姹�.xlsx";
+                //List typecount= HomeService.ReadExecl2(s);
+                // List xiaopian=HomeService.ReadExecl2(s);
+                // //xiaopian   NG1{A:10,B20}   NG2{A:5,B5}
+                // for(Object C:xiaopian){
+                //     //鐪嬪眰鏁�
+                // }
 
+                // for(int i=0;i<result.size();i++){
+                //     System.out.println(result.get(i));
+                // }
+
+
+                List result= HomeService.ReadExecl(url);
+                for(int i=0;i<result.size();i++){
+                    System.out.println(result.get(i));
+                }
+
+
+
+                String PlcRequest = "1";
+                double width = 402;
+                double height = 402;
+                
+                //鑾峰彇鍖归厤璁剧疆
+                if ("1".equals(PlcRequest)) {
+                    List<GlassInfo> Result=HomeService.NormalGlassInfo(width, height, "1");
+                    if(Result.size()==1){
+                        //鍖归厤鎴愬姛  灏变竴绉嶇被鍨�  娣诲姞鏁版嵁
+                        GlassInfo GlassInfo=Result.get(0);
+                        QueueMapper.insert(GlassInfo.getGlassid(),width,height,1);
+                        System.out.println("鍖归厤鎴愬姛");
+                        //S7control.getinstance().WriteWord(plcmes.getPlcParameter("GaToMES").getAddress(), (short) 1);
+                        System.out.println(GlassInfo.getGlassid());
+                    }else if(Result.size()>1){
+                        //鍖归厤澶辫触 鍖归厤鍒板鏉$鍚堢殑鏁版嵁  娣诲姞鏁版嵁
+                        QueueMapper.insert(null,width,height,2);
+                        System.out.println("鍖归厤澶辫触");
+                    }
+                    else{
+                        //鍖归厤澶辫触 鏈壘鍒扮鍚堢殑鏁版嵁 娣诲姞鏁版嵁
+                        QueueMapper.insert(null,width,height,3);
+                        System.out.println("鏈壘鍒扮鍚堢殑鏁版嵁");
+                    }
+                    
+                }
                 // String E01id = new String( S7controlLK.getinstance().ReadByte("DB17.0",16));
                 // String J01id = new String( S7controlLK.getinstance().ReadByte("DB17.22",14));
 
-                if (S7control.getinstance().CheckConnected() == true) {
-
-                    // 閾濇绾夸氦浜�
-                    if (S7controlLK.getinstance().CheckConnected() == true) {
-                        if (CurrentFrame != null) {
-                            S7controlLK.getinstance().writeStrings(CurrentFrame.getBarCode(), "DB17.0");
-                        }
-                        String E01id = S7controlLK.getinstance().readStrings("DB17.0");
-                        String J01id = S7controlLK.getinstance().readStrings("DB17.22");
-
-                        List<Short> liststates = S7controlLK.getinstance().ReadWord("DB17.38", 1);
-                        List<Short> liststate = S7controlLK.getinstance().ReadWord("DB17.20", 1);
-                        Short framerequest = liststate.get(0);
-                        if (framerequest == 1) {
-                            // 閾濇id
-                            String position;
-                            try {
-                                position = dbserve.SelectPositionByFrameBarcode(J01id);
-                            } catch (SQLException e) {
-                                // TODO Auto-generated catch block
-                                position = "0";
-                                e.printStackTrace();
-                            }
-                            Short send;
-                            if (position.equals("0")) {
-                                send = 0;
-                            } else {
-                                send = 1;
-                            }
-                            S7controlLK.getinstance().WriteWord("DB17.38", (short) send);
-                        }
-                    }
-
-                    // 鑾峰彇褰撳墠鎵爜鏂瑰紡
-                    List<Boolean> Scanningmethods = S7control.getinstance().ReadBits("DB101.11.4", 1);
-                    if (Scanningmethods != null) {
-                        for (Boolean Scanningmethod : Scanningmethods) {
-                            jsonObject.append("Scanningmethod", Scanningmethod);
-                        }
-                    }
-                    // 鑾峰彇褰撳墠鎵爜鏋幓鐠僫d
-                    String CurrrentGlassId = spianService.queGlassid("DB103.256", 14).toString();
-                    jsonObject.append("CurrrentGlassId", CurrrentGlassId);
-
-                    // 鑾峰彇D01-D06,A01,A02,B01,B02鐘舵��
-                    List<Short> DeviceList = S7control.getinstance().ReadWord("DB103.0", 10);
-                    jsonObject.append("DeviceList", DeviceList);
-                    // 鑾峰彇D01-D06,A01,A02,B01,B02鐜荤拑id
-                    List<String> GlassIdList = new ArrayList<String>();
-                    GlassIdList.add(spianService.queGlassid("DB103.44", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.58", 14).toString());
-
-                    GlassIdList.add(spianService.queGlassid("DB103.184", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.212", 14).toString());
-
-                    GlassIdList.add(spianService.queGlassid("DB103.128", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.142", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.156", 14).toString());
-
-                    GlassIdList.add(spianService.queGlassid("DB103.72", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.86", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.100", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.114", 14).toString());
-                    jsonObject.append("GlassIdList", GlassIdList);
-
-                    // 鑾峰彇Plc杩涚墖杞︿笌鍑虹墖杞︿綅缃�
-                    List<String> addressList = new ArrayList<String>();
-                    addressList.add("DB106.12");
-                    addressList.add("DB106.0");
-                    List<Short> paramlist = S7control.getinstance().ReadWord(addressList);
-                    if (paramlist != null) {
-                        jsonObject.append("params", paramlist);
-                    }
-                    // // 鑾峰彇杩涚墖杞︾姸鎬�
-                    // List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8",
-                    // 1);// 鑾峰彇杩涚墖杞︾姸鎬�
-                    // if (datas1ListState != null) {
-                    // boolean exist1 = datas1ListState.contains((short) 0);
-                    // jsonObject.append("zhuangtai", exist1);
-                    // }
-
-                    // // 鑾峰彇杩涚墖鐜荤拑淇℃伅
-                    // List<Short> inglassInfo = S7control.getinstance().ReadWord("DB106.24", 1);
-                    // if (inglassInfo != null) {
-                    // if (inglassInfo.size() > 0) {
-                    // jsonObject.append("loadglassheight", inglassInfo.get(0) * 70);
-                    // }
-                    // }
-                    // // 鑾峰彇閾濇idDB106.DBW64锛屾坊鍔犲埌鍑虹墖闃熷垪
-                    // String frameno="X21763329601FB";
-                    String frameno = spianService.queGlassid("DB103.270", 14).toString();
-                    if (!frameno.equals(Plchome.FrameNo)) {
-                        Plchome.FrameNo = frameno;
-                        try {
-                            Short num = 0;
-                            List<north_glass_buffer1> north_glass_buffer1s = north_Glass_Buffer1Service
-                                    .SelectAluminumFrameInfoById(Plchome.FrameNo);
-                            for (north_glass_buffer1 north_glass_buffer1 : north_glass_buffer1s) {
-                                if (north_glass_buffer1.getstorageCage() == null) {
-                                    break;
-                                }
-                                num++;
-                            }
-                            if (num == north_glass_buffer1s.size()) {
-                                north_Glass_Buffer1Service.AddOutSliceS(Plchome.FrameNo);
-                            } else {
-                                Plchome.AluminumFrame = north_glass_buffer1s;
-                            }
-                        } catch (SQLException e) {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
-                        }
-                    }
-                    if (AluminumFrame != null) {
-                        jsonObject.append("AluminumFrame", AluminumFrame);
-                    }
-
-                    // 澶嶄綅鍊掕鏃�
-                    // 鍦板潃104.9.6
-                    List<Boolean> countdown = S7control.getinstance().ReadBits("DB104.9.6", 1);
-                    for (Boolean countdowns : countdown) {
-                        jsonObject.append("countdown", countdowns);
-                    }
-                    // jsonObject.append("countdown", true);
-                    // 澶嶄綅瀹屾垚淇″彿
-                    List<Boolean> resetss = S7control.getinstance().ReadBits("DB103.284", 1);
-                    for (Boolean reset : resetss) {
-                        jsonObject.append("reset", reset);
-                    }
-
-                    // 鏄惁鎬ュ仠
-                    List<Boolean> emergencystops = S7control.getinstance().ReadBits("DB104.5.1", 1);
-                    for (Boolean emergencystop : emergencystops) {
-                        jsonObject.append("emergencystop", emergencystop);
-                    }
-                    // 鑾峰彇杩涚墖璇锋眰鐘舵��
-                    List<Short> D01Request = S7control.getinstance().ReadWord("DB106.24", 1);
-                    boolean D01RequestState = D01Request.contains((short) 1);
-                    jsonObject.append("D01RequestState", D01RequestState);
-
-                    // 鑾峰彇杩涚墖鍙戦�佺姸鎬�
-                    List<Short> D01respnse = S7control.getinstance().ReadWord("DB106.16", 1);
-                    boolean D01ResponseState = D01respnse.contains((short) 1);
-                    // jsonObject.append("D01RequestState", D01RequestState);
-                    // 鑷姩杩涚墖
-                    isConfirm = true;
-                    if (isConfirm == true && form3.getglassId() != null && form3.getglassId() != "") {
-                        if ((form3.getglassheight() < 380 || form3.getglasswidth() < 390
-                                || form3.getglassheight() > 1810
-                                || form3.getglasswidth() > 2760)
-                                || (form3.getglassheight() < 390 || form3.getglasswidth() < 380
-                                        || form3.getglassheight() > 2760 || form3.getglasswidth() > 1810)) {
-                            FeedState = true;
-                            jsonObject.append("FeedState", FeedState);
-                            FeedState = false;
-                        } else {
-                            if (D01RequestState == true && D01ResponseState != true) {
-                                storageCageService.InsertQueueGlassId((short) 1, form3);
-                            }
-                        }
-                    }
-
-                }
+                
 
             } catch (InterruptedException e) {
                 e.printStackTrace();
             }
 
-            boolean dbconnected = false;
-            try {
-                dbserve.getConn();
-                dbconnected = true;
-            } catch (Exception e) {
-                // TODO: handle exception
-                dbconnected = false;
-            }
-            jsonObject.append("dbconnected", dbconnected);
+            
             // jsonObject.append("params", new short[] { 30, 40, });
             ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Home");
             if (sendwServer != null) {

--
Gitblit v1.8.0