Beispiel #1
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);
        }
Beispiel #2
0
        /// <summary>
        /// 烟感解析数据
        /// </summary>
        private static bool SmokeData(ReceiveData info, string ACID)
        {
            FireControl_MpArTable_BLL MpBll          = new FireControl_MpArTable_BLL();
            ResultDis            smokeAnalysisResult = null;
            SmokeAnalysisMessage smokeAnalysis       = new SmokeAnalysisMessage();

            if (info != null)
            {
                smokeAnalysis.IMEI                       = info.IMEI;
                smokeAnalysis.DeviceType                 = info.DeviceType.ToString();
                smokeAnalysis.DataBlockCount             = info.DataBlockCount;
                smokeAnalysis.MainProgramVersionIdentity = info.MainProgramVersionIdentity;
                smokeAnalysis.MainProgramVersion         = info.MainProgramVersion;
                smokeAnalysis.HardwareVersionIdentity    = info.HardwareVersionIdentity;
                smokeAnalysis.HardwareVersion            = info.HardwareVersion;
                smokeAnalysis.BatchDataIdentity          = info.BatchDataIdentity;
                if (info.Bodydata != null)
                {
                    smokeAnalysis.DataSegmentLength          = info.Bodydata.DataSegmentLength;
                    smokeAnalysis.ProductLine                = info.Bodydata.ProductLine;
                    smokeAnalysis.SmokeAlarmStatus           = info.Bodydata.AlarmStatus;
                    smokeAnalysis.SmokeAlarmStatusText       = info.Bodydata.AlarmStatusText;
                    smokeAnalysis.Reserve1                   = info.Bodydata.Reserve1;
                    smokeAnalysis.Reserve2                   = info.Bodydata.Reserve2;
                    smokeAnalysis.Reserve3                   = info.Bodydata.Reserve3;
                    smokeAnalysis.WirelessType               = info.Bodydata.WirelessType;
                    smokeAnalysis.WirelessTypeText           = info.Bodydata.WirelessTypeText;
                    smokeAnalysis.WirelessValue              = info.Bodydata.WirelessValue;
                    smokeAnalysis.CollectorBatteryStatus     = info.Bodydata.CollectorBatteryStatus;
                    smokeAnalysis.CollectorBatteryValue      = info.Bodydata.CollectorBatteryValue;
                    smokeAnalysis.CommunicationBatteryStatus = info.Bodydata.CommunicationBatteryStatus;
                    smokeAnalysis.CommunicationBatteryValue  = info.Bodydata.CommunicationBatteryValue;
                }
                smokeAnalysis.CollectTime = DateTime.Now;
            }
            var Str = ConvertData <SmokeAnalysisMessage> .GetEntityToString(smokeAnalysis);

            Utility.WriteLog("烟感解析结果:" + Str);
            var Result = MpBll.GetObjByKey(ACID);

            if (Result.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
            {
                Utility.WriteLog("开始保存设备信息:");
                var Model = Result.ResultData;
                Model.PJsonData  = Str;
                Model.ReportDate = info.Bodydata.CollectTime;
                Model.DevNum     = info.IMEI;
                //判断是否已经存在该设备的该事件上传时间 存在就保存传入信息后跳过不进行后续操作
                if (info != null && info.Bodydata != null && info.Bodydata.AlarmStatus == "00")
                {
                    //未报警 不用管是重复数据直接跳过
                    Utility.WriteLog("未报警 不用管是重复数据直接跳过");
                }
                MpBll.ModObj(Model);//保存解析后的json串
            }
            //修改设备信息
            FireControl_DeviceBLL buildDeviceBLL = new FireControl_DeviceBLL();

            REG.N6.IFT.TwpFControl.Model.ResultDis <FireControl_Device> resultDevice = null;
            //1、 根据设备编号 查询设备    //修改
            resultDevice = buildDeviceBLL.GetDeviceTypeDetail(info.IMEI);
            FireControl_Device buildDevice = new FireControl_Device();
            var ReportDate = DateTime.MinValue;

            if (Result.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
            {
                ReportDate = Result.ResultData.ReportDate;
            }
            if (resultDevice.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
            {
                Utility.WriteLog("该设备在数据库中存在,设备IMEI为:" + info.IMEI);
                buildDevice = resultDevice.ResultData;
                if (buildDevice.LastUploadTime == ReportDate)
                {
                    Utility.WriteLog("已存在该设备上传信息:" + Str);
                    return(false);
                }
            }


            if (buildDevice != null && !string.IsNullOrEmpty(buildDevice.DevID))
            {
                if (buildDevice.ValidDate < DateTime.Now && buildDevice.ValidDate > Convert.ToDateTime("1900-01-02"))
                {
                    Utility.WriteLog("---------设备已过期等待用户充值后提醒--------");
                    return(false);
                }
                buildDevice.DeviceState     = Convert.ToByte(info.Bodydata.AlarmStatus.Substring(1, 1));
                buildDevice.SignalGrand     = smokeAnalysis.WirelessValue.ToString();
                buildDevice.CommBoardCharge = smokeAnalysis.CommunicationBatteryValue.ToString();
                if (Result.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                {
                    buildDevice.LastUploadTime = Result.ResultData.ReportDate;
                }
                buildDevice.LastUploadTime  = DateTime.Now;
                buildDevice.AcquBoardCharge = smokeAnalysis.CollectorBatteryValue.ToString();

                #region Lyp添加 电量报警
                // 采集板电池状态或者通讯板电池状态 更改为阶梯报警 分别是20%,10%,5% 根据亚伟开会决定
                if (smokeAnalysis.CollectorBatteryValue <= 5 || smokeAnalysis.CommunicationBatteryValue <= 5)
                {
                    buildDevice.ElecAlarm = "本次提示为最后一次提醒,电量低于5%,设备即将停止运行,请及时购买并更换电池。";
                }
                else if (smokeAnalysis.CollectorBatteryValue <= 10 || smokeAnalysis.CommunicationBatteryValue <= 10)
                {
                    buildDevice.ElecAlarm = "电量低于10%,请及时购买并更换电池。";
                }
                else if (smokeAnalysis.CollectorBatteryValue <= 20 || smokeAnalysis.CommunicationBatteryValue <= 20)
                {
                    buildDevice.ElecAlarm = "电量低于20%,请及时购买并更换电池。";
                }
                #endregion

                var ResultDev = buildDeviceBLL.ModObj(buildDevice);
                if (ResultDev.ResultCode == REG.N6.IFT.TwpFControl.Model.ResultCode.Succ)
                {
                    Utility.WriteLog("设备信息修改成功---------------------------------");
                }
                //resultDevice
            }

            return(true);
        }
Beispiel #3
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);
        }