| | |
| | | using IStation.Dto; |
| | | using IStation.Common; |
| | | using IStation.Dto; |
| | | using IStation.Model; |
| | | using IStation.ZyModel; |
| | | using System; |
| | |
| | | [RoutePrefix("PumpRun")] |
| | | public class PumpRunController : ApiController |
| | | { |
| | | bool isdebug = true; |
| | | /// <summary> |
| | | /// 获取泵实际运行参数(一天) |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | [Route("GetByOneDay")] |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetByOneDay(string startday) |
| | | public async Task< IStation.Dto.ApiResult> GetByOneDay(string startday) |
| | | { |
| | | List<RealScadaData> PumpState = new List<RealScadaData>(); |
| | | List<RealScadaData> TotalWater = new List<RealScadaData>(); |
| | | List<RealScadaData> PumpTotalElecty = new List<RealScadaData>(); |
| | | |
| | | Model.RunParasData runParasData = new Model.RunParasData(); |
| | | if (startday == null) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; |
| | |
| | | { |
| | | 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) |
| | | if (d > DateTime.Now.AddDays(1)) |
| | | { |
| | | 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) |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "天数不正确" }; |
| | | } |
| | | RunParasData result = null; |
| | | PumpRunParasHelper pumpRunParasHelper = new PumpRunParasHelper(); |
| | | result = Common.PumpRunParasHelper.ReadPumpRunParas(d); |
| | | if (result != null&& isdebug) |
| | | { |
| | | result.Electric = Math.Round(result.Electric, 2); |
| | | result.Money = Math.Round(result.Money, 2); |
| | | result.FlowIn = Math.Round(result.FlowIn, 2); |
| | | if (result.Pump1.Count != 0) |
| | | { |
| | | foreach (var item in debug.Pump1) |
| | | foreach (var item in result.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) |
| | | if (result.Pump2.Count != 0) |
| | | { |
| | | foreach (var item in debug.Pump2) |
| | | foreach (var item in result.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) |
| | | if (result.Pump3.Count != 0) |
| | | { |
| | | foreach (var item in debug.Pump3) |
| | | foreach (var item in result.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) |
| | | if (result.Pump4.Count != 0) |
| | | { |
| | | foreach (var item in debug.Pump4) |
| | | foreach (var item in result.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) |
| | | if (result.Pump5.Count != 0) |
| | | { |
| | | foreach (var item in debug.Pump5) |
| | | foreach (var item in result.Pump5) |
| | | { |
| | | item.Electric = Math.Round(item.Electric, 2); |
| | | item.Money = Math.Round(item.Money, 2); |
| | |
| | | } |
| | | } |
| | | } |
| | | else { return null; } |
| | | return new IStation.Dto.ApiResult<Model.RunParasData>(debug) { Code = ApiResultCode.Success, Message = "Success" }; |
| | | else |
| | | { |
| | | var PumpTotalElecty = await ZyConnectHelper.GetPumpTotalElectricity(d, d); //获取某段时间的用电量 |
| | | var PumpState = await ZyConnectHelper.GetPumpOpenStatusBySingleDay(d); //获取泵的开机情况 |
| | | var TotalWater = await ZyConnectHelper.GetTotalWaterByDayTimeRange_In(d, d); //取水量 |
| | | |
| | | /* PumpHistoryDataFileHelper pumpHistoryDataFileHelper=new PumpHistoryDataFileHelper(); |
| | | var TotalWater = pumpHistoryDataFileHelper.GetAllWaterData(); |
| | | var PumpState = pumpHistoryDataFileHelper.getpumpstate(); |
| | | var PumpTotalElecty = pumpHistoryDataFileHelper.GetAllEleData();*/ |
| | | result = pumpRunParasHelper.GetRunParasDatas(PumpState, TotalWater, PumpTotalElecty, d); |
| | | } |
| | | if (result != null) |
| | | { |
| | | pumpRunParasHelper.Save(result, out string error); |
| | | // LogHelper.Info(error); |
| | | } |
| | | return new IStation.Dto.ApiResult<Model.RunParasData>(result) { Code = ApiResultCode.Success, Message = "Success" }; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | [Route("GetByHistoryOneDay")] |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetByHistoryOneDay(string day) |
| | | public IStation.Dto.ApiResult GetByHistoryOneDay(string day) |
| | | { |
| | | if (day == null) |
| | | { |
| | |
| | | /// <returns></returns> |
| | | [Route("GetOneDayData")] |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetOneDayPumpWaterData(string day) |
| | | public IStation.Dto.ApiResult GetOneDayPumpWaterData(string day) |
| | | { |
| | | if (day == null) |
| | | { |
| | |
| | | /// <returns></returns> |
| | | [Route("GetPumpOutDayWater")] |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetPumpOutWater(string startday,string endday,int sign) |
| | | public IStation.Dto.ApiResult GetPumpOutWater(string startday,string endday,int sign) |
| | | { |
| | | if (startday == null||endday==null) |
| | | { |
| | |
| | | /// <returns></returns> |
| | | [Route("GetPumpOutMonthWater")] |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetPumpOutMonthWater() |
| | | public IStation.Dto.ApiResult GetPumpOutMonthWater() |
| | | { |
| | | var WaterParas = Common.PumpRunParasHelper.ReadPumpMonthOutWater(); |
| | | return new IStation.Dto.ApiResult<List<Model.PumpOutWater>>(WaterParas) { Code = ApiResultCode.Success, Message = "Success" }; |
| | |
| | | /// <returns></returns> |
| | | [Route("GetPumpTotalDayOutWater")] |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetPumpTotalDayOutWater(string startday, string endday) |
| | | public IStation.Dto.ApiResult GetPumpTotalDayOutWater(string startday, string endday) |
| | | { |
| | | if (startday == null || endday == null) |
| | | { |
| | |
| | | /// <returns></returns> |
| | | [Route("GetPumpTotalDayAccOutWater")] |
| | | [HttpGet] |
| | | public async Task<IStation.Dto.ApiResult> GetPumpTotalDayAccOutWater(string startday, string endday) |
| | | public IStation.Dto.ApiResult GetPumpTotalDayAccOutWater(string startday, string endday) |
| | | { |
| | | if (startday == null || endday == null) |
| | | { |