生成图片

master
夜笙歌 6 months ago
parent 9600486e91
commit d7f7b6d063

@ -15,33 +15,110 @@
<i class="fa icon-grid"></i> 测控点信息 <i class="fa icon-grid"></i> 测控点信息
</div> </div>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<a type="button" class="btn btn-box-tool" href="#" onclick="dept()" title="测控点信息"><i <a class="btn btn-box-tool" href="#" onclick="dept()" title="测控点信息" type="button"><i
class="fa fa-edit"></i></a> class="fa fa-edit"></i></a>
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i <button class="btn btn-box-tool" id="btnExpand" style="display:none;" title="展开" type="button"><i
class="fa fa-chevron-up"></i></button> class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i <button class="btn btn-box-tool" id="btnCollapse" title="折叠" type="button"><i
class="fa fa-chevron-down"></i></button> class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i> <button class="btn btn-box-tool" id="btnRefresh" title="刷新" type="button"><i class="fa fa-refresh"></i>
</button> </button>
</div> </div>
</div> </div>
<div class="ui-layout-content"> <div class="ui-layout-content">
<div id="tree" class="ztree"></div> <div class="ztree" id="tree"></div>
</div> </div>
</div> </div>
</div> </div>
<div class="ui-layout-center"> <div class="ui-layout-center">
<div class="container-div"> <div class="container-div">
<div class="row"> <div class="row">
<div class="centerDiv"> <div class="centerDiv centerDiv1">
<div id="temInfo" style="text-align: center;white-space: nowrap;font-size: 2vw"></div> <div id="temInfo1" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo" style="text-align: center;white-space: nowrap;font-size: 2vw"></div> <div id="timeInfo1" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv" style="width: 32vw;height:24vw;margin:0 auto;"> <div id="canvasDiv1" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas"></canvas> <canvas id="canvas1"></canvas>
</div>
</div>
<div class="centerDiv centerDiv2">
<div id="temInfo2" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo2" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv2" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas2"></canvas>
</div>
</div>
<div class="centerDiv centerDiv3">
<div id="temInfo3" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo3" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv3" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas3"></canvas>
</div>
</div>
<div class="centerDiv centerDiv4">
<div id="temInfo4" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo4" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv4" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas4"></canvas>
</div>
</div>
<div class="centerDiv centerDiv5">
<div id="temInfo5" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo5" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv5" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas5"></canvas>
</div>
</div>
<div class="centerDiv centerDiv6">
<div id="temInfo6" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo6" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv6" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas6"></canvas>
</div>
</div>
<div class="centerDiv centerDiv7">
<div id="temInfo7" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo7" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv7" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas7"></canvas>
</div>
</div>
<div class="centerDiv centerDiv8">
<div id="temInfo8" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo8" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv8" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas8"></canvas>
</div>
</div>
<div class="centerDiv centerDiv9">
<div id="temInfo9" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo9" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv9" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas9"></canvas>
</div>
</div>
<div class="centerDiv centerDiv10">
<div id="temInfo10" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo10" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv10" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas10"></canvas>
</div>
</div>
<div class="centerDiv centerDiv11">
<div id="temInfo11" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo11" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv11" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas11"></canvas>
</div>
</div>
<div class="centerDiv centerDiv12">
<div id="temInfo12" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="timeInfo12" style="text-align: center;white-space: nowrap;font-size: 0.8vw"></div>
<div id="canvasDiv12" style="width: 18vw;height:10vw;margin:0 auto;">
<canvas id="canvas12"></canvas>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
<th:block th:include="include :: footer"/> <th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/> <th:block th:include="include :: layout-latest-js"/>
@ -63,7 +140,6 @@
$('body').layout({initClosed: panehHidden, west__size: 245}); $('body').layout({initClosed: panehHidden, west__size: 245});
queryDeptTree() queryDeptTree()
let getColorByTemperature = {}
function getGradientColor(level, sum) { function getGradientColor(level, sum) {
// 确保级别在1到50之间 // 确保级别在1到50之间
@ -117,15 +193,19 @@
// 返回格式化的CSS颜色字符串 // 返回格式化的CSS颜色字符串
return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`; return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
} }
const getData = () => { const getData = () => {
$.post(prefix + '/newDataStreak', {monitorId}, (e) => { $.post(prefix + '/newDataStreak', {monitorId}, (e) => {
$('#temInfo').html(`<span style="color:#ff0000">最高温度:${e.rows?.[0]?.maxTemperature || ''}℃</span> <span style="color:#0b05f7">最低温度:${e.rows?.[0]?.minTemperature || ''}℃</span> <span style="color:#0066e4">平均温度:${e.rows?.[0]?.avgTemperature || ''}℃</span>`) for (let index = 1; index <= e.data.length; index++) {
$('#timeInfo').html(`<span style="color:#0b05f7">采集时间:${e.rows?.[0]?.collectTime || ''}</span> `) $('.centerDiv' + index).css({'display': 'inline-block'})
let getColorByTemperature = {}
$('#temInfo' + index).html(`<span style="color:#ff0000">最高温度:${e.data?.[index - 1]?.maxTemperature || ''}℃</span> <span style="color:#0b05f7">最低温度:${e.data?.[index - 1]?.minTemperature || ''}℃</span> <span style="color:#0066e4">平均温度:${e.data?.[index - 1]?.avgTemperature || ''}℃</span>`)
$('#timeInfo' + index).html(`<span style="color:#0b05f7">名称:${e.data?.[index - 1]?.monitorName || ''} 采集时间:${e.data?.[index - 1]?.collectTime || ''}</span> `)
let colors = [] let colors = []
let tems = [] let tems = []
for (i in e.rows[0]) { for (i in e.data[index - 1]) {
if (i.includes('site')) { if (i.includes('site')) {
tems.push(e?.rows?.[0]?.[i]) tems.push(e?.data?.[index - 1]?.[i])
} }
} }
let sum = Math.max(...tems) - Math.min(...tems) let sum = Math.max(...tems) - Math.min(...tems)
@ -136,15 +216,15 @@
} }
for (let i = 1; i <= 768; i++) { for (let i = 1; i <= 768; i++) {
colors.push(getColorByTemperature[e?.rows?.[0]?.['site' + i]]) colors.push(getColorByTemperature[e?.data?.[index - 1]?.['site' + i]])
} }
const canvas = document.getElementById('canvas'); const canvas = document.getElementById('canvas' + index);
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
// 设置canvas的宽度和高度 // 设置canvas的宽度和高度
const width = $('#canvasDiv').width(); const width = $('#canvasDiv' + index).width();
const height = ($('#canvasDiv').width() / 32) * 24; const height = ($('#canvasDiv' + index).width() / 32) * 24;
canvas.width = width; canvas.width = width;
canvas.height = height; canvas.height = height;
@ -167,7 +247,7 @@
const x = ((i - 1) % 32) * gridWidth; // 计算x坐标 const x = ((i - 1) % 32) * gridWidth; // 计算x坐标
const y = Math.floor((i - 1) / 32) * gridHeight; // 计算y坐标 const y = Math.floor((i - 1) / 32) * gridHeight; // 计算y坐标
if (Math.min(...tems) === e.rows[0]['site' + i]) { if (Math.min(...tems) === e.data[index - 1]['site' + i]) {
ctx.font = '12px Arial'; ctx.font = '12px Arial';
ctx.fillStyle = 'blue'; ctx.fillStyle = 'blue';
ctx.fillText('I', x + gridWidth / 2 - 6, y + gridHeight / 2 + 6); ctx.fillText('I', x + gridWidth / 2 - 6, y + gridHeight / 2 + 6);
@ -176,7 +256,7 @@
ctx.strokeText('I', x + gridWidth / 2 - 6, y + gridHeight / 2 + 6); ctx.strokeText('I', x + gridWidth / 2 - 6, y + gridHeight / 2 + 6);
} }
if (Math.max(...tems) === e.rows[0]['site' + i]) { if (Math.max(...tems) === e.data[index - 1]['site' + i]) {
ctx.font = '12px Arial'; ctx.font = '12px Arial';
ctx.fillStyle = '#fff'; ctx.fillStyle = '#fff';
ctx.fillText('A', x + gridWidth / 2 - 6, y + gridHeight / 2 + 6); ctx.fillText('A', x + gridWidth / 2 - 6, y + gridHeight / 2 + 6);
@ -186,6 +266,7 @@
} }
} }
}
}) })
} }
@ -204,7 +285,7 @@
function zOnClick(event, treeId, treeNode) { function zOnClick(event, treeId, treeNode) {
monitorId = treeNode.id; monitorId = treeNode.id;
console.log(111,monitorId) console.log(111, monitorId)
} }
} }
@ -234,11 +315,11 @@
</html> </html>
<style> <style>
.centerDiv { .centerDiv {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 1vw solid #fff; border: 1vw solid #fff;
border-radius: 0.25vw; border-radius: 0.25vw;
width: 20vw;
height: 19vw;
display: none;
margin-bottom: 6px;
} }
</style> </style>

Loading…
Cancel
Save