WaferMoveHistoryRecorder.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 List<HistoryMoveData> QueryDBMovement(string sql)
  36. {
  37. List<HistoryMoveData> result = new List<HistoryMoveData>();
  38. try
  39. {
  40. DataSet ds = DB.ExecuteDataset(sql);
  41. if (ds == null)
  42. return result;
  43. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  44. {
  45. HistoryMoveData ev = new HistoryMoveData();
  46. ev.WaferGuid = ds.Tables[0].Rows[i]["wafer_data_guid"].ToString();
  47. ev.Station = ds.Tables[0].Rows[i]["station"].ToString();
  48. ev.Slot = ds.Tables[0].Rows[i]["slot"].ToString();
  49. ev.Result = ds.Tables[0].Rows[i]["status"].ToString();
  50. if (!ds.Tables[0].Rows[i]["arrive_time"].Equals(DBNull.Value))
  51. ev.ArriveTime = ((DateTime)ds.Tables[0].Rows[i]["arrive_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");
  52. result.Add(ev);
  53. }
  54. }
  55. catch (Exception ex)
  56. {
  57. LOG.Write(ex);
  58. }
  59. return result;
  60. }
  61. public static List<WaferHistoryMovement> GetWaferHistoryMovements(string id)
  62. {
  63. //WaferHistoryMovement temp = new WaferHistoryMovement();
  64. //temp.Source = "LP1";
  65. //temp.Destination = "PM1";
  66. //temp.InTime = DateTime.Now.ToString();
  67. List<WaferHistoryMovement> result = new List<WaferHistoryMovement>();
  68. try
  69. {
  70. string sql = string.Format("SELECT * FROM \"wafer_move_history\" where \"wafer_data_guid\" = '{0}' order by \"arrive_time\" ASC limit 1000;", id);
  71. DataSet dataSet = DB.ExecuteDataset(sql);
  72. if (dataSet == null)
  73. return result;
  74. if (dataSet.Tables.Count == 0 || dataSet.Tables[0].Rows.Count == 0)
  75. return result;
  76. for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
  77. {
  78. WaferHistoryMovement item = new WaferHistoryMovement();
  79. item.Source = $"station : {dataSet.Tables[0].Rows[i]["station"]} slot : {dataSet.Tables[0].Rows[i]["slot"]}";
  80. if (i != dataSet.Tables[0].Rows.Count - 1)
  81. item.Destination = $"station : {dataSet.Tables[0].Rows[i + 1]["station"]} slot : {dataSet.Tables[0].Rows[i + 1]["slot"]}";
  82. else
  83. item.Destination = "";
  84. item.InTime = dataSet.Tables[0].Rows[i]["arrive_time"].ToString();
  85. result.Add(item);
  86. }
  87. }
  88. catch (Exception e)
  89. {
  90. LOG.Write(e);
  91. }
  92. return result;
  93. }
  94. }
  95. }