zhangjinli 3 years ago
parent 569143cbcc
commit 4c708aabe3

@ -88,8 +88,8 @@ public class UserController {
qw
// .and(param.getDepartment() != null, q -> q.like("t2.name", param.getDepartment())
// .or(o -> o.like("t3.name", param.getDepartment())))
.inSql(param.getDepartment() != null,"t2.openid",
"SELECT t1.openid from qywxDepartmentUserLink as t1 LEFT JOIN qywxDepartment as t2 on t1.departmentId = t2.departmentId and t2.name like "+"%"+param.getDepartment()+"%")
.inSql(param.getDepartment() != null,"t1.openid",
"SELECT t1.openid from qywxDepartmentUserLink as t1 LEFT JOIN qywxDepartment as t2 on t1.departmentId = t2.departmentId and t2.name like "+"%'"+param.getDepartment()+"'%")
.like(param.getName() != null, "t1.name", param.getName());
return Result.success(userService.userDpList(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), qw));
}

@ -25,16 +25,24 @@ public interface UserEffectRecordsMapper extends BaseMapper<UserEffectRecords> {
" VALUES " +
"(#{userId},(SELECT main_department from user WHERE id = #{userId}),#{effectResultTran},#{createAt})")
void saveEffectResult(UserEffectRecords userEffectRecords);
@Select("SELECT t1.departmentId,t3.name as title,IFNULL(sum(t1.effectResultTran),0) as effectValue from userEffectRecords as t1\n" +
"INNER JOIN qywxDepartment as t3 on t3.departmentId = t1.departmentId\n" +
// @Select("SELECT t1.departmentId,t3.name as title,IFNULL(sum(t1.effectResultTran),0) as effectValue from userEffectRecords as t1\n" +
// "INNER JOIN qywxDepartment as t3 on t3.departmentId = t1.departmentId\n" +
// "${ew.customSqlSegment} " +
// "GROUP BY departmentId\n" +
// "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" +
"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} " +
"GROUP BY departmentId\n" +
"ORDER BY effectValue DESC")
IPage<Map> rankByDepartment(IPage page, @Param("ew") Wrapper<UserEffectRecords> queryWrapper);
@Select("SELECT t1.userId,t2.name as title,t2.avatar,t2.departmentId,t2.departmentName as subtitle,IFNULL(sum(t1.effectResultTran),0) as effectValue from userEffectRecords as t1\n" +
"INNER JOIN (SELECT t1.id,t1.name,t1.avatar,t2.departmentId,t2.name as departmentName FROM user as t1 left join qywxDepartment as t2 on t1.main_department = t2.departmentId) as t2 on t1.userId = t2.id\n" +
"${ew.customSqlSegment} " +
"GROUP BY userId\n" +
"ORDER BY effectValue DESC")
IPage<Map> rankByUser(IPage page,@Param("ew") Wrapper<UserEffectRecords> queryWrapper);
IPage<Map> rankByUser(IPage page, @Param("ew") Wrapper<UserEffectRecords> queryWrapper);
}

Loading…
Cancel
Save