| | |
| | | package com.mes.job; |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.common.S7object; |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.md.entity.LineConfiguration; |
| | | import com.mes.md.entity.Machine; |
| | | import com.mes.md.entity.PrimitiveTask; |
| | | import com.mes.md.entity.Tasking; |
| | | import com.mes.md.mapper.MachineMapper; |
| | | import com.mes.md.mapper.TaskingMapper; |
| | | import com.mes.md.service.PrimitiveTaskService; |
| | | import com.mes.md.service.TaskingService; |
| | | import com.mes.tools.WebSocketServer; |
| | |
| | | @Slf4j |
| | | public class PLCManualReporting { |
| | | |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | PlcParameterObject plcParameterObject =null; |
| | | @Autowired |
| | | TaskingService taskingService; |
| | | @Autowired |
| | | TaskingMapper taskingMapper; |
| | | @Autowired |
| | | MachineMapper machineMapper; |
| | | @Autowired |
| | | PrimitiveTaskService primitiveTaskService; |
| | | |
| | | //@Scheduled(fixedDelay = 500) |
| | | @Scheduled(fixedDelay = 1000) |
| | | @Scheduled(fixedDelay = 500) |
| | | public void manualReporting() { |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | List<PrimitiveTask> taskingList = primitiveTaskService.selectPrimitiveTask(new PrimitiveTask()); |
| | | Machine machine=machineMapper.selectById(24L); |
| | | List<Tasking> taskingList=taskingMapper.selectJoinList(Tasking.class,new MPJLambdaWrapper<Tasking>() |
| | | .selectAll(Tasking.class) |
| | | .innerJoin(LineConfiguration.class,LineConfiguration::getId,Tasking::getLineConfigurationId) |
| | | .innerJoin(Machine.class,Machine::getId,LineConfiguration::getMachineId) |
| | | .eq(LineConfiguration::getMachineId,machine.getId()) |
| | | .eq(Tasking::getGlassState,"正常") |
| | | .eq(Tasking::getState,"线上") |
| | | .ne(Tasking::getWorkState,"完工") |
| | | .orderByDesc(Tasking::getOperationRecordTime)); |
| | | |
| | | //List<PrimitiveTask> taskingList = primitiveTaskService.selectPrimitiveTask(new PrimitiveTask()); |
| | | jsonObject.append("taskingList", taskingList); |
| | | jsonObject.append("machine", machine); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("manualReporting"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | List<String> messages = webserver.getMessages(); |
| | | if (!messages.isEmpty()) { |
| | | // // 将最后一个消息转换为整数类型的列表 |
| | | webserver.clearMessages(); |
| | | try { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | List<String> messages = webserver.getMessages(); |
| | | if (!messages.isEmpty()) { |
| | | // // 将最后一个消息转换为整数类型的列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | }catch (Exception e) { |
| | | |
| | | } |
| | | } else { |
| | | log.info("Home is closed"); |