| | |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.entity.param.FullStoreParam; |
| | | import com.zy.asrs.entity.param.LocDetlAdjustParam; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.*; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.swing.*; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Override |
| | | @Transactional |
| | | public void startupFullTakeStore(StockOutParam param, Long userId) { |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId); |
| | | stockOut(null, locDetlDtos, null, userId); |
| | | } else { |
| | | throw new CoolException("库存不存在"); |
| | | } |
| | | } |
| | | /** |
| | | * 通过库位号获取 排 |
| | | */ |
| | | public static int getRow(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(0, 2)); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | /** |
| | | * 通过库位号获取 列 |
| | | */ |
| | | public static int getBay(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(2, 5)); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | /** |
| | | * 通过库位号获取 层 |
| | | */ |
| | | public static int getLev(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(5, 7)); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | // 获取路径 |
| | | Boolean outMost = locMastService.isOutMost(dto.getLocNo(), false); |
| | | Integer outCrnNo = locMastService.getOutCrnNo(locMast); |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, outCrnNo, staNo.getDevNo()); |
| | | |
| | | // 生成工作号 |
| | | 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.setWrkSts(ioType == 101?17L:9L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(ioType == 101?101:53); // 入出库状态 |
| | | Double ioPri = wrkMastService.getIoPri(ioType, dto.getLocNo()); |
| | | wrkMast.setIoPri(ioPri); // 优先级:13 |
| | | wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), false)?1:0);; |
| | | wrkMast.setCrnNo(outCrnNo); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(dto.getLocNo()); // 源库位 |
| | | wrkMast.setOutMost(outMost?1:0);; |
| | | wrkMast.setCrnNo(outMost?outCrnNo:locMast.getCrnNo()); |
| | | if (ioType == 101){ |
| | | wrkMast.setSourceLocNo(dto.getLocNo()); // 源库位 |
| | | }else { |
| | | wrkMast.setLocNo(dto.getLocNo()); |
| | | } |
| | | |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setLocSts(ioType==101?"R":"Q"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | locMastService.breakUp(dto.getLocNo(), excludeLocNos); |
| | | // locMastService.breakUp(dto.getLocNo(), excludeLocNos); |
| | | } |
| | | } |
| | | |
| | |
| | | LocMast locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | // 获取路径 |
| | | int ioType = taskDto.isAll() ? 101 : 103; |
| | | Boolean outMost = locMastService.isOutMost(taskDto.getLocNo(), false); |
| | | Integer outCrnNo = locMastService.getOutCrnNo(locMast); |
| | | StaDesc staDesc = staDescService.queryCrnStnAuto(ioType, outCrnNo, staNo.getDevNo()); |
| | | // 生成工作号 |
| | |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | Double ioPri = wrkMastService.getIoPri(ioType, taskDto.getLocNo()); |
| | | wrkMast.setIoPri(ioPri); // 优先级:13 |
| | | wrkMast.setOutMost(locMastService.isOutMost(taskDto.getLocNo(), false)?1:0);; |
| | | wrkMast.setCrnNo(outCrnNo); |
| | | wrkMast.setOutMost(outMost?1:0);; |
| | | wrkMast.setCrnNo(outMost?outCrnNo:locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(taskDto.getLocNo()); // 源库位 |
| | |
| | | @Override |
| | | @Transactional |
| | | public void emptyPlateOut(EmptyPlateOutParam param, Long userId) { |
| | | //检测是否为浅库位 |
| | | List<LocMast> locMasts = null; |
| | | boolean sign=false; |
| | | String th = ""; |
| | | for (String locNoKong: param.getLocNos()){ |
| | | int row = getRow(locNoKong); |
| | | int bay = getBay(locNoKong); |
| | | int lev = getLev(locNoKong); |
| | | if (!(row==4 || row==5)){ |
| | | if (row>5){ |
| | | locMasts=locMastService.selectList(new EntityWrapper<LocMast>().ge("row1", 5).le("row1", row) |
| | | .eq("bay1",bay).eq("lev1",lev)); |
| | | for (LocMast locMast1:locMasts){ |
| | | if (locMast1.getRow1()<row){ |
| | | if (!locMast1.getLocSts().equals("O")){ |
| | | if (param.getLocNos().contains(locMast1.getLocNo())){ |
| | | continue; |
| | | } |
| | | sign=true; |
| | | th="库位号:"+locNoKong+" 浅库位有非空库位!"; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | locMasts=locMastService.selectList(new EntityWrapper<LocMast>().le("row1", 4).ge("row1", row) |
| | | .eq("bay1",bay).eq("lev1",lev)); |
| | | for (LocMast locMast1:locMasts){ |
| | | if (locMast1.getRow1()>row){ |
| | | if (!locMast1.getLocSts().equals("O")){ |
| | | if (param.getLocNos().contains(locMast1.getLocNo())){ |
| | | continue; |
| | | } |
| | | sign=true; |
| | | th="库位号:"+locNoKong+" 浅库位有非空库位!"; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (sign){ |
| | | throw new CoolException("出库失败;"+th); |
| | | } |
| | | if (Cools.isEmpty(param.getOutSite())) { |
| | | throw new CoolException("站点不存在"); |
| | | } |
| | |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException(locNo+"库位不存在"); |
| | | } |
| | | Boolean outMost = locMastService.isOutMost(locNo, false); |
| | | Integer outCrnNo = locMastService.getOutCrnNo(locMast); |
| | | // 获取源站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | |
| | | wrkMast.setIoPri(ioPri); |
| | | wrkMast.setSourceStaNo(sourceStaNo); // 源站 |
| | | wrkMast.setStaNo(param.getOutSite()); // 目标站 |
| | | wrkMast.setOutMost(locMastService.isOutMost(locNo, false)?1:0);; |
| | | wrkMast.setCrnNo(outCrnNo); |
| | | wrkMast.setOutMost(outMost?1:0);; |
| | | wrkMast.setCrnNo(outMost?outCrnNo:locMast.getCrnNo()); |
| | | wrkMast.setSourceLocNo(locNo); // 源库位 |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | |
| | | |
| | | @Override |
| | | public StartupDto createWaitPainWrkMastStart(List<WaitPakin> list, Long userId) { |
| | | if (Cools.isEmpty(list)) { |
| | | throw new CoolException("入库通知档不能为空"); |
| | | } |
| | | LocTypeDto locTypeDto = new LocTypeDto(); |
| | | return wcsController.startupFullPutStore(301, list.get(0).getZpallet(), locTypeDto, list); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public StockOutParam selectGood(String barcode) { |
| | | // 查询托盘上的物料信息 |
| | | // 去掉可能的多余引号或者空格 |
| | | barcode = barcode.replaceAll("\"", "").trim(); |
| | | |
| | | // 尝试将 barcode 转换为 int 类型 |
| | | int barcodeInt = Integer.parseInt(barcode); |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList( |
| | | new EntityWrapper<LocDetl>().eq("zpallet", barcodeInt) |
| | | ); |
| | | |
| | | if (locDetls == null || locDetls.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | StockOutParam param = new StockOutParam(); |
| | | param.setOutSite(101); // 可以根据业务动态设置出站口 |
| | | param.setLocDetls(locDetls.stream().map(detl -> { |
| | | StockOutParam.LocDetl loc = new StockOutParam.LocDetl(); |
| | | loc.setLocNo(detl.getLocNo()); |
| | | loc.setMatnr(detl.getMatnr()); |
| | | loc.setBatch(detl.getBatch()); |
| | | loc.setCount(detl.getAnfme()); |
| | | return loc; |
| | | }).collect(Collectors.toList())); |
| | | |
| | | return param; |
| | | } |
| | | |
| | | } |