|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SnowflakeIdWorker snowflakeIdWorker; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | private OrderPakoutService orderPakoutService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderDetlService orderDetlService; | 
|---|
|  |  |  | private OrderPakinService orderPakinService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderDetlPakoutService orderDetlPakoutService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderDetlPakinService orderDetlPakinService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WcsController wcsController; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | private SlaveProperties slaveProperties; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaitPakinService waitPakinService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private InventoryCheckOrderDetlService inventoryCheckOrderDetlService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | 
|---|
|  |  |  | List<LocDetlDto> locDetlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { | 
|---|
|  |  |  | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getSku()); | 
|---|
|  |  |  | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!locDetlDtos.isEmpty()) { | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); | 
|---|
|  |  |  | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D")) { | 
|---|
|  |  |  | // 启动出库开始 101.出库 | 
|---|
|  |  |  | stockOut(staNo, locDetlDtos, null, userId); | 
|---|
|  |  |  | if (staNo.getDevNo() == 1135 && locMast.getLocType1() == 2) { | 
|---|
|  |  |  | throw new CoolException("所选库位不是低库位无法调拨,库位号:{}" + locMast.getLocNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (staNo.getDevNo() >= 1100) { | 
|---|
|  |  |  | // 启动出库开始 101.出库 | 
|---|
|  |  |  | stockOut(staNo, locDetlDtos, null, userId); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | stockOutSXK(staNo, locDetlDtos, null, userId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("所选库位存在状态不为F、D的库位,库位号:" + locMast.getLocNo() + " 、当前状态:" + locMast.getLocSts() + "-" + locMast.getLocSts$()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer outSta = staNo.getDevNo(); | 
|---|
|  |  |  | if (outSta == 1135 || outSta == 1031) { | 
|---|
|  |  |  | if (101 != ioType) { | 
|---|
|  |  |  | throw new CoolException("该站点必须全板出库,出库库位号:" + dto.getLocNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            //2号堆垛机全板出库站指定为204站,拣料站指定为202 | 
|---|
|  |  |  | //            if(locMast.getCrnNo()==2){ | 
|---|
|  |  |  | //                outSta = ioType == 101 ? 204 : 202; | 
|---|
|  |  |  | 
|---|
|  |  |  | // 生成工作档明细 | 
|---|
|  |  |  | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | InventoryCheckOrderDetl inventoryCheckOrderDetl = new InventoryCheckOrderDetl(); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setOrderNo(param.getOrderNo()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setMatnr(detlDto.getLocDetl().getMatnr()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setMaktx(detlDto.getLocDetl().getMaktx()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setBatch(detlDto.getLocDetl().getBatch()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setLocNo(detlDto.getLocDetl().getLocNo()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setArea(detlDto.getLocDetl().getOrigin()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setAnfme(detlDto.getLocDetl().getAnfme()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setIoTime(now); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setStatus("1"); | 
|---|
|  |  |  | if (!inventoryCheckOrderDetlService.insert(inventoryCheckOrderDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存盘点明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (locDto.getAnfme() == null || locDto.getAnfme() <= 0.0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); | 
|---|
|  |  |  | if (orderDetl == null) { | 
|---|
|  |  |  | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); | 
|---|
|  |  |  | OrderDetlPakout orderDetlPakout = orderDetlPakoutService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); | 
|---|
|  |  |  | if (orderDetlPakout == null) { | 
|---|
|  |  |  | orderDetlPakout = orderDetlPakoutService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | wrkDetl.sync(orderDetl); | 
|---|
|  |  |  | wrkDetl.sync(orderDetlPakout); | 
|---|
|  |  |  | wrkDetl.setZpallet(wrkMast.getBarcode()); | 
|---|
|  |  |  | wrkDetl.setIoTime(now); | 
|---|
|  |  |  | wrkDetl.setWrkNo(workNo); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单明细 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQty(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { | 
|---|
|  |  |  | if (!orderDetlPakoutService.increaseWorkQtyById(orderDetlPakout.getId(), locDto.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改订单明细数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); | 
|---|
|  |  |  | orderPakoutService.updateSettle(orderDetlPakout.getOrderId(), 2L, userId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改库位状态:   F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 | 
|---|
|  |  |  | locMast = locMastService.selectById(taskDto.getLocNo()); | 
|---|
|  |  |  | 
|---|
|  |  |  | LocMast locMast = locMastService.selectById(taskDto.getLocNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocMast> locMasts = new ArrayList<>(); | 
|---|
|  |  |  | if ((locMast.getBay1() >= 1 && locMast.getBay1() <= 2) || (locMast.getBay1() >= 6 && locMast.getBay1() <= 7 && locMast.getRow1() != 36 && locMast.getRow1() != 29) || (locMast.getBay1() >= 11 && locMast.getBay1() <= 12)) { | 
|---|
|  |  |  | if ((locMast.getBay1() >= 3 && locMast.getBay1() <= 6)) { | 
|---|
|  |  |  | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("gro1", locMast.getGro1()) | 
|---|
|  |  |  | .eq("crn_no", 7) | 
|---|
|  |  |  | .eq("loc_type1", locMast.getLocType1()) | 
|---|
|  |  |  | .orderBy("bay1", false)); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("gro1", locMast.getGro1()) | 
|---|
|  |  |  | .eq("row1", locMast.getBay1()) | 
|---|
|  |  |  | .in("bay1", 3, 4, 5, 6) | 
|---|
|  |  |  | .eq("crn_no", 7) | 
|---|
|  |  |  | .eq("loc_type1", locMast.getLocType1()) | 
|---|
|  |  |  | .orderBy("bay1", true)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (LocMast locMast1 : locMasts) { | 
|---|
|  |  |  | if (locMast1.getLocNo().equals(taskDto.getLocNo())) { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast1.getLocSts().equals("X")) { | 
|---|
|  |  |  | throw new CoolException(taskDto.getLocNo() + "库位前方有锁定库位,禁止出库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast1.getLocSts().equals("F")) { | 
|---|
|  |  |  | moveLocForDeepLoc(locMast1); | 
|---|
|  |  |  | for (LocMast locMast1 : locMasts) { | 
|---|
|  |  |  | if (locMast1.getLocNo().equals(taskDto.getLocNo())) { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast1.getLocSts().equals("X")) { | 
|---|
|  |  |  | throw new CoolException(taskDto.getLocNo() + "库位前方有锁定库位,禁止出库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast1.getLocSts().equals("F")) { | 
|---|
|  |  |  | locMast = locMast1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取路径 | 
|---|
|  |  |  | int ioType = taskDto.isAll() ? 101 : 103; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (locDto.getAnfme() == null || locDto.getAnfme() <= 0.0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); | 
|---|
|  |  |  | if (orderDetl == null) { | 
|---|
|  |  |  | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); | 
|---|
|  |  |  | OrderDetlPakout orderDetlPakout = orderDetlPakoutService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); | 
|---|
|  |  |  | if (orderDetlPakout == null) { | 
|---|
|  |  |  | orderDetlPakout = orderDetlPakoutService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | wrkDetl.sync(orderDetl); | 
|---|
|  |  |  | wrkDetl.sync(orderDetlPakout); | 
|---|
|  |  |  | wrkDetl.setZpallet(wrkMast.getBarcode()); | 
|---|
|  |  |  | wrkDetl.setIoTime(now); | 
|---|
|  |  |  | wrkDetl.setWrkNo(workNo); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单明细 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQty(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { | 
|---|
|  |  |  | if (!orderDetlPakoutService.increaseWorkQty(orderDetlPakout.getOrderId(), orderDetlPakout.getMatnr(), orderDetlPakout.getBatch(), locDto.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改订单明细数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); | 
|---|
|  |  |  | orderPakoutService.updateSettle(orderDetlPakout.getOrderId(), 2L, userId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改库位状态:   F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 | 
|---|
|  |  |  | locMast = locMastService.selectById(taskDto.getLocNo()); | 
|---|
|  |  |  | 
|---|
|  |  |  | List<LocDetlDto> locDetlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { | 
|---|
|  |  |  | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getSku()); | 
|---|
|  |  |  | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | List<LocDetlDto> locDetlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { | 
|---|
|  |  |  | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getSku()); | 
|---|
|  |  |  | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | // 生成工作档明细 | 
|---|
|  |  |  | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | InventoryCheckOrderDetl inventoryCheckOrderDetl = new InventoryCheckOrderDetl(); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setOrderNo(param.getOrderNo()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setMatnr(detlDto.getLocDetl().getMatnr()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setMaktx(detlDto.getLocDetl().getMaktx()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setBatch(detlDto.getLocDetl().getBatch()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setLocNo(detlDto.getLocDetl().getLocNo()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setArea(detlDto.getLocDetl().getOrigin()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setAnfme(detlDto.getLocDetl().getAnfme()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setIoTime(now); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setStatus("1"); | 
|---|
|  |  |  | if (!inventoryCheckOrderDetlService.insert(inventoryCheckOrderDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存盘点明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(wrkMast)) { | 
|---|
|  |  |  | throw new CoolException(workNo + "工作档不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 14) { | 
|---|
|  |  |  | if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 5 || wrkMast.getWrkSts() == 14 || wrkMast.getWrkSts() == 15) { | 
|---|
|  |  |  | throw new CoolException("当前工作档已完成"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 入库 + 库位转移 | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | throw new CoolException("库位不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!(locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") || locMast.getLocSts().equals("O"))) { | 
|---|
|  |  |  | if (!(locMast.getLocSts().equals("P") || locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") || locMast.getLocSts().equals("O"))) { | 
|---|
|  |  |  | throw new CoolException("当前库位不可调整!库位状态:" + locMast.getLocSts$()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!locDetl.getAnfme().equals(adjust.getCount())) { | 
|---|
|  |  |  | // todo 盘点记录 | 
|---|
|  |  |  | // 修改库存 | 
|---|
|  |  |  | if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch())) { | 
|---|
|  |  |  | if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getSku())) { | 
|---|
|  |  |  | throw new CoolException(locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号修改数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 保存调整记录 | 
|---|
|  |  |  | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(adjust.getMatnr()); | 
|---|
|  |  |  | LocDetl locDetl = new LocDetl(); | 
|---|
|  |  |  | locDetl.sync(mat); | 
|---|
|  |  |  | locDetl.setBatch(adjust.getBatch()); | 
|---|
|  |  |  | locDetl.setDanger(adjust.getDanger()); | 
|---|
|  |  |  | locDetl.setSku(adjust.getBatch()); | 
|---|
|  |  |  | locDetl.setLocNo(locMast.getLocNo()); | 
|---|
|  |  |  | locDetl.setAnfme(adjust.getCount()); // 数量 | 
|---|
|  |  |  | locDetl.setModiUser(userId); // 操作人员信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locMast.setModiUser(userId); | 
|---|
|  |  |  | locMast.setModiTime(now); | 
|---|
|  |  |  | if (locMast.getLocSts().equals("O")) { | 
|---|
|  |  |  | locMast.setBarcode(""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!locMastService.updateById(locMast)) { | 
|---|
|  |  |  | throw new CoolException("更新库位状态失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | for (WrkDetl wrkDetl : wrkDetls) { | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkDetl.getOrderNo())) { | 
|---|
|  |  |  | if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { | 
|---|
|  |  |  | if (!orderDetlPakoutService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("订单数据回滚失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //修改订单主表状态,没有作业数量时才可以修改 | 
|---|
|  |  |  | boolean flag = true; | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", wrkDetl.getOrderNo())); | 
|---|
|  |  |  | for (OrderDetl orderDetl : orderDetls) { | 
|---|
|  |  |  | if (orderDetl.getWorkQty() > 0) { | 
|---|
|  |  |  | List<OrderDetlPakout> orderDetlPakouts = orderDetlPakoutService.selectList(new EntityWrapper<OrderDetlPakout>().eq("order_no", wrkDetl.getOrderNo())); | 
|---|
|  |  |  | for (OrderDetlPakout orderDetlPakout : orderDetlPakouts) { | 
|---|
|  |  |  | if (orderDetlPakout.getWorkQty() > 0) { | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (flag) { | 
|---|
|  |  |  | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", wrkDetl.getOrderNo())); | 
|---|
|  |  |  | OrderPakout order = orderPakoutService.selectOne(new EntityWrapper<OrderPakout>().eq("order_no", wrkDetl.getOrderNo())); | 
|---|
|  |  |  | if (!Cools.isEmpty(order) && order.getSettle() == 2) { | 
|---|
|  |  |  | order.setSettle(1L); | 
|---|
|  |  |  | order.setUpdateBy(userId); | 
|---|
|  |  |  | order.setUpdateTime(now); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!orderService.update(order, new EntityWrapper<Order>().eq("order_no", wrkDetl.getOrderNo()))) { | 
|---|
|  |  |  | if (!orderPakoutService.update(order, new EntityWrapper<OrderPakout>().eq("order_no", wrkDetl.getOrderNo()))) { | 
|---|
|  |  |  | throw new CoolException("修改订单状态失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | // 获取目标站 | 
|---|
|  |  |  | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("type_no", wrkMast.getIoType() - 50) | 
|---|
|  |  |  | .eq("stn_no", wrkMast.getStaNo()) // 作业站点 = 拣料出库的目标站 | 
|---|
|  |  |  | .eq("stn_no", wrkMast.getSourceStaNo()) // 作业站点 = 拣料出库的目标站 | 
|---|
|  |  |  | .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 | 
|---|
|  |  |  | StaDesc staDesc = staDescService.selectOne(wrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(staDesc)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | List<LocDetlDto> locDetlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { | 
|---|
|  |  |  | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getSku()); | 
|---|
|  |  |  | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | List<LocDetlDto> locDetlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { | 
|---|
|  |  |  | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); | 
|---|
|  |  |  | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getSku()); | 
|---|
|  |  |  | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocMast> locMasts = new ArrayList<>(); | 
|---|
|  |  |  | if ((locMast.getBay1() >= 1 && locMast.getBay1() <= 2) || (locMast.getBay1() >= 6 && locMast.getBay1() <= 7 && locMast.getRow1() != 36 && locMast.getRow1() != 29) || (locMast.getBay1() >= 11 && locMast.getBay1() <= 12)) { | 
|---|
|  |  |  | //            if ((locMast.getBay1() >= 1 && locMast.getBay1() <= 2) || (locMast.getBay1() >= 6 && locMast.getBay1() <= 7 && locMast.getRow1() != 36 && locMast.getRow1() != 29) || (locMast.getBay1() >= 11 && locMast.getBay1() <= 12)) { | 
|---|
|  |  |  | //                locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | //                        .eq("gro1", locMast.getGro1()) | 
|---|
|  |  |  | //                        .eq("crn_no", 7) | 
|---|
|  |  |  | //                        .eq("loc_type1", locMast.getLocType1()) | 
|---|
|  |  |  | //                        .orderBy("bay1", false)); | 
|---|
|  |  |  | //            } else { | 
|---|
|  |  |  | //                locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | //                        .eq("gro1", locMast.getGro1()) | 
|---|
|  |  |  | //                        .eq("crn_no", 7) | 
|---|
|  |  |  | //                        .eq("loc_type1", locMast.getLocType1()) | 
|---|
|  |  |  | //                        .orderBy("bay1", true)); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            for (LocMast locMast1 : locMasts) { | 
|---|
|  |  |  | //                if (locMast1.getLocNo().equals(dto.getLocNo())) { | 
|---|
|  |  |  | //                    break; | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (locMast1.getLocSts().equals("X")) { | 
|---|
|  |  |  | //                    throw new CoolException(dto.getLocNo() + "库位前方有锁定库位,禁止出库"); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (locMast1.getLocSts().equals("F")) { | 
|---|
|  |  |  | //                    moveLocForDeepLoc(locMast1); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | if ((locMast.getBay1() >= 3 && locMast.getBay1() <= 6)) { | 
|---|
|  |  |  | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("gro1", locMast.getGro1()) | 
|---|
|  |  |  | .eq("crn_no", 7) | 
|---|
|  |  |  | .eq("loc_type1", locMast.getLocType1()) | 
|---|
|  |  |  | .orderBy("bay1", false)); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("gro1", locMast.getGro1()) | 
|---|
|  |  |  | .eq("row1", locMast.getBay1()) | 
|---|
|  |  |  | .in("bay1", 3, 4, 5, 6) | 
|---|
|  |  |  | .eq("crn_no", 7) | 
|---|
|  |  |  | .eq("loc_type1", locMast.getLocType1()) | 
|---|
|  |  |  | .orderBy("bay1", true)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (LocMast locMast1 : locMasts) { | 
|---|
|  |  |  | if (locMast1.getLocNo().equals(dto.getLocNo())) { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast1.getLocSts().equals("X")) { | 
|---|
|  |  |  | throw new CoolException(dto.getLocNo() + "库位前方有锁定库位,禁止出库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast1.getLocSts().equals("F")) { | 
|---|
|  |  |  | moveLocForDeepLoc(locMast1); | 
|---|
|  |  |  | for (LocMast locMast1 : locMasts) { | 
|---|
|  |  |  | if (locMast1.getLocNo().equals(locMast.getLocNo())) { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast1.getLocSts().equals("X")) { | 
|---|
|  |  |  | throw new CoolException(locMast.getLocNo() + "库位前方有锁定库位,禁止出库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast1.getLocSts().equals("F")) { | 
|---|
|  |  |  | locMast = locMast1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer outSta = staNo.getDevNo(); | 
|---|
|  |  |  | //            //2号堆垛机全板出库站指定为204站,拣料站指定为202 | 
|---|
|  |  |  | 
|---|
|  |  |  | WrkMast wrkMast = new WrkMast(); | 
|---|
|  |  |  | wrkMast.setWrkNo(workNo); | 
|---|
|  |  |  | wrkMast.setIoTime(new Date()); | 
|---|
|  |  |  | wrkMast.setWrkSts(1L); // 工作状态:1.生成入库ID | 
|---|
|  |  |  | wrkMast.setIoType(1); // 入出库状态: 1.库格移载 | 
|---|
|  |  |  | wrkMast.setWrkSts(2L); // 工作状态:1.生成入库ID | 
|---|
|  |  |  | wrkMast.setIoType(wrkMastold.getIoType() - 100); // 入出库状态: 1.库格移载 | 
|---|
|  |  |  | wrkMast.setIoPri(12D); | 
|---|
|  |  |  | wrkMast.setStaNo(1032); | 
|---|
|  |  |  | wrkMast.setSourceStaNo(1031); | 
|---|
|  |  |  | wrkMast.setCrnNo(7); | 
|---|
|  |  |  | wrkMast.setLocNo(dto.getLocNo()); // 目标库位 | 
|---|
|  |  |  | wrkMast.setFullPlt("Y"); // 满板 | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkMast.setEmptyMk("Y"); // 空板 | 
|---|
|  |  |  | wrkMast.setBarcode(wrkMastold.getBarcode()); // 托盘码 | 
|---|
|  |  |  | wrkMast.setLinkMis("N"); | 
|---|
|  |  |  | wrkMast.setPltType(wrkMastold.getWrkNo()); | 
|---|
|  |  |  | wrkMast.setAppeTime(new Date()); | 
|---|
|  |  |  | wrkMast.setModiTime(new Date()); | 
|---|
|  |  |  | boolean res = wrkMastService.insert(wrkMast); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("保存工作档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 工作档明细保存 | 
|---|
|  |  |  | for (WrkDetl wrk : wrkDetls) { | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | Synchro.Copy(wrk, wrkDetl); | 
|---|
|  |  |  | wrkDetl.setWrkNo(workNo); | 
|---|
|  |  |  | wrkDetl.setIoTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setAnfme(wrk.getAnfme()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setModiTime(new Date()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | if (wrkDetls != null) { | 
|---|
|  |  |  | for (WrkDetl wrk : wrkDetls) { | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | Synchro.Copy(wrk, wrkDetl); | 
|---|
|  |  |  | wrkDetl.setWrkNo(workNo); | 
|---|
|  |  |  | wrkDetl.setIoTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setAnfme(wrk.getAnfme()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setModiTime(new Date()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改目标库位状态 | 
|---|
|  |  |  | 
|---|
|  |  |  | public void toCrn(WrkMast wrkMastold, List<WrkDetl> wrkDetls, Short locType) { | 
|---|
|  |  |  | LocTypeDto locTypeDto = new LocTypeDto(); | 
|---|
|  |  |  | locTypeDto.setLocType1(locType); | 
|---|
|  |  |  | StartupDto dto = commonService.getLocNo(1, 1035, null, null, null, locTypeDto, false); | 
|---|
|  |  |  | StartupDto dto = commonService.getLocNo(1, 1135, null, null, null, locTypeDto, false); | 
|---|
|  |  |  | if (Cools.isEmpty(dto)) { | 
|---|
|  |  |  | throw new CoolException("去堆垛机未找到库位"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkMast.setWrkNo(workNo); | 
|---|
|  |  |  | wrkMast.setIoTime(new Date()); | 
|---|
|  |  |  | wrkMast.setWrkSts(1L); // 工作状态:1.生成入库ID | 
|---|
|  |  |  | wrkMast.setIoType(1); // 入出库状态: 1.入库 | 
|---|
|  |  |  | wrkMast.setIoType(wrkMastold.getIoType() - 100);  // 入出库状态: 1.入库 | 
|---|
|  |  |  | wrkMast.setIoPri(12D); | 
|---|
|  |  |  | wrkMast.setCrnNo(7); | 
|---|
|  |  |  | wrkMast.setCrnNo(1); | 
|---|
|  |  |  | wrkMast.setStaNo(1131); | 
|---|
|  |  |  | wrkMast.setSourceStaNo(1135); | 
|---|
|  |  |  | wrkMast.setLocNo(dto.getLocNo()); // 目标库位 | 
|---|
|  |  |  | wrkMast.setFullPlt("Y"); // 满板 | 
|---|
|  |  |  | wrkMast.setFullPlt(wrkDetls == null ? "N" : "Y"); // 满板 | 
|---|
|  |  |  | wrkMast.setPicking("N"); // 拣料 | 
|---|
|  |  |  | wrkMast.setExitMk("N"); // 退出 | 
|---|
|  |  |  | wrkMast.setEmptyMk("Y"); // 空板 | 
|---|
|  |  |  | wrkMast.setEmptyMk(wrkDetls != null ? "N" : "Y"); // 空板 | 
|---|
|  |  |  | wrkMast.setBarcode(wrkMastold.getBarcode()); // 托盘码 | 
|---|
|  |  |  | wrkMast.setLinkMis("N"); | 
|---|
|  |  |  | wrkMast.setPltType(wrkMastold.getWrkNo()); | 
|---|
|  |  |  | wrkMast.setAppeTime(new Date()); | 
|---|
|  |  |  | wrkMast.setModiTime(new Date()); | 
|---|
|  |  |  | boolean res = wrkMastService.insert(wrkMast); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("保存工作档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 工作档明细保存 | 
|---|
|  |  |  | for (WrkDetl wrk : wrkDetls) { | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | Synchro.Copy(wrk, wrkDetl); | 
|---|
|  |  |  | wrkDetl.setWrkNo(workNo); | 
|---|
|  |  |  | wrkDetl.setIoTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setAnfme(wrk.getAnfme()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setModiTime(new Date()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | if (wrkDetls != null) { | 
|---|
|  |  |  | for (WrkDetl wrk : wrkDetls) { | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | Synchro.Copy(wrk, wrkDetl); | 
|---|
|  |  |  | wrkDetl.setWrkNo(workNo); | 
|---|
|  |  |  | wrkDetl.setIoTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setAnfme(wrk.getAnfme()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setModiTime(new Date()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改目标库位状态 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|