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);
|
}
|
}
|