From 37f52097847f9025589c79034be2454432c55433 Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期五, 02 十月 2026 10:12:27 +0800
Subject: [PATCH] docs(交接): 记录关机前开发服务已停止
---
traffic-audit-server/src/main/java/com/trafficaudit/holiday/controller/HolidayStatController.java | 82 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/traffic-audit-server/src/main/java/com/trafficaudit/holiday/controller/HolidayStatController.java b/traffic-audit-server/src/main/java/com/trafficaudit/holiday/controller/HolidayStatController.java
new file mode 100644
index 0000000..d6265b2
--- /dev/null
+++ b/traffic-audit-server/src/main/java/com/trafficaudit/holiday/controller/HolidayStatController.java
@@ -0,0 +1,82 @@
+package com.trafficaudit.holiday.controller;
+
+import com.trafficaudit.common.Result;
+import com.trafficaudit.holiday.service.HolidayBulletinService;
+import com.trafficaudit.holiday.service.HolidayStatService;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+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 javax.annotation.Resource;
+import java.net.URLEncoder;
+import java.time.LocalDate;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/holiday")
+public class HolidayStatController {
+
+ @Resource
+ private HolidayStatService statService;
+ @Resource
+ private HolidayBulletinService bulletinService;
+
+ @GetMapping("/overview")
+ public Result<Map<String, Object>> overview(@RequestParam("year") int year,
+ @RequestParam("holidayType") String holidayType) {
+ try {
+ return Result.ok(statService.overview(year, holidayType));
+ } catch (Exception e) {
+ return Result.error(400, e.getMessage());
+ }
+ }
+
+ @PostMapping("/import")
+ public Result<Map<String, Object>> importWorkbook(@RequestParam(value = "file", required = false) MultipartFile file,
+ @RequestParam("year") int year,
+ @RequestParam("holidayType") String holidayType,
+ @RequestParam(value = "allowHistoricalOverwrite", defaultValue = "false") boolean allowHistoricalOverwrite) {
+ try {
+ return Result.ok(statService.importWorkbook(file, year, holidayType, allowHistoricalOverwrite));
+ } catch (Exception e) {
+ return Result.error(400, e.getMessage());
+ }
+ }
+
+ @GetMapping("/export")
+ public ResponseEntity<byte[]> exportWorkbook(@RequestParam("year") int year,
+ @RequestParam("holidayType") String holidayType) throws Exception {
+ byte[] data = statService.exportWorkbook(year, holidayType);
+ String fileName = year + "骞�" + holidayTypeFileLabel(holidayType) + "鏁版嵁.xlsx";
+ 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.spreadsheetml.sheet"))
+ .body(data);
+ }
+
+ @GetMapping("/bulletin")
+ public ResponseEntity<byte[]> bulletin(@RequestParam(value = "date", required = false) String date) throws Exception {
+ LocalDate targetDate = (date == null || date.trim().isEmpty())
+ ? LocalDate.now().minusDays(1) : LocalDate.parse(date);
+ byte[] data = bulletinService.generate(targetDate);
+ String fileName = String.format("婀栧寳鐪佸浗搴嗗亣鏈熺患鍚堣繍杈撳娴佸揩鎶ワ紙10鏈�%d鏃ワ級.docx", targetDate.getDayOfMonth());
+ 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 "浜斾竴";
+ return "鍗佷竴";
+ }
+}
--
Gitblit v1.9.1