Shuxia Ning
2024-12-27 f94a4ed8e9f5400e73bad84be023096585cb0498
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 = "统计成功!" };
        }
 
 
 
 
    }
}