| | |
| | | private RowLastnoService rowLastnoService; |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | |
| | | @PostMapping("/pakin/loc/v1") |
| | | @ResponseBody |
| | | public synchronized R getLocNo(@RequestBody SearchLocParam param) { |
| | | |
| | | long startTime = System.currentTimeMillis(); |
| | | String barcode = param == null ? null : param.getBarcode(); |
| | | Integer sourceStaNo = param == null ? null : param.getSourceStaNo(); |
| | | try { |
| | | if(param.getBarcode().contains("-") || param.getBarcode().contains("gsl")){ |
| | | log.info("收到WCS入库接口请求====>>入参:{}", param); |
| | | } |
| | |
| | | } |
| | | |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getSourceStaNo(), true); |
| | | sourceStaNo.setLocType1(param.getLocType1()); |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | BasDevp sourceStaNoEntity = basDevpService.checkSiteStatus(param.getSourceStaNo(), true); |
| | | sourceStaNoEntity.setLocType1(param.getLocType1()); |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNoEntity); |
| | | if (waitPakins.get(0).getMatnr().equals("emptyPallet")) { |
| | | locTypeDto.setLocType2((short) 1); |
| | | } |
| | |
| | | StartupDto dto = startupFullPutStore(param.getSourceStaNo(), param.getBarcode(), locTypeDto, waitPakins); |
| | | log.info("WCS入库接口返参:{},托盘码:{}", dto, param.getBarcode()); |
| | | return R.ok().add(dto); |
| | | } finally { |
| | | log.info("WCS入库接口总耗时:{}ms, sourceStaNo:{}, barcode:{}", System.currentTimeMillis() - startTime, sourceStaNo, barcode); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/pakin/agv/loc/v1") |
| | |
| | | */ |
| | | @Transactional |
| | | public StartupDto startupFullPutStore(Integer devpNo, String barcode, LocTypeDto locTypeDto, List<WaitPakin> waitPakins) { |
| | | long startTime = System.currentTimeMillis(); |
| | | try { |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true); |
| | | // 检索库位 |
| | |
| | | List<String> batchs = waitPakins.stream().map(WaitPakin::getBatch).distinct().collect(Collectors.toList()); |
| | | FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(matnrs.get(0), batchs.get(0)); |
| | | // FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(waitPakins.get(0)); |
| | | // 满板入库统一按库位排号(row_lastno)的 currentRow/crn_qty 轮询,不参考 WCS 透传的推荐排。 |
| | | StartupDto dto = commonService.getLocNo(1, devpNo, findLocNoAttributeVo, locTypeDto); |
| | | // IoT 指定了目标库位时优先尝试该库位;不可用时再退回现有自动找位规则。 |
| | | StartupDto dto = buildPreferredStartupDto(devpNo, extractPreferredInboundLoc(waitPakins)); |
| | | if (dto == null) { |
| | | dto = commonService.getLocNo(1, devpNo, findLocNoAttributeVo, locTypeDto); |
| | | } |
| | | int workNo = dto.getWorkNo(); |
| | | Date now = new Date(); |
| | | // 生成工作档 |
| | |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("Y"); |
| | | // 把 referenceId/orderNo 透传到工作主档,便于作业完成后继续回传给 IoT。 |
| | | wrkMast.setUserNo(waitPakins.get(0).getOrderNo()); |
| | | wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | |
| | | dto.setLocNo(wcsLoc); |
| | | dto.setTaskNo(workNo + ""); |
| | | return dto; |
| | | } finally { |
| | | log.info("startupFullPutStore耗时:{}ms, sourceStaNo:{}, barcode:{}", System.currentTimeMillis() - startTime, devpNo, barcode); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 指定库位暂存在入库通知档 manu 字段,等 WCS 真正建任务时再读取。 |
| | | */ |
| | | private String extractPreferredInboundLoc(List<WaitPakin> waitPakins) { |
| | | if (Cools.isEmpty(waitPakins)) { |
| | | return null; |
| | | } |
| | | for (WaitPakin waitPakin : waitPakins) { |
| | | if (!Cools.isEmpty(waitPakin.getManu())) { |
| | | return waitPakin.getManu(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 把远端指定库位转换成可直接下发给 WCS 的目标站台和作业参数。 |
| | | * 如果库位已占用或对应设备不在自动模式,则返回 null 交给原有找位逻辑处理。 |
| | | */ |
| | | private StartupDto buildPreferredStartupDto(Integer sourceStaNo, String preferredLocNo) { |
| | | if (Cools.isEmpty(preferredLocNo)) { |
| | | return null; |
| | | } |
| | | LocMast targetLoc = locMastService.selectById(preferredLocNo); |
| | | if (targetLoc == null || !"O".equalsIgnoreCase(targetLoc.getLocSts())) { |
| | | return null; |
| | | } |
| | | StaDesc staDesc = staDescService.queryCrnStn(targetLoc.getCrnNo()); |
| | | if (staDesc == null) { |
| | | return null; |
| | | } |
| | | BasDevp staNo = basDevpService.selectById(staDesc.getCrnStn()); |
| | | if (staNo == null || !"Y".equalsIgnoreCase(staNo.getAutoing())) { |
| | | return null; |
| | | } |
| | | StartupDto dto = new StartupDto(); |
| | | dto.setWorkNo(commonService.getWorkNo(0)); |
| | | dto.setCrnNo(targetLoc.getCrnNo()); |
| | | dto.setSourceStaNo(sourceStaNo); |
| | | dto.setStaNo(staNo.getDevNo()); |
| | | dto.setLocNo(targetLoc.getLocNo()); |
| | | return dto; |
| | | } |
| | | |
| | | @Transactional |