| | |
| | | } |
| | | |
| | | /** |
| | | * 因双深库位阻塞,对浅库位进行移转(立即执行版) |
| | | * 因双深库位阻塞,对浅库位进行移转 |
| | | * tip:同步 |
| | | */ |
| | | private synchronized boolean moveLocForDeepLoc(CrnSlave crn, CrnProtocol crnProtocol, LocMast shallowLoc, Integer mark) { |
| | | try { |
| | | News.warnNoLog("" + mark + "moveLocForDeepLoc" + " - 0" + " - 开始执行:因双深库位阻塞,对浅库位进行移转(立即执行版)"); |
| | | List<Integer> rows = locMastService.queryDistinctRow(crn.getId()); |
| | | LocMast loc = null; |
| | | for (Integer row : rows) { |
| | | if (Utils.isDeepLoc(slaveProperties, row)) { |
| | | loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1()); |
| | | if (loc != null) { |
| | | if (crn.getId() == 1) { |
| | | if (Utils.getLaneByLocNo(loc.getLocNo()) != crnProtocol.getCrnLane()) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (Utils.isDeepLoc(slaveProperties, loc.getLocNo())) { |
| | | String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo()); |
| | | LocMast shallowLoc1 = locMastService.selectById(shallowLocNo); |
| | | if (!shallowLoc1.getLocSts().equals("O")) { |
| | | loc = null; |
| | | } |
| | | } |
| | | } |
| | | if (null != loc) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (null == loc) { |
| | | for (Integer row : rows) { |
| | | if (Utils.isShallowLoc(slaveProperties, row)) { |
| | | loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1()); |
| | | |
| | | if (null != loc) {//对应深库位非在库状态,不能移库 |
| | | if (crn.getId() == 1) { |
| | | if (Utils.getLaneByLocNo(loc.getLocNo()) != crnProtocol.getCrnLane()) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | String deepLoc = Utils.getDeepLoc(slaveProperties, loc.getLocNo()); |
| | | LocMast deepLoc1 = locMastService.selectById(deepLoc); |
| | | if (!deepLoc1.getLocSts().equals("F") && !deepLoc1.getLocSts().equals("D")) { |
| | | loc = null; |
| | | } |
| | | } |
| | | |
| | | if (null != loc) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (null == loc) { |
| | | News.error("" + mark + "moveLocForDeepLoc" + " - 1" + " - 双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo()); |
| | | Object lock = redisUtil.get(RedisConstantType.TRANSFER_LOCK + shallowLoc.getLocNo()); |
| | | if (lock != null) { |
| | | return false; |
| | | // throw new CoolException("双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo()); |
| | | } else { |
| | | String deepLoc2 = Utils.getDeepLoc2(slaveProperties, loc.getLocNo()); |
| | | if (deepLoc2 != null) { |
| | | LocMast locnew = locMastService.selectById(deepLoc2); |
| | | if (locnew != null && locnew.getLocSts().equals("O")) { |
| | | loc = locnew; |
| | | } |
| | | } |
| | | |
| | | |
| | | redisUtil.set(RedisConstantType.TRANSFER_LOCK + shallowLoc.getLocNo(), "lock", 15); |
| | | try { |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | wrkMast.setIoPri(13D); |
| | | wrkMast.setCrnNo(crn.getId()); |
| | | wrkMast.setSourceLocNo(shallowLoc.getLocNo()); // 源库位 |
| | | wrkMast.setLocNo(loc.getLocNo()); // 目标库位 |
| | | // wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 满板 |
| | | wrkMast.setFullPlt(shallowLoc.getLocSts().equals("D") ? "N" : "Y"); // 满板 |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | wrkMast.setBarcode(shallowLoc.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | int res = wrkMastMapper.insert(wrkMast); |
| | | if (res == 0) { |
| | | News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 2" + " - 保存工作档失败"); |
| | | // throw new CoolException("保存工作档失败"); |
| | | return true; |
| | | } |
| | | // 工作档明细保存 |
| | | if (shallowLoc.getLocSts().equals("F")) { |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); |
| | | |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | // VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制 |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 3" + " - 保存工作档明细失败"); |
| | | // throw new CoolException("保存工作档明细失败"); |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | // 修改源库位状态 |
| | | if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) { |
| | | shallowLoc.setLocSts("R"); // R.出库预约 |
| | | shallowLoc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(shallowLoc)) { |
| | | News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 4" + " - 更新源库位状态失败"); |
| | | // throw new CoolException("更新源库位状态失败"); |
| | | return true; |
| | | } |
| | | } else { |
| | | News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 5" + " - 源库位出库失败"); |
| | | // throw new CoolException("源库位出库失败"); |
| | | return true; |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(loc)) { |
| | | News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 6" + " - 更新目标库位状态失败"); |
| | | // throw new CoolException("更新目标库位状态失败"); |
| | | return true; |
| | | } |
| | | } else { |
| | | News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 7" + " - 移转失败"); |
| | | // throw new CoolException("移转失败"); |
| | | return true; |
| | | } |
| | | } catch (Exception e) { |
| | | News.error("" + mark + "moveLocForDeepLoc" + " - 8" + " - 双深库位阻塞,对浅库位进行移转失败", e); |
| | | } |
| | | int lane = 0; |
| | | if (crnProtocol.getCrnNo() == 1) { |
| | | lane = crnProtocol.getCrnLane(); |
| | | } |
| | | |
| | | HashMap<String, Object> requestParam = new HashMap<>(); |
| | | requestParam.put("locNo", shallowLoc.getLocNo()); |
| | | requestParam.put("lane", lane); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/transfer/loc/v1") |
| | | .setJson(JSON.toJSONString(requestParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | return true; |
| | | } else { |
| | | News.error("" + mark + " - 5" + " - 请求移库接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/transfer/loc/v1", JSON.toJSONString(requestParam), response); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | News.error("" + mark + "moveLocForDeepLoc" + " - 8" + " - 双深库位阻塞,对浅库位进行移转失败", e); |
| | | // e.printStackTrace(); |
| | | // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | e.printStackTrace(); |
| | | } |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | | // /** |
| | | // * 因双深库位阻塞,对浅库位进行移转(立即执行版) |
| | | // * tip:同步 |
| | | // */ |
| | | // private synchronized boolean moveLocForDeepLoc(CrnSlave crn, CrnProtocol crnProtocol, LocMast shallowLoc, Integer mark) { |
| | | // try { |
| | | // News.warnNoLog("" + mark + "moveLocForDeepLoc" + " - 0" + " - 开始执行:因双深库位阻塞,对浅库位进行移转(立即执行版)"); |
| | | // List<Integer> rows = locMastService.queryDistinctRow(crn.getId()); |
| | | // LocMast loc = null; |
| | | // for (Integer row : rows) { |
| | | // if (Utils.isDeepLoc(slaveProperties, row)) { |
| | | // loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1()); |
| | | // if (loc != null) { |
| | | // if (crn.getId() == 1) { |
| | | // if (Utils.getLaneByLocNo(loc.getLocNo()) != crnProtocol.getCrnLane()) { |
| | | // continue; |
| | | // } |
| | | // } |
| | | // |
| | | // if (Utils.isDeepLoc(slaveProperties, loc.getLocNo())) { |
| | | // String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo()); |
| | | // LocMast shallowLoc1 = locMastService.selectById(shallowLocNo); |
| | | // if (!shallowLoc1.getLocSts().equals("O")) { |
| | | // loc = null; |
| | | // } |
| | | // } |
| | | // } |
| | | // if (null != loc) { |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // if (null == loc) { |
| | | // for (Integer row : rows) { |
| | | // if (Utils.isShallowLoc(slaveProperties, row)) { |
| | | // loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1()); |
| | | // |
| | | // if (null != loc) {//对应深库位非在库状态,不能移库 |
| | | // if (crn.getId() == 1) { |
| | | // if (Utils.getLaneByLocNo(loc.getLocNo()) != crnProtocol.getCrnLane()) { |
| | | // continue; |
| | | // } |
| | | // } |
| | | // |
| | | // String deepLoc = Utils.getDeepLoc(slaveProperties, loc.getLocNo()); |
| | | // LocMast deepLoc1 = locMastService.selectById(deepLoc); |
| | | // if (!deepLoc1.getLocSts().equals("F") && !deepLoc1.getLocSts().equals("D")) { |
| | | // loc = null; |
| | | // } |
| | | // } |
| | | // |
| | | // if (null != loc) { |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // if (null == loc) { |
| | | // News.error("" + mark + "moveLocForDeepLoc" + " - 1" + " - 双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo()); |
| | | // return false; |
| | | //// throw new CoolException("双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo()); |
| | | // } else { |
| | | // String deepLoc2 = Utils.getDeepLoc2(slaveProperties, loc.getLocNo()); |
| | | // if (deepLoc2 != null) { |
| | | // LocMast locnew = locMastService.selectById(deepLoc2); |
| | | // if (locnew != null && locnew.getLocSts().equals("O")) { |
| | | // loc = locnew; |
| | | // } |
| | | // } |
| | | // |
| | | // |
| | | // try { |
| | | // // 获取工作号 |
| | | // int workNo = commonService.getWorkNo(0); |
| | | // // 保存工作档 |
| | | // WrkMast wrkMast = new WrkMast(); |
| | | // wrkMast.setWrkNo(workNo); |
| | | // wrkMast.setIoTime(new Date()); |
| | | // wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | // wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | // wrkMast.setIoPri(13D); |
| | | // wrkMast.setCrnNo(crn.getId()); |
| | | // wrkMast.setSourceLocNo(shallowLoc.getLocNo()); // 源库位 |
| | | // wrkMast.setLocNo(loc.getLocNo()); // 目标库位 |
| | | //// wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 满板 |
| | | // wrkMast.setFullPlt(shallowLoc.getLocSts().equals("D") ? "N" : "Y"); // 满板 |
| | | // wrkMast.setPicking("N"); // 拣料 |
| | | // wrkMast.setExitMk("N"); // 退出 |
| | | // wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | // wrkMast.setBarcode(shallowLoc.getBarcode()); // 托盘码 |
| | | // wrkMast.setLinkMis("N"); |
| | | // wrkMast.setAppeTime(new Date()); |
| | | // wrkMast.setModiTime(new Date()); |
| | | // int res = wrkMastMapper.insert(wrkMast); |
| | | // if (res == 0) { |
| | | // News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 2" + " - 保存工作档失败"); |
| | | //// throw new CoolException("保存工作档失败"); |
| | | // return true; |
| | | // } |
| | | // // 工作档明细保存 |
| | | // if (shallowLoc.getLocSts().equals("F")) { |
| | | // List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); |
| | | // |
| | | // for (LocDetl locDetl : locDetls) { |
| | | // WrkDetl wrkDetl = new WrkDetl(); |
| | | // wrkDetl.sync(locDetl); |
| | | // wrkDetl.setWrkNo(workNo); |
| | | // wrkDetl.setIoTime(new Date()); |
| | | // wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | //// VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制 |
| | | // wrkDetl.setAppeTime(new Date()); |
| | | // wrkDetl.setModiTime(new Date()); |
| | | // if (!wrkDetlService.insert(wrkDetl)) { |
| | | // News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 3" + " - 保存工作档明细失败"); |
| | | //// throw new CoolException("保存工作档明细失败"); |
| | | // return true; |
| | | // } |
| | | // } |
| | | // } |
| | | // // 修改源库位状态 |
| | | // if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) { |
| | | // shallowLoc.setLocSts("R"); // R.出库预约 |
| | | // shallowLoc.setModiTime(new Date()); |
| | | // if (!locMastService.updateById(shallowLoc)) { |
| | | // News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 4" + " - 更新源库位状态失败"); |
| | | //// throw new CoolException("更新源库位状态失败"); |
| | | // return true; |
| | | // } |
| | | // } else { |
| | | // News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 5" + " - 源库位出库失败"); |
| | | //// throw new CoolException("源库位出库失败"); |
| | | // return true; |
| | | // } |
| | | // // 修改目标库位状态 |
| | | // if (loc.getLocSts().equals("O")) { |
| | | // loc.setLocSts("S"); // S.入库预约 |
| | | // loc.setModiTime(new Date()); |
| | | // if (!locMastService.updateById(loc)) { |
| | | // News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 6" + " - 更新目标库位状态失败"); |
| | | //// throw new CoolException("更新目标库位状态失败"); |
| | | // return true; |
| | | // } |
| | | // } else { |
| | | // News.errorNoLog("" + mark + "moveLocForDeepLoc" + " - 7" + " - 移转失败"); |
| | | //// throw new CoolException("移转失败"); |
| | | // return true; |
| | | // } |
| | | // } catch (Exception e) { |
| | | // News.error("" + mark + "moveLocForDeepLoc" + " - 8" + " - 双深库位阻塞,对浅库位进行移转失败", e); |
| | | // } |
| | | // } |
| | | // |
| | | // |
| | | // } catch (Exception e) { |
| | | // News.error("" + mark + "moveLocForDeepLoc" + " - 8" + " - 双深库位阻塞,对浅库位进行移转失败", e); |
| | | //// e.printStackTrace(); |
| | | //// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | // } |
| | | // return true; |
| | | // } |
| | | |
| | | /** |
| | | * 堆垛机演示 ===>> 库位移转 |
| | | */ |