| | |
| | | using IStation.Common; |
| | | using IStation.Dto; |
| | | using IStation.ZyDto; |
| | | using Microsoft.Ajax.Utilities; |
| | | using IStation.Untity; |
| | | using IStation.ZyModel; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using System.Web.UI.WebControls; |
| | | using static IStation.ZyConnectHelper; |
| | | using System.Web.Http; |
| | | |
| | | namespace IStation.WebApi.Controllers |
| | | { |
| | |
| | | public class TotalWaterInController : ApiController |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// |
| | | /// </summary> |
| | | /// <param name="day"></param> |
| | | /// <returns></returns> |
| | | [Route("Test1")] |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> Test1() |
| | | { |
| | | { |
| | | var sum = await ZyConnectHelper.async_debug(); |
| | | return new IStation.Dto.ApiResult<double>(sum); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// |
| | | /// </summary> |
| | | /// <param name="day"></param> |
| | | /// <returns></returns> |
| | | [Route("Test2")] |
| | | [HttpGet] |
| | | public IStation.Dto.ApiResult Test2() |
| | | public IStation.Dto.ApiResult Test2() |
| | | { |
| | | var sum = ZyConnectHelper.async_debug().GetAwaiter().GetResult() ; |
| | | var sum = ZyConnectHelper.async_debug().GetAwaiter().GetResult(); |
| | | return new IStation.Dto.ApiResult<double>(sum); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// |
| | | /// </summary> |
| | | /// <param name="day"></param> |
| | | /// <returns></returns> |
| | |
| | | [HttpGet] |
| | | public IStation.Dto.ApiResult GetByDayDebug(string day) |
| | | { |
| | | if (ZyConnectHelper.isDebug) |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "Debug is Unacess " }; |
| | | if (day == null) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; |
| | |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetByDay(string day) |
| | | { |
| | | if (ZyConnectHelper.isDebug) |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "Debug is Unacess " }; |
| | | if (day == null) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; |
| | |
| | | { |
| | | var tagDict = new Dictionary<string, string> |
| | | { |
| | | { "_0402010204012103002", "二取水1号泵累计流量" }, |
| | | { "_0402010204012203002", "二取水2号泵累计流量" }, |
| | | { "_0402010204012303002", "二取水3号泵累计流量" }, |
| | | { "_0402010204012403002", "二取水4号泵累计流量" }, |
| | | { "_0402010204012503002", "二取水5号泵累计流量" }, |
| | | { "1#", "二取水1号主水泵.累计流量" }, |
| | | { "2#", "二取水2号主水泵.累计流量" }, |
| | | { "3#", "二取水3号主水泵.累计流量" }, |
| | | { "4#", "二取水4号主水泵.累计流量" }, |
| | | { "5#", "二取水5号主水泵.累计流量" }, |
| | | }; |
| | | var input = new ScadaDispatchInput |
| | | { |
| | | search = "history", |
| | | starttime = new DateTime(dayD.Year, dayD.Month, dayD.Day, 0, 0, 0).ToString("G"), |
| | | endtime = new DateTime(dayD.Year, dayD.Month, dayD.Day, 23, 59, 59).ToString("G"), |
| | | Resolution = "300", |
| | | taglist = tagDict.Select(x => x.Key).ToArray() |
| | | }; |
| | | var starttime = new DateTime(dayD.Year, dayD.Month, dayD.Day, 0, 0, 0).ToString("G"); |
| | | var endtime = new DateTime(dayD.Year, dayD.Month, dayD.Day, 23, 59, 59).ToString("G"); |
| | | if (dayD == DateTime.Today) |
| | | { |
| | | input.endtime = DateTime.Now.AddMinutes(-5).ToString("G"); |
| | | endtime = DateTime.Now.AddMinutes(-5).ToString("G"); |
| | | } |
| | | |
| | | sum = 0; |
| | | var realScadaDataList = await GetRealScadaResult(input); |
| | | string joinedValues = string.Join(",", tagDict.Values); |
| | | var result = HttpClientHelper.Get<List<DataPoint>>(ZyConnectHelper.ZyApiUrl, starttime, endtime, "first", "300s", joinedValues); |
| | | var realScadaDataList = ZyConnectHelper.GetScadaData(result); |
| | | if (realScadaDataList != null && realScadaDataList.Any()) |
| | | { |
| | | foreach (var r in realScadaDataList) |
| | |
| | | return new IStation.Dto.ApiResult<double>(sum / 10000); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取最近三天的取水总量 |
| | | /// </summary> |
| | |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetLastDay3() |
| | | { |
| | | if (ZyConnectHelper.isDebug) |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "Debug is Unacess " }; |
| | | DateTime yest1 = DateTime.Today.AddDays(-1); |
| | | var sum1 = TotalWaterInHelper.Read(yest1); |
| | | if (sum1 < 0) |
| | | { |
| | | sum1 = await ZyConnectHelper.GetTotalWaterByDay_In(yest1);//.GetAwaiter().GetResult(); |
| | | |
| | | sum1 = await ZyConnectHelper.GetTotalWaterByDay_In(yest1);//.GetAwaiter().GetResult(); |
| | | TotalWaterInHelper.Save(yest1, sum1); |
| | | } |
| | | |
| | |
| | | var sum2 = TotalWaterInHelper.Read(yest2); |
| | | if (sum2 < 0) |
| | | { |
| | | sum2 = await ZyConnectHelper.GetTotalWaterByDay_In(yest2) ;//.GetAwaiter().GetResult(); |
| | | |
| | | sum2 = await ZyConnectHelper.GetTotalWaterByDay_In(yest2);//.GetAwaiter().GetResult(); |
| | | TotalWaterInHelper.Save(yest2, sum2); |
| | | } |
| | | |
| | |
| | | |
| | | return new IStation.Dto.ApiResult<List<double>>(new List<double> { sum1 / 10000, sum2 / 10000, sum3 / 10000 }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取web客户端ip |
| | |
| | | return userIP; |
| | | } |
| | | |
| | | |
| | | |
| | | private string _url = "ws://192.168.201.17:40001"; |
| | | |
| | | private async Task<List<ZyModel.RealScadaData>> Get(string inputJson) |
| | | { |
| | | if (string.IsNullOrEmpty(inputJson)) |
| | |
| | | { |
| | | IStation.LogHelper.Info("ws.SendAsync"); |
| | | List<byte> outputBytes = new List<byte>();//全部消息容器 |
| | | var buffer = new byte[1024 * 4];//缓冲区 |
| | | var buffer = new byte[1024 * 4];//缓冲区 |
| | | var result = ws.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None).Result; //监听Socket信息 |
| | | while (!result.CloseStatus.HasValue) //是否关闭 |
| | | { |
| | |
| | | } |
| | | return realScadaDataList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | } |