PointService.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using EntityDataSet;
  7. using IntelligentControlForsx.Model;
  8. using IntelligentControlForsx.Common;
  9. using log4net;
  10. namespace IntelligentControlForsx.Service
  11. {
  12. public class PointService
  13. {
  14. private static ILog logger = LogManager.GetLogger("AppInfoLog");
  15. public static IList<PointMapModel> GetTestingPoints(PointType ptype, string[] uniformcodes)
  16. {
  17. IList<PointMapModel> ret = new List<PointMapModel>();
  18. if (ptype == PointType.Windturbine)
  19. {
  20. var lstAI = GetWindTurbineAIPoints(uniformcodes);
  21. if (lstAI != null && lstAI.Count > 0)
  22. {
  23. foreach (var obj in lstAI)
  24. {
  25. PointMapModel pmm = new PointMapModel();
  26. pmm.ThingId = CommonMethod.GetShortWindturbineId( obj.WINDTURBINEID);
  27. pmm.ThingType = PointType.Windturbine;
  28. pmm.DataType = PointDataType.AI;
  29. pmm.UniformCode = obj.UNIFORMCODE;
  30. pmm.PointId = obj.ID;
  31. if (!ret.Contains(pmm))
  32. ret.Add(pmm);
  33. else
  34. logger.Info(pmm.PointId);
  35. }
  36. }
  37. var lstDI = GetWindTurbineDIPoints(uniformcodes);
  38. if (lstDI != null && lstDI.Count > 0)
  39. {
  40. foreach (var obj in lstDI)
  41. {
  42. PointMapModel pmm = new PointMapModel();
  43. pmm.ThingId = CommonMethod.GetShortWindturbineId( obj.WINDTURBINEID);
  44. pmm.ThingType = PointType.Windturbine;
  45. pmm.DataType = PointDataType.DI;
  46. pmm.UniformCode = obj.UNIFORMCODE;
  47. pmm.PointId = obj.ID;
  48. if (!ret.Contains(pmm))
  49. ret.Add(pmm);
  50. else
  51. logger.Info(pmm.PointId);
  52. }
  53. }
  54. }
  55. else if (ptype == PointType.Station)
  56. {
  57. var lstP = GetStationTestingPoints(uniformcodes);
  58. if (lstP != null && lstP.Count > 0)
  59. {
  60. foreach (var obj in lstP)
  61. {
  62. PointMapModel pmm = new PointMapModel();
  63. pmm.ThingId = obj.WINDPOWERSTATIONID;
  64. pmm.ThingType = PointType.Station;
  65. pmm.DataType = PointDataType.AI;
  66. pmm.UniformCode = obj.UNIFORMCODE;
  67. pmm.PointId = obj.CODE;
  68. if (!ret.Contains(pmm))
  69. ret.Add(pmm);
  70. }
  71. }
  72. }
  73. else
  74. {
  75. }
  76. return ret;
  77. }
  78. public static IList<windturbinetestingpointai> GetWindTurbineAIPoints(string[] filters)
  79. {
  80. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  81. {
  82. return ctx.windturbinetestingpointai
  83. .Where(q => filters.Contains(q.UNIFORMCODE))
  84. //.Select(q => q.Id)
  85. .ToList();
  86. }
  87. }
  88. public static IList<windturbinetestingpointdi> GetWindTurbineDIPoints(string[] filters)
  89. {
  90. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  91. {
  92. return ctx.windturbinetestingpointdi
  93. .Where(q => filters.Contains(q.UNIFORMCODE))
  94. //.Select(q => q.Id)
  95. .ToList();
  96. }
  97. }
  98. public static IList<windturbinetestingpointai> GetWindTurbineAIPoints(string uniformCode)
  99. {
  100. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  101. {
  102. return ctx.windturbinetestingpointai
  103. .Where(q => q.UNIFORMCODE == uniformCode)
  104. .ToList();
  105. }
  106. }
  107. public static IList<windpowerstationtestingpoint> GetStationTestingPointsByUniformCode(string uniformcode)
  108. {
  109. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  110. {
  111. return ctx.windpowerstationtestingpoint.Where(a => a.UNIFORMCODE == uniformcode && a.WINDPOWERSTATIONID.EndsWith("_FDC")).ToList();
  112. }
  113. }
  114. public static string GetStationTestingPointByUniformCode(string stationId, string uniformcode)
  115. {
  116. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  117. {
  118. return ctx.windpowerstationtestingpoint.Where(a => a.UNIFORMCODE == uniformcode && a.WINDPOWERSTATIONID == stationId).ToList().First().CODE;
  119. }
  120. }
  121. public static IList<windpowerstationtestingpoint> GetStationTestingPoints(string[] uniformcodes)
  122. {
  123. if (uniformcodes == null)
  124. return null;
  125. if (uniformcodes.Length == 1)
  126. return GetStationTestingPointsByUniformCode(uniformcodes[0]);
  127. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  128. {
  129. //return ctx.windpowerstationtestingpoint.Where(a => uniformcodes.Contains(a.UNIFORMCODE) && a.WINDPOWERSTATIONID.EndsWith("_FDC")).ToList();
  130. return ctx.windpowerstationtestingpoint.Where(a => uniformcodes.Contains(a.UNIFORMCODE)).ToList();
  131. }
  132. }
  133. }
  134. }