xyc
2026-08-14 1f4a6cc6045f47861c3e8d49a782afc3e11e3843
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.trafficaudit.dataimport.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.trafficaudit.common.Result;
import com.trafficaudit.dataimport.entity.H2032EnterpriseMonthly;
import com.trafficaudit.dataimport.mapper.H2032EnterpriseMonthlyMapper;
import lombok.extern.slf4j.Slf4j;
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 javax.annotation.Resource;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 企业解释:独立于审核结果的解释列表与 AI 分析入口
 */
@Slf4j
@RestController
@RequestMapping("/api/explain")
public class ExplainController {
 
    @Resource
    private H2032EnterpriseMonthlyMapper h2032Mapper;
 
    @GetMapping("/list")
    public Result<Map<String, Object>> list(@RequestParam(value = "period", required = false) String period,
                                            @RequestParam(value = "keyword", required = false) String keyword,
                                            @RequestParam(value = "page", defaultValue = "1") long page,
                                            @RequestParam(value = "size", defaultValue = "20") long size) {
        String kw = keyword == null ? "" : keyword.trim();
        boolean hasPeriod = period != null && !period.trim().isEmpty();
 
        LambdaQueryWrapper<H2032EnterpriseMonthly> w = new LambdaQueryWrapper<H2032EnterpriseMonthly>()
            .eq(hasPeriod, H2032EnterpriseMonthly::getReportPeriod, period)
            .isNotNull(H2032EnterpriseMonthly::getVerifyExplanation)
            .ne(H2032EnterpriseMonthly::getVerifyExplanation, "")
            .like(!kw.isEmpty(), H2032EnterpriseMonthly::getEnterpriseName, kw)
            .orderByDesc(H2032EnterpriseMonthly::getId);
 
        Page<H2032EnterpriseMonthly> p = new Page<>(Math.max(page, 1), Math.min(Math.max(size, 1), 200));
        Page<H2032EnterpriseMonthly> r = h2032Mapper.selectPage(p, w);
 
        List<Map<String, Object>> records = new ArrayList<>();
        for (H2032EnterpriseMonthly e : r.getRecords()) {
            Map<String, Object> row = new LinkedHashMap<>();
            row.put("id", e.getId());
            row.put("reportPeriod", e.getReportPeriod());
            row.put("regionCode", e.getRegionCode());
            row.put("enterpriseCode", e.getEnterpriseCode());
            row.put("enterpriseName", e.getEnterpriseName());
            row.put("vehicleTotal", e.getVehicleTotal());
            row.put("tonsTotal", e.getTonsTotal());
            row.put("freightTotal", e.getFreightTotal());
            row.put("turnoverTotal", e.getTurnoverTotal());
            row.put("avgDistance", e.getAvgDistance());
            row.put("verifyExplanation", e.getVerifyExplanation());
            records.add(row);
        }
 
        Map<String, Object> result = new LinkedHashMap<>();
        result.put("records", records);
        result.put("total", r.getTotal());
        result.put("current", r.getCurrent());
        result.put("size", r.getSize());
        return Result.ok(result);
    }
}