| | |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.engineering.entity.Engineering; |
| | | import com.mes.engineering.service.EngineeringService; |
| | | import com.mes.opctask.entity.LoadGlassDeviceTask; |
| | | import com.mes.opctask.service.LoadGlassDeviceTaskService; |
| | | import com.mes.pp.service.OptimizeProjectService; |
| | | import com.mes.tools.DateUtil; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.uppattenusage.entity.UpPattenUsage; |
| | | import com.mes.uppattenusage.service.UpPattenUsageService; |
| | | import com.mes.utils.RedisUtil; |
| | | import com.mes.workstation.entity.UpWorkstation; |
| | | import com.mes.workstation.service.UpWorkstationService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | private UpPattenUsageService upPattenUsageService; |
| | | @Autowired |
| | | private OptimizeProjectService optimizeProjectService; |
| | | |
| | | @Autowired |
| | | RedisUtil redisUtil; |
| | | @Resource |
| | | private LoadGlassDeviceTaskService loadGlassDeviceTaskService; |
| | | |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | |
| | | private static final String LOAD_GLASS_DEVICE_ONE_TASK = "load_glass_device_one_task"; |
| | | |
| | | private static final String LOAD_GLASS_DEVICE_TWO_TASK = "load_glass_device_two_task"; |
| | | |
| | | /** |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void plcLoadGlassTask() throws InterruptedException { |
| | | try { |
| | | //获取联机状态 |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void plcLoadGlassReport() { |
| | | //获取是否有汇报 |
| | | String loadStatus = plcParameterObject.getPlcParameter("PlcStatus").getValue(); |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void loadGlassHome() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在进行的任务 |
| | | List<UpPattenUsage> upPattenUsages = upPattenUsageService.prioritylist(); |
| | | if(upPattenUsages!=null){ |
| | | jsonObject.append("prioritylist", upPattenUsages); |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在进行的任务 |
| | | List<UpPattenUsage> upPattenUsages = upPattenUsageService.prioritylist(); |
| | | if(upPattenUsages!=null){ |
| | | jsonObject.append("prioritylist", upPattenUsages); |
| | | } |
| | | //查询1号线的任务 |
| | | Engineering request = redisUtil.getCacheObject("loadGlassRequest"); |
| | | if (request == null) { |
| | | request = new Engineering(); |
| | | request.setStationCell(5); |
| | | } |
| | | List<UpPattenUsage> upPattenUsages1 = upPattenUsageService.selectLoadTask(request); |
| | | jsonObject.append("loadTask1", upPattenUsages1); |
| | | //查询2号线的任务 |
| | | Engineering request2 = redisUtil.getCacheObject("loadGlassRequest2"); |
| | | if (request2 == null) { |
| | | request2 = new Engineering(); |
| | | request2.setStationCell(6); |
| | | } |
| | | List<UpPattenUsage> upPattenUsages2 = upPattenUsageService.selectLoadTask(request2); |
| | | jsonObject.append("loadTask2", upPattenUsages2); |
| | | // 查询工位任务 |
| | | //联机状态 |
| | | LoadGlassDeviceTask LoadOneState = loadGlassDeviceTaskService.queryTaskMessage(LOAD_GLASS_DEVICE_ONE_TASK); |
| | | LoadGlassDeviceTask LoadTwoState = loadGlassDeviceTaskService.queryTaskMessage(LOAD_GLASS_DEVICE_TWO_TASK); |
| | | jsonObject.append("LoadOneState", LoadOneState.getInkageState()); |
| | | jsonObject.append("LoadTwoervice", LoadTwoState.getInkageState()); |
| | | |
| | | //工位信息 |
| | | List<UpWorkstation> upWorkstations = upWorkstationService.list(); |
| | | jsonObject.append("list", upWorkstations); |
| | | |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("loadGlass"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | // } |
| | | } else { |
| | | log.info("loadGlass is closed"); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | //工位信息 |
| | | List<UpWorkstation> upWorkstations = upWorkstationService.list(); |
| | | jsonObject.append("list", upWorkstations); |
| | | //是否开始工程 |
| | | Engineering engineering = engineeringService.selectInitiate(1); |
| | | jsonObject.append("engineering", engineering); |
| | | } |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("loadGlass"); |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void send() { |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("mainMes"); |
| | | if (sendwServer != null) { |
| | | //推送服务器当前时间 |
| | | JSONObject jsonObject = new JSONObject(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | jsonObject.append("globalDate", sdf.format(DateUtil.getEndDate())); |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | // List<String> messages = webserver.getMessages(); |
| | | // if (!messages.isEmpty()) { |
| | | // // // 将最后一个消息转换为整数类型的列表 |
| | | // webserver.clearMessages(); |
| | | // } |
| | | } else { |
| | | log.info("Home is closed"); |
| | | log.info("mainMes is closed"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 5000) |
| | | // @Scheduled(fixedDelay = 5000) |
| | | public void loadGlassStatus() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在进行的任务 |
| | |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | } else { |
| | | log.info("Home is closed"); |
| | | log.info("loadGlass is closed"); |
| | | } |
| | | } |
| | | } |
| | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void loadGlassIsRun() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //是否开始工程 |
| | | Engineering engineering = engineeringService.selectInitiate(1); |
| | | if (engineering != null){ |
| | | jsonObject.append("engineering", engineering); |
| | | }else { |
| | | jsonObject.append("engineering", "0"); |
| | | } |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("IsRun"); |
| | | //工位信息 |
| | | List<UpWorkstation> upWorkstations = upWorkstationService.list(); |
| | | jsonObject.append("list", upWorkstations); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("loadGlassIsRun"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | } else { |
| | | log.info("Home is closed"); |
| | | log.info("loadGlassIsRun is closed"); |
| | | } |
| | | } |
| | | } |