|
@@ -21,35 +21,47 @@ public class RAppAnalyzeService {
|
21
|
21
|
@Resource
|
22
|
22
|
private RAppAnalyzeMapper rAppAnalyzeMapper;
|
23
|
23
|
|
24
|
|
- public Map listApp(RegionParam param) {
|
25
|
|
- Map map = new HashMap();
|
|
24
|
+ public Map<String, Object> listApp(RegionParam param) {
|
|
25
|
+ Map<String, Object> map = new HashMap<>();
|
|
26
|
+ List<Map<String, Object>> schoolList = rAppAnalyzeMapper.listSchool(param.getLevel());
|
|
27
|
+ if(N_Utils.isListEmpty(schoolList)) {
|
|
28
|
+ map.put("dlnum",0);//登录次数
|
|
29
|
+ map.put("pjdlnum",0);//平均登录次数
|
|
30
|
+ map.put("dknum",0);//打开次数
|
|
31
|
+ map.put("pjdknum",0);//平均打开次数
|
|
32
|
+ map.put("costtime",0);//使用时长
|
|
33
|
+ map.put("pjcosttime",0);//平均使用时长
|
|
34
|
+ map.put("rates",new ArrayList<>());
|
|
35
|
+ map.put("schools",new ArrayList<>());
|
|
36
|
+ return map;
|
|
37
|
+ }
|
|
38
|
+ String schoolIds = schoolList.stream().map(m -> m.get("schoolid").toString()).collect(Collectors.joining(","));
|
26
|
39
|
Integer begintime = param.getBegintime();
|
27
|
40
|
Integer endtime = param.getEndtime();
|
28
|
|
- Integer level = param.getLevel();
|
29
|
41
|
Integer daynum = N_Utils.getTimestampDay(begintime,endtime);//使用天数
|
30
|
|
- Integer dlnum = rAppAnalyzeMapper.getLoginNum(level,begintime,endtime,param.getYear());
|
|
42
|
+ Integer dlnum = rAppAnalyzeMapper.getLoginNum(schoolIds,begintime,endtime,param.getYear());
|
31
|
43
|
map.put("dlnum",dlnum);//登录次数
|
32
|
44
|
map.put("pjdlnum", N_Utils.formatAvg(dlnum,daynum));//平均登录次数
|
33
|
45
|
|
34
|
46
|
//应用时长、次数统计
|
35
|
|
- List<RAppVo> list = rAppAnalyzeMapper.listApp(level,begintime,endtime,param.getYear());
|
36
|
|
- Integer dknum = list.stream().collect(Collectors.summingInt(RAppVo::getDknum));
|
|
47
|
+ List<RAppVo> list = rAppAnalyzeMapper.listApp(schoolIds,begintime,endtime,param.getYear());
|
|
48
|
+ Integer dknum = list.stream().mapToInt(RAppVo::getDknum).sum();
|
37
|
49
|
map.put("dknum",dknum);//打开次数
|
38
|
50
|
map.put("pjdknum", N_Utils.formatAvg(dknum,daynum));//平均打开次数
|
39
|
|
- Integer costtime = list.stream().collect(Collectors.summingInt(RAppVo::getCosttime));
|
|
51
|
+ Integer costtime = list.stream().mapToInt(RAppVo::getCosttime).sum();
|
40
|
52
|
map.put("costtime",costtime);//使用时长
|
41
|
53
|
map.put("pjcosttime", N_Utils.formatAvg(costtime,daynum));//平均使用时长
|
42
|
54
|
|
43
|
55
|
//应用统计--应用时长概况(关于率的计算:各应用时长÷总使用时长,排名前5的应用)
|
44
|
56
|
List<RAppVo> list2 = new ArrayList<>();
|
45
|
57
|
Map<String, List<RAppVo>> rcollect = list.stream().collect(Collectors.groupingBy(RAppVo::getModulecode));
|
46
|
|
- for(Map.Entry rmap:rcollect.entrySet()) {
|
47
|
|
- List<RAppVo> rates2 = (List<RAppVo>) rmap.getValue();
|
|
58
|
+ for(Map.Entry<String, List<RAppVo>> rmap:rcollect.entrySet()) {
|
|
59
|
+ List<RAppVo> rates2 = rmap.getValue();
|
48
|
60
|
RAppVo a = new RAppVo();
|
49
|
61
|
RAppVo rate = rates2.get(0);
|
50
|
62
|
a.setModulecode(rate.getModulecode());
|
51
|
63
|
a.setModulename(rate.getModulename());
|
52
|
|
- Integer costtime2 = rates2.stream().collect(Collectors.summingInt(RAppVo::getCosttime));
|
|
64
|
+ Integer costtime2 = rates2.stream().mapToInt(RAppVo::getCosttime).sum();
|
53
|
65
|
a.setCosttime(costtime2);
|
54
|
66
|
a.setTimerate(N_Utils.getIntegerDivideAndMulitiply(costtime2,costtime));
|
55
|
67
|
list2.add(a);
|
|
@@ -61,17 +73,14 @@ public class RAppAnalyzeService {
|
61
|
73
|
|
62
|
74
|
//学校应用时长、次数统计
|
63
|
75
|
Map<Integer, List<RAppVo>> scollect = list.stream().collect(Collectors.groupingBy(RAppVo::getSchoolid));
|
64
|
|
- List<Map> schools = new ArrayList<>();
|
65
|
|
- for(Map.Entry smap:scollect.entrySet()) {
|
66
|
|
- List<RAppVo> schools2 = (List<RAppVo>) smap.getValue();
|
|
76
|
+ List<Map<String, Object>> schools = new ArrayList<>();
|
|
77
|
+ for(Map.Entry<Integer, List<RAppVo>> smap:scollect.entrySet()) {
|
|
78
|
+ List<RAppVo> schools2 = smap.getValue();
|
67
|
79
|
RAppVo school = schools2.get(0);
|
68
|
|
- Map s = new HashMap();
|
69
|
|
- s.put("schoolid",school.getSchoolid());
|
70
|
|
- s.put("schoolname",school.getSchoolname());
|
71
|
|
- s.put("shortname",school.getShortname());
|
72
|
|
- List<Map> modules = new ArrayList<>();//学校模块列表
|
|
80
|
+ Map<String, Object> s = schoolList.stream().filter(m -> m.get("schoolid").equals(school.getSchoolid())).findFirst().orElse(new HashMap<>());
|
|
81
|
+ List<Map<String, Object>> modules = new ArrayList<>();//学校模块列表
|
73
|
82
|
for (RAppVo a : schools2) {
|
74
|
|
- Map module = new HashMap();
|
|
83
|
+ Map<String, Object> module = new HashMap<>();
|
75
|
84
|
module.put("modulecode",a.getModulecode());
|
76
|
85
|
module.put("modulename",a.getModulename());
|
77
|
86
|
module.put("dknum",a.getDknum());
|