| | |
| | | [HttpGet] |
| | | public List<PlanAnaDto> Calculate_debug() |
| | | { |
| | | var responseText = System.IO.File.ReadAllText(@"E:\WorkData\IStation\result.txt");//(测试用的) |
| | | var responseText = System.IO.File.ReadAllText(@"D:\WorkData\IStation\result_1021.json");//(测试用的) |
| | | var planDataList = JsonHelper.Json2Object<List<PlanAnaData>>(responseText); |
| | | return CalculateCore(planDataList); |
| | | } |
| | |
| | | return default; |
| | | } |
| | | |
| | | var factoryIds = planDataList.SelectMany(x => x.datas).Select(x => x.factory).Distinct().ToList(); |
| | | var sg_factoryIds = planDataList.SelectMany(x => x.datas).Select(x => x.factory).Distinct().ToList(); |
| | | var vmList = new List<PlanAnaDto>(); |
| | | foreach (var factoryId in factoryIds) |
| | | foreach (var sg_factoryId in sg_factoryIds) |
| | | { |
| | | //找到相关泵站,并进行计算 |
| | | if (!PlanAnaConstant.FactoryDict.ContainsKey(factoryId)) |
| | | var stationInfo = ShysPlanHelper.GetStationInfo(sg_factoryId); |
| | | if (stationInfo == null) |
| | | { |
| | | LogHelper.Error("未找到id:{factoryId},对应的泵站"); |
| | | return default; |
| | | // LogHelper.Error("未找到id:{factoryId},对应的泵站"); |
| | | continue; |
| | | } |
| | | var stationId = PlanAnaConstant.FactoryDict[factoryId]; |
| | | |
| | | var stationId = stationInfo.ID; |
| | | var station = new Service.Station().GetByID(_corpId, stationId); |
| | | if (station == null) |
| | | { |
| | | LogHelper.Error($"上海原水能耗计划分析计算中, 泵站id:{stationId}, 数据库中未找到此泵站"); |
| | | continue; |
| | | } |
| | | var calculator = PlanAnaCalculatorFactory.CreateCalculator(_corpId, ObjectType.Station, stationId); |
| | | var calculator = stationInfo.Calculator; |
| | | if (calculator == null) |
| | | { |
| | | LogHelper.Error($"上海原水能耗计划分析计算中, 泵站id:{stationId}, 未构建计算器"); |
| | | continue; |
| | | } |
| | | calculator.SetStationID(4, stationInfo.ID);//设置ID |
| | | |
| | | //构造计算入参 |
| | | var sumRecordList = new List<MonthSumRecord>(); |
| | | foreach (var planData in planDataList) |
| | |
| | | var sumRecord = new MonthSumRecord(); |
| | | sumRecord.Month = planData.timeflag; |
| | | sumRecord.HourRecords = new List<HourSumRecord>(); |
| | | var factoryData = planData.datas.Find(t => t.factory == factoryId); |
| | | var factoryData = planData.datas.Find(t => t.factory == sg_factoryId); |
| | | for (int i = 0; i <= 23; i++) |
| | | { |
| | | var hourSumRecord = new HourSumRecord(); |
| | |
| | | var ff = scadaItem.values.Find(t => t.GetHour() == i ); |
| | | if(ff == null) |
| | | { |
| | | LogHelper.Error($"上海原水能耗计划分析计算中, 泵站id:{stationId}, {scadaItem.tagname} 时间点{i}, 未找到数据" ); |
| | | return default; |
| | | if (calculator.Is液位Monitor(scadaItem.tagname)) |
| | | { |
| | | scadaRecord.RecordValue = 0; |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Error($"上海原水能耗计划分析计算中, 泵站id:{stationId}, {scadaItem.tagname} 时间点{i}, 未找到数据"); |
| | | return default; |
| | | } |
| | | |
| | | } |
| | | scadaRecord.RecordValue = ff.value; |
| | | else |
| | | { |
| | | scadaRecord.RecordValue = ff.value; |
| | | } |
| | | |
| | | hourSumRecord.Records.Add(scadaRecord); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | string error_info=""; |
| | | var resultList = calculator.Calc(station, factoryId, sumRecordList, out error_info); |
| | | var resultList = calculator.Calc(station, sg_factoryId, sumRecordList, out error_info); |
| | | if (resultList == null || resultList.Count() < 1) |
| | | { |
| | | LogHelper.Error($"上海原水能耗计划分析计算中,泵站名称:{station.Name} 泵站id:{stationId},计算错误,原因是:{error_info}" ); |
| | |
| | | |
| | | //生成返回结果 |
| | | var vmItem = new PlanAnaDto(); |
| | | vmItem.factory = factoryId; |
| | | vmItem.factory = sg_factoryId; |
| | | vmItem.name = station.Name; |
| | | vmItem.values = new List<List<double>>(); |
| | | for (int i = 1; i <= 12; i++) |