zhangjinli 3 years ago
parent 58fe659beb
commit 537b9199a9

@ -178,7 +178,7 @@ public class StatisticsController {
default: default:
} }
} }
qw.between("t1.createAt", before, now.plusDays(1)); qw.between("t2.createAt", before, now.plusDays(1));
IPage page =(param.getType() != null && param.getType() == 1) ? userEffectRecordsMapper.rankByDepartment(pg,qw) : userEffectRecordsMapper.rankByUser(pg,qw); IPage page =(param.getType() != null && param.getType() == 1) ? userEffectRecordsMapper.rankByDepartment(pg,qw) : userEffectRecordsMapper.rankByUser(pg,qw);
return Result.success(page, "请求成功"); } return Result.success(page, "请求成功"); }
} }

@ -76,7 +76,7 @@ public class RankUController {
Page pg = MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()); Page pg = MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize());
QueryWrapper<UserEffectRecords> qw = new QueryWrapper<>(); QueryWrapper<UserEffectRecords> qw = new QueryWrapper<>();
LocalDateTime now = param.getDateTime() == null ? LocalDateTime.now() : param.getDateTime(); LocalDateTime now = param.getDateTime() == null ? LocalDateTime.now() : param.getDateTime();
qw.eq("date_format(t1.createAt, '%Y-%m')", now.format(DateTimeFormatter.ofPattern("yyyy-MM"))); qw.eq("date_format(t2.createAt, '%Y-%m')", now.format(DateTimeFormatter.ofPattern("yyyy-MM")));
IPage page = (param.getType() != null && param.getType() == 1) ? userEffectRecordsMapper.rankByDepartment(pg, qw) : userEffectRecordsMapper.rankByUser(pg, qw); IPage page = (param.getType() != null && param.getType() == 1) ? userEffectRecordsMapper.rankByDepartment(pg, qw) : userEffectRecordsMapper.rankByUser(pg, qw);
return Result.success(page.getRecords(), "请求成功"); return Result.success(page.getRecords(), "请求成功");
} }

@ -33,7 +33,6 @@ public interface UserEffectRecordsMapper extends BaseMapper<UserEffectRecords> {
// "ORDER BY effectValue DESC") // "ORDER BY effectValue DESC")
@Select("SELECT t1.departmentId,t1.name,IFNULL(sum(t2.effectValue),0) as effectValue from (SELECT t1.*,t2.openid FROM qywxDepartment t1 LEFT JOIN qywxDepartmentUserLink as t2 on t2.departmentId = t1.departmentId) as t1\n" + @Select("SELECT t1.departmentId,t1.name,IFNULL(sum(t2.effectValue),0) as effectValue from (SELECT t1.*,t2.openid FROM qywxDepartment t1 LEFT JOIN qywxDepartmentUserLink as t2 on t2.departmentId = t1.departmentId) as t1\n" +
"INNER JOIN (SELECT t1.openid,IFNULL(sum(t2.effectResultTran),0) as effectValue from user t1 left join userEffectRecords t2 on t2.userId = t1.id GROUP BY openid) as t2 on t2.openid = t1.openid\n" + "INNER JOIN (SELECT t1.openid,IFNULL(sum(t2.effectResultTran),0) as effectValue from user t1 left join userEffectRecords t2 on t2.userId = t1.id GROUP BY openid) as t2 on t2.openid = t1.openid\n" +
"GROUP BY departmentId\n" +
"${ew.customSqlSegment} " + "${ew.customSqlSegment} " +
"GROUP BY departmentId\n" + "GROUP BY departmentId\n" +
"ORDER BY effectValue DESC") "ORDER BY effectValue DESC")

Loading…
Cancel
Save