| | |
| | | /// </summary> |
| | | [RoutePrefix("ZyPrj")] |
| | | public class ZyPrjController : ApiController |
| | | { |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="request"></param> |
| | | /// <returns></returns> |
| | | [Route("CalcPrj")] |
| | | [Route("Calc")] |
| | | [HttpPost] |
| | | public IStation.Dto.ApiResult CalcPrj([FromBody] ZyPrjRequest request) |
| | | public IStation.Dto.ApiResult Calc([FromBody] ZyPrjRequest request) |
| | | { |
| | | if (request == null ) |
| | | { |
| | |
| | | DateTime end_timme = DateTime.Now; |
| | | if(!DateTime.TryParse(request.StartTime,out start_timme)) |
| | | { |
| | | IStation.LogHelper.Error(string.Format("ZyPrjRequest Time:{0}-{1} StartTime is error format", start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "StartTime is error format" }; |
| | | } |
| | | if (!DateTime.TryParse(request.EndTime, out end_timme)) |
| | | { |
| | | IStation.LogHelper.Error(string.Format("ZyPrjRequest Time:{0}-{1} EndTime is error format", start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "EndTime is error format" }; |
| | | } |
| | | if(end_timme< start_timme.AddMinutes(60)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "时间范围错误" }; |
| | | IStation.LogHelper.Error(string.Format("ZyPrjRequest Time:{0}-{1} 时间范围错误,间隔过短", start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "时间范围错误,间隔过短" }; |
| | | } |
| | | if(request.TotalFlowIn == null) |
| | | if(end_timme > start_timme.AddDays(1)) |
| | | { |
| | | IStation.LogHelper.Error(string.Format("ZyPrjRequest Time:{0}-{1} 时间范围错误,不能超过24小时", start_timme, end_timme)) ; |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "时间范围错误,不能超过24小时" }; |
| | | } |
| | | if (request.TotalFlowIn == null) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "取水总量错误" }; |
| | | } |
| | |
| | | } |
| | | dto_prj.schemeID = defaultPrj.ID; |
| | | dto_prj.Day = defaultPrj.StartTime.ToString("yyyy-MM-dd"); |
| | | dto_prj.StartTime = defaultPrj.StartTime.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | dto_prj.EndTime = defaultPrj.EndTime.ToString("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | dto_prj.FlowTotal = Math.Round(defaultPrj.SumFlow, 0); |
| | | dto_prj.PowerTotal = Math.Round(defaultPrj.SumPower, 0); |
| | | dto_prj.MoneyTotal = Math.Round(defaultPrj.SumMoney, 0); |
| | | |
| | | dto_prj.Items = new List<ZyDto.SubmitPrjItem>(); |
| | | foreach (var bt in defaultPrj.BlockTimes) |
| | | { |
| | |
| | | dto_item.StartTime = bt.StartTime; |
| | | dto_item.EndTime = bt.EndTime; |
| | | dto_item.OpenPumpCount = bt.OpenPumpCount; |
| | | dto_item.OpenPumpIndexs = CalcPrjHelper.GetOpenPumpIndexs(bt.OpenPumpCount); |
| | | dto_prj.Items.Add(dto_item); |
| | | } |
| | | |