添加班级统计数据统计功能
parent
c7d4fafd1e
commit
d87d489ee5
|
|
@ -7,6 +7,7 @@ import com.alibaba.cola.dto.Response;
|
|||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.zcloud.edu.api.study.ClassServiceI;
|
||||
import com.zcloud.edu.dto.clientobject.study.ClassCO;
|
||||
import com.zcloud.edu.dto.data.study.ClassCountDTO;
|
||||
import com.zcloud.edu.dto.data.study.ClassQuestionDTO;
|
||||
import com.zcloud.edu.dto.study.ClassAddCmd;
|
||||
import com.zcloud.edu.dto.study.ClassPageQry;
|
||||
|
|
@ -51,6 +52,16 @@ public class ClassController {
|
|||
return classService.listPage(qry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiOperation("统计班级分页数据")
|
||||
@PostMapping("/statisticsCount")
|
||||
public SingleResponse<ClassCountDTO> statisticsCount(@RequestBody ClassPageQry qry) {
|
||||
return classService.statisticsCount(qry);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("所有数据")
|
||||
@GetMapping("/listAll")
|
||||
public MultiResponse<ClassCO> listAll() {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.jjb.saas.framework.auth.model.SSOUser;
|
|||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
import com.zcloud.edu.command.convertor.study.ClassCoConvertor;
|
||||
import com.zcloud.edu.dto.clientobject.study.ClassCO;
|
||||
import com.zcloud.edu.dto.data.study.ClassCountDTO;
|
||||
import com.zcloud.edu.dto.data.study.ClassQuestionDTO;
|
||||
import com.zcloud.edu.dto.study.ClassPageQry;
|
||||
import com.zcloud.edu.persistence.dataobject.study.ClassDO;
|
||||
|
|
@ -70,10 +71,27 @@ public class ClassQueryExe {
|
|||
return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
|
||||
}
|
||||
|
||||
public PageResponse<ClassCO> executeAppListPage(ClassPageQry classPageQry) {
|
||||
SSOUser ssoUser = AuthContext.getCurrentUser();
|
||||
|
||||
public SingleResponse<ClassCountDTO> executeStatisticsCount(ClassPageQry classPageQry) {
|
||||
// 如果isMyCorp不为空,则查询当前登录人所在企业数据
|
||||
if (!ObjectUtils.isEmpty(classPageQry.getIsMyCorp())){
|
||||
SSOUser ssoUser = AuthContext.getCurrentUser();
|
||||
classPageQry.setEqCorpinfoId(ssoUser.getTenantId());
|
||||
}
|
||||
Map<String, Object> params = PageQueryHelper.toHashMap(classPageQry);
|
||||
List<ClassDO> classList = classRepository.listStatistics(params);
|
||||
ClassCountDTO classCountDTO = new ClassCountDTO();
|
||||
if (classList != null && classList.size() > 0){
|
||||
classCountDTO.setClassCount(classList.size());
|
||||
classCountDTO.setStudentCount(classList.stream().mapToInt(ClassDO::getTotalCount).sum());
|
||||
}
|
||||
return SingleResponse.of(classCountDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public PageResponse<ClassCO> executeAppListPage(ClassPageQry classPageQry) {
|
||||
Map<String, Object> params = PageQueryHelper.toHashMap(classPageQry);
|
||||
params.put("phone", ssoUser.getAccount());
|
||||
PageResponse<ClassDO> pageResponse = classRepository.listStuClassPage(params);
|
||||
List<ClassCO> examCenterCOS = classCoConvertor.converDOsToCOs(pageResponse.getData());
|
||||
return PageResponse.of(examCenterCOS, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.zcloud.edu.service.study;
|
||||
|
||||
import com.alibaba.cola.dto.MultiResponse;
|
||||
import com.alibaba.cola.dto.PageResponse;
|
||||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.zcloud.edu.api.study.ClassServiceI;
|
||||
|
|
@ -8,6 +9,7 @@ import com.zcloud.edu.command.study.ClassAddExe;
|
|||
import com.zcloud.edu.command.study.ClassRemoveExe;
|
||||
import com.zcloud.edu.command.study.ClassUpdateExe;
|
||||
import com.zcloud.edu.dto.clientobject.study.ClassCO;
|
||||
import com.zcloud.edu.dto.data.study.ClassCountDTO;
|
||||
import com.zcloud.edu.dto.data.study.ClassQuestionDTO;
|
||||
import com.zcloud.edu.dto.study.ClassAddCmd;
|
||||
import com.zcloud.edu.dto.study.ClassPageQry;
|
||||
|
|
@ -78,5 +80,10 @@ public class ClassServiceImpl implements ClassServiceI {
|
|||
public PageResponse<ClassCO> appListPage(ClassPageQry qry) {
|
||||
return classQueryExe.executeAppListPage(qry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<ClassCountDTO> statisticsCount(ClassPageQry qry) {
|
||||
return classQueryExe.executeStatisticsCount(qry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.zcloud.edu.api.study;
|
||||
|
||||
import com.alibaba.cola.dto.MultiResponse;
|
||||
import com.alibaba.cola.dto.PageResponse;
|
||||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.zcloud.edu.dto.clientobject.study.ClassCO;
|
||||
import com.zcloud.edu.dto.data.study.ClassCountDTO;
|
||||
import com.zcloud.edu.dto.data.study.ClassQuestionDTO;
|
||||
import com.zcloud.edu.dto.study.ClassAddCmd;
|
||||
import com.zcloud.edu.dto.study.ClassPageQry;
|
||||
|
|
@ -36,5 +38,7 @@ public interface ClassServiceI {
|
|||
|
||||
|
||||
PageResponse<ClassCO> appListPage(ClassPageQry qry);
|
||||
|
||||
SingleResponse<ClassCountDTO> statisticsCount(ClassPageQry qry);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.zcloud.edu.dto.data.study;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhangyue
|
||||
* @date 2026/1/22 9:56
|
||||
*/
|
||||
@Data
|
||||
public class ClassCountDTO {
|
||||
private Integer classCount;
|
||||
private Integer studentCount;
|
||||
public ClassCountDTO() {
|
||||
this.classCount = 0;
|
||||
this.studentCount = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ public class ClassPageQry extends PageQuery {
|
|||
private String leEndTime;
|
||||
private String isMyCorp;
|
||||
private Long eqCorpinfoId;
|
||||
private String phone;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import java.util.Map;
|
|||
public interface ClassMapper extends BaseMapper<ClassDO> {
|
||||
|
||||
IPage<ClassDO> listPage(IPage<ClassDO> page, @Param("ew") QueryWrapper<ClassDO> queryWrapper, String menuPerms);
|
||||
|
||||
List<ClassDO> listStatistics(@Param("ew") QueryWrapper<ClassDO> queryWrapper, String menuPerms);
|
||||
IPage<ClassDO> listStuClassPage(IPage<ClassDO> page, @Param("params") Map<String, Object> params, String menuPerms);
|
||||
|
||||
List<ClassQuestionPO> countQuestionByClassId(String classId);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.zcloud.edu.persistence.mapper.po.study.StudentCountPO;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* web-infrastructure
|
||||
|
|
@ -19,5 +20,6 @@ public interface StudentMapper extends BaseMapper<StudentDO> {
|
|||
long postponeUpdateStudent(String classId);
|
||||
|
||||
List<ClassDO> countStudentByClass(List<String> classIds);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,16 @@ public class ClassRepositoryImpl extends BaseRepositoryImpl<ClassMapper, ClassDO
|
|||
return PageHelper.pageToResponse(result, result.getRecords());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClassDO> listStatistics(Map<String, Object> params) {
|
||||
QueryWrapper<ClassDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper = PageQueryHelper.createPageQueryWrapper(queryWrapper, params,"c.");
|
||||
queryWrapper.orderByAsc("c.state").orderByDesc("c.create_time");
|
||||
queryWrapper.eq("c.delete_enum","FALSE");
|
||||
queryWrapper.groupBy("c.class_id");
|
||||
return classMapper.listStatistics(queryWrapper, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResponse<ClassDO> listStuClassPage(Map<String, Object> params) {
|
||||
IPage<ClassDO> iPage = new Query<ClassDO>().getPage(params);
|
||||
|
|
|
|||
|
|
@ -73,5 +73,6 @@ public class StudentRepositoryImpl extends BaseRepositoryImpl<StudentMapper, Stu
|
|||
public List<ClassDO> countStudentByClass(List<String> classIds) {
|
||||
return studentMapper.countStudentByClass(classIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import java.util.Map;
|
|||
*/
|
||||
public interface ClassRepository extends BaseRepository<ClassDO> {
|
||||
PageResponse<ClassDO> listPage(Map<String, Object> params);
|
||||
List<ClassDO> listStatistics(Map<String, Object> params);
|
||||
|
||||
PageResponse<ClassDO> listStuClassPage(Map<String, Object> params);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,5 +26,6 @@ public interface StudentRepository extends BaseRepository<StudentDO> {
|
|||
Integer deleteByClassId(String classId);
|
||||
|
||||
List<ClassDO> countStudentByClass(List<String> classIds);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,18 @@
|
|||
c.numberofexams
|
||||
FROM
|
||||
class c
|
||||
left join training_type t on t.training_type_id = c.train_type
|
||||
left join corp_info ci on ci.id = c.corpinfo_id
|
||||
left join training_type t on t.training_type_id = c.train_type
|
||||
left join corp_info ci on ci.id = c.corpinfo_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="listStatistics" resultType="com.zcloud.edu.persistence.dataobject.study.ClassDO">
|
||||
SELECT
|
||||
c.class_id,
|
||||
count(c.class_id) totalCount
|
||||
FROM
|
||||
class c
|
||||
left join student s on s.class_id = c.class_id and s.delete_enum = 'FALSE'
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
<select id="countStudentByClass" resultType="com.zcloud.edu.persistence.dataobject.study.ClassDO">
|
||||
SELECT
|
||||
count(*) total_count,
|
||||
count(CASE WHEN sign_flag = 1 THEN 1 END) sign_count,
|
||||
count(CASE WHEN state = 3 THEN 1 END) finish_count,
|
||||
class_id
|
||||
count(*) total_count,
|
||||
count(CASE WHEN sign_flag = 1 THEN 1 END) sign_count,
|
||||
count(CASE WHEN state = 3 THEN 1 END) finish_count,
|
||||
class_id
|
||||
FROM
|
||||
student
|
||||
student
|
||||
<where>
|
||||
and class_id IN
|
||||
<foreach item="item" collection="classIds" separator="," open="(" close=")">
|
||||
|
|
@ -32,8 +32,9 @@
|
|||
AND delete_enum = 'FALSE'
|
||||
</where>
|
||||
GROUP BY
|
||||
class_id
|
||||
class_id
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue