|
@@ -7,6 +7,8 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.core.print.service;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.print.common.jpa.SqlWrapper;
|
|
|
+import cn.com.qmth.examcloud.core.print.service.bean.common.ExamCourseInfo;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.common.ExamInfo;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -33,15 +35,27 @@ public class CommonService {
|
|
|
* (正式场景数据极少,一次获取全部)
|
|
|
*/
|
|
|
public List<ExamInfo> getExamList(String examType) {
|
|
|
- StringBuilder sql = new StringBuilder()
|
|
|
- .append("SELECT em.id AS examId,em.name AS examName,em.root_org_id AS orgId,org.name AS orgName FROM ec_e_exam em")
|
|
|
- .append(" INNER JOIN ec_b_org org ON org.id = em.root_org_id");
|
|
|
+ SqlWrapper sql = new SqlWrapper()
|
|
|
+ .select("em.id examId,em.name examName,em.root_org_id orgId,org.name orgName").from("ec_e_exam em")
|
|
|
+ .innerJoin("ec_b_org org").on("org.id", "em.root_org_id");
|
|
|
if (StringUtils.isNotBlank(examType)) {
|
|
|
- sql.append(" WHERE em.exam_type = '").append(examType).append("'");
|
|
|
+ sql.where().eq("em.exam_type", examType);
|
|
|
}
|
|
|
- sql.append(" ORDER BY em.id ASC");
|
|
|
- //log.debug(sql.toString());
|
|
|
- return jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper(ExamInfo.class));
|
|
|
+ sql.orderBy("em.id", false);
|
|
|
+ //log.debug(sql.build());
|
|
|
+ return jdbcTemplate.query(sql.build(), new BeanPropertyRowMapper(ExamInfo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ExamCourseInfo> getExamCourseList(Long orgId, Long examId) {
|
|
|
+ SqlWrapper sql = new SqlWrapper()
|
|
|
+ .select("root_org_id orgId,exam_id,course_id,course_code,course_name,paper_type,count(course_code) totalStudent")
|
|
|
+ .from("ecs_exam_student")//todo ec_e_exam_student
|
|
|
+ .where()
|
|
|
+ .eq("root_org_id", orgId)
|
|
|
+ .and().eq("exam_id", examId)
|
|
|
+ .groupBy("course_id,paper_type");
|
|
|
+ log.debug(sql.build());
|
|
|
+ return jdbcTemplate.query(sql.build(), new BeanPropertyRowMapper(ExamCourseInfo.class));
|
|
|
}
|
|
|
|
|
|
}
|