浏览代码

小区添加机构
设备ID查询用户告警
微信推送

lin 4 年之前
父节点
当前提交
93b0eb1ad5

+ 51 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/SendWechatPush.java

@@ -662,4 +662,55 @@ public class SendWechatPush {
             return "accessToken不存在";
         }
     }
+
+
+    /**
+     * 统一消息发送异常通知(微信公众号和小程序)
+     */
+    public static String sendAbnormalNotice(String accessToken,String oa_appid, String openId, String url,String weapp_appid, String pagepath, String first, String keyword1, String keyword2, String keyword3, String remark) {
+        if (accessToken != null && !"".equals(accessToken)) {
+            String sendUrl = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=" + accessToken;
+            String json = "{\n" +
+                    "  \"touser\": \""+openId+"\",\n" +
+                    "  \"mp_template_msg\": {\n" +
+                    "    \"appid\": \""+oa_appid +"\",\n" +
+                    "    \"template_id\": \"r8mtd2mgMt8w-sNgHsJ4deoD2bfq-0RyK9lCY3WEoxI\",\n" +
+                    "    \"url\": \""+url+"\",\n" +
+                    "    \"miniprogram\": {\n" +
+                    "      \"appid\": \""+weapp_appid+"\",\n" +
+                    "      \"pagepath\": \""+pagepath+"\"\n" +
+                    "    },\n" +
+                    "    \"data\": {\n" +
+                    "      \"first\": {\n" +
+                    "        \"value\": \""+first+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      },\n" +
+                    "      \"keyword1\": {\n" +
+                    "        \"value\": \""+keyword1+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      },\n" +
+                    "      \"keyword2\": {\n" +
+                    "        \"value\": \""+keyword2+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      },\n" +
+                    "      \"keyword3\": {\n" +
+                    "        \"value\": \""+keyword3+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      },\n" +
+                    "      \"remark\": {\n" +
+                    "        \"value\": \""+remark+"\",\n" +
+                    "        \"color\": \"#173177\"\n" +
+                    "      }\n" +
+                    "    }\n" +
+                    "  }\n" +
+                    "}";
+            try {
+                return HttpRequest.doPost(sendUrl, json);
+            } catch (IOException e) {
+                return null;
+            }
+        } else {
+            return "accessToken不存在";
+        }
+    }
 }

+ 62 - 7
smart-city-platform/src/main/java/com/bz/smart_city/controller/common/TestController.java

@@ -8,11 +8,11 @@ import com.bz.smart_city.commom.util.*;
 import com.bz.smart_city.config.AccessTokenService;
 import com.bz.smart_city.dao.PermissionMapper;
 import com.bz.smart_city.dao.SitePermissionMapper;
+import com.bz.smart_city.dao.WarningLogMapper;
+import com.bz.smart_city.dao.WarningMessageMapper;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.ZipStreamEntity;
-import com.bz.smart_city.entity.Permission;
-import com.bz.smart_city.entity.SitePermission;
-import com.bz.smart_city.entity.User;
+import com.bz.smart_city.entity.*;
 import com.bz.smart_city.quartz.entity.QuartzEntity;
 import com.bz.smart_city.quartz.job.WaterMeterReadJobV2;
 import com.bz.smart_city.quartz.service.JobAndTriggerService;
@@ -89,6 +89,10 @@ public class TestController {
     SitePermissionMapper sitePermissionMapper;
     @Autowired
     MeterReadRecordService meterReadRecordService;
+    @Resource
+    WarningLogMapper warningLogMapper;
+    @Resource
+    WarningMessageMapper warningMessageMapper;
 
     @GetMapping("test")
     @ApiOperation(value = "test")
@@ -131,8 +135,8 @@ public class TestController {
             @ApiParam(value = "opendid", required = true) @RequestParam String opendid
     ) {
         String accessToken = accessTokenService.getMpAccessToken();
-        String url = "http://smartcity.100zone.cn";
-        String pagepath = "pages/workorder/detail?orderNo=2019031904500057";
+        String url = "https://www.zoniot.com";
+        String pagepath = "";
         /*SendWechatPush.sendDeviceFaultNotice(accessToken,opendid,url,"您好,您的监控设备发生了故障","电气火灾探测器","TR-18WD01L",
                 "1305办公室","过压","2018-10-25 17:59:32","请尽快查看故障详细信息并及时处理");*/
         /*SendWechatPush.sendDeviceAlarmNotice(accessToken,opendid,url,"您好,您的监控设备发生了报警","电气火灾探测器","TR-18WD01L",
@@ -140,8 +144,10 @@ public class TestController {
         /*String result = SendWechatPush.sendDispatchNotice(accessToken, opendid, url, "您好,您有新派单待处理", "张三", "T3-207室",
                 "电气火灾探测器-025A", "供电中断", "2018-10-25 17:59:32", "请尽快查看并及时处理");*/
 
-        String result = SendWechatPush.sendUniformNotice(accessToken, "wx6b2ce547cd593413", opendid, url, "wx890c58705ee4e2de", pagepath, "您好,您有新派单待处理", "张三", "T3-207室",
-                "电气火灾探测器-025A", "供电中断", "2018-10-25 17:59:32", "请尽快查看并及时处理");
+        /*String result = SendWechatPush.sendUniformNotice(accessToken, "wx6b2ce547cd593413", opendid, url, "wx890c58705ee4e2de", pagepath, "您好,您有新派单待处理", "张三", "T3-207室",
+                "电气火灾探测器-025A", "供电中断", "2018-10-25 17:59:32", "请尽快查看并及时处理");*/
+        String result = SendWechatPush.sendAbnormalNotice(accessToken, "wx6b2ce547cd593413", opendid, url, "wx759db34b9c2e1491", pagepath, "用户用水异常", "水量预警", "单日用水量超过2吨",
+                "2021-02-23 17:59:32", "1030844808林家栋13765510000长泽花园2-1-502楼梯间用水量有异常情况,请及时关注用户情况!");
         log.info(result);
         return new AjaxMessage(ResultStatus.OK);
     }
@@ -486,4 +492,53 @@ public class TestController {
         //int result = deviceService.importRemoteMeterExcel(file);
         return "ok";
     }
+
+    @ResponseBody
+    @PostMapping("/addDemoWarningLog")
+    @ApiOperation(value = "添加演示告警记录", notes = "添加演示告警记录")
+    public String addDemoWarningLog(
+            @ApiParam(value = "openId", required = true) @RequestParam String openId,
+            @ApiParam(value = "deviceId", required = true) @RequestParam Long deviceId,
+            @ApiParam(value = "type", required = true) @RequestParam Integer type
+    ) {
+        //int result = deviceService.importRemoteMeterExcel(file);
+        WarningLog warningLogNew = new WarningLog();
+        //warningLogNew.setClientUserId(clientUserDevice.getClientUserId());
+        warningLogNew.setDeviceId(deviceId);
+        warningLogNew.setWarningType(type);
+        warningLogNew.setFeedbackStatus(0);
+        warningLogNew.setFeedbackContent("");
+        warningLogNew.setLastDate(LocalDateTime.now());
+        warningLogNew.setStatus(1);
+        warningLogNew.setCreateBy("system");
+        warningLogNew.setDateCreate(LocalDateTime.now());
+        warningLogNew.setUpdateBy("system");
+        warningLogNew.setDateUpdate(LocalDateTime.now());
+        warningLogMapper.insertSelective(warningLogNew);
+
+
+        String content = "";
+        if(type==3)content="单日用水量0.01吨";
+        if(type==4)content="单日用水量超过2吨";
+
+        WarningMessage warningMessageNew = new WarningMessage();
+        warningMessageNew.setWarningLogId(warningLogNew.getId());
+        warningMessageNew.setContent(content);
+        warningMessageNew.setStatus(1);
+        warningMessageNew.setCreateBy("system");
+        warningMessageNew.setDateCreate(LocalDateTime.now());
+        warningMessageNew.setUpdateBy("system");
+        warningMessageNew.setDateUpdate(LocalDateTime.now());
+        warningMessageMapper.insertSelective(warningMessageNew);
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        String accessToken = accessTokenService.getMpAccessToken();
+        String url = "https://www.zoniot.com";
+        String pagepath = "";
+        String result = SendWechatPush.sendAbnormalNotice(accessToken, "wx6b2ce547cd593413", openId, url, "wx759db34b9c2e1491", pagepath, "用户用水异常", "水量预警", content,
+                LocalDateTime.now().format(df), "1030844808林家栋13765510000长泽花园2-1-502楼梯间用水量有异常情况,请及时关注用户情况!");
+        log.info(result);
+        return "ok";
+    }
+
 }

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

@@ -32,6 +32,7 @@ public class WarningLogController {
     @GetMapping("getList")
     @ApiOperation(value = "查询预警记录列表")
     public AjaxMessage<Pagination<WarningLogDto>> getList(
+            @ApiParam(value = "设备ID", required = false) @RequestParam(required = false) Long deviceId,
             @ApiParam(value = "场景ID", required = false) @RequestParam(required = false) Integer channelId,
             @ApiParam(value = "设备编号/电子号", required = false) @RequestParam(required = false) String deviceNo,
             @ApiParam(value = "预警类型 1:较上日用水量激增30% 2:连续无用水量超过7天", required = false) @RequestParam(required = false) Integer warningType,
@@ -48,7 +49,7 @@ public class WarningLogController {
             @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") int pageSize
     ){
         Pagination<WarningLogDto> pageInfo = warningLogService.getList(
-                channelId,deviceNo,warningType,clientName,feedbackStatus,provinceId,cityId,regionId,communityId,buildingId,
+                deviceId,channelId,deviceNo,warningType,clientName,feedbackStatus,provinceId,cityId,regionId,communityId,buildingId,
                 startDate,endDate, pageNum, pageSize);
         return new AjaxMessage<>(ResultStatus.OK, pageInfo);
     }

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

@@ -18,6 +18,7 @@ public interface WarningLogMapper {
 
     List<WarningLogDto> getList(
             @Param("siteId") Integer siteId,
+            @Param("deviceId") Long deviceId,
             @Param("channelId") Integer channelId,
             @Param("deviceNo") String deviceNo,
             @Param("warningType") Integer warningType,

+ 19 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/WarningMessageMapper.java

@@ -0,0 +1,19 @@
+package com.bz.smart_city.dao;
+
+import com.bz.smart_city.entity.WarningMessage;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface WarningMessageMapper {
+    int insertSelective(WarningMessage record);
+
+    int updateByPrimaryKeySelective(WarningMessage record);
+
+    int batchInsert(@Param("list") List<WarningMessage> list);
+
+    WarningMessage findById(@Param("id") Integer id);
+
+}

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/CommunityDto.java

@@ -22,4 +22,7 @@ public class CommunityDto extends Community {
     @ApiModelProperty(value = "片区区", position = 4)
     private String districtName;
 
+    @ApiModelProperty(value = "机构名称", position = 5)
+    private String orgName;
+
 }

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/Community.java

@@ -53,6 +53,9 @@ public class Community implements Serializable {
     @ApiModelProperty(value="状态", hidden = true)
     private Integer status;
 
+    @ApiModelProperty(value="机构id", required = true)
+    private Integer orgId;
+
     @ApiModelProperty(value="创建时间", hidden = true)
     private LocalDateTime dateCreate;
 

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/WarningLog.java

@@ -28,6 +28,9 @@ public class WarningLog {
     @ApiModelProperty(value="反馈内容")
     private String feedbackContent;
 
+    @ApiModelProperty(value="最后预警时间")
+    private LocalDateTime lastDate;
+
     @JsonIgnore
     @ApiModelProperty(value="")
     private Integer status;

+ 42 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/WarningMessage.java

@@ -0,0 +1,42 @@
+package com.bz.smart_city.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@ApiModel(value="com-zcxk-water-entity-WarningMessage")
+@Data
+public class WarningMessage {
+    @ApiModelProperty(value="")
+    private Integer id;
+
+    @ApiModelProperty(value="")
+    private Integer warningLogId;
+
+    @ApiModelProperty(value="")
+    private String content;
+
+    @ApiModelProperty(value="")
+    private Integer status;
+
+    @JsonIgnore
+    @ApiModelProperty(value="",hidden = true)
+    private String createBy;
+
+    @ApiModelProperty(value="")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime dateCreate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="",hidden = true)
+    private String updateBy;
+
+    @JsonIgnore
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value="",hidden = true)
+    private LocalDateTime dateUpdate;
+}

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

@@ -15,7 +15,7 @@ public interface WarningLogService{
 
     int updateByPrimaryKeySelective(WarningLog record);
 
-    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);
+    Pagination<WarningLogDto> getList(Long deviceId, 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);
 

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

@@ -10,10 +10,8 @@ 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.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
@@ -25,8 +23,6 @@ import javax.annotation.Resource;
 import com.bz.smart_city.entity.WarningLog;
 import com.bz.smart_city.dao.WarningLogMapper;
 import com.bz.smart_city.service.WarningLogService;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
 import java.time.LocalDateTime;
@@ -60,11 +56,11 @@ public class WarningLogServiceImpl implements WarningLogService{
     }
 
     @Override
-    public 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) {
+    public Pagination<WarningLogDto> getList(Long deviceId, 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) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         PageHelper.startPage(pageNum,pageSize);
-        List<WarningLogDto> list =  warningLogMapper.getList(loginUser.getSiteId(),channelId,deviceNo,warningType,clientName,feedbackStatus,provinceId,cityId,regionId,communityId,buildingId,startDate,endDate,UserUtil.getCurrentSiteProgramItems(loginUser));
-        Set<String>meterCodes=new HashSet<>();
+        List<WarningLogDto> list =  warningLogMapper.getList(loginUser.getSiteId(),deviceId,channelId,deviceNo,warningType,clientName,feedbackStatus,provinceId,cityId,regionId,communityId,buildingId,startDate,endDate,UserUtil.getCurrentSiteProgramItems(loginUser));
+        /*Set<String>meterCodes=new HashSet<>();
         list.forEach(warningLogDto -> {
             meterCodes.add(warningLogDto.getMeterCode());
         });
@@ -83,7 +79,7 @@ public class WarningLogServiceImpl implements WarningLogService{
                      }
                 }
             });
-        }
+        }*/
 
         return new Pagination<>(list);
     }

+ 7 - 7
smart-city-platform/src/main/resources/application-dev.properties

@@ -68,15 +68,15 @@ spring.servlet.multipart.max-request-size=100MB
 spring.servlet.multipart.location=D:/test
 files.path=${file-path:D:/test}
 
-#\u5FAE\u4FE1\u516C\u4F17\u53F7
+#微信公众号
 wechat.oa.appid=wx6b2ce547cd593413
 wechat.oa.app-secret=a0fd84db87a6d56057c2ff261b8b97f1
-#\u4E2D\u8BDA\u4FE1\u79D1\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F
-#wechat.mp.appid=wx890c58705ee4e2de
-#wechat.mp.app-secret=12db3150f496405b4425e6f1a54e204d
-#\u5A04\u5C71\u4E91\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F
-wechat.mp.appid=wx32aae5a5179d3c5b
-wechat.mp.app-secret=ad8b1589a39752602641b134b189378a
+#中诚信科微信小程序
+wechat.mp.appid=wx890c58705ee4e2de
+wechat.mp.app-secret=12db3150f496405b4425e6f1a54e204d
+#娄山云微信小程序
+#wechat.mp.appid=wx32aae5a5179d3c5b
+#wechat.mp.app-secret=ad8b1589a39752602641b134b189378a
 
 #\u8D26\u53F7\u7533\u8BF7\u901A\u77E5\u7684\u4EBA\u7684\u5FAE\u4FE1openid
 account.apply.wechat.openid=oCaAI50Ty9bfqkNzhXUYzbGXkHVY

+ 18 - 8
smart-city-platform/src/main/resources/mapper/CommunityMapper.xml

@@ -74,6 +74,7 @@
             `name`,
             code,
             customer_id,
+            org_id,
             province,
             city,
             region,
@@ -93,6 +94,7 @@
             #{community.name,jdbcType=VARCHAR},
             #{community.code,jdbcType=VARCHAR},
             #{community.customerId,jdbcType=INTEGER},
+            #{community.orgId,jdbcType=INTEGER},
             #{community.province,jdbcType=INTEGER},
             #{community.city,jdbcType=INTEGER},
             #{community.region,jdbcType=INTEGER},
@@ -224,6 +226,7 @@
             <if test="community.siteId != null"> site_id= #{community.siteId,jdbcType=INTEGER},</if>
             <if test="community.name != null"> `name`= #{community.name,jdbcType=VARCHAR},</if>
             <if test="community.customerId != null"> customer_id= #{community.customerId,jdbcType=INTEGER},</if>
+            <if test="community.orgId != null"> org_id= #{community.orgId,jdbcType=INTEGER},</if>
             <if test="community.province != null"> province= #{community.province,jdbcType=INTEGER},</if>
             <if test="community.city != null"> city= #{community.city,jdbcType=INTEGER},</if>
             <if test="community.region != null"> region= #{community.region,jdbcType=INTEGER},</if>
@@ -337,17 +340,20 @@
         </if>
     </select>
     <select id="getList" resultType="com.bz.smart_city.dto.CommunityDto">
-        select <include refid="General_Column_List"></include>,
+        select
+        sc.*,
         sa1.name as province_name,
         sa2.name as city_name,
-        sa3.name as region_name
+        sa3.name as region_name,
+        so.name as org_name
         from sc_community sc
         left join sc_area sa1 on sa1.id = sc.province
         left join sc_area sa2 on sa2.id = sc.city
         left join sc_area sa3 on sa3.id = sc.region
+        left join sc_organization so on   so.id=sc.org_id
         where sc.status = 1
-        <if test="siteId != null"> and site_id = #{siteId} </if>
-        <if test="customerId != null"> and customer_id = #{customerId} </if>
+        <if test="siteId != null"> and sc.site_id = #{siteId} </if>
+        <if test="customerId != null"> and sc.customer_id = #{customerId} </if>
         <if test="communityName != null and communityName != ''"> and sc.name like concat('%',#{communityName} ,'%')</if>
         <if test="province != null"> and sc.province = #{province}</if>
         <if test="city != null"> and sc.city = #{city}</if>
@@ -396,18 +402,22 @@
         where status = 1 and site_id = #{siteId}
     </select>
     <select id="getListByCustomerIds" resultType="com.bz.smart_city.dto.CommunityDto">
-        select <include refid="General_Column_List"></include>,
+        select
+        sc.*,
         sa1.name as province_name,
         sa2.name as city_name,
-        sa3.name as region_name
+        sa3.name as region_name,
+        sc.name as org_name
         from sc_community sc
         left join sc_area sa1 on sa1.id = sc.province
         left join sc_area sa2 on sa2.id = sc.city
         left join sc_area sa3 on sa3.id = sc.region
+        left join sc_organization so on so.id = sc.org_id
+
         where sc.status = 1
-        <if test="siteId != null"> and site_id = #{siteId} </if>
+        <if test="siteId != null"> and sc.site_id = #{siteId} </if>
         <if test="customerIds != null">
-            and customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
+            and sc.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
         </if>
         <if test="communityName != null and communityName != ''"> and sc.name like concat('%',#{communityName} ,'%')</if>
         <if test="province != null"> and sc.province = #{province}</if>

+ 6 - 1
smart-city-platform/src/main/resources/mapper/WarningLogMapper.xml

@@ -136,16 +136,21 @@
     sdt1.equipment_type as equipment_type,
     sdt1.model as model,
     sdm1.name as manufacturer_name,
-    sil.metercode meterCode
+    sil.metercode meterCode,
+    sgm.customer_no as account_number,
+    sgm.customer_name as account_name,
+    sgm.customer_phone as account_phone
     from sc_warning_log swl
     left join sc_device sd on(sd.id = swl.device_id)
     left join sc_install_list sil on sd.id=sil.device_id
     left join sc_building sb on(sb.id = sd.building_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)
+    left join sc_grid_management sgm on(sgm.device_id = sil.device_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>
+    <if test="deviceId != null"> and sd.id = #{deviceId}</if>
     <if test="channelId != null"> and sd.sys_id = #{channelId}</if>
     <if test="deviceNo != null and deviceNo != ''"> and (
       sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%')

+ 114 - 0
smart-city-platform/src/main/resources/mapper/WarningMessageMapper.xml

@@ -0,0 +1,114 @@
+<?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.WarningMessageMapper">
+  <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.WarningMessage">
+    <!--@mbg.generated-->
+    <!--@Table sc_warning_message-->
+    <id column="id" property="id" />
+    <result column="warning_log_id" property="warningLogId" />
+    <result column="content" property="content" />
+    <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, warning_log_id, content, `status`, create_by, date_create, update_by, date_update
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.WarningMessage" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_warning_message
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="warningLogId != null">
+        warning_log_id,
+      </if>
+      <if test="content != null">
+        content,
+      </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="warningLogId != null">
+        #{warningLogId},
+      </if>
+      <if test="content != null">
+        #{content},
+      </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.WarningMessage">
+    <!--@mbg.generated-->
+    update sc_warning_message
+    <set>
+      <if test="warningLogId != null">
+        warning_log_id = #{warningLogId},
+      </if>
+      <if test="content != null">
+        content = #{content},
+      </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>
+  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_warning_message
+    (warning_log_id, content, `status`, create_by, date_create, update_by, date_update
+      )
+    values
+    <foreach collection="list" item="item" separator=",">
+      (#{item.warningLogId}, #{item.content}, #{item.status}, #{item.createBy}, #{item.dateCreate}, 
+        #{item.updateBy}, #{item.dateUpdate})
+    </foreach>
+  </insert>
+
+  <select id="findById" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List" /> from sc_warning_message where status = 1 and id = #{id}
+  </select>
+
+</mapper>