|  |  |  | 
|---|
|  |  |  | staProtocol.setWorkNo(9999); | 
|---|
|  |  |  | staProtocol.setStaNo(inSta.getBackSta()); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | devpThread.setPakMkRun(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | devpThread.setErrorDev(staProtocol.getSiteId(), errMsg); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(workNo)); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!taskWrks.isEmpty()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TaskWrkLog> taskWrkLogs = taskWrkLogService.selectList(new EntityWrapper<TaskWrkLog>().eq("CRN_NO",crnProtocol.getLaneNo()).orderBy("COMPLETE_TIME",true)); | 
|---|
|  |  |  | List<TaskWrkLog> taskWrkLogs = taskWrkLogService.selectList(new EntityWrapper<TaskWrkLog>().eq("CRN_NO",crnProtocol.getLaneNo()).orderBy("COMPLETE_TIME",false)); | 
|---|
|  |  |  | if (!taskWrkLogs.isEmpty()) { | 
|---|
|  |  |  | TaskWrkLog taskWrkLog = taskWrkLogs.get(0); | 
|---|
|  |  |  | Date completeTime = taskWrkLog.getCompleteTime(); | 
|---|
|  |  |  | if (completeTime==null){ | 
|---|
|  |  |  | completeTime = taskWrkLog.getCancelTime(); | 
|---|
|  |  |  | boolean signT = false; | 
|---|
|  |  |  | for (TaskWrkLog taskWrkLog : taskWrkLogs){ | 
|---|
|  |  |  | Date completeTime = taskWrkLog.getCompleteTime(); | 
|---|
|  |  |  | if (completeTime==null){ | 
|---|
|  |  |  | completeTime = taskWrkLog.getModiTime(); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | long differenceInSeconds = TimeCalculatorUtils.differenceInMilliseconds(completeTime, new Date()); | 
|---|
|  |  |  | if (differenceInSeconds <= 60*2*1000) { | 
|---|
|  |  |  | signT = true; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | signT = false; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | long differenceInSeconds = TimeCalculatorUtils.differenceInMilliseconds(completeTime, new Date()); | 
|---|
|  |  |  | if (differenceInSeconds <= 60*10*1000) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | if (signT){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 命令下发区 -------------------------------------------------------------------------- | 
|---|
|  |  |  | 
|---|
|  |  |  | crnCommand.setLaneNo(crnProtocol.getLaneNo()); // 堆垛机巷道编号 | 
|---|
|  |  |  | crnCommand.setTaskNo((short)999); // 工作号 | 
|---|
|  |  |  | crnCommand.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | crnCommand.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 任务模式:  库位移转 | 
|---|
|  |  |  | crnCommand.setSourcePosX((short) 0);     // 源库位排 | 
|---|
|  |  |  | crnCommand.setSourcePosY((short) 0);     // 源库位列 | 
|---|
|  |  |  | crnCommand.setSourcePosZ((short) 0);   // 源库位层 | 
|---|
|  |  |  | crnCommand.setTaskMode(CrnTaskModeType.SITE_MOVE); // 任务模式:  站位移转4 | 
|---|
|  |  |  | int row = crnProtocol.getLaneNo() * 2; | 
|---|
|  |  |  | crnCommand.setSourcePosX((short) row);     // 源库位排 | 
|---|
|  |  |  | crnCommand.setSourcePosY((short) 1);     // 源库位列 | 
|---|
|  |  |  | crnCommand.setSourcePosZ((short) 1);   // 源库位层 | 
|---|
|  |  |  | crnCommand.setDestinationPosX((short) row);     // 目标库位排 | 
|---|
|  |  |  | crnCommand.setDestinationPosY((short) 1);     // 目标库位层 | 
|---|
|  |  |  | crnCommand.setDestinationPosZ((short) 1);     // 目标库位列 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e){ | 
|---|
|  |  |  | log.error("堆垛机5分钟无任务则回到源点失败"); | 
|---|
|  |  |  | log.error("堆垛机10分钟无任务则回到源点失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 命令下发区 -------------------------------------------------------------------------- | 
|---|
|  |  |  | CrnCommand crnCommand = new CrnCommand(); | 
|---|
|  |  |  | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 | 
|---|
|  |  |  | crnCommand.setLaneNo(crnProtocol.getLaneNo()); // 堆垛机巷道编号 | 
|---|
|  |  |  | crnCommand.setTaskNo(taskWrk.getWrkNo().shortValue()); // 工作号 | 
|---|
|  |  |  | crnCommand.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式:  库位移转 | 
|---|
|  |  |  | crnCommand.setSourcePosX(crnStn.getRow().shortValue());     // 源库位排 | 
|---|
|  |  |  | crnCommand.setSourcePosY(crnStn.getBay().shortValue());     // 源库位列 | 
|---|
|  |  |  | crnCommand.setSourcePosZ(crnStn.getLev().shortValue());   // 源库位层 | 
|---|
|  |  |  | crnCommand.setDestinationPosX(Utils.getRowShort(taskWrk.getTargetPoint()));     // 目标库位列 | 
|---|
|  |  |  | CrnCommand crnCommand1 = new CrnCommand(); | 
|---|
|  |  |  | crnCommand1.setCrnNo(slave.getId()); // 堆垛机编号 | 
|---|
|  |  |  | crnCommand1.setLaneNo(crnProtocol.getLaneNo()); // 堆垛机巷道编号 | 
|---|
|  |  |  | crnCommand1.setTaskNo(taskWrk.getWrkNo().shortValue()); // 工作号 | 
|---|
|  |  |  | crnCommand1.setAckFinish((short) 0);  // 任务完成确认位 | 
|---|
|  |  |  | crnCommand1.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式:  库位移转 | 
|---|
|  |  |  | crnCommand1.setSourcePosX(crnStn.getRow().shortValue());     // 源库位排 | 
|---|
|  |  |  | crnCommand1.setSourcePosY(crnStn.getBay().shortValue());     // 源库位列 | 
|---|
|  |  |  | crnCommand1.setSourcePosZ(crnStn.getLev().shortValue());   // 源库位层 | 
|---|
|  |  |  | crnCommand1.setDestinationPosX(Utils.getRowShort(taskWrk.getTargetPoint()));     // 目标库位列 | 
|---|
|  |  |  | int bay1 = Utils.getBayShort(taskWrk.getTargetPoint()) + 1; | 
|---|
|  |  |  | crnCommand.setDestinationPosY((short)bay1);     // 目标库位层 | 
|---|
|  |  |  | crnCommand.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint()));     // 目标库位排 | 
|---|
|  |  |  | crnCommand1.setDestinationPosY((short)bay1);     // 目标库位层 | 
|---|
|  |  |  | crnCommand1.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint()));     // 目标库位排 | 
|---|
|  |  |  | //                crnCommand.setCommand((short) 1); | 
|---|
|  |  |  | if (!MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, crnCommand))) { | 
|---|
|  |  |  | log.error("堆垛机命令生成失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); | 
|---|
|  |  |  | if (!MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, crnCommand1))) { | 
|---|
|  |  |  | log.error("堆垛机命令生成失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand1)); | 
|---|
|  |  |  | devpThread.setErrorDev(staProtocol.getSiteId(), crnProtocol.getLaneNo()+"巷道堆垛机命令生成失败"); | 
|---|
|  |  |  | CrnErrCache.updateCrnErr(crnProtocol.getCrnNo(), "运行命令下发失败"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 判断堆垛机出库站状态 | 
|---|
|  |  |  | if (staProtocol.isAutoing() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")) { | 
|---|
|  |  |  | //                    if (staProtocol.isAutoing() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                    // 判断堆垛机出库站状态 | 
|---|
|  |  |  | //                    if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") | 
|---|
|  |  |  | //                            && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { | 
|---|
|  |  |  | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") | 
|---|
|  |  |  | && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { | 
|---|
|  |  |  | // 命令下发区 -------------------------------------------------------------------------- | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 堆垛机控制过滤 | 
|---|
|  |  |  | 
|---|
|  |  |  | if (staProtocol.isOutEnable()){ | 
|---|
|  |  |  | CrnErrCache.updateCrnErr(crnProtocol.getCrnNo(), "没有可出"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (staProtocol.isLoading()){ | 
|---|
|  |  |  | CrnErrCache.updateCrnErr(crnProtocol.getCrnNo(), "出库站有物"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | CrnErrCache.updateCrnErr(crnProtocol.getCrnNo(), "出库站点:非自动"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 已经存在吊车执行任务时,则过滤 | 
|---|
|  |  |  | if (taskWrkMapper.selectCrnWorking(crnProtocol.getLaneNo()) != null) { | 
|---|
|  |  |  | CrnErrCache.updateCrnErr(crnProtocol.getCrnNo(), "堆垛机存在执行中吊车任务"); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | null,    // 结束时间 | 
|---|
|  |  |  | null,    // 工作状态 | 
|---|
|  |  |  | null,    // 入出库类型 | 
|---|
|  |  |  | crn.getId(),    // 堆垛机 | 
|---|
|  |  |  | null,    // plc | 
|---|
|  |  |  | crnProtocol.getLaneNo(),    // 堆垛机 | 
|---|
|  |  |  | crn.getId(),    // plc | 
|---|
|  |  |  | null,    // 目标库位 | 
|---|
|  |  |  | null,    // 目标站 | 
|---|
|  |  |  | null,    // 源站 | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 判断是否满足取货条件 | 
|---|
|  |  |  | if (!staProtocol.isPakMkTask()) { | 
|---|
|  |  |  | devpThread.setErrorDev(staProtocol.getSiteId(), "任务已下发等待小车取"); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 判断是否满足取货条件 | 
|---|
|  |  |  | if (staProtocol.isAutoing() | 
|---|
|  |  |  | //                && staProtocol.isLoading() | 
|---|
|  |  |  | //                && staProtocol.isStaOk() | 
|---|
|  |  |  | 
|---|
|  |  |  | if (taskWrk != null) { | 
|---|
|  |  |  | Integer stano = staProtocol.getStaNo(); | 
|---|
|  |  |  | if (staProtocol.getSiteId() == 1004 || staProtocol.getSiteId()==1020){ | 
|---|
|  |  |  | // 判断是否满足取货条件 | 
|---|
|  |  |  | if (!staProtocol.isPakMkRun()) { | 
|---|
|  |  |  | devpThread.setErrorDev(staProtocol.getSiteId(), "异常回退标记,需要回退"); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!staProtocol.isLoading()) { | 
|---|
|  |  |  | devpThread.setErrorDev(staProtocol.getSiteId(), "无物"); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!staProtocol.isInEnable()) { | 
|---|
|  |  |  | devpThread.setErrorDev(staProtocol.getSiteId(), "等待可入信号"); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!staProtocol.isStaOk()) { | 
|---|
|  |  |  | devpThread.setErrorDev(staProtocol.getSiteId(), "等待链条就绪"); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 尺寸检测异常 | 
|---|
|  |  |  | 
|---|
|  |  |  | staProtocol.setWorkNo(9999); | 
|---|
|  |  |  | staProtocol.setStaNo(staProtocol.getStaNo()+1); | 
|---|
|  |  |  | devpThread.setPakMk(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | devpThread.setPakMkRun(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | devpThread.setPakMkTask(staProtocol.getSiteId(), false); | 
|---|
|  |  |  | devpThread.setErrorDev(staProtocol.getSiteId(), errMsg); | 
|---|
|  |  |  | MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvSlave.getId()); | 
|---|
|  |  |  | TaskProtocolCache taskProtocolCache = rgvThread.getTaskProtocolCache(); | 
|---|
|  |  |  | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, rgvStn.getDevpPlcId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TaskProtocol issuedTake = new TaskProtocol(); | 
|---|
|  |  |  | TaskProtocol issuedPut = new TaskProtocol(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | devpThread.setPakMkTask(rgvStn.getStaNo(), false); | 
|---|
|  |  |  | } catch (Exception e2){ | 
|---|
|  |  |  | RgvErrCache.updateRgvErr(rgvSlave.getId(),rgvStn.getStaNo()+"小车任务下发标记更新失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BasDevpPosition basDevpPositionSou = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStn.getStaNo())); | 
|---|
|  |  |  | BasDevpPosition basDevpPositionEnd = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", targetPointConvert)); | 
|---|