예제 #1
0
        /// <summary>
        /// 根据条件查询设备告警
        /// </summary>
        /// <param name="regionId"></param>
        /// <param name="areaId"></param>
        /// <param name="alarmLevel"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="eventType"></param>
        /// <returns></returns>
        public System.IO.MemoryStream GetAllInformAlarmStream(int regionId, int areaId, int alarmLevel, string startTime, string endTime, int eventType)
        {
            try
            {
                BaseEventTypeBLL            eventTypeBll        = new BaseEventTypeBLL();
                BaseRegionConfigDAL         baseRegionConfigDal = new BaseRegionConfigDAL();
                List <RetInformAlarmCustom> retList             = new List <RetInformAlarmCustom>();
                RetInformAlarmCustom        retModel            = null;
                #region   拼接DataTable列头
                System.Data.DataTable table = new System.Data.DataTable();
                table.Columns.Add("告警编号");
                table.Columns.Add("事件名称");
                table.Columns.Add("告警设备");
                table.Columns.Add("告警位置");
                table.Columns.Add("园区名称");
                table.Columns.Add("区域名称");
                table.Columns.Add("告警时间");
                table.Columns.Add("告警级别");
                table.Columns.Add("处理状态");

                #endregion
                List <BaseRegionConfigModel> regionList = baseRegionConfigDal.GetAllRegionConfig();//获取所有园区配置
                DefinedInformAlarmQuery      query      = new DefinedInformAlarmQuery();
                query.alarmLevel = alarmLevel;
                query.regionId   = regionId;
                query.areaId     = areaId;
                query.startTime  = startTime;
                query.endTime    = endTime;
                query.eventType  = eventType;
                List <InformAlarmCustom> informList = servInformAlarmDal.GetAllInformAlarmCondition(query); //分页获取设备报警记录
                for (int i = 0; i < informList.Count; i++)
                {
                    System.Data.DataRow row = table.NewRow();
                    row["告警编号"] = informList[i].id;
                    row["事件名称"] = Enum.IsDefined(typeof(EnumClass.DeviceInformAlarmType), informList[i].event_type) ? Enum.GetName(typeof(EnumClass.DeviceInformAlarmType), informList[i].event_type) : " ";
                    row["告警设备"] = informList[i].device_name;
                    row["告警位置"] = informList[i].alarm_location;
                    row["园区名称"] = regionList.Where(n => n.id == informList[i].region_id).FirstOrDefault() == null ? " " : regionList.Where(n => n.id == informList[i].region_id).FirstOrDefault().region_name;
                    row["区域名称"] = informList[i].area_name;
                    row["告警时间"] = informList[i].report_time.ToString();
                    row["告警级别"] = Enum.IsDefined(typeof(EnumClass.AlarmLevel), informList[i].alarm_level) ? Enum.GetName(typeof(EnumClass.AlarmLevel), informList[i].alarm_level) : " ";
                    row["处理状态"] = Enum.IsDefined(typeof(EnumClass.InformAlarmStatus), informList[i].status) ? Enum.GetName(typeof(EnumClass.InformAlarmStatus), informList[i].status) : " ";
                    table.Rows.Add(row);
                }
                System.IO.MemoryStream ms = CSM.Utils.ExcelHelper.DataTableToExcel(table, "sheet2");
                return(ms);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        /// <summary>
        /// 带条件分页查询
        /// </summary>
        /// <param name="pageIndex">第几页</param>
        /// <param name="pageSize">每页数量</param>
        /// <param name="alarmCode">报警编号</param>
        /// <param name="alarmType">报警类型</param>
        /// <param name="subSystem">子系统类型</param>
        /// <param name="startTime">起始时间</param>
        /// <param name="endTime">截止时间</param>
        /// <param name="totalNumber">总条数</param>
        /// <returns></returns>
        public List <AlarmRecordModel> QueryPageList(int pageIndex, int pageSize, int regionId, int confirmState, int alarmType, int alarmLevel, int[] subSystem, string startTime, string endTime, out int totalNumber)
        {
            List <AlarmRecordModel> retList  = new List <AlarmRecordModel>();
            AlarmRecordModel        retModel = null;

            try
            {
                // ServDeviceInfoDAL servDeviceInfoDal = null;
                ServAlarmRecordQuery queryModel = new ServAlarmRecordQuery();
                queryModel.alarmCode    = "";
                queryModel.confirmState = confirmState;
                queryModel.alarmType    = alarmType;
                queryModel.alarmLevel   = alarmLevel;
                queryModel.endTime      = endTime;
                queryModel.pageIndex    = pageIndex;
                queryModel.pageSize     = pageSize;
                queryModel.startTime    = startTime;
                queryModel.regionId     = regionId;
                if (subSystem != null && subSystem.Length > 0)
                {
                    queryModel.subSystem = subSystem;
                }
                else
                {
                    queryModel.subSystem = null;
                }
                //   return _servAlarmRecordDal.GetEntities(queryModel, out totalNumber);
                List <AlarmRecordCustom> list = _servAlarmRecordDal.GetEntities(queryModel, out totalNumber);  //分页查询报警信息
                if (list != null)
                {
                    BaseEventTypeBLL          baseEventTypeBll = new BaseEventTypeBLL();
                    List <BaseEventTypeModel> eventList        = baseEventTypeBll.GetAllEventType(); //获取全部事件类型
                    foreach (AlarmRecordCustom model in list)
                    {
                        retModel = TranAlarmRecord(model, eventList);
                        retList.Add(retModel);
                    }
                }
                return(retList);
            }
            catch (Exception ex)
            {
                //log BLL层查询设备报警列表失败+ex.message
                throw ex;
            }
        }
예제 #3
0
 /// <summary>
 /// 根据查询条件分页获取设备告警
 /// </summary>
 /// <param name="pageIndex"></param>
 /// <param name="pageSize"></param>
 /// <param name="regionId"></param>
 /// <param name="areaId"></param>
 /// <param name="alarmLevel"></param>
 /// <param name="startTime"></param>
 /// <param name="endTime"></param>
 /// <param name="eventType"></param>
 /// <param name="totalNumber"></param>
 /// <returns></returns>
 public List <RetInformAlarmCustom> GetInformAlarmPage(int pageIndex, int pageSize, int regionId, int areaId, int alarmLevel, string startTime, string endTime, int eventType, out int totalNumber)
 {
     try
     {
         BaseEventTypeBLL            eventTypeBll        = new BaseEventTypeBLL();
         BaseRegionConfigDAL         baseRegionConfigDal = new BaseRegionConfigDAL();
         List <RetInformAlarmCustom> retList             = new List <RetInformAlarmCustom>();
         RetInformAlarmCustom        retModel            = null;
         //List<BaseEventTypeModel> eventTypeList = eventTypeBll.GetAllEventType();//获取所有事件类型
         List <BaseRegionConfigModel> regionList = baseRegionConfigDal.GetAllRegionConfig();//获取所有园区配置
         //var childEventType = eventTypeList.Where(n => n.pid == eventType);//获取所有PID为eventType的子级事件
         //List<int> eventArr = new List<int>();
         //if (childEventType != null)
         //{
         //    List<BaseEventTypeModel> childEventTypeList = childEventType.ToList();
         //    for (int i = 0; i < childEventTypeList.Count(); i++)
         //    {
         //        eventArr.Add(childEventTypeList[i].id);  //先用List<int>接收
         //    }
         //}
         DefinedInformAlarmQuery query = new DefinedInformAlarmQuery();
         query.alarmLevel = alarmLevel;
         query.regionId   = regionId;
         query.areaId     = areaId;
         query.startTime  = startTime;
         query.endTime    = endTime;
         //query.eventType = eventArr.Count == 0 ? null : eventArr.ToArray();  //将List<int>转化为数组int[]
         query.eventType = eventType;
         query.pageIndex = pageIndex;
         query.pageSize  = pageSize;
         List <InformAlarmCustom> informList = servInformAlarmDal.GetInformAlarmPage(query, out totalNumber); //分页获取设备报警记录
         for (int i = 0; i < informList.Count; i++)
         {
             retModel                = new RetInformAlarmCustom();
             retModel.alarm_level    = informList[i].alarm_level;
             retModel.alarm_location = informList[i].alarm_location;
             retModel.area_id        = informList[i].area_id;
             retModel.area_name      = informList[i].area_name;
             retModel.content        = informList[i].content;
             retModel.device_code    = informList[i].device_code;
             retModel.device_name    = informList[i].device_name;
             retModel.event_type     = informList[i].event_type;
             //var informAlarmEvent = eventTypeList.FirstOrDefault(n => n.id == informList[i].event_type); //查询当前事件
             //if (informAlarmEvent.pid == -1)  //判断是否是父级事件
             //{
             //    retModel.event_name = informAlarmEvent.event_name;
             //}
             //else
             //{
             //    var rootEvent = eventTypeList.FirstOrDefault(n => n.id == informAlarmEvent.pid);//查询父级事件,目前事件只保留两级
             //    if (rootEvent != null)   //找到父级事件
             //    {
             //        retModel.event_name = rootEvent.event_name;
             //    }
             //    else                    //未找到父级事件
             //    {
             //        retModel.event_name = "--";
             //    }
             //}
             retModel.event_name  = Enum.IsDefined(typeof(EnumClass.DeviceInformAlarmType), informList[i].event_type) ?  Enum.GetName(typeof(EnumClass.DeviceInformAlarmType), informList[i].event_type) : "--";
             retModel.ext1        = informList[i].ext1;
             retModel.ext2        = informList[i].ext2;
             retModel.ext3        = informList[i].ext3;
             retModel.ext4        = informList[i].ext4;
             retModel.ext5        = informList[i].ext5;
             retModel.id          = informList[i].id;
             retModel.region_id   = informList[i].region_id;
             retModel.region_name = regionList.Where(n => n.id == informList[i].region_id).FirstOrDefault() == null ? "--" : regionList.Where(n => n.id == informList[i].region_id).FirstOrDefault().region_name;
             retModel.report_time = informList[i].report_time;
             retModel.status      = informList[i].status;
             retList.Add(retModel);
         }
         return(retList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
        /// <summary>
        ///预案处置项记录结果转换
        /// </summary>
        /// <param name="planType"></param>
        /// <param name="ItemList"></param>
        /// <returns></returns>
        private PlanItemHandledInfo TranPlanItemRecord(int planType, List <ServPlanItemResultModel> ItemList, string eventCode, DateTime alarmTime)
        {
            PlanItemHandledInfo       handleInfoModel   = new PlanItemHandledInfo();
            List <TranPlanItemResult> retList           = new List <TranPlanItemResult>();
            TranPlanItemResult        retModel          = null;
            ServAlarmVideoTimeDAL     alarmVideoTimeDal = new ServAlarmVideoTimeDAL();
            BaseEventTypeBLL          baseEventTypeBll  = new BaseEventTypeBLL();
            List <BaseEventTypeModel> eventList         = baseEventTypeBll.GetAllEventType(); //获取全部事件类型

            #region 查找事件  旧版
            //int queryEventId = eventId;
            //var alarmEvent = eventList.FirstOrDefault(n => n.id == eventId); //查询当前事件
            //if (alarmEvent != null && alarmEvent.pid != -1)  //判断是否是父级事件
            //{
            //    var rootEvent = eventList.FirstOrDefault(n => n.id == alarmEvent.pid);//查询父级事件,目前事件只保留两级
            //    if (rootEvent != null)
            //    {
            //        queryEventId = rootEvent.id;
            //    }
            //    else
            //    {
            //        queryEventId = -1;
            //    }
            //}

            #endregion

            #region 查找事件  新版
            int queryEventId = -1;
            if (!string.IsNullOrEmpty(eventCode) && eventCode != "")
            {
                var alarmEvent = eventList.FirstOrDefault(n => n.event_code == eventCode);//查找事件
                if (alarmEvent != null)
                {
                    if (alarmEvent.pid == -1)
                    {
                        queryEventId = alarmEvent.id;
                    }
                    else
                    {
                        var rootEvent = eventList.FirstOrDefault(n => n.id == alarmEvent.pid);
                        if (rootEvent != null)   //找到父级事件
                        {
                            queryEventId = rootEvent.id;
                        }
                        else                    //未找到父级事件
                        {
                            queryEventId = -1;
                        }
                    }
                }
                else
                {
                    queryEventId = -1;
                }
            }
            else
            {
                queryEventId = -1;
            }
            #endregion
            //查询摄像头播放视频时长
            var videoTimeModel = alarmVideoTimeDal.GetEntityByEventId(queryEventId);
            handleInfoModel.videoTime = new ServAlarmVideoTimeCustom();
            handleInfoModel.videoTime.videoTimeModel = videoTimeModel;
            handleInfoModel.videoTime.videoStartTime = alarmTime.AddSeconds(-handleInfoModel.videoTime.videoTimeModel.start_time);
            handleInfoModel.videoTime.videoEndTime   = alarmTime.AddSeconds(handleInfoModel.videoTime.videoTimeModel.start_time);

            foreach (ServPlanItemResultModel item in ItemList)
            {
                retModel = new TranPlanItemResult();
                retModel.itemRecordId = item.id;
                retModel.content      = item.content;
                retModel.executeTime  = item.execute_time.ToString();
                retModel.confirm_type = item.confirm_type;
                retModel.itemResult   = Enum.IsDefined(typeof(EnumClass.PlanItemResult), item.item_result) ? Enum.ToObject(typeof(EnumClass.PlanItemResult), item.item_result).ToString() : "";

                #region  设备预案与事件预案分开处理,防止处置项类型不一致
                switch (planType)
                {
                case (int)EnumClass.PlanType.设备预案:
                    switch (item.confirm_type)
                    {
                    case (int)EnumClass.PlanHandleTime.确警前:
                        retModel.itemName = Enum.IsDefined(typeof(EnumClass.DevicePlanDefaultOptions), item.item_type) ? Enum.ToObject(typeof(EnumClass.DevicePlanDefaultOptions), item.item_type).ToString() : "";
                        switch (item.item_type)
                        {
                        //case (int)EnumClass.DevicePlanDefaultOptions.关联摄像头:
                        //    //查找关联的摄像头名称以及报警时长
                        //    ServPlanHandleItemCameraDAL planHandleItemCameraDal = new ServPlanHandleItemCameraDAL();
                        //    handleInfoModel.cameraList = planHandleItemCameraDal.GetHandledCameras(item.handleitem_id);
                        //    break;
                        case (int)EnumClass.DevicePlanDefaultOptions.告警视频下载:
                            //查找视频下载记录状态
                            ServVideoPlanHandleRecordDAL servVideoPlanHandleRecordDal = new ServVideoPlanHandleRecordDAL();
                            handleInfoModel.videoList = servVideoPlanHandleRecordDal.GetDownLoadVideoListByItemId(item.id);
                            break;

                        case (int)EnumClass.DevicePlanDefaultOptions.通知其他负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordPersomDal = new ServSMSRecordDAL();
                            handleInfoModel.beforeConfirmedPersonList = smsRecordPersomDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        case (int)EnumClass.DevicePlanDefaultOptions.通知设备网格第一负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordLeadDal = new ServSMSRecordDAL();
                            handleInfoModel.beforeConfirmedLeadList = smsRecordLeadDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        default: break;
                        }
                        break;

                    case (int)EnumClass.PlanHandleTime.确警后:
                        retModel.itemName = Enum.IsDefined(typeof(EnumClass.DevicePlanConfirmOptions), item.item_type) ? Enum.ToObject(typeof(EnumClass.DevicePlanConfirmOptions), item.item_type).ToString() : "";
                        switch (item.item_type)
                        {
                        case (int)EnumClass.DevicePlanConfirmOptions.通知其他负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordPersomDal = new ServSMSRecordDAL();
                            handleInfoModel.afterConfirmedPersonList = smsRecordPersomDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        case (int)EnumClass.DevicePlanConfirmOptions.通知设备网格第一负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordLeadDal = new ServSMSRecordDAL();
                            handleInfoModel.afterConfirmedLeadList = smsRecordLeadDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        default: break;
                        }
                        break;

                    default: break;
                    }
                    break;

                case (int)EnumClass.PlanType.事件预案:
                    switch (item.confirm_type)
                    {
                    case (int)EnumClass.PlanHandleTime.确警前:
                        retModel.itemName = Enum.IsDefined(typeof(EnumClass.EventPlanDefaultOptions), item.item_type) ? Enum.ToObject(typeof(EnumClass.EventPlanDefaultOptions), item.item_type).ToString() : "";
                        switch (item.item_type)
                        {
                        //case (int)EnumClass.EventPlanDefaultOptions.关联摄像头:
                        //    //查找关联的摄像头名称以及报警时长
                        //    ServPlanHandleItemCameraDAL planHandleItemCameraDal = new ServPlanHandleItemCameraDAL();
                        //    handleInfoModel.cameraList = planHandleItemCameraDal.GetHandledCameras(item.handleitem_id);
                        //    break;
                        case (int)EnumClass.EventPlanDefaultOptions.告警视频下载:
                            //查找视频下载记录状态
                            ServVideoPlanHandleRecordDAL servVideoPlanHandleRecordDal = new ServVideoPlanHandleRecordDAL();
                            handleInfoModel.videoList = servVideoPlanHandleRecordDal.GetDownLoadVideoListByItemId(item.id);
                            break;

                        case (int)EnumClass.EventPlanDefaultOptions.通知其他负责人:
                            //查看短信记录
                            ServSMSRecordDAL smsRecordPersomDal = new ServSMSRecordDAL();
                            handleInfoModel.beforeConfirmedPersonList = smsRecordPersomDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        case (int)EnumClass.EventPlanDefaultOptions.通知设备网格第一负责人:
                            //查找短信记录
                            ServSMSRecordDAL smsRecordLeadDal = new ServSMSRecordDAL();
                            handleInfoModel.beforeConfirmedLeadList = smsRecordLeadDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        default: break;
                        }
                        break;

                    case (int)EnumClass.PlanHandleTime.确警后:
                        retModel.itemName = Enum.IsDefined(typeof(EnumClass.EventPlanConfirmOptions), item.item_type) ? Enum.ToObject(typeof(EnumClass.EventPlanConfirmOptions), item.item_type).ToString() : "";
                        switch (item.item_type)
                        {
                        case (int)EnumClass.EventPlanConfirmOptions.通知其他负责人:
                            ServSMSRecordDAL smsRecordPersomDal = new ServSMSRecordDAL();
                            handleInfoModel.afterConfirmedPersonList = smsRecordPersomDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        case (int)EnumClass.EventPlanConfirmOptions.通知设备网格第一负责人:
                            ServSMSRecordDAL smsRecordLeadDal = new ServSMSRecordDAL();
                            handleInfoModel.afterConfirmedLeadList = smsRecordLeadDal.GetSMSRecordByHandleRecordId(item.id);
                            break;

                        default: break;
                        }
                        break;

                    default: break;
                    }
                    break;

                default: break;
                }

                #endregion

                retList.Add(retModel);
            }
            handleInfoModel.resultList = retList;
            return(handleInfoModel);
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="confirmState"></param>
        /// <param name="alarmType"></param>
        /// <param name="subSystem"></param>
        /// <param name="alarmLevel"></param>
        /// <returns></returns>
        public System.IO.MemoryStream GetAllAlarmRecordCondition(int regionId, string startTime, string endTime, int confirmState, int alarmType, string subSystem, int alarmLevel)
        {
            List <AlarmRecordModel> retList = new List <AlarmRecordModel>();

            #region   拼接DataTable列头
            System.Data.DataTable table = new System.Data.DataTable();
            table.Columns.Add("告警编号");
            table.Columns.Add("设备编号");
            table.Columns.Add("事件类型");
            table.Columns.Add("设备名称");
            table.Columns.Add("子系统类型");
            table.Columns.Add("报警时间");
            table.Columns.Add("报警级别");
            table.Columns.Add("确警人");
            table.Columns.Add("园区");
            table.Columns.Add("确警时间");
            table.Columns.Add("确警结果");
            table.Columns.Add("报警位置");
            table.Columns.Add("确警描述");

            #endregion
            AlarmRecordModel retModel = null;
            try
            {
                DefinedAlarmRecordQuery queryModel = new DefinedAlarmRecordQuery();
                queryModel.alarmCode    = "";
                queryModel.confirmState = confirmState;
                queryModel.alarmType    = alarmType;
                queryModel.alarmLevel   = alarmLevel;
                queryModel.endTime      = endTime;
                queryModel.startTime    = startTime;
                queryModel.regionId     = regionId;
                if (!string.IsNullOrEmpty(subSystem))
                {
                    if (subSystem.Contains(','))
                    {
                        string[] arr    = subSystem.Split(',');
                        int[]    intArr = Array.ConvertAll <string, int>(arr, n => int.Parse(n));
                        queryModel.subSystem = intArr;
                    }
                    else
                    {
                        int[] intArr = new int[] { int.Parse(subSystem) };
                        queryModel.subSystem = intArr;
                    }
                }
                else
                {
                    queryModel.subSystem = null;
                }
                List <AlarmRecordCustom> list = _servAlarmRecordDal.GetAllAlarmRecordCondition(queryModel);  //分页查询报警信息
                if (list != null)
                {
                    BaseEventTypeBLL          baseEventTypeBll = new BaseEventTypeBLL();
                    List <BaseEventTypeModel> eventList        = baseEventTypeBll.GetAllEventType(); //获取全部事件类型
                    foreach (AlarmRecordCustom model in list)
                    {
                        retModel = TranAlarmRecord(model, eventList);
                        System.Data.DataRow row = table.NewRow();
                        row["告警编号"]  = retModel.id;
                        row["设备编号"]  = retModel.alarmName;
                        row["事件类型"]  = retModel.alarmEvent;
                        row["设备名称"]  = retModel.deviceName;
                        row["子系统类型"] = retModel.subSystem;
                        row["报警时间"]  = retModel.alarmTime.ToString();
                        row["报警级别"]  = retModel.alarmLevel;
                        row["确警人"]   = retModel.confirmPersonName;
                        row["园区"]    = retModel.regionName;
                        row["确警时间"]  = retModel.alarmTime == retModel.confirmAlarmTime ? "" : retModel.confirmAlarmTime.ToString();
                        row["确警结果"]  = retModel.confirmResult;
                        row["报警位置"]  = retModel.alarmLocation;
                        row["确警描述"]  = retModel.confirmAlarmText;
                        table.Rows.Add(row);
                        // retList.Add(retModel);
                    }
                }
                //  System.Data.DataTable dt= CSM.Utils.ExcelHelper.ToDataTable(retList);
                // System.IO.MemoryStream ms = CSM.Utils.ExcelHelper.DataTableToExcel(dt, "sheet2");

                System.IO.MemoryStream ms = CSM.Utils.ExcelHelper.DataTableToExcel(table, "sheet2");
                // System.IO.MemoryStream ms = CSM.Utils.ExcelHelper.GetExcelStream(retList);
                return(ms);
            }
            catch (Exception ex)
            {
                //log BLL层查询设备报警列表失败+ex.message
                throw ex;
            }
        }