| | |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Runtime.CompilerServices; |
| | | using System.Security.Permissions; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using System.Web.UI.WebControls; |
| | | using System.Web.UI.WebControls.WebParts; |
| | | using System.Web.Http; |
| | | |
| | | namespace IStation.ZyDto |
| | | { |
| | | public class ZyPrjRequest |
| | | { |
| | | public ZyPrjRequest() { } |
| | | |
| | | public ZyPrjRequest() |
| | | { } |
| | | |
| | | public string StartTime { get; set; } |
| | | public string EndTime { get; set; } |
| | | public int StartOpenCount { get; set; } = -1; |
| | | public double? TotalFlowIn { get; set; }//取水总量 (单位 吨) |
| | | } |
| | | //public int? StartOpenCount { get; set; } = -1;//已作废 |
| | | |
| | | public string StartReservoirLevel { get; set; }//开始水库水位(可空):单位m |
| | | public List<int> StartOpenPumpIndexArray { get; set; }//开始机泵开机状态 |
| | | |
| | | public string TotalFlowIn { get; set; }//取水总量 (单位 吨) |
| | | |
| | | public string MaxReservoirLevel { get; set; }//最高水库水位限制(可空):单位m |
| | | public string MaxReservoirLevelTime { get; set; }//最高水库水位限制时间(可空) 时间格式 |
| | | |
| | | public string IsSubmit { get; set; }//计算完,是否推送 |
| | | } |
| | | } |
| | | |
| | | namespace IStation.WebApi.Controllers |
| | | { |
| | | /// <summary> |
| | |
| | | public class ZyPrjController : ApiController |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// |
| | | /// </summary> |
| | | /// <param name="request"></param> |
| | | /// <returns></returns> |
| | |
| | | [HttpPost] |
| | | public IStation.Dto.ApiResult Calc([FromBody] ZyPrjRequest request) |
| | | { |
| | | if (request == null ) |
| | | LogHelper.Info(JsonHelper.Object2Json(request)); |
| | | if (request == null) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "request is null" }; |
| | | } |
| | |
| | | |
| | | DateTime start_timme = DateTime.Now; |
| | | DateTime end_timme = DateTime.Now; |
| | | if(!DateTime.TryParse(request.StartTime,out start_timme)) |
| | | 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" }; |
| | |
| | | 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)) |
| | | if (end_timme < start_timme.AddMinutes(60)) |
| | | { |
| | | IStation.LogHelper.Error(string.Format("ZyPrjRequest Time:{0}-{1} 时间范围错误,间隔过短", start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "时间范围错误,间隔过短" }; |
| | | } |
| | | if(end_timme > start_timme.AddDays(1)) |
| | | 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 = "取水总量错误" }; |
| | | } |
| | | if (request.TotalFlowIn < 10000) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "注意取水总量单位是吨,当前参数参数过小" }; |
| | | IStation.LogHelper.Error(string.Format("ZyPrjRequest Time:{0}-{1} 时间范围错误,不能超过24小时", start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "时间范围错误,不能超过24小时" }; |
| | | } |
| | | |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} ,StartOpenCount:{2}, TotalFlowIn:{3}", |
| | | start_timme, end_timme, request.StartOpenCount, request.TotalFlowIn)); |
| | | |
| | | IStation.CalcModel.AnaRequest anaRequest = new AnaRequest(); |
| | | anaRequest.CalcOptType = eCalcOptType.电费; |
| | | IStation.CalcModel.AnaRequest anaRequest = new AnaRequest(); |
| | | anaRequest.CalcOptType = (eCalcOptType)IStation.AnaGlobalParas.Setting.OptSortType; |
| | | anaRequest.StartTime = start_timme; |
| | | anaRequest.EndTime = end_timme; |
| | | anaRequest.WaterLevels长江 = GetTide3Day(start_timme); |
| | | anaRequest.StartOpenCount = request.StartOpenCount; |
| | | anaRequest.TotalFlow取水总量 = request.TotalFlowIn; |
| | | |
| | | var calcHelper = new IStation.CalcPrjHelper(); |
| | | AnaPrj defaultPrj = null; |
| | | string error_info = calcHelper.Calc(anaRequest, out defaultPrj); |
| | | if (!string.IsNullOrEmpty(error_info) || defaultPrj == null) |
| | | |
| | | if (string.IsNullOrEmpty(request.TotalFlowIn)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "计算错误, 原因是:"+ error_info }; |
| | | if (string.IsNullOrEmpty(request.MaxReservoirLevel)) |
| | | { |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 请输入取水总量或水位要求", |
| | | start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "请输入取水总量或水位要求" }; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | double TotalFlowIn = 0; |
| | | if (!double.TryParse(request.TotalFlowIn, out TotalFlowIn)) |
| | | { |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 注意取水总量单位是吨,当前参数参数过小", |
| | | start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "注意取水总量单位是吨,当前参数参数过小" }; |
| | | } |
| | | if (TotalFlowIn < 10000) |
| | | { |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 注意取水总量单位是吨,当前参数参数过小", |
| | | start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "注意取水总量单位是吨,当前参数参数过小" }; |
| | | } |
| | | |
| | | anaRequest.TotalFlowIn = TotalFlowIn; |
| | | } |
| | | if (!string.IsNullOrEmpty(request.MaxReservoirLevel)) |
| | | { |
| | | anaRequest.MaxLimitWaterBoxLevel = Convert.ToDouble(request.MaxReservoirLevel); |
| | | IStation.DAL.WaterPredictRecord dal = new DAL.WaterPredictRecord(); |
| | | var water_records = dal.GetByHourRangle(start_timme, end_timme); |
| | | LogHelper.Info(water_records.Count.ToString()); |
| | | if (water_records == null) |
| | | { |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 水位预测数据为空,请先保持水位预测服务正常运行", |
| | | start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult<string>() { Code = ApiResultCode.Error, Data = "水位预测数据为空,请先保持水位预测服务正常运行" }; |
| | | } |
| | | var count = (end_timme - start_timme).TotalHours; |
| | | if (water_records.Count != count) |
| | | { |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 预测数据获取失败,数据条无法匹配, 检查是否预测服务中断", |
| | | start_timme, end_timme)); |
| | | return new IStation.Dto.ApiResult<string>() { Code = ApiResultCode.Error, Data = "预测数据获取失败,数据条无法匹配, 检查是否预测服务中断" }; |
| | | } |
| | | |
| | | anaRequest.SpaceFlowOut = new List<double>(); |
| | | foreach (var r in water_records) |
| | | { |
| | | if (r.States == 0) |
| | | { |
| | | var error_info11 = string.Format("预测数据异常,无法进行水位计算:{0} {1},{2}", r.DayHour, r.LastPredictValue, r.Description); |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , {2}}", |
| | | start_timme, end_timme, error_info11)); |
| | | return new IStation.Dto.ApiResult<string>() |
| | | { |
| | | Code = ApiResultCode.Error, |
| | | Data = error_info11 |
| | | }; |
| | | } |
| | | anaRequest.SpaceFlowOut.Add(r.LastPredictValue / 10000); |
| | | } |
| | | } |
| | | if (!string.IsNullOrEmpty(request.MaxReservoirLevelTime)) |
| | | anaRequest.MaxLimitWaterBoxTime = request.MaxReservoirLevelTime; |
| | | |
| | | //开始时的开机状态 |
| | | if (request.StartOpenPumpIndexArray == null) |
| | | { |
| | | IStation.LogHelper.Info(" 未设置开始时机泵开停状态 (Error: StartOpenPumpIndexArray is null)"); |
| | | return new IStation.Dto.ApiResult<string>() { Code = ApiResultCode.Error, Data = "未设置开始时机泵开停状态 (Error: StartOpenPumpIndexArray is null)" }; |
| | | } |
| | | anaRequest.IsKnownStartOpenPump = true; |
| | | anaRequest.StartOpenPumpIndexArray = request.StartOpenPumpIndexArray; |
| | | |
| | | |
| | | //陈行水库水位 |
| | | if (string.IsNullOrEmpty(request.StartReservoirLevel)) |
| | | { |
| | | IStation.LogHelper.Info(" 未设置开始时水库水位 (Error: StartReservoirLevel is null)"); |
| | | return new IStation.Dto.ApiResult<string>() { Code = ApiResultCode.Error, Data = "未设置开始时水库水位 (Error: StartReservoirLevel is null) " }; |
| | | } |
| | | anaRequest.CurrentWaterBoxLevel = Convert.ToDouble(request.StartReservoirLevel); |
| | | if (anaRequest.CurrentWaterBoxLevel < 2) |
| | | { |
| | | IStation.LogHelper.Info(string.Format(" 设置开始时水库水位的数据过小 (Error: StartReservoirLevel is {0}})", |
| | | anaRequest.CurrentWaterBoxLevel)); |
| | | return new IStation.Dto.ApiResult<string>() |
| | | { |
| | | Code = ApiResultCode.Error, |
| | | Data = string.Format(" 设置开始时水库水位的数据过小 (Error: StartReservoirLevel is {0}})", |
| | | anaRequest.CurrentWaterBoxLevel) |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | var calcHelper = new IStation.CalcPrjHelper(); |
| | | AnaPrj defaultPrj = null; |
| | | string error_info = calcHelper.Calc(anaRequest, out defaultPrj); |
| | | LogHelper.Info(error_info); |
| | | if (!string.IsNullOrEmpty(error_info) || defaultPrj == null) |
| | | { |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 计算错误, 原因是:{2} ,Request::: ", |
| | | start_timme, end_timme, error_info) + JsonHelper.Object2Json(anaRequest)); |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "计算错误, 原因是:" + error_info }; |
| | | } |
| | | else |
| | | { |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} , 计算成功", start_timme, end_timme)); |
| | | } |
| | | |
| | | //保存方案 |
| | | var ret = Common.HistoryAnaPrjFileHelper.SavePrj(IStation.AnaGlobalParas.Setting, anaRequest, defaultPrj); |
| | | |
| | | var dto_prj = ToPrjDto(defaultPrj); |
| | | |
| | | #region 推送 |
| | | |
| | | if (!string.IsNullOrEmpty(request.IsSubmit) && Convert.ToBoolean(request.IsSubmit)) |
| | | { |
| | | Task.Run(() => |
| | | { |
| | | _ = ZyProjectHelper.SubmitPrj(defaultPrj); |
| | | }); |
| | | } |
| | | |
| | | #endregion 推送 |
| | | |
| | | return new IStation.Dto.ApiResult<IStation.ZyDto.SubmitPrj>(dto_prj) { Code = ApiResultCode.Success }; |
| | | } |
| | | |
| | | #region 换算成DTO |
| | | |
| | | private IStation.ZyDto.SubmitPrj ToPrjDto(AnaPrj defaultPrj) |
| | | { |
| | | IStation.ZyDto.SubmitPrj dto_prj = new ZyDto.SubmitPrj(); |
| | | |
| | | if (string.IsNullOrEmpty(defaultPrj.ID)) |
| | |
| | | dto_prj.Items = new List<ZyDto.SubmitPrjItem>(); |
| | | foreach (var bt in defaultPrj.BlockTimes) |
| | | { |
| | | if (bt.OpenPumpCount == 0) |
| | | if (bt.OpenPumpIndexs == null) |
| | | continue; |
| | | ZyDto.SubmitPrjItem dto_item = new ZyDto.SubmitPrjItem(); |
| | | dto_item.StartTime = bt.StartTime; |
| | | dto_item.EndTime = bt.EndTime; |
| | | dto_item.OpenPumpCount = bt.OpenPumpCount; |
| | | dto_item.OpenPumpIndexs = CalcPrjHelper.GetOpenPumpIndexs(bt.OpenPumpCount); |
| | | dto_item.OpenPumpCount = bt.OpenPumpIndexs.Count; |
| | | dto_item.OpenPumpIndexs = bt.OpenPumpIndexs;// |
| | | |
| | | if (bt.PointTimes != null) |
| | | { |
| | | dto_item.Records = new List<SubmitPrjTime>(); |
| | | foreach (var bt2 in bt.PointTimes) |
| | | { |
| | | dto_item.Records.Add(new SubmitPrjTime(bt2)); |
| | | } |
| | | } |
| | | |
| | | |
| | | dto_prj.Items.Add(dto_item); |
| | | } |
| | | |
| | | //if (request.isSubmit) |
| | | //{ |
| | | // string error = await ZyConnectHelper.SubmitPrj(request.prj);//, (id) => { IStation.LogHelper.Info("SavePrj success id=" + id); }, (info) => { IStation.LogHelper.Info("SavePrj failse info:" + info); });//.Result; |
| | | // if (!string.IsNullOrEmpty(error)) |
| | | // { |
| | | // IStation.LogHelper.Info("Submit prj finish (fail) day:" + request.requestBase.StartTime + ",error:" + error); |
| | | // return new IStation.Dto.ApiResult<string>(error) { Code = ApiResultCode.Error }; |
| | | // } |
| | | // else |
| | | // { |
| | | // IStation.LogHelper.Info("Submit prj finish (success) day:" + request.requestBase.StartTime); |
| | | // } |
| | | //} |
| | | |
| | | |
| | | return new IStation.Dto.ApiResult< IStation.ZyDto.SubmitPrj>(dto_prj) { Code = ApiResultCode.Success }; |
| | | return dto_prj; |
| | | } |
| | | |
| | | #endregion 换算成DTO |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// 获取某一天,最近一条 |
| | | /// </summary> |
| | | /// <param name="day"></param> |
| | | /// <returns></returns> |
| | | [Route("GetHistoryByDay")] |
| | | [HttpGet] |
| | | public IStation.Dto.ApiResult GetHistoryByDay(string day) |
| | | { |
| | | if (string.IsNullOrEmpty(day)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "入参day 为空" }; |
| | | } |
| | | DateTime d; |
| | | if (!DateTime.TryParse(day, out d)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; |
| | | } |
| | | IStation.CalcModel.AnaRequestBase requestBase = null; |
| | | var prj = Common.HistoryAnaPrjFileHelper.GetByDay(d, out requestBase); |
| | | |
| | | if (prj != null) |
| | | { |
| | | var dto_prj = ToPrjDto(prj); |
| | | return new IStation.Dto.ApiResult<IStation.ZyDto.SubmitPrj>(dto_prj) { Code = ApiResultCode.Success }; |
| | | } |
| | | else |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Alert, Message = "未找到项目" }; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取最近一条 |
| | | /// </summary> |
| | | /// <param name="day"></param> |
| | | /// <returns></returns> |
| | | [Route("GetLastHistoryRecord")] |
| | | [HttpGet] |
| | | public IStation.Dto.ApiResult GetLastHistoryRecord() |
| | | { |
| | | var dal = new IStation.DAL.AnaProject(); |
| | | var record = dal.GetLastRecord(); |
| | | if (record == null) |
| | | return null; |
| | | |
| | | IStation.CalcModel.AnaRequestBase requestBase = null; |
| | | var prj = Common.HistoryAnaPrjFileHelper.GetByStartTime(record.StartTime, out requestBase); |
| | | if (prj != null) |
| | | { |
| | | var dto_prj = ToPrjDto(prj); |
| | | return new IStation.Dto.ApiResult<IStation.ZyDto.SubmitPrj>(dto_prj) { Code = ApiResultCode.Success }; |
| | | } |
| | | else |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Alert, Message = "未找到项目" }; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("GetSetting")] |
| | | [HttpGet] |
| | |
| | | IStation.Dto.ZyPrjAnaSetting dto_setting = new ZyPrjAnaSetting(); |
| | | dto_setting.MinOpenTimeMinute = model_setting.MinOpenTimeMinute; |
| | | dto_setting.MinSwitchTimeMinute = model_setting.MinSwitchTimeMinute; |
| | | dto_setting.MaxPumpSwitchCount = model_setting.MaxPumpSwitchCountQ; |
| | | dto_setting.MaxPumpSwitchCount = model_setting.MaxPumpSwitchCount; |
| | | dto_setting.OptSortType = model_setting.OptSortType; |
| | | if(model_setting.SwitchPumpIgnoreTimes != null) |
| | | dto_setting.OpenPumpIndexSequence = model_setting.OpenPumpIndexSequence; |
| | | dto_setting.ClosePumpIndexSequence = model_setting.ClosePumpIndexSequence; |
| | | dto_setting.SwitchPumpMinuteSpace = model_setting.SwitchPumpMinuteSpace; |
| | | dto_setting.OptimalPumpIndexSequence = model_setting.OptimalPumpIndexSequence; |
| | | |
| | | if (model_setting.SwitchPumpIgnoreTimes != null) |
| | | { |
| | | dto_setting.SwitchPumpIgnoreTimes = new List<ZyPrjAnaSetting.TimeRange>(); |
| | | foreach(var m in model_setting.SwitchPumpIgnoreTimes) |
| | | dto_setting.SwitchPumpIgnoreTimes = new List<ZyPrjAnaSetting.TimeRangeZy>(); |
| | | foreach (var m in model_setting.SwitchPumpIgnoreTimes) |
| | | { |
| | | dto_setting.SwitchPumpIgnoreTimes.Add(new ZyPrjAnaSetting.TimeRange() |
| | | dto_setting.SwitchPumpIgnoreTimes.Add(new ZyPrjAnaSetting.TimeRangeZy() |
| | | { |
| | | IsUse = m.IsUse, |
| | | StartHour = m.StartHour, |
| | |
| | | } |
| | | if (model_setting.OpenPumpTimes != null) |
| | | { |
| | | dto_setting.OpenPumpTimes = new List<ZyPrjAnaSetting.TimeRange>(); |
| | | dto_setting.OpenPumpTimes = new List<ZyPrjAnaSetting.TimeRangeZy>(); |
| | | foreach (var m in model_setting.OpenPumpTimes) |
| | | { |
| | | dto_setting.OpenPumpTimes.Add(new ZyPrjAnaSetting.TimeRange() |
| | | dto_setting.OpenPumpTimes.Add(new ZyPrjAnaSetting.TimeRangeZy() |
| | | { |
| | | IsUse = m.IsUse, |
| | | StartHour = m.StartHour, |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | return new IStation.Dto.ApiResult<IStation.Dto.ZyPrjAnaSetting>(dto_setting); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// |
| | | /// </summary> |
| | | /// <param name="ana"></param> |
| | | /// <returns></returns> |
| | |
| | | return new IStation.Dto.ApiResult<bool>(false); |
| | | } |
| | | var model_setting = IStation.AnaGlobalParas.Setting; |
| | | |
| | | IStation.LogHelper.Info("ZyPrj SaveSetting"); |
| | | if (dto.MinOpenTimeMinute < 5) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "最少开泵时间 设置过少" }; |
| | |
| | | } |
| | | model_setting.MinSwitchTimeMinute = dto.MinSwitchTimeMinute; |
| | | |
| | | |
| | | |
| | | if (dto.MaxPumpSwitchCount < 1) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "最大切泵次数 设置过少" }; |
| | |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "最大切泵次数 设置过长" }; |
| | | } |
| | | model_setting.MaxPumpSwitchCountQ = dto.MaxPumpSwitchCount; |
| | | |
| | | |
| | | |
| | | model_setting.MaxPumpSwitchCount = dto.MaxPumpSwitchCount; |
| | | if (dto.OptSortType >= 2) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "OptSortType 只能设置 0 或者 1, 0代表 用电量最少 1代表 电费最少" }; |
| | | } |
| | | model_setting.OptSortType = dto.OptSortType; |
| | | if (dto.SwitchPumpIgnoreTimes != null) |
| | | { |
| | | model_setting.SwitchPumpIgnoreTimes = new List<CalcModel.AnaSetting.TimeRange>(); |
| | | foreach (var m in dto.SwitchPumpIgnoreTimes) |
| | | { |
| | | if (m.StartHour == 0 && m.EndHour == 0 && m.StartMinute == 0 && m.EndMinute == 0) |
| | | continue; |
| | | if (m.StartHour < 0 || m.StartHour > 24) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "不许切泵时间 时间范围设置不合理" }; |
| | |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "不许切泵时间 时间范围设置不合理" }; |
| | | } |
| | | if(m.StartHour > m.EndHour) |
| | | if (m.StartHour > m.EndHour) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "不许切泵时间 时间范围设置不合理" }; |
| | | } |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (dto.OpenPumpTimes != null) |
| | | { |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (dto.OpenPumpIndexSequence != null) |
| | | { |
| | | List<int> penPumpIndexs = new List<int>(); |
| | | foreach (var ind in dto.OpenPumpIndexSequence) |
| | | { |
| | | if (ind < 0 || ind > 5) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "开泵顺序设置参数不合理" }; |
| | | } |
| | | else |
| | | { |
| | | penPumpIndexs.Add(ind); |
| | | } |
| | | } |
| | | if (penPumpIndexs.Distinct().Count() != 5) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "开泵顺序设置参数不合理" }; |
| | | } |
| | | model_setting.OpenPumpIndexSequence = penPumpIndexs.ToArray(); |
| | | } |
| | | |
| | | if (dto.ClosePumpIndexSequence != null) |
| | | { |
| | | List<int> penPumpIndexs = new List<int>(); |
| | | foreach (var ind in dto.ClosePumpIndexSequence) |
| | | { |
| | | if (ind < 0 || ind > 5) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "关泵顺序设置参数不合理" }; |
| | | } |
| | | else |
| | | { |
| | | penPumpIndexs.Add(ind); |
| | | } |
| | | } |
| | | if (penPumpIndexs.Distinct().Count() != 5) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "关泵顺序设置参数不合理" }; |
| | | } |
| | | model_setting.ClosePumpIndexSequence = penPumpIndexs.ToArray(); |
| | | } |
| | | |
| | | if (dto.OptimalPumpIndexSequence != null) |
| | | { |
| | | List<int> penPumpIndexs = new List<int>(); |
| | | foreach (var ind in dto.OptimalPumpIndexSequence) |
| | | { |
| | | if (ind < 0 || ind > 5) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "调度泵优先度顺序设置参数不合理" }; |
| | | } |
| | | else |
| | | { |
| | | penPumpIndexs.Add(ind); |
| | | } |
| | | } |
| | | if (penPumpIndexs.Distinct().Count() != 5) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "调度泵优先度顺序设置参数不合理" }; |
| | | } |
| | | model_setting.OptimalPumpIndexSequence = penPumpIndexs.ToArray(); |
| | | } |
| | | |
| | | return new IStation.Dto.ApiResult<bool>(IStation.Common.AnaSetting.SaveSetting(model_setting)); |
| | | } |
| | | |
| | | private Model.eTideSouce _tideSouce = Model.eTideSouce.Book; |
| | | |
| | | |
| | | |
| | | Model.eTideSouce _tideSouce = Model.eTideSouce.Book; |
| | | private List<Model.TimeWaterLevel> GetTide3Day(DateTime calc_day ) |
| | | private List<Model.TimeWaterLevel> GetTide3Day(DateTime calc_day) |
| | | { |
| | | DateTime _rangDay1, _rangDay2, _rangDay3; |
| | | string error1, error2, error3; |
| | |
| | | _rangDay3 = calc_day.AddDays(1); |
| | | } |
| | | waterLevels长江1 = TideHelper.GetByDay(_tideSouce, _rangDay1, out error1); |
| | | waterLevels长江2 = TideHelper.GetByDay(_tideSouce, _rangDay2, out error2); |
| | | waterLevels长江2 = TideHelper.GetByDay(_tideSouce, _rangDay2, out error2); |
| | | waterLevels长江3 = TideHelper.GetByDay(_tideSouce, _rangDay3, out error3); |
| | | |
| | | |
| | | |
| | | |
| | | List<Model.TimeWaterLevel> timeValues = new List<Model.TimeWaterLevel>(); |
| | | if (waterLevels长江1 != null) |
| | | { |
| | | timeValues.AddRange(waterLevels长江1); |
| | | } |
| | | |
| | | |
| | | if (waterLevels长江2 != null) |
| | | { |
| | | timeValues.AddRange(waterLevels长江2); |
| | | } |
| | | |
| | | |
| | | if (waterLevels长江3 != null) |
| | | { |
| | | timeValues.AddRange(waterLevels长江3); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | return timeValues; |
| | | } |
| | | } |
| | | } |
| | | } |