cl
2026-04-20 b4b1e61b1dd8fb988957f80f1326bda069a48276
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
54
55
56
57
58
package com.vincent.rsf.server.api.controller;
 
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.server.manager.service.CusItemSyncViewQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * 鼎捷 查询验证(/test/** 免登录)
 */
@RestController
@RequestMapping("/test/cusItemSyncView")
@Api(tags = "鼎捷 测试")
public class CusItemSyncViewTestController {
 
    @Autowired
    private CusItemSyncViewQueryService cusItemSyncViewQueryService;
 
    @GetMapping("/probe")
    @ApiOperation("取视图前几条样例,验证副库/主库连通")
    public R probe(@RequestParam(defaultValue = "5") int limit) {
        Map<String, Object> body = new LinkedHashMap<>();
        body.put("effectiveDataSource", cusItemSyncViewQueryService.effectiveDataSourceLabel());
        body.put("rows", cusItemSyncViewQueryService.probeSample(limit));
        return R.ok().add(body);
    }
 
    @GetMapping("/byCodes")
    @ApiOperation("按物料编码查询视图(逗号分隔)")
    public R byCodes(@RequestParam String codes) {
        if (StringUtils.isBlank(codes)) {
            return R.error("codes 不能为空,示例:/test/cusItemSyncView/byCodes?codes=A001,B002");
        }
        List<String> list = Arrays.stream(codes.split(","))
                .map(String::trim)
                .filter(StringUtils::isNotBlank)
                .collect(Collectors.toList());
        if (list.isEmpty()) {
            return R.error("codes 解析后为空");
        }
        Map<String, Object> body = new LinkedHashMap<>();
        body.put("effectiveDataSource", cusItemSyncViewQueryService.effectiveDataSourceLabel());
        body.put("rows", cusItemSyncViewQueryService.listByItemNos(list));
        return R.ok().add(body);
    }
}