| | |
| | | @Parameter(name = "code", description = "批次号(二维码内容)", required = true, example = "PC20260818L01001") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-batch:query')") |
| | | public CommonResult<MesProBatchTraceRespVO> getBatchByCode(@RequestParam("code") String code) { |
| | | MesProBatchDO batch = batchService.getBatchByCode(code); |
| | | MesProBatchDO batch = batchService.getBatchByScanCode(code); |
| | | if (batch == null) { |
| | | throw exception(PRO_BATCH_NOT_EXISTS); |
| | | } |
| | |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | @PostMapping("/generate-business-code") |
| | | @Operation(summary = "补生成已有生产批次业务码,已有码值不变") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-batch:create')") |
| | | public CommonResult<Integer> generateBusinessCodes(@Valid @RequestBody |
| | | cn.iocoder.yudao.module.mes.controller.admin.pro.vo.MesProBusinessCodeGenerateReqVO reqVO) { |
| | | return success(batchService.generateBusinessCodes(reqVO.getIds())); |
| | | } |
| | | |
| | | @GetMapping("/export-business-qr") |
| | | @Operation(summary = "导出批次及所属托盘业务二维码,内容为纯业务码值") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-batch:export')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void exportBusinessQr(@RequestParam("batchId") Long batchId, |
| | | HttpServletResponse response) throws IOException { |
| | | MesProBatchDO batch = batchService.getBatch(batchId); |
| | | if (batch == null) throw exception(PRO_BATCH_NOT_EXISTS); |
| | | if (cn.iocoder.yudao.module.mes.enums.pro.MesProBatchStatusEnum.CANCELED.getStatus().equals(batch.getStatus())) |
| | | throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400, "已作废批次不可导出业务二维码"); |
| | | List<MesProPalletDO> pallets = palletService.getPalletListByBatchId(batchId).stream() |
| | | .filter(record -> !cn.iocoder.yudao.module.mes.enums.pro.MesProPalletStatusEnum.CANCELED.getStatus().equals(record.getStatus())).toList(); |
| | | if (pallets.size() + 1 > QrCodeImageUtils.MAX_QR_EXPORT) throw exception(PRO_QR_EXPORT_TOO_MANY); |
| | | List<QrLabelInfo> labels = new java.util.ArrayList<>(); |
| | | labels.add(MesProQrLabelBuilder.buildBatchBusinessCodeLabel(batch)); |
| | | pallets.forEach(pallet -> labels.add(MesProQrLabelBuilder.buildPalletBusinessCodeLabel(pallet))); |
| | | QrCodeImageUtils.writeZip(response, "批次业务二维码-" + batch.getBusinessCode(), labels); |
| | | } |
| | | |
| | | private List<MesProBatchRespVO> buildBatchRespVOList(List<MesProBatchDO> list) { |
| | | if (CollUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |
| | |
| | | // 1. 获得关联数据(责任人);品种已下沉到袋码数据包,批次列表不再展示 |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesProBatchDO::getOwnerUserId)); |
| | | // 2. 构建结果 |
| | | return BeanUtils.toBean(list, MesProBatchRespVO.class, vo -> |
| | | MapUtils.findAndThen(userMap, vo.getOwnerUserId(), user -> |
| | | vo.setOwnerUserName(user.getNickname()))); |
| | | Map<Long, MesMdmItemDO> itemMap = mdmItemService.getItemMap(convertSet(list, MesProBatchDO::getItemId)); |
| | | return BeanUtils.toBean(list, MesProBatchRespVO.class, vo -> { |
| | | MapUtils.findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname())); |
| | | MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { vo.setItemCode(item.getCode()); vo.setItemName(item.getName()); }); |
| | | }); |
| | | } |
| | | |
| | | private List<MesProBatchWorkerRespVO> buildWorkerRespVOList(List<MesProBatchWorkerDO> workers) { |
| | |
| | | respVO.setPallets(BeanUtils.toBean(palletService.getPalletListByBatchId(batch.getId()), MesProPalletRespVO.class)); |
| | | // 袋码列表(封顶 2000,bagTotal 记录总数) |
| | | List<MesProBagCodeDO> bags = bagCodeService.getBagCodeListByBatchId(batch.getId()); |
| | | respVO.setPendingBagQuantity((int) bags.stream().filter(b -> !Integer.valueOf(30).equals(b.getStatus()) && b.getInboundEventId() == null).count()); |
| | | respVO.setBagTotal(bags.size()); |
| | | if (bags.size() > QrCodeImageUtils.MAX_QR_EXPORT) { |
| | | bags = bags.subList(0, QrCodeImageUtils.MAX_QR_EXPORT); |