| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import springfox.documentation.spring.web.json.Json; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Jar任务创建 |
| | | * Jar任务创建 //完成 |
| | | */ |
| | | public synchronized void jarGenerateWrkMastSta() { |
| | | public synchronized void jarMastGenerate() { |
| | | for (JarSlave jarSlave : slaveProperties.getJar()) { |
| | | try{ |
| | | if (wrkMastExecuteService.getWrkMastByJarIdCount(jarSlave.getId())!=0){ |
| | | continue; |
| | | } |
| | | for(JarSlave.StaStn staStn : jarSlave.getJarInSta()){ |
| | | // 获取硫化罐入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, staStn.getDevpPlcId()); |
| | |
| | | } |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo()!=0){ |
| | | try{ |
| | | if (basJarMastService.selectJarMastOperation(jarSlave.getId(),1)!=0){ |
| | | if (basJarMastService.selectJarMastOperation(jarSlave.getId(),2)!=0){ |
| | | break; |
| | | } |
| | | if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),1)!=0){ |
| | | if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),3)!=0){ |
| | | // log.error("{}号小车",jarSlave.getJarOtherId()); |
| | | break; |
| | | } |
| | | if (wrkMastExecuteService.getWrkMastByJarIdCount(jarSlave.getId())!=0){ |
| | | if (basJarMastService.getJarMastByJarIdCount(jarSlave.getId())>=14){ |
| | | break; |
| | | } |
| | | if (basJarMastService.getJarMastByJarIdCount(jarSlave.getId())>=7){ |
| | | if (basJarMastService.selectJarMastOperation(jarSlave.getId(),0,9)>=7){ |
| | | break; |
| | | } |
| | | BasJarMast jarMastByJarIdMax = basJarMastService.getJarMastByJarIdMax(jarSlave.getId()); |
| | | if (!Objects.equals |
| | | ( |
| | | basJarMastService.selectJarMastOperation(jarSlave.getId(), 0, 4) |
| | | , |
| | | basJarMastService.selectJarMastOperation(jarSlave.getId(), 0, 9) |
| | | ) |
| | | ){ |
| | | break; |
| | | } |
| | | BasJarMast jarMastByJarIdMax = basJarMastService.getJarMastByJarIdMax(jarSlave.getId(),0,4); |
| | | int jarLocDigit = 0; |
| | | if (Cools.isEmpty(jarMastByJarIdMax)){ |
| | | if (basJarMastService.selectJarMastOperation(jarSlave.getId(),0,4)!=0){ |
| | | break; |
| | | } |
| | | jarLocDigit = 1; |
| | | } else if (jarMastByJarIdMax.getJarLocDigit()<7){ |
| | | jarLocDigit = jarMastByJarIdMax.getJarLocDigit()+1; |
| | |
| | | if (!Cools.isEmpty(wrkMastExecute)){ |
| | | continue; |
| | | } |
| | | if (jarGenerateWrkMastStaExecute(jarSlave,wrkMast,jarLocDigit,staStn.getStaNo())){ |
| | | if (jarMastGenerateExecute(jarSlave,wrkMast,jarLocDigit,staStn.getStaNo())){ |
| | | return; |
| | | } |
| | | }catch (Exception e){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Jar任务创建 执行 |
| | | * Jar任务创建===》执行 //完成 |
| | | */ |
| | | public synchronized boolean jarGenerateWrkMastStaExecute(JarSlave jarSlave,WrkMast wrkMast,Integer jarLocDigit,Integer staNo) { |
| | | public synchronized boolean jarMastGenerateExecute(JarSlave jarSlave,WrkMast wrkMast,Integer jarLocDigit,Integer staNo) { |
| | | try{ |
| | | // 获取堆垛机信息 |
| | | // 获取硫化罐信息 |
| | | JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId()); |
| | | JarProtocol jarProtocol = jarThread.getJarProtocol(); |
| | | if (jarProtocol == null) { |
| | |
| | | if (jarOtherProtocol == null) { |
| | | return false; |
| | | } |
| | | if (jarOtherProtocol.modeType != JarModeType.AUTO){ |
| | | return false; |
| | | } |
| | | // if (jarOtherProtocol.modeType != JarModeType.AUTO){ |
| | | // return false; |
| | | // } |
| | | |
| | | BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo()); |
| | | if (Cools.isEmpty(basJar)){ |
| | |
| | | } |
| | | |
| | | //自动、空闲、右门关闭、 Other左门关闭 |
| | | if (jarProtocol.isAutoing() && !jarProtocol.isRightDoor() && jarProtocol.jarErr==0 && jarProtocol.leftDoorOpen==0 && jarProtocol.leftDoorClose==0 |
| | | if (jarProtocol.isAutoing() && !jarProtocol.isRightDoor() && jarProtocol.jarErr==0 |
| | | && jarProtocol.leftDoorOpen==0 && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0 && jarProtocol.rightDoorClose==0 |
| | | && !jarOtherProtocol.isLeftDoor() && jarOtherProtocol.leftDoorOpen==0 && jarOtherProtocol.leftDoorClose==0){ |
| | | if (jarProtocol.statusType == JarStatusType.IDLE || jarProtocol.statusType == JarStatusType.MOVING){ |
| | | BasJarMast basJarMast = new BasJarMast(basJar, wrkMast, jarLocDigit); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Jar任务创建 执行 |
| | | * Jar任务完成 //未完成 |
| | | */ |
| | | public synchronized boolean jarGenerateWrkMastStaExecuteOne(JarSlave jarSlave) { |
| | | public synchronized boolean jarMastGenerateComplete(JarSlave jarSlave) { |
| | | try{ |
| | | // 获取堆垛机信息 |
| | | JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId()); |
| | |
| | | if (jarProtocol.isAutoing() && !jarProtocol.isRightDoor() && jarProtocol.jarErr==0 && !jarOtherProtocol.isLeftDoor() && jarOtherProtocol.jarErr==0){ |
| | | |
| | | } |
| | | |
| | | } catch (Exception e){ |
| | | // log.error("堆垛机工位二完成等待确认异常,堆垛机号={},异常信息={},工位号={}",crn.getId(),e.getMessage(),2); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Jar任务创建 执行 |
| | | * JarWrkMastExecute任务创建 //未完成 |
| | | * 开门、入硫化罐 |
| | | */ |
| | | public synchronized boolean jarGenerateWrkMastStaExecuteTwo(JarSlave jarSlave) { |
| | | public synchronized void jarWrkMastExecuteGenerate() { |
| | | for (JarSlave jarSlave : slaveProperties.getJar()) { |
| | | try{ |
| | | if (wrkMastExecuteService.getWrkMastByJarIdCount(jarSlave.getId())!=0){ |
| | | continue; |
| | | } |
| | | List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{ |
| | | add(0); |
| | | add(2); |
| | | }}); |
| | | for (BasJarMast basJarMast : basJarMastList){ |
| | | // 获取硫化罐信息 |
| | | JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId()); |
| | | JarProtocol jarProtocol = jarThread.getJarProtocol(); |
| | | if (jarProtocol == null) { |
| | | break; |
| | | } |
| | | if (jarProtocol.modeType != JarModeType.AUTO){ |
| | | break; |
| | | } |
| | | |
| | | JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId()); |
| | | JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol(); |
| | | if (jarOtherProtocol == null) { |
| | | break; |
| | | } |
| | | // if (jarOtherProtocol.modeType != JarModeType.AUTO){ |
| | | // continue; |
| | | // } |
| | | |
| | | BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo()); |
| | | if (Cools.isEmpty(basJar)){ |
| | | log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo()); |
| | | break; |
| | | } |
| | | |
| | | //门作业 无 |
| | | //自动、空闲、右门关闭、 Other左门关闭 |
| | | if (jarProtocol.isAutoing() && !jarProtocol.isRightDoor() && jarProtocol.jarErr==0 |
| | | && jarProtocol.leftDoorOpen==0 && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0 && jarProtocol.rightDoorClose==0 |
| | | && !jarOtherProtocol.isLeftDoor() && jarOtherProtocol.leftDoorOpen==0 && jarOtherProtocol.leftDoorClose==0){ |
| | | if (jarProtocol.statusType == JarStatusType.IDLE && !jarProtocol.isLeftDoor() && basJarMast.getStatus()==0){ |
| | | //生成开门任务 OpenTheDoor |
| | | if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),1,1})){ |
| | | log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast)); |
| | | } |
| | | return; |
| | | } else if (jarProtocol.statusType == JarStatusType.MOVING && jarProtocol.isLeftDoor()){ |
| | | //生成入硫化罐任务 |
| | | if (!jarWrkMastExecuteGenerateExecute(basJar,basJarMast,new int[]{basJar.getEnterSteNo(),basJar.getEnterRgvId(),5,1})){ |
| | | log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast)); |
| | | } |
| | | return; |
| | | } else if (jarProtocol.statusType == JarStatusType.IDLE && jarProtocol.isLeftDoor()){ |
| | | log.error("JarWrkMastExecute任务创建===>执行异常===》硫化罐空闲但是门未关===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMast)); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * JarWrkMastExecute任务创建===>执行 //未完成 |
| | | */ |
| | | public synchronized boolean jarWrkMastExecuteGenerateExecute(BasJar basJar,BasJarMast basJarMast,int[] digit) { |
| | | try{ |
| | | // 获取堆垛机信息 |
| | | JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId()); |
| | | JarProtocol jarProtocol = jarThread.getJarProtocol(); |
| | | if (jarProtocol == null) { |
| | | return false; |
| | | } |
| | | if (jarProtocol.modeType != JarModeType.AUTO){ |
| | | return false; |
| | | } |
| | | |
| | | JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId()); |
| | | JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol(); |
| | | if (jarOtherProtocol == null) { |
| | | return false; |
| | | } |
| | | if (jarOtherProtocol.modeType != JarModeType.AUTO){ |
| | | return false; |
| | | } |
| | | |
| | | //自动、空闲、右门关闭、 |
| | | if (jarProtocol.isAutoing() && !jarProtocol.isRightDoor() && jarProtocol.jarErr==0 && !jarOtherProtocol.isLeftDoor() && jarOtherProtocol.jarErr==0){ |
| | | |
| | | } |
| | | |
| | | } catch (Exception e){ |
| | | // log.error("堆垛机工位二完成等待确认异常,堆垛机号={},异常信息={},工位号={}",crn.getId(),e.getMessage(),2); |
| | | WrkMastExecute wrkMastExecute = new WrkMastExecute(basJarMast); |
| | | wrkMastExecute.setJarId(digit[3]==2? basJar.getBurial():basJar.getJarNo()); |
| | | wrkMastExecute.setSteId(digit[0]);//穿梭板ID |
| | | wrkMastExecute.setRgvId(digit[1]);//RGV ID |
| | | wrkMastExecute.setIoType(digit[2]);//任务类型 0: 未知 1: 开进料门 2: 关进料门 3: 开出料门 4: 关出料门 5: 入硫化罐 6: 入冷却槽 7: 穿梭车进冷却槽 8: 穿梭车离开冷却槽 9: 出冷却槽 |
| | | wrkMastExecute.setType(digit[3]);//设备 0: 未知 1: 硫化罐 2: 冷却槽 3: 硫化罐==>冷却槽 |
| | | return wrkMastExecuteService.insert(wrkMastExecute); |
| | | }catch (Exception e){ |
| | | log.error("JarWrkMastExecute任务创建===>执行异常===》异常原因:"+e.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Jar任务执行 |
| | | */ |
| | | public synchronized void jarExecuteWrkMastSta() { |
| | | try{ |
| | | |
| | | }catch (Exception e){ |
| | | log.error("小车复位线程报错!"+e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Jar完成 |
| | | */ |
| | | public synchronized void jarCompleteWrkMastSta() { |
| | | try{ |
| | | |
| | | }catch (Exception e){ |
| | | log.error("小车复位线程报错!"+e); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * 小车取空板至工位任务 满取 |
| | | * 开门任务创建 |
| | | * */ |
| | | public synchronized boolean jarRgvTake1(Integer rgvId,WrkMastSta wrkMastSta){ |
| | | public synchronized boolean jarWrkMastExecuteGenerate2(){ |
| | | try{ |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | RgvCommand rgvCommand = new RgvCommand(); |
| | | rgvCommand.setRgvNo(rgvId); // RGV编号 |
| | | rgvCommand.setAckFinish2((short) 0); // 工位2任务完成确认位 |
| | | rgvCommand.setTaskNo2(wrkMastSta.getWrkNo().shortValue()); // 工位2工作号 |
| | | rgvCommand.setTaskMode2(RgvTaskModeType.FETCH_5); // 工位2任务模式: 满取 |
| | | rgvCommand.setSourceStaNo2(wrkMastSta.getStaStart().shortValue()); //工位2起点 |
| | | rgvCommand.setCommand((short) 2); //工位2任务确认 |
| | | if (!MessageQueue.offer(SlaveType.Rgv, rgvId, new Task(5, rgvCommand))) { |
| | | //step=2,工位1、2写任务; step=4,工位1写任务; step=5,工位2写任务 |
| | | log.error("RGV命令下发失败,RGV号={},任务数据={}", rgvId, JSON.toJSON(rgvCommand)); |
| | | return false; |
| | | } else { |
| | | return true; |
| | | } |
| | | |
| | | } catch (Exception e){ |
| | | return false; |
| | | log.error("{}号硫化罐OpenTheDoorGenerate==》JarWrkMastExecute任务创建异常,异常原因={}",null,e.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * JarWrkMastExecute任务完成 //未完成 |
| | | */ |
| | | public synchronized void jarWrkMastExecuteGenerateComplete() { |
| | | try{ |
| | | |
| | | }catch (Exception e){ |
| | | log.error("小车复位线程报错!"+e); |
| | | } |
| | | } |
| | | |
| | | |
| | | /* |
| | | * Rgv 移动 |
| | | * */ |