| | |
| | | [HttpGet] |
| | | public List<PlanAnaDto> Calculate_debug() |
| | | { |
| | | var path = @"D:\WorkData\IStation\result_1024lq.json"; |
| | | var path = @"D:\WorkData\IStation\result_20221114.json"; |
| | | if (!System.IO.File.Exists(path)) |
| | | return null; |
| | | |
| | |
| | | return ret; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 计算-Web |
| | | /// </summary> |
| | | [AllowAnonymous] |
| | | [NonUnify] |
| | | [Route("Calculate@Web")] |
| | | [HttpPost] |
| | | public List<PlanAnaDto> Calculate_Web([Required] List<PlanAnaData> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | LogHelper.Error("上海原水能耗计划分析计算接口入参为空"); |
| | | return default; |
| | | } |
| | | |
| | | var ret = CalculateCore(list); |
| | | return ret; |
| | | } |
| | | |
| | | #region 分析核心 |
| | | |
| | | /// <summary> |
| | | /// 分析核心 |
| | | /// </summary> |
| | | /// <param name="planDataList"></param> |
| | | /// <returns></returns> |
| | | private List<PlanAnaDto> CalculateCore(List<PlanAnaData> planDataList ) |
| | | /// <param name="planDataList"></param> |
| | | private List<PlanAnaDto> CalculateCore(List<PlanAnaData> planDataList) |
| | | { |
| | | if (planDataList == null || planDataList.Count < 1) |
| | | { |
| | | { |
| | | LogHelper.Error("上海原水能耗计划分析计算三高返回接口出参为空"); |
| | | return default; |
| | | } |
| | | if (planDataList.Exists(x => x.datas == null || x.datas.Count < 1)) |
| | | { |
| | | { |
| | | LogHelper.Error("上海原水能耗计划分析计算三高返回接口出参格式错误"); |
| | | return default; |
| | | } |
| | | |
| | | var sg_factoryIds = planDataList.SelectMany(x => x.datas).Select(x => x.factory).Distinct().ToList(); |
| | | var vmList = new List<PlanAnaDto>(); |
| | | |
| | | |
| | | |
| | | |
| | | foreach (var sg_factoryId in sg_factoryIds) |
| | | { |
| | | string error_info; |
| | | var vmItem = Ana(planDataList, sg_factoryId,out error_info); |
| | | var vmItem = Ana(planDataList, sg_factoryId, out error_info); |
| | | if (vmItem != null) |
| | | { |
| | | vmList.Add(vmItem); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | vmList.Add(new PlanAnaDto() { factory=sg_factoryId, name="", Error = error_info }); |
| | | vmList.Add(new PlanAnaDto() { factory = sg_factoryId, name = "", error = error_info }); |
| | | } |
| | | } |
| | | return vmList; |
| | |
| | | var stationInfo = ShysPlanHelper.GetStationInfo(sg_factoryId); |
| | | if (stationInfo == null) |
| | | { |
| | | error_info = "未找到id:{factoryId},对应的泵站" ; |
| | | error_info = "未找到id:{factoryId},对应的泵站"; |
| | | return null; |
| | | } |
| | | |
| | |
| | | var station = new Service.Station().GetByID(_corpId, stationId); |
| | | if (station == null) |
| | | { |
| | | error_info = $"泵站id:{stationId}, 数据库中未找到此泵站" ; |
| | | error_info = $"泵站id:{stationId}, 数据库中未找到此泵站"; |
| | | return null; |
| | | } |
| | | var calculator = stationInfo.Calculator; |
| | | if (calculator == null) |
| | | { |
| | | error_info = $"泵站id:{stationId}, 未构建计算器" ; |
| | | error_info = $"泵站id:{stationId}, 未构建计算器"; |
| | | return null; |
| | | } |
| | | calculator.SetStationID(_corpId, stationInfo.ID);//设置ID |
| | |
| | | //} |
| | | else |
| | | { |
| | | error_info = $"factoryId:{sg_factoryId}, 泵站id:{stationId}, 测试tag:{scadaItem.tagname} ,测点名称{calculator.GetMonitorNameByTag(scadaItem.tagname)},时间点{i}, 未找到对应数据" ; |
| | | error_info = $"factoryId:{sg_factoryId}, 泵站id:{stationId}, 测试tag:{scadaItem.tagname} ,测点名称{calculator.GetMonitorNameByTag(scadaItem.tagname)},时间点{i}, 未找到对应数据"; |
| | | return null; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | scadaRecord.RecordValue = ff.value; |
| | | scadaRecord.RecordValue = calculator.CorrectMonitorValue(scadaItem.tagname, ff.value); |
| | | } |
| | | |
| | | hourSumRecord.Records.Add(scadaRecord); |
| | |
| | | sumRecordList.Add(sumRecord); |
| | | } |
| | | |
| | | string ana_error_info = ""; |
| | | string ana_error_info = ""; |
| | | var resultList = calculator.Calc(station, sg_factoryId, sumRecordList, out ana_error_info); |
| | | if (resultList == null || resultList.Count() < 1) |
| | | { |
| | |
| | | vmItem.factory = sg_factoryId; |
| | | vmItem.name = station.Name; |
| | | vmItem.values = new List<List<double>>(); |
| | | vmItem.valueinfo = new List<string>(); |
| | | for (int i = 1; i <= 12; i++) |
| | | { |
| | | var result = resultList.Find(t => t.Month == i); |
| | | if (result == null) |
| | | { |
| | | vmItem.values.Add(new List<double>() { 0, 0, 0 }); |
| | | vmItem.valueinfo.Add("数据为空"); |
| | | } |
| | | else |
| | | { |
| | | vmItem.values.Add(new List<double>() { result.Qt, result.Dt, result.WP }); |
| | | vmItem.valueinfo.Add(result.Info); |
| | | } |
| | | } |
| | | error_info = null; |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |