| | |
| | | package com.mes.job; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.pp.entity.OptimizeHeatDetail; |
| | | import com.mes.pp.entity.OptimizeHeatLayout; |
| | | import com.mes.pp.service.OptimizeHeatDetailService; |
| | | import com.mes.pp.service.OptimizeHeatLayoutService; |
| | | import com.mes.temperingglass.entity.TemperingGlass; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | //@Scheduled(fixedDelay = 1000) |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void requestTemperingTask() throws Exception { |
| | | ReadWriteEntity requestInTempering = miloService.readFromOpcUa("GH1S7.GH1S7.requestInTempering");//请求进片 |
| | | ReadWriteEntity requestTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.requestTemperingId");//请求进片 炉号ID |
| | |
| | | if (request == 0) { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 0));//允许送片清零 |
| | | } else { |
| | | if (id == 0){ |
| | | log.info("炉号不能为0"); |
| | | return; |
| | | } |
| | | ReadWriteEntity placedNumber = miloService.readFromOpcUa("GH1S7.GH1S7.placedNumber");//已摆片数量 |
| | | List<TemperingGlassInfo> glassList = temperingAgoService.selectGlassInfoById(id); |
| | | if (glassList.size() == Integer.parseInt(placedNumber.getValue().toString())) { |
| | | if (Integer.parseInt(placedNumber.getValue().toString()) == glassList.size()) { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 1));//写入允许送片 |
| | | } else { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 2));//不满足进炉条件 |
| | |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | //@Scheduled(fixedDelay = 1000) |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void loadTemperingTask() throws Exception { |
| | | ReadWriteEntity loadTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.loadTemperingId");//进片完成 炉号ID |
| | | getNewTemperingID(Integer.parseInt(loadTemperingId.getValue().toString()));//进片完成 下发参数 |
| | | } |
| | | /** |
| | | * 更新钢化小片表内的玻璃状态 |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void updateTemperingTask() throws Exception { |
| | | ReadWriteEntity furanchiIdEntity = miloService.readFromOpcUa("GH1S7.GH1S7.Furanch1Id");//进片完成 炉号ID |
| | | if (StringUtils.isNotBlank(furanchiIdEntity.getValue()+"")){ |
| | | int temperingid = Integer.parseInt(furanchiIdEntity.getValue().toString()); |
| | | temperingAgoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>().set(TemperingGlassInfo::getState, Const.TEMPERING_START) |
| | | .in(TemperingGlassInfo::getState, Const.TEMPERING_OUT, Const.TEMPERING_DROP).eq(TemperingGlassInfo::getTemperingLayoutId,temperingid)); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | //获取到炉号id执行参数下发任务 |
| | | private void getNewTemperingID(Integer temperingid) throws Exception { |
| | | ReadWriteEntity AutoStatus = miloService.readFromOpcUa("GH1.GH1.AutoStatus"); |
| | | if (1 != Integer.parseInt(AutoStatus.getValue().toString())) { |
| | | ReadWriteEntity autoStatus = miloService.readFromOpcUa("GH1.GH1.AutoStatus"); |
| | | if (1 != Integer.parseInt(autoStatus.getValue().toString())) { |
| | | log.info("当前为非联机状态,结束钢化下发参数任务"); |
| | | return; |
| | | } |
| | |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.WorkMode", workmode));//写入工位数 |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1.GH1.FurnaceMode", furmode));//写入炉体工作方式 |
| | | log.info("炉号" + temperingid + "版面信息尝试下发"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |