RunningInfo.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using IwbZero.IwbBase;
  5. using IwbZero.ToolCommon.StringModel;
  6. using Newtonsoft.Json;
  7. using WeEngine.Enum;
  8. using WeEngine.Packages;
  9. namespace WeEngine.CommonDto
  10. {
  11. public class RunningBase
  12. {
  13. public RunningBase()
  14. {
  15. }
  16. public RunningBase(NodeBase node)
  17. {
  18. Id = node.Id;
  19. No = node.InternalNo;
  20. Name = node.Name;
  21. CorrectionScore = node.CorrectionScore;
  22. SystemScore = node.ActualScore;
  23. FullScore = node.NodeFullScore;
  24. WaitPath = node.WaitPath;
  25. Variables = "";
  26. if (node.Variables != null && node.Variables.Count > 0)
  27. {
  28. foreach (DictionaryEntry entry in node.Variables)
  29. {
  30. if (!DefaultVariable.VariableNames.Contains(entry.Key))
  31. {
  32. var v = (IwbRtVariable)entry.Value;
  33. Variables += (Variables == "" ? "" : ",") + $"[{v.VarName}:{v.DataType.TypeString}:{v.GetStringValue()}]";
  34. }
  35. }
  36. }
  37. IsStart = node.NodeState == NodeState.Running || node.NodeState == NodeState.RunEnd ||
  38. node.NodeState == NodeState.Complete;
  39. IsEnd = node.NodeState == NodeState.RunEnd || node.NodeState == NodeState.Complete;
  40. }
  41. [JsonIgnore]
  42. public RunningBase Parent { get; set; }
  43. public string Id { get; set; }
  44. public string No { get; set; }
  45. public string Name { get; set; }
  46. [JsonIgnore]
  47. public string ParentPath => Parent?.Path ?? "";
  48. public string Path => GetNodePath();
  49. public string Variables{ get; set; }
  50. public decimal FullScore { get; set; }
  51. public decimal CorrectionScore { get; set; }
  52. public decimal SystemScore { get; set; }
  53. public bool IsStart { get; set; }
  54. public bool IsEnd { get; set; }
  55. public List<string> WaitPath { get; set; }
  56. protected virtual string GetNodePath()
  57. {
  58. return Parent != null ? $"{ParentPath}_{No}" : No;
  59. }
  60. [JsonIgnore]
  61. public Hashtable VariableTable => GetVariableTable();
  62. private Hashtable GetVariableTable()
  63. {
  64. var vTable= new Hashtable();
  65. if (Variables.IsNotEmpty())
  66. {
  67. var varArr = Variables.StrToArray();
  68. foreach (var v in varArr)
  69. {
  70. var arr = v.StrToArray(":");
  71. string id = "";
  72. if (arr.Length > 0)
  73. {
  74. id = arr[0].UAndT();
  75. }
  76. if (id.IsNotEmpty())
  77. {
  78. vTable[id] = IwbRtVariable.Str2Variable(v);
  79. }
  80. }
  81. }
  82. return vTable;
  83. }
  84. public Hashtable GetVariables()
  85. {
  86. var variables = new Hashtable().MergeHashtable(VariableTable);
  87. if (Parent != null)
  88. {
  89. variables = Parent.GetVariables().MergeHashtable(variables);
  90. }
  91. return variables;
  92. }
  93. public List<RoundRunningInfo> GetRunRoundInfo(List<RoundRunningInfo> roundInfo)
  94. {
  95. return roundInfo?.Where(a => a.IsStart).ToList() ?? new List<RoundRunningInfo>();
  96. }
  97. public List<BlockRunningInfo> GetRunBlockInfo(List<RoundRunningInfo> roundInfo)
  98. {
  99. var list = new List<BlockRunningInfo>();
  100. foreach (var info in roundInfo)
  101. {
  102. var temp = info.BlockInfo?.Where(a => a.IsStart);
  103. if (temp != null)
  104. {
  105. list.AddRange(temp);
  106. }
  107. }
  108. return list;
  109. }
  110. public List<FlowRunningInfo> GetRunFlowInfo(List<BlockRunningInfo> blockInfo)
  111. {
  112. var list = new List<FlowRunningInfo>();
  113. foreach (var info in blockInfo)
  114. {
  115. var temp = info.FlowInfo?.Where(a => a.IsStart);
  116. if (temp != null)
  117. {
  118. list.AddRange(temp);
  119. }
  120. }
  121. return list;
  122. }
  123. public List<FlowNodeRunningInfo> GetRunNodeInfo(List<FlowRunningInfo> flowInfo)
  124. {
  125. var list = new List<FlowNodeRunningInfo>();
  126. foreach (var info in flowInfo)
  127. {
  128. var temp = info.NodeInfo?.FirstOrDefault(a => a.IsStart);
  129. if (temp != null)
  130. {
  131. list.Add(temp);
  132. list = GetRunChildNodeInfo(list, temp.NodeInfo);
  133. }
  134. }
  135. return list;
  136. }
  137. private List<FlowNodeRunningInfo> GetRunChildNodeInfo(List<FlowNodeRunningInfo> list, List<FlowNodeRunningInfo> childNodes)
  138. {
  139. var temp = childNodes?.FirstOrDefault(a => a.IsStart);
  140. if (temp != null)
  141. {
  142. list.Add(temp);
  143. if (temp.NodeInfo != null && temp.NodeInfo.Any())
  144. {
  145. list = GetRunChildNodeInfo(list, temp.NodeInfo);
  146. }
  147. }
  148. return list;
  149. }
  150. public List<SceneRunningInfo> GetRunSceneInfo(List<FlowNodeRunningInfo> nodeInfo)
  151. {
  152. var list = new List<SceneRunningInfo>();
  153. foreach (var info in nodeInfo)
  154. {
  155. var temp = info.SceneInfo?.Where(a => a.IsStart);
  156. if (temp != null)
  157. {
  158. list.AddRange(temp);
  159. }
  160. }
  161. return list;
  162. }
  163. public List<BehaviorRunningInfo> GetRunBehaviorInfo(List<SceneRunningInfo> sceneInfo)
  164. {
  165. var list = new List<BehaviorRunningInfo>();
  166. foreach (var info in sceneInfo)
  167. {
  168. var temp = info.BehaviorInfo?.Where(a => a.IsStart);
  169. if (temp != null)
  170. {
  171. list.AddRange(temp);
  172. }
  173. }
  174. return list;
  175. }
  176. }
  177. public class RunningInfo : RunningBase
  178. {
  179. public RunningInfo()
  180. {
  181. Parent = null;
  182. }
  183. public RunningInfo(NodeBase node) : base(node)
  184. {
  185. }
  186. public string PackageNo { get; set; }
  187. public int CurrentRoundIndex { get; set; }
  188. /// <summary>
  189. /// 考核角色
  190. /// </summary>
  191. public List<string> AssessRoles { get; set; }
  192. /// <summary>
  193. /// 未考核分数自动运行(满分)
  194. /// </summary>
  195. public bool AssessAuto { get; set; }
  196. /// <summary>
  197. /// 自动下一轮
  198. /// </summary>
  199. public bool AutoNextRound { get; set; }
  200. /// <summary>
  201. /// 每轮总分
  202. /// </summary>
  203. public decimal RoundScore { get; set; }
  204. [JsonIgnore]
  205. private List<RoundRunningInfo> _infos;
  206. public List<RoundRunningInfo> RoundInfo {
  207. get
  208. {
  209. if (_infos != null && _infos.Any())
  210. {
  211. foreach (var info in _infos)
  212. {
  213. info.Parent = this;
  214. }
  215. }
  216. return _infos;
  217. }
  218. set => _infos = value;
  219. }
  220. #region Current-RUN
  221. [JsonIgnore]
  222. public List<RoundRunningInfo> RunRoundInfo => GetRunRoundInfo(RoundInfo);
  223. [JsonIgnore]
  224. public List<BlockRunningInfo> RunBlockInfo => GetRunBlockInfo(RunRoundInfo);
  225. [JsonIgnore]
  226. public List<FlowRunningInfo> RunFlowInfo => GetRunFlowInfo(RunBlockInfo);
  227. [JsonIgnore]
  228. public List<FlowNodeRunningInfo> RunNodeInfo => GetRunNodeInfo(RunFlowInfo);
  229. [JsonIgnore]
  230. public List<SceneRunningInfo> RunSceneInfo => GetRunSceneInfo(RunNodeInfo);
  231. [JsonIgnore]
  232. public List<BehaviorRunningInfo> RunBehaviorInfo => GetRunBehaviorInfo(RunSceneInfo);
  233. #endregion
  234. }
  235. public class RoundRunningInfo: RunningBase
  236. {
  237. public RoundRunningInfo()
  238. {
  239. }
  240. public RoundRunningInfo(NodeBase node) : base(node)
  241. {
  242. RoundIndex = ((SceneRoundNode) node).RoundIndex;
  243. }
  244. public int RoundIndex { get; set; }
  245. [JsonIgnore]
  246. private List<BlockRunningInfo> _infos;
  247. public List<BlockRunningInfo> BlockInfo
  248. {
  249. get
  250. {
  251. if (_infos != null && _infos.Any())
  252. {
  253. foreach (var info in _infos)
  254. {
  255. info.Parent = this;
  256. }
  257. }
  258. return _infos;
  259. }
  260. set => _infos = value;
  261. }
  262. [JsonIgnore]
  263. public List<BlockRunningInfo> RunBlockInfos => BlockInfo.Where(a=>a.IsStart).ToList();
  264. [JsonIgnore]
  265. public List<FlowRunningInfo> RunFlowInfos => GetRunFlowInfo(RunBlockInfos);
  266. [JsonIgnore]
  267. public List<FlowNodeRunningInfo> RunNodeInfos => GetRunNodeInfo(RunFlowInfos);
  268. [JsonIgnore]
  269. public List<SceneRunningInfo> RunSceneInfos => GetRunSceneInfo(RunNodeInfos);
  270. [JsonIgnore]
  271. public List<BehaviorRunningInfo> RunBehaviorInfos => GetRunBehaviorInfo(RunSceneInfos);
  272. [JsonIgnore]
  273. public List<FlowRunningInfo> FlowInfos => GetRunFlowInfo(BlockInfo);
  274. [JsonIgnore]
  275. public List<FlowNodeRunningInfo> NodeInfos => GetRunNodeInfo(FlowInfos);
  276. [JsonIgnore]
  277. public List<SceneRunningInfo> SceneInfos => GetRunSceneInfo(NodeInfos);
  278. [JsonIgnore]
  279. public List<BehaviorRunningInfo> BehaviorInfos => GetRunBehaviorInfo(SceneInfos);
  280. }
  281. public class BlockRunningInfo: RunningBase
  282. {
  283. public BlockRunningInfo()
  284. {
  285. }
  286. public BlockRunningInfo(NodeBase node) : base(node)
  287. {
  288. BlockType = ((SceneFlowBlockNode) node).BlockType;
  289. }
  290. public SceneFlowBlockType BlockType { get; set; }
  291. [JsonIgnore]
  292. private List<FlowRunningInfo> _infos;
  293. public List<FlowRunningInfo> FlowInfo
  294. {
  295. get
  296. {
  297. if (_infos != null && _infos.Any())
  298. {
  299. foreach (var info in _infos)
  300. {
  301. info.Parent = this;
  302. }
  303. }
  304. return _infos;
  305. }
  306. set => _infos = value;
  307. }
  308. }
  309. public class FlowRunningInfo: RunningBase
  310. {
  311. public FlowRunningInfo()
  312. {
  313. }
  314. public FlowRunningInfo(NodeBase node) : base(node)
  315. {
  316. }
  317. [JsonIgnore]
  318. private List<FlowNodeRunningInfo> _infos;
  319. public List<FlowNodeRunningInfo> NodeInfo
  320. {
  321. get
  322. {
  323. if (_infos != null && _infos.Any())
  324. {
  325. foreach (var info in _infos)
  326. {
  327. info.Parent = this;
  328. }
  329. }
  330. return _infos;
  331. }
  332. set => _infos = value;
  333. }
  334. }
  335. public class FlowNodeRunningInfo: RunningBase
  336. {
  337. public FlowNodeRunningInfo()
  338. {
  339. }
  340. public FlowNodeRunningInfo(NodeBase node) : base(node)
  341. {
  342. }
  343. [JsonIgnore]
  344. private List<SceneRunningInfo> _sInfos;
  345. public List<SceneRunningInfo> SceneInfo
  346. {
  347. get
  348. {
  349. if (_sInfos != null && _sInfos.Any())
  350. {
  351. foreach (var info in _sInfos)
  352. {
  353. info.Parent = this;
  354. }
  355. }
  356. return _sInfos;
  357. }
  358. set => _sInfos = value;
  359. }
  360. [JsonIgnore]
  361. private List<FlowNodeRunningInfo> _infos;
  362. public List<FlowNodeRunningInfo> NodeInfo
  363. {
  364. get
  365. {
  366. if (_infos != null && _infos.Any())
  367. {
  368. foreach (var info in _infos)
  369. {
  370. info.Parent = this;
  371. }
  372. }
  373. return _infos;
  374. }
  375. set => _infos = value;
  376. }
  377. }
  378. public class SceneRunningInfo: RunningBase
  379. {
  380. public SceneRunningInfo()
  381. {
  382. }
  383. public SceneRunningInfo(NodeBase node) : base(node)
  384. {
  385. //var variables = node.GetSelfVariables();
  386. //if (variables != null && variables.Count > 0)
  387. //{
  388. // foreach (DictionaryEntry entry in variables)
  389. // {
  390. // var v = (IwbRtVariable)entry.Value;
  391. // Variables += (Variables == "" ? "" : ",") + $"[{v.VarName}:{v.DataType.TypeString}:{v.GetStringValue()}]";
  392. // }
  393. //}
  394. }
  395. [JsonIgnore]
  396. private List<BehaviorRunningInfo> _infos;
  397. public List<BehaviorRunningInfo> BehaviorInfo
  398. {
  399. get
  400. {
  401. if (_infos != null && _infos.Any())
  402. {
  403. foreach (var info in _infos)
  404. {
  405. info.Parent = this;
  406. }
  407. }
  408. return _infos;
  409. }
  410. set => _infos = value;
  411. }
  412. }
  413. public class BehaviorRunningInfo: RunningBase
  414. {
  415. public BehaviorRunningInfo()
  416. {
  417. }
  418. public string KeyWords { get; set; }
  419. public BehaviorRunningInfo(NodeBase node) : base(node)
  420. {
  421. }
  422. }
  423. }