Skip to content

Commit

Permalink
【修复】修复mysql下报表统计异常问题,优化显示数量问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
jianweie committed Mar 6, 2023
1 parent 5dfc3d2 commit f41f314
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
9 changes: 5 additions & 4 deletions CoreCms.Net.Services/Financial/CoreCmsReportsServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.Echarts;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Helper;
using SqlSugar;


Expand Down Expand Up @@ -83,7 +84,7 @@ left join (
select * from CoreCmsOrder
where 1 = 1
" + where + @"
) o on tmp_x.x = ((cast(date(o." + joinVal + @") as signed) - " + sTime.ToString("yyyy-MM-dd") + @") div(" + section + @"))
) o on tmp_x.x = ((unix_timestamp(o." + joinVal + @") - " + CommonHelper.ConvertDateTimeToInt(sTime) + @") div(" + section + @"))
group by tmp_x.x
";
}
Expand Down Expand Up @@ -141,7 +142,7 @@ left join (
select * from CoreCmsBillPayments
where 1 = 1
" + where + @"
) o on tmp_x.x = ((cast(date(o." + joinVal + @") as signed) - " + sTime.ToString("yyyy-MM-dd") + @") div(" + section + @"))
) o on tmp_x.x = ((unix_timestamp(o." + joinVal + @") - " + CommonHelper.ConvertDateTimeToInt(sTime) + @") div(" + section + @"))
group by tmp_x.x
";
}
Expand Down Expand Up @@ -201,7 +202,7 @@ left join(
select* from CoreCmsBillRefund
where 1 = 1
" + where + @"
) o on tmp_x.x = ((cast(date(o." + joinVal + @") as signed) - " + sTime.ToString("yyyy-MM-dd") + @") div(" + section + @"))
) o on tmp_x.x = ((unix_timestamp(o." + joinVal + @") - " + CommonHelper.ConvertDateTimeToInt(sTime) + @") div(" + section + @"))
group by tmp_x.x
";
}
Expand Down Expand Up @@ -258,7 +259,7 @@ left join (
select * from CoreCmsUserTocash
where 1 = 1
" + where + @"
) o on tmp_x.x = ((cast(date(o." + joinVal + @") as signed) - " + sTime.ToString("yyyy-MM-dd") + @") div(" + section + @"))
) o on tmp_x.x = ((unix_timestamp(o." + joinVal + @") - " + CommonHelper.ConvertDateTimeToInt(sTime) + @") div(" + section + @"))
group by tmp_x.x
";
}
Expand Down
14 changes: 14 additions & 0 deletions CoreCms.Net.Utility/Helper/CommonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,5 +650,19 @@ public static bool CheckBase64Size(string base64, int size, string unit = "M")
// 如果上传文件大于限定的容量
return !(fileSize > size);
}


/// <summary>
/// 10位时间戳 转化
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public static long ConvertDateTimeToInt(System.DateTime time)
{
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
long t = (time.Ticks - startTime.Ticks) / 10000000; //除10000000调整为10位
return t;
}

}
}
12 changes: 6 additions & 6 deletions CoreCms.Net.Utility/Helper/ReportsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,29 +110,29 @@ public static WebApiCallBack GetXdata(ReportsBackForGetDate dateArr)
case 3600: //小时
if (dateArr.num <= 24)
{
xType = "H时";
xType = "d日H时";
}
else if (dateArr.num <= 720)
{
xType = "d日H时";
xType = "M月d日H时";
}
else
{
xType = "m月d日H时";
xType = "M月d日H时";
}
break;
case 86400: //天
if (dateArr.num <= 31)
{
xType = "d号";
xType = "M月d号";
}
else if (dateArr.num <= 365)
{
xType = "m.d";
xType = "yyyy年M月dd日";
}
else
{
xType = "Y.m.d";
xType = "yyyy年M月dd日";
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
defaultToolbar: ['filter', 'print', 'exports'],
//height: 'full-127',
page: false,
limit: 30,
limits: [10, 15, 20, 25, 30, 50, 100, 200],
limit: 8760,
//limits: [10, 15, 20, 25, 30, 50, 100, 200],
text: { none: '暂无相关数据' },
totalRow: true,
cols: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
//height: 'full-127',
page: false,
cellMinWidth: '80',
limit: 30,
limits: [10, 15, 20, 25, 30, 50, 100, 200],
limit: 8760,
//limits: [10, 15, 20, 25, 30, 50, 100, 200],
text: { none: '暂无相关数据' },
totalRow: true,
cols: [
Expand Down

0 comments on commit f41f314

Please sign in to comment.