| | |
| | | package com.mes.job; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.mes.temperingglass.service.TemperingAgoService; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.tools.WebSocketServer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | public class PlcTemperingGlassTask { |
| | | |
| | | @Autowired |
| | | private TemperingAgoService temperingAgoService; |
| | | private TemperingGlassInfoService temperingAgoService; |
| | | /** |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | |
| | | //获取整在炉中的两个版图id |
| | | List<TemperingGlassInfo> layoutId = temperingAgoService.selectLayoutId(); |
| | | //进炉中的玻璃 |
| | | List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0).getTemperingLayoutId()); |
| | | jsonObject.append("intoGlass", intoGlass); |
| | | //进炉中的第二个版图 |
| | | if (layoutId.size() > 1) { |
| | | List<TemperingGlassInfo> intoGlass2 = temperingAgoService.selectIntoGlass(layoutId.get(1).getTemperingLayoutId()); |
| | | jsonObject.append("intoGlass2", intoGlass2); |
| | | if(!layoutId.isEmpty()) { |
| | | List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0)); |
| | | jsonObject.append("intoGlass", intoGlass); |
| | | //进炉中的第二个版图 |
| | | if (layoutId.size() > 1) { |
| | | List<TemperingGlassInfo> intoGlass2 = temperingAgoService.selectIntoGlass(layoutId.get(1)); |
| | | jsonObject.append("intoGlass2", intoGlass2); |
| | | } |
| | | } |
| | | //出炉后的玻璃 |
| | | List<TemperingGlassInfo> outGlass = temperingAgoService.selectOutGlass(); |
| | | jsonObject.append("outGlass", outGlass); |
| | | //过旋转台钢化后的玻璃 |
| | | List<TemperingGlassInfo> overGlass = temperingAgoService.selectOverGlass(); |
| | | |
| | | jsonObject.append("overGlass", overGlass); |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingGlass"); |
| | |
| | | } |
| | | } |
| | | } |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void temperingIsRun(){ |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在进行的任务 |
| | | List<TemperingGlassInfo>temperingTaskType=temperingAgoService.selectTaskType(); |
| | | jsonObject.append("temperingTaskType", temperingTaskType); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("isRun"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | } else { |
| | | log.info("Home is closed"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |