WaferMoveHistoryRecorder.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. /*
  10. *
  11. guid text NOT NULL,
  12. wafer_data_guid text,
  13. arrive_time timestamp without time zone,
  14. station timestamp without time zone,
  15. slot text,
  16. status text,
  17. CONSTRAINT wafer_move_history_pkey PRIMARY KEY (guid)
  18. *
  19. *
  20. *
  21. *
  22. */
  23. public class WaferMoveHistoryRecorder
  24. {
  25. public static void WaferMoved(string guid, string station, int slot, string status )
  26. {
  27. string sql = string.Format("INSERT INTO \"wafer_move_history\"(\"wafer_data_guid\", \"arrive_time\", \"station\", \"slot\", \"status\" )VALUES ('{0}', '{1}', '{2}', '{3}', '{4}' );",
  28. guid,
  29. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  30. station,
  31. slot+1,
  32. status);
  33. DB.Insert(sql);
  34. }
  35. public static void WaferUpdate(string guid, string recipeName, string station)
  36. {
  37. string sql = string.Format("UPDATE \"wafer_move_history\" SET \"recipe_name\"='{0}' WHERE \"station\"='{1}' and \"wafer_data_guid\"='{2}';",
  38. recipeName,
  39. station,
  40. guid);
  41. DB.Insert(sql);
  42. }
  43. public static List<HistoryMoveData> QueryDBMovement(string sql)
  44. {
  45. List<HistoryMoveData> result = new List<HistoryMoveData>();
  46. try
  47. {
  48. DataSet ds = DB.ExecuteDataset(sql);
  49. if (ds == null)
  50. return result;
  51. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  52. {
  53. HistoryMoveData ev = new HistoryMoveData();
  54. ev.WaferGuid = ds.Tables[0].Rows[i]["wafer_data_guid"].ToString();
  55. ev.Station = ds.Tables[0].Rows[i]["station"].ToString();
  56. ev.Slot = ds.Tables[0].Rows[i]["slot"].ToString();
  57. ev.Result = ds.Tables[0].Rows[i]["status"].ToString();
  58. if (!ds.Tables[0].Rows[i]["arrive_time"].Equals(DBNull.Value))
  59. ev.ArriveTime = ((DateTime)ds.Tables[0].Rows[i]["arrive_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");
  60. result.Add(ev);
  61. }
  62. }
  63. catch (Exception ex)
  64. {
  65. LOG.Write(ex);
  66. }
  67. return result;
  68. }
  69. public static List<WaferHistoryMovement> GetWaferHistoryMovements(string id)
  70. {
  71. //WaferHistoryMovement temp = new WaferHistoryMovement();
  72. //temp.Source = "LP1";
  73. //temp.Destination = "PM1";
  74. //temp.InTime = DateTime.Now.ToString();
  75. List<WaferHistoryMovement> result = new List<WaferHistoryMovement>();
  76. try
  77. {
  78. string sql = string.Format("SELECT * FROM \"wafer_move_history\" where \"wafer_data_guid\" = '{0}' order by \"arrive_time\" ASC limit 1000;", id);
  79. DataSet dataSet = DB.ExecuteDataset(sql);
  80. if (dataSet == null)
  81. return result;
  82. if (dataSet.Tables.Count == 0 || dataSet.Tables[0].Rows.Count == 0)
  83. return result;
  84. for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
  85. {
  86. WaferHistoryMovement item = new WaferHistoryMovement();
  87. item.Source = $"station : {dataSet.Tables[0].Rows[i]["station"]} slot : {dataSet.Tables[0].Rows[i]["slot"]}";
  88. if (i != dataSet.Tables[0].Rows.Count - 1)
  89. item.Destination = $"station : {dataSet.Tables[0].Rows[i + 1]["station"]} slot : {dataSet.Tables[0].Rows[i + 1]["slot"]}";
  90. else
  91. item.Destination = "";
  92. item.InTime = dataSet.Tables[0].Rows[i]["arrive_time"].ToString();
  93. result.Add(item);
  94. }
  95. }
  96. catch (Exception e)
  97. {
  98. LOG.Write(e);
  99. }
  100. return result;
  101. }
  102. }
  103. }