|
|
|
|
@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
@ -67,69 +68,85 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
|
|
|
|
|
public Page<Map<String, Object>> listForCategory(Page page, DataSearchValidate searchValidate) { |
|
|
|
|
List<Dept> deptslist = null; |
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>(); |
|
|
|
|
List<Map<String,Object>> datalist = new ArrayList<>(); |
|
|
|
|
if (searchValidate.getEasydept()==null||searchValidate.getEasydept().equals("1")){ |
|
|
|
|
List<Map<String,Object>> categorylist = baseMapper.selectMailFirstCategoryWithCount(searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getCategoryCountMap(categorylist)); |
|
|
|
|
List<Map<String,Object>> categorylist_first = baseMapper.selectMailFirstCategoryWithCount(searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime()); |
|
|
|
|
datalist.add(getCategoryDataMap(categorylist_first)); |
|
|
|
|
Wrapper wrapper2 = new QueryWrapper<>().eq("level",2); |
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylistforsecond = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(),searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getCategoryCountMap(categorylistforsecond)); |
|
|
|
|
List<Map<String,Object>> categorylist_second = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime(),null); |
|
|
|
|
datalist.add(getCategoryDataMap(categorylist_second)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else if (searchValidate.getEasydept().equals("2")){ |
|
|
|
|
if (searchValidate.getSdept()==null){ |
|
|
|
|
Wrapper wrapper2 = new QueryWrapper<>().eq("level",2); |
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylist = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getCategoryCountMap(categorylist)); |
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> categorylist_second = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime(),null); |
|
|
|
|
datalist.add(getCategoryDataMap(categorylist_second)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
Wrapper wrapper2 = new QueryWrapper<>().eq("level",2).eq("id",searchValidate.getSdept()); |
|
|
|
|
deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); |
|
|
|
|
for(Dept deptItem :deptslist){ |
|
|
|
|
List<Map<String,Object>> categorylist = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getCategoryCountMap(categorylist)); |
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> categorylist_second = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime(),null); |
|
|
|
|
datalist.add(getCategoryDataMap(categorylist_second)); |
|
|
|
|
} |
|
|
|
|
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.selectMailThreeCategoryWithCount(deptItem.getId().toString(),deptItem.getName(),searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
list.add(getCategoryCountMap(categorylist)); |
|
|
|
|
|
|
|
|
|
List<Map<String,Object>> categorylist_three = baseMapper.selectMailThreeCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime()); |
|
|
|
|
datalist.add(getCategoryDataMap(categorylist_three)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Page<Map<String, Object>> dataVoPage = new Page<>(); |
|
|
|
|
dataVoPage.setRecords(getSortList(list)); |
|
|
|
|
dataVoPage.setRecords(getCategorySortList(datalist)); |
|
|
|
|
dataVoPage.setTotal(page.getTotal()); |
|
|
|
|
dataVoPage.setCurrent(page.getCurrent()); |
|
|
|
|
dataVoPage.setSize(page.getSize()); |
|
|
|
|
dataVoPage.setPages(page.getPages()); |
|
|
|
|
return dataVoPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> getCategoryDataMap(List<Map<String, Object>> categorylist) { |
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
map.put("second_dept_name",categorylist.get(0).get("second_dept_name")); |
|
|
|
|
map.put("allcount",categorylist.get(0).get("allcount")); |
|
|
|
|
for (Map<String,Object> item :categorylist){ |
|
|
|
|
map.put("countrate"+item.get("key"),item.get("countrate")); |
|
|
|
|
map.put("sumcount"+item.get("key"),item.get("sumcount")); |
|
|
|
|
} |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<Map<String, Object>> getSortList(List<Map<String, Object>> list) { |
|
|
|
|
private List<Map<String, Object>> getCategorySortList(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("allcount"); |
|
|
|
|
Comparable value2 = (Comparable) o2.get("allcount"); |
|
|
|
|
// 按"value"升序排序
|
|
|
|
|
return value2.compareTo(value1); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
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"); |
|
|
|
|
|
|
|
|
|
// 按"value"升序排序
|
|
|
|
|
return value2.compareTo(value1); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return list; |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Page<Map<String, Object>> getsourcelist(Page page, DataSearchValidate searchValidate) { |
|
|
|
|
@ -171,7 +188,7 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Page<Map<String, Object>> dataVoPage = new Page<>(); |
|
|
|
|
dataVoPage.setRecords(getSortList(list)); |
|
|
|
|
dataVoPage.setRecords(getSourceSortList(list)); |
|
|
|
|
dataVoPage.setTotal(page.getTotal()); |
|
|
|
|
dataVoPage.setCurrent(page.getCurrent()); |
|
|
|
|
dataVoPage.setSize(page.getSize()); |
|
|
|
|
@ -180,19 +197,86 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Map<String,Object> getCategoryCountMap(List<Map<String,Object>> categorylist){ |
|
|
|
|
int keycount = 1; |
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
for (Map<String,Object> item :categorylist){ |
|
|
|
|
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>> getCategoryHeaderMap(List<Map<String,Object>> fathercategorylist,List<Map<String,Object>> firstchildren,List<Map<String,Object>> secondchildren){ |
|
|
|
|
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 :fathercategorylist){ |
|
|
|
|
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("key")); |
|
|
|
|
father_map.put("children",new ArrayList<Map<String, Object>>()); |
|
|
|
|
list.add(father_map); |
|
|
|
|
} |
|
|
|
|
for (Map<String,Object> item :firstchildren){ |
|
|
|
|
Map<String,Object> firstchildren_map = new HashMap<>(); |
|
|
|
|
firstchildren_map.put("label",item.get("name")); |
|
|
|
|
firstchildren_map.put("key",item.get("key")); |
|
|
|
|
firstchildren_map.put("children",new ArrayList<Map<String, Object>>()); |
|
|
|
|
for (Map<String,Object> father_item :list){ |
|
|
|
|
if (item.get("parent_key").equals(father_item.get("key"))){ |
|
|
|
|
((List<Map<String,Object>>)father_item.get("children")).add(firstchildren_map); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
firstchildrenlist.add(firstchildren_map); |
|
|
|
|
} |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
for (Map<String,Object> father_item :list){ |
|
|
|
|
if (father_item.get("children")!=null&&((List<Map<String,Object>>)father_item.get("children")).size()==0){ |
|
|
|
|
Map<String,Object> data_map1 = new HashMap<>(); |
|
|
|
|
Map<String,Object> data_map2 = new HashMap<>(); |
|
|
|
|
data_map1.put("label","数量"); |
|
|
|
|
data_map1.put("prop","sumcount"+father_item.get("key")); |
|
|
|
|
data_map2.put("label","占比"); |
|
|
|
|
data_map2.put("prop","countrate"+father_item.get("key")); |
|
|
|
|
((List<Map<String,Object>>)father_item.get("children")).add(data_map1); |
|
|
|
|
((List<Map<String,Object>>)father_item.get("children")).add(data_map2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (Map<String,Object> item :secondchildren){ |
|
|
|
|
Map<String,Object> secondchildren_map = new HashMap<>(); |
|
|
|
|
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("key")); |
|
|
|
|
data_map2.put("label","占比"); |
|
|
|
|
data_map2.put("prop","countrate"+item.get("key")); |
|
|
|
|
List<Map<String,Object>> children = new ArrayList<>(); |
|
|
|
|
secondchildren_map.put("label",item.get("name")); |
|
|
|
|
children.add(data_map1); |
|
|
|
|
children.add(data_map2); |
|
|
|
|
secondchildren_map.put("children",children); |
|
|
|
|
for (Map<String,Object> father_item :firstchildrenlist){ |
|
|
|
|
if (item.get("parent_key").equals(father_item.get("key"))){ |
|
|
|
|
((List<Map<String,Object>>)father_item.get("children")).add(secondchildren_map); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (Map<String,Object> father_item :firstchildrenlist){ |
|
|
|
|
if (father_item.get("children")!=null&&((List<Map<String,Object>>)father_item.get("children")).size()==0){ |
|
|
|
|
Map<String,Object> data_map1 = new HashMap<>(); |
|
|
|
|
Map<String,Object> data_map2 = new HashMap<>(); |
|
|
|
|
data_map1.put("label","数量"); |
|
|
|
|
data_map1.put("prop","sumcount"+father_item.get("key")); |
|
|
|
|
data_map2.put("label","占比"); |
|
|
|
|
data_map2.put("prop","countrate"+father_item.get("key")); |
|
|
|
|
((List<Map<String,Object>>)father_item.get("children")).add(data_map1); |
|
|
|
|
((List<Map<String,Object>>)father_item.get("children")).add(data_map2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> getSourceCountMap(List<Map<String,Object>> categorylist){ |
|
|
|
|
int keycount = 1; |
|
|
|
|
@ -208,4 +292,18 @@ public class DataService extends ServiceImpl<DataMapper, Mail> {
|
|
|
|
|
} |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> listForCategoryHeader(DataSearchValidate searchValidate) { |
|
|
|
|
List<Dept> deptslist = null; |
|
|
|
|
List<Map<String,Object>> headerlist = new ArrayList<>(); |
|
|
|
|
Wrapper wrapper2 = new QueryWrapper<>().eq("level",2); |
|
|
|
|
deptslist = deptMapper.selectList(wrapper2); |
|
|
|
|
Dept deptItem =deptslist.get(0); |
|
|
|
|
List<Map<String,Object>> categorylist1 = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime(),"1"); |
|
|
|
|
List<Map<String,Object>> categorylist2 = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime(),"2"); |
|
|
|
|
List<Map<String,Object>> categorylist3 = baseMapper.selectMailCategoryWithCount(deptItem.getId().toString(),deptItem.getName(), searchValidate.getSearchStartTime(), searchValidate.getSearchEndTime(),"3"); |
|
|
|
|
headerlist = getCategoryHeaderMap(categorylist1,categorylist2,categorylist3); |
|
|
|
|
return headerlist; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |