浏览代码

用户预警和修改换表BUG

lin 4 年之前
父节点
当前提交
748a41fe39
共有 20 个文件被更改,包括 289 次插入11 次删除
  1. 10 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  2. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/system/WarningLogController.java
  3. 4 2
      smart-city-platform/src/main/java/com/bz/smart_city/dao/ChannelDeviceTypeUseMapper.java
  4. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java
  5. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/MeterReadRecordMapper.java
  6. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/WarningLogMapper.java
  7. 16 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/WarningRuleMapper.java
  8. 43 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/WarningRule.java
  9. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  10. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/WarningLogService.java
  11. 11 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/WarningRuleService.java
  12. 5 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  13. 7 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WarningLogServiceImpl.java
  14. 24 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WarningRuleServiceImpl.java
  15. 7 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterMaintenanceLogServiceImpl.java
  16. 9 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterReplaceLogServiceImpl.java
  17. 5 0
      smart-city-platform/src/main/resources/mapper/ChannelDeviceTypeUseMapper.xml
  18. 25 0
      smart-city-platform/src/main/resources/mapper/DeviceMapper.xml
  19. 10 7
      smart-city-platform/src/main/resources/mapper/WarningLogMapper.xml
  20. 102 0
      smart-city-platform/src/main/resources/mapper/WarningRuleMapper.xml

+ 10 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java

@@ -202,6 +202,16 @@ public class DeviceController {
         return new AjaxMessage<>(ResultStatus.OK, device);
     }
 
+    @ResponseBody
+    @GetMapping("/deviceDetailV2")
+    @ApiOperation(value = "设备详情V2")
+    public AjaxMessage<DeviceDto> deviceDetailV2(
+            @ApiParam(value = "设备id", required = true) @RequestParam(required = true) Long deviceId
+    ) {
+        DeviceDto device = deviceService.deviceDetailV2(deviceId);
+        return new AjaxMessage<>(ResultStatus.OK, device);
+    }
+
     @ResponseBody
     @PostMapping("add")
     //@PreAuthorize("hasAuthority('sys:device:add')")

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/system/WarningLogController.java

@@ -69,4 +69,6 @@ public class WarningLogController {
         );
         return new AjaxMessage<>(ResultStatus.OK, list);
     }
+
+
 }

+ 4 - 2
smart-city-platform/src/main/java/com/bz/smart_city/dao/ChannelDeviceTypeUseMapper.java

@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+
 import com.bz.smart_city.entity.ChannelDeviceTypeUse;
 
 @Mapper
@@ -16,8 +17,9 @@ public interface ChannelDeviceTypeUseMapper {
 
     int updateByPrimaryKeySelective(@Param("channelDeviceTypeUse") ChannelDeviceTypeUse channelDeviceTypeUse);
 
-    int deleteByChannelId(@Param("channelId")Integer channelId, @Param("updateBy")String updateBy);
+    int deleteByChannelId(@Param("channelId") Integer channelId, @Param("updateBy") String updateBy);
 
-    List<Integer> findDeviceTypeByChannelId(@Param("channelId")Integer channelId);
+    List<Integer> findDeviceTypeByChannelId(@Param("channelId") Integer channelId);
 
+    ChannelDeviceTypeUse findByDeviceId(@Param("deviceTypeId") Integer deviceTypeId);
 }

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/DeviceMapper.java

@@ -81,6 +81,8 @@ public interface DeviceMapper {
 
     Device findByDeviceId(@Param("deviceId") Long deviceId);
 
+    DeviceDto findDeviceDetail(@Param("deviceId") Long deviceId);
+
     /*批量更新设备*/
     int batchUpdate(@Param("list") List<Device> list);
 

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/MeterReadRecordMapper.java

@@ -5,6 +5,7 @@ import com.bz.smart_city.dto.WaterConsumptionSummaryDto;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 import com.bz.smart_city.commom.model.CommonQueryCondition;
@@ -95,4 +96,5 @@ public interface MeterReadRecordMapper {
                                               @Param("deviceNo") String deviceNo,
                                               @Param("electronicNo") String electronicNo,
                                               @Param("custId") Integer custId);
+
 }

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/WarningLogMapper.java

@@ -42,4 +42,5 @@ public interface WarningLogMapper {
             @Param("startDate") LocalDateTime startDate,
             @Param("endDate") LocalDateTime endDate,
             @Param("programItems") List<ProgramItem> programItems);
+
 }

+ 16 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/WarningRuleMapper.java

@@ -0,0 +1,16 @@
+package com.bz.smart_city.dao;
+
+import com.bz.smart_city.entity.WarningRule;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface WarningRuleMapper {
+    int insertSelective(WarningRule record);
+
+    int updateByPrimaryKeySelective(WarningRule record);
+
+    List<WarningRule> getList(@Param("type") Integer type);
+}

+ 43 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/WarningRule.java

@@ -0,0 +1,43 @@
+package com.bz.smart_city.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.time.LocalDateTime;
+import lombok.Data;
+
+@ApiModel(value="com-bz-smart_city-entity-WarningRule")
+@Data
+public class WarningRule {
+    /**
+    * id
+    */
+    @ApiModelProperty(value="id")
+    private Integer id;
+
+    /**
+    * 设备id
+    */
+    @ApiModelProperty(value="设备id")
+    private Long deviceId;
+
+    /**
+    * 预警类型
+    */
+    @ApiModelProperty(value="预警类型")
+    private Integer warningType;
+
+    @ApiModelProperty(value="")
+    private Integer status;
+
+    @ApiModelProperty(value="")
+    private String createBy;
+
+    @ApiModelProperty(value="")
+    private LocalDateTime dateCreate;
+
+    @ApiModelProperty(value="")
+    private String updateBy;
+
+    @ApiModelProperty(value="")
+    private LocalDateTime dateUpdate;
+}

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java

@@ -109,6 +109,9 @@ public interface DeviceService{
     void exportInstallList(String deviceNo, Integer status, String errorType, Integer customerId, Integer province, Integer city, Integer region, Integer community, Integer buildingId, String locDesc, Integer deviceTypeId, Integer registerStatus, LocalDateTime startDate, LocalDateTime endDate, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
 
     Device deviceDetail(Long deviceId);
+
+    DeviceDto deviceDetailV2(Long deviceId);
+
     Pagination<DeviceDto> simpleQueryDeviceList(Integer siteId,Integer channelId , String deviceNo,String waterMeterNo, int pageNum, int pageSize);
 
     List<DeviceCustomerInfo> getDeviceCustomerInfo(Integer buildingId);

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/WarningLogService.java

@@ -18,4 +18,5 @@ public interface WarningLogService{
     Pagination<WarningLogDto> getList(Integer channelId, String deviceNo, Integer warningType, String clientName, Integer feedbackStatus, Integer provinceId, Integer cityId, Integer regionId, Integer communityId, Integer buildingId, LocalDateTime startDate, LocalDateTime endDate, int pageNum, int pageSize);
 
     List<BuildingSelectDto> getAreaList(Integer channelId, String deviceNo, Integer warningType, String clientName, Integer feedbackStatus, LocalDateTime startDate, LocalDateTime endDate);
+
 }

+ 11 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/WarningRuleService.java

@@ -0,0 +1,11 @@
+package com.bz.smart_city.service;
+
+import com.bz.smart_city.entity.WarningRule;
+public interface WarningRuleService{
+
+
+    int insertSelective(WarningRule record);
+
+    int updateByPrimaryKeySelective(WarningRule record);
+
+}

+ 5 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java

@@ -1303,6 +1303,11 @@ public  class DeviceServiceImpl implements DeviceService {
         return device;
     }
 
+    @Override
+    public DeviceDto deviceDetailV2(Long deviceId) {
+        return deviceMapper.findDeviceDetail(deviceId);
+    }
+
     @Override
     public List<DeviceCustomerInfo> getDeviceCustomerInfo(Integer buildingId) {
         return deviceMapper.getDeviceCustomerInfo(buildingId);

+ 7 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WarningLogServiceImpl.java

@@ -2,10 +2,13 @@ package com.bz.smart_city.service.impl;
 
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.MeterReadRecordMapper;
+import com.bz.smart_city.dao.WarningRuleMapper;
 import com.bz.smart_city.dto.BuildingSelectDto;
 import com.bz.smart_city.dto.BuildingSelectInfoDto;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.WarningLogDto;
+import com.bz.smart_city.entity.WarningRule;
 import com.bz.smart_city.service.BuildingService;
 import com.github.pagehelper.PageHelper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,9 +26,13 @@ public class WarningLogServiceImpl implements WarningLogService{
 
     @Resource
     private WarningLogMapper warningLogMapper;
+    @Resource
+    private WarningRuleMapper warningRuleMapper;
 
     @Autowired
     private BuildingService buildingService;
+    @Resource
+    private MeterReadRecordMapper meterReadRecordMapper;
 
     @Override
     public int insertSelective(WarningLog record) {

+ 24 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WarningRuleServiceImpl.java

@@ -0,0 +1,24 @@
+package com.bz.smart_city.service.impl;
+
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import com.bz.smart_city.entity.WarningRule;
+import com.bz.smart_city.dao.WarningRuleMapper;
+import com.bz.smart_city.service.WarningRuleService;
+@Service
+public class WarningRuleServiceImpl implements WarningRuleService{
+
+    @Resource
+    private WarningRuleMapper warningRuleMapper;
+
+    @Override
+    public int insertSelective(WarningRule record) {
+        return warningRuleMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(WarningRule record) {
+        return warningRuleMapper.updateByPrimaryKeySelective(record);
+    }
+
+}

+ 7 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterMaintenanceLogServiceImpl.java

@@ -51,6 +51,8 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
     private DeviceTypeMapper deviceTypeMapper;
     @Autowired
     private UdipUnitService udipUnitService;
+    @Resource
+    private ChannelDeviceTypeUseMapper channelDeviceTypeUseMapper;
 
     @Override
     public int insert(WaterMeterMaintenanceLog waterMeterMaintenanceLog) {
@@ -152,7 +154,7 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
             waterMeterReplaceLog.setNewDeviceFlagNo(waterMeterMaintenanceLog.getNewDeviceFlagNo());
             waterMeterReplaceLog.setOldDeviceFlagNo(waterMeterMaintenanceLog.getOldDeviceFlagNo());
             waterMeterReplaceLog.setRemark(waterMeterMaintenanceLog.getRemark());
-            waterMeterReplaceLog.setReplaceUsername(loginUser.getName());
+            waterMeterReplaceLog.setReplaceUsername(loginUser.getUsername());
             waterMeterReplaceLog.setReplaceUserPhone(loginUser.getMobilePhone());
             waterMeterReplaceLog.setStatus(1);
             waterMeterReplaceLog.setCreateBy(UserUtil.getCurrentUser().getUsername());
@@ -197,6 +199,10 @@ public class WaterMeterMaintenanceLogServiceImpl implements WaterMeterMaintenanc
                         newDevice.setRegisterStatus(1);
                     }
                 }
+                ChannelDeviceTypeUse use = channelDeviceTypeUseMapper.findByDeviceId(waterMeterMaintenanceLog.getNewDeviceTypeId());
+                if (use != null) {
+                    newDevice.setSysId(use.getChannelId());
+                }
 
                 newDevice.setDeviceType(waterMeterMaintenanceLog.getNewDeviceTypeId());
             }

+ 9 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/WaterMeterReplaceLogServiceImpl.java

@@ -7,10 +7,12 @@ import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.AssistantUserUtil;
 import com.bz.smart_city.commom.util.ExcelUtil;
 import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.ChannelDeviceTypeUseMapper;
 import com.bz.smart_city.dao.DeviceMapper;
 import com.bz.smart_city.dao.DeviceTypeMapper;
 import com.bz.smart_city.dto.*;
 import com.bz.smart_city.dto.assistant.LoginAssistantUser;
+import com.bz.smart_city.entity.ChannelDeviceTypeUse;
 import com.bz.smart_city.entity.Device;
 import com.bz.smart_city.service.BuildingService;
 import com.bz.smart_city.service.udip.UdipUnitService;
@@ -46,6 +48,8 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
     private DeviceMapper deviceMapper;
     @Autowired
     private BuildingService buildingService;
+    @Resource
+    private ChannelDeviceTypeUseMapper channelDeviceTypeUseMapper;
 
 
     @Override
@@ -141,7 +145,7 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
         String username = null;
         String userPhone = null;
         if(loginUser != null){
-            username = loginUser.getName();
+            username = loginUser.getUsername();
             userPhone = loginUser.getMobilePhone();
         }
         if(loginAssistantUser != null){
@@ -216,6 +220,10 @@ public class WaterMeterReplaceLogServiceImpl implements WaterMeterReplaceLogServ
                     newDevice.setRegisterStatus(1);
                 }
             }
+            ChannelDeviceTypeUse use = channelDeviceTypeUseMapper.findByDeviceId(waterMeterReplaceInputDto.getNewDeviceTypeId());
+            if (use != null) {
+                newDevice.setSysId(use.getChannelId());
+            }
 
             newDevice.setDeviceType(waterMeterReplaceInputDto.getNewDeviceTypeId());
         }

+ 5 - 0
smart-city-platform/src/main/resources/mapper/ChannelDeviceTypeUseMapper.xml

@@ -133,6 +133,11 @@
         group by device_type_id
     </select>
 
+    <select id="findByDeviceId" resultMap="BaseResultMap">
+        select <include refid="Base_Column_List"/> from sc_channel_device_type_use
+        where status = 1 and device_type_id = #{deviceTypeId} limit 1
+    </select>
+
 
 </mapper>
 

+ 25 - 0
smart-city-platform/src/main/resources/mapper/DeviceMapper.xml

@@ -588,6 +588,31 @@
           select id,device_no from sc_device where status = 1 and device_no = #{deviceNo}
     </select>
 
+    <select id="findDeviceDetail" resultType="com.bz.smart_city.dto.DeviceDto">
+        select sd.*,sdt.equipment_type,sdt.model,sdm.name manufacturer_name,sb.name as building_name,sc.channel_name as system_name,
+        sb.longitude,sb.latitude,
+        sb.province,sb.city,sb.region,sb.community,scom.name as community_name,
+        scon.serial_number as concentrator_name,scol.collector_no as collector_name,swmed.days,swmed.last_error_type,scus.customer_name,
+        sil.plan_time,sil.install_time,sil.accept_time,
+        swmed.meter_reading,
+        swmed.valve_status,
+        swmed.valve_button_status,
+        sdt.is_valve
+        from sc_device sd
+        left join sc_device_type sdt on (sdt.id = sd.device_type and sdt.status = 1)
+        left join sc_device_manufacturer sdm on (sdm.id = sd.manufacturer_id and sdm.status = 1)
+        left join sc_building sb on (sb.id = sd.building_id and sb.status = 1)
+        left join sc_channel sc on (sc.id = sd.sys_id and sc.status = 1)
+        left join sc_community scom on ( scom.id = sb.community and scom.status = 1)
+        left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)
+        left join sc_concentrator scon on ( scon.id = swrd.concentrator_id and scon.status = 1)
+        left join sc_collector scol on ( scol.id = swrd.collector_id)
+        left join sc_water_meter_error_days swmed on ( swmed.device_id = sd.id)
+        left join sc_customer scus on ( scus.id = sd.customer_id)
+        left join sc_install_list sil on (sil.device_id = sd.id)
+        where sd.status = 1 and sd.id = #{deviceId}
+    </select>
+
     <select id="findByDeviceId" resultMap="BaseResultMap">
         select * from sc_device where id = #{deviceId} and status = 1
     </select>

+ 10 - 7
smart-city-platform/src/main/resources/mapper/WarningLogMapper.xml

@@ -130,9 +130,9 @@
   <select id="getList" resultType="com.bz.smart_city.dto.WarningLogDto">
     select
     swl.*,
-    scu.accountnumber as account_number,
-    scu.username as account_name,
-    scu.mobile_phone as account_phone,
+    pba.accountnumber as account_number,
+    pba.name as account_name,
+    pba.mobilephone as account_phone,
     sd.device_no,
     sd.water_meter_no,
     sd.loc_desc,
@@ -142,7 +142,8 @@
     from sc_warning_log swl
     left join sc_device sd on(sd.id = swl.device_id)
     left join sc_building sb on(sb.id = sd.building_id)
-    left join sc_client_user scu on(scu.id = swl.client_user_id)
+    left join pay_base_customerandmeterrela pbc on(pbc.watermeter_id = swl.device_id)
+    left join pay_base_account pba on(pba.id = pbc.account_id)
     left join sc_device_type sdt1 on(sdt1.id = sd.device_type)
     left join sc_device_manufacturer sdm1 on(sdm1.id = sdt1.manufacturer_id)
     <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
@@ -154,7 +155,7 @@
     )</if>
     <if test="warningType != null"> and swl.warning_type = #{warningType}</if>
     <if test="clientName != null and clientName != ''"> and (
-      scu.username LIKE concat('%',#{clientName},'%') or scu.mobile_phone LIKE concat('%',#{clientName},'%') or scu.accountnumber LIKE concat('%',#{clientName},'%')
+      pba.name LIKE concat('%',#{clientName},'%') or pba.mobilephone LIKE concat('%',#{clientName},'%') or pba.accountnumber LIKE concat('%',#{clientName},'%')
     )</if>
     <if test="feedbackStatus != null"> and swl.feedback_status = #{feedbackStatus}</if>
     <if test="provinceId != null"> and sb.province = #{provinceId}</if>
@@ -188,7 +189,8 @@
     select sd.building_id,count(1) as device_count
     from sc_warning_log swl
     left join sc_device sd on(sd.id = swl.device_id)
-    left join sc_client_user scu on(scu.id = swl.client_user_id)
+    left join pay_base_customerandmeterrela pbc on(pbc.watermeter_id = swl.device_id)
+    left join pay_base_account pba on(pba.id = pbc.account_id)
     <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
     where swl.status = 1 and sd.status = 1
     <if test="siteId != null"> and sd.site_id = #{siteId}</if>
@@ -198,7 +200,7 @@
       )</if>
     <if test="warningType != null"> and swl.warning_type = #{warningType}</if>
     <if test="clientName != null and clientName != ''"> and (
-      scu.username LIKE concat('%',#{clientName},'%') or scu.mobile_phone LIKE concat('%',#{clientName},'%') or scu.accountnumber LIKE concat('%',#{clientName},'%')
+      pba.name LIKE concat('%',#{clientName},'%') or pba.mobilephone LIKE concat('%',#{clientName},'%') or pba.accountnumber LIKE concat('%',#{clientName},'%')
       )</if>
     <if test="feedbackStatus != null"> and swl.feedback_status = #{feedbackStatus}</if>
     <if test="startDate != null"> and swl.date_create <![CDATA[ >= ]]> #{startDate}</if>
@@ -212,4 +214,5 @@
     ) t1 on (t1.building_id = b.id)
     where b.status = 1
   </select>
+
 </mapper>

+ 102 - 0
smart-city-platform/src/main/resources/mapper/WarningRuleMapper.xml

@@ -0,0 +1,102 @@
+<?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.bz.smart_city.dao.WarningRuleMapper">
+  <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.WarningRule">
+    <!--@mbg.generated-->
+    <!--@Table sc_warning_rule-->
+    <id column="id" property="id" />
+    <result column="device_id" property="deviceId" />
+    <result column="warning_type" property="warningType" />
+    <result column="status" property="status" />
+    <result column="create_by" property="createBy" />
+    <result column="date_create" property="dateCreate" />
+    <result column="update_by" property="updateBy" />
+    <result column="date_update" property="dateUpdate" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, device_id, warning_type, `status`, create_by, date_create, update_by, date_update
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.WarningRule" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_warning_rule
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="deviceId != null">
+        device_id,
+      </if>
+      <if test="warningType != null">
+        warning_type,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="dateCreate != null">
+        date_create,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="dateUpdate != null">
+        date_update,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="deviceId != null">
+        #{deviceId},
+      </if>
+      <if test="warningType != null">
+        #{warningType},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.WarningRule">
+    <!--@mbg.generated-->
+    update sc_warning_rule
+    <set>
+      <if test="deviceId != null">
+        device_id = #{deviceId},
+      </if>
+      <if test="warningType != null">
+        warning_type = #{warningType},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy},
+      </if>
+      <if test="dateCreate != null">
+        date_create = #{dateCreate},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy},
+      </if>
+      <if test="dateUpdate != null">
+        date_update = #{dateUpdate},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
+
+  <select id="getList" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"/> from sc_warning_rule where status = 1 and warning_type = #{type}
+  </select>
+</mapper>