测试用例

This commit is contained in:
lvys 2025-03-21 11:12:33 +08:00
parent 7d20057de0
commit b0bae5715e
6 changed files with 759 additions and 0 deletions

View File

@ -0,0 +1,221 @@
package com.dkl.large.controller;
import com.dkl.common.core.domain.AjaxResult;
import com.dkl.common.core.page.TableDataInfo;
import com.dkl.large.domain.DklWarningInformation;
import com.dkl.large.service.IDklWarningInformationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
/**
* 预警信息Controller单元测试
* 遵循 JUnit 5 + Mockito 统一风格覆盖所有核心接口与关键业务逻辑
*
* @author Dkl
* @date 2025-06-16
*/
@ExtendWith(MockitoExtension.class)
public class DklWarningInformationControllerTest {
// 待测试的Controller自动注入Mock的Service依赖解耦真实业务层
@InjectMocks
private DklWarningInformationController warningInformationController;
// 模拟Controller依赖的Service层避免依赖真实数据库保证测试独立性
@Mock
private IDklWarningInformationService warningInformationService;
// 模拟HTTP响应对象用于Excel导出接口
private MockHttpServletResponse mockResponse;
// 测试核心实体数据预警信息
private DklWarningInformation testWarning;
// 测试实体列表数据
private List<DklWarningInformation> testWarningList;
/**
* 每个测试方法执行前初始化数据保证测试用例独立性避免相互干扰
*/
@BeforeEach
void setUp() {
// 1. 初始化模拟HTTP响应
mockResponse = new MockHttpServletResponse();
// 2. 初始化单个预警信息实体
testWarning = new DklWarningInformation();
testWarning.setId(1L);
testWarning.setDelFlag("0");
testWarning.setCreateTime(new Date());
testWarning.setCreateBy("admin");
testWarning.setDeptId(100L);
testWarning.setUpdateTime(new Date());
testWarning.setUpdateBy("admin");
testWarning.setEventStatus("1"); // 默认待分配
// 3. 初始化预警信息列表
testWarningList = new ArrayList<>();
testWarningList.add(testWarning);
// 4. 模拟Security上下文解决getUsername()/getDeptId()等方法依赖满足@PreAuthorize注解校验
Authentication authentication = mock(Authentication.class);
SecurityContextHolder.getContext().setAuthentication(authentication);
doReturn("admin").when(authentication).getName();
}
// ---------------------- 测试场景 1查询预警信息列表list 接口带数据权限 ----------------------
@Test
void testList() {
// 步骤1模拟Service层返回列表数据
when(warningInformationService.selectDklWarningInformationList(any(DklWarningInformation.class)))
.thenReturn(testWarningList);
// 步骤2调用Controller接口执行测试
TableDataInfo result = warningInformationController.list(testWarning);
// 步骤3断言结果验证返回数据有效性
assertNotNull(result, "返回的TableDataInfo不能为null");
assertEquals(1, result.getRows().size(), "返回的列表数据条数应为1");
assertEquals(testWarning.getId(), ((DklWarningInformation) result.getRows().get(0)).getId(), "返回的实体ID应与测试数据一致");
// 步骤4验证Service方法被正确调用确保流程无遗漏
verify(warningInformationService, times(1)).selectDklWarningInformationList(any(DklWarningInformation.class));
}
// ---------------------- 测试场景 2查询全部预警信息列表listAll 接口无数据权限 ----------------------
@Test
void testListAll() {
// 步骤1模拟Service层返回列表数据
when(warningInformationService.selectDklWarningInformationList(any(DklWarningInformation.class)))
.thenReturn(testWarningList);
// 步骤2调用Controller接口执行测试
TableDataInfo result = warningInformationController.listAll(testWarning);
// 步骤3断言结果
assertNotNull(result, "返回的TableDataInfo不能为null");
assertEquals(1, result.getRows().size(), "返回的列表数据条数应为1");
// 步骤4验证Service方法调用
verify(warningInformationService, times(1)).selectDklWarningInformationList(any(DklWarningInformation.class));
}
// ---------------------- 测试场景 3导出预警信息列表export 接口无返回值 ----------------------
@Test
void testExport() {
// 步骤1模拟Service层返回列表数据
when(warningInformationService.selectDklWarningInformationList(any(DklWarningInformation.class)))
.thenReturn(testWarningList);
// 步骤2调用导出接口无返回值验证无异常抛出即可
assertDoesNotThrow(() -> warningInformationController.export(mockResponse, testWarning),
"导出接口执行过程中不应抛出异常");
// 步骤3验证Service方法被调用且HTTP响应状态正常
verify(warningInformationService, times(1)).selectDklWarningInformationList(any(DklWarningInformation.class));
assertEquals(200, mockResponse.getStatus(), "HTTP响应状态码应为200");
assertTrue(mockResponse.getContentType().contains("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
"响应内容应为Excel格式");
}
// ---------------------- 测试场景 4获取预警信息详情getInfo 接口 ----------------------
@Test
void testGetInfo() {
// 步骤1模拟Service层返回单个实体数据
when(warningInformationService.selectDklWarningInformationById(anyLong())).thenReturn(testWarning);
// 步骤2调用Controller接口执行测试
AjaxResult result = warningInformationController.getInfo(1L);
// 步骤3断言结果
assertNotNull(result, "返回的AjaxResult不能为null");
assertTrue(result.isSuccess(), "接口应返回成功状态");
assertEquals(testWarning.getId(), ((DklWarningInformation) result.getData()).getId(), "返回的实体ID应与测试数据一致");
// 步骤4验证Service方法调用
verify(warningInformationService, times(1)).selectDklWarningInformationById(1L);
}
// ---------------------- 测试场景 5新增预警信息add 接口 ----------------------
@Test
void testAdd() {
// 步骤1模拟Service层新增成功返回1表示操作成功
when(warningInformationService.insertDklWarningInformation(any(DklWarningInformation.class))).thenReturn(1);
// 步骤2调用Controller接口执行测试
AjaxResult result = warningInformationController.add(testWarning);
// 步骤3断言结果
assertNotNull(result, "返回的AjaxResult不能为null");
assertTrue(result.isSuccess(), "新增接口应返回成功状态");
assertEquals(1, result.getData(), "新增操作应返回1表示成功");
// 步骤4验证实体系统字段与业务字段被正确设置核心逻辑校验
verify(warningInformationService).insertDklWarningInformation(argThat(warning ->
"0".equals(warning.getDelFlag()) &&
"admin".equals(warning.getCreateBy()) &&
100L.equals(warning.getDeptId()) &&
"1".equals(warning.getEventStatus()) &&
warning.getCreateTime() != null &&
warning.getUpdateTime() != null
));
}
// ---------------------- 测试场景 6修改预警信息edit 接口 ----------------------
@Test
void testEdit() {
// 步骤1模拟Service层修改成功返回1表示操作成功
when(warningInformationService.updateDklWarningInformation(any(DklWarningInformation.class))).thenReturn(1);
// 步骤2调用Controller接口执行测试
AjaxResult result = warningInformationController.edit(testWarning);
// 步骤3断言结果
assertNotNull(result, "返回的AjaxResult不能为null");
assertTrue(result.isSuccess(), "修改接口应返回成功状态");
assertEquals(1, result.getData(), "修改操作应返回1表示成功");
// 步骤4验证实体更新字段被正确设置
verify(warningInformationService).updateDklWarningInformation(argThat(warning ->
"admin".equals(warning.getUpdateBy()) &&
warning.getUpdateTime() != null
));
}
// ---------------------- 测试场景 7删除预警信息remove 接口批量删除 ----------------------
@Test
void testRemove() {
// 步骤1准备批量删除ID数组
int[] ids = {1, 2};
// 步骤2模拟Service层删除成功返回2表示删除2条数据
when(warningInformationService.deleteDklWarningInformationByIds(ids)).thenReturn(2);
// 步骤3调用Controller接口执行测试
AjaxResult result = warningInformationController.remove(ids);
// 步骤4断言结果
assertNotNull(result, "返回的AjaxResult不能为null");
assertTrue(result.isSuccess(), "删除接口应返回成功状态");
assertEquals(2, result.getData(), "删除操作应返回2表示成功删除2条数据");
// 步骤5验证Service方法调用
verify(warningInformationService, times(1)).deleteDklWarningInformationByIds(ids);
}
}

View File

@ -0,0 +1,127 @@
package com.dkl.large.domain;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.dkl.common.annotation.Excel;
import com.dkl.common.core.domain.BaseEntity;
/**
* 预警信息对象 dkl_warning_information
*
* @author Dkl
* @date 2025-06-16
*/
@Data
public class DklWarningInformation extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private int id;
/** 预警唯一标识符 */
@Excel(name = "预警唯一标识符")
private String warningSigns;
/** 发布单位名称 */
@Excel(name = "发布单位名称")
private String unitName;
/** 发布单位编码 */
@Excel(name = "发布单位编码=>触发点位")
private Long unitCode;
/** 发布时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date releaseTime;
/** 预警状态 */
@Excel(name = "预警状态")
private String warningStatus;
/** 预警类型 */
@Excel(name = "预警类型")
private String warningType;
/** 事件类别 */
@Excel(name = "事件类别")
private String eventCategory;
/** 预警级别 */
@Excel(name = "预警级别")
private String warningLevel;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/** 预计持续时间 */
@Excel(name = "预计持续时间")
private String expectedDuration;
/** 可能波及范围 */
@Excel(name = "可能波及范围")
private String scopeImpact;
/** 部门id*/
@Excel(name = "部门id")
private Long deptId;
/** 异常数据值 */
@Excel(name = "异常数据值")
private String abnormalData;
/** 是否督办 */
@Excel(name = "是否督办")
private String isSupervise;
/** 经度 */
@Excel(name = "经度")
private String lng;
/** 纬度 */
@Excel(name = "纬度")
private String lat;
/** 规则id */
@Excel(name = "规则id")
private int rulesId;
/** 事件状态 */
@Excel(name = "事件状态")
private String eventStatus;
/** 开始时间 */
@TableField(exist = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/** 结束时间 */
@TableField(exist = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/** 监控点id */
private Long pointsId;
/** 监控点摄像id */
private Long cameraId;
/** 监控点名称 */
@TableField(exist = false)
private String pointName;
/** 监控点摄像名称 */
@TableField(exist = false)
private String cameraName;
/** 监控点摄像地址 */
@TableField(exist = false)
private String filePath;
}

View File

@ -0,0 +1,61 @@
package com.dkl.large.mapper;
import java.util.List;
import com.dkl.large.domain.DklWarningInformation;
/**
* 预警信息Mapper接口
*
* @author Dkl
* @date 2025-06-16
*/
public interface DklWarningInformationMapper
{
/**
* 查询预警信息
*
* @param id 预警信息主键
* @return 预警信息
*/
public DklWarningInformation selectDklWarningInformationById(Long id);
/**
* 查询预警信息列表
*
* @param dklWarningInformation 预警信息
* @return 预警信息集合
*/
public List<DklWarningInformation> selectDklWarningInformationList(DklWarningInformation dklWarningInformation);
public List<DklWarningInformation> selectDklWarningInformationLists(DklWarningInformation dklWarningInformation);
/**
* 新增预警信息
*
* @param dklWarningInformation 预警信息
* @return 结果
*/
public int insertDklWarningInformation(DklWarningInformation dklWarningInformation);
/**
* 修改预警信息
*
* @param dklWarningInformation 预警信息
* @return 结果
*/
public int updateDklWarningInformation(DklWarningInformation dklWarningInformation);
/**
* 删除预警信息
*
* @param id 预警信息主键
* @return 结果
*/
public int deleteDklWarningInformationById(int id);
/**
* 批量删除预警信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDklWarningInformationByIds(int[] ids);
}

View File

@ -0,0 +1,61 @@
package com.dkl.large.service;
import java.util.List;
import com.dkl.large.domain.DklWarningInformation;
/**
* 预警信息Service接口
*
* @author Dkl
* @date 2025-06-16
*/
public interface IDklWarningInformationService
{
/**
* 查询预警信息
*
* @param id 预警信息主键
* @return 预警信息
*/
public DklWarningInformation selectDklWarningInformationById(Long id);
/**
* 查询预警信息列表
*
* @param dklWarningInformation 预警信息
* @return 预警信息集合
*/
public List<DklWarningInformation> selectDklWarningInformationList(DklWarningInformation dklWarningInformation);
public List<DklWarningInformation> selectDklWarningInformationLists(DklWarningInformation dklWarningInformation);
/**
* 新增预警信息
*
* @param dklWarningInformation 预警信息
* @return 结果
*/
public int insertDklWarningInformation(DklWarningInformation dklWarningInformation);
/**
* 修改预警信息
*
* @param dklWarningInformation 预警信息
* @return 结果
*/
public int updateDklWarningInformation(DklWarningInformation dklWarningInformation);
/**
* 批量删除预警信息
*
* @param ids 需要删除的预警信息主键集合
* @return 结果
*/
public int deleteDklWarningInformationByIds(int[] ids);
/**
* 删除预警信息信息
*
* @param id 预警信息主键
* @return 结果
*/
public int deleteDklWarningInformationById(int id);
}

View File

@ -0,0 +1,99 @@
package com.dkl.large.service.impl;
import java.util.List;
import com.dkl.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dkl.large.mapper.DklWarningInformationMapper;
import com.dkl.large.domain.DklWarningInformation;
import com.dkl.large.service.IDklWarningInformationService;
/**
* 预警信息Service业务层处理
*
* @author Dkl
* @date 2025-06-16
*/
@Service
public class DklWarningInformationServiceImpl implements IDklWarningInformationService
{
@Autowired
private DklWarningInformationMapper dklWarningInformationMapper;
/**
* 查询预警信息
*
* @param id 预警信息主键
* @return 预警信息
*/
@Override
public DklWarningInformation selectDklWarningInformationById(Long id)
{
return dklWarningInformationMapper.selectDklWarningInformationById(id);
}
/**
* 查询预警信息列表
*
* @param dklWarningInformation 预警信息
* @return 预警信息
*/
@Override
public List<DklWarningInformation> selectDklWarningInformationList(DklWarningInformation dklWarningInformation)
{
return dklWarningInformationMapper.selectDklWarningInformationList(dklWarningInformation);
}
@Override
public List<DklWarningInformation> selectDklWarningInformationLists(DklWarningInformation dklWarningInformation)
{
return dklWarningInformationMapper.selectDklWarningInformationLists(dklWarningInformation);
} /**
* 新增预警信息
*
* @param dklWarningInformation 预警信息
* @return 结果
*/
@Override
public int insertDklWarningInformation(DklWarningInformation dklWarningInformation)
{
dklWarningInformation.setCreateTime(DateUtils.getNowDate());
return dklWarningInformationMapper.insertDklWarningInformation(dklWarningInformation);
}
/**
* 修改预警信息
*
* @param dklWarningInformation 预警信息
* @return 结果
*/
@Override
public int updateDklWarningInformation(DklWarningInformation dklWarningInformation)
{
dklWarningInformation.setUpdateTime(DateUtils.getNowDate());
return dklWarningInformationMapper.updateDklWarningInformation(dklWarningInformation);
}
/**
* 批量删除预警信息
*
* @param ids 需要删除的预警信息主键
* @return 结果
*/
@Override
public int deleteDklWarningInformationByIds(int[] ids)
{
return dklWarningInformationMapper.deleteDklWarningInformationByIds(ids);
}
/**
* 删除预警信息信息
*
* @param id 预警信息主键
* @return 结果
*/
@Override
public int deleteDklWarningInformationById(int id)
{
return dklWarningInformationMapper.deleteDklWarningInformationById(id);
}
}

View File

@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dkl.large.mapper.DklWarningInformationMapper">
<resultMap type="DklWarningInformation" id="DklWarningInformationResult">
<result property="id" column="id" />
<result property="warningSigns" column="warning_signs" />
<result property="unitName" column="unit_name" />
<result property="unitCode" column="unit_code" />
<result property="releaseTime" column="release_time" />
<result property="warningStatus" column="warning_status" />
<result property="warningType" column="warning_type" />
<result property="eventCategory" column="event_category" />
<result property="warningLevel" column="warning_level" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
<result property="expectedDuration" column="expected_duration" />
<result property="scopeImpact" column="scope_impact" />
<result property="deptId" column="dept_id" />
<result property="abnormalData" column="abnormal_data" />
<result property="isSupervise" column="is_supervise" />
<result property="rulesId" column="rules_id" />
<result property="eventStatus" column="event_status" />
<result property="pointsId" column="points_id" />
</resultMap>
<sql id="selectDklWarningInformationVo">
select dwi.id, dwi.warning_signs, dwi.unit_name, dwi.unit_code, dwi.release_time, dwi.warning_status,
dwi.warning_type, dwi.event_category, dwi.warning_level, dwi.create_by, dwi.create_time, dwi.update_by,
dwi.update_time, dwi.del_flag, dwi.expected_duration, dwi.scope_impact, dwi.dept_id, dwi.abnormal_data,
dwi.is_supervise, dwi.lng, dwi.lat,dwi.rules_id,dwi.event_status,dwi.points_id,dwi.camera_id,dmp.point_name as pointName,dmc.name as cameraName,dmc.file_path as filePath from dkl_warning_information AS dwi
left join sys_dept d on dwi.dept_id = d.dept_id
left join dkl_monitoring_points dmp on dmp.id = dwi.points_id
left join dkl_monitoring_camera dmc on dmc.id = dwi.camera_id
</sql>
<select id="selectDklWarningInformationList" parameterType="DklWarningInformation" resultMap="DklWarningInformationResult">
<include refid="selectDklWarningInformationVo"/>
<where>
<if test="warningSigns != null and warningSigns != ''"> and dwi.warning_signs like concat('%', #{warningSigns}, '%') </if>
<if test="unitName != null and unitName != ''"> and dwi.unit_name like concat('%', #{unitName}, '%')</if>
<if test="unitCode != null and unitCode != ''"> and dwi.unit_code = #{unitCode}</if>
<if test="releaseTime != null "> and dwi.release_time = #{releaseTime}</if>
<if test="warningStatus != null and warningStatus != ''"> and dwi.warning_status = #{warningStatus}</if>
<if test="warningType != null and warningType != ''"> and dwi.warning_type = #{warningType}</if>
<if test="eventCategory != null and eventCategory != ''"> and dwi.event_category = #{eventCategory}</if>
<if test="warningLevel != null and warningLevel != ''"> and dwi.warning_level = #{warningLevel}</if>
<if test="expectedDuration != null and expectedDuration != ''"> and dwi.expected_duration = #{expectedDuration}</if>
<if test="scopeImpact != null "> and dwi.scope_impact = #{scopeImpact}</if>
<if test="deptId != null "> and dwi.dept_id = #{deptId}</if>
<if test="abnormalData != null and abnormalData != ''"> and dwi.abnormal_data = #{abnormalData}</if>
<if test="delFlag != null and delFlag != ''"> and dwi.del_flag = #{delFlag}</if>
<if test="startTime != null and endTime != null ">
AND dwi.create_time BETWEEN #{startTime} and #{endTime}
</if>
</where>
${params.dataScope}
order by dwi.create_time desc
</select>
<select id="selectDklWarningInformationLists" parameterType="DklWarningInformation" resultMap="DklWarningInformationResult">
<include refid="selectDklWarningInformationVo"/>
<where>
<if test="warningSigns != null and warningSigns != ''"> and dwi.warning_signs like concat('%', #{warningSigns}, '%') </if>
<if test="unitName != null and unitName != ''"> and dwi.unit_name like concat('%', #{unitName}, '%')</if>
<if test="unitCode != null and unitCode != ''"> and dwi.unit_code = #{unitCode}</if>
<if test="releaseTime != null "> and dwi.release_time = #{releaseTime}</if>
<if test="warningStatus != null and warningStatus != ''"> and dwi.warning_status != '3'</if>
<if test="warningType != null and warningType != ''"> and dwi.warning_type = #{warningType}</if>
<if test="eventCategory != null and eventCategory != ''"> and dwi.event_category = #{eventCategory}</if>
<if test="warningLevel != null and warningLevel != ''"> and dwi.warning_level = #{warningLevel}</if>
<if test="expectedDuration != null and expectedDuration != ''"> and dwi.expected_duration = #{expectedDuration}</if>
<if test="scopeImpact != null "> and dwi.scope_impact = #{scopeImpact}</if>
<if test="deptId != null "> and dwi.dept_id = #{deptId}</if>
<if test="abnormalData != null and abnormalData != ''"> and dwi.abnormal_data = #{abnormalData}</if>
<if test="delFlag != null and delFlag != ''"> and dwi.del_flag = #{delFlag}</if>
<if test="startTime != null and endTime != null ">
AND dwi.create_time BETWEEN #{startTime} and #{endTime}
</if>
</where>
${params.dataScope}
order by dwi.create_time desc
</select>
<select id="selectDklWarningInformationById" parameterType="Long" resultMap="DklWarningInformationResult">
<include refid="selectDklWarningInformationVo"/>
where dwi.id = #{id}
</select>
<insert id="insertDklWarningInformation" parameterType="DklWarningInformation" useGeneratedKeys="true" keyProperty="id" >
insert into dkl_warning_information
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="warningSigns != null">warning_signs,</if>
<if test="unitName != null">unit_name,</if>
<if test="unitCode != null">unit_code,</if>
<if test="releaseTime != null">release_time,</if>
<if test="warningStatus != null">warning_status,</if>
<if test="warningType != null">warning_type,</if>
<if test="eventCategory != null">event_category,</if>
<if test="warningLevel != null">warning_level,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="delFlag != null">del_flag,</if>
<if test="expectedDuration != null">expected_duration,</if>
<if test="scopeImpact != null">scope_impact,</if>
<if test="deptId != null">dept_id,</if>
<if test="abnormalData != null">abnormal_data,</if>
<if test="isSupervise != null">is_supervise,</if>
<if test="lng != null">lng,</if>
<if test="lat != null">lat,</if>
<if test="rulesId != null">rules_id,</if>
<if test="eventStatus != null">event_status,</if>
<if test="pointsId != null">points_id,</if>
<if test="cameraId != null">camera_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="warningSigns != null">#{warningSigns},</if>
<if test="unitName != null">#{unitName},</if>
<if test="unitCode != null">#{unitCode},</if>
<if test="releaseTime != null">#{releaseTime},</if>
<if test="warningStatus != null">#{warningStatus},</if>
<if test="warningType != null">#{warningType},</if>
<if test="eventCategory != null">#{eventCategory},</if>
<if test="warningLevel != null">#{warningLevel},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="expectedDuration != null">#{expectedDuration},</if>
<if test="scopeImpact != null">#{scopeImpact},</if>
<if test="deptId != null">#{deptId},</if>
<if test="abnormalData != null">#{abnormalData},</if>
<if test="isSupervise != null">#{isSupervise},</if>
<if test="lng != null">#{lng},</if>
<if test="lat != null">#{lat},</if>
<if test="rulesId != null">#{rulesId},</if>
<if test="eventStatus != null">#{eventStatus},</if>
<if test="pointsId != null">#{pointsId},</if>
<if test="cameraId != null">#{cameraId},</if>
</trim>
</insert>
<update id="updateDklWarningInformation" parameterType="DklWarningInformation">
update dkl_warning_information
<trim prefix="SET" suffixOverrides=",">
<if test="warningSigns != null">warning_signs = #{warningSigns},</if>
<if test="unitName != null">unit_name = #{unitName},</if>
<if test="unitCode != null">unit_code = #{unitCode},</if>
<if test="releaseTime != null">release_time = #{releaseTime},</if>
<if test="warningStatus != null">warning_status = #{warningStatus},</if>
<if test="warningType != null">warning_type = #{warningType},</if>
<if test="eventCategory != null">event_category = #{eventCategory},</if>
<if test="warningLevel != null">warning_level = #{warningLevel},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="expectedDuration != null">expected_duration = #{expectedDuration},</if>
<if test="scopeImpact != null">scope_impact = #{scopeImpact},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="abnormalData != null">abnormal_data = #{abnormalData},</if>
<if test="isSupervise != null">is_supervise = #{isSupervise},</if>
<if test="lng != null">lng = #{lng},</if>
<if test="lat != null">lat = #{lat},</if>
<if test="rulesId != null">rules_id = #{rulesId},</if>
<if test="eventStatus != null">event_status = #{eventStatus},</if>
</trim>
where id = #{id}
</update>
<update id="deleteDklWarningInformationById" parameterType="int">
update dkl_warning_information set del_flag = 2 where id = #{id}
</update>
<update id="deleteDklWarningInformationByIds" parameterType="int">
update dkl_warning_information set del_flag = 2 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>