Esempio n. 1
0
        public override void Load()
        {
            var response = hourService.GetDataAnalysisHistoryData(new Basic.Framework.Web.BasicRequest());

            if (response.IsSuccess && response.Data != null)
            {
                _cache.Clear();
                _cache = response.Data;
            }
        }
        protected override void DoWork()
        {
            DateTime analysisModelServerSideTime = DateTime.MinValue;

            try
            {
                DateTime pointDefineServerSideTime = DateTime.MinValue;
                BasicResponse <string> pointDefineLastChangedTimeResponse = largeDataAnalysisLastChangedService.GetPointDefineLastChangedTime(new LargeDataAnalysisLastChangedRequest());
                if (pointDefineLastChangedTimeResponse.IsSuccess && !string.IsNullOrEmpty(pointDefineLastChangedTimeResponse.Data))
                {
                    pointDefineServerSideTime = DateTime.Parse(pointDefineLastChangedTimeResponse.Data);
                }

                var getAllHistoryDataResponse = hourService.GetDataAnalysisHistoryData(new BasicRequest());
                if (getAllHistoryDataResponse.IsSuccess && getAllHistoryDataResponse.Data != null)
                {
                    if (pointDefineServerSideTime > pointDefineLastChangedTime || historyDataCache.Count == 0)
                    {
                        historyDataCache.Clear();
                        foreach (var item in getAllHistoryDataResponse.Data)
                        {
                            historyDataCache.AddItem(item);
                        }
                        pointDefineLastChangedTime = pointDefineServerSideTime;
                    }
                    else
                    {
                        foreach (var item in getAllHistoryDataResponse.Data)
                        {
                            var oldItem = historyDataCache.Query(q => q.PointId == item.PointId).FirstOrDefault();
                            if (null == oldItem)
                            {
                                historyDataCache.AddItem(item);
                            }
                            else
                            {
                                historyDataCache.UpdateItem(item);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("更新内部维护的模拟量历史数据时出错:{0}", ex.StackTrace));
            }
            base.DoWork();
        }
Esempio n. 3
0
 public BasicResponse <List <DataAnalysisHistoryDataInfo> > GetDataAnalysisHistoryData(BasicRequest request)
 {
     return(hourService.GetDataAnalysisHistoryData(request));
 }
        /// <summary>分析函数
        ///
        /// </summary>
        private static void Analyze()
        {
            var req      = new PointDefineCacheGetAllRequest();
            var allPoint = PointDefineCacheService.GetAllPointDefineCache(req).Data;

            var req2 = new BasicRequest();
            var res2 = JcHourService.GetDataAnalysisHistoryData(req2);
            var dataAnalysisHistory = res2.Data;

            var res = GascontentanalyzeconfigService.GetAllGascontentanalyzeconfigListCache();
            var allGascontentanalyzeconfig = res.Data;

            foreach (var item in allGascontentanalyzeconfig)
            {
                double height    = Convert.ToDouble(item.Height);    //巷道高
                double width     = Convert.ToDouble(item.Width);     //巷道宽
                double thickness = Convert.ToDouble(item.Thickness); //煤层厚度
                double speed     = Convert.ToDouble(item.Speed);     //掘进速度m/Month
                double length    = Convert.ToDouble(item.Length);    //巷道已暴露长度m(40)
                double acreage   = Convert.ToDouble(item.Acreage);   //断面
                double percent   = Convert.ToDouble(item.Percent);   //煤的挥发分%====整数
                double wind      = Convert.ToDouble(item.Wind);      //风量

                var info = dataAnalysisHistory.FirstOrDefault(m => m.PointId == item.Pointid);
                if (info == null)
                {
                    continue;
                }
                var monthAvg = Convert.ToDouble(info.MonthAverageValue); //月平均浓度

                double d = 0;                                            //为煤的周长
                if (thickness <= 3)
                {
                    d = 2 * thickness;
                }
                else
                {
                    d = 2 * (height + width);
                }

                speed = speed / 43200.0;          //为每分钟的掘进速度
                var a = d * speed * (2 * Math.Pow(length / speed, 0.5) - 1);
                acreage = acreage * speed * 1.45; //为每分钟的平均落煤量[SVY初台为断面计算之后为落煤量]
                var b  = acreage;
                var c  = 0.026 * (0.0004 * Math.Pow(percent, 2) + 0.16);
                var d1 = 20.252 * Math.Pow(percent, -0.7064);
                var q  = wind * monthAvg;

                //test
                var w0 = (q + b * d1) / (a * c + b);
                //var w0 = 0;

                var comparevalue = Convert.ToDouble(item.Comparevalue);

                //更新实时值
                var req6 = new UpdateRealTimeValueRequest
                {
                    Id            = item.Id,
                    RealTimeValue = w0.ToString("0.##"),
                    State         = w0 >= comparevalue ? "报警" : "正常"
                };
                GasContentAnalyzeConfigCacheService.UpdateRealTimeValue(req6);

                var req3 = new GetCacheByConditionRequest {
                    Condition = m => m.GasContentAnalyzeConfigId == item.Id
                };
                var res3       = GasContentAlarmCacheService.GetCacheByCondition(req3);
                var alarmCache = res3.Data;

                if (w0 >= comparevalue)     //报警
                {
                    if (alarmCache.Count == 0)
                    {
                        var pointInfo = allPoint.FirstOrDefault(m => m.PointID == item.Pointid);
                        if (pointInfo == null)
                        {
                            continue;
                        }

                        var alarmInfo = new GasContentAlarmInfo
                        {
                            Id = IdHelper.CreateLongId().ToString(),
                            GasContentAnalyzeConfigId = item.Id,
                            GasContent = w0.ToString("0.##"),
                            Point      = pointInfo.Point,
                            Location   = pointInfo.Wz
                        };

                        var req4 = new AddCacheRequest
                        {
                            Info = alarmInfo
                        };
                        GasContentAlarmCacheService.AddCache(req4);
                    }
                }
                else        //解除报警
                {
                    if (alarmCache.Count != 0)
                    {
                        var req5 = new DeleteCachesRequest
                        {
                            Infos = alarmCache
                        };
                        GasContentAlarmCacheService.DeleteCaches(req5);
                    }
                }
            }
        }