环境检测场景中的几个动态表单示例

最后更新:2023-10-18 19:31:26 | 状态:未完成
这里只是后格式转换部分,插入到word参考【anyline office】,最困难的是前端怎么把这个规则告知后端(大概思路是先定义几种规则让用户来选,比如横向显示什么,竖向显示什么,每行最多几列)
先看源数据

主键

样品编号

检测项

点位名称

日期

时间

频次

属性名

检测值

参考值

判断结果

ID

SAMPLE_CODE

ITEM_NAME

POINT_NAME

YMD

HMS

RT

FIELD_NAME

VAL

REF

CHK

1

SAMP001

A

2022-1-1

10:10:00

1次

深度

1

1

合格

2

SAMP001

A

2022-1-1

10:10:00

1次

含量

2

2

合格

3

SAMP001

CO2

A

2022-1-2

12:10:00

1次

浓度

1%

5%

合格

4

SAMP001

CO2

B

2022-1-2

15:30:00

1次

含量

6

1

不合格

5

SAMP001

CO2

C

2022-1-2

16:30:00

1次

深度

300

300

合格

6

SAMP001

硫化氢

A

2022-1-2

10:10:00

1次

含量

200

200

合格

7

SAMP001

硫化氢

C

2022-1-2

12:10:00

1次

浓度

100

100

合格

8

SAMP001

A

2022-1-1

10:10:00

2次

深度

11

11

合格

9

SAMP001

A

2022-1-1

10:10:00

2次

含量

21

21

合格

10

SAMP001

CO2

A

2022-1-2

12:10:00

2次

浓度

11%

2%

不合格

11

SAMP001

CO2

B

2022-1-2

15:30:00

2次

含量

31

20

不合格

12

SAMP001

CO2

C

2022-1-2

16:30:00

2次

深度

3001

3001

合格

13

SAMP001

硫化氢

A

2022-1-2

10:10:00

2次

含量

2001

2001

合格

14

SAMP001

A

2022-1-1

10:10:00

3次

深度

11

11

合格

15

SAMP001

A

2022-1-1

10:10:00

3次

含量

21

21

合格

16

SAMP001

CO2

A

2022-1-2

12:10:00

3次

浓度

11%

2%

不合格

17

SAMP001

CO2

B

2022-1-2

15:30:00

3次

含量

31

20

不合格

18

SAMP001

CO2

C

2022-1-2

16:30:00

3次

深度

33

22

合格

19

SAMP001

硫化氢

A

2022-1-2

10:10:00

4次

含量

99

2001

合格

20

SAMP001

A

2022-1-1

10:10:00

4次

深度

11

11

合格

21

SAMP001

A

2022-1-1

10:10:00

4次

含量

21

21

合格

22

SAMP001

CO2

A

2022-1-2

12:10:00

4次

浓度

11%

2%

不合格

23

SAMP001

CO2

B

2022-1-2

15:30:00

4次

含量

31

20

不合格

24

SAMP001

CO2

C

2022-1-2

16:30:00

4次

深度

77

3001

合格

25

SAMP001

硫化氢

A

2022-1-2

10:10:00

4次

含量

22

2001

合格

26

SAMP001

硫化氢

A

2022-1-2

10:10:00

5次

含量

55

2001

合格

27

SAMP001

A

2022-1-1

10:10:00

5次

深度

11

11

合格

28

SAMP001

A

2022-1-1

10:10:00

5次

含量

6

21

合格

29

SAMP001

CO2

A

2022-1-2

12:10:00

5次

浓度

15%

2%

不合格

30

SAMP001

CO2

B

2022-1-2

15:30:00

5次

含量

5

20

不合格

31

SAMP001

CO2

C

2022-1-2

16:30:00

5次

深度

301

3001

合格


111//取出数据集

DataSet set = service.querys("rpt_check_result");


======================================取单列值 频次作表头=========================================


要求输出表格 

检测项

属性

1

2

3

4

5

深度

1

11

11

11

11

含量

2

21

21

21

6

CO2

浓度

1%

11%

11%

11%

15%

含量

6

31

31

31

5

深度

300

3001

33

77

301

硫化氢

含量

200

2001

#

99

55

浓度

100

#

#

#

#

 

String union = "ITEM_NAME";			//需要合同的列
String pks = "ITEM_NAME,FIELD_NAME";		//逻辑主键
String clazzKey = "RT";			//根据RT列的值把行转成列
String valueKey = "VAL";			//取值

String headers = "检测项,属性";			//显示的表头

DataSet ds = set.pivot(pks, clazzKey, valueKey);
List<String> clazzList = set.getDistinctStrings(clazzKey); //取出不重复的clazzKey值列表

Table table = TableBuilder.init()
      .setDatas(ds)						//设置数据源
      .setReplaceEmpty("#")					//替换空值成#
      .setHeaders(headers.split(",")).addHeaders(clazzList)	//添加表头 
	.setFields(pks.split(",")).addFields(clazzList)		//需要显示的属性与表头要对应
      .addUnions(union)						//需要合并的列
.build();



转换后格式


[
    {
        "ITEM_NAME":"铜",
        "FIELD_NAME":"深度",
        "第1次":"1",
        "第2次":"11",
        "第3次":"11",
        "第4次":"11",
        "第5次":"11"
    },
    {
        "ITEM_NAME":"铜",
        "FIELD_NAME":"含量",
        "第1次":"2",
        "第2次":"21",
        "第3次":"21",
        "第4次":"21",
        "第5次":"6"
    },
    {
        "ITEM_NAME":"CO2",
        "FIELD_NAME":"浓度",
        "第1次":"1%",
        "第2次":"11%",
        "第3次":"11%",
        "第4次":"11%",
        "第5次":"15%"
    },
    {
        "ITEM_NAME":"CO2",
        "FIELD_NAME":"含量",
        "第1次":"6",
        "第2次":"31",
        "第3次":"31",
        "第4次":"31",
        "第5次":"5"
    },
    {
        "ITEM_NAME":"CO2",
        "FIELD_NAME":"深度",
        "第1次":"300",
        "第2次":"3001",
        "第3次":"33",
        "第4次":"77",
        "第5次":"301"
    },
    {
        "ITEM_NAME":"硫化氢",
        "FIELD_NAME":"含量",
        "第1次":"200",
        "第2次":"2001",
        "第3次":null,
        "第4次":"99",
        "第5次":"55"
    },
    {
        "ITEM_NAME":"硫化氢",
        "FIELD_NAME":"浓度",
        "第1次":"100",
        "第2次":null,
        "第3次":null,
        "第4次":null,
        "第5次":null
    }
]


======================================取单列值 属性作表头=========================================


要求输出表格

检测项

频次

浓度

含量

深度

CO2

1

1%

6

300

2

11%

31

3001

3

11%

31

33

4

11%

31

77

5

15%

5

301

硫化氢

1

100

200

#

2

#

2001

#

4

#

99

#

5

#

55

#

1

#

2

1

2

#

21

11

3

#

21

11

4

#

21

11

5

#

6

11




union = "ITEM_NAME";             		//需需合并的列
pks = "ITEM_NAME,RT";          		 	//逻辑主键
clazzKey = "FIELD_NAME";         		//根据FIELD_NAME把行转成列
valueKey = "VAL";              			//取值
valueLabel = "检测值";
headers = "检测项,频次";             		//显示表头
set.order("ITEM_NAME");             		//排序
ds = set.pivot(pks, clazzKey,valueKey);
clazzList = set.getDistinctStrings(clazzKey);
html = TableBuilder.init()
      .setDatas(ds)                                                  //设置数据源
      .setReplaceEmpty("#")                                        //替换空值
      .setHeaders(headers.split(",")).addHeaders(clazzList) //设置表头
      .setFields(pks.split(",")).addFields(clazzList)        //需要显示的属性值与表头要对应
      .addUnions(union)                                            //合并列
      .build().build();


转换后格式:

[
    {
        "ITEM_NAME":"CO2",
        "RT":"第1次",
        "浓度":"1%",
        "含量":"6",
        "深度":"300"
    },
    {
        "ITEM_NAME":"CO2",
        "RT":"第2次",
        "浓度":"11%",
        "含量":"31",
        "深度":"3001"
    },
    {
        "ITEM_NAME":"CO2",
        "RT":"第3次",
        "浓度":"11%",
        "含量":"31",
        "深度":"33"
    },
    {
        "ITEM_NAME":"CO2",
        "RT":"第4次",
        "浓度":"11%",
        "含量":"31",
        "深度":"77"
    },
    {
        "ITEM_NAME":"CO2",
        "RT":"第5次",
        "浓度":"15%",
        "含量":"5",
        "深度":"301"
    },
    {
        "ITEM_NAME":"硫化氢",
        "RT":"第1次",
        "浓度":"100",
        "含量":"200",
        "深度":null
    },
    {
        "ITEM_NAME":"硫化氢",
        "RT":"第2次",
        "浓度":null,
        "含量":"2001",
        "深度":null
    },
    {
        "ITEM_NAME":"硫化氢",
        "RT":"第4次",
        "浓度":null,
        "含量":"99",
        "深度":null
    },
    {
        "ITEM_NAME":"硫化氢",
        "RT":"第5次",
        "浓度":null,
        "含量":"55",
        "深度":null
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第1次",
        "浓度":null,
        "含量":"2",
        "深度":"1"
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第2次",
        "浓度":null,
        "含量":"21",
        "深度":"11"
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第3次",
        "浓度":null,
        "含量":"21",
        "深度":"11"
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第4次",
        "浓度":null,
        "含量":"21",
        "深度":"11"
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第5次",
        "浓度":null,
        "含量":"6",
        "深度":"11"
    }
]


========================================取多列值 频次+类别作表头=================================

要求输出表格:

检测项

属性

1-检测值

1-参考值

1-判定结果

2-检测值

2-参考值

2-判定结果

3-检测值

3-参考值

3-判定结果

4-检测值

4-参考值

4-判定结果

5-检测值

5-参考值

5-判定结果

CO2

浓度

1%

5%

合格

11%

2%

不合格

11%

2%

不合格

11%

2%

不合格

15%

2%

不合格

含量

6

1

不合格

31

20

不合格

31

20

不合格

31

20

不合格

5

20

不合格

深度

300

300

合格

3001

3001

合格

33

22

合格

77

3001

合格

301

3001

合格

硫化氢

含量

200

200

合格

2001

2001

合格

#

#

#

99

2001

合格

55

2001

合格

浓度

100

100

合格

#

#

#

#

#

#

#

#

#

#

#

#

深度

1

1

合格

11

11

合格

11

11

合格

11

11

合格

11

11

合格

含量

2

2

合格

21

21

合格

21

21

合格

21

21

合格

6

21

合格


union = "ITEM_NAME";             	//需要合并的列
pks = "ITEM_NAME,FIELD_NAME";    	 //逻辑主键
clazzKey = "RT";               		//根据RT把行转成列
valueKey = "VAL,REF,CHK";        	//多列取值
headers = "检测项,属性";             	//表头(与逻辑主键对应)
valueLabel = "检测值,参考值,判定结果";  	//表头(与取值列对应)
set.order("ITEM_NAME");

ds = set.pivot(pks, clazzKey,valueKey);
clazzList = set.getDistinctStrings(clazzKey);
//组合表头与取值列
List<List<String>> fieldArrays = BeanUtil.descartes(clazzList, BeanUtil.array2list(valueKey.split(",")));
List<List<String>> headArrays = BeanUtil.descartes(clazzList, BeanUtil.array2list(valueLabel.split(",")));
List<String> fields = new ArrayList<>();
List<String> heads = new ArrayList<>();
heads.addAll(BeanUtil.array2list(headers.split(",")));
fields.addAll(BeanUtil.array2list(pks.split(",")));
for(List<String> headArray:headArrays){
   String head = BeanUtil.concat(headArray,"-");
   heads.add(head);
}
for(List<String> fieldArray:fieldArrays){
   String field = BeanUtil.concat(fieldArray,"-");
   fields.add(field);
}
html = TableBuilder.init()
      .setDatas(ds)
      .setReplaceEmpty("#")
      .setHeaders(heads)
      .setFields(fields)
      .addUnions(union)
      .build().build();


转换后数据结构:

[
    {
        "ITEM_NAME":"CO2",
        "FIELD_NAME":"浓度",
        "第1次-VAL":"1%",
        "第1次-REF":"5%",
        "第1次-CHK":"合格",
        "第2次-VAL":"11%",
        "第2次-REF":"2%",
        "第2次-CHK":"不合格",
        "第3次-VAL":"11%",
        "第3次-REF":"2%",
        "第3次-CHK":"不合格",
        "第4次-VAL":"11%",
        "第4次-REF":"2%",
        "第4次-CHK":"不合格",
        "第5次-VAL":"15%",
        "第5次-REF":"2%",
        "第5次-CHK":"不合格"
    },
    {
        "ITEM_NAME":"CO2",
        "FIELD_NAME":"含量",
        "第1次-VAL":"6",
        "第1次-REF":"1",
        "第1次-CHK":"不合格",
        "第2次-VAL":"31",
        "第2次-REF":"20",
        "第2次-CHK":"不合格",
        "第3次-VAL":"31",
        "第3次-REF":"20",
        "第3次-CHK":"不合格",
        "第4次-VAL":"31",
        "第4次-REF":"20",
        "第4次-CHK":"不合格",
        "第5次-VAL":"5",
        "第5次-REF":"20",
        "第5次-CHK":"不合格"
    },
    {
        "ITEM_NAME":"CO2",
        "FIELD_NAME":"深度",
        "第1次-VAL":"300",
        "第1次-REF":"300",
        "第1次-CHK":"合格",
        "第2次-VAL":"3001",
        "第2次-REF":"3001",
        "第2次-CHK":"合格",
        "第3次-VAL":"33",
        "第3次-REF":"22",
        "第3次-CHK":"合格",
        "第4次-VAL":"77",
        "第4次-REF":"3001",
        "第4次-CHK":"合格",
        "第5次-VAL":"301",
        "第5次-REF":"3001",
        "第5次-CHK":"合格"
    },
    {
        "ITEM_NAME":"硫化氢",
        "FIELD_NAME":"含量",
        "第1次-VAL":"200",
        "第1次-REF":"200",
        "第1次-CHK":"合格",
        "第2次-VAL":"2001",
        "第2次-REF":"2001",
        "第2次-CHK":"合格",
        "第3次-VAL":null,
        "第3次-REF":null,
        "第3次-CHK":null,
        "第4次-VAL":"99",
        "第4次-REF":"2001",
        "第4次-CHK":"合格",
        "第5次-VAL":"55",
        "第5次-REF":"2001",
        "第5次-CHK":"合格"
    },
    {
        "ITEM_NAME":"硫化氢",
        "FIELD_NAME":"浓度",
        "第1次-VAL":"100",
        "第1次-REF":"100",
        "第1次-CHK":"合格",
        "第2次-VAL":null,
        "第2次-REF":null,
        "第2次-CHK":null,
        "第3次-VAL":null,
        "第3次-REF":null,
        "第3次-CHK":null,
        "第4次-VAL":null,
        "第4次-REF":null,
        "第4次-CHK":null,
        "第5次-VAL":null,
        "第5次-REF":null,
        "第5次-CHK":null
    },
    {
        "ITEM_NAME":"铜",
        "FIELD_NAME":"深度",
        "第1次-VAL":"1",
        "第1次-REF":"1",
        "第1次-CHK":"合格",
        "第2次-VAL":"11",
        "第2次-REF":"11",
        "第2次-CHK":"合格",
        "第3次-VAL":"11",
        "第3次-REF":"11",
        "第3次-CHK":"合格",
        "第4次-VAL":"11",
        "第4次-REF":"11",
        "第4次-CHK":"合格",
        "第5次-VAL":"11",
        "第5次-REF":"11",
        "第5次-CHK":"合格"
    },
    {
        "ITEM_NAME":"铜",
        "FIELD_NAME":"含量",
        "第1次-VAL":"2",
        "第1次-REF":"2",
        "第1次-CHK":"合格",
        "第2次-VAL":"21",
        "第2次-REF":"21",
        "第2次-CHK":"合格",
        "第3次-VAL":"21",
        "第3次-REF":"21",
        "第3次-CHK":"合格",
        "第4次-VAL":"21",
        "第4次-REF":"21",
        "第4次-CHK":"合格",
        "第5次-VAL":"6",
        "第5次-REF":"21",
        "第5次-CHK":"合格"
    }
]


===========================取多列值 频次+类别作表头 分页显示======================================


要求输出表格

1

检测项

属性

1-检测值

1-参考值

1-判定结果

2-检测值

2-参考值

2-判定结果

CO2

浓度

1%

5%

合格

11%

2%

不合格

含量

6

1

不合格

31

20

不合格

深度

300

300

合格

3001

3001

合格

硫化氢

含量

200

200

合格

2001

2001

合格

浓度

100

100

合格

#

#

#

深度

1

1

合格

11

11

合格

含量

2

2

合格

21

21

合格

2

检测项

属性

3-检测值

3-参考值

3-判定结果

4-检测值

4-参考值

4-判定结果

CO2

浓度

11%

2%

不合格

11%

2%

不合格

含量

31

20

不合格

31

20

不合格

深度

33

22

合格

77

3001

合格

硫化氢

含量

#

#

#

99

2001

合格

深度

11

11

合格

11

11

合格

含量

21

21

合格

21

21

合格

3

检测项

属性

5-检测值

5-参考值

5-判定结果

CO2

浓度

15%

2%

不合格

含量

5

20

不合格

深度

301

3001

合格

硫化氢

含量

55

2001

合格

 



union = "ITEM_NAME";            		//需要合并的列
pks = "ITEM_NAME,FIELD_NAME";     	//逻辑主键
clazzKey = "RT";               		//根据RT把行转成列
valueKey = "VAL,REF,CHK";        	//多列取值
headers = "检测项,属性";             	//表头(与逻辑主键对应)
set.order("ITEM_NAME");
int vol = 2;                  		//每2次一页
clazzList = set.getDistinctStrings(clazzKey);
int size = clazzList.size();
html = "";
int page = (size-1)/vol+1;
for(int i=0; i<page; i++){
   List<String> pageClazzList = BeanUtil.cuts(clazzList, i*vol, i*vol+vol-1);
   ds = set.select.in(clazzKey, pageClazzList).pivot(pks, clazzKey,valueKey);
   fieldArrays = BeanUtil.descartes(pageClazzList, BeanUtil.array2list(valueKey.split(",")));
   headArrays = BeanUtil.descartes(pageClazzList, BeanUtil.array2list(valueLabel.split(",")));
   fields = new ArrayList<>();
   heads = new ArrayList<>();
   heads.addAll(BeanUtil.array2list(headers.split(",")));
   fields.addAll(BeanUtil.array2list(pks.split(",")));
   for(List<String> headArray:headArrays){
      String head = BeanUtil.concat(headArray,"-");
      heads.add(head);
   }
   for(List<String> fieldArray:fieldArrays){
      String field = BeanUtil.concat(fieldArray,"-");
      fields.add(field);
   } 
   html += "<div>第"+(i+1)+"页</div>";
   html += TableBuilder.init().setHeaders(heads)
         .setDatas(ds).setFields(fields).addUnions(union)
         .setReplaceEmpty("#")
         .build().build();
}



[{"ITEM_NAME":"CO2","FIELD_NAME":"浓度","1-VAL":"1%","1-REF":"5%","1-CHK":"合格","2-VAL":"11%","2-REF":"2%","2-CHK":"不合格"},{"ITEM_NAME":"CO2","FIELD_NAME":"含量","1-VAL":"6","1-REF":"1","1-CHK":"不合格","2-VAL":"31","2-REF":"20","2-CHK":"不合格"},{"ITEM_NAME":"CO2","FIELD_NAME":"深度","1-VAL":"300","1-REF":"300","1-CHK":"合格","2-VAL":"3001","2-REF":"3001","2-CHK":"合格"},{"ITEM_NAME":"硫化氢","FIELD_NAME":"含量","1-VAL":"200","1-REF":"200","1-CHK":"合格","2-VAL":"2001","2-REF":"2001","2-CHK":"合格"},{"ITEM_NAME":"硫化氢","FIELD_NAME":"浓度","1-VAL":"100","1-REF":"100","1-CHK":"合格","2-VAL":null,"2-REF":null,"2-CHK":null},{"ITEM_NAME":"","FIELD_NAME":"深度","1-VAL":"1","1-REF":"1","1-CHK":"合格","2-VAL":"11","2-REF":"11","2-CHK":"合格"},{"ITEM_NAME":"","FIELD_NAME":"含量","1-VAL":"2","1-REF":"2","1-CHK":"合格","2-VAL":"21","2-REF":"21","2-CHK":"合格"}]

 

[{"ITEM_NAME":"CO2","FIELD_NAME":"浓度","3-VAL":"11%","3-REF":"2%","3-CHK":"不合格","4-VAL":"11%","4-REF":"2%","4-CHK":"不合格"},{"ITEM_NAME":"CO2","FIELD_NAME":"含量","3-VAL":"31","3-REF":"20","3-CHK":"不合格","4-VAL":"31","4-REF":"20","4-CHK":"不合格"},{"ITEM_NAME":"CO2","FIELD_NAME":"深度","3-VAL":"33","3-REF":"22","3-CHK":"合格","4-VAL":"77","4-REF":"3001","4-CHK":"合格"},{"ITEM_NAME":"硫化氢","FIELD_NAME":"含量","3-VAL":null,"3-REF":null,"3-CHK":null,"4-VAL":"99","4-REF":"2001","4-CHK":"合格"},{"ITEM_NAME":"","FIELD_NAME":"深度","3-VAL":"11","3-REF":"11","3-CHK":"合格","4-VAL":"11","4-REF":"11","4-CHK":"合格"},{"ITEM_NAME":"","FIELD_NAME":"含量","3-VAL":"21","3-REF":"21","3-CHK":"合格","4-VAL":"21","4-REF":"21","4-CHK":"合格"}]

 

[{"ITEM_NAME":"CO2","FIELD_NAME":"浓度","5-VAL":"15%","5-REF":"2%","5-CHK":"不合格"},{"ITEM_NAME":"CO2","FIELD_NAME":"含量","5-VAL":"5","5-REF":"20","5-CHK":"不合格"},{"ITEM_NAME":"CO2","FIELD_NAME":"深度","5-VAL":"301","5-REF":"3001","5-CHK":"合格"},{"ITEM_NAME":"硫化氢","FIELD_NAME":"含量","5-VAL":"55","5-REF":"2001","5-CHK":"合格"},{"ITEM_NAME":"","FIELD_NAME":"深度","5-VAL":"11","5-REF":"11","5-CHK":"合格"},{"ITEM_NAME":"","FIELD_NAME":"含量","5-VAL":"6","5-REF":"21","5-CHK":"合格"}]



=============================取多列值 属性+类别作表头===============================

要求输出表格

检测项

频次

浓度-检测值

浓度-参考值

浓度-判定结果

含量-检测值

含量-参考值

含量-判定结果

深度-检测值

深度-参考值

深度-判定结果

CO2

1

1%

5%

合格

6

1

不合格

300

300

合格

2

11%

2%

不合格

31

20

不合格

3001

3001

合格

3

11%

2%

不合格

31

20

不合格

33

22

合格

4

11%

2%

不合格

31

20

不合格

77

3001

合格

5

15%

2%

不合格

5

20

不合格

301

3001

合格

硫化氢

1

100

100

合格

200

200

合格

#

#

#

2

#

#

#

2001

2001

合格

#

#

#

4

#

#

#

99

2001

合格

#

#

#

5

#

#

#

55

2001

合格

#

#

#

1

#

#

#

2

2

合格

1

1

合格

2

#

#

#

21

21

合格

11

11

合格

3

#

#

#

21

21

合格

11

11

合格

4

#

#

#

21

21

合格

11

11

合格

5

#

#

#

6

21

合格

11

11

合格

union = "ITEM_NAME";         	//需要合并的列
pks = "ITEM_NAME,RT";        	//逻辑主键
clazzKey = "FIELD_NAME";      	//根据FIELD_NAME把行转成列
valueKey = "VAL,REF,CHK";     	//多列取值
headers = "检测项,频次";          //表头(与逻辑主键对应)
set.order("ITEM_NAME");

ds = set.pivot(pks, clazzKey,valueKey);
clazzList = set.getDistinctStrings(clazzKey);
//组合表头(属性与类别 两两组合)
headArrays = BeanUtil.descartes(clazzList, BeanUtil.array2list(valueLabel.split(",")));
fieldArrays = BeanUtil.descartes(clazzList, BeanUtil.array2list(valueKey.split(",")));
heads = new ArrayList<>();
fields = new ArrayList<>();
heads.addAll(BeanUtil.array2list(headers.split(",")));
fields.addAll(BeanUtil.array2list(pks.split(",")));
for(List<String> headArray:headArrays){
   String head = BeanUtil.concat(headArray,"-");
   heads.add(head);
}
for(List<String> fieldArray:fieldArrays){
   String field = BeanUtil.concat(fieldArray,"-");
   fields.add(field);
}
html = TableBuilder.init()
      .setDatas(ds)
      .setReplaceEmpty("#")
      .setHeaders(heads)
      .setFields(fields)
      .addUnions(union)
      .build().build();


转换成数据结构:

[
    {
        "ITEM_NAME":"CO2",
        "RT":"第1次",
        "浓度-VAL":"1%",
        "浓度-REF":"5%",
        "浓度-CHK":"合格",
        "含量-VAL":"6",
        "含量-REF":"1",
        "含量-CHK":"不合格",
        "深度-VAL":"300",
        "深度-REF":"300",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"CO2",
        "RT":"第2次",
        "浓度-VAL":"11%",
        "浓度-REF":"2%",
        "浓度-CHK":"不合格",
        "含量-VAL":"31",
        "含量-REF":"20",
        "含量-CHK":"不合格",
        "深度-VAL":"3001",
        "深度-REF":"3001",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"CO2",
        "RT":"第3次",
        "浓度-VAL":"11%",
        "浓度-REF":"2%",
        "浓度-CHK":"不合格",
        "含量-VAL":"31",
        "含量-REF":"20",
        "含量-CHK":"不合格",
        "深度-VAL":"33",
        "深度-REF":"22",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"CO2",
        "RT":"第4次",
        "浓度-VAL":"11%",
        "浓度-REF":"2%",
        "浓度-CHK":"不合格",
        "含量-VAL":"31",
        "含量-REF":"20",
        "含量-CHK":"不合格",
        "深度-VAL":"77",
        "深度-REF":"3001",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"CO2",
        "RT":"第5次",
        "浓度-VAL":"15%",
        "浓度-REF":"2%",
        "浓度-CHK":"不合格",
        "含量-VAL":"5",
        "含量-REF":"20",
        "含量-CHK":"不合格",
        "深度-VAL":"301",
        "深度-REF":"3001",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"硫化氢",
        "RT":"第1次",
        "浓度-VAL":"100",
        "浓度-REF":"100",
        "浓度-CHK":"合格",
        "含量-VAL":"200",
        "含量-REF":"200",
        "含量-CHK":"合格",
        "深度-VAL":null,
        "深度-REF":null,
        "深度-CHK":null
    },
    {
        "ITEM_NAME":"硫化氢",
        "RT":"第2次",
        "浓度-VAL":null,
        "浓度-REF":null,
        "浓度-CHK":null,
        "含量-VAL":"2001",
        "含量-REF":"2001",
        "含量-CHK":"合格",
        "深度-VAL":null,
        "深度-REF":null,
        "深度-CHK":null
    },
    {
        "ITEM_NAME":"硫化氢",
        "RT":"第4次",
        "浓度-VAL":null,
        "浓度-REF":null,
        "浓度-CHK":null,
        "含量-VAL":"99",
        "含量-REF":"2001",
        "含量-CHK":"合格",
        "深度-VAL":null,
        "深度-REF":null,
        "深度-CHK":null
    },
    {
        "ITEM_NAME":"硫化氢",
        "RT":"第5次",
        "浓度-VAL":null,
        "浓度-REF":null,
        "浓度-CHK":null,
        "含量-VAL":"55",
        "含量-REF":"2001",
        "含量-CHK":"合格",
        "深度-VAL":null,
        "深度-REF":null,
        "深度-CHK":null
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第1次",
        "浓度-VAL":null,
        "浓度-REF":null,
        "浓度-CHK":null,
        "含量-VAL":"2",
        "含量-REF":"2",
        "含量-CHK":"合格",
        "深度-VAL":"1",
        "深度-REF":"1",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第2次",
        "浓度-VAL":null,
        "浓度-REF":null,
        "浓度-CHK":null,
        "含量-VAL":"21",
        "含量-REF":"21",
        "含量-CHK":"合格",
        "深度-VAL":"11",
        "深度-REF":"11",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第3次",
        "浓度-VAL":null,
        "浓度-REF":null,
        "浓度-CHK":null,
        "含量-VAL":"21",
        "含量-REF":"21",
        "含量-CHK":"合格",
        "深度-VAL":"11",
        "深度-REF":"11",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第4次",
        "浓度-VAL":null,
        "浓度-REF":null,
        "浓度-CHK":null,
        "含量-VAL":"21",
        "含量-REF":"21",
        "含量-CHK":"合格",
        "深度-VAL":"11",
        "深度-REF":"11",
        "深度-CHK":"合格"
    },
    {
        "ITEM_NAME":"铜",
        "RT":"第5次",
        "浓度-VAL":null,
        "浓度-REF":null,
        "浓度-CHK":null,
        "含量-VAL":"6",
        "含量-REF":"21",
        "含量-CHK":"合格",
        "深度-VAL":"11",
        "深度-REF":"11",
        "深度-CHK":"合格"
    }
]


首页 最近更新 搜索 提交