using IStation.Common;
|
using IStation.Dto;
|
using System;
|
using System.Collections.Generic;
|
using System.IO;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Security.Permissions;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Web;
|
using System.Web.Http;
|
|
namespace IStation.WebApi.Controllers
|
{
|
/// <summary>
|
/// 水库水位
|
/// </summary>
|
[RoutePrefix("ReservoirWaterLevel")]
|
public class ReservoirWaterLevelController : ApiController
|
{
|
|
/// <summary>
|
/// 获取实时值
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetRealValue")]
|
[HttpGet]
|
public async Task<IStation.Dto.ApiResult> GetRealValue()
|
{
|
var d = await ZyConnectHelper.GetRealReservoirWaterLevel();
|
|
return new IStation.Dto.ApiResult<double>(d);
|
}
|
|
/// <summary>
|
/// 获取今日预测值(24点时)
|
/// </summary>
|
/// <returns></returns>
|
[Route("GetTodayEndPredictiveValue")]
|
[HttpGet]
|
public async Task<IStation.Dto.ApiResult> GetTodayEndPredictiveValue()
|
{
|
var now_value = await ZyConnectHelper.GetRealReservoirWaterLevel();
|
|
var today_prj = Common.HistoryAnaPrjFileHelper.GetPrj(DateTime.Today);
|
|
if(today_prj == null || today_prj.BlockTimes == null || today_prj.PointTimes == null)
|
{
|
return new IStation.Dto.ApiResult<double>(-100);
|
}
|
|
var now = DateTime.Now;
|
double predictiveValue = now_value;
|
|
foreach(var pt in today_prj.PointTimes)
|
{
|
if (now > pt.Time)
|
{
|
predictiveValue = now_value + today_prj.PointTimes.Last().WaterLevelH - pt.WaterLevelH;
|
return new IStation.Dto.ApiResult<double>(predictiveValue);
|
}
|
}
|
|
|
return new IStation.Dto.ApiResult<double>(now_value);
|
}
|
}
|
}
|