| | |
| | | package com.mes.common; |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import com.mes.downworkstation.service.DownGlassLogic; |
| | | |
| | | import com.mes.downworkstation.service.DownWorkstationService; |
| | | import com.mes.tools.WebSocketServer; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.Supplier; |
| | | |
| | | @Component |
| | | public class Plchome extends Thread { |
| | | private int i = 1; |
| | | private static final Logger log = LogManager.getLogger(Plchome.class); |
| | | @Autowired |
| | | private DownWorkstationService downWorkstationService; |
| | | |
| | | private final Supplier<DownGlassLogic> plcServiceSupplier; |
| | | // private final Supplier<DownGlassLogic> plcServiceSupplier; |
| | | |
| | | public Plchome() { |
| | | this.plcServiceSupplier = () -> WebSocketServer.applicationContext.getBean(DownGlassLogic.class); |
| | | } |
| | | // public Plchome() { |
| | | // this.plcServiceSupplier = () -> WebSocketServer.applicationContext.getBean(DownGlassLogic.class); |
| | | // } |
| | | |
| | | |
| | | @Override |
| | |
| | | while (!Thread.currentThread().isInterrupted()) { |
| | | try { |
| | | i++; |
| | | Thread.sleep(100); |
| | | DownGlassLogic plcService = plcServiceSupplier.get(); |
| | | // plcService.performPlcActions(); |
| | | //plcService.unloadpush(); |
| | | |
| | | //当下片任务表状态为1时候将数据插入到下片玻璃信息表 |
| | | plcService.insertdownglassinfo(); |
| | | |
| | | |
| | | //当机械手任务表中状态为1 更新已经落架数量,并且把下片任务表的那条记录删掉 工位表流程卡绑定了架子 |
| | | plcService.downWorkstation(); |
| | | Thread.sleep(1000); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | System.out.println(77); |
| | | downWorkstationService = WebSocketServer.applicationContext.getBean(DownWorkstationService.class); |
| | | List<Map<String, Object>> yy= downWorkstationService.getTotalGlassDimensionsByWorkstation(); |
| | | jsonObject.append("data", yy); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unloadglass"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | log.info("准备向 WebSocket 服务器发送消息: {}", jsonObject.toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } catch (InterruptedException e) { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // System.out.println(arraylist6); |
| | | jsonObject.append("data", 1); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unloadglass"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | log.info("准备向 WebSocket 服务器发送消息: {}", jsonObject.toString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |