MetalUsageRecorder.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DBCore;
  3. using DocumentFormat.OpenXml.EMMA;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.SubstrateTrackings;
  6. using MECF.Framework.Common.WaferHolder;
  7. using CyberX8_Core;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using MECF.Framework.Common.ProcessCell;
  15. namespace MECF.Framework.Common.DBCore
  16. {
  17. public class MetalUsageRecorder
  18. {
  19. /// <summary>
  20. /// 加载Metal使用量集合
  21. /// </summary>
  22. /// <returns></returns>
  23. public static List<MetalUsage> GetAllMetalUsages()
  24. {
  25. List<MetalUsage> result = new List<MetalUsage>();
  26. string sql = $"SELECT * FROM metal_usage";
  27. DataSet ds = DB.ExecuteDataset(sql);
  28. if (ds == null)
  29. return result;
  30. if (ds.Tables.Count == 0)
  31. return result;
  32. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  33. {
  34. MetalUsage data = new MetalUsage();
  35. data.MetalName = ds.Tables[0].Rows[i]["metal_name"].ToString();
  36. data.TotalUsage = double.Parse(ds.Tables[0].Rows[i]["total_usage"].ToString());
  37. data.AnodeAUsage = double.Parse(ds.Tables[0].Rows[i]["anode_a_usage"].ToString());
  38. data.AnodeBUsage = double.Parse(ds.Tables[0].Rows[i]["anode_b_usage"].ToString());
  39. data.MembranceAUsage = double.Parse(ds.Tables[0].Rows[i]["membrance_a_usage"].ToString());
  40. data.MembranceBUsage = double.Parse(ds.Tables[0].Rows[i]["membrance_b_usage"].ToString());
  41. data.TotalWafers = int.Parse(ds.Tables[0].Rows[i]["total_wafers"].ToString());
  42. data.AnodeAWafers = int.Parse(ds.Tables[0].Rows[i]["anode_a_wafers"].ToString());
  43. data.AnodeBWafers = int.Parse(ds.Tables[0].Rows[i]["anode_b_wafers"].ToString());
  44. data.AnodeABathUsage = int.Parse(ds.Tables[0].Rows[i]["anode_a_bath_usage"].ToString());
  45. data.AnodeBBathUsage = int.Parse(ds.Tables[0].Rows[i]["anode_b_bath_usage"].ToString());
  46. data.BathResetTime = DateTime.Parse(ds.Tables[0].Rows[i]["bath_reset_time"].ToString());
  47. result.Add(data);
  48. }
  49. ds.Clear();
  50. return result;
  51. }
  52. /// <summary>
  53. /// 新增
  54. /// </summary>
  55. /// <param name="metalName"></param>
  56. /// <param name="info"></param>
  57. /// <returns></returns>
  58. public static int AddMetalUsage(MetalUsage info)
  59. {
  60. string sql = string.Format(@"Insert into metal_usage(metal_name, total_usage,anode_a_usage,anode_b_usage,membrance_a_usage,
  61. membrance_b_usage,total_wafers,anode_a_wafers,anode_b_wafers,anode_a_bath_usage,anode_b_bath_usage,bath_reset_time,create_time, update_time)
  62. Values('{0}',{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},'{11}','{12}','{13}');",
  63. info.MetalName, info.TotalUsage, info.AnodeAUsage, info.AnodeBUsage, info.MembranceAUsage, info.MembranceBUsage,
  64. info.TotalWafers, info.AnodeAWafers, info.AnodeBWafers, info.AnodeABathUsage, info.AnodeBBathUsage, info.BathResetTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
  65. return DB.SyncInsert(sql);
  66. }
  67. /// <summary>
  68. /// 更新
  69. /// </summary>
  70. /// <param name="waferHolderId"></param>
  71. /// <param name="info"></param>
  72. /// <returns></returns>
  73. public static void UpdateMetalUsageData(string metalName, MetalUsage info)
  74. {
  75. string sql = string.Format(@"update metal_usage set total_usage={0},anode_a_usage={1},anode_b_usage={2},
  76. membrance_a_usage={3},membrance_b_usage={4},total_wafers={5},anode_a_wafers={6},
  77. anode_b_wafers={7},anode_a_bath_usage={8},anode_b_bath_usage={9},bath_reset_time='{10}',update_time='{11}' where metal_name='{12}';",
  78. info.TotalUsage, info.AnodeAUsage, info.AnodeBUsage, info.MembranceAUsage, info.MembranceBUsage,
  79. info.TotalWafers, info.AnodeAWafers, info.AnodeBWafers, info.AnodeABathUsage, info.AnodeBBathUsage, info.BathResetTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  80. DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), metalName);
  81. DB.Update(sql);
  82. }
  83. /// <summary>
  84. /// 更新
  85. /// </summary>
  86. /// <param name="metalName"></param>
  87. /// <param name="info"></param>
  88. /// <returns></returns>
  89. public static int SyncUpdateMetalUsageData(string metalName, MetalUsage info)
  90. {
  91. string sql = string.Format(@"update metal_usage set total_usage={0},anode_a_usage={1},anode_b_usage={2},
  92. membrance_a_usage={3},membrance_b_usage={4},total_wafers={5},anode_a_wafers={6},
  93. anode_b_wafers={7},anode_a_bath_usage={8},anode_b_bath_usage={9},bath_reset_time='{10}',update_time='{11}' where metal_name='{12}';",
  94. info.TotalUsage, info.AnodeAUsage, info.AnodeBWafers, info.MembranceAUsage, info.MembranceBUsage,
  95. info.TotalWafers, info.AnodeAWafers, info.AnodeBWafers, info.AnodeABathUsage, info.AnodeBBathUsage, info.BathResetTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  96. DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), metalName);
  97. return DB.SyncUpdate(sql);
  98. }
  99. }
  100. }