|
|
|
@ -58,6 +58,10 @@ public class StatisticsController {
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
static class SSParam {
|
|
|
|
|
@Schema(title = "任务Id")
|
|
|
|
|
private int taskId;
|
|
|
|
|
@Schema(title = "员工Id")
|
|
|
|
|
private int userId;
|
|
|
|
|
@Schema(title = "时间条件", description = "1今日;2本周;3本月;4全年")
|
|
|
|
|
private int dateCondition;
|
|
|
|
|
@Schema(title = "开始时间(yyyy-MM-dd HH:mm:ss)", description = "如果传入dateCondition以月份区间为条件")
|
|
|
|
@ -72,14 +76,12 @@ public class StatisticsController {
|
|
|
|
|
@PostMapping("/data2")
|
|
|
|
|
@AdminTokenValid
|
|
|
|
|
public Result data2(@Validated @RequestBody SSParam param) {
|
|
|
|
|
Integer condition = param.getDateCondition();
|
|
|
|
|
System.out.println(condition);
|
|
|
|
|
int condition = param.getDateCondition();
|
|
|
|
|
QueryWrapper<Video> qw = new QueryWrapper<>();
|
|
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
DateTimeFormatter df2 = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
|
|
LocalDate now = LocalDateTime.now().toLocalDate();
|
|
|
|
|
LocalDate before = now.with(TemporalAdjusters.firstDayOfMonth());
|
|
|
|
|
if (null != condition) {
|
|
|
|
|
switch (condition) {
|
|
|
|
|
case 1:
|
|
|
|
|
before = now;
|
|
|
|
@ -94,18 +96,19 @@ public class StatisticsController {
|
|
|
|
|
before = now.with(TemporalAdjusters.firstDayOfYear());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
before = param.getBeginTime() != null ? param.getBeginTime().toLocalDate() : before;
|
|
|
|
|
now = param.getEndTime() != null ? param.getEndTime().toLocalDate() : now;
|
|
|
|
|
}
|
|
|
|
|
if(param.getTaskId()>0){
|
|
|
|
|
qw.eq("taskId", param.getTaskId());
|
|
|
|
|
}
|
|
|
|
|
if(param.getUserId()>0){
|
|
|
|
|
qw.eq("userId", param.getUserId());
|
|
|
|
|
}
|
|
|
|
|
ArrayList<JSONObject> res = new ArrayList<>();
|
|
|
|
|
if(condition == 4){
|
|
|
|
|
if (4 == condition) {
|
|
|
|
|
qw.between("date_format(creatAt, '%Y-%m')", before.format(df2), now.plusMonths(1).format(df2));
|
|
|
|
|
List<JSONObject> videoDataBydDay = adminMapper.statistics3(qw);
|
|
|
|
|
if (videoDataBydDay == null || videoDataBydDay.size() == 0) {
|
|
|
|
|
return Result.success(null, "请求成功");
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i <= ChronoUnit.MONTHS.between(before, now); i++) {
|
|
|
|
|
LocalDate today = before.plusMonths(i);
|
|
|
|
|
JSONObject obj = null;
|
|
|
|
@ -122,9 +125,6 @@ public class StatisticsController {
|
|
|
|
|
} else {
|
|
|
|
|
qw.between("date_format(creatAt, '%Y-%m-%d')", before, now.plusDays(1));
|
|
|
|
|
List<JSONObject> videoDataBydDay = adminMapper.statistics2(qw);
|
|
|
|
|
if (videoDataBydDay == null || videoDataBydDay.size() == 0) {
|
|
|
|
|
return Result.success(null, "请求成功");
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i <= ChronoUnit.DAYS.between(before, now); i++) {
|
|
|
|
|
LocalDate today = before.plusDays(i);
|
|
|
|
|
JSONObject obj = null;
|
|
|
|
@ -181,5 +181,6 @@ public class StatisticsController {
|
|
|
|
|
}
|
|
|
|
|
qw.between("createAt", before, now.plusDays(1));
|
|
|
|
|
IPage page = (param.getType() != null && param.getType() == 1) ? userEffectRecordsMapper.rankByDepartment(pg, qw) : userEffectRecordsMapper.rankByUser(pg, qw);
|
|
|
|
|
return Result.success(page, "请求成功"); }
|
|
|
|
|
return Result.success(page, "请求成功");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|