| | |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageFeedTask; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageOutTask; |
| | | import com.mes.bigstoragetask.service.BigStorageCageFeedTaskService; |
| | | import com.mes.bigstoragetask.service.BigStorageCageOutTaskService; |
| | | import com.mes.common.S7object; |
| | | import com.mes.common.WebSocketServer; |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.edgstoragetask.service.TaskCacheService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | @Slf4j |
| | | public class PlcStorageCageTask { |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private BigStorageCageService bigStorageCageService; |
| | | @Autowired |
| | | @Resource |
| | | private BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | @Autowired |
| | | @Resource |
| | | private GlassInfoService glassInfoService; |
| | | @Autowired |
| | | @Resource |
| | | private BigStorageCageFeedTaskService bigStorageCageFeedTaskService; |
| | | @Autowired |
| | | @Resource |
| | | private BigStorageCageOutTaskService bigStorageCageOutTaskService; |
| | | @Autowired |
| | | @Resource |
| | | private TaskCacheService taskCacheService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private SysMenuService sysMenuService; |
| | | |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | /** |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | |
| | | public void plcStorageCageTask() throws InterruptedException { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | try { |
| | | Thread.sleep(300); |
| | | // 爆笼报警 |
| | | boolean bigStorageCageFullAlarm = false; |
| | | |
| | | String plcD01FeedReq = "0"; |
| | | String plcD04FeedReq = "0"; |
| | | String plcFeedGlassid = "111"; |
| | | String plcFeedGlassid = ""; |
| | | String plcFeedReqLine = "0"; |
| | | if ("1".equals(plcD01FeedReq)) { |
| | | if ("1".equals(plcParameterObject.getPlcParameter("D01Request").getValue())) { |
| | | plcFeedReqLine = "1"; |
| | | } else { |
| | | //plc任务发送字0 |
| | | plcFeedGlassid=plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | } |
| | | if ("1".equals(plcD04FeedReq)) { |
| | | if ("1".equals(plcParameterObject.getPlcParameter("D04Request").getValue())) { |
| | | plcFeedReqLine = "2"; |
| | | } else { |
| | | //plc任务发送字0 |
| | | plcFeedGlassid=plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | } |
| | | |
| | | if (!("0".equals(plcFeedReqLine))) { |
| | |
| | | log.info("3、查询任务表判断当前任务类型为上车等到还是上车启动" + taskType); |
| | | bigStorageCageFeedTaskService.addFeedTask(slotInfo, Integer.parseInt(plcFeedReqLine), taskType); |
| | | log.info("4、添加任务到任务表"); |
| | | //plc任务发送字1 |
| | | bigStorageCageFullAlarm = false; |
| | | } else { |
| | | //理片笼爆笼报警 |
| | | bigStorageCageFullAlarm = true; |
| | | } |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | //出片请求 |
| | | String plcOutReq = "0"; |
| | | boolean result = false; |
| | | if ("1".equals(plcOutReq)) { |
| | | result = bigStorageCageService.outGlass(); |
| | | log.info("8、出片请求时调用出片接口" + result); |
| | | if (result) { |
| | | //plc任务发送字1 |
| | | //查询出片表是否有任务未完成的任务 |
| | | List<BigStorageCageOutTask> bigStorageCageOutTask=bigStorageCageOutTaskService.querybigStorageCageOutTask(0); |
| | | if(bigStorageCageOutTask.size()==0){ |
| | | bigStorageCageService.outGlass(); |
| | | log.info("8、没有未完成任务时调用出片接口"); |
| | | } |
| | | } else { |
| | | bigStorageCageOutTaskService.updateOutTask(); |
| | | //plc任务发送字0 |
| | | } |
| | | |
| | | //显示剩余空格子 |
| | | log.info("9、根据任务表状态修改钢化小片表任务状态"); |
| | | |
| | | //报警信息 |
| | | jsonObject.append("bigStorageCageFullAlarm", bigStorageCageFullAlarm); |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Home"); |
| | | if (sendwServer != null) { |
| | | 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"); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |