using IStation.Dto; using IStation.Model; using IStation.ZyModel; using System; using System.Collections.Generic; using System.Security.Policy; using System.Threading.Tasks; using System.Web.Http; namespace IStation.WebApi.Controllers { /// /// 泵运行时间 /// [RoutePrefix("PumpRun")] public class PumpRunController : ApiController { /// /// 获取泵实际运行参数(一天) /// /// /// [Route("GetByOneDay")] [HttpGet] public IStation.Dto.ApiResult GetByOneDay(string startday) { List PumpState = new List(); List TotalWater = new List(); List PumpTotalElecty = new List(); Model.RunParasData runParasData = new Model.RunParasData(); if (startday == null) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; } DateTime d; if (!DateTime.TryParse(startday, out d)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } // PumpState = await ZyConnectHelper.GetPumpOpenStatusBySingleDay(d); //获取泵的开机情况 // totalWater = await ZyConnectHelper.GetTotalWaterByDayRange_In(d, d); // pumpRunParasDay.TotalWater = totalWater; // PumpTotalElecty = await ZyConnectHelper.GetPumpTotalElectricity(d, d); //获取某段时间的用电量 var debug = Common.PumpRunParasHelper.ReadPumpRunParas(d.AddDays(-15)); if (debug != null) { debug.Electric = Math.Round(debug.Electric, 2); debug.Money = Math.Round(debug.Money, 2); debug.FlowIn = Math.Round(debug.FlowIn, 2); if (debug.Pump1.Count != 0) { foreach (var item in debug.Pump1) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } if (debug.Pump2.Count != 0) { foreach (var item in debug.Pump2) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } if (debug.Pump3.Count != 0) { foreach (var item in debug.Pump3) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } if (debug.Pump4.Count != 0) { foreach (var item in debug.Pump4) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } if (debug.Pump5.Count != 0) { foreach (var item in debug.Pump5) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } } else { return null; } return new IStation.Dto.ApiResult(debug) { Code = ApiResultCode.Success, Message = "Success" }; } /// /// 获取泵历史运行参数 /// /// /// [Route("GetByHistoryOneDay")] [HttpGet] public IStation.Dto.ApiResult GetByHistoryOneDay(string day) { if (day == null) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; } DateTime d; if (!DateTime.TryParse(day, out d)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } var history = Common.PumpRunParasHelper.ReadPumpRunParas(d); if (history == null) return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "Data null" }; history.Electric = Math.Round(history.Electric, 2); history.Money = Math.Round(history.Money, 2); history.FlowIn = Math.Round(history.FlowIn, 2); if (history.Pump1.Count != 0) { foreach (var item in history.Pump1) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } if (history.Pump2.Count != 0) { foreach (var item in history.Pump2) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } if (history.Pump3.Count != 0) { foreach (var item in history.Pump3) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } if (history.Pump4.Count != 0) { foreach (var item in history.Pump4) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } if (history.Pump5.Count != 0) { foreach (var item in history.Pump5) { item.Electric = Math.Round(item.Electric, 2); item.Money = Math.Round(item.Money, 2); item.FlowIn = Math.Round(item.FlowIn, 2); } } return new IStation.Dto.ApiResult(history) { Code = ApiResultCode.Success, Message = "Success" }; } /// /// 一天内的总取水量和用电量 /// /// /// [Route("GetOneDayData")] [HttpGet] public IStation.Dto.ApiResult GetOneDayPumpWaterData(string day) { if (day == null) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; } DateTime d; if (!DateTime.TryParse(day, out d)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } var WaterParas = Common.PumpRunParasHelper.ReadPumpWaterParas(d); return new IStation.Dto.ApiResult>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; } /// /// 获取时间段内的单管道供水数据 /// /// /// /// /// [Route("GetPumpOutDayWater")] [HttpGet] public IStation.Dto.ApiResult GetPumpOutWater(string startday,string endday,int sign) { if (startday == null||endday==null) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; } DateTime Start; if (!DateTime.TryParse(startday, out Start)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } DateTime End; if (!DateTime.TryParse(endday, out End)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } var WaterParas = Common.PumpRunParasHelper.ReadPumpOutWater(Start,End, sign); return new IStation.Dto.ApiResult>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; } /// /// 获取所有的月合计数据(单管道) /// /// [Route("GetPumpOutMonthWater")] [HttpGet] public IStation.Dto.ApiResult GetPumpOutMonthWater() { var WaterParas = Common.PumpRunParasHelper.ReadPumpMonthOutWater(); return new IStation.Dto.ApiResult>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; } /// /// 获取天的合并供水瞬时数据(总管) /// /// 开始日期 /// 结束日期 /// [Route("GetPumpTotalDayOutWater")] [HttpGet] public IStation.Dto.ApiResult GetPumpTotalDayOutWater(string startday, string endday) { if (startday == null || endday == null) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; } DateTime Start; if (!DateTime.TryParse(startday, out Start)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } DateTime End; if (!DateTime.TryParse(endday, out End)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } var WaterParas = Common.PumpRunParasHelper.ReadPumpAllDayOutWater(Start,End); return new IStation.Dto.ApiResult>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; } /// /// 获取天的合并供水累计数据(总管) /// /// 开始日期 /// 结束日期 /// [Route("GetPumpTotalDayAccOutWater")] [HttpGet] public IStation.Dto.ApiResult GetPumpTotalDayAccOutWater(string startday, string endday) { if (startday == null || endday == null) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; } DateTime Start; if (!DateTime.TryParse(startday, out Start)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } DateTime End; if (!DateTime.TryParse(endday, out End)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; } var WaterParas = Common.PumpRunParasHelper.ReadPumpAllDayOutAccWater(Start, End); return new IStation.Dto.ApiResult>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; } } }