BatchDetailViewModel.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. using Caliburn.Micro;
  2. using Caliburn.Micro.Core;
  3. using MECF.Framework.Common.CommonData;
  4. using MECF.Framework.UI.Client.CenterViews.Controls;
  5. using MECF.Framework.UI.Client.ClientBase;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Media;
  14. namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
  15. {
  16. public class BatchDetailViewModel : ModuleUiViewModelBase
  17. {
  18. public List<BoatWaferItem> BoatWafers { get; set; } = new List<BoatWaferItem>();
  19. public ObservableCollection<BatchDetailItem> BatchDetailItems { get; set; } = new ObservableCollection<BatchDetailItem>();
  20. private SolidColorBrush _DefaultdBk = new SolidColorBrush(Colors.White);
  21. private SolidColorBrush _SDBk = new SolidColorBrush(Color.FromArgb(255, 251, 147, 85));
  22. private SolidColorBrush _FDBk = new SolidColorBrush(Color.FromArgb(255, 170, 147, 255));
  23. private SolidColorBrush _PBk = new SolidColorBrush(Color.FromArgb(255, 2, 255, 255));
  24. private SolidColorBrush _M1Bk = new SolidColorBrush(Color.FromArgb(255, 3, 149, 255));
  25. private SolidColorBrush _M2Bk = new SolidColorBrush(Color.FromArgb(255, 255, 111, 171));
  26. private string _batchId;
  27. public string BatchId
  28. {
  29. get => _batchId;
  30. set
  31. {
  32. _batchId = value;
  33. NotifyOfPropertyChange(nameof(BatchId));
  34. }
  35. }
  36. private string _layoutName;
  37. public string LayoutName
  38. {
  39. get => _layoutName;
  40. set
  41. {
  42. _layoutName = value;
  43. NotifyOfPropertyChange(nameof(LayoutName));
  44. }
  45. }
  46. private int _productionCount;
  47. public int ProductionCount
  48. {
  49. get => _productionCount;
  50. set
  51. {
  52. _productionCount = value;
  53. NotifyOfPropertyChange(nameof(ProductionCount));
  54. }
  55. }
  56. private int _monitor1Count;
  57. public int Monitor1Count
  58. {
  59. get => _monitor1Count;
  60. set
  61. {
  62. _monitor1Count = value;
  63. NotifyOfPropertyChange(nameof(Monitor1Count));
  64. }
  65. }
  66. private int _monitor2Count;
  67. public int Monitor2Count
  68. {
  69. get => _monitor2Count;
  70. set
  71. {
  72. _monitor2Count = value;
  73. NotifyOfPropertyChange(nameof(Monitor2Count));
  74. }
  75. }
  76. private int _dummyCount;
  77. public int DummyCount
  78. {
  79. get => _dummyCount;
  80. set
  81. {
  82. _dummyCount = value;
  83. NotifyOfPropertyChange(nameof(DummyCount));
  84. }
  85. }
  86. private int _extraDummyCount;
  87. public int ExtraDummyCount
  88. {
  89. get => _extraDummyCount;
  90. set
  91. {
  92. _extraDummyCount = value;
  93. NotifyOfPropertyChange(nameof(ExtraDummyCount));
  94. }
  95. }
  96. private int _etcCount;
  97. public int EtcCount
  98. {
  99. get => _etcCount;
  100. set
  101. {
  102. _etcCount = value;
  103. NotifyOfPropertyChange(nameof(EtcCount));
  104. }
  105. }
  106. private int _total;
  107. public int Total
  108. {
  109. get => _total;
  110. set
  111. {
  112. _total = value;
  113. NotifyOfPropertyChange(nameof(Total));
  114. }
  115. }
  116. public DateTime StartTime { get; set; }
  117. public DateTime EndTime { get; set; }
  118. private int _cassetteSelectIndex;
  119. public int CassetteSelectIndex
  120. {
  121. get => _cassetteSelectIndex;
  122. set
  123. {
  124. _cassetteSelectIndex = value;
  125. NotifyOfPropertyChange(nameof(CassetteSelectIndex));
  126. }
  127. }
  128. public BatchDetailViewModel()
  129. {
  130. }
  131. public BatchDetailViewModel(DateTime startTime, DateTime endTime, string batchId, List<string> layoutData, int iSlotCount, List<string> waferData, string layoutName = "")
  132. {
  133. StartTime = startTime;
  134. EndTime = endTime;
  135. BatchId = batchId;
  136. Total = iSlotCount;
  137. LayoutName = layoutName;
  138. for (int i = 0; i < iSlotCount; i++)
  139. {
  140. BoatWaferItem item = new BoatWaferItem() { Slot = i + 1, Description = $"{layoutData[i]}" };
  141. BoatWafers.Add(item);
  142. }
  143. for (int i = 0; i < iSlotCount; i++)
  144. {
  145. string waferType = BoatWafers[i].Description.Split('-').ToList()[0];
  146. switch (waferType)
  147. {
  148. case "P":
  149. BoatWafers[i].BkColor = _PBk;
  150. break;
  151. case "M1":
  152. BoatWafers[i].BkColor = _M1Bk;
  153. break;
  154. case "M2":
  155. BoatWafers[i].BkColor = _M2Bk;
  156. break;
  157. case "SD":
  158. BoatWafers[i].BkColor = _SDBk;
  159. break;
  160. case "ED":
  161. BoatWafers[i].BkColor = _FDBk;
  162. break;
  163. default:
  164. BoatWafers[i].BkColor = _DefaultdBk;
  165. break;
  166. }
  167. var description = BoatWafers[i].Description;
  168. BoatWafers[i].Description = description;
  169. }
  170. BatchDetailParser(waferData);
  171. }
  172. private void BatchDetailParser(List<string> waferData)
  173. {
  174. ProductionCount = 0;
  175. Monitor1Count = 0;
  176. Monitor2Count = 0;
  177. DummyCount = 0;
  178. ExtraDummyCount = 0;
  179. EtcCount = 0;
  180. for (int i = 0; i < waferData.Count; i++)
  181. {
  182. if (string.IsNullOrEmpty(waferData[i]))
  183. continue;
  184. var temp = waferData[i].Split(':').ToList();
  185. var wafertype = temp[0];
  186. var stockername = temp[1].Split('.')[0];
  187. var lotid = temp.Count > 2 ? temp[2] : "";
  188. switch (wafertype)
  189. {
  190. case "P":
  191. ProductionCount++;
  192. break;
  193. case "M1":
  194. Monitor1Count++;
  195. break;
  196. case "M2":
  197. Monitor2Count++;
  198. break;
  199. case "SD":
  200. DummyCount++;
  201. break;
  202. case "ED":
  203. ExtraDummyCount++;
  204. break;
  205. }
  206. BatchDetailItem detail = BatchDetailItems.Where(x => x.StockerName == stockername).FirstOrDefault();
  207. if (detail == null)
  208. {
  209. BatchDetailItem item = new BatchDetailItem();
  210. item.WaferType = wafertype;
  211. item.StockerName = stockername;
  212. item.LotId = lotid;
  213. item.WaferCount = 1;
  214. BatchDetailItems.Add(item);
  215. }
  216. else
  217. {
  218. BatchDetailItems.Where(x => x.StockerName == stockername).FirstOrDefault().WaferCount++;
  219. }
  220. }
  221. EtcCount = Total - ProductionCount - Monitor1Count - Monitor2Count - DummyCount - ExtraDummyCount;
  222. }
  223. public void CassetteDetail()
  224. {
  225. if (CassetteSelectIndex != -1 && BatchDetailItems.Count > 0)
  226. {
  227. var windowManager = IoC.Get<IWindowManager>();
  228. CassetteDetailViewModel cassetteDetailViewModel = new CassetteDetailViewModel(StartTime, EndTime, BatchDetailItems[CassetteSelectIndex].LotId);
  229. (windowManager as WindowManager)?.ShowDialogWithTitle(cassetteDetailViewModel, null, "Cassette Detail");
  230. }
  231. }
  232. public void CloseCmd()
  233. {
  234. ((Window)GetView()).Close();
  235. }
  236. }
  237. public class BatchDetailItem : NotifiableItem
  238. {
  239. private string _waferType;
  240. public string WaferType
  241. {
  242. get => _waferType;
  243. set
  244. {
  245. _waferType = value;
  246. InvokePropertyChanged(nameof(WaferType));
  247. }
  248. }
  249. private string _stockerName;
  250. public string StockerName
  251. {
  252. get => _stockerName;
  253. set
  254. {
  255. _stockerName = value;
  256. InvokePropertyChanged(nameof(StockerName));
  257. }
  258. }
  259. private string _lotId;
  260. public string LotId
  261. {
  262. get => _lotId;
  263. set
  264. {
  265. _lotId = value;
  266. InvokePropertyChanged(nameof(LotId));
  267. }
  268. }
  269. private int _waferCount;
  270. public int WaferCount
  271. {
  272. get => _waferCount;
  273. set
  274. {
  275. _waferCount = value;
  276. InvokePropertyChanged(nameof(WaferCount));
  277. }
  278. }
  279. }
  280. }