BatchDetailViewModel.cs 8.9 KB

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