/// <summary>
        /// 查询服务接口端缓存信息,并同步到网关
        /// </summary>
        /// <returns></returns>
        public static QueryCacheDataResponse QueryServiceCacheDataToGateway()
        {
            QueryCacheDataResponse queryCacheDataResponse = new QueryCacheDataResponse();
            //获取定义、设备类型、网络模块、手动/交叉控制缓存信息
            List <Jc_DefInfo>    PointDefineCacheList        = _PointDefineService.GetAllPointDefineCache().Data.FindAll(a => a.Upflag != "1");//修改,不向网关同步由子系统同步的数据  20180131
            List <Jc_DevInfo>    DeviceDefineCacheList       = _DeviceDefineService.GetAllDeviceDefineCache().Data;
            List <Jc_MacInfo>    NetworkModuleCacheList      = _NetworkModuleService.GetAllNetworkModuleCache().Data;
            List <Jc_JcsdkzInfo> ManualCrossControlCacheList = _ManualCrossControlService.GetAllManualCrossControl().Data;
            //数据转换
            List <DeviceInfo>              GatewayPointDefineCacheList        = Basic.Framework.Common.ObjectConverter.CopyList <Jc_DefInfo, DeviceInfo>(PointDefineCacheList).ToList();
            List <DeviceTypeInfo>          GatewayDeviceDefineCacheList       = Basic.Framework.Common.ObjectConverter.CopyList <Jc_DevInfo, DeviceTypeInfo>(DeviceDefineCacheList).ToList();
            List <NetworkDeviceInfo>       GatewayNetworkModuleCacheList      = Basic.Framework.Common.ObjectConverter.CopyList <Jc_MacInfo, NetworkDeviceInfo>(NetworkModuleCacheList).ToList();
            List <DeviceAcrossControlInfo> GatewayManualCrossControlCacheList = Basic.Framework.Common.ObjectConverter.CopyList <Jc_JcsdkzInfo, DeviceAcrossControlInfo>(ManualCrossControlCacheList).ToList();

            //key赋值
            foreach (DeviceInfo PointDefine in GatewayPointDefineCacheList)
            {
                PointDefine.UniqueKey = PointDefine.Point;
            }
            foreach (DeviceTypeInfo DeviceDefine in GatewayDeviceDefineCacheList)
            {
                DeviceDefine.UniqueKey = DeviceDefine.Devid;
            }
            foreach (NetworkDeviceInfo NetworkModule in GatewayNetworkModuleCacheList)
            {
                NetworkModule.UniqueKey = NetworkModule.MAC;
            }
            foreach (DeviceAcrossControlInfo ManualCrossControl in GatewayManualCrossControlCacheList)
            {
                ManualCrossControl.UniqueKey = ManualCrossControl.ID;
            }

            queryCacheDataResponse.DeviceList              = GatewayPointDefineCacheList;
            queryCacheDataResponse.DeviceTypeList          = GatewayDeviceDefineCacheList;
            queryCacheDataResponse.NetworkDeviceList       = GatewayNetworkModuleCacheList;
            queryCacheDataResponse.DeviceAcrossControlList = GatewayManualCrossControlCacheList;

            return(queryCacheDataResponse);
        }
Esempio n. 2
0
        /// <summary>
        /// 传感器分级报警输出
        /// </summary>
        /// <param name="analysisConfigInfo"></param>
        /// <param name="analysistemplatealarmlevelInfo"></param>
        private void AnalysistemplateAlarmLevelHandle(JC_LargedataAnalysisConfigInfo analysisConfigInfo, Jc_AnalysistemplatealarmlevelInfo analysistemplatealarmlevelInfo)
        {
            try
            {
                //如果分析配置成立,则添加手动控制
                if (analysisConfigInfo.AnalysisResult == 2)
                {
                    string level = analysistemplatealarmlevelInfo.Level.ToString();

                    if (analysisConfigInfo.AnalysisSuccessfulPointList.Count > 0)
                    {
                        List <Jc_JcsdkzInfo> jckzinfos       = new List <Jc_JcsdkzInfo>();
                        List <Jc_JcsdkzInfo> updatejckzinfos = new List <Jc_JcsdkzInfo>();

                        analysisConfigInfo.AnalysisSuccessfulPointList.ForEach(point =>
                        {
                            //判断是否存在同一配置被控测点的控制缓存,如果不存在则新增一条控制
                            ManualCrossControlGetByTypeZkPointBkPointRequest mcrequest = new ManualCrossControlGetByTypeZkPointBkPointRequest();
                            mcrequest.Type    = 12;
                            mcrequest.ZkPoint = analysisConfigInfo.Id;
                            mcrequest.BkPoint = point.Point;
                            var kzinfo        = manualCrossControlService.GetManualCrossControlByTypeZkPointBkPoint(mcrequest).Data.FirstOrDefault();

                            if (kzinfo == null)
                            {
                                Jc_JcsdkzInfo JkInfo = new Jc_JcsdkzInfo();
                                JkInfo.ID            = IdHelper.CreateLongId().ToString();
                                JkInfo.Type          = 12;
                                JkInfo.ZkPoint       = analysisConfigInfo.Id;
                                JkInfo.Bkpoint       = point.Point;
                                JkInfo.Upflag        = level;

                                jckzinfos.Add(JkInfo);
                            }
                            else if (kzinfo.Upflag != level)
                            {
                                kzinfo.Upflag = level;
                                updatejckzinfos.Add(kzinfo);
                            }
                        });

                        //删除已经结束的分级报警传感器  20180919
                        List <Jc_JcsdkzInfo> manualCrossControlList = manualCrossControlService.GetAllManualCrossControl().Data.FindAll(a => a.Upflag != "0");
                        foreach (Jc_JcsdkzInfo manualCrossControl in manualCrossControlList)
                        {
                            bool isInanalysisConfigInfo = false;
                            foreach (AnalysisSuccessfulPointInfo point in analysisConfigInfo.AnalysisSuccessfulPointList)
                            {
                                if (point.Point == manualCrossControl.Bkpoint)
                                {
                                    isInanalysisConfigInfo = true;
                                    break;
                                }
                            }
                            if (!isInanalysisConfigInfo)//如果在当前成立的表达式中没有找到对应交叉控制测点的表达式,则清除传感器分级报警
                            {
                                manualCrossControl.Upflag = "0";
                                updatejckzinfos.Add(manualCrossControl);
                            }
                        }

                        if (jckzinfos.Count > 0)
                        {
                            ManualCrossControlsRequest batchinsertrequest = new ManualCrossControlsRequest();
                            batchinsertrequest.ManualCrossControlInfos = jckzinfos;
                            manualCrossControlService.AddManualCrossControls(batchinsertrequest);
                        }

                        if (updatejckzinfos.Count > 0)
                        {
                            ManualCrossControlsRequest updaterequest = new ManualCrossControlsRequest();
                            updaterequest.ManualCrossControlInfos = updatejckzinfos;
                            manualCrossControlService.UpdateManualCrossControls(updaterequest);
                        }
                    }
                }
                //如果分析不成立,则修改报警等级为0
                else
                {
                    ManualCrossControlGetByTypeZkPointRequest mcrequest = new ManualCrossControlGetByTypeZkPointRequest();
                    mcrequest.Type    = 12;
                    mcrequest.ZkPoint = analysisConfigInfo.Id;
                    var kzinfo = manualCrossControlService.GetManualCrossControlByTypeZkPoint(mcrequest).Data;

                    if (kzinfo.Count > 0)
                    {
                        kzinfo.ForEach(kz => kz.Upflag = "0");

                        ManualCrossControlsRequest updaterequest = new ManualCrossControlsRequest();
                        updaterequest.ManualCrossControlInfos = kzinfo;
                        manualCrossControlService.UpdateManualCrossControls(updaterequest);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info("传感器分级报警输出出错!" + ex.Message);
            }
        }
 public BasicResponse <List <Jc_JcsdkzInfo> > GetAllManualCrossControl()
 {
     return(_ManualCrossControlService.GetAllManualCrossControl());
 }
Esempio n. 4
0
        private void OpenThreadToDoWork()
        {
            IManualCrossControlService manualCrossControlService = ServiceFactory.Create <IManualCrossControlService>();
            //数据分析线程
            var startDataAnalysisThread = new Thread(new ThreadStart(() =>
            {
                do
                {
                    try
                    {
                        StartDataAnalysis();//开始数据分析
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error(string.Format("分析出现错误! 错误消息:{0}", ex.StackTrace));
                    }
                    finally
                    {
                        Thread.Sleep(5000);
                    }
                } while (IsRunning);
            }));

            startDataAnalysisThread.IsBackground = true;
            startDataAnalysisThread.Start();

            //分析结果处理线程
            var asyncAnalysisHandlerThread = new Thread(new ThreadStart(() =>
            {
                do
                {
                    var analysisConfigInfoList = AnalysisModelCache.Instance.Query();
                    for (int i = 0; IsRunning && null != analysisConfigInfoList && i < analysisConfigInfoList.Count; i++)
                    {
                        if (AnalysisReulstHandlerEvent != null)
                        {
                            try
                            {
                                AnalysisReulstHandlerEvent(new AnalysisChangedEventArgs()
                                {
                                    AnalysisConfig = analysisConfigInfoList[i]
                                });
                            }
                            catch (Exception ex)
                            {
                                LogHelper.Error(string.Format("处理分析模型:{0}的输出出错. 错误消息:{1}", analysisConfigInfoList[i].Name, ex.StackTrace));
                            }
                        }
                        Thread.Sleep(100);
                    }
                    try
                    {
                        //判断,如果分级报警交叉控制中存在已删除的模型,则解除控制  20180919
                        //删除已经结束的分级报警传感器  20180919
                        List <Jc_JcsdkzInfo> updatejckzinfos        = new List <Jc_JcsdkzInfo>();
                        List <Jc_JcsdkzInfo> manualCrossControlList = manualCrossControlService.GetAllManualCrossControl().Data.FindAll(a => a.Upflag != "0");
                        foreach (Jc_JcsdkzInfo manualCrossControl in manualCrossControlList)
                        {
                            bool isInanalysisConfigInfo = false;
                            if (analysisConfigInfoList.FindAll(a => a.Id == manualCrossControl.ZkPoint).Count > 0)
                            {
                                isInanalysisConfigInfo = true;
                            }
                            if (!isInanalysisConfigInfo)//如果模型已经删除,则解除传感器分级报警  20180919
                            {
                                manualCrossControl.Upflag = "0";
                                updatejckzinfos.Add(manualCrossControl);
                            }
                        }
                        if (updatejckzinfos.Count > 0)
                        {
                            ManualCrossControlsRequest updaterequest = new ManualCrossControlsRequest();
                            updaterequest.ManualCrossControlInfos    = updatejckzinfos;
                            manualCrossControlService.UpdateManualCrossControls(updaterequest);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    Thread.Sleep(500);
                } while (IsRunning);
            }));

            asyncAnalysisHandlerThread.IsBackground = true;
            asyncAnalysisHandlerThread.Start();
        }