From 19db3c68c67e27531e716567cefaa266e71a2baf Mon Sep 17 00:00:00 2001 From: Shuxia Ning <NingShuxia0927@outlook.com> Date: 星期五, 26 七月 2024 09:19:12 +0800 Subject: [PATCH] 更新检修状态,单泵累计运行时间() --- IStation.Service/07-global/01-helper/GlobalHelper.cs | 405 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 375 insertions(+), 30 deletions(-) diff --git a/IStation.Service/07-global/01-helper/GlobalHelper.cs b/IStation.Service/07-global/01-helper/GlobalHelper.cs index 5289bc4..20ba109 100644 --- a/IStation.Service/07-global/01-helper/GlobalHelper.cs +++ b/IStation.Service/07-global/01-helper/GlobalHelper.cs @@ -5,7 +5,6 @@ /// </summary> public class GlobalHelper { - #region 榛樿閰嶇疆 #region 娉垫爣蹇� @@ -108,6 +107,18 @@ public readonly static string 浜屽彇4娉礯绱杩愯鏃堕棿 = "10170"; public readonly static string 浜屽彇5娉礯绱杩愯鏃堕棿 = "10171"; + public readonly static string 浜屽彇1娉礯妫�淇姸鎬� = "10191"; + public readonly static string 浜屽彇2娉礯妫�淇姸鎬� = "10192"; + public readonly static string 浜屽彇3娉礯妫�淇姸鎬� = "10193"; + public readonly static string 浜屽彇4娉礯妫�淇姸鎬� = "10194"; + public readonly static string 浜屽彇5娉礯妫�淇姸鎬� = "10195"; + + public readonly static string 浜屽彇1娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜屽彇姘�1鍙蜂富姘存车.绱杩愯鏃堕棿"; + public readonly static string 浜屽彇2娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜屽彇姘�2鍙蜂富姘存车.绱杩愯鏃堕棿"; + public readonly static string 浜屽彇3娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜屽彇姘�3鍙蜂富姘存车.绱杩愯鏃堕棿"; + public readonly static string 浜屽彇4娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜屽彇姘�4鍙蜂富姘存车.绱杩愯鏃堕棿"; + public readonly static string 浜屽彇5娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜屽彇姘�5鍙蜂富姘存车.绱杩愯鏃堕棿"; + #endregion @@ -117,36 +128,29 @@ public readonly static string 鍢夊畾2绾縚鐬椂娴侀噺 = "10139"; public readonly static string 鍢夊畾3绾縚鐬椂娴侀噺 = "10140"; - public readonly static string 鍢夊畾1绾縚鐬椂娴侀噺_闀挎睙绠$綉鍥� = "10159"; public readonly static string 鍢夊畾2绾縚鐬椂娴侀噺_闀挎睙绠$綉鍥� = "10160"; public readonly static string 鍢夊畾3绾縚鐬椂娴侀噺_闀挎睙绠$綉鍥� = "10161"; - public readonly static string 鍢夊畾1绾縚琛ㄥご绱 = "10143"; public readonly static string 鍢夊畾2绾縚琛ㄥご绱 = "10144"; public readonly static string 鍢夊畾3绾縚琛ㄥご绱 = "10145"; - public readonly static string 鍢夊畾1绾縚绱娴侀噺_闀挎睙绠$綉鍥� = "10164"; public readonly static string 鍢夊畾2绾縚绱娴侀噺_闀挎睙绠$綉鍥� = "10165"; public readonly static string 鍢夊畾3绾縚绱娴侀噺_闀挎睙绠$綉鍥� = "10166"; - public readonly static string 鍢夊畾1绾縚鍘嬪姏 = "10128"; public readonly static string 鍢夊畾2绾縚鍘嬪姏 = "10129"; public readonly static string 鍢夊畾3绾縚鍘嬪姏 = "10130"; - public readonly static string 鍢夊畾1绾縚鍘嬪姏_闀挎睙绠$綉鍥� = "10154"; public readonly static string 鍢夊畾2绾縚鍘嬪姏_闀挎睙绠$綉鍥� = "10155"; public readonly static string 鍢夊畾3绾縚鍘嬪姏_闀挎睙绠$綉鍥� = "10156"; - public readonly static string 涓�杈揰鑰佸墠姹犲崡渚ф恫浣� = "10011"; public readonly static string 涓�杈揰鑰佸墠姹犲寳渚ф恫浣� = "10012"; public readonly static string 涓�杈揰鏂板墠姹犳恫浣� = "10013"; - public readonly static string 涓�杈�11娉礯鍑哄彛鍘嬪姏 = "10026"; public readonly static string 涓�杈�12娉礯鍑哄彛鍘嬪姏 = "10027"; @@ -156,7 +160,6 @@ public readonly static string 涓�杈�16娉礯鍑哄彛鍘嬪姏 = "10031"; public readonly static string 涓�杈�17娉礯鍑哄彛鍘嬪姏 = "10032"; public readonly static string 涓�杈�18娉礯鍑哄彛鍘嬪姏 = "10033"; - public readonly static string 涓�杈�11娉礯杞�� = "10084"; public readonly static string 涓�杈�12娉礯杞�� = "10085"; @@ -171,7 +174,6 @@ public readonly static string 涓�杈�14娉礯棰戠巼 = "10069"; public readonly static string 涓�杈�17娉礯棰戠巼 = "10070"; public readonly static string 涓�杈�18娉礯棰戠巼 = "10071"; - public readonly static string 涓�杈�11娉礯杩愯鐘舵�� = "10046"; public readonly static string 涓�杈�12娉礯杩愯鐘舵�� = "10047"; // 10150 is null @@ -205,7 +207,14 @@ public readonly static string 涓�杈�17娉礯鏈夊姛鍔熺巼 = "10107"; public readonly static string 涓�杈�18娉礯鏈夊姛鍔熺巼 = "10108"; - + public readonly static string 涓�杈�11娉礯绱杩愯鏃堕棿_鍘嗗彶 = "涓�杈撴按娉�11鍙峰彉棰戝崟娉�.姘存车绱杩愯鏃堕棿"; + public readonly static string 涓�杈�12娉礯绱杩愯鏃堕棿_鍘嗗彶 = "涓�杈撴按娉�12鍙峰彉棰戝崟娉�1.姘存车杩愯鏃堕棿"; + public readonly static string 涓�杈�13娉礯绱杩愯鏃堕棿_鍘嗗彶 = "涓�杈撴按娉�13鍙峰彉棰戝崟娉�.姘存车绱杩愯鏃堕棿"; + public readonly static string 涓�杈�14娉礯绱杩愯鏃堕棿_鍘嗗彶 = "涓�杈撴按娉�14鍙峰彉棰戝崟娉�.姘存车绱杩愯鏃堕棿"; + public readonly static string 涓�杈�15娉礯绱杩愯鏃堕棿_鍘嗗彶 = "HF涓�杈撴按15鍙峰伐棰戞帶鍒跺浘.姘存车绱杩愯鏃堕棿"; + public readonly static string 涓�杈�16娉礯绱杩愯鏃堕棿_鍘嗗彶 = "HF涓�杈撴按16鍙峰伐棰戞帶鍒跺浘.姘存车绱杩愯鏃堕棿"; + public readonly static string 涓�杈�17娉礯绱杩愯鏃堕棿_鍘嗗彶 = "涓�杈撴按娉�17鍙峰彉棰戝崟娉�.姘存车绱杩愯鏃堕棿"; + public readonly static string 涓�杈�18娉礯绱杩愯鏃堕棿_鍘嗗彶 = "涓�杈撴按娉�18鍙峰彉棰戝崟娉�.姘存车绱杩愯鏃堕棿"; #endregion @@ -229,7 +238,6 @@ public readonly static string DN2400鎬荤_绱娴侀噺_闀挎睙绠$綉鍥� = "10162"; public readonly static string DN2700鎬荤_绱娴侀噺_闀挎睙绠$綉鍥� = "10163"; - public readonly static string 浜岃緭21娉礯娉典簳娑蹭綅 = "10004"; public readonly static string 浜岃緭22娉礯娉典簳娑蹭綅 = "10005"; public readonly static string 浜岃緭23娉礯娉典簳娑蹭綅 = "10006"; @@ -237,7 +245,6 @@ public readonly static string 浜岃緭25娉礯娉典簳娑蹭綅 = "10008"; public readonly static string 浜岃緭26娉礯娉典簳娑蹭綅 = "10009"; public readonly static string 浜岃緭27娉礯娉典簳娑蹭綅 = "10010"; - public readonly static string 浜岃緭21娉礯鍑烘按鍘嬪姏 = "10019"; public readonly static string 浜岃緭22娉礯鍑烘按鍘嬪姏 = "10020"; @@ -247,7 +254,6 @@ public readonly static string 浜岃緭26娉礯鍑烘按鍘嬪姏 = "10024"; public readonly static string 浜岃緭27娉礯鍑烘按鍘嬪姏 = "10025"; - public readonly static string 浜岃緭21娉礯鐬椂娴侀噺 = "10039"; public readonly static string 浜岃緭22娉礯鐬椂娴侀噺 = "10040"; public readonly static string 浜岃緭23娉礯鐬椂娴侀噺 = "10041"; @@ -255,7 +261,6 @@ public readonly static string 浜岃緭25娉礯鐬椂娴侀噺 = "10043"; public readonly static string 浜岃緭26娉礯鐬椂娴侀噺 = "10044"; public readonly static string 浜岃緭27娉礯鐬椂娴侀噺 = "10045"; - public readonly static string 浜岃緭21娉礯绱娴侀噺 = "10059"; public readonly static string 浜岃緭22娉礯绱娴侀噺 = "10060"; @@ -265,7 +270,6 @@ public readonly static string 浜岃緭26娉礯绱娴侀噺 = "10064"; public readonly static string 浜岃緭27娉礯绱娴侀噺 = "10065"; - public readonly static string 浜岃緭21娉礯鏈夊姛鐢佃兘 = "10131"; public readonly static string 浜岃緭22娉礯鏈夊姛鐢佃兘 = "10132"; public readonly static string 浜岃緭23娉礯鏈夊姛鐢佃兘 = "10133"; @@ -274,14 +278,12 @@ public readonly static string 浜岃緭26娉礯鏈夊姛鐢佃兘 = "10136"; public readonly static string 浜岃緭27娉礯鏈夊姛鐢佃兘 = "10137"; - public readonly static string 浜岃緭22娉礯棰戠巼 = "10095"; public readonly static string 浜岃緭23娉礯棰戠巼 = "10096"; public readonly static string 浜岃緭24娉礯棰戠巼 = "10097"; public readonly static string 浜岃緭25娉礯棰戠巼 = "10098"; public readonly static string 浜岃緭26娉礯棰戠巼 = "10099"; public readonly static string 浜岃緭27娉礯棰戠巼 = "10100"; - public readonly static string 浜岃緭21娉礯杞�� = "10114"; public readonly static string 浜岃緭22娉礯杞�� = "10115"; @@ -291,7 +293,6 @@ public readonly static string 浜岃緭26娉礯杞�� = "10119"; public readonly static string 浜岃緭27娉礯杞�� = "10120"; - public readonly static string 浜岃緭21娉礯鏈夊姛鍔熺巼 = "10121"; public readonly static string 浜岃緭22娉礯鏈夊姛鍔熺巼 = "10122"; public readonly static string 浜岃緭23娉礯鏈夊姛鍔熺巼 = "10123"; @@ -299,7 +300,6 @@ public readonly static string 浜岃緭25娉礯鏈夊姛鍔熺巼 = "10125"; public readonly static string 浜岃緭26娉礯鏈夊姛鍔熺巼 = "10126"; // "10151"; is null public readonly static string 浜岃緭27娉礯鏈夊姛鍔熺巼 = "10127"; - public readonly static string 浜岃緭21娉礯杩愯鐘舵�� = "10077"; public readonly static string 浜岃緭22娉礯杩愯鐘舵�� = "10078"; @@ -309,7 +309,6 @@ public readonly static string 浜岃緭26娉礯杩愯鐘舵�� = "10082"; public readonly static string 浜岃緭27娉礯杩愯鐘舵�� = "10083"; - public readonly static string 浜岃緭21娉礯杩愯鏃堕棿 = "10180"; public readonly static string 浜岃緭22娉礯杩愯鏃堕棿 = "10181"; public readonly static string 浜岃緭23娉礯杩愯鏃堕棿 = "10182"; @@ -318,12 +317,27 @@ public readonly static string 浜岃緭26娉礯杩愯鏃堕棿 = "10185"; public readonly static string 浜岃緭27娉礯杩愯鏃堕棿 = "10186"; + public readonly static string 浜岃緭21娉礯妫�淇姸鎬� = "10196"; + public readonly static string 浜岃緭22娉礯妫�淇姸鎬� = "10197"; + public readonly static string 浜岃緭23娉礯妫�淇姸鎬� = "10198"; + public readonly static string 浜岃緭24娉礯妫�淇姸鎬� = "10199"; + public readonly static string 浜岃緭25娉礯妫�淇姸鎬� = "10200"; + public readonly static string 浜岃緭26娉礯妫�淇姸鎬� = "10201"; + public readonly static string 浜岃緭27娉礯妫�淇姸鎬� = "10202"; + + public readonly static string 浜岃緭21娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜岃緭姘�21鍙锋按娉佃繍琛屽弬鏁�.杩愯鏃堕棿"; + public readonly static string 浜岃緭22娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜岃緭姘�22鍙锋按娉佃繍琛屽弬鏁�.杩愯鏃堕棿"; + public readonly static string 浜岃緭23娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜岃緭姘�23鍙锋按娉佃繍琛屽弬鏁�.杩愯鏃堕棿"; + public readonly static string 浜岃緭24娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜岃緭姘�24鍙锋按娉佃繍琛屽弬鏁�.杩愯鏃堕棿"; + public readonly static string 浜岃緭25娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜岃緭姘�25鍙锋按娉佃繍琛屽弬鏁�.杩愯鏃堕棿"; + public readonly static string 浜岃緭26娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜岃緭姘�26鍙锋按娉佃繍琛屽弬鏁�.杩愯鏃堕棿"; + public readonly static string 浜岃緭27娉礯绱杩愯鏃堕棿_鍘嗗彶 = "浜岃緭姘�27鍙锋按娉佃繍琛屽弬鏁�.杩愯鏃堕棿"; + #endregion #endregion #region 娉垫爣蹇� 鍜� 浼楁瘏Scada瀵规帴鏍囩 鏄犲皠 - /// <summary> /// 娉垫爣蹇楄繍琛岀姸鎬佹槧灏勫瓧鍏� 1杈撴按 @@ -366,7 +380,6 @@ {Flag18, 涓�杈揰鏂板墠姹犳恫浣峿 }; - /// <summary> /// 娉垫爣蹇楄繘鍙f按浣嶆槧灏勫瓧鍏� 2杈撴按 /// </summary> @@ -379,8 +392,6 @@ {Flag26, 浜岃緭26娉礯娉典簳娑蹭綅}, {Flag27, 浜岃緭27娉礯娉典簳娑蹭綅} }; - - /// <summary> /// 娉垫爣蹇楄浆閫熸槧灏勫瓧鍏� 1杈撴按 @@ -396,7 +407,6 @@ {Flag18, 涓�杈�18娉礯杞�焳 }; - /// <summary> /// 娉垫爣蹇楄浆閫熸槧灏勫瓧鍏� 2杈撴按 /// </summary> @@ -408,6 +418,46 @@ {Flag25, 浜岃緭25娉礯杞�焳, {Flag26, 浜岃緭26娉礯杞�焳, {Flag27, 浜岃緭27娉礯杞�焳 + }; + + /// <summary> + /// 娉垫爣蹇楁淇姸鎬佹槧灏勫瓧鍏� 2杈撴按 + /// </summary> + public readonly static Dictionary<int, string> FlagMaintenanceMappingDict2 = new() { + {Flag21, 浜岃緭21娉礯妫�淇姸鎬亇, + {Flag22, 浜岃緭22娉礯妫�淇姸鎬亇, + {Flag23, 浜岃緭23娉礯妫�淇姸鎬亇, + {Flag24, 浜岃緭24娉礯妫�淇姸鎬亇, + {Flag25, 浜岃緭25娉礯妫�淇姸鎬亇, + {Flag26, 浜岃緭26娉礯妫�淇姸鎬亇, + {Flag27, 浜岃緭27娉礯妫�淇姸鎬亇 + }; + + /// <summary> + /// 娉垫爣蹇楃疮璁℃椂闂存槧灏勫瓧鍏� 1杈撴按 (鍒嗛挓鍗曚綅) + /// </summary> + public readonly static Dictionary<string, int> FlagCumulativeRunTimeMappingDict1 = new() { + {涓�杈�11娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag11}, + {涓�杈�12娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag12}, + {涓�杈�13娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag13}, + {涓�杈�14娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag14}, + {涓�杈�15娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag15}, + {涓�杈�16娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag16}, + {涓�杈�17娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag17}, + {涓�杈�18娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag18} + }; + + /// <summary> + /// 娉垫爣蹇楃疮璁℃椂闂存槧灏勫瓧鍏� 2杈撴按 (灏忔椂鍗曚綅) + /// </summary> + public readonly static Dictionary<string, int> FlagCumulativeRunTimeMappingDict2 = new() { + {浜岃緭21娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag21}, + {浜岃緭22娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag22}, + {浜岃緭23娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag23}, + {浜岃緭24娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag24}, + {浜岃緭25娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag25}, + {浜岃緭26娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag26}, + {浜岃緭27娉礯绱杩愯鏃堕棿_鍘嗗彶,Flag27} }; #endregion @@ -607,7 +657,7 @@ #endregion - #region 鑾峰彇Scada + #region 鑾峰彇瀹炴椂Scada /// <summary> /// 浼楁瘏瀹炴椂鏁版嵁 @@ -708,6 +758,277 @@ return zy_scada_list; } + /// <summary> + /// 鑾峰彇瀹炴椂浼楁瘏Scada鏁版嵁鍒楄〃 + /// </summary> + public static bool ExportTempZyScadaDebugTxt(List<Model.ZyScada> zy_scada_list) + { + if (zy_scada_list == null || !zy_scada_list.Any()) + { + return false; + } + var debug_zy_scada_file = Settings.ParasHelper.LocalFile.DataFolderDirectory + "\\" + "zy_scada_debug.txt"; + if (File.Exists(debug_zy_scada_file)) + { + File.Delete(debug_zy_scada_file); + } + + var temp_wl_dict = new Dictionary<string, string>() { + {"R3", 涓�杈揰鑰佸墠姹犲崡渚ф恫浣峿, + {"R2", 涓�杈揰鑰佸墠姹犲寳渚ф恫浣� }, + {"R1", 涓�杈揰鏂板墠姹犳恫浣峿, + {"RPump21", 浜岃緭21娉礯娉典簳娑蹭綅}, + {"RPump22", 浜岃緭22娉礯娉典簳娑蹭綅}, + {"RPump23", 浜岃緭23娉礯娉典簳娑蹭綅}, + {"RPump24", 浜岃緭24娉礯娉典簳娑蹭綅}, + {"RPump25", 浜岃緭25娉礯娉典簳娑蹭綅}, + {"RPump26", 浜岃緭26娉礯娉典簳娑蹭綅}, + {"RPump27", 浜岃緭27娉礯娉典簳娑蹭綅} + }; + var temp_pump_dict = new Dictionary<string, string>() { + {"Pump11", 涓�杈�11娉礯杩愯鐘舵�亇, + {"Pump12", 涓�杈�12娉礯杩愯鐘舵�亇, + {"Pump13", 涓�杈�13娉礯杩愯鐘舵�亇, + {"Pump14", 涓�杈�14娉礯杩愯鐘舵�亇, + {"Pump15", 涓�杈�15娉礯杩愯鐘舵�亇, + {"Pump16", 涓�杈�16娉礯杩愯鐘舵�亇, + {"Pump17", 涓�杈�17娉礯杩愯鐘舵�亇, + {"Pump18", 涓�杈�18娉礯杩愯鐘舵�亇, + {"R3", 涓�杈揰鑰佸墠姹犲崡渚ф恫浣峿, + {"R2", 涓�杈揰鑰佸墠姹犲寳渚ф恫浣� }, + {"R1", 涓�杈揰鏂板墠姹犳恫浣峿, + {"RPump21", 浜岃緭21娉礯娉典簳娑蹭綅}, + {"RPump22", 浜岃緭22娉礯娉典簳娑蹭綅}, + {"RPump23", 浜岃緭23娉礯娉典簳娑蹭綅}, + {"RPump24", 浜岃緭24娉礯娉典簳娑蹭綅}, + {"RPump25", 浜岃緭25娉礯娉典簳娑蹭綅}, + {"RPump26", 浜岃緭26娉礯娉典簳娑蹭綅}, + {"RPump27", 浜岃緭27娉礯娉典簳娑蹭綅}, + {"Pump21", 浜岃緭21娉礯杩愯鐘舵�亇, + {"Pump22", 浜岃緭22娉礯杩愯鐘舵�亇, + {"Pump23", 浜岃緭23娉礯杩愯鐘舵�亇, + {"Pump24", 浜岃緭24娉礯杩愯鐘舵�亇, + {"Pump25", 浜岃緭25娉礯杩愯鐘舵�亇, + {"Pump26", 浜岃緭26娉礯杩愯鐘舵�亇, + {"Pump27", 浜岃緭27娉礯杩愯鐘舵�亇 + }; + + var data = new Dictionary<string, Dictionary<string, string>>(); + foreach (var zy_scada in zy_scada_list) + { + var code = zy_scada.Code; + var tag = zy_scada.Tag; + var time = zy_scada.Time.ToString("u"); + var vals = zy_scada.Value.ToString() ?? ""; + if (string.IsNullOrEmpty(code)) + { + if (temp_wl_dict.ContainsKey(tag)) + { + code = temp_wl_dict[tag]; + } + else if (temp_pump_dict.ContainsKey(tag)) + { + code = temp_pump_dict[tag]; + vals = zy_scada.Value > 0 ? "1" : "0"; + } + } + if (string.IsNullOrEmpty(code)) + continue; + + data.Add(code, new Dictionary<string, string>()); + data[code]["key"] = tag; + data[code]["time"] = time; + data[code]["vals"] = vals; + } + + + var debug_zy_scada_dto = new ZyRealTimeDataDto(); + debug_zy_scada_dto.data = data; + debug_zy_scada_dto.msg = "娴嬭瘯鏂囦欢"; + var dto_json = JsonHelper.Object2Json(debug_zy_scada_dto); + File.WriteAllText(debug_zy_scada_file, dto_json); + return true; + } + + #endregion + + #region 鑾峰彇鍘嗗彶Scada + + /// <summary> + /// 浼楁瘏鍘嗗彶鏁版嵁 + /// </summary> + public class ZyHistoryDataDto + { + /// <summary> + /// + /// </summary> + public string msg { get; set; } + + /// <summary> + /// + /// </summary> + public List<ZyDataDto> data { get; set; } + + /// <summary> + /// + /// </summary> + public string status { get; set; } + } + + /// <summary> + /// 浼楁瘏鍘嗗彶鏁版嵁 data + /// </summary> + public class ZyDataDto + { + /// <summary> + /// + /// </summary> + public string dataMsg { get; set; } + + /// <summary> + /// + /// </summary> + public List<string[]> vals { get; set; } + + /// <summary> + /// + /// </summary> + public string tagName { get; set; } + } + + /// <summary> + /// 鑾峰彇娉电疮璁¤繍琛屾椂闂�(灏忔椂)瀛楀吀 + /// </summary> + /// <param name="station1_flag_cumulative_run_time_dict"></param> + /// <param name="station2_flag_cumulative_run_time_dict"></param> + /// <param name="date_interval">缁熻鏃ユ湡闂撮殧(澶�)</param> + /// <param name="frequency">鏁版嵁姝ラ暱 1h(s:绉� m锛氬垎 h:灏忔椂 d:澶�)</param> + /// <param name="type">鏁版嵁鍊肩被鍨� first:姣忎釜闂撮殧鐨勭涓�涓�� mean:姣忎釜闂撮殧鐨勫钩鍧囧��</param> + /// <returns></returns> + public static string GetFlagCumulativeRunTimeDict(out Dictionary<int, double> station1_flag_cumulative_run_time_dict, out Dictionary<int, double> station2_flag_cumulative_run_time_dict, int date_interval = 30, string frequency = "1h", string type = "first") + { + station1_flag_cumulative_run_time_dict = new Dictionary<int, double>(); + station2_flag_cumulative_run_time_dict = new Dictionary<int, double>(); + if (!Settings.ParasHelper.ZyDocking.Enable) + { + return "ZyDocking 鏈惎鐢�"; + } + + var url_prefix = Settings.ParasHelper.ZyDocking.HistoryScadaHttpUrl; + if (string.IsNullOrEmpty(url_prefix)) + { + return "HistoryScadaHttpUrl 涓虹┖"; + } + + var enter_time_format = "yyyy-MM-dd HH:mm:ss"; + var travel_time_format = new System.Globalization.DateTimeFormatInfo() + { + ShortDatePattern = "yyyy-MM-dd'T'HH:mm:ss.SSS Z" + }; ; + + var now_dt = DateTime.Now; + var start_dt = now_dt.AddDays(-date_interval); + var end_dt = now_dt; + + var start_time = start_dt.ToString(enter_time_format); + var end_time = end_dt.ToString(enter_time_format); + + var tag_list = new List<string>(); + tag_list.AddRange(FlagCumulativeRunTimeMappingDict1.Keys); + tag_list.AddRange(FlagCumulativeRunTimeMappingDict2.Keys); + + var measurement_max_count = 5; + var measurements_list = new List<string>(); + for (int i = 0; i < tag_list.Count; i += measurement_max_count) + { + var tag_list_temp = tag_list.Skip(i).Take(measurement_max_count).ToList(); + var measurements = Yw.Untity.StringListHelper.ToString(tag_list_temp); + measurements_list.Add(measurements); + } + + var log_str_builder = new StringBuilder(); + var zy_scada_list_dict = new Dictionary<string, List<Model.ZyScada>>(); + try + { + foreach (var measurements in measurements_list) + { + var url = $"{url_prefix}?" + + $"startTime={start_time}&" + + $"endTime={end_time}&" + + $"type={type}&" + + $"frequency={frequency}&" + + $"measurements={measurements}"; + + log_str_builder.AppendLine($"鍘嗗彶鏁版嵁璇锋眰:{url}"); + var response_text = Yw.Untity.HttpRequestHelper.Get(url); + var dto = JsonHelper.Json2Object<ZyHistoryDataDto>(response_text); + var zy_dada_dto_list = dto?.data; + if (zy_dada_dto_list == null || !zy_dada_dto_list.Any()) + { + log_str_builder.AppendLine("鏃犳暟鎹�"); + continue; + } + + foreach (var zy_dada_dto in zy_dada_dto_list) + { + var tag = zy_dada_dto.tagName; + var vlus = zy_dada_dto.vals; + + var zy_scada_list = new List<Model.ZyScada>(); + foreach (var vlu in vlus) + { + var time_str = vlu[0]; + var value_str = vlu[1]; + if (!double.TryParse(value_str, out double value)) + continue; + var time = Convert.ToDateTime(time_str, travel_time_format).AddHours(-8); + var zy_scada = new Model.ZyScada(); + zy_scada.Time = time; + zy_scada.Code = tag; + zy_scada.Value = value; + zy_scada.Tag = tag; + zy_scada_list.Add(zy_scada); + } + zy_scada_list_dict.Add(tag, zy_scada_list); + } + } + } + catch (System.Exception ex) + { + log_str_builder.AppendLine(ex.Message); + } + + foreach (var item in zy_scada_list_dict) + { + var tag = item.Key; + var zy_scada_list = item.Value; + if (zy_scada_list == null || !zy_scada_list.Any()) + { + continue; + } + var min_time = zy_scada_list.Min(x => x.Value); + var max_time = zy_scada_list.Max(x => x.Value); + var run_time = max_time - min_time ?? 0; + if (FlagCumulativeRunTimeMappingDict1.ContainsKey(tag)) + { + var flag = FlagCumulativeRunTimeMappingDict1[tag]; + var time = Math.Round(run_time / 60, 1); + + station1_flag_cumulative_run_time_dict.Add(flag, time); + } + else if (FlagCumulativeRunTimeMappingDict2.ContainsKey(tag)) + { + var flag = FlagCumulativeRunTimeMappingDict2[tag]; + var time = Math.Round(run_time, 1); + + + station2_flag_cumulative_run_time_dict.Add(flag, time); + } + } + + return log_str_builder.ToString(); + } + #endregion #region 鑾峰彇璋冨害绠楁硶鍏ュ弬 @@ -746,7 +1067,6 @@ } } } - /// <summary> /// 鑾峰彇娉佃繘鍙f按浣嶅瓧鍏� @@ -790,11 +1110,36 @@ } } + /// <summary> + /// 鑾峰彇娉电珯妫�淇爣蹇楀垪琛�(0鏄甯革紝1鏄淇�) + /// </summary> + /// <param name="zy_scada_list">浼楁瘏Scada鍒楄〃</param> + /// <param name="station1_maintenance_flag_list">妫�淇爣蹇楀垪琛� 1杈撴按</param> + /// <param name="station2_maintenance_flag_list">妫�淇爣蹇楀垪琛� 2杈撴按</param> + public static void GetStationMaintenanceFlagList(List<Model.ZyScada> zy_scada_list, out List<int> station1_maintenance_flag_list, out List<int> station2_maintenance_flag_list) + { + station1_maintenance_flag_list = new List<int>(); + station2_maintenance_flag_list = new List<int>(); + if (zy_scada_list == null || !zy_scada_list.Any()) + return; + + //1杈撴按寰呰ˉ鍏� + + foreach (var mapping in FlagMaintenanceMappingDict2) + { + var flag = mapping.Key; + var code = mapping.Value; + var zy_scada = zy_scada_list.Find(x => x.Code == code); + if (zy_scada != null && zy_scada.Value == 1) + { + station2_maintenance_flag_list.Add(flag); + } + } + } + #endregion } - - } -- Gitblit v1.9.3