| | |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-pallet:query')") |
| | | public CommonResult<MesProPalletRespVO> getPallet(@RequestParam("id") Long id) { |
| | | MesProPalletDO pallet = palletService.getPallet(id); |
| | | return success(BeanUtils.toBean(pallet, MesProPalletRespVO.class)); |
| | | return success(pallet == null ? null : buildPalletRespVOList(List.of(pallet)).get(0)); |
| | | } |
| | | |
| | | @GetMapping("/get-by-code") |
| | |
| | | @Parameter(name = "code", description = "托盘码(二维码内容)", required = true, example = "PC20260818L01001-P01") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-pallet:query')") |
| | | public CommonResult<MesProPalletTraceRespVO> getPalletByCode(@RequestParam("code") String code) { |
| | | MesProPalletDO pallet = palletService.getPalletByCode(code); |
| | | MesProPalletDO pallet = palletService.getPalletByScanCode(code); |
| | | if (pallet == null) { |
| | | throw exception(PRO_PALLET_NOT_EXISTS); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-pallet:query')") |
| | | public CommonResult<PageResult<MesProPalletRespVO>> getPalletPage(@Valid MesProPalletPageReqVO pageReqVO) { |
| | | PageResult<MesProPalletDO> pageResult = palletService.getPalletPage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, MesProPalletRespVO.class)); |
| | | return success(new PageResult<>(buildPalletRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | | } |
| | | |
| | | @GetMapping("/simple-list") |
| | |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-pallet:query')") |
| | | public CommonResult<List<MesProPalletRespVO>> getPalletSimpleList(@RequestParam("batchId") Long batchId) { |
| | | List<MesProPalletDO> list = palletService.getPalletListByBatchId(batchId); |
| | | return success(BeanUtils.toBean(list, MesProPalletRespVO.class)); |
| | | return success(buildPalletRespVOList(list)); |
| | | } |
| | | |
| | | @GetMapping("/unbound-list") |
| | |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-pallet:query')") |
| | | public CommonResult<List<MesProPalletRespVO>> getUnboundPalletList() { |
| | | List<MesProPalletDO> list = palletService.getUnboundPalletList(); |
| | | return success(BeanUtils.toBean(list, MesProPalletRespVO.class)); |
| | | return success(buildPalletRespVOList(list)); |
| | | } |
| | | |
| | | @GetMapping("/export-excel") |
| | |
| | | HttpServletResponse response) throws IOException { |
| | | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| | | List<MesProPalletDO> list = palletService.getPalletPage(pageReqVO).getList(); |
| | | List<MesProPalletRespVO> voList = BeanUtils.toBean(list, MesProPalletRespVO.class); |
| | | List<MesProPalletRespVO> voList = buildPalletRespVOList(list); |
| | | ExcelUtils.write(response, "托盘码.xls", "数据", MesProPalletRespVO.class, voList); |
| | | } |
| | | |
| | |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | @PostMapping("/generate-business-code") |
| | | @Operation(summary = "补生成已有托盘业务码,已有码值不变") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-pallet:create')") |
| | | public CommonResult<Integer> generateBusinessCodes(@Valid @RequestBody |
| | | cn.iocoder.yudao.module.mes.controller.admin.pro.vo.MesProBusinessCodeGenerateReqVO reqVO) { |
| | | return success(palletService.generateBusinessCodes(reqVO.getIds())); |
| | | } |
| | | |
| | | @PostMapping("/export-business-qr-by-ids") |
| | | @Operation(summary = "按编号导出托盘业务码二维码,内容为纯业务码值") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-pallet:export')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void exportBusinessQrByIds(@Valid @RequestBody MesProPalletExportQrReqVO reqVO, |
| | | HttpServletResponse response) throws IOException { |
| | | List<MesProPalletDO> list = palletService.getPalletListByIds(reqVO.getIds()).stream() |
| | | .filter(record -> !cn.iocoder.yudao.module.mes.enums.pro.MesProPalletStatusEnum.CANCELED.getStatus().equals(record.getStatus())).toList(); |
| | | if (CollUtil.isEmpty(list)) throw exception(PRO_PALLET_NOT_EXISTS); |
| | | if (list.size() > QrCodeImageUtils.MAX_QR_EXPORT) throw exception(PRO_QR_EXPORT_TOO_MANY); |
| | | QrCodeImageUtils.writeZip(response, "托盘业务二维码", list.stream() |
| | | .map(MesProQrLabelBuilder::buildPalletBusinessCodeLabel).toList()); |
| | | } |
| | | |
| | | private List<MesProPalletRespVO> buildPalletRespVOList(List<MesProPalletDO> list) { |
| | | Map<Long, MesMdmItemDO> items = mdmItemService.getItemMap(convertSet(list, MesProPalletDO::getItemId)); |
| | | return BeanUtils.toBean(list, MesProPalletRespVO.class, vo -> |
| | | MapUtils.findAndThen(items, vo.getItemId(), item -> { vo.setItemCode(item.getCode()); vo.setItemName(item.getName()); })); |
| | | } |
| | | |
| | | private MesProPalletTraceRespVO buildPalletTraceRespVO(MesProPalletDO pallet) { |
| | | MesProPalletTraceRespVO respVO = BeanUtils.toBean(pallet, MesProPalletTraceRespVO.class); |
| | | respVO.setPendingBagQuantity((int) bagCodeService.getBagCodeListByPalletId(pallet.getId()).stream() |
| | | .filter(b -> !Integer.valueOf(30).equals(b.getStatus()) && b.getInboundEventId() == null).count()); |
| | | if (pallet.getItemId() != null) { |
| | | MesMdmItemDO item = mdmItemService.getItem(pallet.getItemId()); |
| | | if (item != null) respVO.setItemCode(item.getCode()).setItemName(item.getName()).setItemSpecification(item.getSpecification()); |
| | | } |
| | | // 批次信息(临时托盘未绑定批次时为空批次) |
| | | MesProBatchDO batch = pallet.getBatchId() == null ? null : batchService.getBatch(pallet.getBatchId()); |
| | | if (batch != null) { |