| | |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | } |
| | | } |
| | | for (LocDetlDto locDetlDto:locDetlDtos){ |
| | | if (locs.contains(locDetlDto.getLocDetl().getLocNo())){ |
| | | locDetlDto.setSign(true); |
| | | } |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); |
| | | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") ){ |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId); |
| | | stockOut2(staNo, locDetlDtos, null, userId); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F、D的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | } |
| | |
| | | } |
| | | |
| | | List<String> outerLocs = Utils.getGroupOuterSingleLoc(locNo); |
| | | LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", dto.getLocNo())); |
| | | if (locMast1.getLocType2().equals((short)3)){ |
| | | outerLocs = Utils.getGroupOuterSingleLocLowFrequency(locMast1.getLocNo()); |
| | | } |
| | | Double wrkPri = 15D; |
| | | for (String outerLoc : outerLocs) { |
| | | LocMast locMast = locMastService.selectById(outerLoc); |
| | |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(101); // 入出库状态101全板出库 |
| | | wrkPri += 2D; |
| | | wrkMast.setIoPri(wrkPri); // 优先级 |
| | | |
| | | wrkMast.setIoPri(Utils.getIoPri(locMast.getLocNo())); // 优先级 |
| | | wrkMast.setOutMost(0); |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut2(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId) { |
| | | Integer basDevp = staNo.getDevNo(); |
| | | 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) { |
| | | // 如果为深库位,且对应浅库位为X.禁用,则略过此库位 |
| | | if (Utils.isDeepLoc(slaveProperties, dto.getLocNo())) { |
| | | String shallowLoc = Utils.getShallowLoc(slaveProperties, dto.getLocNo()); |
| | | if (locMastService.selectById(shallowLoc).getLocSts().equals("X")) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | //-----------------2023.5.31上架区域版本兼容代码----------------------- |
| | | //判断当前库位组是否均为同一种物料,如不是,则认定需要执行兼容代码 |
| | | //需要将待出库库位前侧库位(不包含最外侧高频库位)执行101全板出库 |
| | | String locNo = dto.getLocNo(); |
| | | String matnr = null; |
| | | for (LocDetlDto locDetlDto : dto.getLocDetlDtos()) { |
| | | LocDetl locDetl = locDetlDto.getLocDetl(); |
| | | if (locDetl.getLocNo().equals(locNo)) { |
| | | matnr = locDetl.getMatnr(); |
| | | } |
| | | } |
| | | |
| | | List<String> outerLocs = new ArrayList<>(); |
| | | if (!dto.isSign()){ |
| | | outerLocs.add(dto.getLocNo()); |
| | | } |
| | | Double wrkPri = 15D; |
| | | for (String outerLoc : outerLocs) { |
| | | if (!dto.isSign()) { |
| | | // 生成工作档明细 |
| | | for (LocDetl locDetl : locDetlService.selectByLocNo(outerLoc)) { |
| | | |
| | | Mat mat = matService.selectByMatnr(locDetl.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(locDetl.getMatnr() + "商品档案不存在"); |
| | | } |
| | | int zpallet = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", locDetl.getZpallet()).ne("loc_no",locDetl.getLocNo())); |
| | | if (zpallet>0) { |
| | | throw new CoolException(locDetl.getZpallet() + "入库通知档中已存在"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setBatch(""); |
| | | waitPakin.setZpallet(locDetl.getZpallet()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(locDetl.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setMemo(locDetl.getMemo()); |
| | | waitPakin.setFrozen(0); // 是否冻结 |
| | | waitPakin.setManu(locDetl.getManu()); |
| | | waitPakin.setMatType(mat.getMatType());//物料类型 |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //-----------------2023.5.31上架区域版本兼容代码end----------------------- |
| | | |
| | | // 判断入出库类型:101.全板出库 or 103.拣料出库 |
| | | if (ioWorkType == null) { |
| | | ioType = dto.isAll() ? 101 : 103; |
| | | } else if (ioWorkType.equals(IoWorkType.CHECK_OUT)) { |
| | | ioType = 107; |
| | | // if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) { |
| | | // throw new CoolException("只能存在一笔盘点任务"); |
| | | // } |
| | | } |
| | | assert ioType != null; |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | |
| | | //-----------------2023.6.2出库兼容代码----------------------- |
| | | if (ioType!=107){ |
| | | List<LocDetl> locDetls = locDetlService.selectByLocNo(locMast.getLocNo()); |
| | | //if (locMast.getLocType2() == 1 && locDetls.size() > 1) { |
| | | // //单品区域出库物料大于1种,强制变成101全板出库 |
| | | // ioType = 101; |
| | | // if (staNo.getDevNo()==300){ |
| | | // staNo.setDevNo(200); |
| | | // } |
| | | //} |
| | | if (ioType == 101) { |
| | | if (staNo.getDevNo()==300){ |
| | | if(locMast.getCrnNo() == 1) { |
| | | staNo.setDevNo(100); |
| | | } else { |
| | | staNo.setDevNo(200); |
| | | } |
| | | |
| | | } |
| | | } else { |
| | | staNo.setDevNo(basDevp); |
| | | } |
| | | |
| | | |
| | | } |
| | | //-----------------2023.6.2出库兼容代码end----------------------- |
| | | |
| | | // 获取路径 |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), staNo.getDevNo(), locMast.getRow1()); |
| | | if(staDesc == null){ |
| | | throw new CoolException("出库路径不存在"); |
| | | } |
| | | |
| | | // 生成工作号 |
| | | 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); // 入出库状态 |
| | | Double ioPri = wrkMastService.getIoPri(ioType, dto.getLocNo()); |
| | | wrkMast.setIoPri(15D); // 优先级:13 |
| | | wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), false) ? 1 : 0); |
| | | 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 (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:" + dto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | | 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); |
| | | wrkDetl.setSpecs(detlDto.getLocDetl().getSpecs()); |
| | | wrkDetl.setMatType(detlDto.getLocDetl().getMatType()); |
| | | wrkDetl.setZpallet(locMast.getBarcode()); |
| | | 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() + "库位不是在库状态"); |
| | | } |
| | | // locMastService.breakUp(dto.getLocNo(), excludeLocNos); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(BasDevp staNo, TaskDto taskDto, Long userId) { |
| | | Date now = new Date(); |
| | | if (Cools.isEmpty(taskDto.getLocDtos()) || taskDto.getLocDtos().size()==0){ |