tuqin
13 小时以前 7580d02bd3f9399143a6a388732658bea2610bc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);
    }
 
}