代码调整

This commit is contained in:
2023-04-18 10:38:26 +08:00
parent 7a906d8088
commit 700ddb2a87
18 changed files with 911 additions and 5 deletions

View File

@@ -134,6 +134,8 @@ public class ReportServiceImpl implements ReportService {
private final MonitorClient monitorClient;
private final EventDetailService eventDetailService;
private final FreemarkerUtil freemarkerUtil;
public List<EventDetail> getED(DeviceInfoParam.BusinessParam businessParam) {
List<EventDetail> info = new ArrayList<>();
List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
@@ -1643,7 +1645,7 @@ public class ReportServiceImpl implements ReportService {
public String getStr(String barName, Map<String, Object> map) throws TemplateException, IOException {
String s = FreemarkerUtil.generateString(barName, "com/njcn/event/template", map);
String s = freemarkerUtil.generateString(barName, "com/njcn/event/template", map);
return EchartsUtil.generateEchartsBase64(s, "8910");
}

View File

@@ -3,6 +3,9 @@ package com.njcn.event.utils;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import java.io.File;
import java.io.IOException;
@@ -14,10 +17,13 @@ import java.util.Map;
* @version 1.0.0
* @date 2022年08月23日 19:32
*/
@Component
public class FreemarkerUtil {
@Autowired
FreeMarkerConfigurer freeMarkerConfigurer;
private static String path = FreemarkerUtil.class.getClassLoader().getResource("").getPath();
public static String generateString(String templateFileName, String templateDirectory, Map<String, Object> datas)
public String generateString(String templateFileName, String templateDirectory, Map<String, Object> datas)
throws IOException, TemplateException {
Configuration configuration = new Configuration(Configuration.VERSION_2_3_0);
// 设置默认编码
@@ -30,7 +36,7 @@ public class FreemarkerUtil {
configuration.setDirectoryForTemplateLoading(new File(path + templateDirectory));
// 生成模板对象
Template template = configuration.getTemplate(templateFileName);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(templateFileName);
// 将datas写入模板并返回
try (StringWriter stringWriter = new StringWriter()) {

View File

@@ -38,8 +38,8 @@ public class TestTemplate {
}
map.put("point",JSONArray.fromObject(floatData).toString());
String s = FreemarkerUtil.generateString("bar.ftl", "com/njcn/event/template", map);
System.out.println(EchartsUtil.generateEchartsBase64(s,"8910"));
// String s = freemarkerUtil.generateString("bar.ftl", "com/njcn/event/template", map);
// System.out.println(EchartsUtil.generateEchartsBase64(s,"8910"));

View File

@@ -0,0 +1,86 @@
<#--区域统计和电压等级共用模板-->
{
title: {
text: '设备运行情况',
left:'center',
subtext:'${subtext}',
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: ['在线', '离线',],
left: '10%',
top:'5%',
textStyle: {
color: "#666666"
},
itemWidth: 15,
itemHeight: 10,
itemGap: 25
},
grid: {
left: '3%',
right: '8%',
bottom: '5%',
top: '20%',
containLabel: true
},
xAxis: {
name: '${xname}',
nameTextStyle: {
color: '#666666',
},
type: 'category',
data: ${area}
},
yAxis: {
name: '(个)',
nameTextStyle: {
color: '#666666',
},
type: 'value',
axisLine: { show: true, lineStyle: { color: '#666666' } },
axisLabel: { color: '#666666' },
splitLine: { lineStyle: { color: ['#ccc'], type: [5, 8], dashOffset: 3 } },
},
series: [
{
name: '在线',
type: 'bar',
stack: 'account',
barWidth: 20,
label: {
show: true,
color:'purple',
verticalAlign: 'middle',
rotate: 0,
fontSize: 12,
},
color:'green',
itemStyle: {
},
data: ${onlineData}
},
{
name: '离线',
type: 'bar',
stack: 'account',
barWidth: 20,
label: {
show: true,
color:'purple',
verticalAlign: 'middle',
rotate: 0,
fontSize: 12,
},
color:'orange',
itemStyle: {
},
data: ${offlineData}
}
]
}

View File

@@ -0,0 +1,103 @@
<#--区域和电压等级统计次数共用模板-->
{
title: {
text: '暂态事件次数',
left:'center',
subtext:'${subtext}',
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: ['暂降次数', '中断次数', '暂升次数'],
left: '7%',
top:'5%',
textStyle: {
color: "#666666"
},
itemWidth: 10,
itemHeight: 10,
itemGap: 15
},
grid: {
left: '3%',
right: '8%',
bottom: '5%',
top: '20%',
containLabel: true
},
xAxis: {
name: '${xname}',
nameTextStyle: {
color: '#666666',
},
type: 'category',
data: ${area}
},
yAxis: {
name: '(次)',
nameTextStyle: {
color: '#666666',
},
type: 'value',
axisLine: { show: true, lineStyle: { color: '#666666' } },
axisLabel: { color: '#666666' },
splitLine: { lineStyle: { color: ['#ccc'], type: [5, 8], dashOffset: 3 } },
},
series: [
{
name: '暂降次数',
type: 'bar',
stack: 'account',
barWidth: 20,
label: {
show: true,
color:'purple',
verticalAlign: 'middle',
rotate: 0,
fontSize: 12,
},
color:'#ff9966',
itemStyle: {
},
data: ${sag}
},
{
name: '中断次数',
type: 'bar',
stack: 'account',
barWidth: 20,
label: {
show: true,
color:'purple',
verticalAlign: 'middle',
rotate: 0,
fontSize: 12,
},
color:'#00dd00',
itemStyle: {
},
data: ${break}
},
{
name: '暂升次数',
type: 'bar',
stack: 'account',
barWidth: 20,
label: {
show: true,
color:'purple',
verticalAlign: 'middle',
rotate: 0,
fontSize: 12,
},
color:'#0066ff',
itemStyle: {
},
data: ${up}
},
]
}

View File

@@ -0,0 +1,85 @@
<#--ITIC曲线专用-->
{
backgroundColor: "#FFF",
title: {
text: "ITIC曲线",
x: "center",
},
grid: {
left: "4%",
right: "2%",
bottom: "10%",
},
legend: {
data: ["上限", "下限", "可容忍事件", "不可容忍事件"],
x: "left",
},
color: ["#FF8C00", "#00BFFF", "green", "red"],
xAxis: [
{
type: "log",
min: "0.001",
max: "1000",
splitLine: {
show: false,
},
name: "s",
},
],
yAxis: [
{
type: "value",
splitNumber: 10,
minInterval: 3,
name: "%"
},
],
series: [
{
name: "上限",
type: "line",
data: [
[0.001, 200],
[0.003, 140],
[0.003, 120],
[0.5, 120],
[0.5, 110],
[10, 110],
[1000, 110]
],
showSymbol: false,
tooltips: {
show: false
},
},
{
name: "下限",
type: "line",
data: [
[0.02, 0],
[0.02, 70],
[0.5, 70],
[0.5, 80],
[10, 80],
[10, 90],
[1000, 90]
],
showSymbol: false,
tooltips: {
show: false
},
},
{
name: "可容忍事件",
type: "scatter",
symbol: "circle",
data: ${point}
},
{
name: "不可容忍事件",
type: "scatter",
symbol: "circle",
data: ${pointno}
}
]
}

View File

@@ -0,0 +1,61 @@
<#--F47曲线图专用模板-->
{
backgroundColor: "#fff",
title: {
text: "SEMI F47曲线",
x: "center",
},
grid: {
left: "4%",
right: "5%",
bottom: "10%",
},
legend: {
data: ["边界线", "可容忍事件", "不可容忍事件"],
x: "left",
},
color: ["yellow", "green", "red"],
xAxis: [
{
type: "log",
min: "0.001",
max: "1000",
splitLine: {
show: false,
},
name: "s",
},
],
yAxis: [
{
type: "value",
max: ${zdz} + 20,
splitNumber: 10,
minInterval: 0.1,
name: "%",
},
],
series: [
{
name: "边界线",
type: "line",
data: ${bjx},
showSymbol: false,
tooltips: {
show: false,
},
},
{
name: "可容忍事件",
type: "scatter",
symbol: "circle",
data: ${point}
},
{
name: "不可容忍事件",
type: "scatter",
symbol: "circle",
data: ${pointno}
}
]
}

View File

@@ -0,0 +1,93 @@
<#--暂降幅值的概率分布函数专用模板-->
{
backgroundColor: "#fff",
title: {
text: "暂降幅值的概率分布函数",
x: "center"
},
grid: {
left: "10%",
right: "10%",
bottom: "15%"
},
toolbox: {
show: true,
feature: {
restore: { show: true },
saveAsImage: { show: true },
},
},
tooltip: {
trigger: "axis",
formatter: "暂降幅值: {b0}<br />概率分布: {c0}%",
},
legend: {
show: true,
left: 10,
data: ["概率分布", "占比"],
},
calculable: true,
xAxis: [
{
type: "category",
boundaryGap: false,
name: "暂降幅值",
nameLocation: "center",
nameGap: 20,
nameTextStyle: {
fontSize: 15,
},
data: [
"0",
"10%",
"20%",
"30%",
"40%",
"50%",
"60%",
"70%",
"80%",
"90%",
],
},
],
yAxis: [
{
type: "value",
name: "概率分布",
nameLocation: "center",
nameGap: 40,
nameTextStyle: {
fontSize: 15,
},
axisLabel: {
formatter: "{value} %",
},
},
{
type: "value",
name: "占比",
nameLocation: "center",
nameGap: 40,
nameTextStyle: {
fontSize: 15,
},
axisLabel: {
formatter: "{value} %",
},
},
],
series: [
{
name: "概率分布",
type: "line",
data: ${eventValue},
},
{
name: "占比",
type: "bar",
data: ${pereventValue},
barWidth: 30
}
]
}

View File

@@ -0,0 +1,71 @@
<#--持续时间的概率分布函数专用模板-->
{
backgroundColor: "#fff",
title: {
text: "持续时间的概率分布函数",
x: "center",
},
legend: {
show: true,
left: 10,
data: ["概率分布", "占比"],
},
calculable: true,
grid: {
left: "10%",
right: "10%",
bottom: "15%"
},
xAxis: [
{
type: "category",
boundaryGap: false,
name: "暂降持续时间(s)",
nameLocation: "center",
nameGap: 20,
nameTextStyle: {
fontSize: 15,
},
data: ["0.01", "0.1", "0.25", "0.5", "1", "3", "20", "60", "180"],
},
],
yAxis: [
{
type: "value",
name: "概率分布",
nameLocation: "center",
nameGap: 40,
nameTextStyle: {
fontSize: 15,
},
axisLabel: {
formatter: "{value} %",
},
},
{
type: "value",
name: "占比",
nameLocation: "center",
nameGap: 40,
nameTextStyle: {
fontSize: 15,
},
axisLabel: {
formatter: "{value} %",
},
},
],
series: [
{
name: "概率分布",
type: "line",
data: ${sisttime},
},
{
name: "占比",
type: "bar",
data: ${persisttime},
barWidth: 30,
}
]
}

View File

@@ -0,0 +1,58 @@
<#--月份统计专用模板-->
{
backgroundColor: "#fff",
title: {
text: "${text}",
x: "center",
},
color: ["#FF8C00"],
legend: {
data: ["暂降次数"],
x: "left",
},
grid: {
left: "3%",
bottom: "3%",
right: "7%",
containLabel: true,
},
xAxis: [
{
type: "category",
data: ${months},
name: "${xname}",
splitLine: {
show: false,
},
axisLabel: {
show: true,
interval: 0,
},
},
],
yAxis: [
{
type: "value",
name: "次",
},
],
series: [
{
name: "暂降次数",
type: "bar",
barMaxWidth: 45,
itemStyle: {
normal: {
label: {
show: true,
textStyle: {
label: { show: true, position: "top" },
color: "#8B008B",
},
},
},
},
data: ${handle},
}
]
}

View File

@@ -0,0 +1,49 @@
<#--类型专用模板-->
{
backgroundColor: '#fff',
animation: false,
title: {
text: '暂降类型',
x: 'center',
},
legend: {
orient: 'vertical',
left: 'left',
data: ${typeArray}
},
series: [
{
name: '暂降类型',
type: 'pie',
radius: '70%',
center: ['50%', '60%'],
label: {
normal: {
show: false
},
emphasis: {
show: true
}
},
lableLine: {
normal: {
show: false
},
emphasis: {
show: true
}
},
data: [<#list valueArray as a>
{value:${a.times?c},
name:'${a.type}'},
</#list>],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
}

View File

@@ -0,0 +1,49 @@
<#--暂降原因专用模板-->
{
backgroundColor: '#fff',
animation: false,
title: {
text: '暂降原因',
x: 'center'
},
legend: {
orient: 'vertical',
left: 'left',
data: ${typeArray}
},
series: [
{
name: '暂降原因',
type: 'pie',
radius: '70%',
center: ['50%', '53%'],
label: {
normal: {
show: false
},
emphasis: {
show: true
}
},
lableLine: {
normal: {
show: false
},
emphasis: {
show: true
}
},
data: [<#list valueArray as a>
{value:${a.times?c},
name:'${a.reason}'},
</#list>],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
}

View File

@@ -0,0 +1,66 @@
{
backgroundColor: "#FFF",
title: {
text: '电压等级',
x: 'center'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: function (params) {
var tips = "";
tips += params[0].name ;
for (var i = 0; i < params.length; i++) {
tips += params[i].seriesName + ":" + params[i].value ;
}
return tips;
}
},
color: ['orange'],
legend: {
data: ['暂降次数'],
selectedMode: false,
x: 'left'
},
grid: {
left: '3%',
right: '12%',
bottom: '6%',
containLabel: true
},
xAxis: [{
type: 'category',
data: ${xvalue},
splitLine: {
show: false
},
name: '电压等级\n(监测点数)',
axisLabel: {
interval: 0,
show: true,
fontSize:10
}
}],
yAxis: [{
type: 'value',
name: '(次)'
}],
series: [{
name: '暂降次数',
type: 'bar',
itemStyle: {
normal: {
label: {
show: true,
textStyle: {
color: 'purple'
}
}
}
},
data: ${yvalue},
barMaxWidth: 45
}]
}

View File

@@ -0,0 +1,68 @@
{
backgroundColor: '#FFF',
title: {
text: '区域统计',
x: 'center'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: function (params) {
var tips = "";
tips += params[0].name ;
for (var i = 0; i < params.length; i++) {
tips += params[i].seriesName + ":" + params[i].value ;
}
return tips;
}
},
color: ['orange'],
grid: {
left: '1%',
right: '7%',
bottom: '8%',
containLabel: true
},
legend: {
data: ['暂降次数'],
selectedMode: false,
x: 'left'
},
xAxis: [{
type: 'category',
data: ${xvalue},
splitLine: {
show: false
},
name: '地区\n(监测点数)',
axisLabel: {
interval: 0,
show: true,
rotate:0,
fontSize:10
}
}],
yAxis: [{
type: 'value',
name: '(次)'
}],
series: [{
name: '暂降次数',
type: 'bar',
itemStyle: {
normal: {
label: {
show: true,
textStyle: {
color: 'purple'
}
}
}
},
data: ${yvalue},
barMaxWidth: 45
}],
}

View File

@@ -0,0 +1,12 @@
{
animation:false,
xAxis: {},
yAxis: {},
series: [
{
symbolSize: 2,
data: ${bdata},
type: 'scatter'
}
]
}

View File

@@ -0,0 +1,76 @@
{
backgroundColor: "#FFF",
title: {
text: ${test},
x: 'center'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: function (params) {
var tips = "";
tips += params[0].name ;
for (var i = 0; i < params.length; i++) {
tips += params[i].seriesName + ":" + params[i].value;
}
return tips;
}
},
grid: {
left: '3%',
bottom: '6%',
containLabel: true
},
legend: {
data: ['未关联暂降次数', '已关联处理事件'],
x: 'left'
},
xAxis: [{
type: 'category',
data:${xvalue},
name: ${test},
splitLine: {
show: false
},
axisLabel: {
show: true,
interval: 0,
fontSize:10
}
}],
yAxis: [{
type: 'value',
name: '次'
}],
series: [{
name: '未关联暂降次数',
type: 'bar',
stack: '事件总数',
barMaxWidth: 45,
itemStyle: {
normal: {
color: 'orange',
barBorderColor: 'orange',
barBorderWidth: 2,
barBorderRadius: 0
}
},
data: ${yvalue1}
}, {
name: '已关联处理事件',
type: 'bar',
stack: '事件总数',
barMaxWidth: 45,
itemStyle: {
normal: {
color: "#ccc",
barBorderColor: '#ccc',
barBorderWidth: 2,
barBorderRadius: 0
}
},
data: ${yvalue2}
}]
}

View File

@@ -0,0 +1,18 @@
package com.njcn;
import com.njcn.harmonic.HarmonicBootApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年12月10日 15:05
*/
@RunWith(SpringRunner.class)
@WebAppConfiguration
@SpringBootTest(classes = HarmonicBootApplication.class)
public class BaseJunitTest {
}

View File

@@ -9,6 +9,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.pojo.dto.AreaTreeDTO;
import com.njcn.system.pojo.param.AreaParam;
import com.njcn.system.pojo.po.Area;
@@ -41,6 +42,8 @@ public class AreaController extends BaseController {
private final IAreaService areaService;
private final FileStorageUtil fileStorageUtil;
/**
* 分页查询行政区域
*/