计划分析 增加 GetMonitorNameByTag函数
| | |
| | | using IStation.Calculation; |
| | | using IStation.Dto; |
| | | using System.Collections.Generic; |
| | | using Mapster; |
| | | |
| | | namespace IStation.Application |
| | | { |
| | |
| | | |
| | | var responseText = System.IO.File.ReadAllText(path);//(æµè¯ç¨ç) |
| | | var planDataList = JsonHelper.Json2Object<List<PlanAnaData>>(responseText); |
| | | return CalculateCore(planDataList); |
| | | |
| | | var ret = CalculateCore(planDataList ); |
| | | |
| | | return ret; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="planDataList"></param> |
| | | /// <returns></returns> |
| | | private List<PlanAnaDto> CalculateCore(List<PlanAnaData> planDataList) |
| | | 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) |
| | | { |
| | | var vmItem = Ana(planDataList, sg_factoryId); |
| | | string 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 }); |
| | | } |
| | | } |
| | | return vmList; |
| | | } |
| | | |
| | | private PlanAnaDto Ana(List<PlanAnaData> planDataList, int sg_factoryId) |
| | | private PlanAnaDto Ana(List<PlanAnaData> planDataList, int sg_factoryId, out string error_info) |
| | | { |
| | | //æ¾å°ç¸å
³æ³µç«ï¼å¹¶è¿è¡è®¡ç® |
| | | var stationInfo = ShysPlanHelper.GetStationInfo(sg_factoryId); |
| | | if (stationInfo == null) |
| | | { |
| | | // LogHelper.Error("æªæ¾å°id:{factoryId},对åºçæ³µç«"); |
| | | error_info = "æªæ¾å°id:{factoryId},对åºçæ³µç«" ; |
| | | return null; |
| | | } |
| | | |
| | |
| | | var station = new Service.Station().GetByID(_corpId, stationId); |
| | | if (station == null) |
| | | { |
| | | LogHelper.Error($"䏿µ·åæ°´è½è计ååæè®¡ç®ä¸ï¼ æ³µç«id:{stationId}, æ°æ®åºä¸æªæ¾å°æ¤æ³µç«"); |
| | | error_info = $"æ³µç«id:{stationId}, æ°æ®åºä¸æªæ¾å°æ¤æ³µç«" ; |
| | | return null; |
| | | } |
| | | var calculator = stationInfo.Calculator; |
| | | if (calculator == null) |
| | | { |
| | | LogHelper.Error($"䏿µ·åæ°´è½è计ååæè®¡ç®ä¸ï¼ æ³µç«id:{stationId}, æªæå»ºè®¡ç®å¨"); |
| | | error_info = $"æ³µç«id:{stationId}, æªæå»ºè®¡ç®å¨" ; |
| | | return null; |
| | | } |
| | | calculator.SetStationID(_corpId, stationInfo.ID);//设置ID |
| | |
| | | { |
| | | scadaRecord.RecordValue = 0; |
| | | } |
| | | else if (calculator.Isæ¶²ä½Monitor(scadaItem.tagname)) |
| | | { |
| | | scadaRecord.RecordValue = 0; |
| | | } |
| | | //else if (calculator.Isæ¶²ä½Monitor(scadaItem.tagname)) |
| | | //{ |
| | | // scadaRecord.RecordValue = 0; |
| | | //} |
| | | else |
| | | { |
| | | LogHelper.Error($"䏿µ·åæ°´è½è计ååæè®¡ç®ä¸ï¼ æ³µç«id:{stationId}, {scadaItem.tagname} æ¶é´ç¹{i}, æªæ¾å°æ°æ®"); |
| | | error_info = $"factoryId:{sg_factoryId}, æ³µç«id:{stationId}, æµè¯tag:{scadaItem.tagname} ,æµç¹åç§°{calculator.GetMonitorNameByTag(scadaItem.tagname)},æ¶é´ç¹{i}, æªæ¾å°å¯¹åºæ°æ®" ; |
| | | return null; |
| | | } |
| | | } |
| | |
| | | sumRecordList.Add(sumRecord); |
| | | } |
| | | |
| | | string error_info = ""; |
| | | var resultList = calculator.Calc(station, sg_factoryId, sumRecordList, out error_info); |
| | | string ana_error_info = ""; |
| | | var resultList = calculator.Calc(station, sg_factoryId, sumRecordList, out ana_error_info); |
| | | if (resultList == null || resultList.Count() < 1) |
| | | { |
| | | LogHelper.Error($"䏿µ·åæ°´è½è计ååæè®¡ç®ä¸ï¼æ³µç«åç§°:{station.Name} æ³µç«id:{stationId},计ç®é误,åå æ¯:{error_info}"); |
| | | error_info = $"factoryId:{sg_factoryId},æ³µç«åç§°:{station.Name} æ³µç«id:{stationId},åæé误,åå æ¯:{ana_error_info}"; |
| | | LogHelper.Error("䏿µ·åæ°´è½è计ååæè®¡ç®ä¸ï¼"+error_info); |
| | | return null; |
| | | } |
| | | |
| | |
| | | vmItem.values.Add(new List<double>() { result.Qt, result.Dt, result.WP }); |
| | | } |
| | | } |
| | | |
| | | error_info = null; |
| | | return vmItem; |
| | | } |
| | | |
| | |
| | | /// 12ä¸ªææ°æ®æ°ç»[便°´é,èçµé,å卿°´è½è] |
| | | /// </summary> |
| | | public List<List<double>> values { get; set; } |
| | | |
| | | /// <summary> |
| | | /// éè¯¯ä¿¡æ¯ |
| | | /// </summary> |
| | | public string Error { get; set; } |
| | | } |
| | | |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="tagname"></param> |
| | | /// <returns></returns> |
| | | public virtual string GetMonitorNameByTag(string tagname) |
| | | { |
| | | return "æªç¥æµç¹"; |
| | | } |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="tagname"></param> |
| | | /// <returns></returns> |
| | | public virtual bool IsIgnoreAble(string tagname) |
| | | { |
| | | return false; |
| | |
| | | var daySum = this._dispatchAnaCalc.CalcSumData(allHourRequests,true, out error_info); |
| | | if (daySum == null || daySum.Qt <= 0) |
| | | { |
| | | error_info = "éèæ²,è°åº¦åæå¤±è´¥,åå :" + error_info; |
| | | error_info = "è°åº¦åæå¤±è´¥,åå :" + error_info; |
| | | return null; |
| | | } |
| | | //è®¡ç®æ¯æçæ±æ» |
| | |
| | | private static void Inital() |
| | | { |
| | | _dict = new Dictionary<int, StationInfo>(); |
| | | _dict.Add(1, new StationInfo(2, new IStation.Calculation.shysé¿å
´æ³µç«()));//OK |
| | | _dict.Add(2, new StationInfo(12, new IStation.Calculation.shysäºå·æ²åæ¡¥æ¹å()));//ok |
| | | //_dict.Add(3, new StationInfo(9, new IStation.Calculation.shysäºå·æ²éæµ·æ¹å())); |
| | | _dict.Add(4, new StationInfo(3, new IStation.Calculation.shysäºå·æ²ä¸¥æ¡¥æ¹å1()));//OK |
| | | _dict.Add(5, new StationInfo(5, new IStation.Calculation.shysäºå·æ²ä¸¥æ¡¥æ¹å2()));//OK |
| | | // åºæ°´æ»ç®¡åå, æ²¡ææ°æ® |
| | | _dict.Add(15, new StationInfo(19, new IStation.Calculation.shyséæ³½æ³µç«())); |
| | | |
| | | //_dict.Add(1, new StationInfo(2, new IStation.Calculation.shysé¿å
´æ³µç«()));//OK |
| | | //_dict.Add(2, new StationInfo(12, new IStation.Calculation.shysäºå·æ²åæ¡¥æ¹å()));//ok |
| | | |
| | | //_dict.Add(4, new StationInfo(3, new IStation.Calculation.shysäºå·æ²ä¸¥æ¡¥æ¹å1()));//OK |
| | | //_dict.Add(5, new StationInfo(5, new IStation.Calculation.shysäºå·æ²ä¸¥æ¡¥æ¹å2()));//OK |
| | | |
| | | |
| | | ////_dict.Add(3, new StationInfo(9, new IStation.Calculation.shysäºå·æ²éæµ·æ¹å())); |
| | | //_dict.Add(6, new StationInfo(4, new IStation.Calculation.shys严桥泵ç«())); |
| | | //_dict.Add(7, new StationInfo(6, new IStation.Calculation.shys临æ±1å·æ³µæ¿())); |
| | | //_dict.Add(8, new StationInfo(7, new IStation.Calculation.shys临æ±2å·æ³µæ¿())); |
| | |
| | | //_dict.Add(12, new StationInfo(15, new IStation.Calculation.shyséè¡ä¸è¾())); |
| | | //_dict.Add(13, new StationInfo(16, new IStation.Calculation.shyséè¡äºè¾())); |
| | | //_dict.Add(14, new StationInfo(17, new IStation.Calculation.shysæ³°åæ³µç«())); |
| | | //_dict.Add(15, new StationInfo(19, new IStation.Calculation.shyséæ³½æ³µç«())); |
| | | // |
| | | //_dict.Add(16, new StationInfo(20, new IStation.Calculation.shysæ¾æ±æ³µç«())); |
| | | //_dict.Add(17, new StationInfo(21, new IStation.Calculation.shys大桥泵ç«())); |
| | | |
| | | |
| | | |
| | | // {1,2},//é¿å
´æ³µç« |
| | | // {2,12},//äºå·æ²åæ¡¥æ¹å |
| | |
| | | // {15,19},//éæ³½æ³µç« |
| | | // {16,20},//æ¾æ±æ³µç« |
| | | // {17,21},//å¤§æ¡¥æ³µç« |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// æµç¹åå
¸(è¿ä¸ªæ¯ä¸ªæ³µç«é½ä¸ä¸æ ·) |
| | | /// </summary> |
| | | |
| | | |
| | | private Tuple<string, long> monitoråºæ°´æ»ç®¡1åå = new Tuple<string, long>("_0402010201090105001", 859); |
| | | private Tuple<string, long> monitoråºæ°´æ»ç®¡1ç¬æ¶æµé = new Tuple<string, long>("_0402060601010103000", 860); |
| | | private Tuple<string, long> monitoråºæ°´æ»ç®¡2åå = new Tuple<string, long>("_0402010201090105002", 862); |
| | |
| | | private Tuple<string, long> monitorè¿æ°´åæ± æ¶²ä½1 = new Tuple<string, long>("_0402010201090104011", 856); |
| | | private Tuple<string, long> monitorè¿æ°´åæ± æ¶²ä½2 = new Tuple<string, long>("_0402010201091104123", 857); |
| | | private Tuple<string, long> monitorè¿æ°´åæ± æ¶²ä½3 = new Tuple<string, long>("_0402010201091104122", 858); |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®ä¸é«æä¾çåæ°,æå»ºè°åº¦åææéçåæ°, (è¿ä¸ªæ¯ä¸ªæ³µç«é½ä¸ä¸æ ·) |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// æµç¹åå
¸(è¿ä¸ªæ¯ä¸ªæ³µç«é½ä¸ä¸æ ·) |
| | | /// </summary> |
| | | |
| | | |
| | | private Tuple<string, long> monitoråºæ°´æ»ç®¡1åå = new Tuple<string, long>("_0402010201090105004", 917); |
| | | private Tuple<string, long> monitoråºæ°´æ»ç®¡1ç¬æ¶æµé = new Tuple<string, long>("_0402010201090103020", 918); |
| | | private Tuple<string, long> monitoråºæ°´æ»ç®¡2åå = new Tuple<string, long>("_0402010201090105003", 920); |
| | | private Tuple<string, long> monitoråºæ°´æ»ç®¡2ç¬æ¶æµé = new Tuple<string, long>("_0402010201090103017", 921); |
| | | private Tuple<string, long> monitorè¿æ°´åæ± æ¶²ä½ = new Tuple<string, long>("_0402010201080204002", 916); |
| | | |
| | | public override bool Isæ¶²ä½Monitor(string tagname) |
| | | { |
| | | if (monitorè¿æ°´åæ± æ¶²ä½.Item1 == tagname) |
| | | return true; |
| | | return false ; |
| | | } |
| | | |
| | | public override string GetMonitorNameByTag(string tagname) |
| | | { |
| | | if (monitoråºæ°´æ»ç®¡1åå.Item1 == tagname) |
| | | return "åºæ°´æ»ç®¡1åå"; |
| | | if (monitoråºæ°´æ»ç®¡1ç¬æ¶æµé.Item1 == tagname) |
| | | return "åºæ°´æ»ç®¡1ç¬æ¶æµé"; |
| | | if (monitoråºæ°´æ»ç®¡2åå.Item1 == tagname) |
| | | return "åºæ°´æ»ç®¡2åå"; |
| | | if (monitoråºæ°´æ»ç®¡2ç¬æ¶æµé.Item1 == tagname) |
| | | return "åºæ°´æ»ç®¡2ç¬æ¶æµé"; |
| | | return "æªç¥æµç¹"; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®ä¸é«æä¾çåæ°,æå»ºè°åº¦åææéçåæ°, (è¿ä¸ªæ¯ä¸ªæ³µç«é½ä¸ä¸æ ·) |
| | | /// </summary> |