From 80c7e78e0d52f9005df5e2c1c73a38aec128eb36 Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期日, 07 四月 2024 15:35:35 +0800 Subject: [PATCH] 供水页面及api修改 --- WebApi/Controllers/PumpRunController.cs | 221 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 166 insertions(+), 55 deletions(-) diff --git a/WebApi/Controllers/PumpRunController.cs b/WebApi/Controllers/PumpRunController.cs index c9bee91..ed50783 100644 --- a/WebApi/Controllers/PumpRunController.cs +++ b/WebApi/Controllers/PumpRunController.cs @@ -15,7 +15,7 @@ public class PumpRunController : ApiController { /// <summary> - /// 鑾峰彇鏌愪竴澶╁疄闄呭弬鏁� + /// 鑾峰彇娉靛疄闄呰繍琛屽弬鏁�(涓�澶�) /// </summary> /// <param name="day"></param> /// <returns></returns> @@ -42,63 +42,64 @@ // pumpRunParasDay.TotalWater = totalWater; // PumpTotalElecty = await ZyConnectHelper.GetPumpTotalElectricity(d, d); //鑾峰彇鏌愭鏃堕棿鐨勭敤鐢甸噺 - var debug = Common.PumpRunParasHelper.ReadPumpRunParas(d.AddDays(-15)); - if (debug == null) + 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) + 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) { - item.Electric = Math.Round(item.Electric, 2); - item.Money = Math.Round(item.Money, 2); - item.FlowIn = Math.Round(item.FlowIn, 2); + 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); + } } } - 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<Model.RunParasData>(debug) { Code = ApiResultCode.Success, Message = "Success" }; } /// <summary> - /// 鑾峰彇鍘嗗彶鍙傛暟 + /// 鑾峰彇娉靛巻鍙茶繍琛屽弬鏁� /// </summary> /// <param name="day"></param> /// <returns></returns> @@ -118,8 +119,7 @@ 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); @@ -173,10 +173,14 @@ - + /// <summary> + /// 涓�澶╁唴鐨勬�诲彇姘撮噺鍜岀敤鐢甸噺 + /// </summary> + /// <param name="day"></param> + /// <returns></returns> [Route("GetOneDayData")] [HttpGet] - public async Task<IStation.Dto.ApiResult> GetOneDayData(string day) + public async Task<IStation.Dto.ApiResult> GetOneDayPumpWaterData(string day) { if (day == null) { @@ -187,8 +191,115 @@ { return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 鏍煎紡涓嶆纭�" }; } + var WaterParas = Common.PumpRunParasHelper.ReadPumpWaterParas(d); - return new IStation.Dto.ApiResult<Model.RunParasData>() { Code = ApiResultCode.Success, Message = "Success" }; + return new IStation.Dto.ApiResult<List<Model.PumpWater>>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; + } + + + + /// <summary> + /// 鑾峰彇鏃堕棿娈靛唴鐨勫崟绠¢亾渚涙按鏁版嵁 + /// </summary> + /// <param name="startday"></param> + /// <param name="endday"></param> + /// <param name="sign"></param> + /// <returns></returns> + [Route("GetPumpOutDayWater")] + [HttpGet] + public async Task<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<List<Model.OutList>>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; + } + + + + /// <summary> + /// 鑾峰彇鎵�鏈夌殑鏈堝悎璁℃暟鎹�(鍗曠閬�) + /// </summary> + /// <returns></returns> + [Route("GetPumpOutMonthWater")] + [HttpGet] + public async Task<IStation.Dto.ApiResult> GetPumpOutMonthWater() + { + var WaterParas = Common.PumpRunParasHelper.ReadPumpMonthOutWater(); + return new IStation.Dto.ApiResult<List<Model.PumpOutWater>>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; + } + + + + /// <summary> + /// 鑾峰彇澶╃殑鍚堝苟渚涙按鐬椂鏁版嵁(鎬荤) + /// </summary> + /// <param name="startday"></param> 寮�濮嬫棩鏈� + /// <param name="endday"></param> 缁撴潫鏃ユ湡 + /// <returns></returns> + [Route("GetPumpTotalDayOutWater")] + [HttpGet] + public async Task<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<List<Model.OutTotalOneDayList>>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; + } + + + + /// <summary> + /// 鑾峰彇澶╃殑鍚堝苟渚涙按绱鏁版嵁(鎬荤) + /// </summary> + /// <param name="startday"></param> 寮�濮嬫棩鏈� + /// <param name="endday"></param> 缁撴潫鏃ユ湡 + /// <returns></returns> + [Route("GetPumpTotalDayAccOutWater")] + [HttpGet] + public async Task<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<List<Model.OutTotalOneDayList>>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; } } } -- Gitblit v1.9.3