xyc
昨天 54e10aee11aa4a10926df02782ca07d41eeb9b98
traffic-audit-server/src/main/java/com/trafficaudit/holiday/controller/HolidayStatController.java
@@ -2,6 +2,7 @@
import com.trafficaudit.common.Result;
import com.trafficaudit.holiday.service.HolidayBulletinService;
import com.trafficaudit.holiday.service.HolidayTrendService;
import com.trafficaudit.holiday.service.HolidayStatService;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@@ -26,6 +27,9 @@
    private HolidayStatService statService;
    @Resource
    private HolidayBulletinService bulletinService;
    @Resource
    private HolidayTrendService trendService;
    @GetMapping("/overview")
    public Result<Map<String, Object>> overview(@RequestParam("year") int year,
@@ -74,6 +78,18 @@
                .body(data);
    }
    @GetMapping("/trend")
    public ResponseEntity<byte[]> trend(@RequestParam("year") int year,
                                        @RequestParam("holidayType") String holidayType) throws Exception {
        byte[] data = trendService.generate(year, holidayType);
        String fileName = year + "年" + holidayTypeFileLabel(holidayType) + "假期全省综合运输客流量走势图.docx";
        String encoded = URLEncoder.encode(fileName, "UTF-8").replace("+", "%20");
        return ResponseEntity.ok()
                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encoded)
                .contentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"))
                .body(data);
    }
    private String holidayTypeFileLabel(String holidayType) {
        if ("SPRING_FESTIVAL".equals(holidayType)) return "春节";
        if ("LABOR_DAY".equals(holidayType)) return "五一";