Exemplo n.º 1
0
        /// <summary>
        /// 查找预案处置项执行结果记录
        /// 先根据报警ID查找预案执行记录planRecordId,再通过planRecordId查找Serv_Plan_ItemResult
        /// </summary>
        /// <param name="alarmId"></param>
        /// <returns></returns>
        private PlanItemHandledInfo PlanItemResultList(ServAlarmRecordModel alarmRecord)
        {
            PlanItemHandledInfo handleInfoModel = new PlanItemHandledInfo();

            try
            {
                ServPlanRecordDAL           planRecordDal           = new ServPlanRecordDAL();
                ServPlanItemResultDAL       planItemResultDal       = new ServPlanItemResultDAL();
                ServPlanHandleItemDAL       planHandleItemDal       = new ServPlanHandleItemDAL();
                ServPlanHandleItemCameraDAL planHandleItemCameraDal = new ServPlanHandleItemCameraDAL();
                // ServAlarmRecordModel alarmRecord = _servAlarmRecordDal.GetEntity(alarmId);
                //查找预案执行记录
                ServPlanRecordModel planRecord = planRecordDal.GetEntityByAlarmId(alarmRecord.id);

                if (planRecord != null)
                {
                    //查找预案处置项记录
                    List <ServPlanItemResultModel> planItemRecordList = planItemResultDal.GetEntitiesByPlanRecordId(planRecord.id);
                    if (planItemRecordList != null)
                    {
                        handleInfoModel = TranPlanItemRecord(planRecord.plan_type, planItemRecordList, alarmRecord.alarm_event, alarmRecord.alarm_time);
                    }
                    else
                    {
                        //log 根据预案执行记录ID未找到预案处置项记录
                    }

                    //查找关联摄像头信息(事件预案无关联摄像头)
                    //if (planRecord.plan_type == (int)EnumClass.PlanType.事件预案)
                    //{
                    //    ServPlanHandleItemModel planHandleItemModel = planHandleItemDal.GetPlanHandleItemByTypeAndId(planRecord.plan_id, planRecord.plan_type, (int)EnumClass.EventPlanDefaultOptions.关联摄像头);
                    //    if (planHandleItemModel != null)
                    //    {
                    //        handleInfoModel.cameraList = planHandleItemCameraDal.GetHandledCameras(planHandleItemModel.id);
                    //    }
                    //}
                    if (planRecord.plan_type == (int)EnumClass.PlanType.设备预案)
                    {
                        ServPlanHandleItemModel planHandleItemModel = planHandleItemDal.GetPlanHandleItemByTypeAndId(planRecord.plan_id, planRecord.plan_type, (int)EnumClass.DevicePlanDefaultOptions.关联摄像头);
                        if (planHandleItemModel != null)
                        {
                            handleInfoModel.cameraList = planHandleItemCameraDal.GetHandledCameras(planHandleItemModel.id);
                        }
                    }
                }
                else
                {
                    //log 根据alarmId查找预案执行记录为null
                }
                handleInfoModel.alarmRecord = alarmRecord;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(handleInfoModel);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 根据预案id获取处置项
 /// </summary>
 /// <param name="PlanId"></param>
 /// <returns></returns>
 public List <ServPlanHandleItemModel> GetPlanHandleItem(int PlanId, int planType)
 {
     try
     {
         ServPlanHandleItemModel servPlanHandleItemModel = new ServPlanHandleItemModel();
         servPlanHandleItemModel.plan_type = planType;
         servPlanHandleItemModel.plan_id   = PlanId;
         List <ServPlanHandleItemModel> list = mapContext.QueryForList <ServPlanHandleItemModel>("GetPlanHandleItemByPlanId", servPlanHandleItemModel).ToList();
         return(list);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 通过预案处置项类型,预案类型,预案ID获取预案处置项
 /// </summary>
 /// <param name="planId"></param>
 /// <param name="planType"></param>
 /// <param name="itemType"></param>
 /// <returns></returns>
 public ServPlanHandleItemModel GetPlanHandleItemByTypeAndId(int planId, int planType, int itemType)
 {
     try
     {
         ServPlanHandleItemModel servPlanHandleItemModel = new ServPlanHandleItemModel();
         servPlanHandleItemModel.plan_type = planType;
         servPlanHandleItemModel.plan_id   = planId;
         servPlanHandleItemModel.item_type = itemType;
         ServPlanHandleItemModel retServPlanHandleItemModel = mapContext.QueryForObject <ServPlanHandleItemModel>("GetPlanHandleItemByTypeAndId", servPlanHandleItemModel);
         return(retServPlanHandleItemModel);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 执行设备预案处置项
        /// </summary>
        /// <param name="itemList"></param>
        /// <returns></returns>
        public void HandleDevicePlanItem(int planRecordId, int eventId, BaseRegionConfigModel regionModel, List <ServPlanHandleItemModel> itemList, ServDeviceInfoModel deviceInfo, ServAlarmRecordModel alarmRecord, out List <ServDeviceInfoModel> camerasList, out string ledMessage)
        {
            try
            {
                PlanItemBLL             planItemBll     = new PlanItemBLL();
                ServPlanHandleItemModel handleItemModel = itemList.FirstOrDefault(n => n.item_type == (int)EnumClass.DevicePlanDefaultOptions.关联摄像头);
                if (handleItemModel != null)
                {
                    HandleCamerasBLL camerasbll = new HandleCamerasBLL();
                    camerasList = camerasbll.GetCameras(handleItemModel.id);
                }
                else
                {
                    camerasList = null;
                }
                LEDHandle ledHandle = new LEDHandle(deviceInfo, alarmRecord);
                ledMessage = ledHandle.GetAlarmText();

                foreach (ServPlanHandleItemModel item in itemList)
                {
                    switch (item.item_type)
                    {
                    case (int)EnumClass.DevicePlanDefaultOptions.中控室LED信息显示:
                        // string content = "";
                        // LEDHandle ledHandle = new LEDHandle(deviceInfo, alarmRecord);
                        bool ledResult = ledHandle.HandleLedItem(ledMessage, regionModel.region_code);      //处理LED
                        planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.成功, item.item_type, planRecordId, ledMessage);
                        //if (!ht.ContainsKey(item.item_type))
                        //{
                        //    ht.Add(item.item_type, new { status = 1, info = "" });//已执行
                        //}
                        //else
                        //{
                        //    Log4NetHelp.Info("处置项重复:" + Enum.Parse(typeof(EnumClass.DevicePlanDefaultOptions), item.item_type.ToString()).ToString());
                        //}
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.关联摄像头:

                        // ht.Add(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId });//未执行
                        AddHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.告警视频下载:
                        int handleDownloadRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.成功, item.item_type, planRecordId, "");
                        if (handleDownloadRecordId > 0)     //插入处置项记录成功,开始执行处置项
                        {
                            VideoDownloadBLL videoDownloadBll = new VideoDownloadBLL();
                            bool             bl = videoDownloadBll.VideoDownload(handleDownloadRecordId, eventId, alarmRecord.alarm_time.ToLocalTime(), camerasList);
                        }
                        //  ht.Add(item.item_type, new { status = 1, info = "" });//已执行
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.打开告警设备附近视频:
                        // ht.Add(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });//未执行
                        AddHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.控制中心声光蜂鸣器开启:
                        HandleRelayBLL handleRelayBll = new HandleRelayBLL();
                        handleRelayBll.HandleRelay(item.ext1, regionModel.region_code);
                        planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.成功, item.item_type, planRecordId, "");
                        //  ht.Add(item.item_type, new { status = 1, info = "" });//已执行
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.相关摄像头上大屏:
                        // ht.Add(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });//未执行
                        AddHashTable(item.item_type, new { status = 0, itemid = item.id, itemType = item.item_type, planRecordId = planRecordId, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.通知其他负责人:
                        PlanPersonBLL planPersonBll        = new PlanPersonBLL();
                        int           handlePersonRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.失败, item.item_type, planRecordId, "暂未设置短信平台");
                        if (handlePersonRecordId > 0)      //插入处置项记录成功,开始执行处置项
                        {
                            bool bl = planPersonBll.HandlePlanPerson(item.id, alarmRecord, handlePersonRecordId);
                        }
                        // ht.Add(item.item_type, new { status = 1, info = "" });
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    case (int)EnumClass.DevicePlanDefaultOptions.通知设备网格第一负责人:
                        //查找第一负责人,发送短信,记录短信记录与执行结果
                        // planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, item.item_type, planRecordId, "");
                        // ht.Add(item.item_type, new { status = 1, info = "" });
                        int dutyPersonRecordId = planItemBll.AddItemRecord((int)EnumClass.PlanHandleTime.确警前, item.id, (int)EnumClass.PlanItemResult.失败, item.item_type, planRecordId, "暂未设置短信平台");
                        AddHashTable(item.item_type, new { status = 1, info = "" });
                        break;

                    default: break;
                    }
                }
            }
            catch (Exception ex)
            {
                camerasList = null;
                ledMessage  = "";
                Log4NetHelp.Info("处理设备预案失败!报警记录ID:" + planRecordId + " " + ex.Message);
            }
            // return ht;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 修改预案信息
        /// </summary>
        /// <param name="devicePlanRelationInfoModel"></param>
        /// <returns></returns>
        public bool UpdateDevicePlan(DevicePlanRelationInfoModel devicePlanRelationInfoModel)
        {
            mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务
            try
            {
                bool result = false;
                //修改预案信息.Insert
                string sql    = IBatisHelper.GetRuntimeSql(this.mapContext, "UpdatePartDevicePlanById", devicePlanRelationInfoModel.entity);
                int    planId = (int)mapContext.Update("UpdatePartDevicePlanById", devicePlanRelationInfoModel.entity);
                if (planId > 0)
                {
                    int executionTimeId = (int)mapContext.Delete("DeleteServExecutionTime", devicePlanRelationInfoModel.servExecutionTime);
                    if (executionTimeId > 0)
                    {
                        ServPlanHandleItemModel servPlanHandleItemModel = new ServPlanHandleItemModel();
                        servPlanHandleItemModel.plan_id   = devicePlanRelationInfoModel.entity.id;
                        servPlanHandleItemModel.plan_type = (int)PlanType.设备预案;
                        List <ServPlanHandleItemModel> PlanHandleItem = mapContext.QueryForList <ServPlanHandleItemModel>("GetPlanHandleItemByPlanId", servPlanHandleItemModel).ToList();
                        for (int a = 0; a < PlanHandleItem.Count(); a++)
                        {
                            if (PlanHandleItem[a].item_type == (int)DevicePlanDefaultOptions.通知其他负责人 && PlanHandleItem[a].confirm_type == (int)PlanHandleTime.确警前)
                            {   //删除默认处置项中的通知其他责任人信息
                                result = DeleteRelatedInfo("DeletePlanPersonByHandleId", "DeletePlanHandleItemById", PlanHandleItem[a].id);
                                if (result == false)
                                {
                                    break;
                                }
                            }
                            else if (PlanHandleItem[a].item_type == (int)DevicePlanConfirmOptions.通知其他负责人 && PlanHandleItem[a].confirm_type == (int)PlanHandleTime.确警后)
                            {
                                //删除确警后处置项中的通知其他责任人信息
                                result = DeleteRelatedInfo("DeletePlanPersonByHandleId", "DeletePlanHandleItemById", PlanHandleItem[a].id);
                                if (result == false)
                                {
                                    break;
                                }
                            }
                            else if (PlanHandleItem[a].item_type == (int)DevicePlanDefaultOptions.关联摄像头 && PlanHandleItem[a].confirm_type == (int)PlanHandleTime.确警前)
                            {
                                //删除默认处置项中的摄像头信息
                                result = DeleteRelatedInfo("DeletePlanHandleItemCameraHandleId", "DeletePlanHandleItemById", PlanHandleItem[a].id);
                                if (result == false)
                                {
                                    break;
                                }
                            }
                            else
                            {   //删除处置项
                                result = DeleteRelatedInfo("", "DeletePlanHandleItemById", PlanHandleItem[a].id);
                                if (result == false)
                                {
                                    break;
                                }
                            }
                        }
                        //添加关联信息
                        result = AddRelatedInfo(devicePlanRelationInfoModel.entity.id, devicePlanRelationInfoModel);
                    }
                    else
                    {
                        mapContext.RollBackTransaction();
                        result = false;
                    }
                }
                else
                {
                    mapContext.RollBackTransaction();
                    result = false;
                }
                if (result == true)
                {
                    mapContext.CommitTransaction();//提交事务
                    return(result);
                }
                else
                {
                    mapContext.RollBackTransaction();//事务回滚
                    return(result);
                }
            }


            catch (Exception ex)
            {
                mapContext.RollBackTransaction();
                throw ex;
            }

            finally
            {
                //mapContext.CommitTransaction();
            }
        }
Exemplo n.º 6
0
 public bool UpdateEntity(int id, ServPlanHandleItemModel newentity)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        public int UpdatePlanHandleItemById(ServPlanHandleItemModel model)
        {
            int result = mapContext.Update("UpdatePlanHandleItemById", model);

            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="entity"></param>
        public int AddEntity(ServPlanHandleItemModel entity)
        {
            int id = (int)mapContext.Insert("InsertPlanHandleItem", entity);

            return(id);
        }