From 6c93aedfeeb66023f9506083517aee1a4e18e24d Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期四, 28 三月 2024 19:46:12 +0800 Subject: [PATCH] 修改历史方案界面 --- WebApi/Controllers/PumpRunController.cs | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 153 insertions(+), 27 deletions(-) diff --git a/WebApi/Controllers/PumpRunController.cs b/WebApi/Controllers/PumpRunController.cs index 10b4b6f..c9bee91 100644 --- a/WebApi/Controllers/PumpRunController.cs +++ b/WebApi/Controllers/PumpRunController.cs @@ -1,10 +1,11 @@ 锘縰sing 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; -using static IStation.Common.PumpHistoryDataFileHelper; - namespace IStation.WebApi.Controllers { /// <summary> @@ -13,56 +14,181 @@ [RoutePrefix("PumpRun")] public class PumpRunController : ApiController { - - Dto.PumpRunParasDays pumpRunParasDay = new Dto.PumpRunParasDays(); - /// <summary> - /// 鑾峰彇鏌愪竴澶╁弬鏁� + /// <summary> + /// 鑾峰彇鏌愪竴澶╁疄闄呭弬鏁� /// </summary> /// <param name="day"></param> /// <returns></returns> [Route("GetByOneDay")] [HttpGet] - public async Task<IStation.Dto.ApiResult> GetByOneDay(DateTime startday) + public async Task<IStation.Dto.ApiResult> GetByOneDay(string startday) { - - var PumpState = await ZyConnectHelper.GetPumpIsopen(startday,startday); - // var totalWater = await ZyConnectHelper.GetTotalWaterByDayRange_In(startday, startday); - // pumpRunParasDay.TotalWater = totalWater; - // var PumpTotalElecty = await ZyConnectHelper.GetPumpTotalElectricity(startday, startday); - // pumpRunParasDay.Totalelectricity = PumpTotalElecty; - pumpRunParasDay.PumpRunTotalTime1 = PumpState[0]; - pumpRunParasDay.PumpRunTotalTime2 = PumpState[0]; - pumpRunParasDay.PumpRunTotalTime3 = PumpState[0]; - pumpRunParasDay.PumpRunTotalTime4 = PumpState[0]; - pumpRunParasDay.PumpRunTotalTime5 = PumpState[0]; + List<RealScadaData> PumpState = new List<RealScadaData>(); + List<RealScadaData> TotalWater = new List<RealScadaData>(); + List<RealScadaData> PumpTotalElecty = new List<RealScadaData>(); - return new IStation.Dto.ApiResult<Dto.PumpRunParasDays>(pumpRunParasDay) { Code = ApiResultCode.Success, Message = "Success" }; + 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); + } + } + return new IStation.Dto.ApiResult<Model.RunParasData>(debug) { Code = ApiResultCode.Success, Message = "Success" }; } - + /// <summary> + /// 鑾峰彇鍘嗗彶鍙傛暟 + /// </summary> + /// <param name="day"></param> + /// <returns></returns> [Route("GetByHistoryOneDay")] [HttpGet] - public async Task<IStation.Dto.ApiResult> GetByHistoryOneDay(DateTime day) + public async Task<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)) + if (!DateTime.TryParse(day, out d)) { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 鏍煎紡涓嶆纭�" }; - }*/ + } - var prj = Common.PumpHistoryDataFileHelper.GetHistoryData(day); - return new IStation.Dto.ApiResult<List<Common.PumpHistoryDataFileHelper.RunParasData>>(prj) { Code = ApiResultCode.Success, Message = "Success" }; + var history = Common.PumpRunParasHelper.ReadPumpRunParas(d); + if (history == 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<Model.RunParasData>(history) { Code = ApiResultCode.Success, Message = "Success" }; } + [Route("GetOneDayData")] + [HttpGet] + public async Task<IStation.Dto.ApiResult> GetOneDayData(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 鏍煎紡涓嶆纭�" }; + } - - + return new IStation.Dto.ApiResult<Model.RunParasData>() { Code = ApiResultCode.Success, Message = "Success" }; + } } } -- Gitblit v1.9.3