| | |
| | | break; |
| | | } |
| | | |
| | | // 双深库位且浅库位有货,则需先对浅库位进行库位移转 |
| | | if (Utils.isDeepLoc(slaveProperties, taskWrk.getStartPoint())) { |
| | | |
| | | List<TaskWrk> taskWrks1 = taskWrkMapper.selectPakOutIoType(taskWrk.getCrnNo()); |
| | | if (Cools.isEmpty(taskWrks1) && taskWrks1.size()!=0){ |
| | | break; |
| | | } |
| | | String shallowLocNo = Utils.getShallowLoc(slaveProperties, taskWrk.getStartPoint()); |
| | | LocMast shallowLoc = locMastService.selectById(shallowLocNo); |
| | | // O.空库位、Q.拣料/盘点/并板再入库、S.入库预约、X.禁用 直接搬! |
| | | if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { |
| | | log.error("工作号={},库位号={},浅库位异常:浅库位号:={},库位状态={}",taskWrk.getTaskNo(),taskWrk.getStartPoint(),shallowLocNo,shallowLoc.getLocSts()); |
| | | } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { |
| | | taskWrk.setTransferMark(1); |
| | | taskWrkMapper.updateById(taskWrk); |
| | | break; |
| | | } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) { |
| | | log.error("工作号={},库位号={},浅库位异常:浅库位号:={},库位状态={}",taskWrk.getTaskNo(),taskWrk.getStartPoint(),shallowLocNo,shallowLoc.getLocSts()); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | // 1.堆垛机开始移动 |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | |
| | | * 库位移转 |
| | | */ |
| | | public void locToLoc(CrnSlave slave, CrnProtocol crnProtocol){ |
| | | // 获取工作档信息 |
| | | WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId()); |
| | | if (null == wrkMast) { |
| | | return; |
| | | } |
| | | // 获取源库位信息 |
| | | LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (null == sourceSta) { |
| | | log.error("工作档库位移转失败,原因:检索源库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); |
| | | return; |
| | | } |
| | | // 源库位 库位状态判断 |
| | | if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("S")) { |
| | | return; |
| | | } |
| | | // 获取目标库位信息 |
| | | LocMast sta = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (null == sta) { |
| | | log.error("工作档库位移转失败,原因:检索目标库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); |
| | | return; |
| | | } |
| | | // 获取堆垛机信息 并 判断是否可入出 |
| | | BasCrnp basCrnp = basCrnpService.selectById(slave.getId()); |
| | | if (!basCrnp.getInEnable().equals("Y") && !basCrnp.getOutEnable().equals("Y")) { |
| | | return; |
| | | } |
| | | for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { |
| | | // 获取工作状态为11(生成出库ID)的出库工作档 |
| | | List<TaskWrk> taskWrks = taskWrkMapper.selectPakOut3(slave.getId(), crnStn.getStaNo().toString()); |
| | | for (TaskWrk taskWrk : taskWrks){ |
| | | if (taskWrk == null) { |
| | | continue; |
| | | } |
| | | // 工作档状态判断 |
| | | if (taskWrk.getIoType() != 3 || taskWrk.getTargetPoint() == null) { |
| | | log.error("查询工作档数据不符合条件--入出类型/目标库位号, 工作号={},源库位={},入出类型={}", taskWrk.getWrkNo(), taskWrk.getTargetPoint(), taskWrk.getIoType()); |
| | | continue; |
| | | } |
| | | // 获取源库位信息 |
| | | String locNo = taskWrk.getStartPoint(); |
| | | LocMast sourceSta = locMastService.selectById(locNo); |
| | | if (!sourceSta.getLocSts().equals("R") &&!sourceSta.getLocSts().equals("P")) { |
| | | log.error("出库操作库位状态不符合--状态, 库位号={},库位状态={}", locNo, sourceSta.getLocSts()); |
| | | continue; |
| | | } |
| | | |
| | | // 堆垛机控制过滤 |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | return; |
| | | } |
| | | // 获取目标库位信息 |
| | | String locNoEnd = taskWrk.getTargetPoint(); |
| | | LocMast sourceEnd = locMastService.selectById(locNoEnd); |
| | | if (!sourceEnd.getLocSts().equals("S") && !sourceEnd.getLocSts().equals("Q")) { |
| | | log.error("出库操作库位状态不符合--状态, 库位号={},库位状态={}", locNo, sourceSta.getLocSts()); |
| | | continue; |
| | | } |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (wrkMastMapper.selectWorking(slave.getId()) != null) { |
| | | return; |
| | | } |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 源库位层 |
| | | crnCommand.setDestinationPosX(sta.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 目标库位层 |
| | | if (!CommandUtils.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | | Date now = new Date(); |
| | | wrkMast.setWrkSts(12L); |
| | | wrkMast.setCrnStrTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("【库位移转】 修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | // // 获取堆垛机出库站信息 |
| | | // SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); |
| | | // StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); |
| | | // if (staProtocol == null) { |
| | | // break; |
| | | // } else { |
| | | // staProtocol = staProtocol.clone(); |
| | | // } |
| | | |
| | | // 查询站点详细信息 |
| | | BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); |
| | | if (staDetl == null) { |
| | | log.error("出库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo()); |
| | | continue; |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 堆垛机控制过滤 |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | continue; |
| | | } |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (taskWrkMapper.selectCrnWorking(slave.getId()) != null) { |
| | | continue; |
| | | } |
| | | |
| | | // 起始深库位浅库位不为空 |
| | | if (Utils.isDeepLoc(slaveProperties, taskWrk.getStartPoint())) { |
| | | // 获取浅库位信息 |
| | | String shallowLocNo = Utils.getShallowLoc(slaveProperties, taskWrk.getStartPoint()); |
| | | LocMast shallowLocMast = locMastService.selectById(shallowLocNo); |
| | | if (!shallowLocMast.getLocSts().equals("O")) { |
| | | log.error("移库操作起始库位浅库位状态不符合--状态, 库位号={},库位状态={}", locNo, shallowLocMast.getLocSts()); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | // 目标库位为深库位且浅库位不为空 |
| | | if (Utils.isDeepLoc(slaveProperties, taskWrk.getTargetPoint())) { |
| | | // 获取浅库位信息 |
| | | String shallowLocNo = Utils.getShallowLoc(slaveProperties, taskWrk.getTargetPoint()); |
| | | LocMast shallowLocMast = locMastService.selectById(shallowLocNo); |
| | | if (!shallowLocMast.getLocSts().equals("O")) { |
| | | log.error("移库操作目标库位浅库位状态不符合--状态, 库位号={},库位状态={}", locNo, shallowLocMast.getLocSts()); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | // 目标库位为浅库位且深库位无货 |
| | | if (Utils.isShallowLoc(slaveProperties, taskWrk.getTargetPoint())) { |
| | | // 获取深库位信息 |
| | | String deepLocNo = Utils.getDeepLoc(slaveProperties, taskWrk.getTargetPoint()); |
| | | LocMast deepLocMast = locMastService.selectById(deepLocNo); |
| | | if (!deepLocMast.getLocSts().equals("F") && !deepLocMast.getLocSts().equals("D") ) { |
| | | log.error("移库操作目标库位深库位状态不符合--状态, 库位号={},库位状态={}", locNo, deepLocMast.getLocSts()); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | // 1.堆垛机开始移动 |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | crnCommand.setTaskNo(taskWrk.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 源库位层 |
| | | crnCommand.setDestinationPosX(sourceEnd.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(sourceEnd.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(sourceEnd.getLev1().shortValue()); // 目标库位层 |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | | Date now = new Date(); |
| | | taskWrk.setWrkSts(12); |
| | | taskWrk.setModiTime(now); |
| | | if (taskWrkMapper.updateById(taskWrk) == 0) { |
| | | log.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", taskWrk.getWrkNo()); |
| | | } |
| | | break; |
| | | } |
| | | return; |
| | | } |
| | | } |
| | | |