Browse Source

信件统计导出

master
laishajiang 2 years ago
parent
commit
682c878548
  1. 87
      mailbox-lan/src/main/java/com/biutag/lan/service/DataService.java

87
mailbox-lan/src/main/java/com/biutag/lan/service/DataService.java

@ -436,8 +436,6 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
list_item.add(item.get("second_dept_name1"));
list_item.add(item.get("allcount1"));
for (int i = 0;i<variables.size();i++){
System.out.println("EEEEEEEEEEEEEEEE"+variables.size());
System.out.println("EEEEEEEEEEEEEEEE"+item.get("countrate"+(i + 1)));
list_item.add(item.get("sumcount"+(i + 1)));
list_item.add(item.get("countrate"+(i + 1)));
}
@ -465,38 +463,78 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
public void exportcategory(HttpServletResponse response, DataSearchValidate dataSearchValidate) throws IOException {
List<List<String>> head = new ArrayList<>();
List<Map<String,Object>> list = new ArrayList<>();
List<Map<String,Object>> listdata = new ArrayList<>();
List<List<Object>> data1 = new ArrayList<>();
List<String> variables = new ArrayList<>();
list = getsourcelist(new Page<>(1, 10000),dataSearchValidate).getRecords();
System.out.println(list);
Map<String ,Object> item_one = list.get(0);
for (Map.Entry<String, Object> entry : item_one.entrySet()) {
// 获取键和值
String key = entry.getKey();
Object value = entry.getValue();
// 打印键和值
if (key.contains("name")&&!key.contains("second_dept_name")){
variables.add(value.toString());
list = listForCategoryHeader(dataSearchValidate);
listdata = listForCategory(new Page<>(1, 10000),dataSearchValidate).getRecords();
head.add(List.of("局长信箱即接即办信件分类统计","单位名称","单位名称","单位名称","单位名称"));
head.add(List.of("局长信箱即接即办信件分类统计","信件总量","信件总量","信件总量","信件总量"));
for(int father = 2;father<list.size();father++){
for (int firstchildren = 0;firstchildren<((List<Map<String,Object>>)list.get(father).get("children")).size();firstchildren++){
if (((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")==null){
List<String> stringList = new ArrayList<>();
stringList.add("局长信箱即接即办信件分类统计");
stringList.add(list.get(father).get("label").toString());
stringList.add(((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("label").toString());
stringList.add(((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("label").toString());
stringList.add(((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("label").toString());
System.out.println(stringList);
variables.add(((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("prop").toString());
head.add(stringList);
}else{
for (int secondchildren = 0;secondchildren<((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).size();secondchildren++){
if (((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("children")==null){
List<String> stringList = new ArrayList<>();
stringList.add("局长信箱即接即办信件分类统计");
stringList.add(list.get(father).get("label").toString());
stringList.add(((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("label").toString());
stringList.add(((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("label").toString());
stringList.add(((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("label").toString());
head.add(stringList);
variables.add(((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("prop").toString());
continue;
}else{
for (int threechildren = 0;threechildren<((List<Map<String,Object>>)((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("children")).size();threechildren++) {
if (((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("children")==null) {
List<String> stringList = new ArrayList<>();
stringList.add("局长信箱即接即办信件分类统计");
stringList.add(list.get(father).get("label").toString());
stringList.add(((List<Map<String, Object>>) list.get(father).get("children")).get(firstchildren).get("label").toString());
stringList.add(((List<Map<String, Object>>) ((List<Map<String, Object>>) list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("label").toString());
stringList.add(((List<Map<String, Object>>) ((List<Map<String, Object>>) list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("label").toString());
variables.add(((List<Map<String, Object>>) ((List<Map<String, Object>>) list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("prop").toString());
head.add(stringList);
}else{
List<String> stringList = new ArrayList<>();
stringList.add("局长信箱即接即办信件分类统计");
stringList.add(list.get(father).get("label").toString());
stringList.add(((List<Map<String, Object>>) list.get(father).get("children")).get(firstchildren).get("label").toString());
stringList.add(((List<Map<String, Object>>) ((List<Map<String, Object>>) list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("label").toString());
stringList.add(((List<Map<String,Object>>)((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("children")).get(threechildren).get("label").toString());
variables.add(((List<Map<String,Object>>)((List<Map<String,Object>>)((List<Map<String,Object>>)list.get(father).get("children")).get(firstchildren).get("children")).get(secondchildren).get("children")).get(threechildren).get("prop").toString());
head.add(stringList);
}
}
head.add(List.of("局长信箱即接即办信件来源统计","单位名称","单位名称"));
head.add(List.of("局长信箱即接即办信件来源统计","信件总量","信件总量"));
for (int i = 0;i<variables.size();i++){
head.add(List.of("局长信箱即接即办信件来源统计",variables.get(i),"数量"));
head.add(List.of("局长信箱即接即办信件来源统计",variables.get(i),"占比"));
}
for (Map<String ,Object> item : list){
}
}
}
}
for (Map<String ,Object> item : listdata){
List<Object> list_item = new ArrayList<>();
list_item.add(item.get("second_dept_name1"));
list_item.add(item.get("allcount1"));
list_item.add(item.get("second_dept_name"));
list_item.add(item.get("allcount"));
for (int i = 0;i<variables.size();i++){
System.out.println("EEEEEEEEEEEEEEEE"+variables.size());
System.out.println("EEEEEEEEEEEEEEEE"+item.get("countrate"+(i + 1)));
list_item.add(item.get("sumcount"+(i + 1)));
list_item.add(item.get("countrate"+(i + 1)));
list_item.add(item.get(variables.get(i)));
}
data1.add(list_item);
}
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("UTF-8");
try (OutputStream out = response.getOutputStream()) {
@ -515,4 +553,5 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
}
}
}
}
Loading…
Cancel
Save