using System;
using System.Linq;
using System.Text;
using SqlSugar;
namespace Entity.DbModel.Station
{
///
///电价模型详情
///
[SugarTable("elec_price_model_version_detail")]
public partial class ElecPriceModelVersionDetail : BaseModel
{
public ElecPriceModelVersionDetail(){
}
///
/// Desc:id
/// Default:
/// Nullable:False
///
[SugarColumn(IsPrimaryKey=true,IsIdentity=true,ColumnName="id")]
public int Id {get;set;}
///
/// Desc:版本号
/// Default:
/// Nullable:True
///
[SugarColumn(ColumnName="version")]
public int Version {get;set;}
///
/// 开始时间:小时
///
[SugarColumn(ColumnName = "start_hour")]
public int StartHour { get; set; }
///
/// 开始时间:分组
///
[SugarColumn(ColumnName = "start_minute")]
public int StartMinute { get; set; }
///
/// 开始时间:秒
///
[SugarColumn(ColumnName = "start_second")]
public int StartSecond { get; set; }
///
/// 结束时间:小时
///
[SugarColumn(ColumnName = "end_hour")]
public int EndHour { get; set; }
///
/// 结束时间:分钟
///
[SugarColumn(ColumnName = "end_minute")]
public int EndMinute { get; set; }
///
/// 结束时间:秒
///
[SugarColumn(ColumnName = "end_second")]
public int EndSecond { get; set; }
private double _price;
///
/// Desc:价格;以分为单位存储
/// Default:
/// Nullable:True
///
// [SugarColumn(ColumnName="price")]
public double Price
{
get => _price;
set
{
if (value < 0)
{
throw new ArgumentException("电价不能为负数");
}
_price = Math.Round(value, 4);
}
}
///
/// Desc:尖峰平谷类型;1-尖;2-峰;3-平;4-谷
/// Default:
/// Nullable:True
///
[SugarColumn(ColumnName="type")]
public int? Type {get;set;}
///
/// 判断一个时间段是否包含另一个时间段(包括开始和结束时间的秒数)
///
///
///
public bool Contains(ElecPriceModelVersionDetail other)
{
return (other.StartHour < EndHour ||
(other.StartHour == EndHour && other.StartMinute < EndMinute) ||
(other.StartHour == EndHour && other.StartMinute == EndMinute && other.StartSecond <= EndSecond)) &&
(other.EndHour > StartHour ||
(other.EndHour == StartHour && other.EndMinute > StartMinute) ||
(other.EndHour == StartHour && other.EndMinute == StartMinute && other.EndSecond >= StartSecond));
}
}
}