| | |
| | | private StaDescService staDescService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private MatCodeService matCodeService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("库位不存在"); |
| | | } |
| | | // 清除旧库存明细 |
| | | locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); |
| | | // 保存新库存明细 |
| | | for (LocDetlAdjustParam.LocDetlAdjust adjust : param.getList()) { |
| | | LocDetl locDetl = new LocDetl(); |
| | | if (!locDetlService.insert(locDetl)) { |
| | | throw new CoolException("保存库存明细失败"); |
| | | LocDetl sqlParam = new LocDetl(); |
| | | sqlParam.setLocNo(locMast.getLocNo()); |
| | | sqlParam.setMatnr(adjust.getMatNo()); |
| | | LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam)); |
| | | // 保存新库存明细 |
| | | if (Cools.isEmpty(one)) { |
| | | MatCode matCode = matCodeService.selectById(adjust.getMatNo()); |
| | | LocDetl locDetl = new LocDetl(); |
| | | locDetl.setLocNo(locMast.getLocNo()); |
| | | locDetl.setMatnr(matCode.getMatNo()); |
| | | locDetl.setMaktx(matCode.getMatName()); // 物料描述 |
| | | locDetl.setAnfme(adjust.getCount()); // 数量 |
| | | locDetl.setAltme(matCode.getStr1()); // 单位 |
| | | // todo:luxiaoao |
| | | locDetl.setModiUser(userId); // 操作人员信息 |
| | | locDetl.setModiTime(new Date()); |
| | | locDetl.setAppeUser(userId); |
| | | locDetl.setAppeTime(new Date()); |
| | | if (!locDetlService.insert(locDetl)) { |
| | | throw new CoolException("保存库存明细失败"); |
| | | } |
| | | // 修改原库存明细 |
| | | } else { |
| | | // 如果数量修改,则更新库存明细 |
| | | if (!adjust.getCount().equals(one.getAnfme())) { |
| | | // 当数量被修改为 0 时,直接清除库存明细 |
| | | if (adjust.getCount() == 0) { |
| | | if (!locDetlService.delete(new EntityWrapper<>(one))) { |
| | | throw new CoolException("清除库存明细失败"); |
| | | } |
| | | } else { |
| | | one.setAnfme(adjust.getCount()); |
| | | one.setModiTime(new Date()); |
| | | one.setModiUser(userId); |
| | | if (!locDetlService.updateById(one)) { |
| | | throw new CoolException("修改库存明细失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |