ProcessDetailV2ViewModel.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. using Aitex.Core.UI.Control;
  2. using Aitex.Core.Util;
  3. using Caliburn.Micro.Core;
  4. using DocumentFormat.OpenXml.Drawing;
  5. using DocumentFormat.OpenXml.Drawing.Diagrams;
  6. using MECF.Framework.Common.DataCenter;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.Common.Utilities;
  9. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  10. using MECF.Framework.UI.Client.ClientBase;
  11. using SciChart.Core.Extensions;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Data;
  16. using System.Diagnostics.Eventing.Reader;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
  21. {
  22. public class ProcessDetailV2ViewModel : ModuleUiViewModelBase
  23. {
  24. #region
  25. [Subscription("Rt.Status")]
  26. public string RtStatus { get; set; }
  27. [Subscription("PM1.Status")]
  28. public string PM1Status { get; set; }
  29. private int _upperSDNum = 0;
  30. public int UpperSDNum
  31. {
  32. get => _upperSDNum;
  33. set
  34. {
  35. _upperSDNum = value;
  36. NotifyOfPropertyChange(nameof(UpperSDNum));
  37. }
  38. }
  39. private int _productNum = 0;
  40. public int ProductNum
  41. {
  42. get => _productNum;
  43. set
  44. {
  45. _productNum = value;
  46. NotifyOfPropertyChange(nameof(ProductNum));
  47. }
  48. }
  49. private int _monitorNum1 = 0;
  50. public int MonitorNum1
  51. {
  52. get => _monitorNum1;
  53. set
  54. {
  55. _monitorNum1 = value;
  56. NotifyOfPropertyChange(nameof(MonitorNum1));
  57. }
  58. }
  59. private int _monitorNum2 = 0;
  60. public int MonitorNum2
  61. {
  62. get => _monitorNum2;
  63. set
  64. {
  65. _monitorNum2 = value;
  66. NotifyOfPropertyChange(nameof(MonitorNum2));
  67. }
  68. }
  69. private int _lowerSDNum = 0;
  70. public int LowerSDNum
  71. {
  72. get => _lowerSDNum;
  73. set
  74. {
  75. _lowerSDNum = value;
  76. NotifyOfPropertyChange(nameof(LowerSDNum));
  77. }
  78. }
  79. private int _selectItemIndex = 0;
  80. public int SelectItemIndex
  81. {
  82. get => _selectItemIndex;
  83. set
  84. {
  85. _selectItemIndex = value;
  86. NotifyOfPropertyChange(nameof(SelectItemIndex));
  87. }
  88. }
  89. private int _tableCount = 0;
  90. public int TableCount
  91. {
  92. get => _tableCount;
  93. set
  94. {
  95. _tableCount = value;
  96. NotifyOfPropertyChange(nameof(TableCount));
  97. }
  98. }
  99. private List<string> _boatMapWafers = new List<string>();
  100. public List<string> BoatMapWafers
  101. {
  102. get => _boatMapWafers;
  103. set
  104. {
  105. _boatMapWafers = value;
  106. NotifyOfPropertyChange(nameof(BoatMapWafers));
  107. }
  108. }
  109. private ProcessDetailV2ViewData _viewData;
  110. public ProcessDetailV2ViewData ViewData
  111. {
  112. get => _viewData;
  113. set
  114. {
  115. _viewData = value;
  116. NotifyOfPropertyChange(nameof(ViewData));
  117. }
  118. }
  119. private RecipeDataBase _layoutRecipe = new RecipeDataBase();
  120. public RecipeDataBase LayoutRecipe
  121. {
  122. get { return _layoutRecipe; }
  123. set { _layoutRecipe = value; this.NotifyOfPropertyChange(nameof(LayoutRecipe)); }
  124. }
  125. private RecipeDataBase _processRecipe = new RecipeDataBase();
  126. public RecipeDataBase ProcessRecipe
  127. {
  128. get { return _processRecipe; }
  129. set { _processRecipe = value; this.NotifyOfPropertyChange(nameof(ProcessRecipe)); }
  130. }
  131. private ProcessHistoryLot _pJInfo = new ProcessHistoryLot();
  132. public ProcessHistoryLot PJInfo
  133. {
  134. get { return _pJInfo; }
  135. set { _pJInfo = value; this.NotifyOfPropertyChange(nameof(PJInfo)); }
  136. }
  137. private readonly RecipeProvider _recipeProvider = new RecipeProvider();
  138. private RecipeFormatBuilder _columnBuilder = new RecipeFormatBuilder();
  139. private string _processPrefix = "Furnace\\Process";
  140. private string _layoutPrefix = "Furnace\\Layout";
  141. #endregion
  142. public ProcessDetailV2ViewModel()
  143. {
  144. }
  145. protected override void OnViewLoaded(object _view)
  146. {
  147. base.OnViewLoaded(_view);
  148. ViewData = new ProcessDetailV2ViewData();
  149. LoadLayoutInfo(PJInfo.LayoutName);
  150. LoadProcessData();
  151. if (string.IsNullOrEmpty(PJInfo.LayoutName))
  152. {
  153. ViewData.ProcessStartTime = ViewData.PJobStartTime;
  154. ViewData.ProcessEndTime = ViewData.PJobEndTime;
  155. }
  156. }
  157. private void LoadProcessData()
  158. {
  159. var pjStartNoEnd = PJInfo.StartTime != DateTime.MinValue && PJInfo.EndTime == DateTime.MinValue;
  160. var pjStartAndEnd = PJInfo.StartTime != DateTime.MinValue && PJInfo.EndTime != DateTime.MinValue;
  161. var hasLayoutRecipe = !string.IsNullOrEmpty(PJInfo.LayoutName);
  162. string sql = $"SELECT * FROM process_data where (pj_id ='{PJInfo.PjId}')";
  163. if (string.IsNullOrEmpty(PJInfo.PjId))
  164. {
  165. sql = $"SELECT * FROM process_data where (recipe_name ='{PJInfo.RecipeName}' and process_begin_time >= '{PJInfo.StartTime:yyyy/MM/dd HH:mm:ss.fff}' and process_end_time <= '{PJInfo.EndTime:yyyy/MM/dd HH:mm:ss.fff}') order by process_begin_time DESC;";
  166. }
  167. DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
  168. string processDataStatus = "";
  169. if (dbData != null && dbData.Rows.Count > 0)
  170. {
  171. ViewData.ProcessStartTime = dbData.Rows[0]["process_begin_time"].ToString();
  172. ViewData.ProcessEndTime = dbData.Rows[0]["process_end_time"].ToString();
  173. processDataStatus = dbData.Rows[0]["process_status"].ToString();
  174. }
  175. if (pjStartNoEnd)
  176. {
  177. ViewData.IsSettingUp = true;
  178. ViewData.IsProcessComplete = false;
  179. ViewData.IsProcessing = false;
  180. }
  181. if (!string.IsNullOrEmpty(ViewData.ProcessStartTime) && string.IsNullOrEmpty(ViewData.ProcessEndTime))
  182. {
  183. ViewData.IsSettingUp = false;
  184. ViewData.IsProcessComplete = false;
  185. ViewData.IsProcessing = true;
  186. }
  187. if (pjStartAndEnd)
  188. {
  189. ViewData.IsSettingUp = false;
  190. ViewData.IsProcessComplete = true;
  191. ViewData.IsProcessing = false;
  192. }
  193. if (PJInfo.Form == ProcessEndResultEnum.Abort.ToDescription())
  194. {
  195. ViewData.ProcessEndResult = ProcessEndResultEnum.Abort.ToDescription();
  196. return;
  197. }
  198. if (PJInfo.Form == ProcessEndResultEnum.Normal.ToDescription() && !string.IsNullOrEmpty(processDataStatus) && processDataStatus == ProcessEndResultEnum.Succeed.ToDescription())
  199. {
  200. ViewData.ProcessEndResult = ProcessEndResultEnum.NORMALEND.ToDescription();
  201. return;
  202. }
  203. if (pjStartNoEnd || (PJInfo.Form == ProcessEndResultEnum.Normal.ToDescription() && string.IsNullOrEmpty(processDataStatus)))
  204. {
  205. ViewData.ProcessEndResult = ProcessEndResultEnum.NONE.ToDescription();
  206. return;
  207. }
  208. }
  209. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  210. {
  211. // RefreshCassetteDataTask();
  212. }
  213. private void RefreshCassetteDataTask()
  214. {
  215. var wafers = ModuleManager.ModuleInfos[ModuleName.PM1.ToString()].WaferManager.Wafers;
  216. }
  217. private void LoadLayoutInfo(string layoutName)
  218. {
  219. ViewData.PJobStartTime = PJInfo.StartTime.ToString("yyyy/MM/dd HH:mm:ss.fff");
  220. ViewData.PJobEndTime = PJInfo.EndTime.ToString("yyyy/MM/dd HH:mm:ss.fff");
  221. if (string.IsNullOrEmpty(layoutName))
  222. {
  223. return;
  224. }
  225. _columnBuilder.Build("Layout");
  226. LayoutRecipe.PrefixPath = _layoutPrefix;
  227. var recipeContent = _recipeProvider.LoadRecipe(LayoutRecipe.PrefixPath, layoutName);
  228. //if (string.IsNullOrEmpty(recipeContent))
  229. //{
  230. // System.Windows.MessageBox.Show($"{layoutName} is empty, please confirm the file is valid.");
  231. // return;
  232. //}
  233. // LayoutRecipe.InitData(LayoutRecipe.PrefixPath, layoutName, recipeContent, _columnBuilder.Configs, "PM1");
  234. var waferNumberAll = (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount");
  235. var cassetteSlotCount = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount");
  236. List<string> listWafers = QueryDataClient.Instance.Service.GetLayoutRecipeContent(recipeContent, waferNumberAll.ToString(), cassetteSlotCount.ToString());
  237. BoatMapWafers = listWafers;
  238. if (null != BoatMapWafers && BoatMapWafers.Count > 0)
  239. {
  240. var data = ComputSD(BoatMapWafers);
  241. ComputWafer(listWafers);
  242. }
  243. }
  244. private void ComputWafer(List<string> listWafers)
  245. {
  246. UpperSDNum = listWafers.Where(x => x == "SD").Count();
  247. LowerSDNum = listWafers.Where(x => x == "FD").Count();
  248. ProductNum = listWafers.Where(x => x.StartsWith("P")).Count();
  249. MonitorNum1 = listWafers.Where(x => x == "M1").Count();
  250. MonitorNum2 = listWafers.Where(x => x == "M2").Count();
  251. }
  252. private Tuple<int, int> ComputSD(List<string> dataSource)
  253. {
  254. List<string> otherSlot = dataSource.Where(a => a != "SD" && !string.IsNullOrEmpty(a)).ToList().Distinct().ToList();
  255. if (dataSource == null || dataSource.Count == 0)
  256. {
  257. return new Tuple<int, int>(0, 0);
  258. }
  259. List<int> minList = new List<int>();
  260. for (int i = 0; i < dataSource.Count; i++)
  261. {
  262. var item = dataSource[i];
  263. if (otherSlot.Contains(item) && !string.IsNullOrEmpty(item))
  264. {
  265. break;
  266. }
  267. if (string.IsNullOrEmpty(item))
  268. {
  269. continue;
  270. }
  271. minList.Add(i);
  272. }
  273. dataSource.Reverse();
  274. List<int> maxList = new List<int>();
  275. for (int i = 0; i < dataSource.Count; i++)
  276. {
  277. var item = dataSource[i];
  278. if (otherSlot.Contains(item) && !string.IsNullOrEmpty(item))
  279. {
  280. break;
  281. }
  282. if (string.IsNullOrEmpty(item))
  283. {
  284. continue;
  285. }
  286. maxList.Add(i);
  287. }
  288. return new Tuple<int, int>(minList.Count(), maxList.Count());
  289. }
  290. public enum ProcessEndResultEnum
  291. {
  292. [Description("NORMAL END")]
  293. NORMALEND,
  294. [Description("ABNORMAL END")]
  295. ABNORMALEND,
  296. [Description("NONE")]
  297. NONE,
  298. [Description("Recipe Abort")]
  299. Abort,
  300. [Description("Normal")]
  301. Normal, [Description("Succeed")]
  302. Succeed,
  303. }
  304. public class ProcessDetailV2ViewData : PropertyChangedBase
  305. {
  306. private string _processEndResult;
  307. public string ProcessEndResult
  308. {
  309. get => _processEndResult;
  310. set
  311. {
  312. _processEndResult = value;
  313. NotifyOfPropertyChange(nameof(ProcessEndResult));
  314. }
  315. }
  316. private string _pJobStartTime = "";
  317. public string PJobStartTime
  318. {
  319. get => _pJobStartTime;
  320. set
  321. {
  322. _pJobStartTime = value;
  323. NotifyOfPropertyChange(nameof(PJobStartTime));
  324. }
  325. }
  326. public string PJobEndTime
  327. {
  328. get => _pJobEndTime;
  329. set
  330. {
  331. _pJobEndTime = value;
  332. NotifyOfPropertyChange(nameof(PJobEndTime));
  333. }
  334. }
  335. private string _pJobEndTime = "";
  336. public string ExecREcipeThinckess
  337. {
  338. get => _execREcipeThinckess;
  339. set
  340. {
  341. _execREcipeThinckess = value;
  342. NotifyOfPropertyChange(nameof(ExecREcipeThinckess));
  343. }
  344. }
  345. private string _execREcipeThinckess = "";
  346. public string ProcessStartTime
  347. {
  348. get => _processStartTime;
  349. set
  350. {
  351. _processStartTime = value;
  352. NotifyOfPropertyChange(nameof(ProcessStartTime));
  353. }
  354. }
  355. private string _processStartTime = "";
  356. public string ProcessEndTime
  357. {
  358. get => _processEndTime;
  359. set
  360. {
  361. _processEndTime = value;
  362. NotifyOfPropertyChange(nameof(ProcessEndTime));
  363. }
  364. }
  365. private string _processEndTime = "";
  366. public string CJobId
  367. {
  368. get => _cJobId;
  369. set
  370. {
  371. _cJobId = value;
  372. NotifyOfPropertyChange(nameof(CJobId));
  373. }
  374. }
  375. private string _cJobId = "";
  376. private List<string> _pCarrierIdList = new List<string>();
  377. public List<string> PCarrierIdList
  378. {
  379. get => _pCarrierIdList;
  380. set
  381. {
  382. _pCarrierIdList = value;
  383. NotifyOfPropertyChange(nameof(PCarrierIdList));
  384. }
  385. }
  386. private bool _isSettingUp = false;
  387. public bool IsSettingUp
  388. {
  389. get => _isSettingUp;
  390. set
  391. {
  392. _isSettingUp = value;
  393. NotifyOfPropertyChange(nameof(IsSettingUp));
  394. }
  395. }
  396. private bool _isProcessing = false;
  397. public bool IsProcessing
  398. {
  399. get => _isProcessing;
  400. set
  401. {
  402. _isProcessing = value;
  403. NotifyOfPropertyChange(nameof(IsProcessing));
  404. }
  405. }
  406. private bool _isProcessComplete = false;
  407. public bool IsProcessComplete
  408. {
  409. get => _isProcessComplete;
  410. set
  411. {
  412. _isProcessComplete = value;
  413. NotifyOfPropertyChange(nameof(IsProcessComplete));
  414. }
  415. }
  416. }
  417. }
  418. }