xyc
2 小时以前 5b41c8896ef7850be2672e45b69bb58e149729ec
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
package com.trafficaudit.ledgeraudit.controller;
 
import com.trafficaudit.common.Result;
import com.trafficaudit.ledgeraudit.dto.LedgerBatchAuditResponse;
import com.trafficaudit.ledgeraudit.dto.LedgerAuditResponse;
import com.trafficaudit.ledgeraudit.dto.LedgerEnterpriseOption;
import com.trafficaudit.ledgeraudit.service.LedgerAuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.List;
import java.util.Map;
 
@Slf4j
@RestController
@RequestMapping("/api/ledger-audit")
public class LedgerAuditController {
    private final LedgerAuditService service;
 
    public LedgerAuditController(LedgerAuditService service) {
        this.service = service;
    }
 
    @GetMapping("/metadata")
    public Result<Map<String, Object>> metadata() {
        return Result.ok(service.metadata());
    }
 
    @GetMapping("/enterprises")
    public Result<List<LedgerEnterpriseOption>> enterprises(@RequestParam("city") String city,
                                                           @RequestParam("period") String period) {
        try {
            return Result.ok(service.enterprises(city, period));
        } catch (Exception e) {
            log.error("ledger audit enterprise query failed", e);
            return Result.error("\u4f01\u4e1a\u5217\u8868\u67e5\u8be2\u5931\u8d25: " + e.getMessage());
        }
    }
 
    @PostMapping("/batch-check")
    public Result<LedgerBatchAuditResponse> batchCheck(
                                                      @RequestParam("period") String period,
                                                      @RequestParam("files") List<MultipartFile> files) {
        try {
            return Result.ok(service.checkBatch(period, files));
        } catch (Exception e) {
            log.error("ledger batch audit failed", e);
            return Result.error("\u6279\u91cf\u53f0\u8d26\u6838\u67e5\u5931\u8d25: " + e.getMessage());
        }
    }
 
    @PostMapping("/check")
    public Result<LedgerAuditResponse> check(@RequestParam("city") String city,
                                             @RequestParam("period") String period,
                                             @RequestParam("enterpriseName") String enterpriseName,
                                             @RequestParam("file") MultipartFile file) {
        try {
            return Result.ok(service.check(city, period, enterpriseName, file));
        } catch (Exception e) {
            log.error("ledger audit failed", e);
            return Result.error("\u53f0\u8d26\u6838\u67e5\u5931\u8d25: " + e.getMessage());
        }
    }
}