Exemplo n.º 1
0
        /// <summary>
        /// 自定义消息推送
        /// </summary>
        public static void  AddAlarmWindow(FireControl_AlarmWindow model)
        {
            //添加弹窗window
            FireControl_AlarmWindowBLL alarmWinBLL = new FireControl_AlarmWindowBLL();

            model.AWID = CommHelper.CreatePKID("aw");
            var stateResult = alarmWinBLL.AddObj(model);

            if (stateResult.ResultCode == ResultCode.Succ)
            {
                Dictionary <string, string> dic1 = new Dictionary <string, string>();
                dic1.Add("type", "9");
                dic1.Add("cucode", model.UserID);
                dic1.Add("content", "消息");
                dic1.Add("title", "消息");
                dic1.Add("msgid", model.RecordID);
                dic1.Add("application", "8");
                dic1.Add("platformType", "0");
                dic1.Add("isCustomMsg", "1");
                new Task(() =>
                {
                    HttpSend.GetByRequest(JGApi, dic1, null, true);
                }).Start();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// P1新版极光推送
        /// </summary>
        /// <param name="UserModel">用户基础信息</param>
        /// <param name="TitleID">消息ID</param>
        /// <param name="NewType">消息类型 1 燃起烟感报警 6电气报警</param>
        /// <param name="DevName"></param>
        public static void APPPush(People UserModel, string TitleID, string NewType, string DevName, string DevID)
        {//目前推送智慧给自己推送
         //添加推送记录
            var content = $"紧急通知!您的{DevName}设备发生报警,地址{UserModel.Province + UserModel.City + UserModel.Area + UserModel.VillageName},请尽快处理";
            FireControl_PushRecordBLL pushReBLL = new FireControl_PushRecordBLL();
            FireControl_PushRecord    pushRe    = new FireControl_PushRecord();

            pushRe.DevID    = DevID;
            pushRe.Message  = content;
            pushRe.Phone    = UserModel.Phone;
            pushRe.PRID     = CommHelper.CreatePKID("fr");
            pushRe.SendType = 1;
            pushRe.TitleID  = TitleID;
            pushRe.UserID   = UserModel.UserID;
            pushReBLL.AddObj(pushRe);
            Dictionary <string, string> dic1 = new Dictionary <string, string>();

            dic1.Add("content", content);
            dic1.Add("title", "设备报警");
            dic1.Add("type", NewType); //1为烟感燃气 6为电气
            dic1.Add("msgid", TitleID);
            dic1.Add("cucode", UserModel.UserID);
            dic1.Add("application", "8");
            dic1.Add("platformType", "3");
            dic1.Add("isCustomMsg", "0");
            Utility.WriteLog("极光--1推----" + UserModel.UserID + UserModel.Phone);
            new Task(() =>
            {
                HttpSend.GetByRequest(JGApi, dic1, null, true);
            }).Start();
            //添加极光推送记录
            if (NewType == "6")
            {
                FireControl_WarninsHandleBLL WHandBLL = new FireControl_WarninsHandleBLL();
                //报警推送记录
                List <FireControl_WarninsHandle> InsertModle = new List <FireControl_WarninsHandle>();
                FireControl_WarninsHandle        SecondModel = new FireControl_WarninsHandle();
                SecondModel.Content    = $"报警已推送给{(string.IsNullOrWhiteSpace(UserModel.Name) ? UserModel.Phone : UserModel.Name)}";
                SecondModel.CreateTime = DateTime.Now;
                SecondModel.Deleted    = 0;
                SecondModel.CreatedBy  = "0";
                SecondModel.HandlD     = CommHelper.CreatePKID("hd");
                SecondModel.Hand_Date  = DateTime.Now.AddSeconds(1);
                SecondModel.Title      = $"报警推送";;
                SecondModel.TitleID    = TitleID;
                SecondModel.UserID     = "0"; //初次报警 0代表系统
                SecondModel.Hand_Mode  = 0;
                SecondModel.Hand_Type  = 0;
                InsertModle.Add(SecondModel);
                var ss = WHandBLL.AddAllObj(InsertModle);
                Utility.WriteLog("消息处理:" + ss.ResultContent);
            }
        }
Exemplo n.º 3
0
        private void AddMpArTable(string data, string DevNum)
        {
            FireControl_MpArTable_BLL MpBll = new FireControl_MpArTable_BLL();

            REG.N6.IFT.TwpFControl.Model.ResultDis <bool> Waterresult = null;
            FireControl_MpArTable info = new FireControl_MpArTable();

            info.AccID      = CommHelper.CreatePKID("acc");
            info.RawData    = data;
            info.ReportDate = DateTime.MinValue;
            info.DevNum     = DevNum;
            //保存传入数据                   //修改
            info.CreateTime = DateTime.Now;
            //判断是否有这条消息
            Waterresult = MpBll.AddObj(info);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 推送
 /// </summary>
 /// <param name="Phone"></param>
 /// <param name="userName"></param>
 /// <param name="type">类型 1业主打电话 2给互助联系人 </param>
 /// <param name="address"></param>
 /// NewType 消息类型 1 燃起烟感报警 6电气报警
 public static void PublicPush(string Phone, string userName, string type, string address, string DivName, string title, string content, string cucode, string BeUserID = "", string titleID = "", string NewType = "1")
 {//目前推送智慧给自己推送
     if (type == "1")
     {
         FireControl_WarninsHandleBLL WHandBLL = new FireControl_WarninsHandleBLL();
         Utility.WriteLog("极光--1----");
         Dictionary <string, string> dic1 = new Dictionary <string, string>();
         dic1.Add("content", content);
         dic1.Add("title", title);
         dic1.Add("type", NewType);
         dic1.Add("msgid", titleID);
         dic1.Add("cucode", BeUserID);
         dic1.Add("application", "8");
         dic1.Add("platformType", "3");
         dic1.Add("isCustomMsg", "0");
         Utility.WriteLog("极光--1推----" + BeUserID);
         new Task(() =>
         {
             HttpSend.GetByRequest(JGApi, dic1, null, true);
         }).Start();
         if (NewType == "6")
         {
             //报警推送记录
             List <FireControl_WarninsHandle> InsertModle = new List <FireControl_WarninsHandle>();
             FireControl_WarninsHandle        SecondModel = new FireControl_WarninsHandle();
             SecondModel.Content    = $"报警已推送给{(string.IsNullOrWhiteSpace(userName) ? Phone : userName)}";
             SecondModel.CreateTime = DateTime.Now;
             SecondModel.Deleted    = 0;
             SecondModel.CreatedBy  = "0";
             SecondModel.HandlD     = CommHelper.CreatePKID("hd");
             SecondModel.Hand_Date  = DateTime.Now.AddSeconds(1);
             SecondModel.Title      = $"报警推送";;
             SecondModel.TitleID    = titleID;
             SecondModel.UserID     = "0"; //初次报警 0代表系统
             SecondModel.Hand_Mode  = 0;
             SecondModel.Hand_Type  = 0;
             InsertModle.Add(SecondModel);
             var ss = WHandBLL.AddAllObj(InsertModle);
             Utility.WriteLog("消息处理:" + ss.ResultContent);
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 报警消息处理记录
        /// </summary>
        /// <param name="TitleID">消息id</param>
        /// <param name="deviceType">设备类型</param>
        /// <param name="address">报警地址</param>
        /// <param name="FriendNames">关联好友</param>
        private static void AddPusUserFirst(string TitleID, int deviceType, string address, string FriendNames, string UserName)
        {
            List <FireControl_WarninsHandle> InsertModle = new List <FireControl_WarninsHandle>();
            FireControl_WarninsHandleBLL     WHandBLL    = new FireControl_WarninsHandleBLL();
            //初次报警记录
            FireControl_WarninsHandle Model = new FireControl_WarninsHandle();

            Model.Content    = address + $"的{ConvertControlType.ConvertNameString(deviceType)}发生报警";
            Model.CreateTime = DateTime.Now;
            Model.Deleted    = 0;
            Model.CreatedBy  = "0";
            Model.HandlD     = CommHelper.CreatePKID("hd");;
            Model.Hand_Date  = DateTime.Now;
            Model.Title      = $"{ConvertControlType.ConvertNameString(deviceType)}发生报警";;
            Model.TitleID    = TitleID;
            Model.UserID     = "0"; //初次报警 0代表系统
            Model.Hand_Mode  = 0;
            Model.Hand_Type  = 0;
            InsertModle.Add(Model);
            //报警推送记录
            FireControl_WarninsHandle SecondModel = new FireControl_WarninsHandle();

            SecondModel.Content    = $"报警已推送给{UserName},{(FriendNames != "" ? "和" + FriendNames : "")}";
            SecondModel.CreateTime = Model.Hand_Date.AddSeconds(1);
            SecondModel.Deleted    = 0;
            SecondModel.CreatedBy  = "0";
            SecondModel.HandlD     = CommHelper.CreatePKID("hd");;
            SecondModel.Hand_Date  = Model.Hand_Date.AddSeconds(1);
            SecondModel.Title      = $"报警推送";;
            SecondModel.TitleID    = TitleID;
            SecondModel.UserID     = "0"; //初次报警 0代表系统
            SecondModel.Hand_Mode  = 0;
            SecondModel.Hand_Type  = 2;
            InsertModle.Add(SecondModel);
            var ss = WHandBLL.AddAllObj(InsertModle);

            Utility.WriteLog("消息处理:" + ss.ResultContent);
        }
Exemplo n.º 6
0
        public ResponseJson <bool> GetCallThePoliceData([FromBody] sdfsdfsdf jitem)//JObject jObject
        {
            string userIP;
            // HttpRequest Request = HttpContext.Current.Request;
            HttpRequest Request = System.Web.HttpContext.Current.Request; // 如果使用代理,获取真实IP

            if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "")
            {
                userIP = Request.ServerVariables["REMOTE_ADDR"];
            }
            else
            {
                userIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            }
            if (userIP == null || userIP == "")
            {
                userIP = Request.UserHostAddress;
            }

            string userIP1 = HttpContext.Current.Request.UserHostAddress;

            Utility.WriteLog("请求GetCallThePoliceData的访问者ip------------" + userIP + "----------------------------" + userIP1);

            ResponseJson <bool> json   = null;
            ResultDis <bool>    result = null;

            try
            {
                //1.根据设备编号获取设备基本信息(判断该设备是否是我们的设备)
                FireControl_DeviceBLL      dll        = new FireControl_DeviceBLL();
                FireControl_DevBindUserBLL devUserdll = new FireControl_DevBindUserBLL();
                FireControl_WarninsPush    model      = new FireControl_WarninsPush();
                //JToken jitem = "";
                //foreach (var a in jObject.Children())
                //{

                //    //if (string.IsNullOrEmpty(a.Next.n))
                //    //{
                //    //    jitem = a.Value;
                //    //}
                //    //else
                //    //{
                //    //    jitem = a.Key;
                //    //}
                //}
                //Utility.WriteLog(jitem.ToString());

                string  jsons = JsonConvert.SerializeObject(jitem);
                JObject jo    = JObject.Parse(jsons);

                //添加记录
                AddMpArTable(jitem.ToString(), jo["DevNum"].ToString());
                model.SeqNum           = 0;
                model.TitleID          = "";
                model.NewTitle         = "";
                model.NewContent       = "";
                model.PushDate         = DateTime.Now;
                model.DevID            = "";
                model.WarInAdress      = "";
                model.WarIn_Type       = 0;
                model.CreateTime       = DateTime.Now;
                model.CreatedBy        = "";
                model.Deleted          = 0;
                model.PushState        = string.IsNullOrEmpty(jo["PushState"].ToString()) ? "" : jo["PushState"].ToString();
                model.WarninsState     = "1";
                model.WarninsRepresent = string.IsNullOrEmpty(jo["WarninsRepresent"].ToString()) ? "" : jo["WarninsRepresent"].ToString();
                model.WarninsVoltage   = string.IsNullOrEmpty(jo["WarninsVoltage"].ToString()) ? "" : Convert.ToString(Convert.ToDouble(jo["WarninsVoltage"].ToString()));
                model.WarninsCurrent   = string.IsNullOrEmpty(jo["WarninsCurrent"].ToString()) ? "" : Convert.ToString(Convert.ToDouble(jo["WarninsCurrent"].ToString()));
                model.WarninsTemper    = string.IsNullOrEmpty(jo["WarninsTemper"].ToString()) ? "" : Convert.ToString(Convert.ToDouble(jo["WarninsTemper"].ToString()));
                model.WarninsTemper2   = string.IsNullOrEmpty(jo["WarninsTemper2"].ToString()) ? "" : Convert.ToString(Convert.ToDouble(jo["WarninsTemper2"].ToString()));
                model.WarninsArc       = string.IsNullOrEmpty(jo["WarninsArc"].ToString()) ? "" : jo["WarninsArc"].ToString();
                model.Warninsleakage   = string.IsNullOrEmpty(jo["Warninsleakage"].ToString()) ? "" : jo["Warninsleakage"].ToString();
                model.DevNum           = string.IsNullOrEmpty(jo["DevNum"].ToString()) ? "" : jo["DevNum"].ToString();
                if (!string.IsNullOrEmpty(model.DevNum))
                {
                    string AddressID  = "";
                    string recordID   = string.Empty;
                    string DevTypeNum = string.Empty;
                    #region 将告警信息插入到数据库
                    ResultDis <FireControl_Device> item = dll.GetDevIDByDevNum(model.DevNum);

                    if (item.ResultData != null && item.ResultCode == ResultCode.Succ)
                    {
                        FireControl_DeviceTypeBLL          _DeviceTypeBLL = new FireControl_DeviceTypeBLL();
                        ResultDis <FireControl_DeviceType> dis            = _DeviceTypeBLL.GetObjByDeviceID(item.ResultData.DevID);
                        if (dis.ResultCode == ResultCode.Succ)
                        {
                            DevTypeNum = dis.ResultData.TypeNum;
                        }
                        if (item.ResultData.ValidDate < DateTime.Now)//过期时间大于当前时间)
                        {
                            Utility.WriteLog("设备已过期,设备编号为:" + model.DevNum);
                            json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                            return(json);
                        }
                        //判断设备是否正在报警
                        FireControl_WarninsPushBLL pushBll = new FireControl_WarninsPushBLL();
                        //  model.DevNum
                        var OldData = pushBll.SelectNotCloseState(item.ResultData.DevID, "1", model.PushState);
                        if (OldData.ResultCode == ResultCode.Succ && !string.IsNullOrWhiteSpace(OldData.ResultData.DevID))
                        {
                            if (item.ResultData.DeviceState == 1)
                            {
                                Utility.WriteLog("设备继续报警:" + model.DevNum);
                                json = new ResponseJson <bool>(ResponseCode.Nomal, "继续报警");
                                return(json);
                            }
                            else
                            {
                                item.ResultData.DeviceState = 1;
                                FireControl_DeviceBLL devdlle = new FireControl_DeviceBLL();
                                ResultDis <bool>      dis1    = devdlle.ModObj(item.ResultData);
                                if (dis1.ResultCode == ResultCode.Succ)
                                {
                                    Utility.WriteLog("设备继续报警,但状态刚才是正常----修改状态成功:" + model.DevNum);
                                }
                                Utility.WriteLog("设备继续报警,但状态刚才是正常:" + model.DevNum);
                                json = new ResponseJson <bool>(ResponseCode.Nomal, "继续报警");
                                return(json);
                            }
                        }
                        FireControl_FaultSolution_BLL         fabll = new FireControl_FaultSolution_BLL();
                        ResultDis <FireControl_FaultSolution> list  = fabll.GetListByCode(model.PushState);
                        //1.接收故障信息存入数据库
                        model.NewTitle   = list.ResultData.FaultName;
                        model.NewContent = list.ResultData.Causes;
                        model.PushDate   = DateTime.Now;
                        model.DevID      = item.ResultData.DevID;
                        model.TitleID    = CommHelper.CreatePKID("tit");
                        //根据设备ID获取我的设备绑定地址
                        ResultDis <GetDevPeopleUser> usermodel = devUserdll.GetDevPeople(model.DevID);
                        //修改设备状态为报警状态
                        item.ResultData.DeviceState = 1;
                        FireControl_DeviceBLL devdll = new FireControl_DeviceBLL();
                        devdll.ModObj(item.ResultData);

                        if (!string.IsNullOrWhiteSpace(usermodel.ResultData.AddressID))
                        {
                            AddressID = usermodel.ResultData.AddressID;
                            #region 添加处理流程数据
                            FireControl_WarninsHandleBLL clbll  = new FireControl_WarninsHandleBLL();
                            FireControl_WarninsHandle    handle = new FireControl_WarninsHandle();
                            handle.HandlD     = CommHelper.CreatePKID("han");
                            handle.Title      = "电气设备发生报警";
                            handle.Content    = usermodel.ResultData.Address + "的电气设备发生报警";
                            handle.TitleID    = model.TitleID;
                            handle.Hand_Type  = 0;
                            handle.UserID     = usermodel.ResultData.UserID;
                            handle.Hand_Mode  = 0;
                            handle.Hand_Date  = DateTime.Now;
                            handle.CreateTime = DateTime.Now;
                            handle.CreatedBy  = "System";
                            handle.Deleted    = 0;
                            clbll.AddObj(handle);
                            #endregion
                            if (usermodel.ResultData != null)
                            {
                                model.WarInAdress = usermodel.ResultData.Address;
                            }
                            model.WarIn_Type = 1;
                            model.CreateTime = DateTime.Now;
                            model.CreatedBy  = "System";
                            model.Deleted    = 0;
                            model.AddressID  = usermodel.ResultData.AddressID;
                            FireControl_WarninsPushBLL push = new FireControl_WarninsPushBLL();
                            result = push.AddObj(model, out recordID);
                            if (result.ResultCode == ResultCode.Succ)
                            {
                                json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                            }
                            else
                            {
                                Utility.WriteLog("设备报警记录添加失败:" + model.DevNum);
                                json = new ResponseJson <bool>(ResponseCode.Err, result.ResultContent);
                            }

                            #region 向客户发推送故障消息
                            var PeopleModel = usermodel.ResultData;
                            #region 推送入库
                            FireControl_PushProcess FireControl_PushProcessModel = new FireControl_PushProcess();
                            FireControl_PushProcessModel.CreateTime = DateTime.Now;
                            FireControl_PushProcessModel.DevID      = model.DevID;
                            FireControl_PushProcessModel.DevName    = "电气";
                            FireControl_PushProcessModel.isPush     = 0;
                            FireControl_PushProcessModel.PPID       = CommHelper.CreatePKID("pp");
                            FireControl_PushProcessModel.TitleID    = model.TitleID;
                            FireControl_PushProcessBLL proBll = new FireControl_PushProcessBLL();
                            var proResult = proBll.AddObj(FireControl_PushProcessModel);
                            if (proResult.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                            {
                                Utility.WriteLog("消息保存推送成功---------------------xxxxx--------");
                            }
                            else
                            {
                                Utility.WriteLog("保存推送失败-----------------------------");
                            }

                            #endregion
                            #endregion

                            #region 将推送消息添加到推送记录表
                            //添加推送记录表
                            //FireControl_WarninsPUserBLL puBll = new FireControl_WarninsPUserBLL();
                            //var Model = new FireControl_WarninsPUser();
                            //Model.CreatedBy = "0";
                            //Model.CreateTime = DateTime.Now;
                            //Model.Deleted = 0;
                            //Model.PUID = CommHelper.CreatePKID("pu");
                            //Model.TitleID = model.TitleID;// TitleID;
                            //Model.UserID = usermodel.ResultData.UserID;
                            //Model.UserPhone = usermodel.ResultData.Phone;
                            //puBll.AddObj(Model);
                            #endregion

                            #region //同步到设备管理api
                            EMModel eMModel = new EMModel();
                            eMModel.deviceNumber     = model.DevNum;
                            eMModel.deviceTypeNumber = DevTypeNum;
                            eMModel.recordID         = string.IsNullOrEmpty(recordID) ? "1111111111111" : recordID;
                            if (!string.IsNullOrEmpty(AddressID))
                            {
                                eMModel.unitID = EMApi.GetCommunityIDByADID(AddressID);
                            }
                            EMApi.SendEM_Alert(eMModel);
                            #endregion
                        }
                        else
                        {
                            Utility.WriteLog("地址不存在,设备编号为:" + model.DevNum);
                            json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                        }
                    }
                    else
                    {
                        Utility.WriteLog("在获取装备告警信息时,未能在全民消防数据库中查到该设备,设备编号为:" + model.DevNum);
                        json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                    }
                    #endregion
                }
                else
                {
                    Utility.WriteLog("在获取装备告警信息时,未能在全民消防数据库中查到该设备,设备编号为:" + model.DevNum);
                    json = new ResponseJson <bool>(ResponseCode.Nomal, "添加成功");
                }
            }
            catch (Exception ex)
            {
                ex.WriteErrLog();
                Utility.WriteLog(ex.Message);
                json = new ResponseJson <bool>(ResponseCode.Err, ex.Message);
                //log.Error("", ex);
            }
            return(json);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 判断
        /// </summary>ACID 消息记录id
        private static void JudgementAlarm(ReceiveData info, int deviceType, string ACID)
        {
            try
            {
                Utility.WriteLog("开始---------------------------------1--------");
                if (info.Bodydata != null)
                {
                    FireControl_DeviceBLL      buildDeviceBLL = new FireControl_DeviceBLL();
                    FireControl_DevBindUserBLL DevBinBll      = new FireControl_DevBindUserBLL();
                    REG.N6.IFT.TwpFControl.Model.ResultDis <FireControl_Device> resultDevice = null;
                    //1、 根据设备编号 查询设备    //修改
                    resultDevice = buildDeviceBLL.GetDevIDByDevNum(info.IMEI);
                    FireControl_Device buildDevice = new FireControl_Device();
                    if (resultDevice.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                    {
                        Utility.WriteLog("该设备在数据库中存在,设备IMEI为:" + info.IMEI);
                        buildDevice = resultDevice.ResultData;
                    }
                    if (buildDevice != null && !string.IsNullOrEmpty(buildDevice.DevID))
                    {  //警情记录id  同步设备管理系统用
                        string recordID              = string.Empty;
                        string AddressID             = "";
                        FireControl_DeviceBLL DevBLL = new FireControl_DeviceBLL();
                        if (info.Bodydata.AlarmStatus == "01")//判断设备是否报警
                        {
                            Utility.WriteLog("该设备发生报警,设备IMEI为" + info.IMEI);
                            //8燃气 7烟感
                            //查询是否该设备已经有未关闭的报警消息
                            FireControl_WarninsPushBLL pushBll = new FireControl_WarninsPushBLL();
                            var Result = pushBll.SelectNotClose(buildDevice.DevID, Dictoary.Warnin_Warning.ToString());
                            if (Result.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                            {
                                var PushModel = Result.ResultData;
                                if (PushModel != null && !string.IsNullOrWhiteSpace(PushModel.TitleID) && PushModel.WarIn_Type == Dictoary.Warnin_Warning)
                                {
                                    //有报警的消息记录
                                    Utility.WriteLog($"还在报警报警的消息记录id{PushModel.TitleID}---------------------------------2--------");
                                    Utility.WriteLog("//////////////////////////正常结束//////////////////////");
                                    return;
                                }
                            }
                            ///查询该设备是否在报警但消音
                            var SilencingResult = pushBll.SelectNotClose(buildDevice.DevID, Dictoary.Warnin_Silencing.ToString());
                            if (SilencingResult.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                            {
                                var PushModel = SilencingResult.ResultData;
                                if (PushModel != null && !string.IsNullOrWhiteSpace(PushModel.TitleID) && PushModel.WarIn_Type == Dictoary.Warnin_Silencing)
                                {
                                    //有报警的消息记录
                                    Utility.WriteLog($"还在报警但是已经消音了{PushModel.TitleID}---------------------------------2--------");
                                    Utility.WriteLog("把状态改为报警,添加一条处理记录");
                                    //改为报警状态  并增加报警推送记录
                                    PushModel.WarIn_Type = 1;//报警  警情状态 0正常 1报警 2已正常未关闭 3报警但消音
                                    pushBll.ModObj(PushModel.TitleID, "设备报警", "设备继续报警", "0", 1);
                                    Utility.WriteLog("结束");
                                    return;
                                }
                            }
                            //查询设备对应的人员和地址id和地址详细

                            var PeopleResult = DevBinBll.GetDevPeople(buildDevice.DevID);
                            if (PeopleResult.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                            {
                                AddressID = PeopleResult.ResultData.AddressID;
                                var People = PeopleResult.ResultData;
                                if (string.IsNullOrWhiteSpace(People.AddressID))
                                {
                                    Utility.WriteLog("该设备的地址为空人员为:---------------------------------3--------" + People.UserName + People.Phone);
                                    Utility.WriteLog("正常结束");
                                    return;
                                }
                                //给用户发送推送  告警
                                //先获取到消息id
                                var TitleID = CommHelper.CreatePKID("tit");
                                #region 添加主消息记录
                                var PushModel = new REG.N6.IFT.TwpFControl.Model.FireControl_WarninsPush();
                                PushModel.CreateTime   = DateTime.Now;
                                PushModel.PushDate     = DateTime.Now;
                                PushModel.Deleted      = 0;
                                PushModel.CreatedBy    = "0";
                                PushModel.TitleID      = TitleID;
                                PushModel.DevID        = buildDevice.DevID;
                                PushModel.NewContent   = "消息详情";
                                PushModel.NewTitle     = buildDevice.DevName + "发生报警";
                                PushModel.WarInAdress  = People.Address;
                                PushModel.WarIn_Type   = 1;     //消息报警开启
                                PushModel.WarninsState = "1";
                                PushModel.RecordValue  = "100"; //假值 目前只有公司燃气存在浓度
                                PushModel.AddressID    = AddressID;
                                var sp = pushBll.AddObj(PushModel, out recordID);
                                if (sp.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                                {
                                    Utility.WriteLog("主报警消息保存成功---------------------zzzz--------");
                                    //添加敬请消息处理记录 设备报警 推送人员记录
                                    var PeopleName = "";
                                    if (People.PeopleList != null && People.PeopleList.Any())
                                    {
                                        PeopleName = string.Join(",", People.PeopleList.Where(f => f != null).Where(f => !string.IsNullOrWhiteSpace(f.FriendName)).Distinct()?.Select(f => f.FriendName).Distinct().ToList());
                                    }
                                    AddPusUserFirst(recordID, deviceType, People.Address, PeopleName, People.UserName);

                                    FireControl_PushProcess FireControl_PushProcessModel = new FireControl_PushProcess();
                                    FireControl_PushProcessModel.CreateTime = DateTime.Now;
                                    FireControl_PushProcessModel.DevID      = buildDevice.DevID;
                                    FireControl_PushProcessModel.DevName    = buildDevice.DevName;
                                    FireControl_PushProcessModel.isPush     = 0;
                                    FireControl_PushProcessModel.PPID       = CommHelper.CreatePKID("pp");
                                    FireControl_PushProcessModel.TitleID    = TitleID;
                                    FireControl_PushProcessBLL proBll = new FireControl_PushProcessBLL();
                                    var proResult = proBll.AddObj(FireControl_PushProcessModel);
                                    if (proResult.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                                    {
                                        Utility.WriteLog("消息保存推送成功---------------------xxxxx--------");
                                    }
                                    else
                                    {
                                        Utility.WriteLog("保存推送失败-----------------------------");
                                    }
                                    //进行推送 推送
                                    // AlarmPush.Send(People, buildDevice.DevName, recordID, buildDevice.DevID);
                                }
                                else
                                {
                                    Utility.WriteLog("消息保存失败---------------------xxxxx--------");
                                }
                                #endregion
                            }
                            else
                            {
                                Utility.WriteLog("未找到该设备对应的人员---------------------zzzz--------");
                            }
                            #region //同步到设备管理api
                            EMModel eMModel = new EMModel();
                            eMModel.deviceNumber     = buildDevice.DevNum;
                            eMModel.deviceTypeNumber = buildDevice.TypeID;
                            if (!string.IsNullOrEmpty(AddressID))
                            {
                                eMModel.unitID = EMApi.GetCommunityIDByADID(AddressID);
                            }
                            eMModel.recordID = string.IsNullOrEmpty(recordID) ? "1111111111111" : recordID;
                            EMApi.SendEM_Alert(eMModel);
                            #endregion
                        }
                        else if (info.Bodydata.AlarmStatus == "02")
                        {
                            Utility.WriteLog("设备消音----********************************--------");
                        }
                        else if (info.Bodydata.AlarmStatus == "04")
                        {
                            var PeopleResult = DevBinBll.GetDevPeople(buildDevice.DevID);
                            if (PeopleResult.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                            {
                                var People = PeopleResult.ResultData;
                                if (string.IsNullOrWhiteSpace(People.AddressID))
                                {
                                    Utility.WriteLog("该设备的地址为空人员为:---------------------------------3--------" + People.UserName + People.Phone);
                                    Utility.WriteLog("正常结束");
                                    return;
                                }
                                AlarmPush.PublicPush("", People.UserName, "1", People.Address, buildDevice.DevName, "设备故障", $"紧急通知!您的{buildDevice.DevName}发生故障告警,地址{People.Address},请尽快处理!", "", People.UserID, "0", "7");
                            }


                            Utility.WriteLog("设备信号异常----********************************--------");
                        }
                        else if (info.Bodydata.AlarmStatus == "05")
                        {
                            Utility.WriteLog("设备自检----********************************--------");
                        }
                        else
                        {
                            //查询该设备是否有未关闭的消息记录
                            //如果存在未关闭的消息 此时 添加关闭消息记录并 修改该消息状态
                            FireControl_WarninsPushBLL pushBll = new FireControl_WarninsPushBLL();
                            var Result = pushBll.SelectNotClose(buildDevice.DevID, "1");
                            if (Result.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ && Result.ResultData != null)
                            {
                                var PushModel = Result.ResultData;
                                if (PushModel == null || string.IsNullOrWhiteSpace(PushModel.TitleID))
                                {
                                    //没有未关闭的消息
                                    //做什么处理后序添加
                                    Utility.WriteLog("设备一直很正常....");
                                }
                                else
                                {
                                    Utility.WriteLog("设备变正常");
                                    //该设备有未关闭和未消音的消息
                                    PushModel.WarIn_Type = 2;                                     //设备消音
                                    pushBll.ModObj(PushModel.TitleID, "设备已正常", "设备报警解除", "0", 2); //该方法内置添加消息处理操作

                                    #region 修改设备状态  同步到设备管理系统
                                    DevStateModel devState = new DevStateModel();
                                    devState.deviceNumber = buildDevice.DevNum;
                                    devState.recordID     = PushModel.TitleID;

                                    FireControl_DeviceTypeBLL _DeviceTypeBLL = new FireControl_DeviceTypeBLL();
                                    REG.N6.IFT.TwpFControl.Model.ResultDis <FireControl_DeviceType> dis = _DeviceTypeBLL.GetObjByDeviceID(buildDevice.DevID);
                                    if (dis.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                                    {
                                        devState.deviceTypeNumber = dis.ResultData.TypeNum;
                                    }

                                    EMApi.SendEM_UpdateDevState(devState);
                                    #endregion
                                }
                            }
                            else
                            {
                                var ResultXYin = pushBll.SelectNotClose(buildDevice.DevID, "3");//消音过得设备
                                if (Result.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                                {
                                    var PushModel = Result.ResultData;
                                    if (PushModel != null && string.IsNullOrWhiteSpace(PushModel.TitleID))
                                    {
                                        //有设备消音记录
                                        Utility.WriteLog("设备变正常");
                                        //该设备有未关闭和未消音的消息
                                        PushModel.WarIn_Type = 2;                                     //设备消音
                                        pushBll.ModObj(PushModel.TitleID, "设备已正常", "设备报警解除", "0", 2); //该方法内置添加消息处理操作
                                        #region 修改设备状态  同步到设备管理系统
                                        DevStateModel devState = new DevStateModel();
                                        devState.deviceNumber = buildDevice.DevNum;
                                        devState.recordID     = PushModel.TitleID;
                                        FireControl_DeviceTypeBLL _DeviceTypeBLL = new FireControl_DeviceTypeBLL();
                                        REG.N6.IFT.TwpFControl.Model.ResultDis <FireControl_DeviceType> dis = _DeviceTypeBLL.GetObjByDeviceID(buildDevice.DevID);
                                        if (dis.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                                        {
                                            devState.deviceTypeNumber = dis.ResultData.TypeNum;
                                        }
                                        EMApi.SendEM_UpdateDevState(devState);
                                        #endregion
                                    }
                                }
                                else
                                {
                                    Utility.WriteLog("无该设备的报警消息");
                                }
                            }

                            Utility.WriteLog("设备正常未报警");
                        }
                    }
                    else
                    {
                        Utility.WriteLog("没有该设备或设备未入库:" + info.IMEI);
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.WriteLog(ex.Message);
                Utility.WriteLog("//////////////////////////异常结束//////////////////////");
            }
            Utility.WriteLog("//////////////////////////正常结束//////////////////////");
        }
Exemplo n.º 8
0
        private static string JGApi = ConfigurationManager.AppSettings["JGCHApi"].ToString();//修改为公司统一API
        /// <summary>
        /// 提醒
        /// </summary>
        /// <param name="People">人员信息</param>
        /// <param name="DevName">设备名称</param>
        /// <param name="TitleID">消息推送主id</param>
        /// <param name="DevID">设备ID</param> 2019年9月16日16:29:06 增加
        ///
        public static void Send(GetDevPeopleUser People, string DevName, string TitleID, string DevID)//
        {
            FireControl_WarninsPUserBLL puBll = new FireControl_WarninsPUserBLL();

            var indexF  = People.Address.IndexOf(People.Area) + People.Area.Length;
            var Address = People.Address.Substring(indexF);

            Utility.WriteLog("给业主发进行三种推送-----------------------------------------" + People.Phone + Address + People.UserName + DevName);
            #region 处理业主推送
            //   var Content = $"紧急通知!您的{DevName}发生报警,地址{People.Address},请尽快处理!";
            // 燃气报警 烟感报警
            var PeopleModel = new People();
            PeopleModel.Name        = People.UserName;
            PeopleModel.Phone       = People.Phone;
            PeopleModel.Province    = People.Province;
            PeopleModel.StreetName  = People.StreetName;
            PeopleModel.Address     = People.Address;
            PeopleModel.Area        = People.Area;
            PeopleModel.City        = People.City;
            PeopleModel.VillageName = People.VillageName;
            PeopleModel.UserID      = People.UserID;
            GetPushStr(PeopleModel, DevID, TitleID);
            //新短信模板   T170317005189     [address]的[DevName][PushName],友情提示[Message]
            #endregion
            //紧急联系人推送,电话和短信不变
            if (People.PeopleList != null && People.PeopleList.Any())
            {
                //联系人
                var BeUserIDList     = string.Join(",", People.PeopleList.Select(f => f.FriendID).Where(f => !string.IsNullOrWhiteSpace(f)).Distinct().ToList());
                var PeoPleFirendList = People.PeopleList.Select(f => new People {
                    Name = f.FriendName, Phone = f.FriendPhone, UserID = f.FriendID
                }).ToList();
                PeoPleFirendList = PeoPleFirendList.Distinct().ToList();
                var FoList = new List <People>();

                foreach (var mod in PeoPleFirendList)
                {
                    if (FoList.Where(f => f.Phone == mod.Phone).Any())
                    {
                        Utility.WriteLog("联系人重复---------------------------------AS3--------" + mod.Name + People.Address + mod.Phone);
                        continue;
                    }
                    FoList.Add(mod);
                    Utility.WriteLog("联系人发短信---------------------------------AS3--------" + mod.Name + People.Address + mod.Phone);
                    //发送短信
                    HttpSend.ShortMessageSend(mod.Phone, Address, DevName, People.UserName, mod.Name, "2");

                    //打电话
                    sendTalePoone(mod.Phone, People.UserName, "2", People.Address, DevName, mod.Name, DevID);

                    //添加推送记录表

                    var Models = new FireControl_WarninsPUser();
                    Models.CreatedBy  = "0";
                    Models.CreateTime = DateTime.Now;
                    Models.Deleted    = 0;
                    Models.PUID       = CommHelper.CreatePKID("pu");
                    Models.TitleID    = TitleID;// TitleID;
                    Models.UserID     = mod.UserID;
                    Models.UserPhone  = mod.Phone;
                    puBll.AddObj(Models);
                }
            }
            //添加推送记录表

            var Model = new FireControl_WarninsPUser();
            Model.CreatedBy  = "0";
            Model.CreateTime = DateTime.Now;
            Model.Deleted    = 0;
            Model.PUID       = CommHelper.CreatePKID("pu");
            Model.TitleID    = TitleID;// TitleID;
            Model.UserID     = People.UserID;
            Model.UserPhone  = People.Phone;
            puBll.AddObj(Model);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 业主设备报警推送处理 (电话短信+极光推送)
        /// </summary>
        /// <param name="UserModel">业主信息</param>
        /// <param name="DevID">设备ID</param>
        /// <returns></returns>
        public static string GetPushStr(People UserModel, string DevID, string TitleID)
        {
            //语音电话模板是通过集合方式发送请求的 可以在数据库中添加模板 ,后期维护的话可直接改成数据表查询方式
            //先判断设备类型
            var NewType = "";
            var DevName = ""; //设备名称简称
            FireControl_DeviceBLL DevBll = new FireControl_DeviceBLL();
            var str          = "";
            var Message      = ""; //短信报警解释
            var PhoneMessage = "";
            var DevResult    = DevBll.GetObjByKey(DevID);

            if (DevResult.ResultCode == ResultCode.Succ)
            {
                var        Device     = DevResult.ResultData;
                DeviceType deviceType = CommHelper.StringToDeviceType(Device.TypeID);
                switch (deviceType)
                {
                case DeviceType.单相电气火灾探测器:
                    //电气 不同报警类型提示文字不同
                    //电气开始时间
                    var DQStart = "09:00";
                    //电气推送结束时间
                    var DQEnd = "22:00";
                    str     = "";
                    NewType = "6";
                    DevName = "电气";
                    if (Convert.ToDateTime(DQStart) > DateTime.Now && DateTime.Now < Convert.ToDateTime(DQEnd))
                    {    //可以进行推送
                         // 同一个设备一天只推送两次 间隔最少一小时
                        FireControl_PushRecordBLL pushRecBLL = new FireControl_PushRecordBLL();
                        var PushRecResult = pushRecBLL.GetPushRecordOneDayByDevIDAndUserID(DevID, UserModel.UserID);
                        if (PushRecResult.ResultCode == ResultCode.UnSucc)
                        {
                            var pushRec = PushRecResult.ResultData;
                            //找到记录 极光一天两次 间隔最少一小时   短信和电话一天一次
                            if (pushRec.Count == 1)
                            {    //只有极光可以发送
                                //还需要判断该报警是否是一小时以前的
                                var time     = pushRec.FirstOrDefault().CreateTime;
                                var timeDiff = Utility.ExecDateDiff(DateTime.Now, time);
                                if (timeDiff > 60)
                                {    //此时可以再推送一次
                                    SendDQ(UserModel, TitleID, NewType, DevName, DevID, "2");
                                }
                            }
                            else if (pushRec.Count == 0)
                            {
                                //都可以发送
                                SendDQ(UserModel, TitleID, NewType, DevName, DevID, "1");
                            }
                        }
                        else
                        {
                            //未找到记录直接推送
                            SendDQ(UserModel, TitleID, NewType, DevName, DevID, "1");
                        }
                    }
                    break;

                case DeviceType.独立式光电感烟火灾探测报警器:
                    // 烟感  1-4个烟感同时报警 三种推送的文字不同
                    FireControl_DevBindUserBLL devUserBLL = new FireControl_DevBindUserBLL();
                    var NumberResult = devUserBLL.GetYGAlarmNumberByDevID(DevID);    //
                    var Number       = Convert.ToInt32(NumberResult.ResultData);

                    str     = "";
                    NewType = "1";
                    DevName = "烟感";
                    //推送
                    APPPush(UserModel, TitleID, NewType, DevName, DevID);
                    if (Number <= 1)
                    {
                        PhoneMessage = UserModel.Name.Replace("&", "") + "&" + UserModel.Address.Replace(UserModel.Province, "").Replace("&", "") + "&" + "烟感探测器&正在报警&置小火于不顾终会酿成大灾,";
                        //玉龙小区1号楼二单元403室 的感烟探测器正在报警,友情提示电气火灾先断电、燃气火灾关阀门、家具火灾用水泼
                        DevName = "烟感设备";
                        Message = "电气火灾先断电、燃气火灾关阀门、家具火灾用水泼";
                    }
                    else if (Number == 2)
                    {
                        PhoneMessage = UserModel.Name.Replace("&", "") + "&" + UserModel.Address.Replace(UserModel.Province, "").Replace("&", "") + "&" + "两个烟感探测器&正在报警&";
                        //玉龙小区1号楼二单元403室 的两个感烟探测器同时在报警,友情提示应争分夺秒扑灭初期火灾,火势凶猛要迅速逃离现场
                        DevName = "两个感烟设备";
                        Message = "应争分夺秒扑灭初期火灾,火势凶猛要迅速逃离现场";
                    }
                    else if (Number >= 3)
                    {
                        PhoneMessage = UserModel.Name.Replace("&", "") + "&" + UserModel.Address.Replace(UserModel.Province, "").Replace("&", "") + "&" + "三个烟感探测器&正在报警&";
                        //玉龙小区1号楼二单元403室的三个感烟探测器同时在报警,友情提示您先冷静判断火灾类型、火势大小,报警电话要讲全
                        DevName = "多个感烟设备";
                        Message = "您先冷静判断火灾类型、火势大小,报警电话要讲全";
                    }

                    //短信
                    #region 短信
                    SendSmsModel SendSmsModel = new SendSmsModel();
                    SendSmsModel.AddressDetail = UserModel.Address.Replace(UserModel.Province + UserModel.City + UserModel.Area + UserModel.StreetName + UserModel.VillageName, "");
                    SendSmsModel.DevName       = DevName;
                    SendSmsModel.PushName      = "正在报警";
                    SendSmsModel.Phone         = UserModel.Phone;
                    SendSmsModel.VillageName   = UserModel.VillageName;
                    SendSmsModel.Message       = Message;
                    HttpSend.sendSmsP1(SendSmsModel);
                    #endregion

                    #region 电话
                    //地址去掉省
                    HttpSend.TalePhoneP1(DevName, UserModel.Phone, UserModel.Address.Replace(UserModel.Province, ""), UserModel.Name, DevID, "1", PhoneMessage);

                    #endregion

                    //首页弹窗
                    FireControl_YGAlarmPromptBLL YGBLL = new FireControl_YGAlarmPromptBLL();
                    var YGList = YGBLL.GetList();
                    if (YGList.ResultCode == ResultCode.Succ)
                    {
                        var YGText = YGList.ResultData;
                        var mod    = YGText.Where(f => f.Number == Number).FirstOrDefault();
                        if (mod == null || string.IsNullOrWhiteSpace(mod.APID))
                        {
                            mod = YGText.OrderBy(f => f.Number).LastOrDefault();
                        }
                        FireControl_AlarmWindow AlarmWindow = new FireControl_AlarmWindow();
                        AlarmWindow.Address     = UserModel.Address.Replace(UserModel.Province + UserModel.City + UserModel.Area + UserModel.StreetName, ""); //小区名+详细地址
                        AlarmWindow.AWID        = CommHelper.CreatePKID("aw");
                        AlarmWindow.DevID       = DevID;
                        AlarmWindow.DevName     = DevName;
                        AlarmWindow.DevNum      = Device.DevNum;
                        AlarmWindow.DevTypeID   = Device.TypeID;
                        AlarmWindow.DevTypeName = "";
                        AlarmWindow.PromptText  = mod.PromptText;
                        AlarmWindow.RecordID    = TitleID;
                        AlarmWindow.Title       = "您的" + DevName + "正在报警";
                        AlarmWindow.UserID      = UserModel.UserID;

                        AddAlarmWindow(AlarmWindow);
                    }
                    break;

                case DeviceType.独立式可燃气体探测器:
                    var PushName = "";
                    str     = "";
                    NewType = "1";
                    DevName = "燃气";
                    //燃气 不同浓度报警提示不同
                    //没浓度的燃气报警显示最高报警信息
                    //查询当前报警的浓度
                    FireControl_WarninsPushBLL pushBll = new FireControl_WarninsPushBLL();
                    var PushResult  = pushBll.GetObjByKey(TitleID);
                    var PushModel   = PushResult.ResultData;
                    var RecordValue = Convert.ToInt32(PushModel.RecordValue);     //浓度值

                    if (RecordValue >= 0 && RecordValue < 5)
                    {
                        /*
                         * 报警语音(王志您好,您家玉龙小区的燃气正在泄漏,如遇到明火会引起微型火灾,请尽快处理!)
                         * 报警短信(【全民消防】玉龙小区1号楼二单元403室的燃气正在泄漏,友情提示您立即关闭燃气阀门,开窗疏散燃气浓度)
                         */
                        PushName     = "正在泄漏";
                        Message      = "您立即关闭燃气阀门,开窗疏散燃气浓度";
                        PhoneMessage = UserModel.Name.Replace("&", "") + "&" + UserModel.Address.Replace(UserModel.Province, "").Replace("&", "") + "&" + "燃气&正在泄漏&如遇到明火会引起微型火灾,";
                    }
                    else if (RecordValue >= 5 && RecordValue < 15)
                    {
                        /*
                         * 报警语音(王志您好,石家庄市玉龙小区1号楼二单元403室的燃气泄漏浓度已超过5%,如遇热源和明火有爆炸的危险,请尽快处理!)
                         * 报警短信(【全民消防】玉龙小区1号楼二单元403室的燃气泄漏浓度已超过5%,友情提示您不要开关电器,泄漏区不要出现热源和明火
                         */
                        PushName     = "泄漏浓度已超过5%";
                        Message      = "您不要开关电器,泄漏区不要出现热源和明火";
                        PhoneMessage = UserModel.Name.Replace("&", "") + "&" + UserModel.Address.Replace(UserModel.Province, "").Replace("&", "") + "&" + "燃气&泄漏浓度已超过百分之五&如遇热源和明火有爆炸的危险,";
                    }
                    else if (RecordValue >= 15 && RecordValue < 30)
                    {
                        /*
                         * 报警语音(王志您好,石家庄市玉龙小区1号楼二单元403室的燃气泄漏浓度已超过15%,如吸入大量甲烷会使人窒息,请尽快处理!)
                         * 报警短信(【全民消防】玉龙小区1号楼二单元403室的燃气泄漏浓度已超过15%,友情提示您立即关闭燃气阀门,离开燃气泄漏区)
                         */
                        PushName     = "泄漏浓度已超过15%";
                        Message      = "您立即关闭燃气阀门,离开燃气泄漏区";
                        PhoneMessage = UserModel.Name.Replace("&", "") + "&" + UserModel.Address.Replace(UserModel.Province, "").Replace("&", "") + "&" + "燃气&泄漏浓度已超过百分之十五&如吸入大量甲烷会使人窒息,";
                    }
                    else if (RecordValue >= 30 && RecordValue <= 100)
                    {
                        /*
                         *   报警语音(王志您好,石家庄市玉龙小区1号楼二单元403室的燃气泄漏浓度已超过30%,有中毒窒息和火灾爆炸的双重危险,请尽快处理!)
                         *   报警短信(【全民消防】玉龙小区1号楼二单元403室的燃气泄漏浓度已超过30%,友情提示您立即远离泄漏区打电话给物业处理)
                         */
                        PushName     = "泄漏浓度已超过30%";
                        Message      = "您立即远离泄漏区打电话给物业处理";
                        PhoneMessage = UserModel.Name.Replace("&", "") + "&" + UserModel.Address.Replace(UserModel.Province, "").Replace("&", "") + "&" + "燃气&泄漏浓度已超过百分之三十&有中毒窒息和火灾爆炸的双重危险,";
                    }
                    //推送
                    APPPush(UserModel, TitleID, NewType, DevName, DevID);


                    #region 短信
                    SendSmsModel SendSmsRQModel = new SendSmsModel();
                    SendSmsRQModel.AddressDetail = UserModel.Address.Replace(UserModel.Province + UserModel.City + UserModel.Area + UserModel.StreetName + UserModel.VillageName, "");
                    SendSmsRQModel.DevName       = DevName;
                    SendSmsRQModel.PushName      = PushName;
                    SendSmsRQModel.Phone         = UserModel.Phone;
                    SendSmsRQModel.VillageName   = UserModel.VillageName;
                    SendSmsRQModel.Message       = Message;
                    HttpSend.sendSmsP1(SendSmsRQModel);
                    #endregion

                    #region 电话
                    HttpSend.TalePhoneP1(DevName, UserModel.Phone, UserModel.Address.Replace(UserModel.Province, ""), UserModel.Name, DevID, "2", PhoneMessage);
                    #endregion


                    //首页弹窗
                    //添加弹窗一条记录
                    //增加一个自定义推送

                    FireControl_RQAlarmPromptBLL RQBLL = new FireControl_RQAlarmPromptBLL();
                    var RQList = RQBLL.GetList();
                    if (RQList.ResultCode == ResultCode.Succ)
                    {
                        var RQText = RQList.ResultData;
                        var mod    = RQText.Where(f => f.MinValue < RecordValue && f.MaxValue >= RecordValue).FirstOrDefault();
                        if (mod == null || string.IsNullOrWhiteSpace(mod.APID))
                        {
                            mod = RQText.OrderBy(f => f.MaxValue).LastOrDefault();
                        }
                        FireControl_AlarmWindow AlarmWindow = new FireControl_AlarmWindow();
                        AlarmWindow.Address     = UserModel.Address.Replace(UserModel.Province + UserModel.City + UserModel.Area + UserModel.StreetName, "");;  //小区名+详细地址
                        AlarmWindow.AWID        = CommHelper.CreatePKID("aw");
                        AlarmWindow.DevID       = DevID;
                        AlarmWindow.DevName     = DevName;
                        AlarmWindow.DevNum      = Device.DevNum;
                        AlarmWindow.DevTypeID   = Device.TypeID;
                        AlarmWindow.DevTypeName = "";
                        AlarmWindow.PromptText  = mod.PromptText;
                        AlarmWindow.RecordID    = TitleID;
                        AlarmWindow.Title       = "您的" + DevName + PushName;
                        AlarmWindow.UserID      = UserModel.UserID;
                        AddAlarmWindow(AlarmWindow);
                    }
                    break;
                }

                //所有设备的不同报警极光推送都一样
                //紧急通知!您的{1}设备发生报警,地址{2},请尽快处理{1.设备类型简称;2.省市区+小区名称;
            }


            return("");
        }
Exemplo n.º 10
0
        public ResponseJson OCIOTMsg([FromBody] OCIOTModel model)
        {
            //暂时去掉该注释
            Utility.WriteLog("调我接口了:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---:" + JsonConvert.SerializeObject(model));
            ResponseJson json = null;

            try
            {
                FireControl_MpArTable_BLL MpBll = new FireControl_MpArTable_BLL();
                REG.N6.IFT.TwpFControl.Model.ResultDis <bool> Waterresult = null;
                FireControl_MpArTable info = new FireControl_MpArTable();
                info.AccID      = CommHelper.CreatePKID("acc");
                info.RawData    = JsonConvert.SerializeObject(model);
                info.ReportDate = DateTime.MinValue;

                //保存传入数据                   //修改

                //判断是否有这条消息
                Waterresult = MpBll.AddObj(info);
                if (Waterresult.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                {
                    Utility.WriteLog("数据保存成功:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                }
                else
                {
                    Utility.WriteLog(Waterresult.ResultContent);
                    Utility.WriteLog("传入数据系统生成时间:" + info.RawData);
                }

                OCIOTServiceData data     = new OCIOTServiceData();
                string           alamdate = string.Empty;
                if (model != null)
                {
                    if (model.service != null)
                    {
                        OCIOTService services = new OCIOTService();
                        services = model.service;
                        if (services != null)
                        {
                            data = services.data;
                            //事件上报时间
                            alamdate = services.eventTime;
                            if (!string.IsNullOrEmpty(alamdate))
                            {
                                string year   = alamdate.Substring(0, 4);
                                string month  = alamdate.Substring(4, 2);
                                string day    = alamdate.Substring(6, 2);
                                string t      = alamdate.Substring(8, 1);
                                string hour   = alamdate.Substring(9, 2);
                                string minute = alamdate.Substring(11, 2);
                                string second = alamdate.Substring(13, 2);
                                string z      = alamdate.Substring(15, 1);
                                alamdate = year + "-" + month + "-" + day + t + hour + ":" + minute + ":" + second + z;
                            }
                        }
                    }
                }
                if (data != null)
                {
                    OCIOTData ociotdata = new OCIOTData();
                    Utility.WriteLog("数据保存成功报文的内置时间:" + DateTime.Parse(alamdate).ToString("yyyy-MM-dd HH:mm:ss:fff"));
                    ociotdata.GetData(data.rawData, alamdate, info.AccID);
                }
                json = new ResponseJson(ResponseCode.Nomal, "成功");
            }
            catch (Exception ex)
            {
                Utility.WriteLog(ex.Message);
                json = new ResponseJson(ResponseCode.Err, "失败");
            }
            return(json);
        }