Commit cbd73dbe authored by wangsong's avatar wangsong

add line api

parent a783e533
......@@ -70,7 +70,7 @@ public class StatisticsController {
*/
@RequestMapping("app")
@ResponseBody
public MapMessage applications(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", required = false) Integer latestDays, @RequestParam(value = "topN", required = false) Integer topN) {
public MapMessage applications(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays, @RequestParam(value = "topN", required = false) Integer topN) {
List<StatItem> dataList = new ArrayList<>();
List<AuthClient> clientList = authClientService.listAll();
if (StringUtils.isNoneBlank(clientId)){
......@@ -108,7 +108,7 @@ public class StatisticsController {
*/
@RequestMapping("environment")
@ResponseBody
public MapMessage environments(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", required = false) Integer latestDays) {
public MapMessage environments(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays) {
Map<String, List<StatItem>> result = new HashMap<>();
Map<String,Object> param = new HashMap<>();
param.put("loginSuccessFlag", true);
......@@ -172,4 +172,116 @@ public class StatisticsController {
return MapMessage.successMessage().add("data", result);
}
/**
* 认证热点单位统计
*
* @return
*/
@RequestMapping("auth_hot_org")
@ResponseBody
public MapMessage authHotOrgs(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays, @RequestParam(value = "topN", required = false) Integer topN) {
Map<String,Object> param = new HashMap<>();
param.put("loginSuccessFlag", true);
if (clientId != null){
param.put("clientId",clientId);
}
Date startDate = getStartDay(latestDays);
List<String> schoolNames = authLogService.distinct("logUserInfo.schoolName", param, startDate);
List<StatItem> result = new ArrayList<>();
if (CollectionUtils.isNotEmpty(schoolNames)){
for (String name : schoolNames) {
param.put("logUserInfo.schoolName",name);
long count = authLogService.count(param, startDate);
StatItem item = new StatItem();
item.setCount(count);
item.setName(name);
result.add(item);
}
}
result.sort(Comparator.comparing(StatItem::getCount).reversed());
if (result.size()>topN){
result=result.subList(0,topN);
}
return MapMessage.successMessage().add("data", result);
}
/**
* 认证身份统计
*
* @return
*/
@RequestMapping("auth_user_type")
@ResponseBody
public MapMessage authUserTypes(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "startDay") Integer startDay, @RequestParam(value = "endDay") Integer endDay) {
Map<String,Object> param = new HashMap<>();
param.put("loginSuccessFlag", true);
if (clientId != null){
param.put("clientId",clientId);
}
List<Map<String,Object>> dataList = new ArrayList<>();
Date startDate = DateUtils.stringToDate(String.valueOf(startDay), "yyyyMMdd");
Date endDate = DateUtils.stringToDate(String.valueOf(endDay), "yyyyMMdd");
while(startDate.before(endDate)){
String yearMonthDay = DateUtils.dateToString(startDate, "yyyy-MM-dd");
param.put("yearMonthDay", yearMonthDay);
long all_auth = authLogService.count(param);
param.put("logUserInfo.userType","TEACHER");
long teacherCount = authLogService.count(param);
param.put("logUserInfo.userType","STUDENT");
long studentCount = authLogService.count(param);
startDate = DateUtils.calculateDateDay(startDate, 1);
Map<String,Object> data = new HashMap<>();
data.put("date", yearMonthDay);
data.put("teacherCount", teacherCount);
data.put("studentCount", studentCount);
data.put("otherCount", all_auth - teacherCount - studentCount);
dataList.add(data);
}
return MapMessage.successMessage().add("dataList", dataList);
}
@RequestMapping("auth_user_type_sum")
@ResponseBody
public MapMessage authUserTypeSum(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays) {
Map<String,Object> param = new HashMap<>();
param.put("loginSuccessFlag", true);
if (clientId != null){
param.put("clientId",clientId);
}
Date startDate = getStartDay(latestDays);
long days = DateUtils.dayDiff(new Date(), startDate);
long all_auth = authLogService.count(param, startDate);
param.put("logUserInfo.userType","TEACHER");
long teacherCount = authLogService.count(param, startDate);
param.put("logUserInfo.userType","STUDENT");
long studentCount = authLogService.count(param, startDate);
Map<String,Object> data = new HashMap<>();
data.put("totalCount", all_auth);
data.put("teacherCount", teacherCount);
data.put("studentCount", studentCount);
data.put("otherCount", all_auth - teacherCount - studentCount);
data.put("avgTotalCount", all_auth/days);
data.put("avgTeacherCount", teacherCount/days);
data.put("avgStudentCount", studentCount/days);
data.put("avgOtherCount", (all_auth - teacherCount - studentCount)/days);
return MapMessage.successMessage().add("data", data);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment