From caf56217dc2bf898b63b0e1f31a7098202c32825 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期六, 15 十一月 2025 16:50:17 +0800
Subject: [PATCH] Merge branch 'feature_gps'

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleMileageStatsController.java |  135 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 135 insertions(+), 0 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleMileageStatsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleMileageStatsController.java
index e69de29..2383778 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleMileageStatsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/VehicleMileageStatsController.java
@@ -0,0 +1,135 @@
+package com.ruoyi.web.controller.system;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.system.domain.VehicleMileageStats;
+import com.ruoyi.system.service.IVehicleMileageStatsService;
+
+/**
+ * 杞﹁締閲岀▼缁熻Controller
+ */
+@RestController
+@RequestMapping("/system/mileageStats")
+public class VehicleMileageStatsController extends BaseController {
+    
+    @Autowired
+    private IVehicleMileageStatsService vehicleMileageStatsService;
+
+    /**
+     * 鏌ヨ杞﹁締閲岀▼缁熻鍒楄〃
+     */
+    @PreAuthorize("@ss.hasPermi('system:mileageStats:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(VehicleMileageStats vehicleMileageStats) {
+        startPage();
+        List<VehicleMileageStats> list = vehicleMileageStatsService.selectVehicleMileageStatsList(vehicleMileageStats);
+        return getDataTable(list);
+    }
+
+    /**
+     * 瀵煎嚭杞﹁締閲岀▼缁熻鍒楄〃
+     */
+    @PreAuthorize("@ss.hasPermi('system:mileageStats:export')")
+    @Log(title = "杞﹁締閲岀▼缁熻", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, VehicleMileageStats vehicleMileageStats) {
+        List<VehicleMileageStats> list = vehicleMileageStatsService.selectVehicleMileageStatsList(vehicleMileageStats);
+        ExcelUtil<VehicleMileageStats> util = new ExcelUtil<VehicleMileageStats>(VehicleMileageStats.class);
+        util.exportExcel(response, list, "杞﹁締閲岀▼缁熻鏁版嵁");
+    }
+
+    /**
+     * 鑾峰彇杞﹁締閲岀▼缁熻璇︾粏淇℃伅
+     */
+    @PreAuthorize("@ss.hasPermi('system:mileageStats:query')")
+    @GetMapping(value = "/{statsId}")
+    public AjaxResult getInfo(@PathVariable("statsId") Long statsId) {
+        return success(vehicleMileageStatsService.selectVehicleMileageStatsById(statsId));
+    }
+
+    /**
+     * 鏂板杞﹁締閲岀▼缁熻
+     */
+    @PreAuthorize("@ss.hasPermi('system:mileageStats:add')")
+    @Log(title = "杞﹁締閲岀▼缁熻", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody VehicleMileageStats vehicleMileageStats) {
+        return toAjax(vehicleMileageStatsService.insertVehicleMileageStats(vehicleMileageStats));
+    }
+
+    /**
+     * 淇敼杞﹁締閲岀▼缁熻
+     */
+    @PreAuthorize("@ss.hasPermi('system:mileageStats:edit')")
+    @Log(title = "杞﹁締閲岀▼缁熻", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody VehicleMileageStats vehicleMileageStats) {
+        return toAjax(vehicleMileageStatsService.updateVehicleMileageStats(vehicleMileageStats));
+    }
+
+    /**
+     * 鍒犻櫎杞﹁締閲岀▼缁熻
+     */
+    @PreAuthorize("@ss.hasPermi('system:mileageStats:remove')")
+    @Log(title = "杞﹁締閲岀▼缁熻", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{statsIds}")
+    public AjaxResult remove(@PathVariable Long[] statsIds) {
+        return toAjax(vehicleMileageStatsService.deleteVehicleMileageStatsByIds(statsIds));
+    }
+
+    /**
+     * 鎵嬪姩瑙﹀彂璁$畻鎸囧畾杞﹁締鎸囧畾鏃ユ湡鐨勯噷绋嬬粺璁�
+     */
+    @PreAuthorize("@ss.hasPermi('system:mileageStats:calculate')")
+    @Log(title = "杞﹁締閲岀▼缁熻", businessType = BusinessType.OTHER)
+    @PostMapping("/calculate")
+    public AjaxResult calculate(Long vehicleId, String statDate) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            Date date = sdf.parse(statDate);
+            VehicleMileageStats stats = vehicleMileageStatsService.calculateAndSaveMileageStats(vehicleId, date);
+            if (stats != null) {
+                return success("閲岀▼缁熻璁$畻鎴愬姛", stats);
+            } else {
+                return error("璇ヨ溅杈嗗湪鎸囧畾鏃ユ湡鏃燝PS鏁版嵁");
+            }
+        } catch (Exception e) {
+            return error("閲岀▼缁熻璁$畻澶辫触锛�" + e.getMessage());
+        }
+    }
+
+    /**
+     * 鎵归噺璁$畻鎸囧畾鏃ユ湡鎵�鏈夎溅杈嗙殑閲岀▼缁熻
+     */
+    @PreAuthorize("@ss.hasPermi('system:mileageStats:batch')")
+    @Log(title = "杞﹁締閲岀▼缁熻", businessType = BusinessType.OTHER)
+    @PostMapping("/batchCalculate")
+    public AjaxResult batchCalculate(String statDate) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            Date date = sdf.parse(statDate);
+            int count = vehicleMileageStatsService.batchCalculateMileageStats(date);
+            return success("鎵归噺閲岀▼缁熻瀹屾垚锛屾垚鍔熺粺璁� " + count + " 杈嗚溅");
+        } catch (Exception e) {
+            return error("鎵归噺閲岀▼缁熻澶辫触锛�" + e.getMessage());
+        }
+    }
+}

--
Gitblit v1.9.1