BatchDetailViewModel.cs 9.2 KB

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