| | |
| | | @Autowired |
| | | private WrkMastMapper wrkMastMapper; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | |
| | | /** |
| | | * 拣料、并板、盘点再入库【第2阶段】 |
| | | */ |
| | | @Transactional |
| | | public synchronized void stnToCrnStnPick1(){ |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历拣料入库口 |
| | |
| | | } |
| | | |
| | | String sourceLocNo = wrkMast.getSourceLocNo().trim(); |
| | | |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | |
| | | if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败"); |
| | | } |
| | | |
| | | LocMast locMast = null; |
| | | // 修改源库位状态 O.空库位 |
| | | // locMast = locMastService.selectById(sourceLocNo); |
| | | // locMast.setLocSts("O"); |
| | | // locMast.setModiTime(new Date()); |
| | | // if (!locMastService.updateById(locMast)) { |
| | | // throw new CoolException(wrkMast.getWrkNo() + "修改源库位状态 O.空库位"); |
| | | // } |
| | | // 修改目标库位状态 Q.拣料/盘点/并板再入库 |
| | | locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | locMast.setLocSts("Q"); |
| | |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "修改目标库位状态 Q.拣料/盘点/并板再入库"); |
| | | } |
| | | // 库存明细转移 |
| | | // if (!locDetlService.updateLocNo(wrkMast.getLocNo(), sourceLocNo)) { |
| | | // throw new CoolException(wrkMast.getWrkNo() + "任务库存明细转移失败!!!"); |
| | | // } |
| | | // 源库位库存明细转移到目标库位 |
| | | if (!locDetlService.updateLocNo(wrkMast.getLocNo(), sourceLocNo)) { |
| | | throw new CoolException(wrkMast.getLocNo() + "任务库存明细转移失败!!!"); |
| | | } |
| | | |
| | | // 修改源库位状态 O.空库位 |
| | | LocMast sourceLocMast = locMastService.selectById(sourceLocNo); |
| | | if (sourceLocMast.getLocSts().equals("P")) { |
| | | sourceLocMast.setLocSts("O"); |
| | | sourceLocMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(sourceLocMast)) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "修改源库位状态 O.空库位"); |
| | | } |
| | | locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); |
| | | } |
| | | |
| | | // 条码设备处理 |
| | | barcodeThread.setBarcode(""); |
| | |
| | | public synchronized void pickWrkCompleteStaNo() { |
| | | List<WrkMast> wrkMasts = wrkMastMapper.selectPick17(null, null); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | // 修改源库位状态 O.空库位 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (locMast.getLocSts().equals("P")) { |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "修改源库位状态 O.空库位"); |
| | | } |
| | | locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); |
| | | } |
| | | // // 修改源库位状态 O.空库位 |
| | | // LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | // if (locMast.getLocSts().equals("P")) { |
| | | // locMast.setLocSts("O"); |
| | | // locMast.setModiTime(new Date()); |
| | | // if (!locMastService.updateById(locMast)) { |
| | | // throw new CoolException(wrkMast.getWrkNo() + "修改源库位状态 O.空库位"); |
| | | // } |
| | | // locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); |
| | | // } |
| | | // 修改工作档 |
| | | wrkMast.setIoPri(13D); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("更新工作档的优先级失败!!! [工作号:{}]", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 拣料/盘点转全板后,300站任务转100/200站去 |
| | | */ |
| | | public synchronized void transPickToFullChangeStn() { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历拣料出库口 |
| | | for (DevpSlave.Sta pickSta : devp.getPickOutSta()) { |
| | | // 获取拣料出库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && staProtocol.getWorkNo() > 0 |
| | | && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue()) |
| | | && staProtocol.isPakMk()){ |
| | | WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); |
| | | if(Cools.isEmpty(wrkMast)){ |
| | | log.error("拣料/盘点转全板,任务号工作档不存在===>>[任务号:{}]", staProtocol.getWorkNo()); |
| | | continue; |
| | | } |
| | | if (wrkMast.getIoType() != 101) { continue; } |
| | | |
| | | //拣料转全板默认出库站100站,当100站有物时,目标改200站 |
| | | Integer staNo = 100; |
| | | StaProtocol staProtocol100 = devpThread.getStation().get(staNo); |
| | | if (staProtocol100 == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol100 = staProtocol100.clone(); |
| | | } |
| | | if (staProtocol100.isLoading()) { |
| | | staNo = 200; |
| | | } |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(staNo.shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | log.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | } else { |
| | | wrkMast.setStaNo(staNo); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("更新工作档的目标站失败!!! [工作号:{}]", wrkMast.getWrkNo()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // 更新工作档状态为 17.出库完成 |
| | | wrkMast.setWrkSts(17L); |
| | | wrkMast.setSteNo(0); |
| | | wrkMast.setCrnEndTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) != 0) { |
| | | // 复位堆垛机 |
| | |
| | | // log.error("{}站点查询无待入库数据 工作号={}", crnStn.getStaNo(), staProtocol.getWorkNo()); |
| | | continue; |
| | | } |
| | | |
| | | // 判断是否已存在小车绑定任务 |
| | | BasSte basSte = basSteService.findByCrnNo(wrkMast.getCrnNo()); |
| | | if(basSte == null) continue; |
| | | WrkMast one1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("ste_no",basSte.getSteNo()) |
| | | .last(" and wrk_sts > 10")); |
| | | if(one1 != null){ |
| | | log.error("{}入库任务无法作业,因出库任务已绑定小车!", wrkMast.getWrkNo()); |
| | | continue; |
| | | } |
| | | |
| | | if (wrkMast.getWrkSts() < 3) { |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable() |
| | | && staDetl.getCanining()!=null && staDetl.getCanining().equals("Y")) { |
| | |
| | | } |
| | | // 没有小车 |
| | | } else { |
| | | if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) { |
| | | if (wrkMast.getWrkSts() == 2L && (wrkMast.getSteNo() == null || wrkMast.getSteNo() == 0)) { |
| | | // 寻找当前堆垛机对应的小车 |
| | | SteThread steThread = queryIdleCar(wrkMast); |
| | | if (steThread != null) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 判断是否已存在小车绑定任务 |
| | | BasSte basSte = basSteService.findByCrnNo(wrkMast.getCrnNo()); |
| | | if(basSte == null) continue; |
| | | WrkMast one1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("ste_no",basSte.getSteNo()) |
| | | .last(" and wrk_sts < 10")); |
| | | if(one1 != null){ |
| | | log.error("{}出库任务无法作业,因入库任务已绑定小车!", wrkMast.getWrkNo()); |
| | | continue; |
| | | } |
| | | |
| | | //加强判断,确保因出库导致的移库整套任务全部结束后,才能执行下一笔出库任务。只有库位完成移库回去全部任务后,才认为当组出库任务完成 |
| | | WrkMast one = wrkMastMapper.selectLocMoveData(slave.getId()); |
| | | if(!Cools.isEmpty(one)){ |
| | | //存在移库任务,且在移出中,且移库源库位与待出库库位不在同一库位组,时跳出,确保移库/出库全套任务完成后,再执行下一笔 |
| | | if(one.getWrkSts() > 10 && (Utils.getGroupRow(wrkMast.getSourceLocNo()) != Utils.getGroupRow(one.getSourceLocNo()) |
| | | if(wrkMast.getWrkNo() == 11 && one.getWrkSts() > 10 && (Utils.getGroupRow(wrkMast.getSourceLocNo()) != Utils.getGroupRow(one.getSourceLocNo()) |
| | | || Utils.getBay(wrkMast.getSourceLocNo()) != Utils.getBay(one.getSourceLocNo()) |
| | | || Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(one.getSourceLocNo()))){ |
| | | continue; |
| | | } |
| | | //存在移库任务,且在移回中,且移库目标库位与待出库库位不在同一库位组,时跳出,确保移库/出库全套任务完成后,再执行下一笔 |
| | | if(one.getWrkSts() < 11 && (Utils.getGroupRow(wrkMast.getSourceLocNo()) != Utils.getGroupRow(one.getLocNo()) |
| | | if(wrkMast.getWrkNo() == 11 && one.getWrkSts() < 11 && (Utils.getGroupRow(wrkMast.getSourceLocNo()) != Utils.getGroupRow(one.getLocNo()) |
| | | || Utils.getBay(wrkMast.getSourceLocNo()) != Utils.getBay(one.getLocNo()) |
| | | || Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(one.getLocNo()))){ |
| | | continue; |
| | | } |
| | | log.info(""); |
| | | } |
| | | |
| | | //出库库位不是最外层库位,判断浅库位组是否都为空,或存在库位移转任务 |
| | | boolean flag = false; |
| | | if(!locMastService.isOutMost(wrkMast.getSourceLocNo())){ |
| | | WrkMast wrkMastMove = wrkMastMapper.selectLocMoveWorking(slave.getId()); |
| | | if(wrkMastMove != null){ |
| | | if(wrkMastMove != null && wrkMast.getWrkNo() == 11){ |
| | | continue; |
| | | } |
| | | |
| | |
| | | if (null == wrkMast) { |
| | | return; |
| | | } |
| | | // 过滤 |
| | | if (null != wrkMastMapper.selectPakin(slave.getId(), null)) { |
| | | log.error("{}出库任务无法作业,因存在入库中任务!", wrkMast.getWrkNo()); |
| | | return; |
| | | } |
| | | |
| | | // 判断是否已存在小车绑定任务 |
| | | BasSte basSte = basSteService.findByCrnNo(wrkMast.getCrnNo()); |
| | | if(basSte == null) return; |
| | | WrkMast one = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("ste_no",basSte.getSteNo()) |
| | | .last(" and io_type != 11 and wrk_sts < 10")); |
| | | if(one != null){ |
| | | log.error("{}移库任务无法作业,因入库任务已绑定小车!", wrkMast.getWrkNo()); |
| | | return; |
| | | } |
| | | |
| | | // 获取源库位信息 |
| | | LocMast sourceLoc = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (null == sourceLoc) { |
| | |
| | | } |
| | | } |
| | | LocMast sourceLoc = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if(sourceLoc.getLocSts().equals("F")){ |
| | | if(sourceLoc.getLocSts().equals("F") || sourceLoc.getLocSts().equals("D")){ |
| | | sourceLoc.setLocSts("R"); // R.出库预约 |
| | | sourceLoc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(sourceLoc)) { |
| | |
| | | if (wrkMast.getWrkSts() == 2L && (wrkMast.getSteNo() == null || wrkMast.getSteNo() == 0)) { |
| | | // 没有其他任务 |
| | | if (null == wrkMastMapper.selectPakin(slave.getId(), steNo)) { |
| | | this.letCarBeWaiting(wrkMast, steNo, wrkMast.getLocNo()); |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { return; } |
| | | if(steProtocol.getLoca()==3 || steProtocol.getLoca()==4){ |
| | | //小车已经在待机位时,无需下发到待机位任务,直接更新状态微3,同时绑定小车 |
| | | wrkMast.setWrkSts(3L); |
| | | wrkMast.setSteNo(steNo); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error("修改工作档状态 绑定穿梭车 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | } else { |
| | | this.letCarBeWaiting(wrkMast, steNo, wrkMast.getLocNo()); |
| | | } |
| | | } |
| | | } |
| | | // 堆垛机将货放至小车上 3.小车待搬(小车不用搬运,已经在当前组库位) / 6.小车待入 ===>> 7.吊车入库中 |
| | |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { return; } |
| | | if (steProtocol.isIdle()) { |
| | | if (steProtocol.isIdle() && steProtocol.getLoad() == 0) { |
| | | // 堆垛机空闲 |
| | | if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) { |
| | | LocMast locMast; |
| | |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { return; } |
| | | // 穿梭车空闲 |
| | | if (steProtocol.isIdle()) { |
| | | if (steProtocol.isIdle() && steProtocol.getLoad() == 0) { |
| | | // 堆垛机空闲 |
| | | if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) { |
| | | |
| | |
| | | log.error("库位移转 ===>> 转移库存明细数据失败;[源库位={}],[目标库位={}]", wrkMast.getSourceLocNo(), wrkMast.getLocNo()); |
| | | continue; |
| | | } |
| | | } else { |
| | | locSts = "D"; |
| | | } |
| | | if(Cools.isEmpty(locSts)){ |
| | | log.error("库位移转 ===>> 库存状态为空;[源库位={}],[目标库位={}]", wrkMast.getSourceLocNo(), wrkMast.getLocNo()); |