123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using EntityDataSet;
- using IntelligentControlForsx.Model;
- using IntelligentControlForsx.Common;
- using log4net;
- namespace IntelligentControlForsx.Service
- {
- public class PointService
- {
- private static ILog logger = LogManager.GetLogger("AppInfoLog");
- public static IList<PointMapModel> GetTestingPoints(PointType ptype, string[] uniformcodes)
- {
- IList<PointMapModel> ret = new List<PointMapModel>();
- if (ptype == PointType.Windturbine)
- {
- var lstAI = GetWindTurbineAIPoints(uniformcodes);
- if (lstAI != null && lstAI.Count > 0)
- {
- foreach (var obj in lstAI)
- {
- PointMapModel pmm = new PointMapModel();
- pmm.ThingId = CommonMethod.GetShortWindturbineId( obj.WINDTURBINEID);
- pmm.ThingType = PointType.Windturbine;
- pmm.DataType = PointDataType.AI;
- pmm.UniformCode = obj.UNIFORMCODE;
- pmm.PointId = obj.ID;
- if (!ret.Contains(pmm))
- ret.Add(pmm);
- else
- logger.Info(pmm.PointId);
- }
- }
- var lstDI = GetWindTurbineDIPoints(uniformcodes);
- if (lstDI != null && lstDI.Count > 0)
- {
- foreach (var obj in lstDI)
- {
- PointMapModel pmm = new PointMapModel();
- pmm.ThingId = CommonMethod.GetShortWindturbineId( obj.WINDTURBINEID);
- pmm.ThingType = PointType.Windturbine;
- pmm.DataType = PointDataType.DI;
- pmm.UniformCode = obj.UNIFORMCODE;
- pmm.PointId = obj.ID;
- if (!ret.Contains(pmm))
- ret.Add(pmm);
- else
- logger.Info(pmm.PointId);
- }
- }
- }
- else if (ptype == PointType.Station)
- {
- var lstP = GetStationTestingPoints(uniformcodes);
- if (lstP != null && lstP.Count > 0)
- {
- foreach (var obj in lstP)
- {
- PointMapModel pmm = new PointMapModel();
- pmm.ThingId = obj.WINDPOWERSTATIONID;
- pmm.ThingType = PointType.Station;
- pmm.DataType = PointDataType.AI;
- pmm.UniformCode = obj.UNIFORMCODE;
- pmm.PointId = obj.CODE;
- if (!ret.Contains(pmm))
- ret.Add(pmm);
- }
- }
- }
- else
- {
- }
- return ret;
- }
- public static IList<windturbinetestingpointai> GetWindTurbineAIPoints(string[] filters)
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- return ctx.windturbinetestingpointai
- .Where(q => filters.Contains(q.UNIFORMCODE))
- //.Select(q => q.Id)
- .ToList();
- }
- }
- public static IList<windturbinetestingpointdi> GetWindTurbineDIPoints(string[] filters)
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- return ctx.windturbinetestingpointdi
- .Where(q => filters.Contains(q.UNIFORMCODE))
- //.Select(q => q.Id)
- .ToList();
- }
- }
- public static IList<windturbinetestingpointai> GetWindTurbineAIPoints(string uniformCode)
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- return ctx.windturbinetestingpointai
- .Where(q => q.UNIFORMCODE == uniformCode)
- .ToList();
- }
- }
- public static IList<windpowerstationtestingpoint> GetStationTestingPointsByUniformCode(string uniformcode)
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- return ctx.windpowerstationtestingpoint.Where(a => a.UNIFORMCODE == uniformcode && a.WINDPOWERSTATIONID.EndsWith("_FDC")).ToList();
- }
- }
- public static string GetStationTestingPointByUniformCode(string stationId, string uniformcode)
- {
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- return ctx.windpowerstationtestingpoint.Where(a => a.UNIFORMCODE == uniformcode && a.WINDPOWERSTATIONID == stationId).ToList().First().CODE;
- }
- }
- public static IList<windpowerstationtestingpoint> GetStationTestingPoints(string[] uniformcodes)
- {
- if (uniformcodes == null)
- return null;
- if (uniformcodes.Length == 1)
- return GetStationTestingPointsByUniformCode(uniformcodes[0]);
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- //return ctx.windpowerstationtestingpoint.Where(a => uniformcodes.Contains(a.UNIFORMCODE) && a.WINDPOWERSTATIONID.EndsWith("_FDC")).ToList();
- return ctx.windpowerstationtestingpoint.Where(a => uniformcodes.Contains(a.UNIFORMCODE)).ToList();
- }
- }
- }
- }
|