|
@@ -1,18 +1,24 @@
|
|
|
package cn.com.qmth.examcloud.service.examwork.service;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.util.BeanCopierUtil;
|
|
|
+
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.RowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
@@ -29,6 +35,7 @@ import cn.com.qmth.examcloud.service.examwork.assembler.ExamStudentAssembler;
|
|
|
import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
|
|
|
import cn.com.qmth.examcloud.service.examwork.dao.ExamStudentRepo;
|
|
|
import cn.com.qmth.examcloud.service.examwork.dto.ExamStudentDTO;
|
|
|
+import cn.com.qmth.examcloud.service.examwork.dto.OrgExamInfo;
|
|
|
import cn.com.qmth.examcloud.service.examwork.entity.Exam;
|
|
|
import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
|
|
|
import cn.com.qmth.examcloud.service.examwork.service.rpc.CourseService;
|
|
@@ -61,7 +68,9 @@ public class ExamStudentService {
|
|
|
|
|
|
@Autowired
|
|
|
OrgService orgService;
|
|
|
-
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
// @Value("${app.em.photo.path}")
|
|
|
// private String PHOTO_PATH ;
|
|
@@ -428,4 +437,43 @@ public class ExamStudentService {
|
|
|
throw new RuntimeException("该考试已开始,不能删除");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 学习中心考试进度信息
|
|
|
+ * @param examId
|
|
|
+ * @param orgCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<OrgExamInfo> findOrgExamInfos(String examId,String orgCode){
|
|
|
+ if(!StringUtils.hasLength(examId)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ StringBuilder sql = new StringBuilder();
|
|
|
+ sql.append("select t.org_id orgid,"+
|
|
|
+ " t.org_code orgcode,"+
|
|
|
+ " t.org_name orgname,"+
|
|
|
+ " count(t.id) allNum,"+
|
|
|
+ " sum(case when t.finished = 1 then 1 else 0 end) completedNum "+
|
|
|
+ " from ecs_exam_student t"+
|
|
|
+ " where t.exam_id = ?");
|
|
|
+ if(StringUtils.hasLength(orgCode)){
|
|
|
+ sql.append(" and t.org_code = '"+orgCode+"'");
|
|
|
+ }
|
|
|
+ sql.append(" group by t.org_id, t.org_name order by t.org_id");
|
|
|
+ return jdbcTemplate.query(sql.toString(),new Object[]{examId}, new RowMapper<OrgExamInfo>(){
|
|
|
+ @Override
|
|
|
+ public OrgExamInfo mapRow(ResultSet rs, int rowNum)throws SQLException {
|
|
|
+ OrgExamInfo orgExamInfo = new OrgExamInfo();
|
|
|
+ orgExamInfo.setOrgId(rs.getLong("orgid")+"");
|
|
|
+ orgExamInfo.setOrgCode(rs.getString("orgcode"));
|
|
|
+ orgExamInfo.setOrgName(rs.getString("orgname"));
|
|
|
+ orgExamInfo.setAllNum(rs.getInt("allNum"));
|
|
|
+ orgExamInfo.setCompletedNum(rs.getInt("completedNum"));
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+ double proportion = orgExamInfo.getCompletedNum()/orgExamInfo.getAllNum();
|
|
|
+ orgExamInfo.setProportion(df.format(proportion));
|
|
|
+ return orgExamInfo;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|