/// <summary>
            /// 处理报警逻辑(汉王数据接入使用)
            /// 1.是否命中报警策略
            /// 2.记录流水
            /// 3.发送消息
            /// </summary>
            /// <param name="deviceInfo"></param>
            /// <param name="itemInfo"></param>
            /// <param name="curValue"></param>
            /// <param name="now"></param>
            /// <returns></returns>
            private Task <int> HandleAlarmPolicies1(RetDeviceInfo deviceInfo, RetDeviceItemInfo itemInfo, string curValue, DateTime now)
            {
                int result = -1;

                using (AlertPoliciesEntities alert = new AlertPoliciesEntities())
                {
                    var alertInfo = alert.A_AlarmStrategy.Where(s => (s.DeviceID == deviceInfo.ID) && (s.DeviceItemId == itemInfo.ID) && (s.Active == true)).FirstOrDefault();
                    if (null != alertInfo)
                    {
                        if (isHitPolicies(curValue, alertInfo.Compare, alertInfo.Threshold))
                        {
                            log.InfoFormat("[MQTT]Hit Policies,topic:{0}/{1},curValue:{2},compare:{3},theshold:{4}.", deviceInfo.DeviceLabel, itemInfo.PropertyLabel, curValue, alertInfo.Compare, alertInfo.Threshold);
                            HistoryAlertPoliciesBLL   historyBLL = new HistoryAlertPoliciesBLL();
                            HistoryAlertPoliciesModel model      = new HistoryAlertPoliciesModel()
                            {
                                DeviceID     = deviceInfo.ID.ToString(),
                                DeviceItemID = itemInfo.ID.ToString(),
                                StrategyID   = alertInfo.ID.ToString(),
                                Value        = curValue,
                                AlarmTime    = now,
                                EndTime      = now.AddSeconds(1),
                                OrgID        = alertInfo.OrgID.ToString(),
                            };
                            historyBLL.AddHistoryAlertPolicies(model);
                            // 发送消息通知
                            UserApi api = new UserApi();
                            GetMessageInfoParameter messageModel = new GetMessageInfoParameter()
                            {
                                Type   = "2", // 报警预警
                                Tittle = "【设备报警通知】" + deviceInfo.Name + itemInfo.Name + "报警!",
                                Text   = "<p>您好:</p><p class='ql-indent-1'>" + deviceInfo.Name + "(设备)" + itemInfo.Name + "(属性)当前数值为" + curValue + ",已触发预设报警策略,请及时处理异常!</p><p><br></p><p class='ql-align-right'>设备在线监测平台</p>",
                                OrgID  = alertInfo.OrgID.ToString()
                            };

                            var userApi = api.AddAlarmMessage(messageModel);
                            if (userApi.Code != 0)
                            {
                                log.ErrorFormat(userApi.Data);
                            }
                        }
                    }
                }
                return(new Task <int>(() => result));
            }