Skip to content

Commit ae34985

Browse files
committed
插件更新
1 parent 721afd9 commit ae34985

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+8432
-472
lines changed

TP.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ CREATE TABLE "ts_kv" (
155155
CONSTRAINT "ts_kv_pkey" PRIMARY KEY ("entity_type", "entity_id", "key", "ts")
156156
) WITH (oids = false);
157157
SELECT create_hypertable('ts_kv', 'ts',chunk_time_interval => 86400000000);
158-
CREATE INDEX "ts_kv_ts_idx" ON "ts_kv" USING btree ("ts" DESC);
158+
-- CREATE INDEX "ts_kv_ts_idx" ON "ts_kv" USING btree ("ts" DESC);
159159
COMMENT ON COLUMN "ts_kv"."entity_type" IS '类型:DEVICE';
160160
COMMENT ON COLUMN "ts_kv"."entity_id" IS '设备id';
161161
COMMENT ON COLUMN "ts_kv"."key" IS '字段';
162162
COMMENT ON COLUMN "ts_kv"."ts" IS '毫秒时间戳';
163163
COMMENT ON COLUMN "ts_kv"."dbl_v" IS '数值';
164-
CREATE TRIGGER "ts_insert_blocker" BEFORE INSERT ON "ts_kv" FOR EACH ROW EXECUTE FUNCTION _timescaledb_internal.insert_blocker();
164+
-- CREATE TRIGGER "ts_insert_blocker" BEFORE INSERT ON "ts_kv" FOR EACH ROW EXECUTE FUNCTION _timescaledb_internal.insert_blocker();
165165
CREATE TABLE "ts_kv_latest" (
166166
"entity_type" character varying(255) NOT NULL,
167167
"entity_id" character varying(36) NOT NULL,

extensions/formaldehyde/config.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
formaldehyde:
2+
type: 'app'
3+
name: '甲醛监测'
4+
device: '甲醛监测v1.0'
5+
description: '插件plug-in'
6+
version: '1.0.0'
7+
author: '字段【甲醛浓度,二氧化碳浓度】'
8+
email: ''
9+
widgets:
10+
formaldehyde_line:
11+
name: '甲醛曲线'
12+
description: '甲醛曲线图表'
13+
receiver: ''
14+
template: 'formaldehyde-line'
15+
fields:
16+
formaldehyde:
17+
name: '甲醛浓度'
18+
type: 3
19+
symbol: ''
20+
formaldehyde_value:
21+
name: '甲醛浓度'
22+
description: '值插件图表'
23+
receiver: ''
24+
template: 'formaldehyde-value'
25+
fields:
26+
formaldehyde:
27+
name: '甲醛浓度'
28+
type: 3
29+
symbol: ''
30+
formaldehyde_height:
31+
name: '甲醛当日最高值'
32+
description: '值插件图表'
33+
receiver: ''
34+
template: 'formaldehyde-height'
35+
fields:
36+
formaldehyde:
37+
name: '甲醛浓度'
38+
type: 3
39+
symbol: ''
40+
carbon_dioxide_value:
41+
name: '二氧化碳浓度'
42+
description: '值插件图表'
43+
receiver: ''
44+
template: 'carbon-dioxide-value'
45+
fields:
46+
carbon:
47+
name: '二氧化碳浓度'
48+
type: 3
49+
symbol: ''
50+
carbon_dioxide_line:
51+
name: '二氧化碳曲线'
52+
description: '曲线插件图表'
53+
receiver: ''
54+
template: 'carbon-dioxide-line'
55+
fields:
56+
carbon:
57+
name: '二氧化碳浓度'
58+
type: 3
59+
symbol: ''
60+
carbon_dioxide_height:
61+
name: '二氧化碳当日最高值'
62+
description: '值插件图表'
63+
receiver: ''
64+
template: 'carbon-dioxide-height'
65+
fields:
66+
carbon:
67+
name: '二氧化碳浓度'
68+
type: 3
69+
symbol: ''

extensions/formaldehyde/view/CarbonDioxideHeight.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
<template>
2+
<div class="chart-all-kA6iA2">
3+
<div class="chart-top-kA6iA2">
4+
<div style="
5+
text-align:center;
6+
color: #fff;
7+
width: 100%;
8+
white-space: nowrap;
9+
overflow: hidden;
10+
text-overflow: ellipsis;
11+
">二氧化碳浓度当日最高值</div>
12+
<!-- <div style="color: #5b92ff">Noise concentration</div> -->
13+
</div>
14+
<div class="chart-body-kA6iA2" :id="'chart_' + id"></div>
15+
</div>
16+
</template>
17+
<script>
18+
// import * as echarts from "echarts";
19+
export default {
20+
props: {
21+
id: {
22+
type: Number,
23+
default: 0,
24+
},
25+
loading: {
26+
type: Boolean,
27+
default: true,
28+
},
29+
apiData: {
30+
type: Object,
31+
},
32+
legend: {
33+
type: Boolean,
34+
default: true,
35+
},
36+
},
37+
data() {
38+
return {
39+
latest: {},
40+
fields: [],
41+
chart: null,
42+
systime: '',
43+
theTime: '',
44+
hValue: 0
45+
};
46+
},
47+
watch: {
48+
apiData: {
49+
//document.getElementById('ElementId').removeAttribute("style")
50+
//style="width: 100%; height: 100%"
51+
//apiData的数据样例,fields是传感器一段时间内的数据,latest是传感器最新数据
52+
// {
53+
// "device_id": "f1ab2c47-951f-10b8-60c0-c6b33440f189",
54+
// "fields": [
55+
// {
56+
// "hum": 24,
57+
// "systime": "2022-01-18 18:59:11",
58+
// "temp": 26
59+
// },
60+
// {
61+
// "hum": 24,
62+
// "systime": "2022-01-18 18:59:17",
63+
// "temp": 26
64+
// },
65+
// {
66+
// "hum": 24,
67+
// "systime": "2022-01-18 18:59:41",
68+
// "temp": 26
69+
// }
70+
// ],
71+
// "latest": {
72+
// "hum": 24,
73+
// "systime": "2022-01-18 18:59:41",
74+
// "temp": 26
75+
// }
76+
// }
77+
// deep: true,
78+
immediate: true,
79+
handler(val, oldVal) {
80+
console.log("01-kA6iA2-图表接收到数据");
81+
console.log("02-kA6iA2-图表id:" + this.id);
82+
if (val["fields"]) {
83+
console.log("03-kA6iA2-fields有值");
84+
console.log("04-kA6iA2-device_id:" + val["device_id"]);
85+
this.latest = val["latest"];
86+
this.fields = val["fields"];
87+
this.getData();
88+
} else {
89+
console.log("05-kA6iA2-fields没有值");
90+
}
91+
},
92+
},
93+
colorStart() { },
94+
colorEnd() { },
95+
legend(val, oldVal) {
96+
this.chart.setOption({
97+
legend: {
98+
show: val,
99+
},
100+
});
101+
},
102+
},
103+
mounted() {
104+
this.initChart();
105+
const resizeObserver = new ResizeObserver((entries) => {
106+
//回调,重置图表大小
107+
this.chart && this.chart.resize();
108+
});
109+
resizeObserver.observe(document.getElementById("chart_" + this.id));
110+
},
111+
methods: {
112+
getData() {
113+
if (this.latest.systime.substr(0, 10) > this.theTime) {
114+
this.theTime = this.latest.systime.substr(0, 10)
115+
console.log(this.theTime)
116+
}
117+
for (var i = 0; i < this.fields.length; i++) {
118+
if (this.theTime == this.fields[i].systime.substr(0, 10)) {
119+
if (this.hValue < this.fields[i].carbon) {
120+
this.hValue = this.fields[i].carbon
121+
}
122+
}
123+
}
124+
this.initChart();
125+
// setTimeout(() => {
126+
// this.initChart();
127+
// }, 1000);
128+
},
129+
initChart() {
130+
console.log("05-kA6iA2-初始化图表开始");
131+
this.chart = echarts.init(document.getElementById("chart_" + this.id));
132+
var option = {
133+
title: {
134+
text: ''
135+
},
136+
legend: {
137+
data: []
138+
},
139+
tooltip: {
140+
trigger: 'axis',
141+
axisPointer: {
142+
type: 'shadow'
143+
}
144+
},
145+
grid: {
146+
containLabel: true,
147+
top: '100px',
148+
left: 0,
149+
bottom: '10px',
150+
},
151+
yAxis: {
152+
data: [],
153+
inverse: true,
154+
axisLine: { show: false },
155+
axisTick: { show: false },
156+
axisLabel: {
157+
margin: 0,
158+
fontSize: 14,
159+
},
160+
axisPointer: {
161+
label: {
162+
show: true,
163+
margin: 0
164+
}
165+
}
166+
},
167+
xAxis: {
168+
splitLine: { show: false },
169+
axisLabel: { show: false },
170+
axisTick: { show: false },
171+
axisLine: { show: false }
172+
},
173+
series: [{
174+
itemStyle: {
175+
color: '#5E94FC',
176+
},
177+
name: '二氧化碳',
178+
type: 'pictorialBar',
179+
label: {
180+
normal: {
181+
formatter: '{c}{title| ppm}',
182+
rich: {
183+
title: {
184+
color: '#5B92FF',
185+
fontSize: '16px',
186+
align: 'center'
187+
},
188+
},
189+
show: true,
190+
position: 'left,top',
191+
offset: [10, -30],
192+
textStyle: {
193+
fontSize: 50
194+
},
195+
color: '#fff'
196+
}
197+
},
198+
symbolRepeat: true,
199+
symbolSize: ['7%', '50%'],
200+
barCategoryGap: '0%',
201+
data: [{
202+
value: this.hValue,
203+
symbol: 'roundRect',
204+
205+
// symbol: 'media/bg/chart-img.png',
206+
}]
207+
}]
208+
};
209+
//this.chart.clear();
210+
this.chart.setOption(option);
211+
// window.addEventListener("resize", () => {
212+
// this.chart.resize();
213+
// });
214+
console.log("06-kA6iA2-初始化图表完成");
215+
},
216+
/**
217+
* 重置图表大小
218+
*/
219+
resizeChart() {
220+
/* eslint-disable no-unused-expressions */
221+
this.chart && this.chart.resize();
222+
},
223+
},
224+
};
225+
</script>
226+
<style scoped>
227+
.chart-all-kA6iA2 {
228+
width: 100%;
229+
height: 100%;
230+
/* position: absolute;
231+
top: 50%;
232+
left: 50%;
233+
transform: translate(-50%, -50%); */
234+
/* border: 1px solid rgb(41, 189, 139); */
235+
}
236+
237+
.chart-top-kA6iA2 {
238+
padding-left: 0px;
239+
left: 0px;
240+
top: 0px;
241+
width: 100%;
242+
height: 20px;
243+
box-sizing: border-box;
244+
/* border: 2px solid rgb(24, 222, 50); */
245+
}
246+
247+
.chart-body-kA6iA2 {
248+
width: 100%;
249+
height: calc(100% - 50px);
250+
/* border: 2px solid rgb(201, 26, 26); */
251+
}
252+
</style>

0 commit comments

Comments
 (0)