namespace IStation.Application
|
{
|
/// <summary>
|
/// 输水调度配置
|
/// </summary>
|
[AllowAnonymous]
|
[Route("Standard/Dispatch/Config")]
|
[ApiDescriptionSettings("Schedule", Name = "调度配置", Order = 1)]
|
public class ScheduleConfig_Std_Controller : IDynamicApiController, ITransient
|
{
|
private readonly Service.ScheduleConfig _service_schedule_config = new();
|
|
|
/// <summary>
|
/// 统计
|
/// </summary>
|
[Route("Statistics")]
|
[HttpGet]
|
[NonUnify]
|
public SaveChScheduleConfigOutput Statistics()
|
{
|
var id = Yw.YitIdHelper.NextId();
|
var log_title = "调度配置";
|
ScheduleLog.Info(id, log_title, "统计!");
|
try
|
{
|
var schedule_config = _service_schedule_config.Get();
|
if (schedule_config == null)
|
{
|
ScheduleLog.Info(id, log_title, "统计失败:ScheduleConfig文件缺失!");
|
return new SaveChScheduleConfigOutput() { Result = false, Msg = "ScheduleConfig文件缺失!" };
|
}
|
|
var msg = GlobalHelper.GetFlagCumulativeRuntimeDict(DateTime.Now,out Dictionary<int, double> station1_flag_cumulative_run_time_dict, out Dictionary<int, double> station2_flag_cumulative_run_time_dict, 35);
|
if (!string.IsNullOrEmpty(msg))
|
{
|
ScheduleLog.Info(id, log_title, $"统计失败:{msg}");
|
return new SaveChScheduleConfigOutput() { Result = false, Msg = $"统计失败:{msg}" };
|
}
|
|
schedule_config.Station1.FlagCumulativeRuntimeDict = station1_flag_cumulative_run_time_dict;
|
schedule_config.Station2.FlagCumulativeRuntimeDict = station2_flag_cumulative_run_time_dict;
|
var bol = _service_schedule_config.Save(schedule_config);
|
if (!bol)
|
{
|
ScheduleLog.Info(id, log_title, $"统计失败:Save()");
|
return new SaveChScheduleConfigOutput() { Result = false, Msg = "统计失败:Save()" };
|
}
|
|
ScheduleLog.Info(id, log_title, $"统计成功!");
|
ScheduleLog.Debug(id, log_title, JsonHelper.Object2Json(schedule_config));
|
|
}
|
catch (Exception ex)
|
{
|
ScheduleLog.Error(id, log_title, "统计失败!", ex);
|
return new SaveChScheduleConfigOutput() { Result = false, Msg = ex.Message };
|
}
|
|
return new SaveChScheduleConfigOutput() { Result = true, Msg = "统计成功!" };
|
}
|
|
|
|
|
}
|
}
|