| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private InventoryCheckOrderDetlService inventoryCheckOrderDetlService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | // 检索库位 |
| | | 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,0,locTypeDto,0); |
| | | // List<String> batchs = param.getList().stream().map(FullStoreParam.MatCodeStore::getBatch).distinct().collect(Collectors.toList()); |
| | | StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), matnrs.get(0), null, null,locTypeDto); |
| | | if (Cools.isEmpty(dto)){ |
| | | throw new CoolException("查询库位失败!!==》startupFullPutStore ==》 commonService.getLocNo"); |
| | | } |
| | | // 生成工作号 |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional |
| | | public void inventoryCheckStockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId,StockOutParam param) { |
| | | Date now = new Date(); |
| | | // 合并同类项 |
| | | Set<String> locNos = new HashSet<>(); |
| | | List<OutLocDto> dtos = new ArrayList<>(); |
| | | for (LocDetlDto locDetlDto : locDetlDtos) { |
| | | String locNo = locDetlDto.getLocDetl().getLocNo(); |
| | | if (locNos.contains(locNo)) { |
| | | for (OutLocDto dto : dtos) { |
| | | if (dto.getLocNo().equals(locNo)) { |
| | | dto.getLocDetlDtos().add(locDetlDto); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | locNos.add(locNo); |
| | | dtos.add(new OutLocDto(locNo, locDetlDto)); |
| | | } |
| | | } |
| | | Integer ioType = null; |
| | | // 生成工作档 |
| | | for (OutLocDto dto : dtos) { |
| | | // 判断入出库类型:101.全板出库 or 103.拣料出库 |
| | | if (ioWorkType == null) { |
| | | ioType = dto.isAll() ? 101 : 103; |
| | | } else if (ioWorkType.equals(IoWorkType.CHECK_OUT)) { |
| | | ioType = 107; |
| | | } |
| | | assert ioType != null; |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | |
| | | Integer outSta = staNo.getDevNo(); |
| | | // //2号堆垛机全板出库站指定为204站,拣料站指定为202 |
| | | // if(locMast.getCrnNo()==2){ |
| | | // outSta = ioType == 101 ? 204 : 202; |
| | | // } |
| | | |
| | | // 获取路径 |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta); |
| | | |
| | | |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(dto.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setAppeUser(userId); // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (ioType == 107){ |
| | | wrkMast.setSheetNo(param.getOrderNo()); |
| | | } |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+dto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | 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(wrkMast.getCrnNo$()); |
| | | 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;} |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(detlDto.getLocDetl()); |
| | | wrkDetl.setOrderNo(""); // 手动出库不需要带出库存中的单据编号 |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | Double anfme = ioType==101?detlDto.getLocDetl().getAnfme():detlDto.getCount(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+dto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(BasDevp staNo, TaskDto taskDto, Long userId) { |
| | |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true); |
| | | // 检索库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 10, devpNo, null,null,null,0, locTypeDto, 0); |
| | | StartupDto dto = commonService.getLocNo( 10, devpNo, null,null,null, locTypeDto); |
| | | int workNo = dto.getWorkNo(); |
| | | Date now = new Date(); |
| | | // 生成工作档 |
| | |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | // 启动出库开始 107.盘点出库 |
| | | stockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId); |
| | | inventoryCheckStockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId,param); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | } |
| | |
| | | throw new CoolException("当前工作档已完成"); |
| | | } |
| | | // 入库 + 库位转移 |
| | | if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) { |
| | | if (wrkMast.getIoType() <100 ) { |
| | | wrkMast.setWrkSts(4L); |
| | | // 出库 |
| | | } else if (wrkMast.getWrkSts() > 10) { |
| | | } else if (wrkMast.getIoType() >100 && wrkMast.getWrkSts() > 10) { |
| | | wrkMast.setWrkSts(14L); |
| | | } |
| | | Date now = new Date(); |
| | |
| | | String locNo = ""; // 待修改目标库位 |
| | | String locSts = ""; // 待修改目标库位状态 |
| | | // 入库取消(修改目标库位) |
| | | if (wrkMast.getWrkSts() < 4) { |
| | | if (wrkMast.getIoType() <100 ) { |
| | | locNo = wrkMast.getLocNo(); |
| | | locSts = "O"; |
| | | |
| | |
| | | locMastService.updateById(locMast); |
| | | } |
| | | // 出库取消(修改源库位) |
| | | } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 14) { |
| | | } else if (wrkMast.getIoType() >=100) { |
| | | locNo = wrkMast.getSourceLocNo(); |
| | | // 出库 ===>> F.在库 |
| | | if (wrkMast.getIoType() > 100 && wrkMast.getIoType() != 110) { |