WaferDataRecorder.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using Aitex.Core.RT.DBCore;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Sorter.Common;
  7. namespace MECF.Framework.Common.DBCore
  8. {
  9. public class WaferDataRecorder
  10. {
  11. public static void CreateWafer(string guid, string carrierGuid, string station, int slot, string waferId, string status = "")
  12. {
  13. string sql = string.Format(
  14. "INSERT INTO \"wafer_data\"(\"guid\", \"create_time\", \"carrier_data_guid\", \"create_station\", \"wafer_id\",\"create_slot\",\"process_status\" )VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}' );",
  15. guid,
  16. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  17. carrierGuid,
  18. station,
  19. waferId,
  20. slot + 1,
  21. status);
  22. DB.Insert(sql);
  23. }
  24. public static void SetProcessInfo(string guid, string processGuid)
  25. {
  26. string sql = string.Format("UPDATE \"wafer_data\" SET \"process_data_guid\"='{0}' WHERE \"guid\"='{1}';",
  27. processGuid,
  28. guid);
  29. DB.Insert(sql);
  30. }
  31. public static void SetWaferMarker(string guid, string marker)
  32. {
  33. string sql = string.Format("UPDATE \"wafer_data\" SET \"lasermarker1\"='{0}' WHERE \"guid\"='{1}';",
  34. marker,
  35. guid);
  36. DB.Insert(sql);
  37. }
  38. public static void SetPjInfo(string guid, string pjGuid)
  39. {
  40. string sql = string.Format("UPDATE \"wafer_data\" SET \"pj_data_guid\"='{0}' WHERE \"guid\"='{1}';",
  41. pjGuid,
  42. guid);
  43. DB.Insert(sql);
  44. }
  45. public static void SetCjInfo(string guid, string cjGuid)
  46. {
  47. string sql = string.Format("UPDATE \"wafer_data\" SET \"lot_data_guid\"='{0}' WHERE \"guid\"='{1}';",
  48. cjGuid,
  49. guid);
  50. DB.Insert(sql);
  51. }
  52. public static void SetWaferLotId(string guid, string lotId)
  53. {
  54. string sql = string.Format("UPDATE \"wafer_data\" SET \"lot_id\"='{0}' WHERE \"guid\"='{1}';",
  55. lotId,
  56. guid);
  57. DB.Insert(sql);
  58. }
  59. public static void SetWaferStatus(string guid, string status)
  60. {
  61. string sql = string.Format("UPDATE \"wafer_data\" SET \"process_status\"='{0}' WHERE \"guid\"='{1}';",
  62. status,
  63. guid);
  64. DB.Insert(sql);
  65. }
  66. public static void SetWaferNotchAngle(string guid, float angle)
  67. {
  68. string sql = string.Format("UPDATE \"wafer_data\" SET \"notch_angle\"='{0}' WHERE \"guid\"='{1}';",
  69. angle,
  70. guid);
  71. DB.Insert(sql);
  72. }
  73. public static void SetCjobID(string guid, string cjGuid)
  74. {
  75. string sql = string.Format("UPDATE \"wafer_data\" SET \"control_job_guid\"='{0}' WHERE \"guid\"='{1}';",
  76. cjGuid,
  77. guid);
  78. DB.Insert(sql);
  79. }
  80. public static void SetPjobID(string guid, string cjGuid)
  81. {
  82. string sql = string.Format("UPDATE \"wafer_data\" SET \"process_job_guid\"='{0}' WHERE \"guid\"='{1}';",
  83. cjGuid,
  84. guid);
  85. DB.Insert(sql);
  86. }
  87. public static void SetWaferSequence(string guid, string sequence)
  88. {
  89. string sql = string.Format("UPDATE \"wafer_data\" SET \"sequence_name\"='{0}' WHERE \"guid\"='{1}';",
  90. sequence,
  91. guid);
  92. DB.Insert(sql);
  93. }
  94. public static void SetWaferMarkerWithScoreAndFileName(string guid, string marker, string score, string fileName, string filePath)
  95. {
  96. string sql = string.Format("UPDATE \"wafer_data\" SET \"lasermarker1\"='{0}' , \"lasermarker1Score\"='{1}' , \"fileName\"='{2}' , \"filePath\"='{3}' WHERE \"guid\"='{4}';",
  97. marker,
  98. score,
  99. fileName,
  100. filePath,
  101. guid);
  102. DB.Insert(sql);
  103. }
  104. public static void SetWaferT7Code(string guid, string t7code)
  105. {
  106. string sql = string.Format("UPDATE \"wafer_data\" SET \"t7code1\"='{0}' WHERE \"guid\"='{1}';",
  107. t7code,
  108. guid);
  109. DB.Insert(sql);
  110. }
  111. public static void SetWaferT7CodeWithScoreAndFileName(string guid, string t7code, string score, string fileName, string filePath)
  112. {
  113. string sql = string.Format("UPDATE \"wafer_data\" SET \"t7code1\"='{0}' , \"t7code1Score\"='{1}' , \"fileName\"='{2}' , \"filePath\"='{3}' WHERE \"guid\"='{4}';",
  114. t7code,
  115. score,
  116. fileName,
  117. filePath,
  118. guid);
  119. DB.Insert(sql);
  120. }
  121. public static void SetWaferId(string guid, string marker1, string marker2, string marker3, string t7code1, string t7code2, string t7code3)
  122. {
  123. string sql = string.Format("UPDATE \"wafer_data\" SET \"lasermarker1\"='{0}', \"t7code1\"='{1}' WHERE \"guid\"='{2}';",
  124. marker1,
  125. t7code1,
  126. guid);
  127. DB.Insert(sql);
  128. }
  129. public static void UpdateWaferId(string guid, string waferID)
  130. {
  131. string sql = string.Format("UPDATE \"wafer_data\" SET \"wafer_id\"='{0}' WHERE \"guid\"='{1}';",
  132. waferID,
  133. guid);
  134. DB.Insert(sql);
  135. }
  136. public static void DeleteWafer(string guid)
  137. {
  138. string sql = string.Format("UPDATE \"wafer_data\" SET \"delete_time\"='{0}' WHERE \"guid\"='{1}';",
  139. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  140. guid);
  141. DB.Insert(sql);
  142. }
  143. public static List<HistoryWaferData> QueryDBWafer(string sql)
  144. {
  145. List<HistoryWaferData> result = new List<HistoryWaferData>();
  146. try
  147. {
  148. DataSet ds = DB.ExecuteDataset(sql);
  149. if (ds == null)
  150. return result;
  151. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  152. {
  153. HistoryWaferData ev = new HistoryWaferData();
  154. ev.Guid = ds.Tables[0].Rows[i]["guid"].ToString();
  155. ev.LaserMarker = ds.Tables[0].Rows[i]["lasermarker1"].ToString();
  156. ev.T7Code = ds.Tables[0].Rows[i]["t7code1"].ToString();
  157. if (!ds.Tables[0].Rows[i]["create_time"].Equals(DBNull.Value))
  158. ev.CreateTime = ((DateTime)ds.Tables[0].Rows[i]["create_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");
  159. if (!ds.Tables[0].Rows[i]["delete_time"].Equals(DBNull.Value))
  160. ev.DeleteTime = ((DateTime)ds.Tables[0].Rows[i]["delete_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");
  161. ev.LotId = ds.Tables[0].Rows[i]["lot_id"].ToString();
  162. ev.Station = ds.Tables[0].Rows[i]["create_station"].ToString();
  163. ev.Slot = ds.Tables[0].Rows[i]["create_slot"].ToString();
  164. ev.CarrierGuid = ds.Tables[0].Rows[i]["carrier_data_guid"].ToString();
  165. ev.WaferId = ds.Tables[0].Rows[i]["wafer_id"].ToString();
  166. result.Add(ev);
  167. }
  168. result.Sort((x, y) => int.Parse(x.Slot) - int.Parse(y.Slot));
  169. }
  170. catch (Exception ex)
  171. {
  172. LOG.Write(ex);
  173. }
  174. return result;
  175. }
  176. public static List<WaferHistoryWafer> GetWaferHistoryWafers(string id)
  177. {
  178. List<WaferHistoryWafer> result = new List<WaferHistoryWafer>();
  179. try
  180. {
  181. string sql = string.Format("SELECT * FROM \"wafer_data\" where \"carrier_data_guid\" = '{0}' and \"lot_id\" <> '' order by \"wafer_id\" ASC limit 1000;", id);
  182. DataSet dataSet = DB.ExecuteDataset(sql);
  183. if (dataSet == null)
  184. return result;
  185. if (dataSet.Tables.Count == 0 || dataSet.Tables[0].Rows.Count == 0)
  186. return result;
  187. for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
  188. {
  189. WaferHistoryWafer item = new WaferHistoryWafer();
  190. item.ID = dataSet.Tables[0].Rows[i]["guid"].ToString();
  191. item.Type = WaferHistoryItemType.Wafer;
  192. item.Name = dataSet.Tables[0].Rows[i]["wafer_id"].ToString();
  193. if (!dataSet.Tables[0].Rows[i]["sequence_name"].Equals(DBNull.Value))
  194. {
  195. item.ProcessJob = dataSet.Tables[0].Rows[i]["sequence_name"].ToString();
  196. }
  197. if (!dataSet.Tables[0].Rows[i]["create_time"].Equals(DBNull.Value))
  198. item.StartTime = DateTime.Parse(dataSet.Tables[0].Rows[i]["create_time"].ToString());
  199. if (!dataSet.Tables[0].Rows[i]["delete_time"].Equals(DBNull.Value))
  200. item.EndTime = DateTime.Parse(dataSet.Tables[0].Rows[i]["delete_time"].ToString());
  201. result.Add(item);
  202. }
  203. }
  204. catch (Exception e)
  205. {
  206. LOG.Write(e);
  207. }
  208. return result;
  209. }
  210. }
  211. public class OcrDataRecorder
  212. {
  213. public static void RecordOcrReadResult(string guid, string waferid, int souceplp, string sourcecarrier,
  214. int sourceslot, int ocrno, string ocrjob, bool readresult, string lasermark, string ocrscore, string readperiod)
  215. {
  216. string sql = string.Format(
  217. "INSERT INTO \"ocr_data\"(\"guid\", \"wafer_id\", \"read_time\", \"source_lp\", " +
  218. "\"source_carrier\",\"source_slot\",\"ocr_no\" ,\"ocr_job\",\"read_result\",\"lasermark\" ," +
  219. "\"ocr_score\" ,\"read_period\")VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}','{6}', '{7}', '{8}', '{9}', '{10}', '{11}' );",
  220. guid,
  221. waferid,
  222. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  223. souceplp.ToString(),
  224. sourcecarrier,
  225. sourceslot.ToString(),
  226. ocrno.ToString(),
  227. ocrjob,
  228. readresult,
  229. lasermark,
  230. ocrscore,
  231. readperiod);
  232. DB.Insert(sql);
  233. }
  234. }
  235. public class WaferProcessDataRecorder
  236. {
  237. public static void WaferProcessDataRecord(string guid, string station, string dataName, string dataValue)
  238. {
  239. string sql = string.Format("INSERT INTO \"wafer_process_data\"(\"wafer_guid\", \"process_time\", \"station\", \"data_name\", \"data_value\" )VALUES ('{0}', '{1}', '{2}', '{3}', '{4}' );",
  240. guid,
  241. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  242. station,
  243. dataName,
  244. dataValue);
  245. DB.Insert(sql);
  246. }
  247. public static List<WaferHistoryMetrology> GetWaferProcessDatas(string id)
  248. {
  249. //WaferHistoryMovement temp = new WaferHistoryMovement();
  250. //temp.Source = "LP1";
  251. //temp.Destination = "PM1";
  252. //temp.InTime = DateTime.Now.ToString();
  253. List<WaferHistoryMetrology> result = new List<WaferHistoryMetrology>();
  254. try
  255. {
  256. string sql = string.Format("SELECT * FROM \"wafer_process_data\" where \"wafer_guid\" = '{0}' order by \"process_time\" ASC limit 1000;", id);
  257. DataSet dataSet = DB.ExecuteDataset(sql);
  258. if (dataSet == null)
  259. return result;
  260. if (dataSet.Tables.Count == 0 || dataSet.Tables[0].Rows.Count == 0)
  261. return result;
  262. for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
  263. {
  264. WaferHistoryMetrology item = new WaferHistoryMetrology();
  265. item.stationname = dataSet.Tables[0].Rows[i]["station"].ToString();
  266. item.processtime = dataSet.Tables[0].Rows[i]["processtime"].ToString();
  267. item.dataname = dataSet.Tables[0].Rows[i]["data_name"].ToString();
  268. item.datavalue = dataSet.Tables[0].Rows[i]["data_value"].ToString();
  269. result.Add(item);
  270. }
  271. }
  272. catch (Exception e)
  273. {
  274. LOG.Write(e);
  275. }
  276. return result;
  277. }
  278. }
  279. }