package com.vincent.rsf.server.api.controller; import com.vincent.rsf.framework.common.R; import com.vincent.rsf.server.manager.service.CusBarcodeSyncViewQueryService; 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; /** * cus_barcode_sync_view 查询验证(/test/** 免登录) */ @RestController @RequestMapping("/test/cusBarcodeSyncView") @Api(tags = "cus_barcode_sync_view 测试") public class CusBarcodeSyncViewTestController { @Autowired private CusBarcodeSyncViewQueryService cusBarcodeSyncViewQueryService; @GetMapping("/probe") @ApiOperation("取视图前几条样例,验证副库连通") public R probe(@RequestParam(defaultValue = "5") int limit) { Map body = new LinkedHashMap<>(); body.put("effectiveDataSource", cusBarcodeSyncViewQueryService.effectiveDataSourceLabel()); body.put("rows", cusBarcodeSyncViewQueryService.probeSample(limit)); return R.ok().add(body); } @GetMapping("/byCodes") @ApiOperation("按 barcode 等值查询(逗号分隔,须与视图 barcode 完全一致)") public R byCodes(@RequestParam String codes) { if (StringUtils.isBlank(codes)) { return R.error("codes 不能为空,示例:/test/cusBarcodeSyncView/byCodes?codes=0508#20250610#002"); } List list = Arrays.stream(codes.split(",")) .map(String::trim) .filter(StringUtils::isNotBlank) .collect(Collectors.toList()); if (list.isEmpty()) { return R.error("codes 解析后为空"); } Map body = new LinkedHashMap<>(); body.put("effectiveDataSource", cusBarcodeSyncViewQueryService.effectiveDataSourceLabel()); body.put("rows", cusBarcodeSyncViewQueryService.listByItemNos(list)); return R.ok().add(body); } }