| | |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.OutStockInterceptUtil; |
| | | import com.zy.common.utils.Synchro; |
| | | import com.zy.common.web.WcsController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | 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(1, param.getDevpNo(), matnrs.get(0), null, null,locTypeDto,matnrs.size()>1); |
| | | if (Cools.isEmpty(dto)){ |
| | | StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), matnrs.get(0), null, null, locTypeDto, matnrs.size() > 1); |
| | | if (Cools.isEmpty(dto)) { |
| | | throw new CoolException("查询库位失败!!==》startupFullPutStore ==》 commonService.getLocNo"); |
| | | } |
| | | // 生成工作号 |
| | |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiUser(userId); |
| | | sourceStaNo.setModiTime(now); |
| | | if (!basDevpService.updateById(sourceStaNo)){ |
| | | if (!basDevpService.updateById(sourceStaNo)) { |
| | | throw new CoolException("更新源站失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("O")){ |
| | | if (locMast.getLocSts().equals("O")) { |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)){ |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo()+"目标库位已被占用"); |
| | | throw new CoolException(dto.getLocNo() + "目标库位已被占用"); |
| | | } |
| | | return dto.getLocNo(); |
| | | } |
| | |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | // 判断入库模式 |
| | | OutStockInterceptUtil.outStockIntercept(param.getOutSite()); |
| | | //OutStockInterceptUtil.outStockIntercept(param.getOutSite()); |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | |
| | | } |
| | | 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") ){ |
| | | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D")) { |
| | | if (staNo.getDevNo() == 1135 && locMast.getLocType1() == 2) { |
| | | throw new CoolException("所选库位不是低库位无法调拨,库位号:{}" + locMast.getLocNo()); |
| | | } |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F、D的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | } else { |
| | | throw new CoolException("所选库位存在状态不为F、D的库位,库位号:" + locMast.getLocNo() + " 、当前状态:" + locMast.getLocSts() + "-" + locMast.getLocSts$()); |
| | | } |
| | | } else { |
| | | throw new CoolException("库存不存在"); |
| | |
| | | ioType = dto.isAll() ? 101 : 103; |
| | | } else if (ioWorkType.equals(IoWorkType.CHECK_OUT)) { |
| | | ioType = 107; |
| | | }else if (ioWorkType.equals(IoWorkType.MERGE_OUT)) { |
| | | } else if (ioWorkType.equals(IoWorkType.MERGE_OUT)) { |
| | | ioType = 104; |
| | | } |
| | | assert ioType != null; |
| | |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | |
| | | Integer outSta = staNo.getDevNo(); |
| | | if (outSta == 1135 || outSta == 1031) { |
| | | if (101 != ioType) { |
| | | throw new CoolException("该站点必须全板出库,出库库位号:" + dto.getLocNo()); |
| | | } |
| | | } |
| | | // //2号堆垛机全板出库站指定为204站,拣料站指定为202 |
| | | // if(locMast.getCrnNo()==2){ |
| | | // outSta = ioType == 101 ? 204 : 202; |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+dto.getLocNo()); |
| | | throw new CoolException("保存工作档失败,出库库位号:" + dto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | if (ioType != 104){ |
| | | if (ioType != 104) { |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | 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(); |
| | | Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+dto.getLocNo()); |
| | | throw new CoolException("预约库位状态失败,库位号:" + dto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | |
| | | } |
| | | |
| | | @Transactional |
| | | public void inventoryCheckStockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId,StockOutParam param) { |
| | | public void inventoryCheckStockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId, StockOutParam param) { |
| | | Date now = new Date(); |
| | | // 合并同类项 |
| | | Set<String> locNos = new HashSet<>(); |
| | |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (ioType == 107){ |
| | | if (ioType == 107) { |
| | | wrkMast.setSheetNo(param.getOrderNo()); |
| | | } |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+dto.getLocNo()); |
| | | throw new CoolException("保存工作档失败,出库库位号:" + dto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | |
| | | throw new CoolException("保存盘点明细失败"); |
| | | } |
| | | |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | 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(); |
| | | Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+dto.getLocNo()); |
| | | throw new CoolException("预约库位状态失败,库位号:" + dto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+taskDto.getLocNo()); |
| | | throw new CoolException("保存工作档失败,出库库位号:" + taskDto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; } |
| | | if (locDto.getAnfme() == null || locDto.getAnfme() <= 0.0D) { |
| | | continue; |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); |
| | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+taskDto.getLocNo()); |
| | | throw new CoolException("预约库位状态失败,库位号:" + taskDto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(taskDto.getLocNo() + "库位不是在库状态"); |
| | |
| | | LocMast locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | if ((locMast.getBay1() >=1 && locMast.getBay1()<=2) || (locMast.getBay1() >=6 && locMast.getBay1()<=7 && locMast.getRow1() !=36 && locMast.getRow1() !=29 ) || (locMast.getBay1() >=11 && locMast.getBay1()<=12)){ |
| | | if ((locMast.getBay1() >= 1 && locMast.getBay1() <= 2) || (locMast.getBay1() >= 6 && locMast.getBay1() <= 7 && locMast.getRow1() != 36 && locMast.getRow1() != 29) || (locMast.getBay1() >= 11 && locMast.getBay1() <= 12)) { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .eq("loc_type1", locMast.getLocType1()) |
| | | .orderBy("bay1", false)); |
| | | }else { |
| | | } else { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .eq("loc_type1", locMast.getLocType1()) |
| | | .orderBy("bay1", true)); |
| | | } |
| | | for (LocMast locMast1 : locMasts) { |
| | | if (locMast1.getLocNo().equals(taskDto.getLocNo())){ |
| | | if (locMast1.getLocNo().equals(taskDto.getLocNo())) { |
| | | break; |
| | | } |
| | | if (locMast1.getLocSts().equals("X")){ |
| | | throw new CoolException(taskDto.getLocNo()+"库位前方有锁定库位,禁止出库"); |
| | | if (locMast1.getLocSts().equals("X")) { |
| | | throw new CoolException(taskDto.getLocNo() + "库位前方有锁定库位,禁止出库"); |
| | | } |
| | | if (locMast1.getLocSts().equals("F")) { |
| | | moveLocForDeepLoc(locMast1); |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+taskDto.getLocNo()); |
| | | throw new CoolException("保存工作档失败,出库库位号:" + taskDto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; } |
| | | if (locDto.getAnfme() == null || locDto.getAnfme() <= 0.0D) { |
| | | continue; |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); |
| | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+taskDto.getLocNo()); |
| | | throw new CoolException("预约库位状态失败,库位号:" + taskDto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(taskDto.getLocNo() + "库位不是在库状态"); |
| | |
| | | LocTypeDto locTypeDto = new LocTypeDto(); |
| | | locTypeDto.setLocType1(shallowLoc.getLocType1()); |
| | | locTypeDto.setLev1(shallowLoc.getLev1()); |
| | | StartupDto dto = commonService.getLocNo( 1, 31002, null,null,null, locTypeDto, false); |
| | | if (Cools.isEmpty(dto)){ |
| | | StartupDto dto = commonService.getLocNo(1, 31002, null, null, null, locTypeDto, false); |
| | | if (Cools.isEmpty(dto)) { |
| | | throw new CoolException("移库未找到库位"); |
| | | } |
| | | LocMast loc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", dto.getLocNo())); |
| | |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true); |
| | | // 检索库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | StartupDto dto = commonService.getLocNo( 10, devpNo, null,null,null, locTypeDto,false); |
| | | StartupDto dto = commonService.getLocNo(10, devpNo, null, null, null, locTypeDto, false); |
| | | int workNo = dto.getWorkNo(); |
| | | Date now = new Date(); |
| | | // 生成工作档 |
| | |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiUser(userId); |
| | | sourceStaNo.setModiTime(now); |
| | | if (!basDevpService.updateById(sourceStaNo)){ |
| | | if (!basDevpService.updateById(sourceStaNo)) { |
| | | throw new CoolException("更新源站失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("O")){ |
| | | if (locMast.getLocSts().equals("O")) { |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)){ |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo()+"目标库位已被占用"); |
| | | throw new CoolException(dto.getLocNo() + "目标库位已被占用"); |
| | | } |
| | | return dto.getLocNo(); |
| | | } |
| | |
| | | throw new CoolException("站点不存在"); |
| | | } |
| | | // 判断入库模式 |
| | | OutStockInterceptUtil.outStockIntercept(param.getOutSite()); |
| | | //OutStockInterceptUtil.outStockIntercept(param.getOutSite()); |
| | | for (String locNo : param.getLocNos()) { |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PAKOUT.type); |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException(locNo+"库位不存在"); |
| | | throw new CoolException(locNo + "库位不存在"); |
| | | } |
| | | if (!locMast.getLocSts().equals("D")){ |
| | | throw new CoolException("所选库位存在状态不为D的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | if (!locMast.getLocSts().equals("D")) { |
| | | throw new CoolException("所选库位存在状态不为D的库位,库位号:" + locMast.getLocNo() + " 、当前状态:" + locMast.getLocSts() + "-" + locMast.getLocSts$()); |
| | | } |
| | | // 获取源站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新库位状态 D.空板 -> R.出库预约 |
| | | if (locMast.getLocSts().equals("D")){ |
| | | if (locMast.getLocSts().equals("D")) { |
| | | locMast.setLocSts("R"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException(locNo+"库位不存在"); |
| | | throw new CoolException(locNo + "库位不存在"); |
| | | } |
| | | // 获取源站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新库位状态 D.空板 -> R.出库预约 |
| | | if (locMast.getLocSts().equals("D")){ |
| | | if (locMast.getLocSts().equals("D")) { |
| | | locMast.setLocSts("R"); |
| | | locMast.setModiUser(1L); |
| | | locMast.setModiTime(now); |
| | |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | // 判断入库模式 |
| | | OutStockInterceptUtil.outStockIntercept(param.getOutSite()); |
| | | //OutStockInterceptUtil.outStockIntercept(param.getOutSite()); |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | if (locMast.getLocSts().equals("F")) { |
| | | // 启动出库开始 107.盘点出库 |
| | | inventoryCheckStockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId,param); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | inventoryCheckStockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId, param); |
| | | } else { |
| | | throw new CoolException("所选库位存在状态不为F的库位,库位号:" + locMast.getLocNo() + " 、当前状态:" + locMast.getLocSts() + "-" + locMast.getLocSts$()); |
| | | } |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | // 判断入库模式 |
| | | OutStockInterceptUtil.outStockIntercept(param.getOutSite()); |
| | | //OutStockInterceptUtil.outStockIntercept(param.getOutSite()); |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | if (locMast.getLocSts().equals("F")) { |
| | | // 启动出库开始 107.盘点出库 |
| | | inventoryCheckStockOutsxk(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId,param); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | inventoryCheckStockOutsxk(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId, param); |
| | | } else { |
| | | throw new CoolException("所选库位存在状态不为F的库位,库位号:" + locMast.getLocNo() + " 、当前状态:" + locMast.getLocSts() + "-" + locMast.getLocSts$()); |
| | | } |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | |
| | | } |
| | | |
| | | @Transactional |
| | | public void inventoryCheckStockOutsxk(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId,StockOutParam param) { |
| | | public void inventoryCheckStockOutsxk(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId, StockOutParam param) { |
| | | Date now = new Date(); |
| | | // 合并同类项 |
| | | Set<String> locNos = new HashSet<>(); |
| | |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | if ((locMast.getBay1() >=1 && locMast.getBay1()<=2) || (locMast.getBay1() >=6 && locMast.getBay1()<=7 && locMast.getRow1() !=36 && locMast.getRow1() !=29 ) || (locMast.getBay1() >=11 && locMast.getBay1()<=12)){ |
| | | if ((locMast.getBay1() >= 1 && locMast.getBay1() <= 2) || (locMast.getBay1() >= 6 && locMast.getBay1() <= 7 && locMast.getRow1() != 36 && locMast.getRow1() != 29) || (locMast.getBay1() >= 11 && locMast.getBay1() <= 12)) { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .eq("loc_type1", locMast.getLocType1()) |
| | | .orderBy("bay1", false)); |
| | | }else { |
| | | } else { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .eq("loc_type1", locMast.getLocType1()) |
| | | .orderBy("bay1", true)); |
| | | } |
| | | for (LocMast locMast1 : locMasts) { |
| | | if (locMast1.getLocNo().equals(dto.getLocNo())){ |
| | | if (locMast1.getLocNo().equals(dto.getLocNo())) { |
| | | break; |
| | | } |
| | | if (locMast1.getLocSts().equals("X")){ |
| | | throw new CoolException(dto.getLocNo()+"库位前方有锁定库位,禁止出库"); |
| | | if (locMast1.getLocSts().equals("X")) { |
| | | throw new CoolException(dto.getLocNo() + "库位前方有锁定库位,禁止出库"); |
| | | } |
| | | if (locMast1.getLocSts().equals("F")) { |
| | | moveLocForDeepLoc(locMast1); |
| | |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (ioType == 107){ |
| | | if (ioType == 107) { |
| | | wrkMast.setSheetNo(param.getOrderNo()); |
| | | } |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+dto.getLocNo()); |
| | | throw new CoolException("保存工作档失败,出库库位号:" + dto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | |
| | | throw new CoolException("保存盘点明细失败"); |
| | | } |
| | | |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | 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(); |
| | | Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+dto.getLocNo()); |
| | | throw new CoolException("预约库位状态失败,库位号:" + dto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | |
| | | public void locMove(String sourceLocNo, String locNo, Long userId) { |
| | | LocMast sourceLoc = locMastService.selectById(sourceLocNo); |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); |
| | | if (Cools.isEmpty(sourceLoc)){ |
| | | if (Cools.isEmpty(sourceLoc)) { |
| | | throw new CoolException("未找到库位"); |
| | | } |
| | | LocMast loc = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(loc)){ |
| | | if (Cools.isEmpty(loc)) { |
| | | throw new CoolException("未找到库位"); |
| | | } |
| | | if (!loc.getLocSts().equals("O") || (!sourceLoc.getLocSts().equals("F") && !sourceLoc.getLocSts().equals("D"))){ |
| | | if (!loc.getLocSts().equals("O") || (!sourceLoc.getLocSts().equals("F") && !sourceLoc.getLocSts().equals("D"))) { |
| | | throw new CoolException("库位状态已改变"); |
| | | } |
| | | if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { |
| | |
| | | wrkMast.setCrnNo(sourceLoc.getCrnNo()); |
| | | wrkMast.setSourceLocNo(sourceLocNo); // 源库位 |
| | | wrkMast.setLocNo(locNo); // 目标库位 |
| | | wrkMast.setFullPlt(Cools.isEmpty(locDetls)?"N":"Y"); // 满板:Y |
| | | wrkMast.setFullPlt(Cools.isEmpty(locDetls) ? "N" : "Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 空板 |
| | | wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeUser(userId); |
| | |
| | | sourceLoc.setLocSts("R"); // R.出库预约 |
| | | sourceLoc.setModiUser(userId); |
| | | sourceLoc.setModiTime(now); |
| | | if (!locMastService.updateById(sourceLoc)){ |
| | | if (!locMastService.updateById(sourceLoc)) { |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("源库位出库失败,状态:"+sourceLoc.getLocSts$()); |
| | | throw new CoolException("源库位出库失败,状态:" + sourceLoc.getLocSts$()); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:"+loc.getLocSts$()); |
| | | throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$()); |
| | | } |
| | | } |
| | | |
| | |
| | | @Transactional |
| | | public void completeWrkMast(String workNo, Long userId) { |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 14) { |
| | | throw new CoolException("当前工作档已完成"); |
| | | } |
| | | // 入库 + 库位转移 |
| | | if (wrkMast.getIoType() <100 ) { |
| | | if (wrkMast.getIoType() < 100) { |
| | | wrkMast.setWrkSts(4L); |
| | | // 出库 |
| | | } else if (wrkMast.getIoType() >100 && wrkMast.getWrkSts() > 10) { |
| | | // 出库 |
| | | } else if (wrkMast.getIoType() > 100 && wrkMast.getWrkSts() > 10) { |
| | | wrkMast.setWrkSts(14L); |
| | | } |
| | | Date now = new Date(); |
| | |
| | | Iterator<LocDetlAdjustParam.LocDetlAdjust> iterator1 = list.iterator(); |
| | | while (iterator1.hasNext()) { |
| | | LocDetlAdjustParam.LocDetlAdjust adjust = iterator1.next(); |
| | | if (adjust.getCount() == 0) { continue; } |
| | | if (adjust.getCount() == 0) { |
| | | continue; |
| | | } |
| | | if (locDetl.getMatnr().equals(adjust.getMatnr()) && Cools.eq(locDetl.getBatch(), adjust.getBatch())) { |
| | | if (!locDetl.getAnfme().equals(adjust.getCount())) { |
| | | // todo 盘点记录 |
| | |
| | | |
| | | // 添加库存 |
| | | for (LocDetlAdjustParam.LocDetlAdjust adjust : list) { |
| | | if (adjust.getCount() == 0.0D) { continue; } |
| | | if (adjust.getCount() == 0.0D) { |
| | | continue; |
| | | } |
| | | Mat mat = matService.selectByMatnr(adjust.getMatnr()); |
| | | LocDetl locDetl = new LocDetl(); |
| | | locDetl.sync(mat); |
| | |
| | | public void cancelWrkMast(String workNo, Long userId) { |
| | | Date now = new Date(); |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | String locNo = ""; // 待修改目标库位 |
| | | String locSts = ""; // 待修改目标库位状态 |
| | | // 入库取消(修改目标库位) |
| | | if (wrkMast.getIoType() <100 ) { |
| | | if (wrkMast.getIoType() < 100) { |
| | | locNo = wrkMast.getLocNo(); |
| | | locSts = "O"; |
| | | |
| | |
| | | // 库位转移:源库位 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消库位转移失败,源库位不存在:"+ wrkMast.getSourceLocNo()); |
| | | throw new CoolException("取消库位转移失败,源库位不存在:" + wrkMast.getSourceLocNo()); |
| | | } |
| | | locMast.setLocSts(wrkMast.getFullPlt().equalsIgnoreCase("N")?"D":"F"); |
| | | locMast.setLocSts(wrkMast.getFullPlt().equalsIgnoreCase("N") ? "D" : "F"); |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(userId); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | // 出库取消(修改源库位) |
| | | } else if (wrkMast.getIoType() >=100 && wrkMast.getIoType()<=200) { |
| | | // 出库取消(修改源库位) |
| | | } else if (wrkMast.getIoType() >= 100 && wrkMast.getIoType() <= 200) { |
| | | locNo = wrkMast.getSourceLocNo(); |
| | | // 出库 ===>> F.在库 |
| | | if (wrkMast.getIoType() > 100 && wrkMast.getIoType() != 110) { |
| | | locSts = "F"; |
| | | // 空板出库 ===>> D.空桶/空栈板 |
| | | // 空板出库 ===>> D.空桶/空栈板 |
| | | } else if (wrkMast.getIoType() == 110) { |
| | | locSts = "D"; |
| | | // 库位转移 ===>> D.空桶/空栈板 |
| | | // 库位转移 ===>> D.空桶/空栈板 |
| | | } else if (wrkMast.getIoType() == 11) { |
| | | locSts = wrkMast.getFullPlt().equalsIgnoreCase("N")?"D":"F"; |
| | | locSts = wrkMast.getFullPlt().equalsIgnoreCase("N") ? "D" : "F"; |
| | | // 库位转移:目标库位 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消库位转移失败,目标库位不存在:"+ wrkMast.getSourceLocNo()); |
| | | throw new CoolException("取消库位转移失败,目标库位不存在:" + wrkMast.getSourceLocNo()); |
| | | } |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(userId); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | } else if (wrkMast.getIoType() >=300) { |
| | | |
| | | } else if (wrkMast.getIoType() >= 300) { |
| | | |
| | | } else { |
| | | throw new CoolException("当前工作状态无法取消"); |
| | | } |
| | | |
| | | //取消入库工作档时,查询组托表,如果有将状态改为待处理 |
| | | if(wrkMast.getIoType() == 1) { |
| | | List<WaitPakin> waitPakins=waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", wrkMast.getBarcode())); |
| | | for (WaitPakin waitPakin:waitPakins){ |
| | | if (wrkMast.getIoType() == 1) { |
| | | List<WaitPakin> waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", wrkMast.getBarcode())); |
| | | for (WaitPakin waitPakin : waitPakins) { |
| | | if (!Cools.isEmpty(waitPakin)) { |
| | | waitPakin.setIoStatus("N"); |
| | | waitPakin.setLocNo(""); |
| | | waitPakinService.update(waitPakin, new EntityWrapper<WaitPakin>() |
| | | // .eq("order_no", waitPakin.getOrderNo()) |
| | | .eq("zpallet",waitPakin.getZpallet()) |
| | | .eq("zpallet", waitPakin.getZpallet()) |
| | | .eq("matnr", waitPakin.getMatnr()) |
| | | .eq("batch", waitPakin.getBatch())); |
| | | } |
| | |
| | | } |
| | | |
| | | //取消出库工作档时,查询单据管理表,回滚作业中数量 |
| | | if(wrkMast.getIoType() == 101 || wrkMast.getIoType() == 103 || wrkMast.getIoType() == 300) { |
| | | if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 103 || wrkMast.getIoType() == 300) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | if (!Cools.isEmpty(wrkDetl.getOrderNo())) { |
| | |
| | | |
| | | //修改订单主表状态,没有作业数量时才可以修改 |
| | | boolean flag = true; |
| | | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no",wrkDetl.getOrderNo())); |
| | | for(OrderDetl orderDetl : orderDetls){ |
| | | if(orderDetl.getWorkQty() > 0){ |
| | | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", wrkDetl.getOrderNo())); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | if (orderDetl.getWorkQty() > 0) { |
| | | flag = false; |
| | | } |
| | | } |
| | | if(flag){ |
| | | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no",wrkDetl.getOrderNo())); |
| | | if(!Cools.isEmpty(order) && order.getSettle()==2){ |
| | | if (flag) { |
| | | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", wrkDetl.getOrderNo())); |
| | | if (!Cools.isEmpty(order) && order.getSettle() == 2) { |
| | | order.setSettle(1L); |
| | | order.setUpdateBy(userId); |
| | | order.setUpdateTime(now); |
| | | } |
| | | if(!orderService.update(order,new EntityWrapper<Order>().eq("order_no",wrkDetl.getOrderNo()))){ |
| | | if (!orderService.update(order, new EntityWrapper<Order>().eq("order_no", wrkDetl.getOrderNo()))) { |
| | | throw new CoolException("修改订单状态失败"); |
| | | } |
| | | } |
| | |
| | | boolean wrkDetlRes = wrkDetlService.delete(new EntityWrapper<WrkDetl>().eq("wrk_no", workNo)); |
| | | } |
| | | |
| | | if (wrkMast.getIoType() != 300){ |
| | | if (wrkMast.getIoType() != 300) { |
| | | // 修改库位状态 |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消工作档失败,库位不存在:"+ locNo); |
| | | throw new CoolException("取消工作档失败,库位不存在:" + locNo); |
| | | } |
| | | locMast.setLocSts(locSts); |
| | | locMast.setModiTime(now); |
| | |
| | | if (!wrkMastRes || !locMastRes) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |
| | | }else { |
| | | } else { |
| | | if (!wrkMastRes) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |
| | |
| | | @Transactional |
| | | public void pickWrkMast(String workNo, Long userId) { |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | // 入出库类型判断 |
| | | if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) { |
| | |
| | | // 目标库位 |
| | | LocMast targetLoc = null; |
| | | |
| | | for (int curRow = rowLastno.getsRow(); curRow<=rowLastno.geteRow(); curRow++) { |
| | | for (int curRow = rowLastno.getsRow(); curRow <= rowLastno.geteRow(); curRow++) { |
| | | |
| | | if (Utils.isShallowLoc(slaveProperties, curRow)) { |
| | | Integer deepRow = Utils.getDeepRow(slaveProperties, curRow); |
| | |
| | | throw new CoolException("修改工作档失败"); |
| | | } |
| | | // 修改库位状态 O ===>>> S |
| | | if (targetLoc.getLocSts().equals("O")){ |
| | | if (targetLoc.getLocSts().equals("O")) { |
| | | targetLoc.setLocSts("S"); // S.入库预约 |
| | | targetLoc.setModiUser(userId); |
| | | targetLoc.setModiTime(now); |
| | | if (!locMastService.updateById(targetLoc)){ |
| | | if (!locMastService.updateById(targetLoc)) { |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException(targetLoc.getLocNo()+"目标库位已被占用"); |
| | | throw new CoolException(targetLoc.getLocNo() + "目标库位已被占用"); |
| | | } |
| | | // 禁用异常库位 |
| | | // locMast.setLocSts("X"); // X.禁用 |
| | |
| | | @Transactional |
| | | public void turnMatLocDetl(EmptyPlateOutParam param, Long userId) { |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("id", param.getMatId())); |
| | | if (Cools.isEmpty(mat)){ |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException("目标库位商品编码有误!"); |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("matnr", param.getLocDetls().get(0).getMatnr())); |
| | | if (Cools.isEmpty(locDetls) || locDetls.size()<1){ |
| | | throw new CoolException("待修改商品无库存,无需修改! 品号:"+param.getLocDetls().get(0).getMatnr()); |
| | | if (Cools.isEmpty(locDetls) || locDetls.size() < 1) { |
| | | throw new CoolException("待修改商品无库存,无需修改! 品号:" + param.getLocDetls().get(0).getMatnr()); |
| | | } |
| | | try { |
| | | locDetlService.updateMatTurn(param.getLocDetls().get(0).getMatnr(),mat.getMatnr()); |
| | | }catch (Exception e){ |
| | | locDetlService.updateMatTurn(param.getLocDetls().get(0).getMatnr(), mat.getMatnr()); |
| | | } catch (Exception e) { |
| | | throw new CoolException("对数据库修改出错!"); |
| | | } |
| | | for (LocDetl locDetl:locDetls){ |
| | | for (LocDetl locDetl : locDetls) { |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |
| | | adjDetl.setLocNo(locDetl.getLocNo()); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Transactional |
| | | public void stockOutSXK(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId) { |
| | | Date now = new Date(); |
| | |
| | | ioType = dto.isAll() ? 101 : 103; |
| | | } else if (ioWorkType.equals(IoWorkType.CHECK_OUT)) { |
| | | ioType = 107; |
| | | }else if (ioWorkType.equals(IoWorkType.MERGE_OUT)) { |
| | | } else if (ioWorkType.equals(IoWorkType.MERGE_OUT)) { |
| | | ioType = 104; |
| | | } |
| | | assert ioType != null; |
| | |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | if ((locMast.getBay1() >=1 && locMast.getBay1()<=2) || (locMast.getBay1() >=6 && locMast.getBay1()<=7 && locMast.getRow1() !=36 && locMast.getRow1() !=29 ) || (locMast.getBay1() >=11 && locMast.getBay1()<=12)){ |
| | | if ((locMast.getBay1() >= 1 && locMast.getBay1() <= 2) || (locMast.getBay1() >= 6 && locMast.getBay1() <= 7 && locMast.getRow1() != 36 && locMast.getRow1() != 29) || (locMast.getBay1() >= 11 && locMast.getBay1() <= 12)) { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .eq("loc_type1", locMast.getLocType1()) |
| | | .orderBy("bay1", false)); |
| | | }else { |
| | | } else { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .eq("loc_type1", locMast.getLocType1()) |
| | | .orderBy("bay1", true)); |
| | | } |
| | | for (LocMast locMast1 : locMasts) { |
| | | if (locMast1.getLocNo().equals(dto.getLocNo())){ |
| | | if (locMast1.getLocNo().equals(dto.getLocNo())) { |
| | | break; |
| | | } |
| | | if (locMast1.getLocSts().equals("X")){ |
| | | throw new CoolException(dto.getLocNo()+"库位前方有锁定库位,禁止出库"); |
| | | if (locMast1.getLocSts().equals("X")) { |
| | | throw new CoolException(dto.getLocNo() + "库位前方有锁定库位,禁止出库"); |
| | | } |
| | | if (locMast1.getLocSts().equals("F")) { |
| | | moveLocForDeepLoc(locMast1); |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+dto.getLocNo()); |
| | | throw new CoolException("保存工作档失败,出库库位号:" + dto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | if (ioType != 104){ |
| | | if (ioType != 104) { |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | 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(); |
| | | Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+dto.getLocNo()); |
| | | throw new CoolException("预约库位状态失败,库位号:" + dto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public void toSxk(WrkMast wrkMastold, List<WrkDetl> wrkDetls, Short locType) { |
| | | LocTypeDto locTypeDto = new LocTypeDto(); |
| | | locTypeDto.setLocType1(locType); |
| | | StartupDto dto = commonService.getLocNo(1, 1031, null, null, null, locTypeDto, false); |
| | | if (Cools.isEmpty(dto)) { |
| | | throw new CoolException("去四项库未找到库位"); |
| | | } |
| | | LocMast loc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", dto.getLocNo())); |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(1L); // 工作状态:1.生成入库ID |
| | | wrkMast.setIoType(1); // 入出库状态: 1.库格移载 |
| | | wrkMast.setIoPri(12D); |
| | | wrkMast.setCrnNo(7); |
| | | wrkMast.setLocNo(dto.getLocNo()); // 目标库位 |
| | | wrkMast.setFullPlt("Y"); // 满板 |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setBarcode(wrkMastold.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 工作档明细保存 |
| | | if (wrkDetls != null) { |
| | | for (WrkDetl wrk : wrkDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | Synchro.Copy(wrk, wrkDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setAnfme(wrk.getAnfme()); |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(loc)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Transactional |
| | | public void toCrn(WrkMast wrkMastold, List<WrkDetl> wrkDetls, Short locType) { |
| | | LocTypeDto locTypeDto = new LocTypeDto(); |
| | | locTypeDto.setLocType1(locType); |
| | | StartupDto dto = commonService.getLocNo(1, 1035, null, null, null, locTypeDto, false); |
| | | if (Cools.isEmpty(dto)) { |
| | | throw new CoolException("去堆垛机未找到库位"); |
| | | } |
| | | LocMast loc = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", dto.getLocNo())); |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(1L); // 工作状态:1.生成入库ID |
| | | wrkMast.setIoType(1); // 入出库状态: 1.入库 |
| | | wrkMast.setIoPri(12D); |
| | | wrkMast.setCrnNo(7); |
| | | wrkMast.setLocNo(dto.getLocNo()); // 目标库位 |
| | | wrkMast.setFullPlt(wrkDetls == null ? "N" : "Y"); // 满板 |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(wrkDetls != null ? "N" : "Y"); // 空板 |
| | | wrkMast.setBarcode(wrkMastold.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 工作档明细保存 |
| | | if (wrkDetls != null) { |
| | | for (WrkDetl wrk : wrkDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | Synchro.Copy(wrk, wrkDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setAnfme(wrk.getAnfme()); |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(loc)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |