|
@@ -10,7 +10,6 @@ import freemarker.cache.StringTemplateLoader;
|
|
|
import freemarker.template.Configuration;
|
|
import freemarker.template.Configuration;
|
|
|
import freemarker.template.Template;
|
|
import freemarker.template.Template;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
-import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
|
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
|
|
import org.apache.commons.math3.distribution.TDistribution;
|
|
import org.apache.commons.math3.distribution.TDistribution;
|
|
@@ -29,7 +28,7 @@ public abstract class PVModel {
|
|
|
private Map[] chartTemplate;
|
|
private Map[] chartTemplate;
|
|
|
|
|
|
|
|
private List<String> chartNames;
|
|
private List<String> chartNames;
|
|
|
- private boolean isSupportItems;
|
|
|
|
|
|
|
+ private final boolean isSupportItems;
|
|
|
private String itemName;
|
|
private String itemName;
|
|
|
private int scale;
|
|
private int scale;
|
|
|
private String units;
|
|
private String units;
|
|
@@ -48,20 +47,20 @@ public abstract class PVModel {
|
|
|
this.itemName = configVO.getItemName();
|
|
this.itemName = configVO.getItemName();
|
|
|
this.isSupportItems = configVO.isSupportItems();
|
|
this.isSupportItems = configVO.isSupportItems();
|
|
|
|
|
|
|
|
- if(configVO.isUsingReportTemplate()){
|
|
|
|
|
|
|
+ if (configVO.isUsingReportTemplate()) {
|
|
|
this.reportTemplate = configVO.getReportTemplate();
|
|
this.reportTemplate = configVO.getReportTemplate();
|
|
|
cfg = new Configuration(Configuration.VERSION_2_3_30);
|
|
cfg = new Configuration(Configuration.VERSION_2_3_30);
|
|
|
StringTemplateLoader stringLoader = new StringTemplateLoader();
|
|
StringTemplateLoader stringLoader = new StringTemplateLoader();
|
|
|
- stringLoader.putTemplate(itemName+"Report", reportTemplate);
|
|
|
|
|
|
|
+ stringLoader.putTemplate(itemName + "Report", reportTemplate);
|
|
|
cfg.setTemplateLoader(stringLoader);
|
|
cfg.setTemplateLoader(stringLoader);
|
|
|
- if(StringUtils.isNotEmpty(configVO.getChartOption())) {
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(configVO.getChartOption())) {
|
|
|
chartTemplate = JSON.parseObject(configVO.getChartOption(), Map[].class);
|
|
chartTemplate = JSON.parseObject(configVO.getChartOption(), Map[].class);
|
|
|
chartNames = new ArrayList<>();
|
|
chartNames = new ArrayList<>();
|
|
|
for (Map chart : chartTemplate) {
|
|
for (Map chart : chartTemplate) {
|
|
|
String value = (String) chart.get("value");
|
|
String value = (String) chart.get("value");
|
|
|
String label = (String) chart.get("label");
|
|
String label = (String) chart.get("label");
|
|
|
chartNames.add(label);
|
|
chartNames.add(label);
|
|
|
- stringLoader.putTemplate( label + "Chart", value.replaceAll("\\s*|\t|\r|\n", ""));
|
|
|
|
|
|
|
+ stringLoader.putTemplate(label + "Chart", value.replaceAll("\\s*|\t|\r|\n", ""));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -183,13 +182,13 @@ public abstract class PVModel {
|
|
|
.toArray();
|
|
.toArray();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public String[] sheetNames(){
|
|
|
|
|
- if(isSupportItems) {
|
|
|
|
|
|
|
+ public String[] sheetNames() {
|
|
|
|
|
+ if (isSupportItems) {
|
|
|
String[] strings = itemName.split(",");
|
|
String[] strings = itemName.split(",");
|
|
|
return strings;
|
|
return strings;
|
|
|
}
|
|
}
|
|
|
return new String[]{itemName};
|
|
return new String[]{itemName};
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public abstract String[] tableNames();
|
|
public abstract String[] tableNames();
|
|
|
|
|
|
|
@@ -258,15 +257,15 @@ public abstract class PVModel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected String renderChartTemplate(Object ctx, int index, String filePath) {
|
|
protected String renderChartTemplate(Object ctx, int index, String filePath) {
|
|
|
- return renderTemplate(ctx,chartNames.get(index)+"Chart",filePath);
|
|
|
|
|
|
|
+ return renderTemplate(ctx, chartNames.get(index) + "Chart", filePath);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- protected String renderReportTemplate(Object ctx, String filePath) {
|
|
|
|
|
- return renderTemplate(ctx,itemName+"Report",filePath);
|
|
|
|
|
|
|
+ protected String renderReportTemplate(Object ctx, String filePath) {
|
|
|
|
|
+ return renderTemplate(ctx, itemName + "Report", filePath);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String renderTemplate(Object ctx, String name, String filePath) {
|
|
private String renderTemplate(Object ctx, String name, String filePath) {
|
|
|
- if(cfg != null) {
|
|
|
|
|
|
|
+ if (cfg != null) {
|
|
|
Writer out = new StringWriter(2048);
|
|
Writer out = new StringWriter(2048);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -277,7 +276,7 @@ public abstract class PVModel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return out.toString();
|
|
return out.toString();
|
|
|
- } else{
|
|
|
|
|
|
|
+ } else {
|
|
|
return EchartsFreemarkerUtils.generate(filePath, ctx);
|
|
return EchartsFreemarkerUtils.generate(filePath, ctx);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|