From 70f2265af5c8ec078ef2a7be65dd7229ab5f2924 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期一, 17 六月 2024 10:49:08 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/Albania_Mes

---
 springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java |  344 ++++++++++++++++++++------------------------------------
 1 files changed, 125 insertions(+), 219 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..67c767e 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,38 +1,41 @@
 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.FlowCard;
+import com.example.springboot.entity.FlowCard;
+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;
+import com.example.springboot.entity.StorageTask;
 import com.example.springboot.entity.alarmmg;
 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;
+    @Autowired
+    private GlassInfoMapper glassInfoMapper;
+    private QueueMapper QueueMapper;
     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;
@@ -57,30 +60,40 @@
 
     // public static Map b=new HashMap<>();
     // b.put()
+    public double carstart = 200;
+    public double carend = 20000;
+
     @Override
     public void run() {
+
         while (this != null) {
             JSONObject jsonObject = new JSONObject();
             try {
-                Thread.sleep(1000);
+                Thread.sleep(500);
                 // 娉ㄥ叆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);
                 outSliceServive = WebSocketServer.applicationContext.getBean(OutSliceServive.class);
-                north_Glass_Buffer1Service = WebSocketServer.applicationContext
-                        .getBean(North_Glass_Buffer1Service.class);
                 storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class);
-                dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
+                glassInfoMapper = WebSocketServer.applicationContext.getBean(GlassInfoMapper.class);
 
+                // 鑾峰彇鍏惰溅鐨勪綅缃�
+                if (S7control.getinstance().CheckConnected() == true&&false) {
+                    double carposition = 0;
+                    float car = S7control.getinstance().readFloat32("DB10.1992");
+                    carposition = (-40 + (car / (carend - carstart) * 595));
+                    jsonObject.append("carposition", carposition);
+                }
                 // 绗煎瓙浣跨敤鎯呭喌
-                List<StorageCage> tableData = homeMapper.selectAll();
+                List<StorageCage> tableData = homeMapper.selectAlls();
                 jsonObject.append("tableData", tableData);
+
                 // 鏍肩悊鐗囩鏍煎瓙鐘舵��
-                List<StorageCage> cagelist1 = homeMapper.selectRack1();
-                List<StorageCage> cagelist2 = homeMapper.selectRack2();
-                List<StorageCage> cagelist3 = homeMapper.selectRack3();
-                List<StorageCage> cagelist4 = homeMapper.selectRack4();
+                List<StorageCage> cagelist1 = storageCageService.SelectStorageCageByCage(1);
+                List<StorageCage> cagelist2 = storageCageService.SelectStorageCageByCage(2);
+                List<StorageCage> cagelist3 = storageCageService.SelectStorageCageByCage(3);
+                List<StorageCage> cagelist4 = storageCageService.SelectStorageCageByCage(4);
                 jsonObject.append("cagelist1", cagelist1);
                 jsonObject.append("cagelist2", cagelist2);
                 jsonObject.append("cagelist3", cagelist3);
@@ -94,20 +107,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);
-                if (form2.getglassId() != null && form2.getglassId() != "") {
-                    jsonObject.append("form2", form2);
-                }
-                if (form3.getglassId() != null && form3.getglassId() != "") {
-                    jsonObject.append("form3", form3);
-                }
                 // 鑾峰彇鍑虹墖闃熷垪淇℃伅
                 List<Out_slice> listoutslice = outSliceServive.SelectProductionqueue();
                 jsonObject.append("listoutslice", listoutslice);
@@ -123,204 +122,111 @@
                 Out_slice CurrentFrame = outSliceServive.SelectCurrentFrame();
                 jsonObject.append("CurrentFrame", CurrentFrame);
 
+                // 璇诲彇DB105鍖烘枃浠�
+                PlcParameterObject plcmes = PLCAutoMes.PlcMesObject;
+                // if(plcmes.==null){
+
+                // }
+
+                // 鑾峰彇娴嬮噺鐨勯暱锛屽
+                boolean istest = true;
+                // String PlcRequest = "1";
+                // String MesSend = "0";
+                // double width = 0;
+                // double height = 0;
+
+                // 鍖归厤
+                // System.err.println(PlcRequest+","+MesSend+","+width+","+height);
+                // if (plcmes.getPlcParameter("GaToMES").getValue() != null) {
+                // 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());// 楂�
+                // if ("0".equals(PlcRequest) && istest) {
+                // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),
+                // (short) 0);
+                // }
+                // if ("1".equals(PlcRequest) && "0".equals(MesSend)) {
+                // boolean is = HomeService.Normal(width, height, "1");
+                // if (is && istest) {
+                // // 娴嬮噺鎴愬姛
+                // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),
+                // (short) 1);
+
+                // } else if (istest) {
+                // // 閲嶆柊娴嬮噺
+                // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),
+                // (short) 4);
+                // }
+                // }
+                // }
+
+                // S7control.getinstance().WriteWord("DB14.170", (short)0);
+
+                // 姝e湪涓婄墖璁㈠崟涓殑鎵�鏈夊皬鐗囦俊鎭�   
+                List<GlassInfo> glassInfoFlowCard = glassInfoMapper.selectOrderState(1);
+                jsonObject.append("glassInfoFlowCard", glassInfoFlowCard);
+
+                Queue LastQueue = QueueMapper.selectLastQueue();
+                if (LastQueue == null) {
+                    Queue nullQueue = new Queue();
+                    nullQueue.setglassId("");
+                    nullQueue.setglassheight(0);
+                    nullQueue.setglasswidth(0);
+                    nullQueue.setglassheightmm(0);
+                    nullQueue.setglasstype(0);
+                    nullQueue.setglasswidthmm(0);
+                    jsonObject.append("LastQueue", nullQueue);
+                } else {
+                    if (LastQueue.getstate() < 1) {
+                        LastQueue.setglasswidth(0);
+                        LastQueue.setglassheight(0);
+                    }
+                    jsonObject.append("LastQueue", LastQueue);
+                }
                 // 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) {
+                // 鏌ヨ鐞嗙墖绗间俊鎭�
+                List<StorageCage> StorageCageInfo = storageCageService.SelectStorageCageInfo();
+                jsonObject.append("StorageCageInfo", StorageCageInfo);
 
-                    // 閾濇绾夸氦浜�
-                    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<StorageTask> StoragTaskeTaskFeed = storageCageService.SelectStorageTask(0);
+                jsonObject.append("StoragTaskeTaskFeed", StoragTaskeTaskFeed);
 
-                        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<StorageTask> StoragTaskeTaskOut = storageCageService.SelectStorageTask(1);
+                jsonObject.append("StoragTaskeTaskOut", StoragTaskeTaskOut);
 
-                    // 鑾峰彇褰撳墠鎵爜鏂瑰紡
-                    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);
+                // //鏌ヨ褰撳墠璁㈠崟浠诲姟
+                List<FlowCard> OrderTask = storageCageService.SelectOrderTask();
+                jsonObject.append("OrderTask", OrderTask);
 
-                    // 鑾峰彇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());
+                // jsonObject.append("params", new short[] { 30, 40, });
+                // System.out.println("jsonObject:" + jsonObject);
+                ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Home");
+                if (sendwServer != null) {
+                    for (WebSocketServer webserver : sendwServer) {
+                        webserver.sendMessage(jsonObject.toString());
 
-                    GlassIdList.add(spianService.queGlassid("DB103.184", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.212", 14).toString());
+                        if (webserver != null) {
 
-                    GlassIdList.add(spianService.queGlassid("DB103.128", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.142", 14).toString());
-                    GlassIdList.add(spianService.queGlassid("DB103.156", 14).toString());
+                            List<String> messages = webserver.getMessages();
 
-                    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);
+                            if (!messages.isEmpty()) {
+                                // // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛�
+                                webserver.clearMessages();
                             }
                         }
-                    }
 
+                    }
                 }
 
             } 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) {
-                for (WebSocketServer webserver : sendwServer) {
-                    webserver.sendMessage(jsonObject.toString());
-
-                    if (webserver != null) {
-
-                        List<String> messages = webserver.getMessages();
-
-                        if (!messages.isEmpty()) {
-                            // // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛�
-                            webserver.clearMessages();
-                        }
-
-                    }
-
-                }
             }
         }
     }

--
Gitblit v1.8.0