wlzboy
2026-01-24 2f09efc660bf2cc94cbc5291ad25ca06fc9bdadf
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.ruoyi.web.controller.system;
 
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.enums.BusinessType;
import com.ruoyi.system.domain.VehicleAbnormalAlert;
import com.ruoyi.system.service.IVehicleAbnormalAlertService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
 
/**
 * 车辆异常告警Controller
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/vehicleAlert")
public class VehicleAbnormalAlertController extends BaseController {
    
    @Autowired
    private IVehicleAbnormalAlertService vehicleAbnormalAlertService;
 
    /**
     * 查询车辆异常告警列表
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleAlert:list')")
    @GetMapping("/list")
    public TableDataInfo list(VehicleAbnormalAlert vehicleAbnormalAlert) {
        startPage();
        List<VehicleAbnormalAlert> list = vehicleAbnormalAlertService.selectVehicleAbnormalAlertList(vehicleAbnormalAlert);
        return getDataTable(list);
    }
 
    /**
     * 导出车辆异常告警列表
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleAlert:export')")
    @Log(title = "车辆异常告警", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VehicleAbnormalAlert vehicleAbnormalAlert) {
        List<VehicleAbnormalAlert> list = vehicleAbnormalAlertService.selectVehicleAbnormalAlertList(vehicleAbnormalAlert);
        ExcelUtil<VehicleAbnormalAlert> util = new ExcelUtil<VehicleAbnormalAlert>(VehicleAbnormalAlert.class);
        util.exportExcel(response, list, "车辆异常告警数据");
    }
 
    /**
     * 获取车辆异常告警详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleAlert:query')")
    @GetMapping(value = "/{alertId}")
    public AjaxResult getInfo(@PathVariable("alertId") Long alertId) {
        return success(vehicleAbnormalAlertService.selectVehicleAbnormalAlertByAlertId(alertId));
    }
 
    /**
     * 新增车辆异常告警
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleAlert:add')")
    @Log(title = "车辆异常告警", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VehicleAbnormalAlert vehicleAbnormalAlert) {
        return toAjax(vehicleAbnormalAlertService.insertVehicleAbnormalAlert(vehicleAbnormalAlert));
    }
 
    /**
     * 修改车辆异常告警
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleAlert:edit')")
    @Log(title = "车辆异常告警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VehicleAbnormalAlert vehicleAbnormalAlert) {
        return toAjax(vehicleAbnormalAlertService.updateVehicleAbnormalAlert(vehicleAbnormalAlert));
    }
 
    /**
     * 删除车辆异常告警
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleAlert:remove')")
    @Log(title = "车辆异常告警", businessType = BusinessType.DELETE)
    @DeleteMapping("/{alertIds}")
    public AjaxResult remove(@PathVariable Long[] alertIds) {
        return toAjax(vehicleAbnormalAlertService.deleteVehicleAbnormalAlertByAlertIds(alertIds));
    }
 
    /**
     * 处理告警
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleAlert:handle')")
    @Log(title = "处理车辆告警", businessType = BusinessType.UPDATE)
    @PutMapping("/handle/{alertId}")
    public AjaxResult handleAlert(@PathVariable Long alertId, @RequestBody VehicleAbnormalAlert vehicleAbnormalAlert) {
        Long handlerId = getUserId();
        String handlerName = getUsername();
        String handleRemark = vehicleAbnormalAlert.getHandleRemark();
        
        return toAjax(vehicleAbnormalAlertService.handleAlert(alertId, handlerId, handlerName, handleRemark));
    }
 
    /**
     * 批量处理告警
     */
    @PreAuthorize("@ss.hasPermi('system:vehicleAlert:handle')")
    @Log(title = "批量处理车辆告警", businessType = BusinessType.UPDATE)
    @PutMapping("/batchHandle")
    public AjaxResult batchHandleAlert(@RequestBody VehicleAbnormalAlert vehicleAbnormalAlert) {
        Long[] alertIds = vehicleAbnormalAlert.getAlertId() != null ? 
                new Long[]{vehicleAbnormalAlert.getAlertId()} : new Long[0];
        Long handlerId = getUserId();
        String handlerName = getUsername();
        String handleRemark = vehicleAbnormalAlert.getHandleRemark();
        
        return toAjax(vehicleAbnormalAlertService.batchHandleAlert(alertIds, handlerId, handlerName, handleRemark));
    }
 
    /**
     * 获取未处理告警数量
     */
    @GetMapping("/unhandledCount")
    public AjaxResult getUnhandledCount() {
        VehicleAbnormalAlert query = new VehicleAbnormalAlert();
        query.setStatus("0"); // 未处理
        List<VehicleAbnormalAlert> list = vehicleAbnormalAlertService.selectVehicleAbnormalAlertList(query);
        return success(list.size());
    }
 
    /**
     * 获取今日告警数量
     */
    @GetMapping("/todayCount")
    public AjaxResult getTodayCount() {
        VehicleAbnormalAlert query = new VehicleAbnormalAlert();
        query.setAlertDate(new java.util.Date());
        List<VehicleAbnormalAlert> list = vehicleAbnormalAlertService.selectVehicleAbnormalAlertList(query);
        return success(list.size());
    }
}