yf_zn пре 8 месеци
родитељ
комит
bb19e73a02

+ 32 - 0
src/main/java/com/yunfeiyun/agmp/iots/mq/provider/AgmpIotMqProviderService.java

@@ -0,0 +1,32 @@
+package com.yunfeiyun.agmp.iots.mq.provider;
+
+import com.yunfeiyun.agmp.common.framework.mq.rabbitmq.consts.MqAgmpConsts;
+import com.yunfeiyun.agmp.common.framework.mq.rabbitmq.consts.MqAgmpIotConsts;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+@ConditionalOnBean(name = "agmpIotMqConfig")
+public class AgmpIotMqProviderService {
+    @Autowired
+    @Qualifier("agmpIotRabbitTemplate")
+    private RabbitTemplate agmpIotRabbitTemplate;
+
+
+    /**
+     * 往智慧农业发送
+     *
+     * @param message
+     */
+    public void sendToAgmpIot(String message) {
+        log.info("【消息通知】sendToagmpIot message:{}", message);
+        agmpIotRabbitTemplate.convertAndSend(MqAgmpIotConsts.ExchangeConsts.EXCHANGE_KEY, MqAgmpIotConsts.RoutingConsts.ROUTING_KEY, message);
+    }
+
+
+}

+ 31 - 0
src/main/java/com/yunfeiyun/agmp/iots/mq/provider/AgmpMqProviderService.java

@@ -0,0 +1,31 @@
+package com.yunfeiyun.agmp.iots.mq.provider;
+
+import com.yunfeiyun.agmp.common.framework.mq.rabbitmq.consts.MqAgmpConsts;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+@ConditionalOnBean(name = "agmpMqConfig")
+public class AgmpMqProviderService {
+    @Autowired
+    @Qualifier("agmpRabbitTemplate")
+    private RabbitTemplate agmpRabbitTemplate;
+
+
+    /**
+     * 往智慧农业发送
+     *
+     * @param message
+     */
+    public void sendToAgmp(String message) {
+        log.info("【消息通知】sendToAgmp message:{}", message);
+        agmpRabbitTemplate.convertAndSend(MqAgmpConsts.ExchangeConsts.EXCHANGE_KEY, MqAgmpConsts.RoutingConsts.ROUTING_KEY, message);
+    }
+
+
+}

+ 8 - 0
src/main/java/com/yunfeiyun/agmp/iots/warn/mapper/IotWarnBussinessMapper.java

@@ -82,4 +82,12 @@ public interface IotWarnBussinessMapper {
     List<IotWarnconfigDevVo> selectIotWarnconfigCbdDevList();
 
     IotDevice selectDeviceById(@Param("devBid") String devBid);
+
+    IotWarnpolicy selectWarnPolicy(@Param("configId") String configId);
+
+    List<IotWarnreceiver> selectWarnReceiverByConfigId(String configId);
+
+    void updateWarnLogSendStatus(@Param("time") String time, @Param("wlBid") String wlBid, @Param("status") String status);
+
+    IotWarnlog getLastedUnSendWarnLog(String wcBid);
 }

+ 10 - 0
src/main/java/com/yunfeiyun/agmp/iots/warn/model/WarnResult.java

@@ -2,8 +2,11 @@ package com.yunfeiyun.agmp.iots.warn.model;
 
 import com.yunfeiyun.agmp.iot.common.domain.IotBaseEntity;
 import com.yunfeiyun.agmp.iot.common.domain.IotWarnconfig;
+import com.yunfeiyun.agmp.iot.common.domain.IotWarnpolicy;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * 预警结果,不是对应数据库层面的
  */
@@ -53,6 +56,13 @@ public class WarnResult extends IotBaseEntity {
      * 是不是离线指标
      */
     private boolean isOffline;
+    private IotWarnpolicy iotWarnpolicy;
+
+    private List<String> receiverIds;
+    /**
+     * 预警日志id
+     */
+    private String wlBid;
 
     public WarnResult(boolean isTriggered, String message) {
         this.isTriggered = isTriggered;

+ 19 - 2
src/main/java/com/yunfeiyun/agmp/iots/warn/service/IotWarnBussinessService.java

@@ -101,11 +101,11 @@ public class IotWarnBussinessService {
         return result;
     }
 
-    public int insertWarnRecord(IotWarnlog iotWarnlog) {
+    public String insertWarnRecord(IotWarnlog iotWarnlog) {
         log.info("插入预警记录: {}", iotWarnlog);
         int result = iotWarnBussinessMapper.insertWarnRecord(iotWarnlog);
         log.info("插入预警记录结果: {}", result);
-        return result;
+        return iotWarnlog.getWlBid();
     }
 
     public List<WarnConfigInfo> selectIotWarnConfigInfoList(WarnConfigInfo warnConfigInfo) {
@@ -412,4 +412,21 @@ public class IotWarnBussinessService {
         }
         return iotWarnindicatorMap;
     }
+
+    public IotWarnpolicy selectWarnPolicy(String configId) {
+        return iotWarnBussinessMapper.selectWarnPolicy(configId);
+    }
+
+    public List<IotWarnreceiver> selectWarnReceiverByConfigId(String configId) {
+
+        return iotWarnBussinessMapper.selectWarnReceiverByConfigId(configId);
+    }
+
+    public void updateWarnLogSendStatus(String time, String wlBid, String status) {
+        iotWarnBussinessMapper.updateWarnLogSendStatus(time, wlBid, status);
+    }
+
+    public IotWarnlog getLastedUnSendWarnLog(String wcBid) {
+        return iotWarnBussinessMapper.getLastedUnSendWarnLog(wcBid);
+    }
 }

+ 219 - 0
src/main/java/com/yunfeiyun/agmp/iots/warn/service/MsgService.java

@@ -0,0 +1,219 @@
+package com.yunfeiyun.agmp.iots.warn.service;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.yunfeiyun.agmp.common.enums.warn.MsgBusType;
+import com.yunfeiyun.agmp.common.enums.warn.MsgType;
+import com.yunfeiyun.agmp.common.enums.warn.WarnLogSendStatus;
+import com.yunfeiyun.agmp.common.framework.message.MessageDto;
+import com.yunfeiyun.agmp.common.framework.mq.rabbitmq.enums.AgmpActionEnums;
+import com.yunfeiyun.agmp.common.framework.mq.rabbitmq.model.SynAgmpInfoDto;
+import com.yunfeiyun.agmp.common.utils.DateUtils;
+import com.yunfeiyun.agmp.common.utils.StringUtils;
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictEnum;
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceTypeLv1Enum;
+import com.yunfeiyun.agmp.iot.common.domain.IotWarnconfig;
+import com.yunfeiyun.agmp.iot.common.domain.IotWarnlog;
+import com.yunfeiyun.agmp.iot.common.domain.IotWarnpolicy;
+import com.yunfeiyun.agmp.iot.common.domain.IotWarnreceiver;
+import com.yunfeiyun.agmp.iots.mq.provider.AgmpIotMqProviderService;
+import com.yunfeiyun.agmp.iots.warn.model.WarnResult;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 消息中心
+ * 重复次数服务产生告警信息后发给消息中心发送消息
+ */
+@Service
+@Slf4j
+public class MsgService {
+    @Autowired
+    private IotWarnBussinessService iotWarnBussinessService;
+
+    @Autowired
+    private AgmpIotMqProviderService agmpMqProviderService;
+
+    /**
+     * 1. 判断是否触发
+     * 2. 如果已经触发预警,获取配置信息IotWarnpolicy,检查是即使发送还是周期性发送wpType:0即时推送,1选定时间
+     * 3. 如果是及时发送
+     * 3.1 如果是站内信web,直接入库,代表发送
+     * 3.2 首先入库,状态待发送,然后放入队列,异步发送
+     * 4. 如果是选定时间
+     * 4.1 获取需要发送的时间段,还要获取上一次发送的时间,以及配置信息的发送周期
+     * 4.2 如果在这个发送时间段,离上次发送消息已经过了一个周期,则发送,否则不发送
+     *
+     * @param warnResult
+     */
+    public void handleWarn(WarnResult warnResult) {
+
+        try {
+            if (!warnResult.isTriggered()) {
+                return;
+            }
+            String messageId = warnResult.getMessageId();
+            IotWarnpolicy iotWarnpolicy = iotWarnBussinessService.selectWarnPolicy(warnResult.getConfigId());
+            if (iotWarnpolicy == null) {
+                log.info("未找到配置信息,配置id:{}", warnResult.getConfigId());
+                return;
+            }
+            warnResult.setIotWarnpolicy(iotWarnpolicy);
+            List<IotWarnreceiver> iotWarnreceiverList = iotWarnBussinessService.selectWarnReceiverByConfigId(warnResult.getConfigId());
+            if (iotWarnreceiverList.isEmpty()) {
+                iotWarnreceiverList = new ArrayList<>();
+            }
+            List<String> userIds = iotWarnreceiverList.stream().map(IotWarnreceiver::getWruserId).collect(Collectors.toList());
+            warnResult.setReceiverIds(userIds);
+            String wpType = iotWarnpolicy.getWpType();
+            boolean reSend = false;
+            if (wpType.equals("0")) {
+                // 即时推送
+                log.info("【告警通知】消息标识{}:当前设备ID:{},即时推送", messageId, warnResult.getDevId());
+                saveWarnMsg(warnResult);
+            } else if (wpType.equals("1")) {
+                // 选定时间
+                String deliveryTimePeriod = iotWarnpolicy.getDeliveryTimePeriod();
+                String startTime = deliveryTimePeriod.split("-")[0];
+                String endTime = deliveryTimePeriod.split("-")[1];
+                Date startDate = DateUtils.parseDate(DateUtils.getDate()+" "+startTime);
+                Date endDate = DateUtils.parseDate(DateUtils.getDate()+" "+endTime);
+                log.info("【告警通知】消息标识{}:当前设备ID:{},时间段推送:deliveryTimePeriod{},start:{},end:{}", messageId, warnResult.getDevId(),deliveryTimePeriod,startDate,endDate);
+                if (DateUtils.isBetween(new Date(), startDate, endDate)) {
+                    // 发送频率,每N时,数字类型
+                    String wpFrequency = StringUtils.isEmpty(iotWarnpolicy.getWpFrequency())?"0":iotWarnpolicy.getWpFrequency();
+                    // 判断是否到了发送时间
+                    IotWarnlog lastedUnSendWarnLog = getLastedUnSendWarnLog(warnResult.getConfigId());
+                    if (lastedUnSendWarnLog != null) {
+                        // 根据最后一次发送时间,结合发送频率,如果上次距离当下超过发送频率,那就可以发送
+                        if (!DateUtils.isBetween(new Date(), DateUtils.parseDate(lastedUnSendWarnLog.getWlCreateddate()), DateUtils.addHours(DateUtils.parseDate(lastedUnSendWarnLog.getWlCreateddate()), Integer.parseInt(wpFrequency)))) {
+                            saveWarnMsg(warnResult);
+                        } else {
+                            reSend = true;
+                            log.info("还没到发送时间,下次发送时间:{}", DateUtils.addHours(DateUtils.parseDate(lastedUnSendWarnLog.getWlCreateddate()), Integer.parseInt(wpFrequency)).toString());
+                        }
+                    } else {
+                        saveWarnMsg(warnResult);
+                    }
+                } else {
+                    reSend = true;
+                }
+            }
+            //统一处理补发逻辑
+            reSendWarn(warnResult.getWlBid(), reSend, warnResult.getConfigId(), iotWarnpolicy.getDeliveryTimePeriod(), iotWarnpolicy.getWpFrequency());
+        } catch (Exception e) {
+            log.error("handleWarn error", e);
+        }
+    }
+
+    /**
+     * 补发逻辑
+     *
+     * @param wlId
+     * @param reSendStatus
+     * @param wlBid
+     * @param deliveryTimePeriod
+     * @param wpFrequency
+     */
+    void reSendWarn(String wlId, boolean reSendStatus, String wlBid, String deliveryTimePeriod, String wpFrequency) {
+        if (reSendStatus) {
+            //标记需要补发
+        } else {
+            //标记不需要补发
+        }
+    }
+
+    void saveWarnMsg(WarnResult warnResult) {
+        SynAgmpInfoDto synAgmpInfoDto = new SynAgmpInfoDto();
+        synAgmpInfoDto.setAction(AgmpActionEnums.AGMP_SEND_MSG.getCode());
+        synAgmpInfoDto.setData(JSONObject.from(resolvePtsMsgByIotWarnlog(warnResult)));
+        synAgmpInfoDto.setDesc("发送消息");
+        //标记告警记录,已发送;
+        iotWarnBussinessService.updateWarnLogSendStatus(DateUtils.dateTimeNow(), warnResult.getWlBid(), WarnLogSendStatus.SEND_SUCCESS.getCode());
+        agmpMqProviderService.sendToAgmpIot(JSONObject.toJSONString(synAgmpInfoDto));
+    }
+
+    public IotWarnlog getLastedUnSendWarnLog(String wcBid) {
+        // 获取最新的一条未发送的告警
+        IotWarnlog iotWarnlog = iotWarnBussinessService.getLastedUnSendWarnLog(wcBid);
+        return iotWarnlog;
+    }
+
+
+    /**
+     * 告警日志转为消息对象
+     */
+    public MessageDto resolvePtsMsgByIotWarnlog(WarnResult warnResult) {
+        MessageDto messageDto = new MessageDto();
+        IotWarnconfig iotWarnconfig = warnResult.getConfig();
+        IotWarnpolicy iotWarnpolicy = warnResult.getIotWarnpolicy();
+        // 直接映射或推测可能的对应关系
+        messageDto.setMsgbatchId(warnResult.getMessageId());  // 假设消息标识作为消息批次标识
+        messageDto.setMsgbatchContent(warnResult.getMessage());  // 使用预警消息作为消息批次内容
+        messageDto.setMsgbatchContenttype("1");  // 假定使用固定内容,具体依据业务需求确定
+        messageDto.setMsgbatchMsgtype(MsgType.WARN_INFO.getCode());
+        messageDto.setMsgbatchBiztype(resolveMsgBusTypeByDevtype(warnResult.getDevtypeBid()).getCode());  // 业务类型,这里假设为预警配置ID
+        messageDto.setMsgbatchBizobj(warnResult.getDevId());  // 设备ID作为业务对象
+        messageDto.setMsgbatchLevel(iotWarnconfig.getWcLevel());  // 消息等级,这里默认为1,实际应用中应依据具体情况设置
+        messageDto.setMsgbatchSource("iots");  // 消息来源,假设来自物联网系统
+        messageDto.setMsgbatchSender("system");  // 发送者,这里假设为系统发送
+        messageDto.setMsgbatchChannel(iotWarnpolicy.getWpChannel());  // 通知渠道,这里假设通过电子邮件发送,需要根据实际情况调整
+        JSONObject extra = new JSONObject();
+        extra.put("location", "/iotm/warning/record");
+        extra.put("permission", "iotm:warningPlanning:historyRecord");
+        extra.put("handleId", warnResult.getWlBid());
+        messageDto.setMsgbatchExtra(extra.toJSONString());
+        messageDto.setMsgbatchHandler(warnResult.getReceiverIds());  // 处理人暂时为空,根据业务逻辑补充
+        messageDto.setMsgbatchHandlerType("1");  // 处理人暂时为空,根据业务逻辑补充
+        messageDto.setMsgbatchCreateddate(DateUtils.dateTimeNow());  // 创建时间
+        messageDto.setMsgbatchTitle("设备告警");  // 消息标题,这里假设为物联网设备警告
+        messageDto.setMsgbatchTarget("PTS");  // 目标子系统,这里假设为目标设备型号ID
+        messageDto.setWlBid(warnResult.getWlBid());  // 物联网预警ID
+        return messageDto;
+    }
+
+    //根据设备型号判断对应那种告警类型
+    public MsgBusType resolveMsgBusTypeByDevtype(String devtypeBid) {
+        String devClass = IotDeviceDictEnum.getLv1CodeByCode(devtypeBid);
+        IotDeviceTypeLv1Enum iotDeviceTypeLv1Enum = IotDeviceTypeLv1Enum.findEnumByCode(devClass);
+        switch (iotDeviceTypeLv1Enum) {
+            case QXZ: {
+                return MsgBusType.WARN_QX;
+            }
+            case SQZ:
+            case GSSQ: {
+                return MsgBusType.WARN_SQ;
+            }
+            //病害
+            case YBQ_DWB:
+            case YBQ_CMB:
+            case YBQ_DBB:
+            case YBQ_TXB:
+            case YBQ_BFB: {
+                return MsgBusType.WARN_DISEASE;
+            }
+            //虫害
+            case CBD:
+                return MsgBusType.WARN_PEST;
+            default:
+                return MsgBusType.WARN_DEVICE_COMMON;
+        }
+    }
+
+
+    /**
+     * 插入消息内容
+     */
+    public void saveWarnMsg(IotWarnlog iotWarnlog) {
+
+    }
+
+/**
+ * 定时任务:获取到了需要发送的时间段,获取最新的一条未发送的告警进行发送
+ */
+}

+ 12 - 2
src/main/java/com/yunfeiyun/agmp/iots/warn/service/ReCountService.java

@@ -1,6 +1,7 @@
 package com.yunfeiyun.agmp.iots.warn.service;
 
 import com.yunfeiyun.agmp.common.constant.ErrorCode;
+import com.yunfeiyun.agmp.common.enums.warn.WarnLogSendStatus;
 import com.yunfeiyun.agmp.common.exception.BizException;
 import com.yunfeiyun.agmp.common.utils.DateUtils;
 import com.yunfeiyun.agmp.common.utils.StringUtils;
@@ -20,6 +21,8 @@ import org.springframework.stereotype.Service;
 public class ReCountService {
     @Autowired
     private IotWarnBussinessService iotWarnBussinessService;
+    @Autowired
+    private MsgService msgService;
 
     /**
      * 针对预警解析出来的结果进行处理
@@ -35,7 +38,10 @@ public class ReCountService {
         // 离线的只用直接入库即可
         if (warnResult.isTriggered() && warnResult.isOffline()) {
             log.info("【设备预警】消息标识{}:当前设备ID:{},离线告警", messageId, warnResult.getDevId(), warnResult.getConfigId(), warnResult);
-            iotWarnBussinessService.insertWarnRecord(buildWarnMessage(messageId, warnResult));
+            String wlBid = iotWarnBussinessService.insertWarnRecord(buildWarnMessage(messageId, warnResult));
+            //发给消息服务
+            warnResult.setWlBid(wlBid);
+            msgService.handleWarn(warnResult);
             return;
         }
         // 触发了预警,进行校验处理
@@ -46,7 +52,10 @@ public class ReCountService {
             log.info("【设备预警】消息标识{}:当前设备ID:{}, 预警配置ID:{} 的重复次数为: {}", messageId, warnResult.getDevId(), warnResult.getConfigId(), thisReCount);
             if (thisReCount + 1 > targetReCount) {
                 log.info("【设备预警】消息标识{}:达到或超过阈值, 不再增加重复次数,直接生成预警记录", messageId);
-                iotWarnBussinessService.insertWarnRecord(buildWarnMessage(messageId, warnResult));
+                String wlBid = iotWarnBussinessService.insertWarnRecord(buildWarnMessage(messageId, warnResult));
+                //发给消息服务
+                warnResult.setWlBid(wlBid);
+                msgService.handleWarn(warnResult);
             } else {
                 log.info("【设备预警】消息标识{}:未达阈值, 增加重复次数", messageId);
                 iotWarnBussinessService.incrementReCount(reCount, warnResult);
@@ -115,6 +124,7 @@ public class ReCountService {
         iotWarnlog.setWlData(warnResult.getReportData());
         iotWarnlog.setTid(config.getTid());
         iotWarnlog.setWcBid(config.getWcBid());
+        iotWarnlog.setWlSendmsgstatus(WarnLogSendStatus.SEND_WAIT.getCode());
         log.info("【设备预警】消息标识{}:构建预警信息: {}", messageId, iotWarnlog);
         return iotWarnlog;
     }

+ 13 - 2
src/main/resources/application-dev.yml

@@ -52,6 +52,9 @@ user:
 
 # Spring配置
 spring:
+  autoconfigure:
+    exclude:
+      - org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration
   data:
     mongodb:
       uri: mongodb://root:Yf%40123456@192.168.1.228:57017/com_yunfeiyun_iot
@@ -141,7 +144,15 @@ spring:
       connection-timeout: 15000
       publisher-returns: true
       enabled: true
-
+    agmpIot:
+      host: 192.168.1.230
+      port: 5672
+      username: admin
+      password: admin
+      virtual-host: /agmp-saas
+      connection-timeout: 15000
+      publisher-returns: true
+      enabled: true
 
   # redis 配置
   redis:
@@ -280,4 +291,4 @@ map:
 
 #只允许在228机器上访问,其他环境不要配置
 warn:
-  cbdDateDiff: 0
+  cbdDateDiff: 0

+ 4 - 1
src/main/resources/application-prod.yml

@@ -52,6 +52,9 @@ user:
 
 # Spring配置
 spring:
+  autoconfigure:
+    exclude:
+      - org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration
   # 资源信息
   messages:
     # 国际化资源文件路径
@@ -261,4 +264,4 @@ weather:
 map:
   gaode:
     api: http://restapi.amap.com
-    key: 78ce288400f4fc6d9458989875c833c2
+    key: 78ce288400f4fc6d9458989875c833c2

+ 3 - 0
src/main/resources/application-test.yml

@@ -52,6 +52,9 @@ user:
 
 # Spring配置
 spring:
+  autoconfigure:
+    exclude:
+      - org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration
   data:
     mongodb:
       uri: mongodb://root:123456@127.0.0.1:27017/com_yunfeiyun_iot

+ 17 - 0
src/main/resources/mapper/IotWarnBusinessMapper.xml

@@ -22,6 +22,7 @@
             <if test="wlData != null">wlData,</if>
             <if test="tid != null and tid != ''">tid,</if>
             <if test="wcBid != null and wcBid != ''">wcBid,</if>
+            <if test="wlSendmsgstatus != null and wlSendmsgstatus != ''">wlSendmsgstatus,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="wlBid != null">#{wlBid},</if>
@@ -39,6 +40,7 @@
             <if test="wlData != null">#{wlData},</if>
             <if test="tid != null and tid != ''">#{tid},</if>
             <if test="wcBid != null and wcBid != ''">#{wcBid},</if>
+            <if test="wlSendmsgstatus != null and wlSendmsgstatus != ''">#{wlSendmsgstatus},</if>
         </trim>
     </insert>
     <insert id="insertIncrementReCount" parameterType="IotWarncount" useGeneratedKeys="true" keyProperty="id">
@@ -167,6 +169,9 @@
         where devBid = #{devBid} and wlType='1' and status='0'
 
     </update>
+    <update id="updateWarnLogSendStatus">
+        update IotWarnlog set wlSendmsgstatus=#{status},wlSendmsgtime=#{time}  where wlBid=#{wlBid}
+    </update>
 
     <select id="selectIotWarnconfigCbdDevList" resultType="com.yunfeiyun.agmp.iots.warn.model.IotWarnconfigDevVo">
         SELECT wi.wiBid, d.devBid, d.devCode, d.devtypeBid, d.devCbdrecogtype, wc.*
@@ -238,4 +243,16 @@
     <select id="selectDeviceById" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDevice">
         select * from IotDevice where devBid=#{devBid}
     </select>
+    <select id="selectWarnPolicy" resultType="com.yunfeiyun.agmp.iot.common.domain.IotWarnpolicy">
+        select *
+        from IotWarnpolicy
+        where wcBid = #{configId}
+    </select>
+    <select id="selectWarnReceiverByConfigId"
+            resultType="com.yunfeiyun.agmp.iot.common.domain.IotWarnreceiver">
+        select * from IotWarnreceiver where wcBid = #{configId}
+    </select>
+    <select id="getLastedUnSendWarnLog" resultType="com.yunfeiyun.agmp.iot.common.domain.IotWarnlog">
+        select * from IotWarnlog where wcBid = #{wcBid} and wlSendmsgstatus = "1" order by wlCreateddate desc limit 1
+    </select>
 </mapper>