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