|
@@ -1,4 +1,6 @@
|
|
|
-using System;
|
|
|
+using DocumentFormat.OpenXml.Bibliography;
|
|
|
+using Microsoft.Azure.Amqp.Framing;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
@@ -88,16 +90,16 @@ namespace TEAMModelOS.SDK.Models.Service.BI
|
|
|
/// <param name="date"></param>
|
|
|
/// <param name="dateLenth"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task<List<MonthStartEnd>> GetYearSataMthCtMth(DateTimeOffset date, bool dateLenth = true)
|
|
|
+ public static async Task<List<StartEndTime>> GetYearSataMthCtMth(DateTimeOffset date, bool dateLenth = true)
|
|
|
{
|
|
|
int year = date.Year;
|
|
|
int mth = date.Month;
|
|
|
int day = date.Day;
|
|
|
|
|
|
- List<MonthStartEnd> monthStartEnds = new();
|
|
|
+ List<StartEndTime> monthStartEnds = new();
|
|
|
for (int i = 1; i <= mth; i++)
|
|
|
{
|
|
|
- MonthStartEnd monthStartEnd = new() { yearMonth = $"{year}-{i}" };
|
|
|
+ StartEndTime monthStartEnd = new() { date = $"{year}-{i}" };
|
|
|
//DateTime dt = DateTime.Parse($"{year}-{i}");
|
|
|
DateTimeOffset dtNew = new(year, i, 1, 0, 0, 0, TimeSpan.Zero);
|
|
|
long start = dtNew.ToUnixTimeMilliseconds();
|
|
@@ -131,12 +133,12 @@ namespace TEAMModelOS.SDK.Models.Service.BI
|
|
|
/// <param name="year">年份</param>
|
|
|
/// <param name="dateLenth">true :13位时间戳 false:10位时间戳</param>
|
|
|
/// <returns></returns>
|
|
|
- public static List<MonthStartEnd> GetYearMonthlyStartEnd(int year, bool dateLenth = true)
|
|
|
+ public static List<StartEndTime> GetYearMonthlyStartEnd(int year, bool dateLenth = true)
|
|
|
{
|
|
|
- List<MonthStartEnd> monthStartEnds = new();
|
|
|
+ List<StartEndTime> monthStartEnds = new();
|
|
|
for (int i = 1; i <= 12; i++)
|
|
|
{
|
|
|
- MonthStartEnd monthStartEnd = new() { yearMonth = $"{year}-{i}" };
|
|
|
+ StartEndTime monthStartEnd = new() { date = $"{year}-{i}" };
|
|
|
//DateTime dt = DateTime.Parse($"{year}-{i}");
|
|
|
DateTimeOffset dtNew = new(year, i, 1, 0, 0, 0, TimeSpan.Zero);
|
|
|
long start = dtNew.ToUnixTimeMilliseconds();
|
|
@@ -160,9 +162,9 @@ namespace TEAMModelOS.SDK.Models.Service.BI
|
|
|
/// <param name="yearMonth">日期</param>
|
|
|
/// <param name="dateLenth">true :13位时间戳 false:10位时间戳</param>
|
|
|
/// <returns></returns>
|
|
|
- public static List<MonthStartEnd> monthsOfYear(string yearMonth, bool dateLenth = true)
|
|
|
+ public static List<StartEndTime> monthsOfYear(string yearMonth, bool dateLenth = true)
|
|
|
{
|
|
|
- List<MonthStartEnd> monthStartEnds = new();
|
|
|
+ List<StartEndTime> monthStartEnds = new();
|
|
|
DateTime dateTime = DateTime.Parse(yearMonth);
|
|
|
|
|
|
int year = dateTime.Year;
|
|
@@ -170,7 +172,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
|
|
|
List<string> months = new();
|
|
|
while (year > dateTime.Year - 1 || month > dateTime.Month)
|
|
|
{
|
|
|
- MonthStartEnd monthStartEnd = new() { yearMonth = $"{year}-{month}" };
|
|
|
+ StartEndTime monthStartEnd = new() { date = $"{year}-{month}" };
|
|
|
|
|
|
DateTimeOffset dtNew = new(year, month, 1, 0, 0, 0, TimeSpan.Zero);
|
|
|
long start = dateLenth ? dtNew.ToUnixTimeMilliseconds() : dtNew.ToUnixTimeSeconds();
|
|
@@ -387,6 +389,44 @@ namespace TEAMModelOS.SDK.Models.Service.BI
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 计算每年获取开始时间
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dateTime"></param>
|
|
|
+ /// <param name="dateLenth"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static List<StartEndTime> GetYearEveryDay(DateTimeOffset dateTime, bool dateLenth = true,bool isCurrDay = false)
|
|
|
+ {
|
|
|
+ List<StartEndTime> dayStartEen = new();
|
|
|
+ int year = dateTime.Year;
|
|
|
+ int curry = dateTime.DayOfYear;
|
|
|
+ List<int> isLeapYear = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? isLeapYear = leapY : isLeapYear = flatY;
|
|
|
+ for (int m = 1; m <= 12; m++)
|
|
|
+ {
|
|
|
+ for (int d = 1; d <= isLeapYear[m - 1]; d++)
|
|
|
+ {
|
|
|
+ if (isCurrDay == true && (curry <= dayStartEen.Count))
|
|
|
+ break;
|
|
|
+ DateTimeOffset tempStrart = new(year, m, d, 0, 0, 0, TimeSpan.Zero);
|
|
|
+ DateTimeOffset tempEnd = new(year, m, d, 23, 59, 59, TimeSpan.Zero);
|
|
|
+
|
|
|
+ long longStart = dateLenth ? tempStrart.ToUnixTimeMilliseconds() : tempStrart.ToUnixTimeSeconds();
|
|
|
+ long longEnd = dateLenth ? tempEnd.ToUnixTimeMilliseconds() : tempEnd.ToUnixTimeSeconds();
|
|
|
+
|
|
|
+ dayStartEen.Add(new StartEndTime() { date = $"{year}-{m}-{d}", start = longStart, end = longEnd });
|
|
|
+ }
|
|
|
+
|
|
|
+ ////DateTime 有方法
|
|
|
+ //DateTime monthStart = new DateTime(year, i, 01);
|
|
|
+ //DateTime monthEnd = dateTime.AddMonths(1);
|
|
|
+
|
|
|
+ //DateTimeOffset tempStrart = new DateTimeOffset(year, i, days, 0, 0, 0, TimeSpan.Zero);
|
|
|
+ //DateTimeOffset tempEnd = new DateTimeOffset(year, i, days, 23, 59, 59, TimeSpan.Zero);
|
|
|
+ }
|
|
|
+
|
|
|
+ return dayStartEen;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 将时间戳格式 转换成string类型
|
|
|
/// 例:yyyyMMdd,等string类型
|
|
@@ -422,32 +462,40 @@ namespace TEAMModelOS.SDK.Models.Service.BI
|
|
|
return days;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 12个月
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="doubles"></param>
|
|
|
+ /// <param name="year"></param>
|
|
|
+ /// <param name="month"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public static List<YearMonth> GetYearMonth(List<double> doubles, int year = 0, int month = 0)
|
|
|
{
|
|
|
List<YearMonth> months = new();
|
|
|
- DateTimeOffset dateTime = DateTimeOffset.Now;
|
|
|
- if (year == 0)
|
|
|
- year = dateTime.Year;
|
|
|
- if (month == 0)
|
|
|
- month = dateTime.Month;
|
|
|
-
|
|
|
- List<int> isLeapYear = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? isLeapYear = leapY : isLeapYear = flatY;
|
|
|
- double[] array = doubles.ToArray();
|
|
|
- double ser = doubles.Sum();
|
|
|
- int moth = 1;
|
|
|
- int primaryD = 0;
|
|
|
- for (int i = 0; i < isLeapYear.Count; i++)
|
|
|
+ if (doubles.Count > 0)
|
|
|
{
|
|
|
- if (month < moth)
|
|
|
- break;
|
|
|
- double[] temp = new double[isLeapYear[i]];
|
|
|
- Array.ConstrainedCopy(array, primaryD, temp, 0, isLeapYear[i]);
|
|
|
- months.Add(new YearMonth() { id = $"{year}-{moth}", cnt = temp.Sum() });
|
|
|
- moth += 1;
|
|
|
- primaryD += isLeapYear[i];
|
|
|
+ DateTimeOffset dateTime = DateTimeOffset.Now;
|
|
|
+ if (year == 0)
|
|
|
+ year = dateTime.Year;
|
|
|
+ if (month == 0)
|
|
|
+ month = dateTime.Month;
|
|
|
+
|
|
|
+ List<int> isLeapYear = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? isLeapYear = leapY : isLeapYear = flatY;
|
|
|
+ double[] array = doubles.ToArray();
|
|
|
+ double ser = doubles.Sum();
|
|
|
+ int moth = 1;
|
|
|
+ int primaryD = 0;
|
|
|
+ for (int i = 0; i < isLeapYear.Count; i++)
|
|
|
+ {
|
|
|
+ if (month < moth)
|
|
|
+ break;
|
|
|
+ double[] temp = new double[isLeapYear[i]];
|
|
|
+ Array.ConstrainedCopy(array, primaryD, temp, 0, isLeapYear[i]);
|
|
|
+ months.Add(new YearMonth() { id = $"{year}-{moth}", cnt = temp.Sum() });
|
|
|
+ moth += 1;
|
|
|
+ primaryD += isLeapYear[i];
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
return months;
|
|
|
}
|
|
|
|