报表速度提升
This commit is contained in:
@ -3,6 +3,11 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using HT.Cloud.Service.ChartsManage;
|
||||
using HT.Cloud.Service.ReportManage;
|
||||
using Newtonsoft.Json;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Text;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace HT.Cloud.Web.Areas.ReportManage.Controllers
|
||||
{
|
||||
@ -22,6 +27,47 @@ namespace HT.Cloud.Web.Areas.ReportManage.Controllers
|
||||
var data = await _historyReportService.GetReportFileName(StartTime, EndTime, Interval);
|
||||
return Content(data);
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> GetReportNew(Reportparam reportparam)
|
||||
{
|
||||
var t1 = DateTime.Now;
|
||||
//var ob = JsonConvert.SerializeObject(reportparam);
|
||||
var t2 = DateTime.Now;
|
||||
Console.WriteLine($"第1次序列化,花费时间:{(t2 - t1).TotalMilliseconds}");
|
||||
//var StartTime = reportparam.StartTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
//var EndTime = reportparam.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
var StartTime = Gettime(reportparam.StartTime.ToString());
|
||||
var EndTime = Gettime(reportparam.EndTime.ToString());
|
||||
var Interval = int.Parse(reportparam.Interval);
|
||||
var t5 = DateTime.Now;
|
||||
var data = await _historyReportService.GetReportNew(StartTime, EndTime, Interval);
|
||||
var t6 = DateTime.Now;
|
||||
Console.WriteLine($"调用service,花费时间:{(t6 - t5).TotalMilliseconds}");
|
||||
var t3 = DateTime.Now;
|
||||
var con = JsonConvert.SerializeObject(data);
|
||||
var t4 = DateTime.Now;
|
||||
Console.WriteLine($"第2次序列化,花费时间:{(t4 - t3).TotalMilliseconds}");
|
||||
return Content(con, "text/html; charset=utf-8");
|
||||
//return Content(con);
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetReportFirstHead()
|
||||
{
|
||||
//var StartTime = reportparam.StartTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
//var EndTime = reportparam.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
var data = await _historyReportService.GetReportFirstHead();
|
||||
return Content(data);
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetReportSecondHead()
|
||||
{
|
||||
//var StartTime = reportparam.StartTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
//var EndTime = reportparam.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
var data = await _historyReportService.GetReportSecondHead();
|
||||
return Content(data);
|
||||
}
|
||||
|
||||
public string Gettime(string longtime)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@
|
||||
<div id="bottom_5" class="layui-form-item active" data-id="bottom_5" data-tag="bottom"
|
||||
data-index="0">
|
||||
<div class="layui-input-block" style="margin-left: 0px;">
|
||||
<button id="btn_search" type="button" class="layui-btn custom-zc" ; onclick="GetReportView()">
|
||||
<button id="btn_search" type="button" class="layui-btn custom-zc" ; onclick="GetReportViewNew()">
|
||||
<i class="layui-icon ">
|
||||
</i>
|
||||
确定
|
||||
@ -582,10 +582,199 @@
|
||||
}
|
||||
|
||||
async function downloadreport() {
|
||||
|
||||
|
||||
window.open(filepath);
|
||||
}
|
||||
async function GetReportViewNew() {
|
||||
debugger;
|
||||
showLoading();
|
||||
var datetimestart = $('#dateReStartTime')[0].value;
|
||||
var datetimeend = $('#dateReEndTime')[0].value;
|
||||
var timeInterval = 0;
|
||||
switch ($('[name="selectint"]')[0].value) {
|
||||
case "tensec":
|
||||
timeInterval = 10
|
||||
break
|
||||
case "twentysec":
|
||||
timeInterval = 20
|
||||
break
|
||||
case "thirtysec":
|
||||
timeInterval = 30
|
||||
break
|
||||
case "onemin":
|
||||
timeInterval = 60
|
||||
break
|
||||
case "fivemin":
|
||||
timeInterval = 300
|
||||
break
|
||||
case "tenmin":
|
||||
timeInterval = 600
|
||||
break
|
||||
case "thirtymin":
|
||||
timeInterval = 1800
|
||||
break
|
||||
case "onehour":
|
||||
timeInterval = 3600
|
||||
break
|
||||
default:
|
||||
timeInterval = 3600
|
||||
};
|
||||
debugger;
|
||||
//showLoading();
|
||||
var datapa = {
|
||||
"StartTime": Date.parse(new Date(datetimestart)), "EndTime": Date.parse(new Date(datetimeend)), "Interval": timeInterval
|
||||
};
|
||||
//var datapa = { "StartTime": datetimestart, "EndTime": datetimeend, "Interval": timeInterval };
|
||||
debugger;
|
||||
let result = "";
|
||||
let first = "";
|
||||
let second = "";
|
||||
var start1 = Date.now();
|
||||
await $.ajax({
|
||||
url: "/ReportManage/HistoryReport/GetReportNew",
|
||||
type: "POST",
|
||||
//dataType: "json",
|
||||
//async: false,
|
||||
data: datapa,
|
||||
dataType: "text",
|
||||
//contentType:"text/html",
|
||||
beforeSend: function (XMLHttpRequest) {
|
||||
XMLHttpRequest.setRequestHeader("accept-encoding", "gzip");
|
||||
XMLHttpRequest.setRequestHeader("accept", "text/html; charset=utf-8");
|
||||
},
|
||||
success: function (redata) {
|
||||
|
||||
var start = Date.now();
|
||||
result = JSON.parse(redata);
|
||||
|
||||
var end = Date.now();
|
||||
console.log(end - start);
|
||||
debugger;
|
||||
}
|
||||
});
|
||||
var end1 = Date.now();
|
||||
console.log(end1 - start1);
|
||||
await $.ajax({
|
||||
url: "/ReportManage/HistoryReport/GetReportFirstHead",
|
||||
type: "GET",
|
||||
//dataType: "json",
|
||||
//async: false,
|
||||
//data: datapa,
|
||||
success: function (refirst) {
|
||||
first = JSON.parse(refirst);
|
||||
debugger;
|
||||
}
|
||||
});
|
||||
|
||||
await $.ajax({
|
||||
url: "/ReportManage/HistoryReport/GetReportSecondHead",
|
||||
type: "GET",
|
||||
//dataType: "json",
|
||||
//async: false,
|
||||
//data: datapa,
|
||||
success: function (resecond) {
|
||||
second = JSON.parse(resecond);
|
||||
debugger;
|
||||
}
|
||||
});
|
||||
|
||||
let firstHead = new Array();
|
||||
let secondHead = new Array();
|
||||
let timeHead = {
|
||||
field: 'HDATETIME',
|
||||
title: '时间',
|
||||
align: 'center',
|
||||
width: 200,
|
||||
rowspan: 2,
|
||||
}
|
||||
firstHead.push(timeHead);
|
||||
for (var si = 0; si < second.length; si++) {
|
||||
let head = {
|
||||
align: 'center',
|
||||
title: second[si].HSYS,
|
||||
colspan: second[si].Head.length,
|
||||
}
|
||||
|
||||
|
||||
firstHead.push(head);
|
||||
|
||||
|
||||
for(var hi = 0; hi < second[si].Head.length;hi++){
|
||||
let shead = {
|
||||
field: second[si].Title[hi],
|
||||
title: second[si].Head[hi],
|
||||
align: 'center',
|
||||
width: 80,
|
||||
}
|
||||
|
||||
secondHead.push(shead);
|
||||
}
|
||||
}
|
||||
debugger;
|
||||
var ingd =0;
|
||||
var table = layui.table;
|
||||
table.render({
|
||||
elem: '#result',
|
||||
height: 'full-200',
|
||||
data: result,
|
||||
//editTrigger:'dblclick',
|
||||
cols: [
|
||||
firstHead,
|
||||
secondHead,
|
||||
],
|
||||
page:true,
|
||||
limit:15,
|
||||
done: function (res, curr, count) {
|
||||
debugger;
|
||||
// console.log(res)
|
||||
//var donestyle = "<style>.layui - table - cell { height: auto;overflow: visible;text - overflow: inherit;white - space: normal;word -break: break-all;}.layui - table - cell a {text- decoration: underline;}.layui - table - cell div {white - space: nowrap;overflow: hidden;text - overflow: ellipsis;min - height: 30px;line - height: 30px;}</style>"
|
||||
//var oDiv = document.querySelector("#tdemo");
|
||||
//oDiv.style.cssText = donestyle;
|
||||
//layui-table-cell laytable-cell-group
|
||||
//layui-table-cell laytable-cell-1-1-0
|
||||
//$(".layui-table-cell"). [800].style
|
||||
////解决表头宽度不够自动换行问题
|
||||
//$(".layui-table-cell").each(function (index, val) {
|
||||
// $(".layui-table-cell")[index].style.lineHeight = "20px !importanr";
|
||||
// $(".layui-table-cell")[index].style.verticalAlign = "middle";
|
||||
// $(".layui-table-cell")[index].style.height = "auto";
|
||||
// $(".layui-table-cell")[index].style.overflow = "visible";
|
||||
// $(".layui-table-cell")[index].style.textOverflow = "inherit";
|
||||
// $(".layui-table-cell")[index].style.whiteSpace = "normal";
|
||||
//});
|
||||
////解决操作栏因为内容过多换行问题
|
||||
//$(".layui-table-main tr").each(function (index, val) {
|
||||
// $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
|
||||
// $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
|
||||
//});
|
||||
////解决fixed固定,而导致的th高度不一致
|
||||
//$(".layui-table-header tr").each(function (index, val) {
|
||||
// $(".layui-table-fixed").each(function () {
|
||||
// $($(this).find(".layui-table-header thead th")[index]).height($(val).height());
|
||||
// });
|
||||
//});
|
||||
//$(".layui-table-header tr").each(function (index, val) {
|
||||
// $(".layui-table-fixed").each(function () {
|
||||
// $($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
|
||||
// });
|
||||
//});
|
||||
//$(".layui-table-main tr").each(function (index, val) {
|
||||
// $(".layui-table-fixed").each(function () {
|
||||
// $($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
|
||||
// });
|
||||
//});
|
||||
//$(".layui-table-main tr").each(function (index, val) {
|
||||
// $(".layui-table-fixed").each(function () {
|
||||
// $($(this).find(".layui-table-body tbody th")[index]).height($(val).height());
|
||||
// });
|
||||
//});
|
||||
|
||||
$('.layui-laypage-limits').hide();
|
||||
}
|
||||
});
|
||||
debugger;
|
||||
completeLoading();
|
||||
|
||||
};
|
||||
async function GetReportView() {
|
||||
debugger;
|
||||
showLoading();
|
||||
|
@ -9,6 +9,10 @@ using System;
|
||||
using System.Reflection;
|
||||
using HT.Cloud.Code;
|
||||
using HT.Cloud.Service;
|
||||
using Microsoft.AspNetCore.ResponseCompression;
|
||||
using System.IO.Compression;
|
||||
using System.Net.Sockets;
|
||||
using System.Linq;
|
||||
|
||||
namespace HT.Cloud.Web
|
||||
{
|
||||
@ -20,7 +24,30 @@ namespace HT.Cloud.Web
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
base.ConfigureServices(services);
|
||||
services.Configure<BrotliCompressionProviderOptions>(options =>
|
||||
{
|
||||
options.Level = CompressionLevel.Fastest;
|
||||
}).Configure<GzipCompressionProviderOptions>(options =>
|
||||
{
|
||||
options.Level = CompressionLevel.Fastest;
|
||||
}).AddResponseCompression(options =>
|
||||
{
|
||||
options.EnableForHttps = true;
|
||||
options.Providers.Add<BrotliCompressionProvider>();
|
||||
options.Providers.Add<GzipCompressionProvider>();
|
||||
options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
|
||||
{
|
||||
//"text/html",
|
||||
"json/html; charset=utf-8",
|
||||
"text/html; charset=utf-8",
|
||||
"application/xhtml+xml",
|
||||
"application/atom+xml",
|
||||
"image/svg+xml"
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
base.ConfigureServices(services);
|
||||
services.AddDefaultSwaggerGen(Assembly.GetExecutingAssembly().GetName().Name)
|
||||
.AddSqlSugar()
|
||||
.AddQuartz()
|
||||
@ -41,6 +68,9 @@ namespace HT.Cloud.Web
|
||||
// 返回数据首字母不小写,CamelCasePropertyNamesContractResolver是小写
|
||||
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
||||
});
|
||||
|
||||
|
||||
|
||||
//调试前端可更新
|
||||
services.AddControllersWithViews().AddRazorRuntimeCompilation();
|
||||
//清理缓存
|
||||
@ -57,8 +87,8 @@ namespace HT.Cloud.Web
|
||||
public override void Configure(IApplicationBuilder app)
|
||||
{
|
||||
base.Configure(app);
|
||||
//MVC路由
|
||||
app.UseMiddleware(typeof(GlobalExceptionMiddleware))
|
||||
//MVC路由
|
||||
app.UseMiddleware(typeof(GlobalExceptionMiddleware))
|
||||
.AddDefaultSwaggerGen()
|
||||
.UseEndpoints(endpoints =>
|
||||
{
|
||||
|
@ -12,7 +12,7 @@
|
||||
"LoginMultiple": false, // 是否允许一个账户在多处登录
|
||||
"AllowCorsSite": "http://localhost:8058", // 允许的其他站点访问Api
|
||||
"DBProvider": "SqlServer", //SqlServer //Oracle
|
||||
"DBConnectionString": "Data Source=192.168.110.36;Initial Catalog=HTSCADA;User Id= sa;Password= Sa1qaz;Integrated Security=False;Encrypt=True;TrustServerCertificate=True;",
|
||||
"DBConnectionString": "Data Source=192.168.110.32;Initial Catalog=SCADA;User Id= sa;Password= Sa1qaz;Integrated Security=False;Encrypt=True;TrustServerCertificate=True;",
|
||||
"DBCommandTimeout": 180, // 数据库超时时间,单位秒
|
||||
"CacheProvider": "Memory", // 缓存使用方式 Redis/Memory
|
||||
"RedisConnectionString": "127.0.0.1:6379", //docker部署 172.17.0.1
|
||||
|
BIN
HT.Cloud.Web/wwwroot/report/Report20230426135532.xlsx
Normal file
BIN
HT.Cloud.Web/wwwroot/report/Report20230426135532.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user