| | |
| | | |
| | | 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; |
| | |
| | | private HolidayStatService statService; |
| | | @Resource |
| | | private HolidayBulletinService bulletinService; |
| | | |
| | | @Resource |
| | | private HolidayTrendService trendService; |
| | | |
| | | @GetMapping("/overview") |
| | | public Result<Map<String, Object>> overview(@RequestParam("year") int year, |
| | |
| | | .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 "五一"; |