| | |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private MatCodeService matCodeService; |
| | | @Autowired |
| | | private AdjDetlService adjDetlService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | param.getList().forEach(elem -> { |
| | | matDtos.add(new MatCodeCountDto(elem.getMatNo(), elem.getCount())); |
| | | }); |
| | | wrkDetlService.createWorkDetail(workNo, matDtos, userId); |
| | | wrkDetlService.createWorkDetail(workNo, matDtos, param.getBarcode(), userId); |
| | | // 更新源站点信息 |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiUser(userId); |
| | |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl locDetl : param.getLocDetls()) { |
| | | if (!Cools.isEmpty(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getCount())) { |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { |
| | | LocDetl sqlParam = new LocDetl(); |
| | | sqlParam.setLocNo(locDetl.getLocNo()); |
| | | sqlParam.setMatnr(locDetl.getMatnr()); |
| | | sqlParam.setLocNo(paramLocDetl.getLocNo()); |
| | | sqlParam.setMatnr(paramLocDetl.getMatnr()); |
| | | LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam)); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, locDetl.getCount())); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | } |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 |
| | | stockOut(staNo, locDetlDtos, userId); |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, 101, userId); |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, Long userId) { |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE); |
| | | public void stockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, Integer ioType, Long userId) { |
| | | // 合并同类项 |
| | | Set<String> locNos = new HashSet<>(); |
| | | locDetlDtos.forEach(dto -> locNos.add(dto.getLocDetl().getLocNo())); |
| | |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | // 获取路径 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", 101) |
| | | .eq("type_no", ioType) |
| | | .eq("stn_no", staNo.getDevNo()) |
| | | .eq("crn_no", locMast.getCrnNo()); |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | throw new CoolException("出库路径不存在"); |
| | | } |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(101); // 入出库状态:101.出库 |
| | | wrkMast.setIoType(ioType); // 入出库状态:101.出库 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | | if (detlDto.getCount() <= 0.0D) {continue;} |
| | | // 出库时,数量为0的直接忽略 |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setMatnr(detlDto.getLocDetl().getMatnr()); |
| | | wrkDetl.setAnfme(detlDto.getCount()); // 数量 |
| | | Double anfme = ioType==101?detlDto.getCount():detlDto.getLocDetl().getAnfme(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | wrkDetl.setZmatid(detlDto.getLocDetl().getZmatid()); |
| | | wrkDetl.setTbpos(detlDto.getLocDetl().getTbpos()); |
| | | wrkDetl.setTbnum(detlDto.getLocDetl().getTbnum()); |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void locCheckOut(StockOutParam param, Long userId) { |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr())) { |
| | | LocDetl sqlParam = new LocDetl(); |
| | | sqlParam.setLocNo(paramLocDetl.getLocNo()); |
| | | sqlParam.setMatnr(paramLocDetl.getMatnr()); |
| | | LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam)); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, one.getAnfme())); |
| | | } |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 107.盘点出库 |
| | | stockOut(staNo, locDetlDtos, 107, userId); |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void locMove(String sourceLocNo, String locNo, Long userId) { |
| | | LocMast sourceLoc = locMastService.selectById(sourceLocNo); |
| | | if (Cools.isEmpty(sourceLoc)){ |
| | |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("预约源库位出库失败,状态:"+sourceLoc.getLocType$()); |
| | | throw new CoolException("源库位出库失败,状态:"+sourceLoc.getLocType$()); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocType().equals("O")) { |
| | |
| | | throw new CoolException("库位不存在"); |
| | | } |
| | | for (LocDetlAdjustParam.LocDetlAdjust adjust : param.getList()) { |
| | | if (Cools.isEmpty(adjust.getMatnr())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | LocDetl sqlParam = new LocDetl(); |
| | | sqlParam.setLocNo(locMast.getLocNo()); |
| | | sqlParam.setMatnr(adjust.getMatNo()); |
| | | sqlParam.setMatnr(adjust.getMatnr()); |
| | | LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam)); |
| | | // 保存新库存明细 |
| | | if (Cools.isEmpty(one)) { |
| | | MatCode matCode = matCodeService.selectById(adjust.getMatNo()); |
| | | if (adjust.getCount() == 0){ |
| | | continue; |
| | | } |
| | | MatCode matCode = matCodeService.selectById(adjust.getMatnr()); |
| | | LocDetl locDetl = new LocDetl(); |
| | | locDetl.setLocNo(locMast.getLocNo()); |
| | | locDetl.setMatnr(matCode.getMatNo()); |
| | |
| | | locDetl.setAnfme(adjust.getCount()); // 数量 |
| | | locDetl.setAltme(matCode.getStr1()); // 单位 |
| | | // todo:luxiaoao |
| | | locDetl.setLgnum("待定"); // 仓库号 |
| | | locDetl.setTbnum(0); // 转储请求编号 |
| | | locDetl.setTbpos(0); // 行项目 |
| | | locDetl.setZmatid("待定"); // 物料标签ID |
| | | locDetl.setZpallet("待定"); // 托盘条码 |
| | | |
| | | locDetl.setModiUser(userId); // 操作人员信息 |
| | | locDetl.setModiTime(new Date()); |
| | | locDetl.setAppeUser(userId); |
| | |
| | | if (!locDetlService.insert(locDetl)) { |
| | | throw new CoolException("保存库存明细失败"); |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | | adjDetl.setLocNo(locDetl.getLocNo()); |
| | | adjDetl.setMatNo(locDetl.getMatnr()); |
| | | adjDetl.setOriQty(0.0D); |
| | | adjDetl.setAdjQty(adjust.getCount()); |
| | | adjDetlService.save(adjDetl, userId); |
| | | // 修改原库存明细 |
| | | } else { |
| | | // 如果数量修改,则更新库存明细 |
| | |
| | | throw new CoolException("清除库存明细失败"); |
| | | } |
| | | } else { |
| | | one.setAnfme(adjust.getCount()); |
| | | one.setModiTime(new Date()); |
| | | one.setModiUser(userId); |
| | | if (!locDetlService.updateById(one)) { |
| | | LocDetl sqlParam1 = new LocDetl(); |
| | | sqlParam1.setAnfme(adjust.getCount()); |
| | | sqlParam1.setModiTime(new Date()); |
| | | sqlParam1.setModiUser(userId); |
| | | if (!locDetlService.update(sqlParam1, new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", locMast.getLocNo()) |
| | | .eq("matnr", adjust.getMatnr()))) { |
| | | throw new CoolException("修改库存明细失败"); |
| | | } |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | | adjDetl.setLocNo(locMast.getLocNo()); |
| | | adjDetl.setMatNo(adjust.getMatnr()); |
| | | adjDetl.setOriQty(one.getAnfme()); |
| | | adjDetl.setAdjQty(adjust.getCount()); |
| | | adjDetlService.save(adjDetl, userId); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |