LinearProcessDataRecorder.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.Core.UI.ControlDataContext;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.DataCenter;
  9. using MECF.Framework.Common.Equipment;
  10. namespace MECF.Framework.Common.DBCore
  11. {
  12. public class LinearProcessDataRecorder
  13. {
  14. public static void Start(string guid, string recipeName, int ppId, string batchId, string cassette1Id, string cassette2Id, string user)
  15. {
  16. string sql = string.Format(
  17. "INSERT INTO \"process_data_linear\"(\"guid\", \"process_begin_time\", \"recipe_name\" , \"pp_id\", \"batch_id\", \"cassette1_id\", \"cassette2_id\", \"user\" , \"cassette1_load_wafer_position\", \"cassette2_load_wafer_position\", \"cassette1_unload_wafer_position\", \"cassette2_unload_wafer_position\")VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}',' ',' ',' ',' ');",
  18. guid,
  19. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  20. recipeName,
  21. ppId,
  22. batchId,
  23. cassette1Id,
  24. cassette2Id,
  25. user);
  26. DB.Insert(sql);
  27. }
  28. public static void UpdateWaferCount(string guid, int cassette1Count, int cassette2Count)
  29. {
  30. string sql = string.Format(
  31. "UPDATE \"process_data_linear\" SET \"cassette1_count\"='{1}', \"cassette2_count\"='{2}' WHERE \"guid\"='{0}';",
  32. guid,
  33. cassette1Count,
  34. cassette2Count);
  35. DB.Insert(sql);
  36. }
  37. public static void UpdateLoadWaferPosition(string guid, string cassette1WaferPosition, string cassette2WaferPosition)
  38. {
  39. string sql = string.Format(
  40. "UPDATE \"process_data_linear\" SET \"cassette1_load_wafer_position\" = '{1}', \"cassette2_load_wafer_position\"='{2}' WHERE \"guid\"='{0}';",
  41. guid,
  42. cassette1WaferPosition,
  43. cassette2WaferPosition);
  44. DB.Insert(sql);
  45. }
  46. public static void UpdateUnloadWaferPosition(string guid, string cassette1WaferPosition, string cassette2WaferPosition)
  47. {
  48. string sql = string.Format(
  49. "UPDATE \"process_data_linear\" SET \"cassette1_unload_wafer_position\" = '{1}', \"cassette2_unload_wafer_position\"='{2}' WHERE \"guid\"='{0}';",
  50. guid,
  51. cassette1WaferPosition,
  52. cassette2WaferPosition);
  53. DB.Insert(sql);
  54. }
  55. public static void End(string guid, string finishType)
  56. {
  57. string sql = string.Format(
  58. "UPDATE \"process_data_linear\" SET \"process_end_time\"='{1}',\"finish_type\"='{2}' WHERE \"guid\"='{0}';",
  59. guid,
  60. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  61. finishType);
  62. DB.Insert(sql);
  63. }
  64. public static List<string> GetProcesData(int ppId, string batchId)
  65. {
  66. List<string> processData = new List<string>();
  67. string sql = string.Format(
  68. "SELECT * FROM \"process_data_linear\" where \"pp_id\" = '{0}' and \"batch_id\" = '{1}' and (\"finish_type\" is null or \"finish_type\" != 'RecipeFinish') order by \"process_begin_time\" ASC;",
  69. ppId.ToString(), batchId);
  70. DataSet dataSet = DB.ExecuteDataset(sql);
  71. if (dataSet == null || dataSet.Tables.Count == 0)
  72. return processData;
  73. DataTable queryDataTable = dataSet.Tables[0];
  74. if (queryDataTable == null || queryDataTable.Rows.Count == 0)
  75. return processData;
  76. try
  77. {
  78. processData.Add(queryDataTable.Rows[queryDataTable.Rows.Count - 1]["guid"].ToString());
  79. processData.Add(queryDataTable.Rows[queryDataTable.Rows.Count - 1]["cassette1_count"].ToString());
  80. processData.Add(queryDataTable.Rows[queryDataTable.Rows.Count - 1]["cassette2_count"].ToString());
  81. processData.Add(queryDataTable.Rows[queryDataTable.Rows.Count - 1]["process_begin_time"].ToString());
  82. }
  83. catch (Exception ex)
  84. {
  85. LOG.Write(ex);
  86. return null;
  87. }
  88. return processData;
  89. }
  90. }
  91. }