更新依赖
This commit is contained in:
parent
4eb7619086
commit
9e78438074
@ -2,7 +2,7 @@
|
||||
<!-- 定义项目加载属性 -->
|
||||
<PropertyGroup>
|
||||
<!--JiShe.ServicePro版本-->
|
||||
<ServiceProVersion>1.0.5.08</ServiceProVersion>
|
||||
<ServiceProVersion>1.0.5.13</ServiceProVersion>
|
||||
<!--Volo Abp 版本-->
|
||||
<VoloAbpVersion>9.1.1</VoloAbpVersion>
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using JiShe.CollectBus.Common;
|
||||
using JiShe.CollectBus.Common.DeviceBalanceControl;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Diagnostics;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using JiShe.CollectBus.Ammeters;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.DeviceBalanceControl;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Helpers;
|
||||
using JiShe.CollectBus.IotSystems.Devices;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using JiShe.CollectBus.Common;
|
||||
using JiShe.CollectBus.Common.Consts;
|
||||
using JiShe.CollectBus.Common.DeviceBalanceControl;
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using JiShe.CollectBus.Common.Extensions;
|
||||
using JiShe.CollectBus.Common.Models;
|
||||
|
||||
@ -1,343 +0,0 @@
|
||||
using JiShe.CollectBus.Common.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace JiShe.CollectBus.Common.Extensions
|
||||
{
|
||||
public static class DateTimeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a DateTime to a Unix Timestamp
|
||||
/// </summary>
|
||||
/// <param name="target">This DateTime</param>
|
||||
/// <returns></returns>
|
||||
[Description("将日期时间转换为Unix时间戳")]
|
||||
public static double ToUnixTimestamp(this DateTime target)
|
||||
{
|
||||
var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
var diff = target - origin;
|
||||
return Math.Floor(diff.TotalSeconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Unix Timestamp in to a DateTime
|
||||
/// </summary>
|
||||
/// <param name="unixTime">This Unix Timestamp</param>
|
||||
/// <returns></returns>
|
||||
[Description("将Unix时间戳转换为日期时间")]
|
||||
public static DateTime FromUnixTimestamp(this double unixTime)
|
||||
{
|
||||
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
return epoch.AddSeconds(unixTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the End of the day (23:59)
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
[Description("获取一天结束的值(23:59)")]
|
||||
public static DateTime ToDayEnd(this DateTime target)
|
||||
{
|
||||
return target.Date.AddDays(1).AddMilliseconds(-1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the First Date of the week for the specified date
|
||||
/// </summary>
|
||||
/// <param name="dt">this DateTime</param>
|
||||
/// <param name="startOfWeek">The Start Day of the Week (ie, Sunday/Monday)</param>
|
||||
/// <returns>The First Date of the week</returns>
|
||||
[Description("获取指定日期的星期的第一个日期")]
|
||||
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
|
||||
{
|
||||
var diff = dt.DayOfWeek - startOfWeek;
|
||||
|
||||
if (diff < 0)
|
||||
diff += 7;
|
||||
|
||||
return dt.AddDays(-1 * diff).Date;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all the days of a month.
|
||||
/// </summary>
|
||||
/// <param name="year">The year.</param>
|
||||
/// <param name="month">The month.</param>
|
||||
/// <returns></returns>
|
||||
[Description("获取一个月的所有日期")]
|
||||
public static IEnumerable<DateTime> DaysOfMonth(int year, int month)
|
||||
{
|
||||
return Enumerable.Range(0, DateTime.DaysInMonth(year, month))
|
||||
.Select(day => new DateTime(year, month, day + 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the Nth instance of a Date's DayOfWeek in a month
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <example>11/29/2011 would return 5, because it is the 5th Tuesday of each month</example>
|
||||
[Description("获取当前日期在一个月的第几个星期")]
|
||||
public static int WeekDayInstanceOfMonth(this DateTime dateTime)
|
||||
{
|
||||
var y = 0;
|
||||
return DaysOfMonth(dateTime.Year, dateTime.Month)
|
||||
.Where(date => dateTime.DayOfWeek.Equals(date.DayOfWeek))
|
||||
.Select(x => new { n = ++y, date = x })
|
||||
.Where(x => x.date.Equals(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day)))
|
||||
.Select(x => x.n).FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total days in a month
|
||||
/// </summary>
|
||||
/// <param name="dateTime">The date time.</param>
|
||||
/// <returns></returns>
|
||||
[Description("获取一个月内的总天数")]
|
||||
public static int TotalDaysInMonth(this DateTime dateTime)
|
||||
{
|
||||
return DaysOfMonth(dateTime.Year, dateTime.Month).Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the first day in a month
|
||||
/// </summary>
|
||||
/// <param name="dateTime">The date time.</param>
|
||||
/// <returns></returns>
|
||||
[Description("获取一个月内的第一天")]
|
||||
public static DateTime FirstInMonth(this DateTime dateTime)
|
||||
{
|
||||
return DateTime.Now.AddDays(1 - DateTime.Now.Day);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Last Day in a Month 23:59:59
|
||||
/// </summary>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
[Description("获取一个月内的最后一天 23:59:59")]
|
||||
public static DateTime LastInMonth(this DateTime dateTime)
|
||||
{
|
||||
return DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes any date and returns it's value as an Unspecified DateTime
|
||||
/// </summary>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
[Description("获取Unspecified日期")]
|
||||
public static DateTime ToDateTimeUnspecified(this DateTime date)
|
||||
{
|
||||
if (date.Kind == DateTimeKind.Unspecified)
|
||||
{
|
||||
return date;
|
||||
}
|
||||
|
||||
return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, DateTimeKind.Unspecified);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trims the milliseconds off of a datetime
|
||||
/// </summary>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
[Description("将日期时间缩短毫秒")]
|
||||
public static DateTime TrimMilliseconds(this DateTime date)
|
||||
{
|
||||
return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Kind);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the time.
|
||||
/// </summary>
|
||||
/// <param name="dateTime">The date time.</param>
|
||||
/// <returns></returns>
|
||||
[Description("清除时间")]
|
||||
public static DateTime ClearTime(this DateTime dateTime)
|
||||
{
|
||||
return dateTime.Subtract(
|
||||
new TimeSpan(
|
||||
0,
|
||||
dateTime.Hour,
|
||||
dateTime.Minute,
|
||||
dateTime.Second,
|
||||
dateTime.Millisecond
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表分片策略
|
||||
/// </summary>
|
||||
/// <param name="dateTime"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDataTableShardingStrategy(this DateTime dateTime, TableTimeStrategyEnum tableStrategy)
|
||||
{
|
||||
switch (tableStrategy)
|
||||
{
|
||||
case TableTimeStrategyEnum.MinuteShardingStrategy:
|
||||
return $"{dateTime:yyyyMMddHHmm}";
|
||||
case TableTimeStrategyEnum.HourShardingStrategy:
|
||||
return $"{dateTime:yyyyMMddHH}";
|
||||
case TableTimeStrategyEnum.DayShardingStrategy:
|
||||
return $"{dateTime:yyyyMMdd}";
|
||||
case TableTimeStrategyEnum.MonthShardingStrategy:
|
||||
return $"{dateTime:yyyyMM}";
|
||||
case TableTimeStrategyEnum.YearShardingStrategy:
|
||||
return $"{dateTime:yyyy}";
|
||||
default:
|
||||
return $""; // 默认不分表
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 采集时间节点计算
|
||||
/// </summary>
|
||||
/// <param name="referenceTime">待采集时间</param>
|
||||
/// <param name="interval"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime CalculateNextCollectionTime(this DateTime referenceTime, int interval)
|
||||
{
|
||||
// 计算精确到分钟的基准时间
|
||||
var baseTime = new DateTime(
|
||||
referenceTime.Year,
|
||||
referenceTime.Month,
|
||||
referenceTime.Day,
|
||||
referenceTime.Hour,
|
||||
referenceTime.Minute,
|
||||
0);
|
||||
|
||||
// 计算总分钟数和下一个间隔点
|
||||
int totalMinutes = baseTime.Hour * 60 + baseTime.Minute;
|
||||
int nextTotalMinutes = ((totalMinutes / interval) + 1) * interval;
|
||||
|
||||
// 处理跨天情况
|
||||
int daysToAdd = nextTotalMinutes / (24 * 60);
|
||||
int remainingMinutes = nextTotalMinutes % (24 * 60);
|
||||
int hours = remainingMinutes / 60;
|
||||
int minutes = remainingMinutes % 60;
|
||||
|
||||
return baseTime.Date
|
||||
.AddDays(daysToAdd)
|
||||
.AddHours(hours)
|
||||
.AddMinutes(minutes);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 格式化为微秒(μs)
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToMicrosecondString(this DateTime dt)
|
||||
{
|
||||
long microseconds = (dt.Ticks % TimeSpan.TicksPerSecond) / 10; // 1 Tick = 100ns → 0.1μs
|
||||
return $"{dt:yyyy-MM-dd HH:mm:ss.fffffff}".Remove(23) + $"{microseconds:D6}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格式化为纳秒(ns)
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToNanosecondString(this DateTime dt)
|
||||
{
|
||||
long nanoseconds = (dt.Ticks % TimeSpan.TicksPerSecond) * 100; // 1 Tick = 100ns
|
||||
return $"{dt:yyyy-MM-dd HH:mm:ss.fffffff}".Remove(23) + $"{nanoseconds:D9}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 毫米、微秒、纳秒时间戳转DateTime
|
||||
/// </summary>
|
||||
/// <param name="dateLong"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static DateTime ParseIntToDate(this long dateLong)
|
||||
{
|
||||
if (dateLong < 10000101 || dateLong > 99991231)
|
||||
{
|
||||
throw new ArgumentException("Date must be between 10000101 and 99991231.");
|
||||
}
|
||||
return DateTime.TryParseExact(dateLong.ToString(), "yyyyMMdd HHmmssZZ", null, System.Globalization.DateTimeStyles.None, out DateTime date) ? date : throw new ArgumentException("Date must be between 10000101 and 99991231.");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取得某月的第一天
|
||||
/// </summary>
|
||||
/// <param name="datetime">要取得月份第一天的时间</param>
|
||||
/// <returns></returns>
|
||||
public static DateTime FirstDayOfMonth(this DateTime datetime)
|
||||
{
|
||||
return datetime.AddDays(1 - datetime.Day);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// 取得某月的最后一天
|
||||
/// </summary>
|
||||
/// <param name="datetime">要取得月份最后一天的时间</param>
|
||||
/// <returns></returns>
|
||||
public static DateTime LastDayOfMonth(this DateTime datetime)
|
||||
{
|
||||
return datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得上个月第一天
|
||||
/// </summary>
|
||||
/// <param name="datetime">要取得上个月第一天的当前时间</param>
|
||||
/// <returns></returns>
|
||||
public static DateTime FirstDayOfPreviousMonth(this DateTime datetime)
|
||||
{
|
||||
return datetime.AddDays(1 - datetime.Day).AddMonths(-1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得上个月的最后一天
|
||||
/// </summary>
|
||||
/// <param name="datetime">要取得上个月最后一天的当前时间</param>
|
||||
/// <returns></returns>
|
||||
public static DateTime LastDayOfPrdviousMonth(this DateTime datetime)
|
||||
{
|
||||
return datetime.AddDays(1 - datetime.Day).AddDays(-1);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取得某月第一天0点以及最后一天的23:59:59时间范围
|
||||
/// </summary>
|
||||
/// <param name="datetime"></param>
|
||||
/// <returns></returns>
|
||||
public static Tuple<DateTime, DateTime> GetMonthDateRange(this DateTime datetime)
|
||||
{
|
||||
var lastDayOfMonthDate = LastDayOfMonth(datetime);
|
||||
return new Tuple<DateTime, DateTime>(datetime.FirstDayOfMonth(), new DateTime(lastDayOfMonthDate.Year, lastDayOfMonthDate.Month, lastDayOfMonthDate.Day, 23, 59, 59));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得某一天0点到当月最后一天的23:59:59时间范围
|
||||
/// </summary>
|
||||
/// <param name="datetime"></param>
|
||||
/// <returns></returns>
|
||||
public static Tuple<DateTime, DateTime> GetCurrentDateToLastDayRange(this DateTime datetime)
|
||||
{
|
||||
var lastDayOfMonthDate = LastDayOfMonth(datetime);
|
||||
return new Tuple<DateTime, DateTime>(datetime.Date, new DateTime(lastDayOfMonthDate.Year, lastDayOfMonthDate.Month, lastDayOfMonthDate.Day, 23, 59, 59));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得某一天0点到23:59:59时间范围
|
||||
/// </summary>
|
||||
/// <param name="datetime"></param>
|
||||
/// <returns></returns>
|
||||
public static Tuple<DateTime, DateTime> GetCurrentDateRange(this DateTime datetime)
|
||||
{
|
||||
return new Tuple<DateTime, DateTime>(datetime.Date, new DateTime(datetime.Year, datetime.Month, datetime.Day, 23, 59, 59));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"Default": "mongodb://admin:4mFmPTTB8tn6aI@47.110.62.104:27017,47.110.53.196:27017,47.110.60.222:27017/JiSheCollectBus?authSource=admin&maxPoolSize=400&minPoolSize=10&waitQueueTimeoutMS=5000",
|
||||
"Default": "",
|
||||
"PrepayDB": "server=rm-m5el3d1u1k0wzk70n2o.sqlserver.rds.aliyuncs.com,3433;database=jishe.sysdb;uid=v3sa;pwd=JiShe123;Encrypt=False;Trust Server Certificate=False",
|
||||
"EnergyDB": "server=rm-wz9hw529i3j1e3b5fbo.sqlserver.rds.aliyuncs.com,3433;database=db_energy;uid=yjdb;pwd=Kdjdhf+9*7ad222LL;Encrypt=False;Trust Server Certificate=False"
|
||||
},
|
||||
"FreeRedisOptions": {
|
||||
"ConnectionString": "47.110.53.196:6379,password=1q3J@BGf!yhTaD46nS#,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true,maxPoolSize=50,defaultdatabase=14",
|
||||
"ConnectionString": "172.21.40.197:6379,password=1q3J@BGf!yhTaD46nS#,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true,maxPoolSize=50,defaultdatabase=14",
|
||||
"UseDistributedCache": true
|
||||
},
|
||||
"FreeSqlProviderOptions": {
|
||||
@ -14,7 +14,7 @@
|
||||
"PrintLog": true
|
||||
},
|
||||
"Kafka": {
|
||||
"BootstrapServers": "47.110.62.104:9094,47.110.53.196:9094,47.110.60.222:9094",
|
||||
"BootstrapServers": "172.21.40.198:9092,172.21.40.197:9092,172.21.40.199:9092",
|
||||
"EnableFilter": true,
|
||||
"EnableAuthorization": false,
|
||||
"SaslUserName": "lixiao",
|
||||
@ -26,8 +26,8 @@
|
||||
"IoTDBOptions": {
|
||||
"UserName": "root",
|
||||
"Password": "Lixiao@1980",
|
||||
"TreeModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ],
|
||||
"TableModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ],
|
||||
"TreeModelClusterList": [ "172.21.40.198:6667", "172.21.40.197:6667", "172.21.40.199:6667" ],
|
||||
"TableModelClusterList": [ "172.21.40.198:6667", "172.21.40.197:6667", "172.21.40.199:6667" ],
|
||||
"PoolSize": 32,
|
||||
"TableModelDataBaseName": "energy",
|
||||
"OpenDebugMode": true,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"Default": "mongodb://mongo_PmEeF3:lixiao1980@192.168.5.9:27017/JiSheCollectBus?authSource=admin&maxPoolSize=400&minPoolSize=10&waitQueueTimeoutMS=5000",
|
||||
"Kafka": "192.168.5.9:29092,192.168.5.9:39092,192.168.5.9:49092",
|
||||
"Default": "",
|
||||
"PrepayDB": "server=118.190.144.92;database=jishe.sysdb;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False",
|
||||
"EnergyDB": "server=118.190.144.92;database=db_energy;uid=sa;pwd=admin@2023;Encrypt=False;Trust Server Certificate=False"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user