|
|
|
|
@ -157,6 +157,17 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Map<String, Object> getSourceDataMap(List<Map<String, Object>> sourcelist) { |
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
map.put("second_dept_name",sourcelist.get(0).get("second_dept_name")); |
|
|
|
|
map.put("allcount",sourcelist.get(0).get("allcount")); |
|
|
|
|
for (Map<String,Object> item :sourcelist){ |
|
|
|
|
map.put("countrate"+item.get("source"),item.get("countrate")); |
|
|
|
|
map.put("sumcount"+item.get("source"),item.get("sumcount")); |
|
|
|
|
} |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<Map<String, Object>> getCategorySortList(List<Map<String, Object>> list) { |
|
|
|
|
Collections.sort(list, new Comparator<Map<String, Object>>() { |
|
|
|
|
@Override |
|
|
|
|
@ -170,13 +181,14 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
}); |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<Map<String, Object>> getSourceSortList(List<Map<String, Object>> list) { |
|
|
|
|
Collections.sort(list, new Comparator<Map<String, Object>>() { |
|
|
|
|
@Override |
|
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) { |
|
|
|
|
// 假设"value"对应的value是可以比较的(例如Integer, Double等)
|
|
|
|
|
Comparable value1 = (Comparable) o1.get("allcount1"); |
|
|
|
|
Comparable value2 = (Comparable) o2.get("allcount1"); |
|
|
|
|
Comparable value1 = (Comparable) o1.get("allcount"); |
|
|
|
|
Comparable value2 = (Comparable) o2.get("allcount"); |
|
|
|
|
// 按"value"升序排序
|
|
|
|
|
return value2.compareTo(value1); |
|
|
|
|
} |
|
|
|
|
@ -189,12 +201,12 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>(); |
|
|
|
|
if (searchValidate.getEasydept()==null||searchValidate.getEasydept().equals("1")){ |
|
|
|
|
List<Map<String,Object>> categorylist = baseMapper.selectFirstMailSourceWithCount(searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getSourceCountMap(categorylist)); |
|
|
|
|
list.add(getSourceDataMap(categorylist)); |
|
|
|
|
Wrapper wrapper2 = new QueryWrapper<>().eq("level",2); |
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylistforsecond = baseMapper.selectSecondMailSourceWithCount(deptItem.getId().toString(),deptItem.getName(),searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getSourceCountMap(categorylistforsecond)); |
|
|
|
|
list.add(getSourceDataMap(categorylistforsecond)); |
|
|
|
|
} |
|
|
|
|
}else if (searchValidate.getEasydept().equals("2")){ |
|
|
|
|
if (searchValidate.getSdept()==null){ |
|
|
|
|
@ -202,8 +214,7 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylist = baseMapper.selectSecondMailSourceWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
|
|
|
|
|
list.add(getSourceCountMap(categorylist)); |
|
|
|
|
list.add(getSourceDataMap(categorylist)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
@ -211,13 +222,13 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylist = baseMapper.selectSecondMailSourceWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getSourceCountMap(categorylist)); |
|
|
|
|
list.add(getSourceDataMap(categorylist)); |
|
|
|
|
} |
|
|
|
|
Wrapper wrapper3 = new QueryWrapper<>().eq("level",3).eq("pid",searchValidate.getSdept()); |
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper3).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylist = baseMapper.selectThreeMailSourceWithCount(deptItem.getId().toString(),deptItem.getName(),searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getSourceCountMap(categorylist)); |
|
|
|
|
list.add(getSourceDataMap(categorylist)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else if (searchValidate.getEasydept().equals("3")){ |
|
|
|
|
@ -233,7 +244,7 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylistforsecond = baseMapper.selectSecondMailSourceWithCount(deptItem.getId().toString(),deptItem.getName(),searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getSourceCountMap(categorylistforsecond)); |
|
|
|
|
list.add(getSourceDataMap(categorylistforsecond)); |
|
|
|
|
} |
|
|
|
|
}else if (searchValidate.getEasydept().equals("4")){ |
|
|
|
|
Wrapper wrapper2 = new QueryWrapper<>().eq("level",2).and(wrapper -> wrapper |
|
|
|
|
@ -245,7 +256,7 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylistforsecond = baseMapper.selectSecondMailSourceWithCount(deptItem.getId().toString(),deptItem.getName(),searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getSourceCountMap(categorylistforsecond)); |
|
|
|
|
list.add(getSourceDataMap(categorylistforsecond)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Page<Map<String, Object>> dataVoPage = new Page<>(); |
|
|
|
|
@ -336,22 +347,34 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> getSourceCountMap(List<Map<String,Object>> categorylist){ |
|
|
|
|
int keycount = 1; |
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
for (Map<String,Object> item :categorylist){ |
|
|
|
|
map.put("source"+keycount,item.get("source")); |
|
|
|
|
map.put("countrate"+keycount,item.get("countrate")); |
|
|
|
|
map.put("sumcount"+keycount,item.get("sumcount")); |
|
|
|
|
map.put("name"+keycount,item.get("name")); |
|
|
|
|
map.put("second_dept_name"+keycount,item.get("second_dept_name")); |
|
|
|
|
map.put("allcount"+keycount,item.get("allcount")); |
|
|
|
|
keycount++; |
|
|
|
|
public List<Map<String,Object>> getSourceHeaderMap(List<Map<String,Object>> sourcelist){ |
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>(); |
|
|
|
|
List<Map<String,Object>> firstchildrenlist = new ArrayList<>(); |
|
|
|
|
Map<String,Object> map1 = new HashMap<>(); |
|
|
|
|
Map<String,Object> map2 = new HashMap<>(); |
|
|
|
|
map1.put("label","单位名称"); |
|
|
|
|
map1.put("prop","second_dept_name"); |
|
|
|
|
map2.put("label","信件总量"); |
|
|
|
|
map2.put("prop","allcount"); |
|
|
|
|
list.add(map1); |
|
|
|
|
list.add(map2); |
|
|
|
|
for (Map<String,Object> item :sourcelist){ |
|
|
|
|
Map<String,Object> father_map = new HashMap<>(); |
|
|
|
|
List<Map<String,Object>> children = new ArrayList<>(); |
|
|
|
|
father_map.put("label",item.get("name")); |
|
|
|
|
father_map.put("key",item.get("source")); |
|
|
|
|
Map<String,Object> data_map1 = new HashMap<>(); |
|
|
|
|
Map<String,Object> data_map2 = new HashMap<>(); |
|
|
|
|
data_map1.put("label","数量"); |
|
|
|
|
data_map1.put("prop","sumcount"+item.get("source")); |
|
|
|
|
data_map2.put("label","占比"); |
|
|
|
|
data_map2.put("prop","countrate"+item.get("source")); |
|
|
|
|
children.add(data_map1); |
|
|
|
|
children.add(data_map2); |
|
|
|
|
father_map.put("children",children); |
|
|
|
|
list.add(father_map); |
|
|
|
|
} |
|
|
|
|
return map; |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> listForCategoryHeader(DataSearchValidate searchValidate) { |
|
|
|
|
@ -367,6 +390,14 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
return headerlist; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> listForSourceHeader(DataSearchValidate searchValidate) { |
|
|
|
|
List<Map<String,Object>> headerlist = new ArrayList<>(); |
|
|
|
|
List<Map<String,Object>> sourcelist = baseMapper.selectFirstMailSourceWithCount(searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime()); |
|
|
|
|
headerlist = getSourceHeaderMap(sourcelist); |
|
|
|
|
return headerlist; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void exportdata(HttpServletResponse response, DataSearchValidate dataSearchValidate) throws IOException { |
|
|
|
|
List<List<String>> head = new ArrayList<>(); |
|
|
|
|
List<String> headLevelOne = new ArrayList<>(); |
|
|
|
|
@ -407,37 +438,35 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void exportsource(HttpServletResponse response, DataSearchValidate dataSearchValidate) throws IOException { |
|
|
|
|
List<List<String>> head = new ArrayList<>(); |
|
|
|
|
List<Map<String,Object>> headerlist = new ArrayList<>(); |
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>(); |
|
|
|
|
List<List<Object>> data1 = new ArrayList<>(); |
|
|
|
|
List<String> variables = new ArrayList<>(); |
|
|
|
|
headerlist = listForSourceHeader(dataSearchValidate); |
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(int father = 2;father<headerlist.size();father++){ |
|
|
|
|
for (int firstchildren = 0;firstchildren<((List<Map<String,Object>>)headerlist.get(father).get("children")).size();firstchildren++){ |
|
|
|
|
List<String> stringList = new ArrayList<>(); |
|
|
|
|
stringList.add("局长信箱即接即办信件来源统计"); |
|
|
|
|
stringList.add(headerlist.get(father).get("label").toString()); |
|
|
|
|
stringList.add(((List<Map<String,Object>>) headerlist.get(father).get("children")).get(firstchildren).get("label").toString()); |
|
|
|
|
variables.add(((List<Map<String,Object>>)headerlist.get(father).get("children")).get(firstchildren).get("prop").toString()); |
|
|
|
|
head.add(stringList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (Map<String ,Object> item : list){ |
|
|
|
|
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++){ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
@ -554,4 +583,5 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |