| | |
| | | } |
| | | |
| | | @GetMapping("/get-by-code") |
| | | @Operation(summary = "扫码追溯:根据袋码(二维码内容)反查批次、产线、责任人等信息") |
| | | @Operation(summary = "内部扫码查询:根据追溯码或业务码反查袋、批次、产线信息") |
| | | @Parameter(name = "code", description = "单元识别代码(国标:不超过 20 个字符,数字或字母数字组合)", |
| | | required = true, example = "0286267849370923") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-bag-code:query')") |
| | | public CommonResult<MesProBagCodeTraceRespVO> getBagCodeByCode(@RequestParam("code") String code) { |
| | | MesProBagCodeDO bagCode = bagCodeService.getBagCodeByCode(code); |
| | | MesProBagCodeDO bagCode = bagCodeService.getBagCodeByScanCode(code); |
| | | if (bagCode == null) { |
| | | throw exception(PRO_BAG_CODE_NOT_EXISTS); |
| | | } |
| | |
| | | |
| | | // ==================== 拼接 VO ==================== |
| | | |
| | | @PostMapping("/generate-business-code") |
| | | @Operation(summary = "补生成已有袋码的出入库业务码(已有码值不变)") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-bag-code:create')") |
| | | public CommonResult<Integer> generateBusinessCodes(@Valid @RequestBody |
| | | cn.iocoder.yudao.module.mes.controller.admin.pro.bagcode.vo.MesProBagBusinessCodeGenerateReqVO reqVO) { |
| | | return success(bagCodeService.generateBusinessCodes(reqVO.getIds())); |
| | | } |
| | | |
| | | @GetMapping("/export-business-qr") |
| | | @Operation(summary = "导出出入库业务码二维码 ZIP(二维码仅编码业务码值)") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-bag-code:export')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void exportBusinessQr(@RequestParam(value = "uuid", required = false) String uuid, |
| | | @RequestParam(value = "batchId", required = false) Long batchId, |
| | | HttpServletResponse response) throws IOException { |
| | | List<MesProBagCodeDO> list; |
| | | if (StrUtil.isNotBlank(uuid)) list = bagCodeService.getPrintableBagCodeListByUuid(uuid); |
| | | else if (batchId != null) list = bagCodeService.getPrintableBagCodeListByBatchId(batchId); |
| | | else throw exception(PRO_QR_EXPORT_PARAMS_INVALID); |
| | | if (CollUtil.isEmpty(list)) throw exception(PRO_BAG_CODE_NOT_EXISTS); |
| | | if (list.size() > QrCodeImageUtils.MAX_QR_EXPORT) throw exception(PRO_QR_EXPORT_TOO_MANY); |
| | | List<QrLabelInfo> labels = list.stream().map(MesProQrLabelBuilder::buildBagBusinessCodeLabel).toList(); |
| | | QrCodeImageUtils.writeZip(response, "袋码业务二维码-" + (StrUtil.isNotBlank(uuid) ? uuid : batchId), labels); |
| | | } |
| | | |
| | | private List<MesProBagCodeRespVO> buildBagCodeRespVOList(List<MesProBagCodeDO> list) { |
| | | if (CollUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |