package cn.iocoder.yudao.module.mes.controller.admin.pro.trace;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.module.mes.service.pro.bagcode.MesProBagCodeService;
|
import cn.iocoder.yudao.module.mes.service.pro.batch.MesProBatchService;
|
import cn.iocoder.yudao.module.mes.service.pro.pallet.MesProPalletService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.annotation.Resource;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
/**
|
* MES 扫码追溯 - 编码类型解析。
|
*
|
* <p>编码统一为「16 位纯数字」后,无法再按前缀判断类型(BAG-/PL-/PB- 等前缀已取消),
|
* 前端扫码后先调用本接口按编码反查其所属类型,再调用对应类型的追溯接口。
|
*/
|
@Tag(name = "管理后台 - MES 扫码溯源(类型解析)")
|
@RestController
|
@RequestMapping("/mes/pro/trace")
|
@Validated
|
public class MesProTraceResolveController {
|
|
@Resource
|
private MesProBagCodeService bagCodeService;
|
@Resource
|
private MesProPalletService palletService;
|
@Resource
|
private MesProBatchService batchService;
|
|
@GetMapping("/resolve-type")
|
@Operation(summary = "根据编码解析溯源类型:bag / pallet / batch;均不匹配返回空")
|
@Parameter(name = "code", description = "编码(二维码内容)", required = true)
|
@PreAuthorize("@ss.hasPermission('mes:pro-bag-code:query')")
|
public CommonResult<String> resolveType(@RequestParam("code") String code) {
|
if (bagCodeService.getBagCodeByCode(code) != null) {
|
return success("bag");
|
}
|
if (palletService.getPalletByCode(code) != null) {
|
return success("pallet");
|
}
|
if (batchService.getBatchByCode(code) != null) {
|
return success("batch");
|
}
|
return success(null);
|
}
|
|
}
|