ProcessHistoryViewModel.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. using MECF.Framework.Common.DataCenter;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Windows.Media;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Venus_Core;
  10. using Prism.Commands;
  11. using Prism.Mvvm;
  12. using Venus_MainPages.Unity;
  13. using Venus_MainPages.Views;
  14. using System.Collections.ObjectModel;
  15. using System.Windows.Threading;
  16. using System.Windows;
  17. using Aitex.Core.RT.Log;
  18. using Aitex.Core.UI.ControlDataContext;
  19. using WPF.Themes.UserControls;
  20. using System.IO;
  21. using System.Diagnostics;
  22. using Aitex.Core.RT.Routine;
  23. using System.Xml.Linq;
  24. using System.Windows.Forms;
  25. using ExcelLibrary.BinaryFileFormat;
  26. using Aitex.Core.UI.View.Common;
  27. using Aitex.Core.RT.DataCenter;
  28. using System.Xml;
  29. using System.Security.Cryptography.X509Certificates;
  30. using System.Reflection;
  31. using Newtonsoft.Json;
  32. using Venus_Themes.UserControls;
  33. using Aitex.Core.UI.Control;
  34. using System.Windows.Annotations;
  35. using System.Runtime.Serialization;
  36. namespace Venus_MainPages.ViewModels
  37. {
  38. public class ProcessHistoryViewModel : BindableBase
  39. {
  40. #region 私有字段
  41. private ProcessHistoryView view;
  42. List<string> keys = new List<string>();
  43. RealtimeProvider _provider = new RealtimeProvider();
  44. private ObservableCollection<ParameterNode> _ParameterNodes;
  45. DispatcherTimer timer = new DispatcherTimer();
  46. ObservableCollection<PdKeyData> _PdKeyDataObservation = new ObservableCollection<PdKeyData>();
  47. public List<string> RecipesAdd = new List<string>();
  48. public List<SolidColorBrush> solidColorBrushes = new List<SolidColorBrush>();
  49. //DateTime currentTime;
  50. private RecipeItem selectedRecipeItem;
  51. private bool m_IsShowStep;
  52. #endregion
  53. #region 属性
  54. public List<HistoryDataItem> ProcessData { get; set; }
  55. public List<Recipeslist> CheboxRecipes { get; set; }
  56. public ProcessDataChartDataItem ProcessChartData { get; set; }
  57. public DateTime StartDateTime { get; set; }
  58. public DateTime EndDateTime { get; set; }
  59. public string SelectedValuePM { get; set; }
  60. public string RecipeName { get; set; }
  61. public ObservableCollection<PdKeyData> OldPdKeyDataCollection { get; set; }
  62. public ObservableCollection<RecipeItem> Recipes { get; set; }
  63. public class Recipeslist
  64. {
  65. public string BoxName { get; set; }
  66. }
  67. public class RecipeAdd
  68. {
  69. public string Recipesname { get; set; }
  70. }
  71. public ObservableCollection<ParameterNode> ParameterNodes
  72. {
  73. get { return _ParameterNodes; }
  74. set { SetProperty(ref _ParameterNodes, value); }
  75. }
  76. public ObservableCollection<PdKeyData> PdKeyDataCollection
  77. {
  78. get { return _PdKeyDataObservation; }
  79. set { SetProperty(ref _PdKeyDataObservation, value); }
  80. }
  81. public bool IsShowStep
  82. {
  83. get { return m_IsShowStep; }
  84. set { SetProperty(ref m_IsShowStep, value); }
  85. }
  86. #endregion
  87. #region 命令
  88. private DelegateCommand<object> _LoadCommandPD;
  89. public DelegateCommand<object> LoadCommandPD =>
  90. _LoadCommandPD ?? (_LoadCommandPD = new DelegateCommand<object>(OnLoadPd));
  91. private DelegateCommand _SearchRecipeCommand;
  92. public DelegateCommand SearchRecipeCommand =>
  93. _SearchRecipeCommand ?? (_SearchRecipeCommand = new DelegateCommand(SearchRecipes));
  94. private DelegateCommand<object> _PdParameterCheckCommand;
  95. public DelegateCommand<object> PdParameterCheckCommand =>
  96. _PdParameterCheckCommand ?? (_PdParameterCheckCommand = new DelegateCommand<object>(OnParameterCheck));
  97. private DelegateCommand<object> _DataGridSelectionChangedCommand;
  98. public DelegateCommand<object> DataGridSelectionChangedCommand =>
  99. _DataGridSelectionChangedCommand ?? (_DataGridSelectionChangedCommand = new DelegateCommand<object>(OnDataGridSelectionChanged));
  100. private DelegateCommand _SearchDataCommand;
  101. public DelegateCommand SearchDataCommand =>
  102. _SearchDataCommand ?? (_SearchDataCommand = new DelegateCommand(OnSearchData));
  103. private DelegateCommand _ClearDataCommand;
  104. public DelegateCommand ClearDataCommand =>
  105. _ClearDataCommand ?? (_ClearDataCommand = new DelegateCommand(OnClearData));
  106. #endregion
  107. #region 构造函数
  108. public ProcessHistoryViewModel()
  109. {
  110. ProcessData = new List<HistoryDataItem>() { };
  111. ProcessChartData = new ProcessDataChartDataItem(60000);
  112. Recipes = new ObservableCollection<RecipeItem>();
  113. timer.Interval = TimeSpan.FromSeconds(0.5);
  114. OldPdKeyDataCollection = new ObservableCollection<PdKeyData>();
  115. CheboxRecipes = new List<Recipeslist>();
  116. solidColorBrushes.Add(new SolidColorBrush(Colors.Green));
  117. solidColorBrushes.Add(new SolidColorBrush(Colors.Red));
  118. solidColorBrushes.Add(new SolidColorBrush(Colors.Blue));
  119. solidColorBrushes.Add(new SolidColorBrush(Colors.Orange));
  120. solidColorBrushes.Add(new SolidColorBrush(Colors.Yellow));
  121. solidColorBrushes.Add(new SolidColorBrush(Colors.YellowGreen));
  122. solidColorBrushes.Add(new SolidColorBrush(Colors.AliceBlue));
  123. solidColorBrushes.Add(new SolidColorBrush(Colors.Chocolate));
  124. solidColorBrushes.Add(new SolidColorBrush(Colors.Cyan));
  125. solidColorBrushes.Add(new SolidColorBrush(Colors.DarkGreen));
  126. }
  127. #endregion
  128. #region 命令方法
  129. private void OnLoadPd(Object eventView)
  130. {
  131. this.view = (ProcessHistoryView)eventView;
  132. this.view.wfTimeFrom.Value = DateTime.Today;
  133. this.view.wfTimeTo.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59, 999);
  134. this.LoadRecipeCheckBox();
  135. }
  136. private void LoadRecipeCheckBox()
  137. {
  138. List<string> chamber = new List<string>() { "PMA", "PMB", "PMC", "PMD" };
  139. CheboxRecipes.Clear();
  140. foreach (string item in chamber)
  141. {
  142. string path = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", item);
  143. if (Directory.Exists(path))
  144. {
  145. string[] dir = Directory.GetFiles(path);
  146. for (int i = 0; i < dir.Length; i++)
  147. {
  148. CheboxRecipes.Add(new Recipeslist { BoxName = Path.GetFileName(dir[i]) });
  149. }
  150. }
  151. }
  152. }
  153. public void SearchRecipes()
  154. {
  155. SearchRecipe(this.view.wfTimeFrom.Value, this.view.wfTimeTo.Value);
  156. }
  157. public void searchlot(string id)
  158. {
  159. Recipes.Clear();
  160. try
  161. {
  162. string sql1 = string.Format($"SELECT * FROM \"lot_wafer_data\" where guid ='{id}'; ");
  163. DataTable dbData1 = QueryDataClient.Instance.Service.QueryData(sql1);
  164. string lot_data_guid = dbData1.Rows[0]["wafer_data_guid"].ToString();
  165. string sql = string.Format($"SELECT * FROM \"process_data\" where wafer_data_guid ='{lot_data_guid}'");
  166. if (!string.IsNullOrEmpty(SelectedValuePM))
  167. {
  168. string[] pms = SelectedValuePM.Split(',');
  169. if (pms.Length > 0)
  170. {
  171. sql += " and (FALSE ";
  172. foreach (var pm in pms)
  173. {
  174. sql += $" OR \"process_in\"='{pm}' ";
  175. }
  176. sql += " ) ";
  177. }
  178. }
  179. if (!string.IsNullOrEmpty(RecipeName))
  180. {
  181. sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower());
  182. }
  183. sql += " order by \"process_begin_time\" ASC;";
  184. DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
  185. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  186. {
  187. if (dbData == null || dbData.Rows.Count == 0) return;
  188. for (int i = 0; i < dbData.Rows.Count; i++)
  189. {
  190. RecipeItem item = new RecipeItem();
  191. item.Selected = false;
  192. item.Recipe = dbData.Rows[i]["recipe_name"].ToString();
  193. item.Guid = dbData.Rows[i]["guid"].ToString();
  194. item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString();
  195. item.Chamber = dbData.Rows[i]["process_in"].ToString();
  196. item.Status = dbData.Rows[i]["process_status"].ToString();
  197. item.SlotID = dbData.Rows[i]["slot_id"].ToString();
  198. item.LotID = dbData.Rows[i]["lot_id"].ToString();
  199. item.RecipeType= dbData.Rows[i]["recipe_type"].ToString();
  200. if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
  201. item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  202. if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
  203. item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  204. Recipes.Add(item);
  205. }
  206. }));
  207. }
  208. catch (Exception e)
  209. {
  210. LOG.WriteExeption(e);
  211. }
  212. }
  213. public void SearchRecipe(DateTime start, DateTime end)
  214. {
  215. this.StartDateTime = start;
  216. this.EndDateTime = end;
  217. Recipes.Clear();
  218. try
  219. {
  220. string sql = $"SELECT * FROM \"process_data\" where \"process_begin_time\" >='{StartDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' and \"process_begin_time\" <='{EndDateTime.ToString("yyyy/MM/dd HH:mm:ss.fff")}' ";
  221. if (!string.IsNullOrEmpty(SelectedValuePM))
  222. {
  223. string[] pms = SelectedValuePM.Split(',');
  224. if (pms.Length > 0)
  225. {
  226. sql += " and (FALSE ";
  227. foreach (var pm in pms)
  228. {
  229. sql += $" OR \"process_in\"='{pm}' ";
  230. }
  231. sql += " ) ";
  232. }
  233. }
  234. if (!string.IsNullOrEmpty(RecipeName))
  235. {
  236. sql += string.Format(" and lower(\"recipe_name\") like '%{0}%'", RecipeName.ToLower());
  237. }
  238. sql += " order by \"process_begin_time\" DESC;";
  239. DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
  240. System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  241. {
  242. if (dbData == null || dbData.Rows.Count == 0) return;
  243. for (int i = 0; i < dbData.Rows.Count; i++)
  244. {
  245. RecipeItem item = new RecipeItem();
  246. item.Selected = false;
  247. item.Recipe = dbData.Rows[i]["recipe_name"].ToString();
  248. item.Guid = dbData.Rows[i]["guid"].ToString();
  249. item.RecipeRunGuid = dbData.Rows[i]["wafer_data_guid"].ToString();
  250. item.Chamber = dbData.Rows[i]["process_in"].ToString();
  251. item.Status = dbData.Rows[i]["process_status"].ToString();
  252. item.SlotID = dbData.Rows[i]["slot_id"].ToString();
  253. item.RecipeType = dbData.Rows[i]["recipe_type"].ToString();
  254. item.LotID = dbData.Rows[i]["lot_id"].ToString();
  255. if (!dbData.Rows[i]["process_begin_time"].Equals(DBNull.Value))
  256. item.StartTime = ((DateTime)dbData.Rows[i]["process_begin_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  257. if (!dbData.Rows[i]["process_end_time"].Equals(DBNull.Value))
  258. item.EndTime = ((DateTime)dbData.Rows[i]["process_end_time"]).ToString("yyyy-MM-dd HH:mm:ss");
  259. Recipes.Add(item);
  260. }
  261. }));
  262. }
  263. catch (Exception e)
  264. {
  265. LOG.WriteExeption(e);
  266. }
  267. }
  268. private void CalKeys(ParameterNode parameterNode)
  269. {
  270. if (parameterNode.ChildNodes.Count > 0)
  271. {
  272. foreach (var item in parameterNode.ChildNodes)
  273. {
  274. CalKeys(item);
  275. }
  276. }
  277. else
  278. {
  279. if (parameterNode.Selected == true)
  280. {
  281. keys.Add(parameterNode.Name);
  282. }
  283. }
  284. }
  285. private Dictionary<string, List<HistoryDataItem>> GetData(List<string> keys, DateTime from, DateTime to)
  286. {
  287. string sql = "select time AS InternalTimeStamp";
  288. foreach (var dataId in keys)
  289. {
  290. sql += "," + string.Format("\"{0}\"", dataId);
  291. }
  292. sql += string.Format(" from \"{0}\" where time > {1} and time <= {2} order by time asc",
  293. from.ToString("yyyyMMdd") + "." + "Data", from.Ticks, to.Ticks);
  294. DataTable dataTable = QueryDataClient.Instance.Service.QueryData(sql);
  295. Dictionary<string, List<HistoryDataItem>> historyData = new Dictionary<string, List<HistoryDataItem>>();
  296. if (dataTable == null || dataTable.Rows.Count == 0)
  297. return null;
  298. DateTime dt = new DateTime();
  299. Dictionary<int, string> colName = new Dictionary<int, string>();
  300. for (int colNo = 0; colNo < dataTable.Columns.Count; colNo++)
  301. {
  302. colName.Add(colNo, dataTable.Columns[colNo].ColumnName);
  303. historyData[dataTable.Columns[colNo].ColumnName] = new List<HistoryDataItem>();
  304. }
  305. for (int rowNo = 0; rowNo < dataTable.Rows.Count; rowNo++)
  306. {
  307. PointCollection points = new PointCollection();
  308. var row = dataTable.Rows[rowNo];
  309. for (int i = 0; i < dataTable.Columns.Count; i++)
  310. {
  311. HistoryDataItem data = new HistoryDataItem();
  312. if (i == 0)
  313. {
  314. long ticks = (long)row[i];
  315. dt = new DateTime(ticks);
  316. continue;
  317. }
  318. else
  319. {
  320. string dataId = colName[i];
  321. if (row[i] is DBNull || row[i] == null)
  322. {
  323. data.dateTime = dt;
  324. data.dbName = colName[i];
  325. data.value = 0;
  326. }
  327. else if (row[i] is bool)
  328. {
  329. data.dateTime = dt;
  330. data.dbName = colName[i];
  331. data.value = (bool)row[i] ? 1 : 0;
  332. }
  333. else
  334. {
  335. data.dateTime = dt;
  336. data.dbName = colName[i];
  337. data.value = float.Parse(row[i].ToString());
  338. }
  339. }
  340. historyData[data.dbName].Add(data);
  341. }
  342. }
  343. foreach (var item in historyData)
  344. {
  345. item.Value.Sort((x, y) => DateTime.Compare(x.dateTime, y.dateTime));
  346. }
  347. return historyData;
  348. }
  349. private bool RefreshTreeStatusToChild(ParameterNode node)
  350. {
  351. if (node.ChildNodes.Count > 0)
  352. {
  353. for (int i = 0; i < node.ChildNodes.Count; i++)
  354. {
  355. ParameterNode n = node.ChildNodes[i];
  356. n.Selected = node.Selected;
  357. if (!RefreshTreeStatusToChild(n))
  358. {
  359. //uncheck left node
  360. for (int j = i; j < node.ChildNodes.Count; j++)
  361. {
  362. node.ChildNodes[j].Selected = !node.Selected;
  363. }
  364. //node.Selected = !node.Selected;
  365. return false;
  366. }
  367. }
  368. }
  369. //else
  370. //{
  371. // if (node.Selected == true)
  372. // {
  373. // keys.Add(node.Name);
  374. // }
  375. // else
  376. // {
  377. // keys.Remove(node.Name);
  378. // }
  379. //}
  380. return true;
  381. }
  382. private void RefreshTreeStatusToParent(ParameterNode node)
  383. {
  384. if (node.ParentNode != null)
  385. {
  386. if (node.Selected)
  387. {
  388. bool flag = true;
  389. for (int i = 0; i < node.ParentNode.ChildNodes.Count; i++)
  390. {
  391. if (!node.ParentNode.ChildNodes[i].Selected)
  392. {
  393. flag = false; //as least one child is unselected
  394. break;
  395. }
  396. }
  397. if (flag)
  398. node.ParentNode.Selected = true;
  399. }
  400. else
  401. {
  402. node.ParentNode.Selected = false;
  403. }
  404. RefreshTreeStatusToParent(node.ParentNode);
  405. }
  406. }
  407. public static T DeepCopyJson<T>(T obj)
  408. {
  409. // 序列化
  410. string json = JsonConvert.SerializeObject(obj);
  411. // 反序列化
  412. return JsonConvert.DeserializeObject<T>(json);
  413. }
  414. private void OnParameterCheck(object obj)
  415. {
  416. ParameterNode node = obj as ParameterNode;
  417. if (!RefreshTreeStatusToChild(node))
  418. {
  419. node.Selected = !node.Selected;
  420. }
  421. else
  422. {
  423. RefreshTreeStatusToParent(node);
  424. }
  425. keys.Clear();
  426. for (int i = 0; i < ParameterNodes.Count; i++)
  427. {
  428. CalKeys(ParameterNodes[i]);
  429. }
  430. if (keys.Count > 10)
  431. {
  432. WPFMessageBox.ShowWarning("最多显示10个数据");
  433. return;
  434. }
  435. OldPdKeyDataCollection.Clear();
  436. OldPdKeyDataCollection = DeepCopyJson(PdKeyDataCollection);
  437. PdKeyDataCollection.Clear();
  438. for (int i = 0; i < keys.Count; i++)
  439. {
  440. if (i == 10)
  441. {
  442. break;
  443. }
  444. PdKeyDataCollection.Add(new PdKeyData() { Key = keys[i], Color = solidColorBrushes[i], UniqueId = i });
  445. }
  446. Compare(OldPdKeyDataCollection, PdKeyDataCollection);
  447. PdKeyDataCollection = DeepCopyJson(OldPdKeyDataCollection);
  448. }
  449. public void Compare(ObservableCollection<PdKeyData> olddata, ObservableCollection<PdKeyData> newdata)
  450. {
  451. if (newdata != null)
  452. {
  453. for (int i = 0; i < newdata.Count; i++)
  454. {
  455. var lists = olddata.ToList().Find(t => t.Key == newdata[i].Key);
  456. if (lists == null)
  457. {
  458. olddata.Add(new PdKeyData() { Key = newdata[i].Key, Color = solidColorBrushes[i], UniqueId = olddata.Count + 1 });
  459. }
  460. }
  461. for (int i = 0; i < olddata.Count; i++)
  462. {
  463. var lists = newdata.ToList().Find(t => t.Key == olddata[i].Key);
  464. if (lists == null)
  465. {
  466. olddata.Remove(olddata[i]);
  467. }
  468. }
  469. }
  470. }
  471. public void UpdateData(RecipeItem dataLog)
  472. {
  473. OnClearData();
  474. //CheckRecipe(dataLog.Guid);
  475. }
  476. public void CheckRecipe(string RecipeGuid)
  477. {
  478. string sql = $"SELECT * FROM \"recipe_step_data\" where \"process_data_guid\" = '{RecipeGuid}' order by step_number ASC;";
  479. var dbData = QueryDataClient.Instance.Service.QueryData(sql);
  480. List<StepData> steps = new List<StepData>();
  481. if (dbData != null && dbData.Rows.Count > 0)
  482. {
  483. for (int i = 0; i < dbData.Rows.Count; i++)
  484. {
  485. StepData item = new StepData();
  486. item.No = int.Parse(dbData.Rows[i]["step_number"].ToString());
  487. item.Name = dbData.Rows[i]["step_name"].ToString();
  488. if (!dbData.Rows[i]["step_begin_time"].Equals(DBNull.Value))
  489. item.StartTime = (DateTime)dbData.Rows[i]["step_begin_time"];
  490. if (!dbData.Rows[i]["step_end_time"].Equals(DBNull.Value))
  491. item.EndTime = (DateTime)dbData.Rows[i]["step_end_time"];
  492. item.ActualTime = item.EndTime.CompareTo(item.StartTime) <= 0 ? "" : item.EndTime.Subtract(item.StartTime).TotalSeconds.ToString();
  493. item.SettingTime = dbData.Rows[i]["step_time"].ToString();
  494. //annotation.Add(VerLine(Brushes.Blue, item.StartTime, Brushes.Blue, $"{item.No}:{item.Name}"));
  495. }
  496. }
  497. }
  498. public void OnDataGridSelectionChanged(object obj)
  499. {
  500. selectedRecipeItem = obj as RecipeItem;
  501. ParameterNodes = new ObservableCollection<ParameterNode>(_provider.GetParameters().Where(x => x.Name == selectedRecipeItem?.Chamber));
  502. }
  503. public void OnSearchData()
  504. {
  505. ProcessData.Clear();
  506. this.view.MyDrawGraphicsControl.ClearPlotPoints();
  507. var Keys = new List<string>();
  508. PdKeyDataCollection.ToList().ForEach(key =>
  509. {
  510. Keys.Add(key.Key);
  511. });
  512. if (keys.Count == 0)
  513. {
  514. return;
  515. }
  516. var result = GetData(Keys.Distinct().ToList(), Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime));
  517. if (result == null)
  518. {
  519. return;
  520. }
  521. List<PointCollection> cls = new List<PointCollection>();
  522. for (int i = 0; i < Keys.Count; i++)
  523. {
  524. PointCollection points = new PointCollection();
  525. int k = 1;
  526. result[Keys[i]].ForEach(point =>
  527. {
  528. ProcessData.Add(new HistoryDataItem() { dateTime= point.dateTime, dbName= Keys[i],value= point.value });
  529. points.Add(new Point() { X = point.dateTime.ToOADate(), Y = point.value });
  530. k += 1;
  531. });
  532. cls.Add(points);
  533. }
  534. for (int i = 0; i <PdKeyDataCollection.Count(); i++)
  535. {
  536. var _color = PdKeyDataCollection[i].Color.Color;
  537. view.MyDrawGraphicsControl.m_PenCollencteions[i] = new System.Drawing.Pen(System.Drawing.Color.FromArgb(_color.A, _color.R, _color.G, _color.B), 2);
  538. }
  539. this.view.MyDrawGraphicsControl.PointCollections = cls;
  540. this.view.MyDrawGraphicsControl.FitControl();
  541. this.view.MyDrawGraphicsControl.YPoints.Clear();
  542. //var item = QueryDataClient.Instance.Service.GetHistorySteps(Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime));
  543. //if (item!=null)
  544. //{
  545. // item.ForEach(x =>
  546. // {
  547. // this.view.MyDrawGraphicsControl.YPoints.Add(new Venus_Core.StepItem() { StartValue = x.StartTime.ToOADate(), Information = $"{x.RecipeId}:{x.StepNo}" });
  548. // });
  549. //}
  550. if (IsShowStep)
  551. {
  552. var item2 = QueryDataClient.Instance.Service.GetHistorySteps(Convert.ToDateTime(selectedRecipeItem?.StartTime), Convert.ToDateTime(selectedRecipeItem?.EndTime));
  553. if (item2 != null)
  554. {
  555. item2.ForEach(x =>
  556. {
  557. this.view.MyDrawGraphicsControl.YPoints.Add(new Venus_Core.StepItem() { StartValue = x.StartTime.ToOADate(), Information = $"{x.RecipeId}\n{x.StepNo}\n{x.StartTime.ToString("HH:mm:ss:fff")}" });
  558. });
  559. }
  560. }
  561. }
  562. private void CloseAll(ObservableCollection<ParameterNode> parameterNodes)
  563. {
  564. if (parameterNodes != null)
  565. {
  566. foreach (var item in parameterNodes)
  567. {
  568. item.Selected = false;
  569. if (item.ChildNodes.Count > 0)
  570. {
  571. CloseAll(item.ChildNodes);
  572. }
  573. }
  574. }
  575. }
  576. private void OnClearData()
  577. {
  578. this.view.MyDrawGraphicsControl.YPoints.Clear();
  579. PdKeyDataCollection.Clear();
  580. this.view.MyDrawGraphicsControl.ClearPlotPoints();
  581. CloseAll(ParameterNodes);
  582. }
  583. public void ColorChanged()
  584. {
  585. for (int i = 0; i < PdKeyDataCollection.Count(); i++)
  586. {
  587. var _color = PdKeyDataCollection[i].Color.Color;
  588. this.view.MyDrawGraphicsControl.m_PenCollencteions[i] = new System.Drawing.Pen(System.Drawing.Color.FromArgb(_color.A, _color.R, _color.G, _color.B), 2);
  589. }
  590. }
  591. }
  592. #endregion
  593. #region 数据类
  594. public class RecipeItem : BindableBase
  595. {
  596. public bool Selected { get; set; }
  597. public string Recipe { get; set; }
  598. public string Guid { get; set; }
  599. public string RecipeRunGuid { get; set; }
  600. public string Chamber { get; set; }
  601. public string Status { get; set; }
  602. public string StartTime { get; set; }
  603. public string EndTime { get; set; }
  604. public string LotID { get; set; }
  605. public string SlotID { get; set; }
  606. public string RecipeType { get; set; }
  607. }
  608. public class StepData
  609. {
  610. [DataMember]
  611. public int No { get; set; }
  612. [DataMember]
  613. public string Name { get; set; }
  614. [DataMember]
  615. public DateTime StartTime { get; set; }
  616. [DataMember]
  617. public DateTime EndTime { get; set; }
  618. [DataMember]
  619. public string ActualTime { get; set; }
  620. [DataMember]
  621. public string SettingTime { get; set; }
  622. }
  623. public class PdKeyData : BindableBase, ICloneable
  624. {
  625. public string Key { get; set; }
  626. public SolidColorBrush _Color;
  627. public SolidColorBrush Color
  628. {
  629. get { return _Color; }
  630. set { SetProperty(ref _Color, value); }
  631. }
  632. public int UniqueId { get; set; }
  633. public object Clone()
  634. {
  635. return MemberwiseClone();
  636. }
  637. }
  638. #endregion
  639. }