| | |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.alarm.entity.ProductAlarmInfo; |
| | | import com.mes.alarm.service.ProductAlarmInfoService; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.common.config.ConstSysConfig; |
| | | import com.mes.damage.service.DamageService; |
| | |
| | | private String glassIdOne = ""; |
| | | private String glassIdTwo = ""; |
| | | |
| | | @Resource |
| | | private ProductAlarmInfoService productAlarmInfoService; |
| | | |
| | | private static final String ALARM_MODULE = "磨边"; |
| | | private static final String ALARM_TYPE1 = "一线卧式理片笼"; |
| | | private static final String ALARM_TYPE2 = "二线卧式理片笼"; |
| | | private static final String ALARM_CODE_NOGLASS = "noGlass"; |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void startOneOpcTask() throws Exception { |
| | | List<ProductAlarmInfo> alarmInfos = productAlarmInfoService.list(new LambdaQueryWrapper<ProductAlarmInfo>() |
| | | .eq(ProductAlarmInfo::getState, Const.LOAD_RAW_GLASS_NEW) |
| | | .eq(ProductAlarmInfo::getAlarmModule, ALARM_MODULE) |
| | | .eq(ProductAlarmInfo::getAlarmType, ALARM_TYPE1)); |
| | | if (CollectionUtil.isNotEmpty(alarmInfos)) { |
| | | log.info("界面报警,等待人工干预处理"); |
| | | return; |
| | | } |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | S7DataWLExtra s7DataWLExtraTwo = s7SerializerWLTwo.read(S7DataWLExtra.class); |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void startTwoOpcTask() throws Exception { |
| | | List<ProductAlarmInfo> alarmInfos = productAlarmInfoService.list(new LambdaQueryWrapper<ProductAlarmInfo>() |
| | | .eq(ProductAlarmInfo::getState, Const.LOAD_RAW_GLASS_NEW) |
| | | .eq(ProductAlarmInfo::getAlarmModule, ALARM_MODULE) |
| | | .eq(ProductAlarmInfo::getAlarmType, ALARM_TYPE2)); |
| | | if (CollectionUtil.isNotEmpty(alarmInfos)) { |
| | | log.info("界面报警,等待人工干预处理"); |
| | | return; |
| | | } |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | S7DataWLExtra s7DataWLExtraTwo = s7SerializerWLTwo.read(S7DataWLExtra.class); |
| | |
| | | log.info("开始执行进片任务,任务信息为:{},设备id:{},开始时间:{}", task, deviceId, startDate); |
| | | //获取玻璃的基本信息 |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdIn())); |
| | | if (null == glassInfo) { |
| | | if (null == glassInfo && StringUtils.isNotBlank(task.getGlassIdIn())) { |
| | | log.info("进片玻璃信息不存在,玻璃id:{}", task.getGlassIdIn()); |
| | | ProductAlarmInfo alarmInfo = new ProductAlarmInfo(); |
| | | alarmInfo.setState(Const.LOAD_RAW_GLASS_NEW); |
| | | alarmInfo.setAlarmModule(ALARM_MODULE); |
| | | if (deviceId == 1) { |
| | | alarmInfo.setAlarmType(ALARM_TYPE1); |
| | | } else { |
| | | alarmInfo.setAlarmType(ALARM_TYPE2); |
| | | } |
| | | alarmInfo.setAlarmCode(ALARM_CODE_NOGLASS); |
| | | alarmInfo.setAlarmMessage(task.getGlassIdIn()); |
| | | productAlarmInfoService.save(alarmInfo); |
| | | Date endDate = new Date(); |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.FALSE; |
| | |
| | | |
| | | private boolean outTask(S7DataWL task, int deviceId, int cellFlag) { |
| | | Date startDate = new Date(); |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdOut())); |
| | | if (null == glassInfo && StringUtils.isNotBlank(task.getGlassIdIn())) { |
| | | log.info("进片玻璃信息不存在,玻璃id:{}", task.getGlassIdIn()); |
| | | ProductAlarmInfo alarmInfo = new ProductAlarmInfo(); |
| | | alarmInfo.setState(Const.LOAD_RAW_GLASS_NEW); |
| | | alarmInfo.setAlarmModule(ALARM_MODULE); |
| | | if (deviceId == 1) { |
| | | alarmInfo.setAlarmType(ALARM_TYPE1); |
| | | } else { |
| | | alarmInfo.setAlarmType(ALARM_TYPE2); |
| | | } |
| | | alarmInfo.setAlarmCode(ALARM_CODE_NOGLASS); |
| | | alarmInfo.setAlarmMessage(task.getGlassIdIn()); |
| | | productAlarmInfoService.save(alarmInfo); |
| | | Date endDate = new Date(); |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.FALSE; |
| | | } |
| | | //获取对应的设备状态信息 |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | |
| | | Integer d06OutState = s7DataWLExtraTwo.getD06SlotState(); |
| | | //状态有3中情况:0空闲 1忙碌 2禁用 |
| | | //两条线都为禁用则不出玻璃 |
| | | log.info("当前设备为:{},一号设备任务信息:{},二号设备任务信息:{},d06任务信息:{}", deviceId, s7DataWLOne, s7DataWLTwo, d06OutState); |
| | | if (Const.OUT_DISABLE.equals(oneOutState) && Const.OUT_DISABLE.equals(twoOutState)) { |
| | | log.info("设备{}:A09、A10为{},{}非自动状态,无法出片", deviceId, oneOutState, oneOutState); |
| | | return Boolean.FALSE; |
| | |
| | | cell = Const.TWO_OUT_TARGET_POSITION; |
| | | } else if (Const.OUT_FREE.equals(oneOutState)) { |
| | | cell = Const.ONE_OUT_TARGET_POSITION; |
| | | } else { |
| | | } else if (Const.OUT_BUSY.equals(twoOutState)) { |
| | | cell = Const.TWO_OUT_TARGET_POSITION; |
| | | } else if (Const.OUT_BUSY.equals(oneOutState)) { |
| | | cell = Const.ONE_OUT_TARGET_POSITION; |
| | | } else { |
| | | return Boolean.FALSE; |
| | | } |
| | | } |
| | | log.info("{}线路计算完成:{}", deviceId, cell); |
| | |
| | | if (null == edgStorageCageDetails) { |
| | | // 获取历史表中上次任务最后一片尺寸 |
| | | EdgStorageDeviceTaskHistory edgeData = edgStorageDeviceTaskHistoryService.getOne(new LambdaQueryWrapper<EdgStorageDeviceTaskHistory>() |
| | | .eq(EdgStorageDeviceTaskHistory::getDeviceId, cell) |
| | | .eq(EdgStorageDeviceTaskHistory::getEndCell, cell) |
| | | .in(EdgStorageDeviceTaskHistory::getTaskType, Const.GLASS_CACHE_TYPE_OUT, Const.GLASS_CACHE_TYPE_THROUGH) |
| | | .orderByDesc(EdgStorageDeviceTaskHistory::getId).last("limit 1")); |
| | | log.info("{}获取上次任务信息:{}", deviceId, edgeData); |