| | |
| | | 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); |
| | |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdIn())); |
| | | if (null == glassInfo) { |
| | | 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.getGlassIdIn())); |
| | | if (null == glassInfo) { |
| | | 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); |
| | |
| | | cell = Const.ONE_OUT_TARGET_POSITION; |
| | | } else if (Const.OUT_BUSY.equals(twoOutState)) { |
| | | cell = Const.TWO_OUT_TARGET_POSITION; |
| | | }else if(Const.OUT_BUSY.equals(oneOutState)){ |
| | | } else if (Const.OUT_BUSY.equals(oneOutState)) { |
| | | cell = Const.ONE_OUT_TARGET_POSITION; |
| | | }else{ |
| | | } else { |
| | | return Boolean.FALSE; |
| | | } |
| | | } |