| | |
| | | using IStation.CalcModel; |
| | | using Antlr.Runtime.Tree; |
| | | using IStation.CalcModel; |
| | | using IStation.Common; |
| | | using IStation.Dto; |
| | | using IStation.Model; |
| | |
| | | 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; |
| | |
| | | { |
| | | 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 TotalFlowIn { get; set; }//取水总量 (单位 吨) |
| | | public string StartReservoirLevel { get; set; }//开始水库水位(可空):单位m |
| | | public string MaxReservoirLevel { get; set; }//最高水库水位限制(可空):单位m |
| | | public string MaxReservoirLevelTime { get; set; }//最高水库水位限制时间(可空) 时间格式 |
| | | |
| | | public string IsSubmit { get; set; }//计算完,是否推送 |
| | | } |
| | | } |
| | | |
| | | namespace IStation.WebApi.Controllers |
| | | { |
| | | /// <summary> |
| | |
| | | /// </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 ) |
| | | 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" }; |
| | | } |
| | | 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)) |
| | | 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)) |
| | | { |
| | | 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小时" }; |
| | | } |
| | | if (request.TotalFlowIn < 10000) |
| | | if (request.TotalFlowIn == null) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "注意取水总量单位是吨,当前参数参数过小" }; |
| | | if (string.IsNullOrEmpty(request.MaxReservoirLevel )) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "请输入取水总量或水位要求" }; |
| | | } |
| | | } |
| | | |
| | | IStation.CalcModel.AnaRequest anaRequest = new AnaRequest(); |
| | | anaRequest.CalcOptType = eCalcOptType.电费; |
| | | |
| | | |
| | | |
| | | IStation.LogHelper.Info(string.Format("Zy Prj Time:{0}-{1} ,StartOpenCount:{2} ", |
| | | start_timme, end_timme, request.StartOpenCount )); |
| | | |
| | | 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 }; |
| | | double TotalFlowIn = 0; |
| | | if(!double.TryParse( request.TotalFlowIn,out TotalFlowIn)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "注意取水总量单位是吨,当前参数参数过小" }; |
| | | } |
| | | if (TotalFlowIn < 10000) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "注意取水总量单位是吨,当前参数参数过小" }; |
| | | } |
| | | |
| | | anaRequest.TotalFlowIn = TotalFlowIn; |
| | | } |
| | | |
| | | |
| | | if (request.StartOpenCount == null) |
| | | { |
| | | anaRequest.StartOpenCount = -1; |
| | | } |
| | | else |
| | | { |
| | | anaRequest.StartOpenCount = request.StartOpenCount.Value; |
| | | } |
| | | |
| | | #region 陈行水库水位 |
| | | |
| | | if (!string.IsNullOrEmpty(request.StartReservoirLevel)) |
| | | { |
| | | anaRequest.CurrentWaterBoxLevel = Convert.ToDouble(request.StartReservoirLevel); |
| | | } |
| | | else |
| | | { |
| | | /* var tagDict = new Dictionary<string, string> { { "_0402010201030103006", "陈行水库水位" } }; |
| | | var input = new { search = "real", tablename = "陈行智能调度" }; |
| | | var tags = tagDict.Keys.ToList(); |
| | | var realScadaRecordList = ZyConnectHelper.GetRealScadaResultAsync(tags, input).GetAwaiter().GetResult(); |
| | | if (realScadaRecordList != null && realScadaRecordList.Count() > 0) |
| | | { |
| | | anaRequest.CurrentWaterBoxLevel = realScadaRecordList.Last().Value; |
| | | }*/ |
| | | anaRequest.CurrentWaterBoxLevel = ZyConnectHelper.GetRealReservoirWaterLevel(); |
| | | } |
| | | |
| | | #endregion 陈行水库水位 |
| | | |
| | | if (!string.IsNullOrEmpty(request.MaxReservoirLevel)) |
| | | anaRequest.MaxLimitWaterBoxLevel = Convert.ToDouble(request.MaxReservoirLevel); |
| | | if (!string.IsNullOrEmpty(request.MaxReservoirLevelTime)) |
| | | anaRequest.MaxLimitWaterBoxTime = request.MaxReservoirLevelTime; |
| | | |
| | | var calcHelper = new IStation.CalcPrjHelper(); |
| | | AnaPrj defaultPrj = null; |
| | | string error_info = calcHelper.Calc(anaRequest, out defaultPrj); |
| | | if (!string.IsNullOrEmpty(error_info) || defaultPrj == null) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "计算错误, 原因是:" + error_info }; |
| | | } |
| | | |
| | | //保存方案 |
| | | 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.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 = IStation.AnaGlobalParas.Setting.GetOpenPumpIndexArrays(bt.OpenPumpCount); |
| | | 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 }; |
| | | if (defaultPrj.PointTimes != null) |
| | | { |
| | | dto_prj.Records = new List<SubmitPrjTime>(); |
| | | foreach (var bt in defaultPrj.PointTimes) |
| | | { |
| | | dto_prj.Records.Add(new SubmitPrjTime(bt)); |
| | | } |
| | | } |
| | | return dto_prj; |
| | | } |
| | | |
| | | Model.eTideSouce _tideSouce = Model.eTideSouce.Book; |
| | | private List<Model.TimeWaterLevel> GetTide3Day(DateTime calc_day ) |
| | | #endregion 换算成DTO |
| | | |
| | | /// <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] |
| | | public IStation.Dto.ApiResult GetSetting() |
| | | { |
| | | var model_setting = IStation.AnaGlobalParas.Setting; |
| | | 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.OptSortType = model_setting.OptSortType; |
| | | dto_setting.OpenPumpIndexs = model_setting.OpenPumpIndexs; |
| | | |
| | | if (model_setting.SwitchPumpIgnoreTimes != null) |
| | | { |
| | | dto_setting.SwitchPumpIgnoreTimes = new List<ZyPrjAnaSetting.TimeRangeZy>(); |
| | | foreach (var m in model_setting.SwitchPumpIgnoreTimes) |
| | | { |
| | | dto_setting.SwitchPumpIgnoreTimes.Add(new ZyPrjAnaSetting.TimeRangeZy() |
| | | { |
| | | IsUse = m.IsUse, |
| | | StartHour = m.StartHour, |
| | | StartMinute = m.StartMinute, |
| | | EndHour = m.EndHour, |
| | | EndMinute = m.EndMinute, |
| | | }); |
| | | } |
| | | } |
| | | if (model_setting.OpenPumpTimes != null) |
| | | { |
| | | dto_setting.OpenPumpTimes = new List<ZyPrjAnaSetting.TimeRangeZy>(); |
| | | foreach (var m in model_setting.OpenPumpTimes) |
| | | { |
| | | dto_setting.OpenPumpTimes.Add(new ZyPrjAnaSetting.TimeRangeZy() |
| | | { |
| | | IsUse = m.IsUse, |
| | | StartHour = m.StartHour, |
| | | StartMinute = m.StartMinute, |
| | | EndHour = m.EndHour, |
| | | EndMinute = m.EndMinute, |
| | | }); |
| | | } |
| | | } |
| | | |
| | | return new IStation.Dto.ApiResult<IStation.Dto.ZyPrjAnaSetting>(dto_setting); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="ana"></param> |
| | | /// <returns></returns> |
| | | [Route("SaveSetting")] |
| | | [HttpPost] |
| | | public IStation.Dto.ApiResult SaveSetting([FromBody] IStation.Dto.ZyPrjAnaSetting dto) |
| | | { |
| | | if (dto == null) |
| | | { |
| | | 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 = "最少开泵时间 设置过少" }; |
| | | } |
| | | if (dto.MinOpenTimeMinute > 120) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "最少开泵时间 设置过长" }; |
| | | } |
| | | model_setting.MinOpenTimeMinute = dto.MinOpenTimeMinute; |
| | | |
| | | if (dto.MinSwitchTimeMinute < 5) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "最少切泵时间 设置过少" }; |
| | | } |
| | | if (dto.MinSwitchTimeMinute > 120) |
| | | { |
| | | 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 = "最大切泵次数 设置过少" }; |
| | | } |
| | | if (dto.MaxPumpSwitchCount > 10) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "最大切泵次数 设置过长" }; |
| | | } |
| | | model_setting.MaxPumpSwitchCountQ = dto.MaxPumpSwitchCount; |
| | | |
| | | 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 = "不许切泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.EndHour < 0 || m.EndHour > 24) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "不许切泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.StartMinute < 0 || m.StartMinute > 60) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "不许切泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.EndMinute < 0 || m.EndMinute > 60) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "不许切泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.StartHour > m.EndHour) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "不许切泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.StartHour == m.EndHour) |
| | | { |
| | | if (m.StartMinute > m.EndMinute) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "不许切泵时间 时间范围设置不合理" }; |
| | | } |
| | | } |
| | | model_setting.SwitchPumpIgnoreTimes.Add(new CalcModel.AnaSetting.TimeRange() |
| | | { |
| | | IsUse = m.IsUse, |
| | | StartHour = m.StartHour, |
| | | StartMinute = m.StartMinute, |
| | | EndHour = m.EndHour, |
| | | EndMinute = m.EndMinute, |
| | | }); |
| | | } |
| | | } |
| | | |
| | | if (dto.OpenPumpTimes != null) |
| | | { |
| | | model_setting.OpenPumpTimes = new List<CalcModel.AnaSetting.TimeRange>(); |
| | | foreach (var m in dto.OpenPumpTimes) |
| | | { |
| | | if (m.StartHour < 0 || m.StartHour > 24) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "开泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.EndHour < 0 || m.EndHour > 24) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "开泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.StartMinute < 0 || m.StartMinute > 60) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "开泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.EndMinute < 0 || m.EndMinute > 60) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "开泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.StartHour > m.EndHour) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "开泵时间 时间范围设置不合理" }; |
| | | } |
| | | if (m.StartHour == m.EndHour) |
| | | { |
| | | if (m.StartMinute > m.EndMinute) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "开泵时间 时间范围设置不合理" }; |
| | | } |
| | | } |
| | | model_setting.OpenPumpTimes.Add(new CalcModel.AnaSetting.TimeRange() |
| | | { |
| | | IsUse = m.IsUse, |
| | | StartHour = m.StartHour, |
| | | StartMinute = m.StartMinute, |
| | | EndHour = m.EndHour, |
| | | EndMinute = m.EndMinute, |
| | | }); |
| | | } |
| | | } |
| | | |
| | | if (dto.OpenPumpIndexs != null) |
| | | { |
| | | List<int> penPumpIndexs = new List<int>(); |
| | | foreach (var ind in dto.OpenPumpIndexs) |
| | | { |
| | | 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.OpenPumpIndexs = penPumpIndexs.ToArray(); |
| | | } |
| | | return new IStation.Dto.ApiResult<bool>(IStation.Common.AnaSetting.SaveSetting(model_setting)); |
| | | } |
| | | |
| | | private Model.eTideSouce _tideSouce = Model.eTideSouce.Book; |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | } |