|
@@ -4,13 +4,17 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.lc.ibps.components.verification.model.InspectionConfigVO;
|
|
import com.lc.ibps.components.verification.model.InspectionConfigVO;
|
|
|
import com.lc.ibps.components.verification.regression.PolynomialRegression;
|
|
import com.lc.ibps.components.verification.regression.PolynomialRegression;
|
|
|
-import com.lc.ibps.components.verification.report.*;
|
|
|
|
|
|
|
+import com.lc.ibps.components.verification.report.ChartDTO;
|
|
|
|
|
+import com.lc.ibps.components.verification.report.ReportDataDTO;
|
|
|
|
|
+import com.lc.ibps.components.verification.report.TableDTO;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.apache.commons.math3.stat.StatUtils;
|
|
import org.apache.commons.math3.stat.StatUtils;
|
|
|
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
|
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
-import java.util.*;
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
public class LinearRangeAverageSlope extends PVModel {
|
|
public class LinearRangeAverageSlope extends PVModel {
|
|
|
|
|
|
|
@@ -114,120 +118,26 @@ public class LinearRangeAverageSlope extends PVModel {
|
|
|
return table;
|
|
return table;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public SheetDTO[] buildSheetDTO() {
|
|
|
|
|
- SheetDTO sheet = new SheetDTO("平均斜率");
|
|
|
|
|
- sheet.setReportDataDTO(buildReportTableDTO());
|
|
|
|
|
- sheet.setChartDataDTO(buildChartDTO());
|
|
|
|
|
- return new SheetDTO[]{sheet};
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String generateResult() {
|
|
public String generateResult() {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public Map<String, TableDTO> buildReportTableDTO() {
|
|
|
|
|
- Map<String, TableDTO> reports = new HashMap<>();
|
|
|
|
|
- reports.put("表1: 重复性差异检测结果", buildTable1DTO());
|
|
|
|
|
- reports.put("表2: 多项式回归分析结果", buildTable2DTO());
|
|
|
|
|
- reports.put("表3: 线性偏离计算结果", buildTable3DTO());
|
|
|
|
|
- return reports;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public Map<String, ChartDTO> buildChartDTO() {
|
|
|
|
|
- Map<String, ChartDTO> charts = new HashMap<>();
|
|
|
|
|
- charts.put("图1: 线性实验", buildChart1DTO());
|
|
|
|
|
- charts.put("图2: 线性评价差值点图", buildChart2DTO());
|
|
|
|
|
- return charts;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private ChartDTO buildChart2DTO() {
|
|
|
|
|
- ChartDTO chartDTO = new ChartDTO("linesForRange");
|
|
|
|
|
- double[][] data = new double[targetValues.length][2];
|
|
|
|
|
- for (int i = 0; i < data.length; i++) {
|
|
|
|
|
- data[i] = new double[]{i + 1, diffs[1][i]};
|
|
|
|
|
- }
|
|
|
|
|
-// chartDTO.setData(data);
|
|
|
|
|
- final HashMap<String, Object> config = new HashMap<>();
|
|
|
|
|
- config.put("yAxisUp", 0.1);
|
|
|
|
|
- config.put("yAxisLow", -0.1);
|
|
|
|
|
- config.put("data", JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect));
|
|
|
|
|
-
|
|
|
|
|
- chartDTO.setOption(EchartsFreemarkerUtils.generateChart("/scatter/linesForRange.ftl", config));
|
|
|
|
|
- return chartDTO;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private ChartDTO buildChart1DTO() {
|
|
|
|
|
- ChartDTO chartDTO = new ChartDTO("polynomialRegression");
|
|
|
|
|
- double[][] data = new double[targetValues.length][2];
|
|
|
|
|
- for (int i = 0; i < data.length; i++) {
|
|
|
|
|
- data[i] = new double[]{targetValues[i], means[i]};
|
|
|
|
|
- }
|
|
|
|
|
-// chartDTO.setData(data);
|
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
|
- map.put("data", JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect));
|
|
|
|
|
- chartDTO.setOption(EchartsFreemarkerUtils.generateChart("/scatter/polynomialRegression.ftl", map));
|
|
|
|
|
- return chartDTO;
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String[] sheetNames() {
|
|
|
|
|
+ return new String[0];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private TableDTO buildTable1DTO() {
|
|
|
|
|
-
|
|
|
|
|
- TableDTO table = new TableDTO();
|
|
|
|
|
- String[] header = {"标本号", "均值", "差值Diff", "Diff<sup>2</sup>/2", "%Diff", "%Diff<sup>2</sup>/2"};
|
|
|
|
|
- table.buildHeader(header);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- double[][] r = new double[specimensNum][6];
|
|
|
|
|
- double[][] doubles = transposeMatrix(diffs);
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < doubles.length; i++) {
|
|
|
|
|
- r[i] = ArrayUtils.add(doubles[i], 0, i + 1);
|
|
|
|
|
- }
|
|
|
|
|
- table.buildData(r, getScale());
|
|
|
|
|
- return table;
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String[] tableNames() {
|
|
|
|
|
+ return new String[0];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private TableDTO buildTable2DTO() {
|
|
|
|
|
-
|
|
|
|
|
- TableDTO table = new TableDTO();
|
|
|
|
|
- String[] header = {"阶别", "系数", "系数值", "SE<sub>i</sub>", "t 检验", "S<sub>y.x</sub>", "自由度"};
|
|
|
|
|
- table.buildHeader(header);
|
|
|
|
|
- table.getHeader()[0].put("merge", "true");
|
|
|
|
|
- table.getHeader()[5].put("merge", "true");
|
|
|
|
|
- table.getHeader()[6].put("merge", "true");
|
|
|
|
|
- String[][] r = new String[9][7];
|
|
|
|
|
- int i = 0;
|
|
|
|
|
- for (int j = 0; j < pr1.getParameters().length; j++) {
|
|
|
|
|
- r[i][0] = "1";
|
|
|
|
|
- r[i][1] = String.format("b%d", j);
|
|
|
|
|
- r[i][2] = format(pr1.getParameters()[j]);
|
|
|
|
|
- r[i][3] = format(pr1.getStdErrors()[j]);
|
|
|
|
|
- r[i][4] = format(pr1.gettValues()[j]);
|
|
|
|
|
- r[i][5] = format((pr1.getStdError()));
|
|
|
|
|
- r[i][6] = pr1.getDfDependent().toString();
|
|
|
|
|
- i++;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- table.buildData(r);
|
|
|
|
|
- return table;
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String[] chartNames() {
|
|
|
|
|
+ return new String[0];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private TableDTO buildTable3DTO() {
|
|
|
|
|
-
|
|
|
|
|
- TableDTO table = new TableDTO();
|
|
|
|
|
- String[] header = {"标本号", "x<sub>i</sub>", "p(x<sub>i</sub>)", "b<sub>0</sub>+b<sub>1</sub>x<sub>i</sub>", "DL<sub>i</sub>", "%DL<sub>i</sub>"};
|
|
|
|
|
- table.buildHeader(header);
|
|
|
|
|
-
|
|
|
|
|
- double[][] r = new double[specimensNum][6];
|
|
|
|
|
- double[][] doubles = transposeMatrix(dli);
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < doubles.length; i++) {
|
|
|
|
|
- r[i] = ArrayUtils.add(doubles[i], 0, i + 1);
|
|
|
|
|
- }
|
|
|
|
|
- table.buildData(r, getScale());
|
|
|
|
|
- return table;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
InspectionConfigVO config = new InspectionConfigVO("平均斜率", 1, 6,
|
|
InspectionConfigVO config = new InspectionConfigVO("平均斜率", 1, 6,
|
|
@@ -236,8 +146,8 @@ public class LinearRangeAverageSlope extends PVModel {
|
|
|
double[][] data = {{-0.01, -0.01}, {5.00, 4.99}, {10.18, 10.05}, {14.65, 14.65}, {19.57, 19.65}, {24.02, 24.09}};
|
|
double[][] data = {{-0.01, -0.01}, {5.00, 4.99}, {10.18, 10.05}, {14.65, 14.65}, {19.57, 19.65}, {24.02, 24.09}};
|
|
|
LinearRangeAverageSlope ep6 = new LinearRangeAverageSlope(data, config);
|
|
LinearRangeAverageSlope ep6 = new LinearRangeAverageSlope(data, config);
|
|
|
TableDTO tableDTO = ep6.buildDataTableDTO();
|
|
TableDTO tableDTO = ep6.buildDataTableDTO();
|
|
|
- Map<String, TableDTO> stringTableDTOMap = ep6.buildReportTableDTO();
|
|
|
|
|
- final Map<String, ChartDTO> stringChartDTOMap = ep6.buildChartDTO();
|
|
|
|
|
|
|
+ Map<String, TableDTO> stringTableDTOMap = ep6.buildTableDTO(0);
|
|
|
|
|
+ final Map<String, ChartDTO> stringChartDTOMap = ep6.buildChartDTO(0);
|
|
|
ReportDataDTO report = new ReportDataDTO();
|
|
ReportDataDTO report = new ReportDataDTO();
|
|
|
|
|
|
|
|
|
|
|