WaferDataRecorder.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. using MECF.Framework.Common.CommonData;
  8. namespace MECF.Framework.Common.DBCore
  9. {
  10. public class WaferDataRecorder
  11. {
  12. public static void CreateWafer(string guid, string carrierGuid, string station, int slot, string waferId )
  13. {
  14. string sql = string.Format(
  15. "INSERT INTO \"wafer_data\"(\"guid\", \"create_time\", \"carrier_data_guid\", \"create_station\", \"wafer_id\",\"create_slot\" )VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}' );",
  16. guid,
  17. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  18. carrierGuid,
  19. station,
  20. waferId,
  21. slot+1 );
  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 SetPjInfo(string guid, string pjGuid)
  32. {
  33. string sql = string.Format("UPDATE \"wafer_data\" SET \"pj_data_guid\"='{0}' WHERE \"guid\"='{1}';",
  34. pjGuid,
  35. guid);
  36. DB.Insert(sql);
  37. }
  38. public static void SetWaferMarker(string guid, string marker )
  39. {
  40. string sql = string.Format("UPDATE \"wafer_data\" SET \"lasermarker1\"='{0}' WHERE \"guid\"='{1}';",
  41. marker,
  42. guid);
  43. DB.Insert(sql);
  44. }
  45. public static void SetWaferT7Code(string guid, string t7code )
  46. {
  47. string sql = string.Format("UPDATE \"wafer_data\" SET \"t7code1\"='{0}' WHERE \"guid\"='{1}';",
  48. t7code,
  49. guid);
  50. DB.Insert(sql);
  51. }
  52. public static void SetWaferId(string guid, string marker1, string marker2, string marker3, string t7code1, string t7code2, string t7code3)
  53. {
  54. string sql = string.Format("UPDATE \"wafer_data\" SET \"lasermarker1\"='{0}', \"t7code1\"='{1}' WHERE \"guid\"='{2}';",
  55. marker1,
  56. t7code1,
  57. guid);
  58. DB.Insert(sql);
  59. }
  60. public static void SetWaferLotId(string guid, string lotId,string sequence)
  61. {
  62. string sql = $"UPDATE \"wafer_data\" SET \"lot_id\"='{lotId}', \"sequence_name\"='{sequence}' WHERE \"guid\"='{guid}';";
  63. DB.Insert(sql);
  64. }
  65. public static void DeleteWafer(string guid )
  66. {
  67. string sql = string.Format("UPDATE \"wafer_data\" SET \"delete_time\"='{0}' WHERE \"guid\"='{1}';",
  68. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  69. guid);
  70. DB.Insert(sql);
  71. }
  72. public static List<HistoryWaferData> QueryDBWafer(string sql)
  73. {
  74. List<HistoryWaferData> result = new List<HistoryWaferData>();
  75. try
  76. {
  77. DataSet ds = DB.ExecuteDataset(sql);
  78. if (ds == null)
  79. return result;
  80. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  81. {
  82. HistoryWaferData ev = new HistoryWaferData();
  83. ev.Guid = ds.Tables[0].Rows[i]["guid"].ToString();
  84. ev.LaserMarker = ds.Tables[0].Rows[i]["lasermarker1"].ToString();
  85. ev.T7Code = ds.Tables[0].Rows[i]["t7code1"].ToString();
  86. if (!ds.Tables[0].Rows[i]["create_time"].Equals(DBNull.Value))
  87. ev.CreateTime = ((DateTime)ds.Tables[0].Rows[i]["create_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");
  88. if (!ds.Tables[0].Rows[i]["delete_time"].Equals(DBNull.Value))
  89. ev.DeleteTime = ((DateTime)ds.Tables[0].Rows[i]["delete_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");
  90. ev.Station = ds.Tables[0].Rows[i]["create_station"].ToString();
  91. ev.Slot = ds.Tables[0].Rows[i]["create_slot"].ToString();
  92. ev.CarrierGuid = ds.Tables[0].Rows[i]["carrier_data_guid"].ToString();
  93. ev.WaferId = ds.Tables[0].Rows[i]["wafer_id"].ToString();
  94. result.Add(ev);
  95. }
  96. result.Sort((x, y) => int.Parse(x.Slot) - int.Parse(y.Slot) );
  97. }
  98. catch (Exception ex)
  99. {
  100. LOG.Write(ex);
  101. }
  102. return result;
  103. }
  104. }
  105. }