| | |
| | | @Transactional |
| | | public String startupFullPutStore(FullStoreParam param, Long userId) { |
| | | // 参数非空判断 |
| | | if (Cools.isEmpty(param.getDevpNo(), param.getList())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | Date now = new Date(); |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo(), true); |
| | | // 检索库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); |
| | | List<String> batchs = param.getList().stream().map(FullStoreParam.MatCodeStore::getBatch).distinct().collect(Collectors.toList()); |
| | | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 1, param.getDevpNo(), matnrs.get(0), batchs.get(0), null, locTypeDto); |
| | | // 生成工作号 |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(1L); // 工作状态:生成入库ID |
| | | wrkMast.setIoType(1); // 入出库状态:1.入库 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(dto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(dto.getSourceStaNo()); |
| | | wrkMast.setStaNo(dto.getStaNo()); |
| | | wrkMast.setLocNo(dto.getLocNo()); |
| | | wrkMast.setBarcode(param.getBarcode()); // 托盘码 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 生成工作档明细 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getList().forEach(elem -> { |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto detlDto1 = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert detlDto1 != null; |
| | | detlDto1.setAnfme(detlDto1.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | wrkDetlService.createWorkDetail(workNo, detlDtos, param.getBarcode(), userId, now); |
| | | // 更新源站点信息 |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiUser(userId); |
| | | sourceStaNo.setModiTime(now); |
| | | if (!basDevpService.updateById(sourceStaNo)) { |
| | | throw new CoolException("更新源站失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("O")) { |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "目标库位已被占用"); |
| | | } |
| | | return dto.getLocNo(); |
| | | // if (Cools.isEmpty(param.getDevpNo(), param.getList())) { |
| | | // throw new CoolException(BaseRes.PARAM); |
| | | // } |
| | | // Date now = new Date(); |
| | | // // 源站点状态检测 |
| | | // BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo(), true); |
| | | // // 检索库位 |
| | | // LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | // List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); |
| | | // List<String> batchs = param.getList().stream().map(FullStoreParam.MatCodeStore::getBatch).distinct().collect(Collectors.toList()); |
| | | // StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 1, param.getDevpNo(), matnrs.get(0), batchs.get(0), null, locTypeDto); |
| | | // // 生成工作号 |
| | | // int workNo = dto.getWorkNo(); |
| | | // // 生成工作档 |
| | | // WrkMast wrkMast = new WrkMast(); |
| | | // wrkMast.setWrkNo(workNo); |
| | | // wrkMast.setIoTime(now); |
| | | // wrkMast.setWrkSts(1L); // 工作状态:生成入库ID |
| | | // wrkMast.setIoType(1); // 入出库状态:1.入库 |
| | | // wrkMast.setIoPri(13D); // 优先级:13 |
| | | // wrkMast.setCrnNo(dto.getCrnNo()); |
| | | // wrkMast.setSourceStaNo(dto.getSourceStaNo()); |
| | | // wrkMast.setStaNo(dto.getStaNo()); |
| | | // wrkMast.setLocNo(dto.getLocNo()); |
| | | // wrkMast.setBarcode(param.getBarcode()); // 托盘码 |
| | | // wrkMast.setFullPlt("Y"); // 满板:Y |
| | | // wrkMast.setPicking("N"); // 拣料 |
| | | // wrkMast.setExitMk("N"); // 退出 |
| | | // wrkMast.setEmptyMk("N"); // 空板 |
| | | // wrkMast.setLinkMis("N"); |
| | | // wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | // wrkMast.setAppeUser(userId); |
| | | // wrkMast.setAppeTime(now); |
| | | // wrkMast.setModiUser(userId); |
| | | // wrkMast.setModiTime(now); |
| | | // if (!wrkMastService.insert(wrkMast)) { |
| | | // throw new CoolException("保存工作档失败"); |
| | | // } |
| | | // // 生成工作档明细 |
| | | // List<DetlDto> detlDtos = new ArrayList<>(); |
| | | // param.getList().forEach(elem -> { |
| | | // DetlDto detlDto = new DetlDto(elem); |
| | | // if (DetlDto.has(detlDtos, detlDto)) { |
| | | // DetlDto detlDto1 = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | // assert detlDto1 != null; |
| | | // detlDto1.setAnfme(detlDto1.getAnfme() + detlDto.getAnfme()); |
| | | // } else { |
| | | // detlDtos.add(detlDto); |
| | | // } |
| | | // }); |
| | | // wrkDetlService.createWorkDetail(workNo, detlDtos, param.getBarcode(), userId, now); |
| | | // // 更新源站点信息 |
| | | // sourceStaNo.setWrkNo(workNo); |
| | | // sourceStaNo.setModiUser(userId); |
| | | // sourceStaNo.setModiTime(now); |
| | | // if (!basDevpService.updateById(sourceStaNo)) { |
| | | // throw new CoolException("更新源站失败"); |
| | | // } |
| | | // // 更新目标库位状态 |
| | | // LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | // if (locMast.getLocSts().equals("O")) { |
| | | // locMast.setLocSts("S"); // S.入库预约 |
| | | // locMast.setModiUser(userId); |
| | | // locMast.setModiTime(now); |
| | | // if (!locMastService.updateById(locMast)) { |
| | | // throw new CoolException("改变库位状态失败"); |
| | | // } |
| | | // } else { |
| | | // throw new CoolException(dto.getLocNo() + "目标库位已被占用"); |
| | | // } |
| | | // return dto.getLocNo(); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | } |
| | | } |
| | |
| | | continue; |
| | | } |
| | | log.info("工作档明细:{},{},{},{}", locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(),locDto.getAnfme()); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(), locDto.getAnfme()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null, locDto.getAnfme()); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectItem(locDto); |
| | | |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(orderDetl); |
| | | wrkDetl.setZpallet(wrkMast.getBarcode()); |
| | |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | // 修改订单明细 |
| | | if (!orderDetlService.increaseWorkQty(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { |
| | | if (!orderDetlService.increaseWorkQty(orderDetl, locDto.getAnfme())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | |
| | | 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); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | } |
| | | } |
| | |
| | | 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)) { |
| | | throw new CoolException(locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号修改数量失败"); |
| | | } |
| | | // 保存调整记录 |
| | |
| | | // 删除库存 |
| | | for (LocDetl locDetl : locDetls) { |
| | | // todo 盘点记录 |
| | | if (!locDetlService.updateAnfme(-1.0D, locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch())) { |
| | | if (!locDetlService.updateAnfme(-1.0D, locDetl.getLocNo(), locDetl)) { |
| | | throw new CoolException("删除" + locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号库存明细失败"); |
| | | } |
| | | // 保存调整记录 |
| | |
| | | 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 (!orderDetlService.decrease(wrkDetl, wrkDetl.getAnfme())) { |
| | | throw new CoolException("订单数据回滚失败"); |
| | | } |
| | | |