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 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 list = vehicleAbnormalAlertService.selectVehicleAbnormalAlertList(vehicleAbnormalAlert); ExcelUtil util = new ExcelUtil(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 list = vehicleAbnormalAlertService.selectVehicleAbnormalAlertList(query); return success(list.size()); } /** * 获取今日告警数量 */ @GetMapping("/todayCount") public AjaxResult getTodayCount() { VehicleAbnormalAlert query = new VehicleAbnormalAlert(); query.setAlertDate(new java.util.Date()); List list = vehicleAbnormalAlertService.selectVehicleAbnormalAlertList(query); return success(list.size()); } }