| | |
| | | import com.trafficaudit.auditengine.entity.AuditResult; |
| | | import com.trafficaudit.auditengine.service.AuditEngineService; |
| | | import com.trafficaudit.common.Result; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | private AuditEngineService auditService; |
| | | |
| | | @PostMapping("/execute") |
| | | public Result<List<AuditResult>> executeAudit(@RequestParam("period") String period) { |
| | | List<AuditResult> results = auditService.executeAudit(period); |
| | | public Result<List<AuditResult>> executeAudit(@RequestParam("period") String period, |
| | | @RequestParam(value = "reportType", defaultValue = "H2032") String reportType) { |
| | | List<AuditResult> results; |
| | | if ("H2031".equals(reportType)) { |
| | | results = auditService.executePassengerAudit(period); |
| | | } else if ("H204".equals(reportType)) { |
| | | results = auditService.executeEnergyAudit(period); |
| | | } else if ("INVEST".equals(reportType)) { |
| | | results = auditService.executeInvestmentAudit(period); |
| | | } else if ("CITY_BUS".equals(reportType)) { |
| | | results = auditService.executeCityBusAudit(period); |
| | | } else if ("CITY_TAXI".equals(reportType)) { |
| | | results = auditService.executeCityTaxiAudit(period); |
| | | } else { |
| | | results = auditService.executeAudit(period); |
| | | } |
| | | return Result.ok(results); |
| | | } |
| | | |
| | | /** 标记该报表期+类型为「已审核」(线下审核通过的数据;先审核再出表的依据,导出前不再提示未审核) */ |
| | | @PostMapping("/markAudited") |
| | | public Result<Boolean> markAudited(@RequestParam("period") String period, |
| | | @RequestParam("reportType") String reportType) { |
| | | return Result.ok(auditService.markAudited(reportType, period)); |
| | | } |
| | | |
| | | @GetMapping("/ruleStats") |
| | | public Result<java.util.List<java.util.Map<String, Object>>> ruleStats(@RequestParam("period") String period, |
| | | @RequestParam(value = "reportType", defaultValue = "H2032") String reportType) { |
| | | return Result.ok(auditService.ruleStats(period, reportType)); |
| | | } |
| | | |
| | | @GetMapping("/latestPeriod") |
| | | public Result<String> latestPeriod(@RequestParam(value = "reportType", defaultValue = "H2032") String reportType) { |
| | | return Result.ok(auditService.latestPeriod(reportType)); |
| | | } |
| | | |
| | | @GetMapping("/export") |
| | | public ResponseEntity<byte[]> exportResults(@RequestParam("period") String period, |
| | | @RequestParam(value = "reportType", defaultValue = "H2032") String reportType) throws Exception { |
| | | byte[] bytes = auditService.exportResults(period, reportType); |
| | | String name = java.net.URLEncoder.encode("审核结果_" + period + ".xlsx", "UTF-8"); |
| | | return ResponseEntity.ok() |
| | | .header("Content-Disposition", "attachment; filename*=UTF-8''" + name) |
| | | .contentType(org.springframework.http.MediaType.APPLICATION_OCTET_STREAM) |
| | | .body(bytes); |
| | | } |
| | | |
| | | @GetMapping("/results") |
| | | public Result<List<AuditResult>> getResults(@RequestParam("period") String period) { |
| | | List<AuditResult> results = auditService.queryResults(period); |
| | | public Result<List<AuditResult>> getResults(@RequestParam("period") String period, |
| | | @RequestParam(value = "reportType", defaultValue = "H2032") String reportType) { |
| | | List<AuditResult> results = auditService.queryResults(period, reportType); |
| | | return Result.ok(results); |
| | | } |
| | | |