| | |
| | | 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> 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()); |
| | | FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(matnrs.get(0)); |
| | | FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(param.getList().get(0)); |
| | | StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), findLocNoAttributeVo,locTypeDto); |
| | | if (Cools.isEmpty(dto)){ |
| | | throw new CoolException("查询库位失败!!==》startupFullPutStore ==》 commonService.getLocNo"); |
| | |
| | | |
| | | List<LocDetlAdjustParam.LocDetlAdjust> list = param.getList(); |
| | | |
| | | // 添加历史工作主档 |
| | | WrkMastLog wrkMast = new WrkMastLog(); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(5); |
| | | wrkMast.setIoPri(13D); // 优先级 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); |
| | | wrkMast.setLocNo(locMast.getLocNo()); |
| | | wrkMast.setBarcode(locMast.getBarcode()); // 托盘码 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("Y"); |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setModiUser(userId); |
| | | |
| | | // 增删改只创建一次工作主档 |
| | | boolean updateFlag = true; |
| | | boolean deleteFlag = true; |
| | | boolean addFlag = true; |
| | | |
| | | // 修改数量 |
| | | Iterator<LocDetl> iterator = locDetls.iterator(); |
| | | while (iterator.hasNext()) { |
| | |
| | | adjDetl.setAppeTime(now); |
| | | adjDetl.setAppeUser(userId); |
| | | adjDetlService.save(adjDetl, userId); |
| | | |
| | | if (updateFlag) { |
| | | wrkMast.setWrkNo(commonService.getWorkNo(3)); |
| | | wrkMast.setIoType(23); |
| | | boolean res = wrkMastLogService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("库存调整-修改 保存工作档失败"); |
| | | } |
| | | updateFlag = false; |
| | | } |
| | | |
| | | // 添加历史工作明细 |
| | | WrkDetlLog wrkDetl = new WrkDetlLog(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | wrkDetl.setAnfme(adjust.getCount()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkDetlLogService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | } |
| | | iterator.remove(); |
| | | iterator1.remove(); |
| | |
| | | adjDetl.setAppeTime(now); |
| | | adjDetl.setAppeUser(userId); |
| | | adjDetlService.save(adjDetl, userId); |
| | | |
| | | if (deleteFlag) { |
| | | wrkMast.setWrkNo(commonService.getWorkNo(3)); |
| | | wrkMast.setIoType(22); |
| | | boolean res = wrkMastLogService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("库存调整-删除 保存工作档失败"); |
| | | } |
| | | deleteFlag = false; |
| | | } |
| | | |
| | | // 添加历史工作明细 |
| | | WrkDetlLog wrkDetl = new WrkDetlLog(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | wrkDetl.setAnfme(0.0); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkDetlLogService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | } |
| | | |
| | | // 添加库存 |
| | |
| | | locDetl.sync(mat); |
| | | locDetl.setBatch(adjust.getBatch()); |
| | | locDetl.setLocNo(locMast.getLocNo()); |
| | | locDetl.setZpallet(locMast.getBarcode()); |
| | | locDetl.setAnfme(adjust.getCount()); // 数量 |
| | | locDetl.setModiUser(userId); // 操作人员信息 |
| | | locDetl.setModiTime(now); |
| | |
| | | adjDetl.setAppeTime(now); |
| | | adjDetl.setAppeUser(userId); |
| | | adjDetlService.save(adjDetl, userId); |
| | | |
| | | if (addFlag) { |
| | | wrkMast.setWrkNo(commonService.getWorkNo(3)); |
| | | wrkMast.setIoType(21); |
| | | boolean res = wrkMastLogService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("库存调整-新增 保存工作档失败"); |
| | | } |
| | | addFlag = false; |
| | | } |
| | | |
| | | // 添加历史工作明细 |
| | | WrkDetlLog wrkDetl = new WrkDetlLog(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | wrkDetl.setAnfme(adjust.getCount()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkDetlLogService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | } |
| | | // 修改库位状态 |
| | | int count = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | if (count == 0) { |
| | | locMast.setLocSts("D"); |
| | | } |
| | | } |
| | | if (locMast.getLocSts().equals("D") || locMast.getLocSts().equals("O")) { |
| | | if (count > 0) { |
| | | locMast.setLocSts("F"); |
| | | } |
| | | } |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("更新库位状态失败"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void adjustLocDetl2(LocDetlAdjustParam param, Long userId) { |
| | | param.integrate(); |
| | | LocMast locMast = locMastService.selectById(param.getLocNo()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("库位不存在"); |
| | | } |
| | | if (!(locMast.getLocSts().equals("P"))) { |
| | | throw new CoolException("当前库位不可调整!库位状态:" + locMast.getLocSts$()); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", param.getLocNo())); |
| | | |
| | | List<LocDetlAdjustParam.LocDetlAdjust> list = param.getList(); |
| | | |
| | | // 添加历史工作主档 |
| | | WrkMastLog wrkMast = new WrkMastLog(); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(5); |
| | | wrkMast.setIoPri(13D); // 优先级 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); |
| | | wrkMast.setLocNo(locMast.getLocNo()); |
| | | wrkMast.setBarcode(locMast.getBarcode()); // 托盘码 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("Y"); |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setModiUser(userId); |
| | | |
| | | // 增删改只创建一次工作主档 |
| | | boolean updateFlag = true; |
| | | boolean deleteFlag = true; |
| | | boolean addFlag = true; |
| | | |
| | | // 修改数量 |
| | | Iterator<LocDetl> iterator = locDetls.iterator(); |
| | | while (iterator.hasNext()) { |
| | | LocDetl locDetl = iterator.next(); |
| | | |
| | | Iterator<LocDetlAdjustParam.LocDetlAdjust> iterator1 = list.iterator(); |
| | | while (iterator1.hasNext()) { |
| | | LocDetlAdjustParam.LocDetlAdjust adjust = iterator1.next(); |
| | | if (adjust.getCount() == 0) { continue; } |
| | | if (locDetl.getMatnr().equals(adjust.getMatnr()) && Cools.eq(locDetl.getBatch(), adjust.getBatch())) { |
| | | if (!locDetl.getAnfme().equals(adjust.getCount())) { |
| | | // todo 盘点记录 |
| | | // 修改库存 |
| | | if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBrand(), |
| | | locDetl.getStandby1(),locDetl.getStandby2(),locDetl.getStandby3(),locDetl.getBoxType1(),locDetl.getBoxType2(),locDetl.getBoxType3())) { |
| | | throw new CoolException(locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号修改数量失败"); |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | | adjDetl.setLocNo(locDetl.getLocNo()); |
| | | adjDetl.setMatnr(locDetl.getMatnr()); |
| | | adjDetl.setBatch(locDetl.getBatch()); |
| | | adjDetl.setOriQty(locDetl.getAnfme()); |
| | | adjDetl.setAdjQty(adjust.getCount()); |
| | | adjDetl.setModiTime(now); |
| | | adjDetl.setModiUser(userId); |
| | | adjDetl.setAppeTime(now); |
| | | adjDetl.setAppeUser(userId); |
| | | adjDetlService.save(adjDetl, userId); |
| | | |
| | | if (updateFlag) { |
| | | wrkMast.setWrkNo(commonService.getWorkNo(3)); |
| | | wrkMast.setIoType(23); |
| | | boolean res = wrkMastLogService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("库存调整-修改 保存工作档失败"); |
| | | } |
| | | updateFlag = false; |
| | | } |
| | | |
| | | // 添加历史工作明细 |
| | | WrkDetlLog wrkDetl = new WrkDetlLog(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | wrkDetl.setAnfme(adjust.getCount()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkDetlLogService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | } |
| | | iterator.remove(); |
| | | iterator1.remove(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 删除库存 |
| | | for (LocDetl locDetl : locDetls) { |
| | | // todo 盘点记录 |
| | | if (!locDetlService.updateAnfme(-1.0D, locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBrand(), |
| | | locDetl.getStandby1(),locDetl.getStandby2(),locDetl.getStandby3(),locDetl.getBoxType1(),locDetl.getBoxType2(),locDetl.getBoxType3())) { |
| | | throw new CoolException("删除" + locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号库存明细失败"); |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | | adjDetl.setLocNo(locDetl.getLocNo()); |
| | | adjDetl.setMatnr(locDetl.getMatnr()); |
| | | adjDetl.setBatch(locDetl.getBatch()); |
| | | adjDetl.setOriQty(locDetl.getAnfme()); |
| | | adjDetl.setAdjQty(0.0D); |
| | | adjDetl.setModiTime(now); |
| | | adjDetl.setModiUser(userId); |
| | | adjDetl.setAppeTime(now); |
| | | adjDetl.setAppeUser(userId); |
| | | adjDetlService.save(adjDetl, userId); |
| | | |
| | | if (deleteFlag) { |
| | | wrkMast.setWrkNo(commonService.getWorkNo(3)); |
| | | wrkMast.setIoType(22); |
| | | boolean res = wrkMastLogService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("库存调整-删除 保存工作档失败"); |
| | | } |
| | | deleteFlag = false; |
| | | } |
| | | |
| | | // 添加历史工作明细 |
| | | WrkDetlLog wrkDetl = new WrkDetlLog(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | wrkDetl.setAnfme(0.0); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkDetlLogService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | } |
| | | |
| | | // 添加库存 |
| | | for (LocDetlAdjustParam.LocDetlAdjust adjust : list) { |
| | | if (adjust.getCount() == 0.0D) { continue; } |
| | | Mat mat = matService.selectByMatnr(adjust.getMatnr()); |
| | | LocDetl locDetl = new LocDetl(); |
| | | locDetl.sync(mat); |
| | | locDetl.setBatch(adjust.getBatch()); |
| | | locDetl.setLocNo(locMast.getLocNo()); |
| | | locDetl.setZpallet(locMast.getBarcode()); |
| | | locDetl.setAnfme(adjust.getCount()); // 数量 |
| | | locDetl.setModiUser(userId); // 操作人员信息 |
| | | locDetl.setModiTime(now); |
| | | locDetl.setAppeUser(userId); |
| | | locDetl.setAppeTime(now); |
| | | if (!locDetlService.insert(locDetl)) { |
| | | throw new CoolException("添加" + locDetl.getLocNo() + "库位," + locDetl.getMatnr() + "商品," + locDetl.getBatch() + "批号库存明细失败"); |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | | adjDetl.setLocNo(locMast.getLocNo()); |
| | | adjDetl.setMatnr(adjust.getMatnr()); |
| | | adjDetl.setBatch(adjust.getBatch()); |
| | | adjDetl.setOriQty(0.0D); |
| | | adjDetl.setAdjQty(adjust.getCount()); |
| | | adjDetl.setModiTime(now); |
| | | adjDetl.setModiUser(userId); |
| | | adjDetl.setAppeTime(now); |
| | | adjDetl.setAppeUser(userId); |
| | | adjDetlService.save(adjDetl, userId); |
| | | |
| | | if (addFlag) { |
| | | wrkMast.setWrkNo(commonService.getWorkNo(3)); |
| | | wrkMast.setIoType(21); |
| | | boolean res = wrkMastLogService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("库存调整-新增 保存工作档失败"); |
| | | } |
| | | addFlag = false; |
| | | } |
| | | |
| | | // 添加历史工作明细 |
| | | WrkDetlLog wrkDetl = new WrkDetlLog(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | wrkDetl.setAnfme(adjust.getCount()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setModiUser(userId); |
| | | if (!wrkDetlLogService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | } |
| | | // 修改库位状态 |
| | | int count = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); |