package com.zc.business.controller; import com.ruoyi.common.utils.uuid.IdUtils; import com.zc.business.service.IDcWarningService; 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.zc.business.domain.DcWarning; 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 javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; /** * 预警信息Controller * * @author ruoyi * @date 2024-01-26 */ @RestController @RequestMapping("/business/warning") public class DcWarningController extends BaseController { @Autowired private IDcWarningService dcWarningService; /** * 查询预警信息列表 */ @PreAuthorize("@ss.hasPermi('business:warning:list')") @GetMapping("/list") public TableDataInfo list(DcWarning dcWarning) { startPage(); List> list = dcWarningService.selectDcWarningList(dcWarning); return getDataTable(list); } /** * 导出预警信息列表 */ @PreAuthorize("@ss.hasPermi('business:warning:export')") @Log(title = "预警信息", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, DcWarning dcWarning) { List list = dcWarningService.export(dcWarning); ExcelUtil util = new ExcelUtil<>(DcWarning.class); util.exportExcel(response, list, "预警信息数据"); } /** * 获取预警信息详细信息 */ @PreAuthorize("@ss.hasPermi('business:warning:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Integer id) { return AjaxResult.success(dcWarningService.selectDcWarningById(id)); } /** * 新增预警信息 */ @PreAuthorize("@ss.hasPermi('business:warning:add')") @Log(title = "预警信息", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody DcWarning dcWarning) { //设置事件Id UUID无下划线格式32 String uuid = IdUtils.fastSimpleUUID(); dcWarning.setId(uuid); return toAjax(dcWarningService.insertDcWarning(dcWarning)); } /** * 修改预警信息 */ @PreAuthorize("@ss.hasPermi('business:warning:edit')") @Log(title = "预警信息", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody DcWarning dcWarning) { return toAjax(dcWarningService.updateDcWarning(dcWarning)); } /** * 删除预警信息 */ @PreAuthorize("@ss.hasPermi('business:warning:remove')") @Log(title = "预警信息", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Integer[] ids) { return toAjax(dcWarningService.deleteDcWarningByIds(ids)); } //感知事件转交通事件 @PostMapping("/updateWarningConvert") public AjaxResult updateWarningConvert(@RequestBody DcWarning dcWarning) { return dcWarningService.updateWarningConvert(dcWarning); } }