lixiaojun
2022-08-12 424d2d20a24b76850b73fae8ecc9bc98505be4f5
新增重新分析 实时、时、日、月、年等常规分析测点接口
已修改13个文件
已添加16个文件
8676 ■■■■■ 文件已修改
Application/IStation.Application4Core/exception/ErrorCodes.cs 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/IStation.Application4Run.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_day_record/mgr/MonitorGeneralDayRecord_MgrController.cs 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_day_record/mgr/dto/AnalyAgainMonitorGeneralDayRecordOfDayRangeInput.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_day_record/mgr/dto/AnalyAgainMonitorGeneralDayRecordOfDayRangeResultDto.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_hour_record/mgr/MonitorGeneralHourRecord_MgrController.cs 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_hour_record/mgr/dto/AnalyAgainMonitorGeneralHourRecordOfDayRangeInput.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_hour_record/mgr/dto/AnalyAgainMonitorGeneralHourRecordOfDayRangeResultDto.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_month_record/mgr/MonitorGeneralMonthRecord_MgrController.cs 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_month_record/mgr/dto/AnalyAgainMonitorGeneralMonthRecordOfMonthRangeInput.cs 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_month_record/mgr/dto/AnalyAgainMonitorGeneralMonthRecordOfMonthRangeResultDto.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_real_record/mgr/MonitorGeneralRealRecord_MgrController.cs 173 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_real_record/mgr/dto/AnalyAgainMonitorGeneralRealRecordOfDayInput.cs 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_real_record/mgr/dto/AnalyAgainMonitorGeneralRealRecordOfDayResultDto.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_year_record/mgr/MonitorGeneralYearRecord_MgrController.cs 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_year_record/mgr/dto/AnalyAgainMonitorGeneralYearRecordOfYearRangeInput.cs 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Run/monitor_general_year_record/mgr/dto/AnalyAgainMonitorGeneralYearRecordOfYearRangeResultDto.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Calculation/IStation.Calculation4Analy/MonitorFormulaCalcuHelper.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Calculation/IStation.Calculation4Analy/MonitorFormulaHistoryCalcuHelper.cs 7275 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/IStation.Core/MonitorRecord.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DAL/IStation.DAL4Run/monitor_record/hour/MonitorHourRecord.cs 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.WebApi.sln 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Model/IStation.Model4Monitor/FormulaParas/NumberAccumulateCalculationFormulaParas.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Server/IStation.Server.Analy/general/real/single/GeneralRealAnalyCronJob.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Service/IStation.Service4Run/monitor_record/day/MonitorDayRecord.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Service/IStation.Service4Run/monitor_record/hour/MonitorHourRecord.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Service/IStation.Service4Run/monitor_record/month/MonitorMonthRecord.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Service/IStation.Service4Run/monitor_record/real/MonitorRealRecord.cs 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Service/IStation.Service4Run/monitor_record/year/MonitorYearRecord.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application4Core/exception/ErrorCodes.cs
@@ -23,8 +23,20 @@
        /// <summary>
        /// å­—符串不能为空
        /// </summary>
        [ErrorCodeItemMetadata("{0} å­—符串不能为空")]
        S001,
        [ErrorCodeItemMetadata("{0} ä¸èƒ½ä¸ºç©º")]
        S001,
        /// <summary>
        /// æ•°æ®ä¸å­˜åœ¨
        /// </summary>
        [ErrorCodeItemMetadata("{0} æ•°æ®ä¸å­˜åœ¨")]
        D001,
        /// <summary>
        /// æ•°æ®æ ¼å¼é”™è¯¯
        /// </summary>
        [ErrorCodeItemMetadata("{0} æ•°æ®æ ¼å¼é”™è¯¯ï¼Œä¿¡æ¯ï¼š{1}")]
        D002,
    }
}
Application/IStation.Application4Run/IStation.Application4Run.csproj
@@ -10,6 +10,7 @@
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\Calculation\IStation.Calculation4Analy\IStation.Calculation4Analy.csproj" />
    <ProjectReference Include="..\..\Calculation\IStation.Calculation4Handle\IStation.Calculation4Handle.csproj" />
    <ProjectReference Include="..\..\Service\IStation.Service4Main\IStation.Service4Main.csproj" />
    <ProjectReference Include="..\..\Service\IStation.Service4Monitor\IStation.Service4Monitor.csproj" />
Application/IStation.Application4Run/monitor_general_day_record/mgr/MonitorGeneralDayRecord_MgrController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,139 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using IStation.Calculation;
using IStation.Model;
using Microsoft.AspNetCore.Authorization;
using Furion.FriendlyException;
namespace IStation.Application
{
    /// <summary>
    /// MonitorGeneralDayRecord
    /// </summary>
    [Route("Run/MonitorGeneralDayRecord/Mgr")]
    [ApiDescriptionSettings("Run", Name = "监测常规日记录(管理)", Order = 930)]
    public class MonitorGeneralDayRecord_MgrController : IDynamicApiController
    {
        /// <summary>
        /// é‡æ–°åˆ†æžæŸä¸ªæ—¥æœŸåŒºé—´ï¼ˆä»…针对一个常规日分析测点的分析,会删除已有记录)
        /// </summary>
        [Route("AnalyAgainOfDayRange@V1.0")]
        [HttpPost]
        public AnalyAgainMonitorGeneralDayRecordOfDayRangeResultDto AnalyAgainOfDayRange([Required] AnalyAgainMonitorGeneralDayRecordOfDayRangeInput input)
        {
            var corpId = input.CorpID;
            var monitorId = input.MonitorPointID;
            var startDay = input.StartDay.Date;
            var endDay = input.EndDay.Date;
            var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, monitorId);
            if (monitor == null)
            {
                throw Oops.Oh(ErrorCodes.D001, $"测点:{monitorId}");
            }
            if (monitor.CronType != Model.Monitor.eCronType.EachDay)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是日测点");
            }
            if (monitor.SourceType != Model.Monitor.eSourceType.Analyse)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是分析测点");
            }
            if (string.IsNullOrEmpty(monitor.SourceParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置分析参数");
            }
            var analyModel = Model.Monitor.AnalyseParameters.ToModel(monitor.SourceParas);
            if (analyModel == null)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "分析参数配置错误");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaType))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式类型");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式参数");
            }
            var getMonitorPoint = new Func<long, Model.MonitorPoint_Signal_SignalType>(x => {
                return new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, x);
            });
            var getLastRecord = new Func<long, long, Model.MonitorBasicRecord>((x, y) => {
                return new Service.MonitorDayRecord().GetBySignalIDOfDay(corpId, x, y, startDay.AddDays(-1));
            });
            var getRecordList = new Func<long, long,Model.Monitor.eCronType, DateTime,DateTime, List<Model.MonitorBasicRecord>>((x, y,cy, st,et) => {
                switch (cy)
                {
                    case Model.Monitor.eCronType.Real:
                        {
                            return new Service.MonitorRealRecord()
                                            .GetBySignalIDOfTimeRange(corpId,x,y,st,et)?.Select(x=>x as Model.MonitorBasicRecord).ToList();
                        }
                    case Model.Monitor.eCronType.EachHour:
                        {
                            return new Service.MonitorHourRecord().GetBySignalIDOfHourRange
                                            (monitor.CorpID, x, y, st.Date, st.Hour + 1, et.AddHours(-1).Date, et.AddHours(-1).Hour + 1)?.Select(x=>x as Model.MonitorBasicRecord).ToList();
                        }
                    default:return default;
                }
            });
            List<Model.MonitorDayRecordPure> recordList = null;
            string msg = string.Empty;
            switch (analyModel.FormulaType)
            {
                case Model.Monitor.FormulaType.Statistics_Max://最大值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalDayMaxValue
                            (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Min://最小值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalDayMinValue
                            (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Avg://平均值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalDayAvgValue
                            (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Diff://差值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalDayDiffValue
                              (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Sum://和值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalDaySumValue
                               (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                default: msg = $"不支持的公式类型:{analyModel.FormulaType}"; break;
            }
            if (recordList == null || recordList.Count < 1)
            {
                return new AnalyAgainMonitorGeneralDayRecordOfDayRangeResultDto(false, msg);
            }
            var bol = new Service.MonitorDayRecord().InsertsAgain(recordList);
            return new AnalyAgainMonitorGeneralDayRecordOfDayRangeResultDto(bol, msg);
        }
    }
}
Application/IStation.Application4Run/monitor_general_day_record/mgr/dto/AnalyAgainMonitorGeneralDayRecordOfDayRangeInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    /// é‡æ–°åˆ†æžæ—¥æœŸåŒºé—´å†…的常规监测日记录Input
    /// </summary>
    public class AnalyAgainMonitorGeneralDayRecordOfDayRangeInput : IValidatableObject
    {
        /// <summary>
        /// å®¢æˆ·id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID å¿…须大于0")]
        public long CorpID { get; set; }
        /// <summary>
        /// å¸¸è§„实时测点id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID å¿…须大于0")]
        public long MonitorPointID { get; set; }
        /// <summary>
        /// å¼€å§‹æ—¥æœŸ
        /// </summary>
        public DateTime StartDay { get; set; }
        /// <summary>
        /// ç»“束日期
        /// </summary>
        public DateTime EndDay { get; set; }
        /// <summary>
        ///
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if(StartDay.Date>EndDay.Date)
            {
                yield return new ValidationResult(
                        "日期参数错误"
                        , new[] { nameof(StartDay) }
                    );
            }
        }
    }
}
Application/IStation.Application4Run/monitor_general_day_record/mgr/dto/AnalyAgainMonitorGeneralDayRecordOfDayRangeResultDto.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    ///
    /// </summary>
    public class AnalyAgainMonitorGeneralDayRecordOfDayRangeResultDto
    {
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralDayRecordOfDayRangeResultDto() { }
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralDayRecordOfDayRangeResultDto(bool succeed,string msg)
        {
            this.Succeed = succeed;
            this.Message = msg;
        }
        /// <summary>
        /// æ˜¯å¦æˆåŠŸ
        /// </summary>
        public bool Succeed { get; set; }
        /// <summary>
        /// ä¿¡æ¯
        /// </summary>
        public string Message { get; set; }
    }
}
Application/IStation.Application4Run/monitor_general_hour_record/mgr/MonitorGeneralHourRecord_MgrController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,123 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using IStation.Calculation;
using IStation.Model;
using Microsoft.AspNetCore.Authorization;
using Furion.FriendlyException;
namespace IStation.Application
{
    /// <summary>
    /// MonitorGeneralHourRecord
    /// </summary>
    [Route("Run/MonitorGeneralHourRecord/Mgr")]
    [ApiDescriptionSettings("Run", Name = "监测常规时记录(管理)", Order = 930)]
    public class MonitorGeneralHourRecord_MgrController : IDynamicApiController
    {
        /// <summary>
        /// é‡æ–°åˆ†æžæŸä¸ªæ—¥æœŸåŒºé—´ï¼ˆä»…针对一个常规时分析测点的分析,会删除已有记录)
        /// </summary>
        [Route("AnalyAgainOfDayRange@V1.0")]
        [HttpPost]
        public AnalyAgainMonitorGeneralHourRecordOfDayRangeResultDto AnalyAgainOfDayRange([Required] AnalyAgainMonitorGeneralHourRecordOfDayRangeInput input)
        {
            var corpId = input.CorpID;
            var monitorId = input.MonitorPointID;
            var startDay = input.StartDay.Date;
            var endDay = input.EndDay.Date;
            var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, monitorId);
            if (monitor == null)
            {
                throw Oops.Oh(ErrorCodes.D001, $"测点:{monitorId}");
            }
            if (monitor.CronType != Model.Monitor.eCronType.EachHour)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是时测点");
            }
            if (monitor.SourceType != Model.Monitor.eSourceType.Analyse)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是分析测点");
            }
            if (string.IsNullOrEmpty(monitor.SourceParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置分析参数");
            }
            var analyModel = Model.Monitor.AnalyseParameters.ToModel(monitor.SourceParas);
            if (analyModel == null)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "分析参数配置错误");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaType))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式类型");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式参数");
            }
            var getMonitorPoint = new Func<long, Model.MonitorPoint_Signal_SignalType>(x => {
                return new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, x);
            });
            var getLastRecord = new Func<long, long, Model.MonitorBasicRecord>((x, y) => {
                return new Service.MonitorHourRecord().GetBySignalIDOfHour(corpId, x, y, startDay.AddDays(-1),24);
            });
            var getRecordList = new Func<long, long,DateTime,DateTime, List<Model.MonitorBasicRecord>>((x, y,st,et) => {
                return new Service.MonitorRealRecord().GetBySignalIDOfTimeRange(corpId, x, y,st,et )?.Select(t => t as Model.MonitorBasicRecord).ToList();
            });
            List<Model.MonitorHourRecordPure> recordList = null;
            string msg = string.Empty;
            switch (analyModel.FormulaType)
            {
                case Model.Monitor.FormulaType.Statistics_Max://最大值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalHourMaxValue
                            (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Min://最小值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalHourMinValue
                            (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Avg://平均值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalHourAvgValue
                            (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Diff://差值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalHourDiffValue
                              (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Sum://和值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalHourSumValue
                               (startDay, endDay, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                default: msg = $"不支持的公式类型:{analyModel.FormulaType}"; break;
            }
            if (recordList == null || recordList.Count < 1)
            {
                return new AnalyAgainMonitorGeneralHourRecordOfDayRangeResultDto(false, msg);
            }
            var bol = new Service.MonitorHourRecord().InsertsAgain(recordList);
            return new AnalyAgainMonitorGeneralHourRecordOfDayRangeResultDto(bol, msg);
        }
    }
}
Application/IStation.Application4Run/monitor_general_hour_record/mgr/dto/AnalyAgainMonitorGeneralHourRecordOfDayRangeInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    /// é‡æ–°åˆ†æžæ—¥æœŸåŒºé—´å†…的常规监测时记录Input
    /// </summary>
    public class AnalyAgainMonitorGeneralHourRecordOfDayRangeInput : IValidatableObject
    {
        /// <summary>
        /// å®¢æˆ·id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID å¿…须大于0")]
        public long CorpID { get; set; }
        /// <summary>
        /// å¸¸è§„实时测点id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID å¿…须大于0")]
        public long MonitorPointID { get; set; }
        /// <summary>
        /// å¼€å§‹æ—¥æœŸ
        /// </summary>
        public DateTime StartDay { get; set; }
        /// <summary>
        /// ç»“束日期
        /// </summary>
        public DateTime EndDay { get; set; }
        /// <summary>
        ///
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if(StartDay.Date>EndDay.Date)
            {
                yield return new ValidationResult(
                        "日期参数错误"
                        , new[] { nameof(StartDay) }
                    );
            }
        }
    }
}
Application/IStation.Application4Run/monitor_general_hour_record/mgr/dto/AnalyAgainMonitorGeneralHourRecordOfDayRangeResultDto.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    ///
    /// </summary>
    public class AnalyAgainMonitorGeneralHourRecordOfDayRangeResultDto
    {
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralHourRecordOfDayRangeResultDto() { }
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralHourRecordOfDayRangeResultDto(bool succeed,string msg)
        {
            this.Succeed = succeed;
            this.Message = msg;
        }
        /// <summary>
        /// æ˜¯å¦æˆåŠŸ
        /// </summary>
        public bool Succeed { get; set; }
        /// <summary>
        /// ä¿¡æ¯
        /// </summary>
        public string Message { get; set; }
    }
}
Application/IStation.Application4Run/monitor_general_month_record/mgr/MonitorGeneralMonthRecord_MgrController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,143 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using IStation.Calculation;
using IStation.Model;
using Microsoft.AspNetCore.Authorization;
using Furion.FriendlyException;
namespace IStation.Application
{
    /// <summary>
    /// MonitorGeneralMonthRecord
    /// </summary>
    [Route("Run/MonitorGeneralMonthRecord/Mgr")]
    [ApiDescriptionSettings("Run", Name = "监测常规月记录(管理)", Order = 930)]
    public class MonitorGeneralMonthRecord_MgrController : IDynamicApiController
    {
        /// <summary>
        /// é‡æ–°åˆ†æžæŸä¸ªæœˆä»½åŒºé—´ï¼ˆä»…针对一个常规月分析测点的分析,会删除已有记录)
        /// </summary>
        [Route("AnalyAgainOfMonthRange@V1.0")]
        [HttpPost]
        public AnalyAgainMonitorGeneralMonthRecordOfMonthRangeResultDto AnalyAgainOfMonthRange
            ([Required] AnalyAgainMonitorGeneralMonthRecordOfMonthRangeInput input)
        {
            var corpId = input.CorpID;
            var monitorId = input.MonitorPointID;
            var startYear=input.StartYear;
            var endYear=input.EndYear;
            var startMonth=input.StartMonth;
            var endMonth=input.EndMonth;
            var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, monitorId);
            if (monitor == null)
            {
                throw Oops.Oh(ErrorCodes.D001, $"测点:{monitorId}");
            }
            if (monitor.CronType != Model.Monitor.eCronType.EachMonth)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是月测点");
            }
            if (monitor.SourceType != Model.Monitor.eSourceType.Analyse)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是分析测点");
            }
            if (string.IsNullOrEmpty(monitor.SourceParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置分析参数");
            }
            var analyModel = Model.Monitor.AnalyseParameters.ToModel(monitor.SourceParas);
            if (analyModel == null)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "分析参数配置错误");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaType))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式类型");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式参数");
            }
            var getMonitorPoint = new Func<long, Model.MonitorPoint_Signal_SignalType>(x => {
                return new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, x);
            });
            var getLastRecord = new Func<long, long, Model.MonitorBasicRecord>((x, y) => {
                var dtLast = new DateTime(startYear, startMonth, 1);
                dtLast = dtLast.AddMonths(-1);
                return new Service.MonitorMonthRecord().GetBySignalIDOfMonth(corpId, x, y, dtLast.Year,dtLast.Month);
            });
            var getRecordList = new Func<long, long,Model.Monitor.eCronType, DateTime,DateTime, List<Model.MonitorBasicRecord>>((x, y,cy, st,et) => {
                switch (cy)
                {
                    case Model.Monitor.eCronType.Real:
                        {
                            return new Service.MonitorRealRecord()
                                            .GetFixedBySignalIDOfTimeRange(corpId,x,y,10000,st,et)?.Select(x=>x as Model.MonitorBasicRecord).ToList();
                        }
                    case Model.Monitor.eCronType.EachDay:
                        {
                            return new Service.MonitorDayRecord().GetBySignalIDOfDayRange
                                            (monitor.CorpID, x, y,st.Date,et.Date.AddDays(-1))?.Select(x=>x as Model.MonitorBasicRecord).ToList();
                        }
                    default:return default;
                }
            });
            List<Model.MonitorMonthRecordPure> recordList = null;
            string msg = string.Empty;
            switch (analyModel.FormulaType)
            {
                case Model.Monitor.FormulaType.Statistics_Max://最大值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalMonthMaxValue
                            (startYear,startMonth,endYear,endMonth, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Min://最小值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalMonthMinValue
                            (startYear, startMonth, endYear, endMonth, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Avg://平均值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalMonthAvgValue
                            (startYear, startMonth, endYear, endMonth, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Diff://差值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalMonthDiffValue
                              (startYear, startMonth, endYear, endMonth, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Sum://和值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalMonthSumValue
                               (startYear, startMonth, endYear, endMonth, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                default: msg = $"不支持的公式类型:{analyModel.FormulaType}"; break;
            }
            if (recordList == null || recordList.Count < 1)
            {
                return new AnalyAgainMonitorGeneralMonthRecordOfMonthRangeResultDto(false, msg);
            }
            var bol = new Service.MonitorMonthRecord().InsertsAgain(recordList);
            return new AnalyAgainMonitorGeneralMonthRecordOfMonthRangeResultDto(bol, msg);
        }
    }
}
Application/IStation.Application4Run/monitor_general_month_record/mgr/dto/AnalyAgainMonitorGeneralMonthRecordOfMonthRangeInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    /// é‡æ–°åˆ†æžæœˆåŒºé—´å†…的常规监测月记录Input
    /// </summary>
    public class AnalyAgainMonitorGeneralMonthRecordOfMonthRangeInput : IValidatableObject
    {
        /// <summary>
        /// å®¢æˆ·id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID å¿…须大于0")]
        public long CorpID { get; set; }
        /// <summary>
        /// å¸¸è§„实时测点id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID å¿…须大于0")]
        public long MonitorPointID { get; set; }
        /// <summary>
        /// å¼€å§‹å¹´ä»½
        /// </summary>
        public int StartYear { get; set; }
        /// <summary>
        /// å¼€å§‹æœˆä»½
        /// </summary>
        public int StartMonth { get; set; }
        /// <summary>
        /// ç»“束月份
        /// </summary>
        public int EndYear { get; set; }
        /// <summary>
        /// ç»“束月份
        /// </summary>
        public int EndMonth { get; set; }
        /// <summary>
        ///
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            var startDay = new DateTime(StartYear,StartMonth,1);
            var endDay = new DateTime(EndYear,EndMonth,1);
            if(startDay>endDay)
            {
                yield return new ValidationResult(
                        "月份区间参数错误"
                        , new[] { nameof(StartYear) }
                    );
            }
        }
    }
}
Application/IStation.Application4Run/monitor_general_month_record/mgr/dto/AnalyAgainMonitorGeneralMonthRecordOfMonthRangeResultDto.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    ///
    /// </summary>
    public class AnalyAgainMonitorGeneralMonthRecordOfMonthRangeResultDto
    {
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralMonthRecordOfMonthRangeResultDto() { }
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralMonthRecordOfMonthRangeResultDto(bool succeed,string msg)
        {
            this.Succeed = succeed;
            this.Message = msg;
        }
        /// <summary>
        /// æ˜¯å¦æˆåŠŸ
        /// </summary>
        public bool Succeed { get; set; }
        /// <summary>
        /// ä¿¡æ¯
        /// </summary>
        public string Message { get; set; }
    }
}
Application/IStation.Application4Run/monitor_general_real_record/mgr/MonitorGeneralRealRecord_MgrController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,173 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using IStation.Calculation;
using IStation.Model;
using Microsoft.AspNetCore.Authorization;
using Furion.FriendlyException;
namespace IStation.Application
{
    /// <summary>
    /// MonitorGeneralRealRecord
    /// </summary>
    [Route("Run/MonitorGeneralRealRecord/Mgr")]
    [ApiDescriptionSettings("Run", Name = "监测常规实时记录(管理)", Order = 930)]
    public class MonitorGeneralRealRecord_MgrController : IDynamicApiController
    {
        /// <summary>
        /// é‡æ–°åˆ†æžæŸå¤©ï¼ˆä»…针对一个常规实时分析测点一天的分析,会删除已有记录)
        /// </summary>
        [Route("AnalyAgainOfDay@V1.0")]
        [HttpPost]
        public AnalyAgainMonitorGeneralRealRecordOfDayResultDto AnalyAgainOfDay([Required] AnalyAgainMonitorGeneralRealRecordOfDayInput input)
        {
            var corpId = input.CorpID;
            var monitorId = input.MonitorPointID;
            var day = input.Day;
            var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId,monitorId);
            if (monitor == null)
            {
                throw Oops.Oh(ErrorCodes.D001, $"测点:{monitorId}");
            }
            if (monitor.CronType != Model.Monitor.eCronType.Real)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}","不是实时测点");
            }
            if (monitor.SourceType != Model.Monitor.eSourceType.Analyse)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是分析测点");
            }
            if (string.IsNullOrEmpty(monitor.SourceParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置分析参数");
            }
            var analyModel = Model.Monitor.AnalyseParameters.ToModel(monitor.SourceParas);
            if (analyModel == null)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "分析参数配置错误");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaType))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式类型");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式参数");
            }
            var startTime = day.Date;//开始时间
            var endTime = day.AddDays(1).Date.AddSeconds(-1);//结束时间
            var getMonitorPoint = new Func<long, Model.MonitorPoint_Signal_SignalType>(x => {
                return new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, x);
            });
            var getLastRecord = new Func<long,long, Model.MonitorBasicRecord>((x,y) => {
                return new Service.MonitorRealRecord().GetLastBySignalIDOfDay(corpId, x, y, day.AddDays(-1));
            });
            var getRecordList = new Func<long, long, List<Model.MonitorBasicRecord>>((x, y) => {
                return new Service.MonitorRealRecord().GetBySignalIDOfDay(corpId, x, y, day)?.Select(t=>t as Model.MonitorBasicRecord).ToList();
            });
            List<Model.MonitorRealRecordPure> recordList = null;
            string msg = string.Empty;
            switch (analyModel.FormulaType)
            {
                case Model.Monitor.FormulaType.Calculation_SingleMapping://单一映射转换
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuSingleMapping
                            (startTime,endTime,monitor,analyModel.FormulaParas,getMonitorPoint,getRecordList,getLastRecord,out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_CompareMapping://比较映射转换
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuCompareMapping
                                (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_RangeMapping://区间映射转换
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuRangeMapping
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_OnceRatio://一元系数换算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuOnceRatio
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_TwiceRatio://二元系数换算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuTwiceRatio
                               (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_RunStatus://运行状态计算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuRunStatus
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_Sum://和值计算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuSum
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_Diff://差值计算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuDiff
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_NumericAccumulate://数值累积计算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuNumberAccumulate
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_EnumAccumulate://枚举累积计算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuEnumAccumulate
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_E://效率计算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuE
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_WP://千吨能耗计算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuWP
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Calculation_UWP://单位能耗计算
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.CalcuUWP
                            (startTime, endTime, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                default:msg = $"不支持的公式类型:{analyModel.FormulaType}";break;
            }
            if (recordList == null || recordList.Count < 1)
            {
                return new AnalyAgainMonitorGeneralRealRecordOfDayResultDto(false, msg);
            }
            var bol = new Service.MonitorRealRecord().InsertsAgain(recordList);
            return new AnalyAgainMonitorGeneralRealRecordOfDayResultDto(bol, msg);
        }
    }
}
Application/IStation.Application4Run/monitor_general_real_record/mgr/dto/AnalyAgainMonitorGeneralRealRecordOfDayInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    /// é‡æ–°åˆ†æžæŸå¤©çš„常规监测实时记录Input
    /// </summary>
    public class AnalyAgainMonitorGeneralRealRecordOfDayInput
    {
        /// <summary>
        /// å®¢æˆ·id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID å¿…须大于0")]
        public long CorpID { get; set; }
        /// <summary>
        /// å¸¸è§„实时测点id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID å¿…须大于0")]
        public long MonitorPointID { get; set; }
        /// <summary>
        /// åˆ†æžæ—¥æœŸ
        /// </summary>
        public DateTime Day { get; set; }
    }
}
Application/IStation.Application4Run/monitor_general_real_record/mgr/dto/AnalyAgainMonitorGeneralRealRecordOfDayResultDto.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    /// é‡æ–°åˆ†æžæŸå¤©çš„常规监测实时记录结果类
    /// </summary>
    public class AnalyAgainMonitorGeneralRealRecordOfDayResultDto
    {
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralRealRecordOfDayResultDto() { }
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralRealRecordOfDayResultDto(bool succeed, string msg)
        {
            this.Succeed = succeed;
            this.Message = msg;
        }
        /// <summary>
        /// æ˜¯å¦æˆåŠŸ
        /// </summary>
        public bool Succeed { get; set; }
        /// <summary>
        /// ç›¸å…³ä¿¡æ¯
        /// </summary>
        public string Message { get; set; }
    }
}
Application/IStation.Application4Run/monitor_general_year_record/mgr/MonitorGeneralYearRecord_MgrController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,144 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using IStation.Calculation;
using IStation.Model;
using Microsoft.AspNetCore.Authorization;
using Furion.FriendlyException;
namespace IStation.Application
{
    /// <summary>
    /// MonitorGeneralYearRecord
    /// </summary>
    [Route("Run/MonitorGeneralYearRecord/Mgr")]
    [ApiDescriptionSettings("Run", Name = "监测常规年记录(管理)", Order = 930)]
    public class MonitorGeneralYearRecord_MgrController : IDynamicApiController
    {
        /// <summary>
        /// é‡æ–°åˆ†æžæŸä¸ªå¹´ä»½ä»½åŒºé—´ï¼ˆä»…针对一个常规年分析测点的分析,会删除已有记录)
        /// </summary>
        [Route("AnalyAgainOfYearRange@V1.0")]
        [HttpPost]
        public AnalyAgainMonitorGeneralYearRecordOfYearRangeResultDto AnalyAgainOfYearRange
            ([Required] AnalyAgainMonitorGeneralYearRecordOfYearRangeInput input)
        {
            var corpId = input.CorpID;
            var monitorId = input.MonitorPointID;
            var startYear=input.StartYear;
            var endYear=input.EndYear;
            var monitor = new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, monitorId);
            if (monitor == null)
            {
                throw Oops.Oh(ErrorCodes.D001, $"测点:{monitorId}");
            }
            if (monitor.CronType != Model.Monitor.eCronType.EachYear)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是年测点");
            }
            if (monitor.SourceType != Model.Monitor.eSourceType.Analyse)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "不是分析测点");
            }
            if (string.IsNullOrEmpty(monitor.SourceParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置分析参数");
            }
            var analyModel = Model.Monitor.AnalyseParameters.ToModel(monitor.SourceParas);
            if (analyModel == null)
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "分析参数配置错误");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaType))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式类型");
            }
            if (string.IsNullOrEmpty(analyModel.FormulaParas))
            {
                throw Oops.Oh(ErrorCodes.D002, $"测点:{monitorId}", "未配置公式参数");
            }
            var getMonitorPoint = new Func<long, Model.MonitorPoint_Signal_SignalType>(x => {
                return new Service.MonitorPoint().GetExSignalWithSignalTypeByID(corpId, x);
            });
            var getLastRecord = new Func<long, long, Model.MonitorBasicRecord>((x, y) => {
                return new Service.MonitorYearRecord().GetBySignalIDOfYear(corpId, x, y, startYear-1);
            });
            var getRecordList = new Func<long, long,Model.Monitor.eCronType, DateTime,DateTime, List<Model.MonitorBasicRecord>>((x, y,cy, st,et) => {
                switch (cy)
                {
                    case Model.Monitor.eCronType.Real:
                        {
                            return new Service.MonitorRealRecord()
                                            .GetFixedBySignalIDOfTimeRange(corpId,x,y,10000,st,et)?.Select(x=>x as Model.MonitorBasicRecord).ToList();
                        }
                    case Model.Monitor.eCronType.EachDay:
                        {
                            return new Service.MonitorDayRecord().GetBySignalIDOfDayRange
                                            (monitor.CorpID, x, y,st.Date,et.Date.AddDays(-1))?.Select(x=>x as Model.MonitorBasicRecord).ToList();
                        }
                    case Model.Monitor.eCronType.EachMonth:
                        {
                            return new Service.MonitorMonthRecord().GetBySignalIDOfMonthRange
                                                (monitor.CorpID, x, y, st.Year, st.Month, et.AddDays(-1).Year, et.AddDays(-1).Month)?.Select(x => x as Model.MonitorBasicRecord).ToList();
                        }
                    default:return default;
                }
            });
            List<Model.MonitorYearRecordPure> recordList = null;
            string msg = string.Empty;
            switch (analyModel.FormulaType)
            {
                case Model.Monitor.FormulaType.Statistics_Max://最大值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalYearMaxValue
                            (startYear,endYear, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Min://最小值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalYearMinValue
                            (startYear, endYear, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Avg://平均值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalYearAvgValue
                            (startYear, endYear, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Diff://差值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalYearDiffValue
                              (startYear, endYear, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                case Model.Monitor.FormulaType.Statistics_Sum://和值统计
                    {
                        recordList = MonitorFormulaHistoryCalcuHelper.StatisticalYearSumValue
                               (startYear, endYear, monitor, analyModel.FormulaParas, getMonitorPoint, getRecordList, getLastRecord, out msg);
                    }
                    break;
                default: msg = $"不支持的公式类型:{analyModel.FormulaType}"; break;
            }
            if (recordList == null || recordList.Count < 1)
            {
                return new AnalyAgainMonitorGeneralYearRecordOfYearRangeResultDto(false, msg);
            }
            var bol = new Service.MonitorYearRecord().InsertsAgain(recordList);
            return new AnalyAgainMonitorGeneralYearRecordOfYearRangeResultDto(bol, msg);
        }
    }
}
Application/IStation.Application4Run/monitor_general_year_record/mgr/dto/AnalyAgainMonitorGeneralYearRecordOfYearRangeInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    /// é‡æ–°åˆ†æžå¹´åŒºé—´å†…的常规监测年记录Input
    /// </summary>
    public class AnalyAgainMonitorGeneralYearRecordOfYearRangeInput : IValidatableObject
    {
        /// <summary>
        /// å®¢æˆ·id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "CorpID å¿…须大于0")]
        public long CorpID { get; set; }
        /// <summary>
        /// å¸¸è§„实时测点id
        /// </summary>
        [Required, Range(1, long.MaxValue, ErrorMessage = "MonitorPointID å¿…须大于0")]
        public long MonitorPointID { get; set; }
        /// <summary>
        /// å¼€å§‹å¹´ä»½
        /// </summary>
        public int StartYear { get; set; }
        /// <summary>
        /// ç»“束月份
        /// </summary>
        public int EndYear { get; set; }
        /// <summary>
        ///
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if(StartYear>EndYear)
            {
                yield return new ValidationResult(
                        "年份区间参数错误"
                        , new[] { nameof(StartYear) }
                    );
            }
        }
    }
}
Application/IStation.Application4Run/monitor_general_year_record/mgr/dto/AnalyAgainMonitorGeneralYearRecordOfYearRangeResultDto.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IStation.Application
{
    /// <summary>
    ///
    /// </summary>
    public class AnalyAgainMonitorGeneralYearRecordOfYearRangeResultDto
    {
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralYearRecordOfYearRangeResultDto() { }
        /// <summary>
        ///
        /// </summary>
        public AnalyAgainMonitorGeneralYearRecordOfYearRangeResultDto(bool succeed,string msg)
        {
            this.Succeed = succeed;
            this.Message = msg;
        }
        /// <summary>
        /// æ˜¯å¦æˆåŠŸ
        /// </summary>
        public bool Succeed { get; set; }
        /// <summary>
        /// ä¿¡æ¯
        /// </summary>
        public string Message { get; set; }
    }
}
Calculation/IStation.Calculation4Analy/MonitorFormulaCalcuHelper.cs
@@ -383,7 +383,7 @@
        }
        /// <summary>
        /// ç»Ÿè®¡å·®å€¼
        /// ç»Ÿè®¡å’Œå€¼
        /// </summary>
        public static double StatisticalSumValue
            (
@@ -551,9 +551,6 @@
            return srcValue;
            #endregion
        }
        /// <summary>
@@ -644,9 +641,6 @@
            return srcValue;
            #endregion
        }
        /// <summary>
@@ -737,9 +731,6 @@
            return srcValue;
            #endregion
        }
        #endregion
@@ -835,8 +826,6 @@
            #endregion
        }
        /// <summary>
@@ -927,9 +916,6 @@
            return srcValue;
            #endregion
        }
        #endregion
Calculation/IStation.Calculation4Analy/MonitorFormulaHistoryCalcuHelper.cs
¶Ô±ÈÐÂÎļþ
ÎļþÌ«´ó
Core/IStation.Core/MonitorRecord.cs
@@ -32,6 +32,11 @@
        public const string Status_DataFormatError = "SZGSCW";
        /// <summary>
        /// è®¡ç®—失败
        /// </summary>
        public const string Status_CalculateFailed = "JSSB";
        /// <summary>
        /// è½¬æ¢å¤±è´¥
        /// </summary>
        public const string Status_ConvertFailed = "ZHSB";
DAL/IStation.DAL4Run/monitor_record/hour/MonitorHourRecord.cs
@@ -9,18 +9,18 @@
namespace IStation.DAL
{
    /// <summary>
    /// æ—¶ç›‘测记录
    /// </summary>
    public partial class MonitorHourRecord : CorpDAL<Entity.MonitorHourRecord>
    {
        /// <summary>
        ///
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.MonitorRecordConnectionConfig; }
        }
    /// <summary>
    /// æ—¶ç›‘测记录
    /// </summary>
    public partial class MonitorHourRecord : CorpDAL<Entity.MonitorHourRecord>
    {
        /// <summary>
        ///
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.MonitorRecordConnectionConfig; }
        }
        #region é€šè¿‡ MonitorPointID èŽ·å–
@@ -97,7 +97,7 @@
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.MonitorHourRecord>()
                    .Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID&&x.SignalID==SignalID)
                    .Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID && x.SignalID == SignalID)
                    .OrderBy(x => x.DataTime, OrderByType.Asc).ToList();
            }
        }
@@ -110,8 +110,22 @@
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.MonitorHourRecord>()
                    .Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID&&x.SignalID==SignalID && x.DataDay == Day.Date)
                    .Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID && x.SignalID == SignalID && x.DataDay == Day.Date)
                    .OrderBy(x => x.DataTime, OrderByType.Asc).ToList();
            }
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æŸæ—¶çš„æ•°æ®
        /// </summary>
        public Entity.MonitorHourRecord GetBySignalIDOfHour(long CorpID, long MonitorPointID, long SignalID, DateTime DataDay, int DataHour)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.MonitorHourRecord>()
                    .Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID && x.SignalID == SignalID)
                    .Where(x => x.DataDay == DataDay.Date && x.DataHour == DataHour)
                    .First();
            }
        }
@@ -125,7 +139,7 @@
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<Entity.MonitorHourRecord>()
                        .Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID&&x.SignalID==SignalID && x.DataDay >= StartDay.Date && x.DataDay <= EndDay.Date)
                        .Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID && x.SignalID == SignalID && x.DataDay >= StartDay.Date && x.DataDay <= EndDay.Date)
                        .OrderBy(x => x.DataTime, OrderByType.Asc).ToList();
            }
        }
@@ -164,7 +178,7 @@
            {
                return db.Deleteable<Entity.MonitorHourRecord>()
                    .Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID && x.SignalID == SignalID)
                    .Where(x => x.DataDay==DataDay.Date&&x.DataHour==DataHour)
                    .Where(x => x.DataDay == DataDay.Date && x.DataHour == DataHour)
                    .ExecuteCommand() > 0;
            }
        }
@@ -185,7 +199,7 @@
                            || (x.DataDay == StartDay.Date && x.DataDay < EndDay.Date && x.DataHour >= StartHour)
                            || (x.DataDay == EndDay.Date && x.DataDay > StartDay.Date && x.DataHour <= EndHour)
                            || (x.DataDay == StartDay.Date && x.DataDay == EndDay.Date && x.DataHour >= StartHour && x.DataHour <= EndHour))
                        .ExecuteCommand()>0;
                        .ExecuteCommand() > 0;
            }
        }
IStation.WebApi.sln
@@ -233,25 +233,27 @@
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Application4LargeScreen", "Application\IStation.Application4LargeScreen\IStation.Application4LargeScreen.csproj", "{C18E7387-5CFA-4BC4-9886-ED25DE6DCFAE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Entity4Job", "Entity\IStation.Entity4Job\IStation.Entity4Job.csproj", "{3A241303-BECA-4D81-B01E-8F75A6D70304}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Entity4Job", "Entity\IStation.Entity4Job\IStation.Entity4Job.csproj", "{3A241303-BECA-4D81-B01E-8F75A6D70304}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Model4Job", "Model\IStation.Model4Job\IStation.Model4Job.csproj", "{EE323F42-77EC-4AE4-B39C-F922DA61945D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Model4Job", "Model\IStation.Model4Job\IStation.Model4Job.csproj", "{EE323F42-77EC-4AE4-B39C-F922DA61945D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.DAL4Job", "DAL\IStation.DAL4Job\IStation.DAL4Job.csproj", "{C7C288AF-B39C-4E4A-9E0D-9D9943693E85}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.DAL4Job", "DAL\IStation.DAL4Job\IStation.DAL4Job.csproj", "{C7C288AF-B39C-4E4A-9E0D-9D9943693E85}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Service4Job", "Service\IStation.Service4Job\IStation.Service4Job.csproj", "{71B73D1F-56ED-44D3-A3E3-B409A2DF88F4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Service4Job", "Service\IStation.Service4Job\IStation.Service4Job.csproj", "{71B73D1F-56ED-44D3-A3E3-B409A2DF88F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Application4Job", "Application\IStation.Application4Job\IStation.Application4Job.csproj", "{398CD0EE-C62E-4E44-85FB-AC04A0DE30CE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Application4Job", "Application\IStation.Application4Job\IStation.Application4Job.csproj", "{398CD0EE-C62E-4E44-85FB-AC04A0DE30CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Entity4Epanet", "Entity\IStation.Entity4Epanet\IStation.Entity4Epanet.csproj", "{F851F9AA-7267-4AF8-B60C-C62FB21F5A3A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Entity4Epanet", "Entity\IStation.Entity4Epanet\IStation.Entity4Epanet.csproj", "{F851F9AA-7267-4AF8-B60C-C62FB21F5A3A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Model4Epanet", "Model\IStation.Model4Epanet\IStation.Model4Epanet.csproj", "{B9D5D2DA-09E9-4853-AD30-1D2717F21B90}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Model4Epanet", "Model\IStation.Model4Epanet\IStation.Model4Epanet.csproj", "{B9D5D2DA-09E9-4853-AD30-1D2717F21B90}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.DAL4Epanet", "DAL\IStation.DAL4Epanet\IStation.DAL4Epanet.csproj", "{85CDAFFC-F0BE-4328-ADC3-CA54C44CB411}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.DAL4Epanet", "DAL\IStation.DAL4Epanet\IStation.DAL4Epanet.csproj", "{85CDAFFC-F0BE-4328-ADC3-CA54C44CB411}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Service4Epanet", "Service\IStation.Service4Epanet\IStation.Service4Epanet.csproj", "{18557443-7507-41F7-93CD-156104EA164E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Service4Epanet", "Service\IStation.Service4Epanet\IStation.Service4Epanet.csproj", "{18557443-7507-41F7-93CD-156104EA164E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Application4Epanet", "Application\IStation.Application4Epanet\IStation.Application4Epanet.csproj", "{0E635F6A-71C0-4BC4-AE69-6ABCFC902BA3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Application4Epanet", "Application\IStation.Application4Epanet\IStation.Application4Epanet.csproj", "{0E635F6A-71C0-4BC4-AE69-6ABCFC902BA3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Calculation4Analy", "Calculation\IStation.Calculation4Analy\IStation.Calculation4Analy.csproj", "{06A261AF-DF88-411A-BC4F-318CF38DA62D}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -711,6 +713,10 @@
        {0E635F6A-71C0-4BC4-AE69-6ABCFC902BA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {0E635F6A-71C0-4BC4-AE69-6ABCFC902BA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {0E635F6A-71C0-4BC4-AE69-6ABCFC902BA3}.Release|Any CPU.Build.0 = Release|Any CPU
        {06A261AF-DF88-411A-BC4F-318CF38DA62D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {06A261AF-DF88-411A-BC4F-318CF38DA62D}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {06A261AF-DF88-411A-BC4F-318CF38DA62D}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {06A261AF-DF88-411A-BC4F-318CF38DA62D}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
@@ -828,6 +834,7 @@
        {85CDAFFC-F0BE-4328-ADC3-CA54C44CB411} = {49E7CA43-7FD9-48A3-B0DB-6D99FA93F393}
        {18557443-7507-41F7-93CD-156104EA164E} = {3BE2BA1A-B93F-4EDE-BC37-915663317C33}
        {0E635F6A-71C0-4BC4-AE69-6ABCFC902BA3} = {C7614DA2-0679-407D-B9E3-66D448DD7488}
        {06A261AF-DF88-411A-BC4F-318CF38DA62D} = {B1548C2C-C3C2-47C0-8F6E-B265D0603099}
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {18D1EA07-81E5-4443-8512-F303BC79DCF4}
Model/IStation.Model4Monitor/FormulaParas/NumberAccumulateCalculationFormulaParas.cs
@@ -64,5 +64,7 @@
            }
            return result;
        }
    }
}
Server/IStation.Server.Analy/general/real/single/GeneralRealAnalyCronJob.cs
@@ -94,7 +94,6 @@
                        #endregion
                        switch (analyModel.FormulaType)
                        {
                            case Model.Monitor.FormulaType.Calculation_SingleMapping:
Service/IStation.Service4Run/monitor_record/day/MonitorDayRecord.cs
@@ -153,6 +153,31 @@
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æŸå¤©çš„æ•°æ®
        /// </summary>
        public Model.MonitorDayRecord GetBySignalIDOfDay(long CorpID, long MonitorPointID, long SignalID, DateTime Day)
        {
            var dal = new DAL.MonitorDayRecord();
            var entity = dal.GetBySignalIDOfDay(CorpID, MonitorPointID,SignalID, Day.Date);
            var model = Entity2Model(entity);
            return model;
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æ—¥æœŸåŒºé—´å†…çš„æ•°æ®
        /// </summary>
        public List<Model.MonitorDayRecord> GetBySignalIDOfDayRange(long CorpID, long MonitorPointID, long SignalID, DateTime StartDay, DateTime EndDay)
        {
            if (StartDay.Date > EndDay.Date)
                return default;
            var dal = new DAL.MonitorDayRecord();
            var entityList = dal.GetBySignalIDOfDayRange(CorpID, MonitorPointID, SignalID, StartDay.Date, EndDay.Date);
            var modelList = Entity2Models(entityList);
            return modelList;
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æ—¥æœŸåŒºé—´å†…çš„åŸºç¡€å†…å®¹æ•°æ®
        /// </summary>
        public List<Model.MonitorBasicRecordContent> GetBasicContentBySignalIDOfDayRange(long CorpID, long MonitorPointID,long SignalID, DateTime StartDay, DateTime EndDay)
Service/IStation.Service4Run/monitor_record/hour/MonitorHourRecord.cs
@@ -165,8 +165,33 @@
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æŸæ—¶çš„æ•°æ®
        /// </summary>
        public Model.MonitorHourRecord GetBySignalIDOfHour(long CorpID, long MonitorPointID, long SignalID, DateTime DataDay, int DataHour)
        {
            var dal = new DAL.MonitorHourRecord();
            var entity = dal.GetBySignalIDOfHour(CorpID,MonitorPointID,SignalID,DataDay,DataHour);
            var model=Entity2Model(entity);
            return model;
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æ—¶é—´åŒºé—´å†…çš„æ•°æ®
        /// </summary>
        public List<Model.MonitorHourRecord> GetBySignalIDOfHourRange(long CorpID, long MonitorPointID, long SignalID, DateTime StartDay, int StartHour, DateTime EndDay, int EndHour)
        {
            if (EndDay.Date < StartDay.Date)
                return default;
            var dal = new DAL.MonitorHourRecord();
            var entityList = dal.GetBySignalIDOfHourRange(CorpID, MonitorPointID, SignalID, StartDay.Date, StartHour, EndDay.Date, EndHour);
            var modelList = Entity2Models(entityList);
            return modelList;
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æ—¶é—´åŒºé—´å†…çš„åŸºç¡€å†…å®¹æ•°æ®
        /// </summary>
        public List<Model.MonitorBasicRecordContent> GetBasicContentBySignalIDOfHourRange(long CorpID, long MonitorPointID,long SignalID, DateTime StartDay, int StartHour, DateTime EndDay, int EndHour)
        {
            if (EndDay.Date < StartDay.Date)
Service/IStation.Service4Run/monitor_record/month/MonitorMonthRecord.cs
@@ -173,6 +173,29 @@
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æŸæœˆçš„æ•°æ®
        /// </summary>
        public Model.MonitorMonthRecord GetBySignalIDOfMonth(long CorpID, long MonitorPointID, long SignalID, int DataYear, int DataMonth)
        {
            var dal = new DAL.MonitorMonthRecord();
            var entity = dal.GetBySignalIDOfMonth(CorpID, MonitorPointID, SignalID, DataYear, DataMonth);
            var model = Entity2Model(entity);
            return model;
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æœˆåŒºé—´å†…çš„æ•°æ®
        /// </summary>
        public List<Model.MonitorMonthRecord> GetBySignalIDOfMonthRange(long CorpID, long MonitorPointID, long SignalID, int StartYear, int StartMonth, int EndYear, int EndMonth)
        {
            var dal = new DAL.MonitorMonthRecord();
            var entityList = dal.GetBySignalIDOfMonthRange(CorpID, MonitorPointID, SignalID, StartYear, StartMonth, EndYear, EndMonth);
            var modelList = Entity2Models(entityList);
            return modelList;
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æœˆåŒºé—´å†…çš„åŸºç¡€å†…å®¹æ•°æ®
        /// </summary>
        public List<Model.MonitorBasicRecordContent> GetBasicContentBySignalIDOfMonthRange(long CorpID, long MonitorPointID,long SignalID, int StartYear, int StartMonth, int EndYear, int EndMonth)
Service/IStation.Service4Run/monitor_record/real/MonitorRealRecord.cs
@@ -322,6 +322,34 @@
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æ—¶é—´åŒºé—´å†…çš„æ•°æ®
        /// </summary>
        public List<Model.MonitorRealRecord> GetBySignalIDOfTimeRange(long CorpID, long MonitorPointID, long SignalID, DateTime StartTime, DateTime EndTime)
        {
            if (StartTime > EndTime)
                return default;
            var dal = new DAL.MonitorRealRecord();
            var entityList = dal.GetBySignalIDOfTimeRange(CorpID, MonitorPointID, SignalID, StartTime, EndTime);
            var modelList= Entity2Models(entityList);
            return modelList;
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æ—¶é—´åŒºé—´å†…çš„å›ºå®šæ•°é‡çš„æ•°æ®
        /// </summary>
        public List<Model.MonitorRealRecord> GetFixedBySignalIDOfTimeRange(long CorpID, long MonitorPointID, long SignalID, int Fixed, DateTime StartTime, DateTime EndTime)
        {
            if (StartTime > EndTime)
                return default;
            var dal = new DAL.MonitorRealRecord();
            var entityList = dal.GetFixedBySignalIDOfTimeRange(CorpID, MonitorPointID, SignalID, Fixed, StartTime, EndTime);
            var modelList=Entity2Models(entityList);
            return modelList;
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æ—¶é—´åŒºé—´å†…çš„å†…å®¹æ•°æ®
        /// </summary>
        public List<Model.MonitorRealRecordContent> GetContentBySignalIDOfTimeRange(long CorpID, long MonitorPointID, long SignalID, DateTime StartTime, DateTime EndTime)
Service/IStation.Service4Run/monitor_record/year/MonitorYearRecord.cs
@@ -149,6 +149,17 @@
            return model_list?.OrderBy(x => x.DataYear).ThenBy(x => x.DataTime).ToList();
        }
        /// <summary>
        /// é€šè¿‡ SignalID èŽ·å–æŸå¹´çš„æ•°æ®
        /// </summary>
        public Model.MonitorYearRecord GetBySignalIDOfYear(long CorpID, long MonitorPointID, long SignalID, int Year)
        {
            var dal = new DAL.MonitorYearRecord();
            var entity = dal.GetBySignalIDOfYear(CorpID, MonitorPointID,SignalID, Year);
            var model = Entity2Model(entity);
            return model;
        }
        #endregion
        #region Insert