| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageTask; |
| | | import com.mes.bigstoragecagetask.service.BigStorageCageTaskService; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.hollow.entity.HollowBigStorageCage; |
| | | import com.mes.hollow.entity.HollowGlassOutRelationInfo; |
| | | import com.mes.hollow.service.HollowBigStorageCageService; |
| | | import com.mes.hollow.service.HollowGlassOutRelationInfoService; |
| | | import com.mes.hollowqueue.entity.HollowGlassQueueInfo; |
| | | import com.mes.hollowqueue.service.HollowGlassQueueInfoService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | HollowGlassQueueInfoService hollowGlassQueueInfoService; |
| | | @Resource |
| | | HollowGlassOutRelationInfoService hollowGlassOutRelationInfoService; |
| | | @Resource |
| | | HollowBigStorageCageService hollowBigStorageCageService; |
| | | @Resource |
| | | BigStorageCageTaskService bigStorageCageTaskService; |
| | | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Resource |
| | | RedisUtil redisUtil; |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void hollowGlassTask() { |
| | | List<HollowGlassOutRelationInfo> taskList = hollowGlassOutRelationInfoService.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>() |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void hollowGlassMessage() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | try { |
| | | //查询使用数据源1查询数据 |
| | | queryDataSource1(jsonObject); |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("hollowGlassMessage"); |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void queryDataSource1(JSONObject jsonObject) throws Exception { |
| | | List<Double> carPostion = new ArrayList<>(); |
| | | carPostion.add(0.25); |
| | | carPostion.add(0.5); |
| | | jsonObject.append("carPostion", carPostion); |
| | | //界面展示笼子信息 |
| | | jsonObject.append("bigStorageCageInfos", hollowBigStorageCageService.queryHollowbigStorageCageDetail()); |
| | | |
| | | try{ |
| | | //进片任务数据 |
| | | List<BigStorageCageTask> inTaskList = new ArrayList(); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM1"); |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP2A.DLP2A.TO" + i); |
| | | ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP2A.DLP2A.STATE" + i); |
| | | if (null != requestWord.getValue()) { |
| | | BigStorageCageTask task = new BigStorageCageTask(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | inTaskList.add(task); |
| | | continue; |
| | | } |
| | | } |
| | | jsonObject.append("bigStorageCageDetailsFeedTask", inTaskList); |
| | | //进片联机 |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | //进片请求 |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2A.DLP2A.RequestMes"); |
| | | jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | //启动命令 |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP2A.DLP2A.MesReply"); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | //出片联机 |
| | | ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | //出片请求 |
| | | ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP2B.DLP2B.RequestMes"); |
| | | jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | |
| | | }catch(Exception e){ |
| | | //todo:不做任务处理 |
| | | } |
| | | |
| | | //出片任务数据 |
| | | List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_two_task"); |
| | | jsonObject.append("bigStorageCageDetailsOutTask", outTaskList); |
| | | |
| | | //调度开关 |
| | | boolean dispatchHollowSwitch = false; |
| | | if (redisUtil.getCacheObject("dispatchHollowSwitch") == null) { |
| | | redisUtil.setCacheObject("dispatchHollowSwitch", false); |
| | | } else { |
| | | dispatchHollowSwitch = redisUtil.getCacheObject("dispatchHollowSwitch"); |
| | | } |
| | | jsonObject.append("dispatchHollowSwitch", dispatchHollowSwitch); |
| | | |
| | | //理片笼使用情况 |
| | | List<Map<String, Object>> bigStorageCageUsage = hollowBigStorageCageService.selectBigStorageCageUsage(); |
| | | jsonObject.append("bigStorageCageUsage", bigStorageCageUsage); |
| | | |
| | | // |
| | | // //打印开关 |
| | | // boolean autoPrint = false; |
| | | // if (redisUtil.getCacheObject("autoPrint") == null) { |
| | | // redisUtil.setCacheObject("autoPrint", false); |
| | | // } else { |
| | | // autoPrint = redisUtil.getCacheObject("autoPrint"); |
| | | // } |
| | | // jsonObject.append("autoPrint", autoPrint); |
| | | |
| | | } |
| | | |
| | | } |