Commit b0f09124 authored by wangsong's avatar wangsong

update user type api

parent eb97f95a
...@@ -218,7 +218,7 @@ public class StatisticsController { ...@@ -218,7 +218,7 @@ public class StatisticsController {
*/ */
@RequestMapping("auth_user_type") @RequestMapping("auth_user_type")
@ResponseBody @ResponseBody
public MapMessage authUserTypes(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "startDay") Integer startDay, @RequestParam(value = "endDay") Integer endDay) { public MapMessage authUserTypes(@RequestParam(value = "clientId", required = false) String clientId, @RequestParam(value = "latestDays", defaultValue = "7") Integer latestDays) {
Map<String,Object> param = new HashMap<>(); Map<String,Object> param = new HashMap<>();
param.put("loginSuccessFlag", true); param.put("loginSuccessFlag", true);
...@@ -226,21 +226,42 @@ public class StatisticsController { ...@@ -226,21 +226,42 @@ public class StatisticsController {
param.put("clientId",clientId); param.put("clientId",clientId);
} }
int type = 1; // 1: 日数据 2: 月数据
if(latestDays > 30){
type = 2;
}
Date startDate = getStartDay(latestDays);
List<Map<String,Object>> dataList = new ArrayList<>(); List<Map<String,Object>> dataList = new ArrayList<>();
Date startDate = DateUtils.stringToDate(String.valueOf(startDay), "yyyyMMdd"); Date endDate = new Date();
Date endDate = DateUtils.stringToDate(String.valueOf(endDay), "yyyyMMdd");
while(startDate.before(endDate)){ while(startDate.before(endDate)){
String yearMonthDay = DateUtils.dateToString(startDate, "yyyy-MM-dd"); String dateStr = "";
param.put("yearMonthDay", yearMonthDay); if(Objects.equals(type, 1)){ // 日数据
String yearMonthDay = DateUtils.dateToString(startDate, "yyyy-MM-dd");
param.put("yearMonthDay", yearMonthDay);
dateStr = DateUtils.dateToString(startDate, "M月dd日");
}else { // 月数据
String yearMonth = DateUtils.dateToString(startDate, "yyyy-MM");
param.put("yearMonth", yearMonth);
dateStr = DateUtils.dateToString(startDate, "M月");
}
long all_auth = authLogService.count(param); long all_auth = authLogService.count(param);
param.put("logUserInfo.userType","TEACHER"); param.put("logUserInfo.userType","TEACHER");
long teacherCount = authLogService.count(param); long teacherCount = authLogService.count(param);
param.put("logUserInfo.userType","STUDENT"); param.put("logUserInfo.userType","STUDENT");
long studentCount = authLogService.count(param); long studentCount = authLogService.count(param);
startDate = DateUtils.calculateDateDay(startDate, 1); if(Objects.equals(type, 1)){ // 日数据
startDate = DateUtils.calculateDateDay(startDate, 1);
}else { // 月数据
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
calendar.add(Calendar.MONTH, 1);
startDate = calendar.getTime();
}
Map<String,Object> data = new HashMap<>(); Map<String,Object> data = new HashMap<>();
data.put("date", yearMonthDay); data.put("date", dateStr);
data.put("teacherCount", teacherCount); data.put("teacherCount", teacherCount);
data.put("studentCount", studentCount); data.put("studentCount", studentCount);
data.put("otherCount", all_auth - teacherCount - studentCount); data.put("otherCount", all_auth - teacherCount - studentCount);
......
...@@ -79,6 +79,8 @@ public class AuthLog implements CacheDimensionDocument { ...@@ -79,6 +79,8 @@ public class AuthLog implements CacheDimensionDocument {
@DocumentField @DocumentField
private String yearMonthDay; private String yearMonthDay;
private Integer hour;
@Override @Override
public String[] generateCacheDimensions() { public String[] generateCacheDimensions() {
return new String[0]; return new String[0];
......
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