瀏覽代碼

。。。

wangwei 7 年之前
父節點
當前提交
99e73cad38
共有 21 個文件被更改,包括 1842 次插入1842 次删除
  1. 27 80
      examcloud-core-examwork-export/pom.xml
  2. 73 20
      examcloud-core-examwork-service/pom.xml
  3. 112 112
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamCourseService.java
  4. 60 60
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamOrgTimeService.java
  5. 84 84
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamScoreService.java
  6. 175 175
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamService.java
  7. 825 825
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java
  8. 34 34
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/CourseService.java
  9. 23 23
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/OeService.java
  10. 35 35
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/OrgService.java
  11. 29 29
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/SpecialtyService.java
  12. 49 49
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/StudentService.java
  13. 24 24
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/CourseClient.java
  14. 19 19
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/OeClient.java
  15. 21 21
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/OrgClient.java
  16. 19 19
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/SpecialtyClient.java
  17. 31 31
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/StudentClient.java
  18. 81 81
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/sync/DataReceiveService.java
  19. 26 26
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/sync/DataSendService.java
  20. 37 37
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/util/ExportUtils.java
  21. 58 58
      examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/util/ImportUtils.java

+ 27 - 80
examcloud-core-examwork-export/pom.xml

@@ -1,80 +1,27 @@
-<?xml version="1.0"?>
-<project
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
-	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-	<modelVersion>4.0.0</modelVersion>
-	<parent>
-		<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
-		<artifactId>examcloud-core-examwork</artifactId>
-		<version>0.1.0</version>
-	</parent>
-	<artifactId>examcloud-core-examwork-export</artifactId>
-	<packaging>jar</packaging>
-
-	<dependencies>
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-feign</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-eureka</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-web</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-data-redis</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>io.springfox</groupId>
-			<artifactId>springfox-swagger2</artifactId>
-			<version>2.6.1</version>
-		</dependency>
-		<dependency>
-			<groupId>io.springfox</groupId>
-			<artifactId>springfox-swagger-ui</artifactId>
-			<version>2.6.1</version>
-		</dependency>
-
-		<dependency>
-			<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
-			<artifactId>examcloud-core-examwork-domain</artifactId>
-			<version>${examcloud.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
-			<artifactId>examcloud-core-examwork-service</artifactId>
-			<version>${examcloud.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>cn.com.qmth.examcloud.commons</groupId>
-			<artifactId>examcloud-commons-uac</artifactId>
-			<version>${examcloud.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>cn.com.qmth.examcloud.commons</groupId>
-			<artifactId>examcloud-commons-dto</artifactId>
-			<version>${examcloud.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>com.esotericsoftware</groupId>
-			<artifactId>reflectasm</artifactId>
-			<version>1.11.3</version>
-		</dependency>
-
-		<dependency>
-			<groupId>commons-fileupload</groupId>
-			<artifactId>commons-fileupload</artifactId>
-			<version>1.3.2</version>
-		</dependency>
-
-		<dependency>
-			<groupId>com.qmth.commons</groupId>
-			<artifactId>data-sync-rabbit</artifactId>
-			<version>1.0-SNAPSHOT</version>
-		</dependency>
-	</dependencies>
-</project>
+<?xml version="1.0"?>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
+		<artifactId>examcloud-core-examwork</artifactId>
+		<version>0.1.0</version>
+	</parent>
+	<artifactId>examcloud-core-examwork-export</artifactId>
+	<packaging>jar</packaging>
+
+	<dependencies>
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
+			<artifactId>examcloud-core-examwork-domain</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
+			<artifactId>examcloud-core-examwork-service</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
+
+	</dependencies>
+</project>

+ 73 - 20
examcloud-core-examwork-service/pom.xml

@@ -1,20 +1,73 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	<parent>
-		<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
-		<artifactId>examcloud-core-examwork</artifactId>
-		<version>0.1.0</version>
-	</parent>
-	<artifactId>examcloud-core-examwork-service</artifactId>
-
-	<dependencies>
-		<dependency>
-			<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
-			<artifactId>examcloud-core-examwork-dao</artifactId>
-			<version>${examcloud.version}</version>
-		</dependency>
-	</dependencies>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
+		<artifactId>examcloud-core-examwork</artifactId>
+		<version>0.1.0</version>
+	</parent>
+	<artifactId>examcloud-core-examwork-service</artifactId>
+
+	<dependencies>
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.core.examwork</groupId>
+			<artifactId>examcloud-core-examwork-dao</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-feign</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-eureka</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-redis</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>io.springfox</groupId>
+			<artifactId>springfox-swagger2</artifactId>
+			<version>2.6.1</version>
+		</dependency>
+		<dependency>
+			<groupId>io.springfox</groupId>
+			<artifactId>springfox-swagger-ui</artifactId>
+			<version>2.6.1</version>
+		</dependency>
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.commons</groupId>
+			<artifactId>examcloud-commons-uac</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.commons</groupId>
+			<artifactId>examcloud-commons-dto</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>com.esotericsoftware</groupId>
+			<artifactId>reflectasm</artifactId>
+			<version>1.11.3</version>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-fileupload</groupId>
+			<artifactId>commons-fileupload</artifactId>
+			<version>1.3.2</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.qmth.commons</groupId>
+			<artifactId>data-sync-rabbit</artifactId>
+			<version>1.0-SNAPSHOT</version>
+		</dependency>
+	</dependencies>
+
+</project>

+ 112 - 112
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamCourseService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamCourseService.java

@@ -1,112 +1,112 @@
-package cn.com.qmth.examcloud.service.examwork.service;
-
-import cn.com.qmth.examcloud.service.examwork.criteria.ExamCourseCriteria;
-import cn.com.qmth.examcloud.service.examwork.dto.ExamCourseDTO;
-import cn.com.qmth.examcloud.service.examwork.entity.Exam;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageImpl;
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * Created by songyue on 18/4/2.
- */
-@Service
-public class ExamCourseService {
-
-    @Autowired
-    private JdbcTemplate jdbcTemplate;
-
-    @Autowired
-    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
-
-    public Page<ExamCourseDTO> findAllPage(ExamCourseCriteria examCourseCriteria){
-        StringBuilder sql = new StringBuilder();
-        sql.append(buildBaseSql());
-        sql.append(buildCriteriaSql(examCourseCriteria));
-        sql.append(buildGroupSql());
-        sql.append(buildPageSql(examCourseCriteria));
-        BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(ExamCourseDTO.class);
-        List<ExamCourseDTO> projectStatDTOs = this.namedParameterJdbcTemplate.query(sql.toString(), mapper);
-        long total = countAll(examCourseCriteria);
-        return new PageImpl<ExamCourseDTO>(projectStatDTOs,examCourseCriteria.getPageable(),total);
-
-    }
-
-    public List<ExamCourseDTO> findAll(ExamCourseCriteria examCourseCriteria){
-        StringBuilder sql = new StringBuilder();
-        sql.append(buildBaseSql());
-        sql.append(buildCriteriaSql(examCourseCriteria));
-        sql.append(buildGroupSql());
-        BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(ExamCourseDTO.class);
-        List<ExamCourseDTO> projectStatDTOs = this.namedParameterJdbcTemplate.query(sql.toString(), mapper);
-        return projectStatDTOs;
-    }
-
-    private long countAll(ExamCourseCriteria examCourseCriteria){
-        StringBuffer sql = new StringBuffer();
-        sql.append(buildCountSql(examCourseCriteria));
-        return this.jdbcTemplate.queryForObject(sql.toString(),Long.class);
-    }
-
-    private String buildPageSql(ExamCourseCriteria examCourseCriteria){
-        StringBuilder pageSql = new StringBuilder();
-        int currentNum = examCourseCriteria.getCurPage() * examCourseCriteria.getPageSize();
-        pageSql.append(" limit "+currentNum+","+examCourseCriteria.getPageSize());
-        return pageSql.toString();
-    }
-
-    private String buildCriteriaSql(ExamCourseCriteria examCourseCriteria){
-        StringBuilder criteriaSql = new StringBuilder();
-        if(examCourseCriteria.getExamId() != null){
-            criteriaSql.append(" and exam_id ="+examCourseCriteria.getExamId());
-        }
-        if(!StringUtils.isEmpty(examCourseCriteria.getCourseCode())){
-            criteriaSql.append(" and course_code ='"+examCourseCriteria.getCourseCode()+"'");
-        }
-        if(!StringUtils.isEmpty(examCourseCriteria.getCourseLevel())){
-            criteriaSql.append(" and course_level ='"+examCourseCriteria.getCourseLevel()+"'");
-        }
-        criteriaSql.append(" and exists (select 1 from ecs_core_course tc where tc.org_id = ts.root_org_id" +
-                                        " and tc.code = ts.course_code" +
-                                        " and tc.enable = 1)");
-        return criteriaSql.toString();
-    }
-
-    private String buildGroupSql(){
-        return " group by ts.course_code order by ts.course_code";
-    }
-
-    private String buildBaseSql(){
-        StringBuilder baseSql = new StringBuilder();
-        baseSql.append("select" +
-                        " ts.exam_id as exam_id," +
-                        " te.name as exam_name," +
-                        " te.exam_type as exam_type," +
-                        " ts.course_code as course_code," +
-                        " ts.course_name as course_name," +
-                        " ts.root_org_id as org_id" +
-                        " from" +
-                        " ecs_exam_student ts," +
-                        " ecs_exam te" +
-                        " where ts.exam_id = te.id");
-        return baseSql.toString();
-    }
-
-    private String buildCountSql(ExamCourseCriteria examCourseCriteria){
-        StringBuilder countSql = new StringBuilder();
-        countSql.append("select count(*) from (");
-        countSql.append(buildBaseSql());
-        countSql.append(buildCriteriaSql(examCourseCriteria));
-        countSql.append(buildGroupSql());
-        countSql.append(")as tt");
-        return countSql.toString();
-    }
-
-}
+package cn.com.qmth.examcloud.service.examwork.service;
+
+import cn.com.qmth.examcloud.service.examwork.criteria.ExamCourseCriteria;
+import cn.com.qmth.examcloud.service.examwork.dto.ExamCourseDTO;
+import cn.com.qmth.examcloud.service.examwork.entity.Exam;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * Created by songyue on 18/4/2.
+ */
+@Service
+public class ExamCourseService {
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Autowired
+    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
+
+    public Page<ExamCourseDTO> findAllPage(ExamCourseCriteria examCourseCriteria){
+        StringBuilder sql = new StringBuilder();
+        sql.append(buildBaseSql());
+        sql.append(buildCriteriaSql(examCourseCriteria));
+        sql.append(buildGroupSql());
+        sql.append(buildPageSql(examCourseCriteria));
+        BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(ExamCourseDTO.class);
+        List<ExamCourseDTO> projectStatDTOs = this.namedParameterJdbcTemplate.query(sql.toString(), mapper);
+        long total = countAll(examCourseCriteria);
+        return new PageImpl<ExamCourseDTO>(projectStatDTOs,examCourseCriteria.getPageable(),total);
+
+    }
+
+    public List<ExamCourseDTO> findAll(ExamCourseCriteria examCourseCriteria){
+        StringBuilder sql = new StringBuilder();
+        sql.append(buildBaseSql());
+        sql.append(buildCriteriaSql(examCourseCriteria));
+        sql.append(buildGroupSql());
+        BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(ExamCourseDTO.class);
+        List<ExamCourseDTO> projectStatDTOs = this.namedParameterJdbcTemplate.query(sql.toString(), mapper);
+        return projectStatDTOs;
+    }
+
+    private long countAll(ExamCourseCriteria examCourseCriteria){
+        StringBuffer sql = new StringBuffer();
+        sql.append(buildCountSql(examCourseCriteria));
+        return this.jdbcTemplate.queryForObject(sql.toString(),Long.class);
+    }
+
+    private String buildPageSql(ExamCourseCriteria examCourseCriteria){
+        StringBuilder pageSql = new StringBuilder();
+        int currentNum = examCourseCriteria.getCurPage() * examCourseCriteria.getPageSize();
+        pageSql.append(" limit "+currentNum+","+examCourseCriteria.getPageSize());
+        return pageSql.toString();
+    }
+
+    private String buildCriteriaSql(ExamCourseCriteria examCourseCriteria){
+        StringBuilder criteriaSql = new StringBuilder();
+        if(examCourseCriteria.getExamId() != null){
+            criteriaSql.append(" and exam_id ="+examCourseCriteria.getExamId());
+        }
+        if(!StringUtils.isEmpty(examCourseCriteria.getCourseCode())){
+            criteriaSql.append(" and course_code ='"+examCourseCriteria.getCourseCode()+"'");
+        }
+        if(!StringUtils.isEmpty(examCourseCriteria.getCourseLevel())){
+            criteriaSql.append(" and course_level ='"+examCourseCriteria.getCourseLevel()+"'");
+        }
+        criteriaSql.append(" and exists (select 1 from ecs_core_course tc where tc.org_id = ts.root_org_id" +
+                                        " and tc.code = ts.course_code" +
+                                        " and tc.enable = 1)");
+        return criteriaSql.toString();
+    }
+
+    private String buildGroupSql(){
+        return " group by ts.course_code order by ts.course_code";
+    }
+
+    private String buildBaseSql(){
+        StringBuilder baseSql = new StringBuilder();
+        baseSql.append("select" +
+                        " ts.exam_id as exam_id," +
+                        " te.name as exam_name," +
+                        " te.exam_type as exam_type," +
+                        " ts.course_code as course_code," +
+                        " ts.course_name as course_name," +
+                        " ts.root_org_id as org_id" +
+                        " from" +
+                        " ecs_exam_student ts," +
+                        " ecs_exam te" +
+                        " where ts.exam_id = te.id");
+        return baseSql.toString();
+    }
+
+    private String buildCountSql(ExamCourseCriteria examCourseCriteria){
+        StringBuilder countSql = new StringBuilder();
+        countSql.append("select count(*) from (");
+        countSql.append(buildBaseSql());
+        countSql.append(buildCriteriaSql(examCourseCriteria));
+        countSql.append(buildGroupSql());
+        countSql.append(")as tt");
+        return countSql.toString();
+    }
+
+}

+ 60 - 60
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamOrgTimeService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamOrgTimeService.java

@@ -1,60 +1,60 @@
-package cn.com.qmth.examcloud.service.examwork.service;
-
-import cn.com.qmth.examcloud.service.examwork.dao.ExamOrgTimeRepo;
-import cn.com.qmth.examcloud.service.examwork.entity.ExamOrgTime;
-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.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by songyue on 18/3/1.
- */
-@Service
-public class ExamOrgTimeService {
-
-
-    @Autowired
-    private ExamOrgTimeRepo examOrgTimeRepo;
-
-    /**
-     * 获取所有学习中心考试时间(分页)
-     * @param examOrgTime
-     * @param pageable
-     * @return
-     * @return
-     */
-    public Page<ExamOrgTime> getAllOrgTime(ExamOrgTime examOrgTime, Pageable pageable){
-        Specification<ExamOrgTime> specification = getPageSpecification(examOrgTime);
-        Page<ExamOrgTime> examOrgTimes = examOrgTimeRepo.findAll(specification,pageable);
-        return examOrgTimes;
-    }
-
-    /**
-     * 生成查询条件
-     * @param examOrgTime
-     * @return
-     */
-    private Specification<ExamOrgTime> getPageSpecification(ExamOrgTime examOrgTime) {
-        Specification<ExamOrgTime> specification = (root, query, cb) -> {
-            List<Predicate> predicates = new ArrayList<>();
-            if(!StringUtils.isEmpty(examOrgTime.getExamId())){
-                predicates.add(cb.equal(root.get("examId"),examOrgTime.getExamId()));
-            }
-            if(!StringUtils.isEmpty(examOrgTime.getOrgCode())){
-                predicates.add(cb.like(root.get("orgCode"),"%"+examOrgTime.getOrgCode()+"%"));
-            }
-            if(!StringUtils.isEmpty(examOrgTime.getOrgName())){
-                predicates.add(cb.like(root.get("orgName"),"%"+examOrgTime.getOrgName()+"%"));
-            }
-            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-        };
-        return specification;
-    }
-}
+package cn.com.qmth.examcloud.service.examwork.service;
+
+import cn.com.qmth.examcloud.service.examwork.dao.ExamOrgTimeRepo;
+import cn.com.qmth.examcloud.service.examwork.entity.ExamOrgTime;
+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.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.criteria.Predicate;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by songyue on 18/3/1.
+ */
+@Service
+public class ExamOrgTimeService {
+
+
+    @Autowired
+    private ExamOrgTimeRepo examOrgTimeRepo;
+
+    /**
+     * 获取所有学习中心考试时间(分页)
+     * @param examOrgTime
+     * @param pageable
+     * @return
+     * @return
+     */
+    public Page<ExamOrgTime> getAllOrgTime(ExamOrgTime examOrgTime, Pageable pageable){
+        Specification<ExamOrgTime> specification = getPageSpecification(examOrgTime);
+        Page<ExamOrgTime> examOrgTimes = examOrgTimeRepo.findAll(specification,pageable);
+        return examOrgTimes;
+    }
+
+    /**
+     * 生成查询条件
+     * @param examOrgTime
+     * @return
+     */
+    private Specification<ExamOrgTime> getPageSpecification(ExamOrgTime examOrgTime) {
+        Specification<ExamOrgTime> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+            if(!StringUtils.isEmpty(examOrgTime.getExamId())){
+                predicates.add(cb.equal(root.get("examId"),examOrgTime.getExamId()));
+            }
+            if(!StringUtils.isEmpty(examOrgTime.getOrgCode())){
+                predicates.add(cb.like(root.get("orgCode"),"%"+examOrgTime.getOrgCode()+"%"));
+            }
+            if(!StringUtils.isEmpty(examOrgTime.getOrgName())){
+                predicates.add(cb.like(root.get("orgName"),"%"+examOrgTime.getOrgName()+"%"));
+            }
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+        return specification;
+    }
+}

+ 84 - 84
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamScoreService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamScoreService.java

@@ -1,84 +1,84 @@
-package cn.com.qmth.examcloud.service.examwork.service;
-
-import cn.com.qmth.examcloud.service.examwork.dao.ExamScoreRepo;
-import cn.com.qmth.examcloud.service.examwork.entity.ExamScore;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
-import org.springframework.data.domain.ExampleMatcher;
-import org.springframework.data.domain.Pageable;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Service;
-
-import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
-
-/**
- * Created by songyue on 17/1/14.
- */
-@Service
-public class ExamScoreService {
-    @Autowired
-    ExamScoreRepo examScoreRepo;
-
-    /**
-     * 获取所有考试分数(分页)
-     * @param examCriteria
-     * @param pageable
-     * @return
-     */
-    public ResponseEntity getAllExamScore(ExamScore examCriteria, Pageable pageable){
-        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",startsWith());
-        Example<ExamScore> examExamScoreple = Example.of(examCriteria, exampleMatcher);
-        return new ResponseEntity(examScoreRepo.findAll(examExamScoreple,pageable), HttpStatus.OK);
-    }
-
-    /**
-     * 获取所有考试分数
-     * @param examCriteria
-     * @return
-     */
-    public ResponseEntity getAllExamScore(ExamScore examCriteria){
-        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",startsWith());
-        Example<ExamScore> examExamScoreple = Example.of(examCriteria, exampleMatcher);
-        return new ResponseEntity(examScoreRepo.findAll(examExamScoreple), HttpStatus.OK);
-    }
-
-    /**
-     * 按ID获取考试分数
-     * @param scoreId
-     * @return
-     */
-    public ResponseEntity<ExamScore> getExamScoreById(Long scoreId){
-        return new ResponseEntity<ExamScore>(examScoreRepo.findOne(scoreId),HttpStatus.OK);
-    }
-
-    /**
-     * 保存考试分数
-     * @param exam
-     * @return
-     */
-    public ResponseEntity saveExamScore(ExamScore exam){
-        return new ResponseEntity(examScoreRepo.save(exam),HttpStatus.OK);
-    }
-
-    /**
-     * 删除考试分数
-     * @param examId
-     * @return
-     */
-    public ResponseEntity deleteExamScore(Long examId){
-        examScoreRepo.delete(examId);
-        return new ResponseEntity(HttpStatus.OK);
-    }
-
-    /**
-     * 删除所有考试分数
-     * @return
-     */
-    public ResponseEntity deleteAllExamScore(){
-        examScoreRepo.deleteAll();
-        return new ResponseEntity(HttpStatus.OK);
-    }
-}
+package cn.com.qmth.examcloud.service.examwork.service;
+
+import cn.com.qmth.examcloud.service.examwork.dao.ExamScoreRepo;
+import cn.com.qmth.examcloud.service.examwork.entity.ExamScore;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Pageable;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+/**
+ * Created by songyue on 17/1/14.
+ */
+@Service
+public class ExamScoreService {
+    @Autowired
+    ExamScoreRepo examScoreRepo;
+
+    /**
+     * 获取所有考试分数(分页)
+     * @param examCriteria
+     * @param pageable
+     * @return
+     */
+    public ResponseEntity getAllExamScore(ExamScore examCriteria, Pageable pageable){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("name",startsWith());
+        Example<ExamScore> examExamScoreple = Example.of(examCriteria, exampleMatcher);
+        return new ResponseEntity(examScoreRepo.findAll(examExamScoreple,pageable), HttpStatus.OK);
+    }
+
+    /**
+     * 获取所有考试分数
+     * @param examCriteria
+     * @return
+     */
+    public ResponseEntity getAllExamScore(ExamScore examCriteria){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("name",startsWith());
+        Example<ExamScore> examExamScoreple = Example.of(examCriteria, exampleMatcher);
+        return new ResponseEntity(examScoreRepo.findAll(examExamScoreple), HttpStatus.OK);
+    }
+
+    /**
+     * 按ID获取考试分数
+     * @param scoreId
+     * @return
+     */
+    public ResponseEntity<ExamScore> getExamScoreById(Long scoreId){
+        return new ResponseEntity<ExamScore>(examScoreRepo.findOne(scoreId),HttpStatus.OK);
+    }
+
+    /**
+     * 保存考试分数
+     * @param exam
+     * @return
+     */
+    public ResponseEntity saveExamScore(ExamScore exam){
+        return new ResponseEntity(examScoreRepo.save(exam),HttpStatus.OK);
+    }
+
+    /**
+     * 删除考试分数
+     * @param examId
+     * @return
+     */
+    public ResponseEntity deleteExamScore(Long examId){
+        examScoreRepo.delete(examId);
+        return new ResponseEntity(HttpStatus.OK);
+    }
+
+    /**
+     * 删除所有考试分数
+     * @return
+     */
+    public ResponseEntity deleteAllExamScore(){
+        examScoreRepo.deleteAll();
+        return new ResponseEntity(HttpStatus.OK);
+    }
+}

+ 175 - 175
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamService.java

@@ -1,175 +1,175 @@
-package cn.com.qmth.examcloud.service.examwork.service;
-
-import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import cn.com.qmth.examcloud.common.dto.core.Org;
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
-import cn.com.qmth.examcloud.service.examwork.dao.ExamOrgTimeRepo;
-import cn.com.qmth.examcloud.service.examwork.entity.ExamOrgTime;
-import cn.com.qmth.examcloud.service.examwork.enums.ExamType;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.OrgService;
-import cn.com.qmth.examcloud.service.examwork.service.sync.DataSendService;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
-import org.springframework.data.domain.ExampleMatcher;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.domain.Sort.Direction;
-import org.springframework.stereotype.Service;
-
-import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
-import cn.com.qmth.examcloud.service.examwork.entity.Exam;
-
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * 考试批次服务类
- * Created by songyue on 17/1/13.
- */
-@Service
-public class ExamService {
-    @Autowired
-    ExamRepo examRepo;
-
-    @Autowired
-    ExamStudentService examStudentService;
-
-    @Autowired
-    ExamOrgTimeRepo examOrgTimeRepo;
-
-    @Autowired
-    OrgService orgService;
-    
-    @Autowired
-    DataSendService dataSendService;
-
-    /**
-     * 获取所有考试批次(分页)
-     * @param examCriteria
-     * @param pageable
-     * @return
-     */
-    public Page<Exam> getAllExam(Exam examCriteria, Pageable pageable){
-        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",contains());
-        Example<Exam> examExample = Example.of(examCriteria, exampleMatcher);
-        return examRepo.findAll(examExample,pageable);
-    }
-
-    /**
-     * 获取所有考试批次
-     * @param examCriteria
-     * @return 
-     * @return
-     */
-    public List<Exam> getAllExam(Exam examCriteria){
-    	ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",contains());
-        Example<Exam> examExample = Example.of(examCriteria,exampleMatcher);
-        return examRepo.findAll(examExample, new Sort(Direction.DESC,"id"));
-    }
-
-    /**
-     * 按ID获取考试批次
-     * @param examId
-     * @return
-     */
-    public Exam getExamById(Long examId){
-        return examRepo.findOne(examId);
-    }
-
-    /**
-     * 保存考试批次
-     * @param exam
-     * @return
-     */
-    public Exam saveExam(Exam exam){
-    	Exam newExam = examRepo.save(exam);
-    	/*if(newExam.getId() != null){
-    		dataSendService.sendExam(newExam);
-    	}*/
-        return newExam;
-    }
-
-    @Transactional
-    public Exam insertExam(Exam exam, AccessUser accessUser){
-        ExamType examType = exam.getExamType();
-        if(examType == ExamType.OFFLINE){
-            Exam newExam = examRepo.save(exam);
-            insertExamOrgTime(newExam,accessUser);
-            return newExam;
-        }
-        return examRepo.save(exam);
-    }
-
-    /**
-     * 新增学习中心考试时间
-     * @param exam
-     * @param accessUser
-     */
-    private void insertExamOrgTime(Exam exam,AccessUser accessUser){
-        Long examId = exam.getId();
-        Long rootOrgId = accessUser.getRootOrgId();
-        String token = accessUser.getToken();
-        Date beginTime = exam.getBeginTime();
-        Date endTime = exam.getEndTime();
-        List<Org> orgList = orgService.findByParentId(token,rootOrgId);
-        List<ExamOrgTime> examOrgTimes = new ArrayList<>();
-        for(Org org:orgList){
-            Long orgId = org.getId();
-            String orgCode = org.getCode();
-            String orgName = org.getName();
-            ExamOrgTime examOrgTime = new ExamOrgTime(examId, orgId, orgCode,
-                                                      orgName, beginTime, endTime);
-            examOrgTimes.add(examOrgTime);
-        }
-        examOrgTimeRepo.save(examOrgTimes);
-    }
-
-    /**
-     * 删除考试批次
-     * @param ids
-     * @return
-     */
-    @Transactional
-    public void deleteExam(List<Long> ids)throws Exception{
-        List<Exam> exams = examRepo.findByIdIn(ids);
-        for(Exam exam:exams){
-            //删除考生
-            if(exam.getCanStuDel()){
-                //删除学习中心考试时间
-                examOrgTimeRepo.deleteByExamId(exam.getId());
-                examStudentService.deleteExamStudents(exam.getId());
-                examRepo.delete(exam);
-            }else{
-                throw new RuntimeException(exam.getName()+"批次已经开始,不能删除");
-            }
-        }
-    }
-
-
-    public boolean checkExamName(Exam exam){
-        if(exam.getId()!=null){
-            if(examRepo.countByNameAndRootOrgIdAndIdNot(exam.getName(),
-                                                        exam.getRootOrgId(),
-                                                        exam.getId()) > 0){
-                return false;
-            }else{
-                return true;
-            }
-        }else{
-            if(examRepo.countByNameAndRootOrgId(exam.getName(),exam.getRootOrgId()) > 0){
-                return false;
-            }else{
-                return true;
-            }
-        }
-
-    }
-}
+package cn.com.qmth.examcloud.service.examwork.service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import cn.com.qmth.examcloud.common.dto.core.Org;
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+import cn.com.qmth.examcloud.service.examwork.dao.ExamOrgTimeRepo;
+import cn.com.qmth.examcloud.service.examwork.entity.ExamOrgTime;
+import cn.com.qmth.examcloud.service.examwork.enums.ExamType;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.OrgService;
+import cn.com.qmth.examcloud.service.examwork.service.sync.DataSendService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
+import cn.com.qmth.examcloud.service.examwork.entity.Exam;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 考试批次服务类
+ * Created by songyue on 17/1/13.
+ */
+@Service
+public class ExamService {
+    @Autowired
+    ExamRepo examRepo;
+
+    @Autowired
+    ExamStudentService examStudentService;
+
+    @Autowired
+    ExamOrgTimeRepo examOrgTimeRepo;
+
+    @Autowired
+    OrgService orgService;
+    
+    @Autowired
+    DataSendService dataSendService;
+
+    /**
+     * 获取所有考试批次(分页)
+     * @param examCriteria
+     * @param pageable
+     * @return
+     */
+    public Page<Exam> getAllExam(Exam examCriteria, Pageable pageable){
+        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("name",contains());
+        Example<Exam> examExample = Example.of(examCriteria, exampleMatcher);
+        return examRepo.findAll(examExample,pageable);
+    }
+
+    /**
+     * 获取所有考试批次
+     * @param examCriteria
+     * @return 
+     * @return
+     */
+    public List<Exam> getAllExam(Exam examCriteria){
+    	ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+                .withMatcher("name",contains());
+        Example<Exam> examExample = Example.of(examCriteria,exampleMatcher);
+        return examRepo.findAll(examExample, new Sort(Direction.DESC,"id"));
+    }
+
+    /**
+     * 按ID获取考试批次
+     * @param examId
+     * @return
+     */
+    public Exam getExamById(Long examId){
+        return examRepo.findOne(examId);
+    }
+
+    /**
+     * 保存考试批次
+     * @param exam
+     * @return
+     */
+    public Exam saveExam(Exam exam){
+    	Exam newExam = examRepo.save(exam);
+    	/*if(newExam.getId() != null){
+    		dataSendService.sendExam(newExam);
+    	}*/
+        return newExam;
+    }
+
+    @Transactional
+    public Exam insertExam(Exam exam, AccessUser accessUser){
+        ExamType examType = exam.getExamType();
+        if(examType == ExamType.OFFLINE){
+            Exam newExam = examRepo.save(exam);
+            insertExamOrgTime(newExam,accessUser);
+            return newExam;
+        }
+        return examRepo.save(exam);
+    }
+
+    /**
+     * 新增学习中心考试时间
+     * @param exam
+     * @param accessUser
+     */
+    private void insertExamOrgTime(Exam exam,AccessUser accessUser){
+        Long examId = exam.getId();
+        Long rootOrgId = accessUser.getRootOrgId();
+        String token = accessUser.getToken();
+        Date beginTime = exam.getBeginTime();
+        Date endTime = exam.getEndTime();
+        List<Org> orgList = orgService.findByParentId(token,rootOrgId);
+        List<ExamOrgTime> examOrgTimes = new ArrayList<>();
+        for(Org org:orgList){
+            Long orgId = org.getId();
+            String orgCode = org.getCode();
+            String orgName = org.getName();
+            ExamOrgTime examOrgTime = new ExamOrgTime(examId, orgId, orgCode,
+                                                      orgName, beginTime, endTime);
+            examOrgTimes.add(examOrgTime);
+        }
+        examOrgTimeRepo.save(examOrgTimes);
+    }
+
+    /**
+     * 删除考试批次
+     * @param ids
+     * @return
+     */
+    @Transactional
+    public void deleteExam(List<Long> ids)throws Exception{
+        List<Exam> exams = examRepo.findByIdIn(ids);
+        for(Exam exam:exams){
+            //删除考生
+            if(exam.getCanStuDel()){
+                //删除学习中心考试时间
+                examOrgTimeRepo.deleteByExamId(exam.getId());
+                examStudentService.deleteExamStudents(exam.getId());
+                examRepo.delete(exam);
+            }else{
+                throw new RuntimeException(exam.getName()+"批次已经开始,不能删除");
+            }
+        }
+    }
+
+
+    public boolean checkExamName(Exam exam){
+        if(exam.getId()!=null){
+            if(examRepo.countByNameAndRootOrgIdAndIdNot(exam.getName(),
+                                                        exam.getRootOrgId(),
+                                                        exam.getId()) > 0){
+                return false;
+            }else{
+                return true;
+            }
+        }else{
+            if(examRepo.countByNameAndRootOrgId(exam.getName(),exam.getRootOrgId()) > 0){
+                return false;
+            }else{
+                return true;
+            }
+        }
+
+    }
+}

+ 825 - 825
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java

@@ -1,825 +1,825 @@
-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.Date;
-import java.util.List;
-
-import javax.persistence.criteria.Predicate;
-
-import cn.com.qmth.examcloud.common.util.BeanCopierUtil;
-import cn.com.qmth.examcloud.service.examwork.dao.ExamOrgTimeRepo;
-import cn.com.qmth.examcloud.service.examwork.entity.ExamOrgTime;
-import cn.com.qmth.examcloud.service.examwork.enums.ExamType;
-
-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.PageImpl;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.domain.Sort.Direction;
-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;
-
-import cn.com.qmth.examcloud.common.dto.core.Course;
-import cn.com.qmth.examcloud.common.dto.core.Org;
-import cn.com.qmth.examcloud.common.dto.core.Student;
-import cn.com.qmth.examcloud.common.dto.core.User;
-import cn.com.qmth.examcloud.common.dto.core.enums.UserType;
-import cn.com.qmth.examcloud.common.dto.examwork.CommonExamStudent;
-import cn.com.qmth.examcloud.common.util.ErrorMsg;
-import cn.com.qmth.examcloud.common.util.excel.ExcelError;
-import cn.com.qmth.examcloud.common.util.excel.ExcelReader;
-import cn.com.qmth.examcloud.common.util.excel.ExcelReaderHandle;
-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.OrgExamInfoDTO;
-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;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.OrgService;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.SpecialtyService;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.StudentService;
-
-/**
- * 考试学生服务类
- * Created by songyue on 17/1/14.
- */
-@Service
-public class ExamStudentService {
-
-	protected static final Logger log = LoggerFactory.getLogger(ExamStudentService.class);
-
-    @Autowired
-    ExamStudentRepo examStudentRepo;
-
-    @Autowired
-    ExamRepo examRepo;
-
-    @Autowired
-    ExamStudentAssembler examStudentAssembler;
-
-    @Autowired
-    StudentService studentService;
-
-    @Autowired
-    CourseService courseService;
-
-    @Autowired
-    OrgService orgService;
-    
-    @Autowired
-	private JdbcTemplate jdbcTemplate;
-
-	@Autowired
-	SpecialtyService specialtyService;
-
-	@Autowired
-	ExamOrgTimeRepo examOrgTimeRepo;
-
-    /**
-     * 获取所有考试学生(分页)
-     * @param examCriteria
-     * @param pageable
-     * @return 
-     * @return
-     */
-    public Page<ExamStudent> getAllExamStudent(ExamStudentDTO examCriteria, Pageable pageable){
-    	Specification<ExamStudent> specification = getPageSpecification(examCriteria);
-		Page<ExamStudent> examStudents = examStudentRepo.findAll(specification,pageable);
-		processExamStudent(examStudents.getContent());
-        return examStudents;
-    }
-
-    /**
-     * 获取所有考试学生
-     * @param examCriteria
-     * @return 
-     * @return
-     */
-    public List<ExamStudent> getAllExamStudent(ExamStudentDTO examCriteria){
-    	Specification<ExamStudent> specification = getSpecification(examCriteria);
-		List<ExamStudent> examStudents = examStudentRepo.findAll(specification,new Sort(Direction.DESC,"id"));
-		processExamStudent(examStudents);
-        return examStudents;
-    }
-
-	/**
-	 * 处理考生集合(设置学习中心考试时间)
-	 * @param examStudents
-     */
-    private void processExamStudent(List<ExamStudent> examStudents){
-		for(ExamStudent examStudent:examStudents){
-			//设置学习中心考试时间
-			setExamOrgTime(examStudent);
-		}
-	}
-
-	/**
-	 * 设置学习中心考试时间
-	 * @param examStudent
-     */
-	private void setExamOrgTime(ExamStudent examStudent){
-		Exam exam = examStudent.getExam();
-		if(exam != null){
-			if(exam.getExamType() == ExamType.OFFLINE){
-				Long examId = exam.getId();
-				Long orgId = examStudent.getOrgId();
-				ExamOrgTime examOrgTime = examOrgTimeRepo.findFirstByExamIdAndOrgId(examId,orgId);
-				if(examOrgTime != null){
-					String examBeginTime = String.valueOf(examOrgTime.getBeginTime().getTime());
-					String examEndTime = String.valueOf(examOrgTime.getEndTime().getTime());
-					examStudent.setExamBeginTime(examBeginTime);
-					examStudent.setExamEndTime(examEndTime);
-					examStudent.setCanUpload(getCanUpload(examOrgTime));
-				}
-			}else{
-				String examBeginTime = String.valueOf(exam.getBeginTime().getTime());
-				String examEndTime = String.valueOf(exam.getEndTime().getTime());
-				examStudent.setExamBeginTime(examBeginTime);
-				examStudent.setExamEndTime(examEndTime);
-			}
-		}
-	}
-
-	private Boolean getCanUpload(ExamOrgTime examOrgTime){
-		if(examOrgTime.getCanUpload() == null){
-			Date now = new Date();
-			if(now.after(examOrgTime.getEndTime())){
-				return false;
-			}else{
-				return true;
-			}
-		}else{
-			return examOrgTime.getCanUpload();
-		}
-	}
-
-	public ExamStudent findById(Long id){
-		ExamStudent examStudent = examStudentRepo.findOne(id);
-		setExamOrgTime(examStudent);
-		return examStudent;
-	}
-
-    /**
-     * 按考试批次获取学生
-     * @param examId
-     * @return 
-     * @return
-     */
-    public Page<ExamStudent> getExamStudentByExamId(Long examId,Pageable pageable){
-        return examStudentRepo.findByExamId(examId,pageable);
-    }
-
-    /**
-     * 保存考试学生
-     * @param examStudent
-     * @return
-     */
-    public ExamStudent saveExamStudent(ExamStudent examStudent)throws Exception{
-    	checkExamStudent(examStudent);
-        return saveStudent(examStudent);
-    }
-
-    /**
-     * 导入考试学生
-     * @return
-     */
-	public List<ExcelError> importExamStudent(Long examId, InputStream inputStream) {
-		log.info("导入考生开始");
-		Exam exam = examRepo.findOne(examId);
-		List<ExcelError> excelErrors = new ArrayList<ExcelError>();
-		if(exam == null){
-			ExcelError excelError = new ExcelError(1,"请先创建考试");
-			excelErrors.add(excelError);
-			return excelErrors;
-		}
-		List<ExamStudent> examStudents = new ArrayList<ExamStudent>();
-		ExcelReader excelReader = new ExcelReader(ExamStudentDTO.class);
-        excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
-            @Override
-            public ExcelError handle(Object obj) {
-                ExamStudentDTO dto = (ExamStudentDTO) obj;
-                dto.setRootOrgId(exam.getOrgId());
-                dto.setExam(exam);
-                ExcelError error = importCheck(dto);
-                if (error == null) {
-                	examStudents.add(examStudentAssembler.toDomain(dto));
-                }
-                int stu_num = examStudents.size();
-                if (stu_num % 5000 == 0) {
-                	saveStudentList(examStudents);
-					log.info("已导入"+stu_num+"条数据");
-                }
-                return error;
-            }
-
-        });
-		int stu_num = examStudents.size();
-        saveStudentList(examStudents);
-		log.info("已导入"+stu_num+"条数据");
-		log.info("导入考生结束");
-        return excelErrors;
-	}
-	
-
-	private void saveStudentList(List<ExamStudent> examStudents) {
-		for (ExamStudent examStudent : examStudents) {
-			saveStudent(examStudent);
-		}
-		examStudents.removeAll(examStudents);
-	}
-
-	private ExamStudent saveStudent(ExamStudent examStudent){
-		if(examStudent.getStudentId() == null){
-			Student student = new Student();
-			student.setIdentityNumber(examStudent.getIdentityNumber());
-			student.setName(examStudent.getName());
-			student.setStudentCode(examStudent.getStudentCode());
-			student.setRootOrgId(examStudent.getRootOrgId());
-			student.setOrgId(examStudent.getOrgId());
-			User user = new User();
-			user.setOrgId(examStudent.getOrgId());
-			user.setEnable(true);
-			user.setType(UserType.STUDENT);
-			user.setRootOrgId(examStudent.getRootOrgId());
-			student.setUser(user);
-			student = studentService.addStudent(student);
-			examStudent.setStudentId(student.getId());
-		}else{
-			Student student = studentService.getStudent(examStudent.getStudentId());
-			student.setOrgId(examStudent.getOrgId());
-			student.setName(examStudent.getName());
-			student.setRootOrgId(examStudent.getRootOrgId());
-			student.setStudentCode(examStudent.getStudentCode());
-			student.setIdentityNumber(examStudent.getIdentityNumber());
-			studentService.updateStudent(student);
-		}
-		examStudent.setFinished(false);
-		examStudent.setGraduated(false);
-		examStudent.setDegree(false);
-		examStudent.setRepair(false);
-		return examStudentRepo.save(examStudent);
-	}
-
-	public void checkExamStudent(ExamStudent examStudent){
-		if(examStudent.getId() != null){
-			if(examStudentRepo.checkExamStuById(examStudent.getExam().getId(),
-												examStudent.getRootOrgId(),
-												examStudent.getIdentityNumber(),
-												examStudent.getCourseCode(),
-												examStudent.getId()) > 0){
-				throw new RuntimeException("该考生已存在");
-			}
-		}else{
-			if(examStudentRepo.checkExamStu(examStudent.getExam().getId(),
-											examStudent.getRootOrgId(),
-											examStudent.getIdentityNumber(),
-											examStudent.getCourseCode()) > 0){
-				throw new RuntimeException("该考生已存在");
-			}
-		}
-	}
-	
-	/**
-	 * 考生导入验证
-	 * @param dto
-	 * @return
-	 */
-	public ExcelError importCheck(ExamStudentDTO dto){
-		if(StringUtils.isEmpty(dto.getName())){
-			return new ExcelError("姓名不能为空");
-		}
-		if(StringUtils.isEmpty(dto.getStudentCode())||StringUtils.isEmpty(dto.getIdentityNumber())){
-			return new ExcelError("学号或身份证号不能为空");
-		}else{
-			if(!StringUtils.isEmpty(dto.getStudentCode()) && dto.getStudentCode().length() < 6){
-				return new ExcelError("学号至少为6位");
-			}
-			if(!StringUtils.isEmpty(dto.getIdentityNumber()) && dto.getIdentityNumber().length() < 6){
-				return new ExcelError("身份证号至少为6位");
-			}
-		}
-		if(StringUtils.isEmpty(dto.getCourseCode())){
-			return new ExcelError("课程代码不能为空");
-		}
-		if(StringUtils.isEmpty(dto.getOrgCode())){
-			return new ExcelError("学习中心代码不能为空");
-		}
-//		if(StringUtils.isEmpty(dto.getSpecialtyCode())){
-//			return new ExcelError("专业代码不能为空");
-//		}
-//
-//		Specialty specialty = specialtyService.findByOrgIdAndCode(dto.getOrgId(),dto.getSpecialtyCode());
-//		if(specialty == null || !specialty.getEnable()){
-//			return new ExcelError("专业代码不存在/被禁用");
-//		}
-//		dto.setSpecialtyName(specialty.getName());
-
-		Course course = courseService.findByOrgIdAndCode(dto.getRootOrgId(), dto.getCourseCode());
-		if(course == null || !course.getEnable()){
-			return new ExcelError("课程不存在/被禁用");
-		}
-		dto.setCourseLevel(course.getLevel().toString());
-		dto.setCourseName(course.getName());
-		Org org = orgService.findByParentIdAndCode(dto.getRootOrgId(), dto.getOrgCode());
-		if(org == null || !org.getEnable()){
-			return new ExcelError("学习中心不存在/禁用");
-		}
-		dto.setOrgId(org.getId());
-		dto.setOrgName(org.getName());
-		stuCheck(dto);
-		if(StringUtils.isEmpty(dto.getPaperType())){
-			dto.setPaperType("O");
-		}
-		return null;
-	}
-
-	public void stuCheck(ExamStudentDTO dto){
-		ExamStudent examStudent = null;
-		if(!StringUtils.isEmpty(dto.getIdentityNumber())) {
-			examStudent = examStudentRepo.findFirstByExamId(dto.getExam().getId(), dto.getCourseCode(), dto.getIdentityNumber());
-		}else{
-			examStudent = examStudentRepo.findFirstByExamId(dto.getExam().getId(), dto.getCourseCode(), dto.getStudentCode());
-		}
-		if(examStudent != null){
-			dto.setId(examStudent.getId());
-			dto.setStudentId(examStudent.getStudentId());
-		}
-	}
-
-	/**
-	 * 照片检验
-	 * @param examId
-	 * @return
-	 */
-	public List<ErrorMsg> photoCheck(Long examId) {
-		List<ErrorMsg> msgs = new ArrayList<ErrorMsg>();
-		List<ExamStudent> examStudents = examStudentRepo.findByExamId(examId);
-		for (ExamStudent examStudent : examStudents) {
-			ErrorMsg errorMsg = null;
-			if(!StringUtils.isEmpty(examStudent.getStudentCode())){
-				
-				errorMsg = new ErrorMsg(examStudent.getStudentCode());
-			}else if(!StringUtils.isEmpty(examStudent.getIdentityNumber())){
-				
-				errorMsg =  new ErrorMsg(examStudent.getIdentityNumber());
-			}
-			if(errorMsg != null){
-				msgs.add(errorMsg);
-			}
-		}
-		return msgs;
-	}
-	
-	/**
-	 * 获取重考考生
-	 * @param examCriteria
-	 * @param curPage
-	 * @param pageSize
-	 * @return
-	 */
-    public Page<ExamStudent> getReexamineStudent(CommonExamStudent examCriteria,Integer curPage,Integer pageSize){
-    	if(examCriteria.getExamId() == null){
-    		return null;
-    	}
-    	StringBuffer sql = new StringBuffer();
-    	sql.append("select "
-				   + "t1.id 				id,"
-				   + "t1.exam_id 			exam_id,"
-				   + "t1.org_id 			org_id,"
-				   + "t1.org_name 			org_name,"
-				   + "t1.course_code 		course_code,"
-				   + "t1.course_name 		course_name,"
-				   + "t1.course_level 		course_level,"
-				   + "t1.name 				name,"
-				   + "t1.student_code 	 	student_code,"
-				   + "t1.identity_number 	identity_number"
-				+ " from ecs_exam_student t1 "
-				+ " where t1.exam_id="+examCriteria.getExamId());
-    	sql.append(" and  t1.normal_exam_times >= ( select t2.exam_times from ecs_exam t2 where t2.id = t1.exam_id ) ");
-    	//没设置重考的或者设置了重考,重考已完成的
-    	sql.append(" and ((t1.is_reexamine is null OR t1.is_reexamine = 0) OR (t1.is_reexamine = 1 and t1.reexamine_completed = 1)) ");
-    	sql.append(" and NOT EXISTS ( select * from oe_exam_record t3 where t3.exam_student_id = t1.id and t3.status = 'EXAM_ING') ");
-    	sql.append(getSqlSpecification(examCriteria));
-    	sql.append(" limit "+(curPage-1)*pageSize+","+pageSize);
-    	
-    	Exam exam = examRepo.findOne(examCriteria.getExamId());
-    	List<ExamStudent> examStudents = this.jdbcTemplate.query(sql.toString(), new RowMapper<ExamStudent>(){
-			@Override
-			public ExamStudent mapRow(ResultSet rs, int arg)throws SQLException {
-				ExamStudent examStudent = new ExamStudent();
-				examStudent.setId(rs.getLong("id"));
-				examStudent.setExam(exam);
-				examStudent.setOrgId(rs.getLong("org_id"));
-				examStudent.setOrgName(rs.getString("org_name"));
-				examStudent.setCourseCode(rs.getString("course_code"));
-				examStudent.setCourseName(rs.getString("course_name"));
-				examStudent.setCourseLevel(rs.getString("course_level"));
-				examStudent.setName(rs.getString("name"));
-				examStudent.setStudentCode(rs.getString("student_code"));
-				examStudent.setIdentityNumber(rs.getString("identity_number"));
-				return examStudent;
-			}
-    	});
-    	int total = countReexamineStudent(examCriteria);
-    	return new PageImpl<>(examStudents,null,total);
-    }
-	
-	private int countReexamineStudent(CommonExamStudent examCriteria) {
-		StringBuffer sql = new StringBuffer();
-    	sql.append("select count(t1.id) from ecs_exam_student t1 where t1.normal_exam_times = ( "+
-    				" select t2.exam_times from ecs_exam t2 where t2.id = t1.exam_id "+
-    			")");
-    	sql.append(" and t1.exam_id="+examCriteria.getExamId());
-    	//没设置重考的或者设置了重考,重考已完成的
-    	sql.append(" and ((t1.is_reexamine is null OR t1.is_reexamine = 0) OR (t1.is_reexamine = 1 and t1.reexamine_completed = 1)) ");
-    	sql.append(" and NOT EXISTS ( select * from oe_exam_record t3 where t3.exam_student_id = t1.id and t3.status = 'EXAM_ING') ");
-    	sql.append(getSqlSpecification(examCriteria));
-		return this.jdbcTemplate.queryForObject(sql.toString(), Integer.class);
-	}
-
-	private String getSqlSpecification(CommonExamStudent examCriteria){
-		StringBuffer sql = new StringBuffer(""); 
-		if(!StringUtils.isEmpty(examCriteria.getOrgId())){
-			sql.append(" and t1.org_id = "+examCriteria.getOrgId());
-	    }
-		if(!StringUtils.isEmpty(examCriteria.getName())){
-			sql.append(" and t1.name LIKE '%"+examCriteria.getName()+"%'");
-	    }
-		if(!StringUtils.isEmpty(examCriteria.getStudentCode())){
-			sql.append(" and t1.student_code LIKE '%"+examCriteria.getStudentCode()+"%'");
-	    }
-		if(!StringUtils.isEmpty(examCriteria.getCourseCode())){
-			sql.append(" and t1.course_code = '"+examCriteria.getCourseCode()+"'");
-		}
-		if(!StringUtils.isEmpty(examCriteria.getCourseLevel())){
-			sql.append(" and t1.course_level = '"+examCriteria.getCourseLevel()+"'");
-		}
-		if(!StringUtils.isEmpty(examCriteria.getIdentityNumber())){
-			sql.append(" and t1.identity_number LIKE '%"+examCriteria.getIdentityNumber()+"%'");
-		}
-		sql.append(" order by t1.id ");
-		return sql.toString();
-	}
-	
-	/**
-	 * 生成查询条件
-	 * @param examCriteria
-	 * @return
-	 */
-	private Specification<ExamStudent> getSpecification(ExamStudentDTO examCriteria) {
-		Specification<ExamStudent> specification = (root, query, cb) -> {
-		    List<Predicate> predicates = new ArrayList<>();
-			if(!StringUtils.isEmpty(examCriteria.getStudentId())){
-				predicates.add(cb.equal(root.get("studentId"),examCriteria.getStudentId()));
-			}
-		    if(!StringUtils.isEmpty(examCriteria.getRootOrgId())){
-		    	predicates.add(cb.equal(root.get("rootOrgId"),examCriteria.getRootOrgId()));
-		    }
-		    if(!StringUtils.isEmpty(examCriteria.getOrgId())){
-		    	predicates.add(cb.equal(root.get("orgId"),examCriteria.getOrgId()));
-		    }
-		    if(!StringUtils.isEmpty(examCriteria.getOrgName())){
-		    	predicates.add(cb.like(root.get("orgName"),"%"+examCriteria.getOrgName()+"%"));
-		    }
-		    if(!StringUtils.isEmpty(examCriteria.getExamId())){
-		    	predicates.add(cb.equal(root.get("exam").get("id"),examCriteria.getExamId()));
-		    }
-		    if(!StringUtils.isEmpty(examCriteria.getName())){
-		    	predicates.add(cb.like(root.get("name"),"%"+examCriteria.getName()+"%"));
-		    }
-		    if(!StringUtils.isEmpty(examCriteria.getStudentCode())){
-		    	predicates.add(cb.like(root.get("studentCode"),"%"+examCriteria.getStudentCode()+"%"));
-		    }
-			if(!StringUtils.isEmpty(examCriteria.getCourseCode())){
-				predicates.add(cb.equal(root.get("courseCode"),examCriteria.getCourseCode()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getCourseLevel())){
-				predicates.add(cb.equal(root.get("courseLevel"),examCriteria.getCourseLevel()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getCourseName())){
-				predicates.add(cb.like(root.get("courseName"),"%"+examCriteria.getCourseName()+"%"));
-			}
-		    if(!StringUtils.isEmpty(examCriteria.getFinished())){
-		    	predicates.add(cb.equal(root.get("finished"),examCriteria.getFinished()));
-		    }
-			if(!StringUtils.isEmpty(examCriteria.getExamSite())){
-				predicates.add(cb.like(root.get("examSite"),"%"+examCriteria.getExamSite()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getIdentityNumber())){
-				predicates.add(cb.equal(root.get("identityNumber"),examCriteria.getIdentityNumber()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getSpecialtyName())){
-				predicates.add(cb.like(root.get("specialtyName"),"%"+examCriteria.getSpecialtyName()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getPaperType())){
-				predicates.add(cb.equal(root.get("paperType"),examCriteria.getPaperType()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getDegree())){
-				predicates.add(cb.equal(root.get("degree"),examCriteria.getDegree()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getRepair())){
-				predicates.add(cb.equal(root.get("repair"),examCriteria.getRepair()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getGraduated())){
-				predicates.add(cb.equal(root.get("graduated"),examCriteria.getGraduated()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getGrade())){
-				predicates.add(cb.like(root.get("grade"),"%"+examCriteria.getGrade()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getExamNumber())){
-				predicates.add(cb.like(root.get("examNumber"),"%"+examCriteria.getExamNumber()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getInfoCollector())){
-				predicates.add(cb.like(root.get("infoCollector"),"%"+examCriteria.getInfoCollector()+"%"));
-			}
-		    return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-		return specification;
-	}
-
-	/**
-	 * 生成查询条件
-	 * @param examCriteria
-	 * @return
-	 */
-	private Specification<ExamStudent> getPageSpecification(ExamStudentDTO examCriteria) {
-		Specification<ExamStudent> specification = (root, query, cb) -> {
-			List<Predicate> predicates = new ArrayList<>();
-			if(!StringUtils.isEmpty(examCriteria.getStudentId())){
-				predicates.add(cb.equal(root.get("studentId"),examCriteria.getStudentId()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getRootOrgId())){
-				predicates.add(cb.equal(root.get("rootOrgId"),examCriteria.getRootOrgId()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getOrgId())){
-				predicates.add(cb.equal(root.get("orgId"),examCriteria.getOrgId()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getOrgName())){
-				predicates.add(cb.like(root.get("orgName"),"%"+examCriteria.getOrgName()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getExamId())){
-				predicates.add(cb.equal(root.get("exam").get("id"),examCriteria.getExamId()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getName())){
-				predicates.add(cb.like(root.get("name"),"%"+examCriteria.getName()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getStudentCode())){
-				predicates.add(cb.like(root.get("studentCode"),"%"+examCriteria.getStudentCode()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getCourseCode())){
-				predicates.add(cb.equal(root.get("courseCode"),examCriteria.getCourseCode()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getCourseLevel())){
-				predicates.add(cb.equal(root.get("courseLevel"),examCriteria.getCourseLevel()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getCourseName())){
-				predicates.add(cb.like(root.get("courseName"),"%"+examCriteria.getCourseName()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getFinished())){
-				predicates.add(cb.equal(root.get("finished"),examCriteria.getFinished()));
-			}
-
-			if(!StringUtils.isEmpty(examCriteria.getExamSite())){
-				predicates.add(cb.like(root.get("examSite"),"%"+examCriteria.getExamSite()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getIdentityNumber())){
-				predicates.add(cb.like(root.get("identityNumber"),"%"+examCriteria.getIdentityNumber()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getSpecialtyName())){
-				predicates.add(cb.like(root.get("specialtyName"),"%"+examCriteria.getSpecialtyName()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getPaperType())){
-				predicates.add(cb.equal(root.get("paperType"),examCriteria.getPaperType()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getDegree())){
-				predicates.add(cb.equal(root.get("degree"),examCriteria.getDegree()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getRepair())){
-				predicates.add(cb.equal(root.get("repair"),examCriteria.getRepair()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getGraduated())){
-				predicates.add(cb.equal(root.get("graduated"),examCriteria.getGraduated()));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getGrade())){
-				predicates.add(cb.like(root.get("grade"),"%"+examCriteria.getGrade()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getExamNumber())){
-				predicates.add(cb.like(root.get("examNumber"),"%"+examCriteria.getExamNumber()+"%"));
-			}
-			if(!StringUtils.isEmpty(examCriteria.getInfoCollector())){
-				predicates.add(cb.like(root.get("infoCollector"),"%"+examCriteria.getInfoCollector()+"%"));
-			}
-			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-		return specification;
-	}
-
-	/**
-	 * 复制考生
-	 * @param sourceExamId
-	 * @param targetExamId
-     */
-	public void copyExamStudent(Long sourceExamId,Long targetExamId){
-		List<ExamStudent> sourceExamStudents = examStudentRepo.findByExamId(sourceExamId);
-		List<ExamStudent> targetExamStudents = new ArrayList<ExamStudent>();
-		Exam targetExam = examRepo.findOne(targetExamId);
-		sourceExamStudents.stream().forEach(examStudent -> {
-			if(examStudentRepo.checkExamStu(targetExam.getId(),
-					examStudent.getRootOrgId(),
-					examStudent.getIdentityNumber(),
-					examStudent.getCourseCode()) == 0){
-				ExamStudent tempStudent = BeanCopierUtil.copyProperties(examStudent,ExamStudent.class);
-				tempStudent.setId(null);
-				tempStudent.setFinished(false);
-				tempStudent.setGraduated(false);
-				tempStudent.setDegree(false);
-				tempStudent.setRepair(false);
-				tempStudent.setNormalExamTimes(null);
-				tempStudent.setIsReexamine(null);
-				tempStudent.setReexamineType(null);
-				tempStudent.setReexamineDetail(null);
-				tempStudent.setReexamineCompleted(null);
-				tempStudent.setExam(targetExam);
-				targetExamStudents.add(tempStudent);
-			}
-		});
-		examStudentRepo.save(targetExamStudents);
-		sourceExamStudents.clear();
-		targetExamStudents.clear();
-	}
-
-	public void deleteExamStudent(List<Long> ids)throws Exception{
-		List<ExamStudent> examStudents = examStudentRepo.findByIdIn(ids);
-		for(ExamStudent examStudent : examStudents){
-			if(examStudent.getExam().getCanStuDel()){
-				examStudentRepo.delete(examStudent);
-			}else{
-				throw new RuntimeException(examStudent.getName()+"已开始考试,不能删除");
-			}
-		}
-	}
-
-	public void deleteExamStudents(Long examId)throws Exception{
-		Exam exam = examRepo.findOne(examId);
-		if(exam.getCanStuDel()){
-			examStudentRepo.deleteByExamId(examId);
-		}else{
-			throw new RuntimeException("该考试已开始,不能删除");
-		}
-	}
-	
-	/**
-	 * 学习中心考试进度信息
-	 * @param examId
-	 * @param orgCode
-	 * @return
-	 */
-	public List<OrgExamInfoDTO> 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<OrgExamInfoDTO>(){
-			@Override
-			public OrgExamInfoDTO mapRow(ResultSet rs, int rowNum)throws SQLException {
-				OrgExamInfoDTO orgExamInfoDTO = new OrgExamInfoDTO();
-				orgExamInfoDTO.setOrgId(rs.getLong("orgid")+"");
-				orgExamInfoDTO.setOrgCode(rs.getString("orgcode"));
-				orgExamInfoDTO.setOrgName(rs.getString("orgname"));
-				orgExamInfoDTO.setAllNum(rs.getInt("allNum"));
-				orgExamInfoDTO.setCompletedNum(rs.getInt("completedNum"));
-				if(orgExamInfoDTO.getCompletedNum()==0){
-					orgExamInfoDTO.setProportion("0");
-				}else{
-					DecimalFormat df = new DecimalFormat("#.00");
-					double proportion = (double) orgExamInfoDTO.getCompletedNum()/ orgExamInfoDTO.getAllNum();
-					orgExamInfoDTO.setProportion(df.format(proportion*100));
-				}
-				return orgExamInfoDTO;
-			}
-		});
-	}
-	
-	/**
-	 * 根据考试和学习中心查询课程
-	 * @param examId
-	 * @param orgId
-	 * @return
-	 */
-	public List<Course> findCoursesFromExamStudent(String examId,String orgId){
-		List<Object> paramsList = new ArrayList<Object>();
-		if(StringUtils.isEmpty(examId)){
-			return null;
-		}
-		StringBuilder sql = new StringBuilder();
-		paramsList.add(examId);
-		sql.append("SELECT t.course_code course_code,"
-						+ "t.course_level course_level,"
-						+ "t.course_name course_name "+
-				   " FROM ecs_exam_student t  "+
-				   " where  t.exam_id = ? ");
-				   
-		if(!StringUtils.isEmpty(orgId)){
-			sql.append(" and t.org_id = ? ");
-			paramsList.add(orgId);
-		}
-		sql.append(" group by course_code");
-		Object[] params = new Object[paramsList.size()];
-		for(int i = 0;i<paramsList.size();i++){
-			params[i] = paramsList.get(i);
-		}
-		return jdbcTemplate.query(sql.toString(),params,new RowMapper<Course>(){
-			@Override
-			public Course mapRow(ResultSet resultSet, int rowNum) throws SQLException {
-				Course course = new Course();
-				course.setCode(resultSet.getString("course_code"));
-				course.setName(resultSet.getString("course_name"));
-				return course;
-			}
-		});
-	}
-	
-	/**
-	 * 当考生进入考试时
-	 * 1.设置考生不缺考
-	 * 2.考生考试次数加1
-	 * @param examStuId
-	 */
-	public void updateExamStudentInfo(Long examStuId){
-		 ExamStudent examStudent = examStudentRepo.findOne(examStuId);
-	     examStudent.setFinished(true);
-	     /**
-	      * 进入考试时,判断正常考试次数是否小于考试信息(ecs_exam)中的考试次数
-	      * 如果是,考试次数加一,将重考标识设置成false
-	      */
-	     long examTimes = examStudent.getExam().getExamTimes();
-	     if(examTimes > examStudent.getNormalExamTimes()){
-	        examStudent.setNormalExamTimes(examStudent.getNormalExamTimes()+1);
-	        examStudent.setIsReexamine(null);
-	        examStudent.setReexamineCompleted(null);
-	     }
-	     //考生开始重考时,将重考已完成设置为true
-	     if(examStudent.getIsReexamine()!=null&&examStudent.getIsReexamine()){
-	    	 examStudent.setReexamineCompleted(true);
-	     }
-	     examStudentRepo.save(examStudent);
-	}
-	
-	
-	
-	/**
-	 * 设置考生重考信息
-	 * @param commonExamStudent
-	 */
-	public void setExamStudentIsReexamine(CommonExamStudent commonExamStudent){
-		if(commonExamStudent.getId() == null){
-			return;
-		}
-		ExamStudent examStudent = examStudentRepo.findOne(commonExamStudent.getId());
-		if(examStudent!=null){
-			examStudent.setIsReexamine(true);
-			//设置了重考,但考生重考未完成,考生开始重考时,该字段改为true
-			examStudent.setReexamineCompleted(false);
-			examStudent.setReexamineType(commonExamStudent.getReexamineType());
-			examStudent.setReexamineDetail(commonExamStudent.getReexamineDetail());
-			examStudentRepo.save(examStudent);
-		}
-	}
-
-	/**
-	 * 按照数量限制查询考生
-	 * @param examId		考试ID
-	 * @param startLimit	数量开始限制
-	 * @param endLimit		数量结束限制
-	 * @return
-	 */
-	public List<ExamStudent> getExamStudentByLimit(Long examId, Integer startLimit,Integer endLimit) {
-		if(examId==null||startLimit==null||endLimit==null||startLimit>endLimit){
-			return null;
-		}
-		return examStudentRepo.findByLimit(examId, startLimit-1,(endLimit-startLimit+1));
-	}
-}
+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.Date;
+import java.util.List;
+
+import javax.persistence.criteria.Predicate;
+
+import cn.com.qmth.examcloud.common.util.BeanCopierUtil;
+import cn.com.qmth.examcloud.service.examwork.dao.ExamOrgTimeRepo;
+import cn.com.qmth.examcloud.service.examwork.entity.ExamOrgTime;
+import cn.com.qmth.examcloud.service.examwork.enums.ExamType;
+
+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.PageImpl;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+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;
+
+import cn.com.qmth.examcloud.common.dto.core.Course;
+import cn.com.qmth.examcloud.common.dto.core.Org;
+import cn.com.qmth.examcloud.common.dto.core.Student;
+import cn.com.qmth.examcloud.common.dto.core.User;
+import cn.com.qmth.examcloud.common.dto.core.enums.UserType;
+import cn.com.qmth.examcloud.common.dto.examwork.CommonExamStudent;
+import cn.com.qmth.examcloud.common.util.ErrorMsg;
+import cn.com.qmth.examcloud.common.util.excel.ExcelError;
+import cn.com.qmth.examcloud.common.util.excel.ExcelReader;
+import cn.com.qmth.examcloud.common.util.excel.ExcelReaderHandle;
+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.OrgExamInfoDTO;
+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;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.OrgService;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.SpecialtyService;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.StudentService;
+
+/**
+ * 考试学生服务类
+ * Created by songyue on 17/1/14.
+ */
+@Service
+public class ExamStudentService {
+
+	protected static final Logger log = LoggerFactory.getLogger(ExamStudentService.class);
+
+    @Autowired
+    ExamStudentRepo examStudentRepo;
+
+    @Autowired
+    ExamRepo examRepo;
+
+    @Autowired
+    ExamStudentAssembler examStudentAssembler;
+
+    @Autowired
+    StudentService studentService;
+
+    @Autowired
+    CourseService courseService;
+
+    @Autowired
+    OrgService orgService;
+    
+    @Autowired
+	private JdbcTemplate jdbcTemplate;
+
+	@Autowired
+	SpecialtyService specialtyService;
+
+	@Autowired
+	ExamOrgTimeRepo examOrgTimeRepo;
+
+    /**
+     * 获取所有考试学生(分页)
+     * @param examCriteria
+     * @param pageable
+     * @return 
+     * @return
+     */
+    public Page<ExamStudent> getAllExamStudent(ExamStudentDTO examCriteria, Pageable pageable){
+    	Specification<ExamStudent> specification = getPageSpecification(examCriteria);
+		Page<ExamStudent> examStudents = examStudentRepo.findAll(specification,pageable);
+		processExamStudent(examStudents.getContent());
+        return examStudents;
+    }
+
+    /**
+     * 获取所有考试学生
+     * @param examCriteria
+     * @return 
+     * @return
+     */
+    public List<ExamStudent> getAllExamStudent(ExamStudentDTO examCriteria){
+    	Specification<ExamStudent> specification = getSpecification(examCriteria);
+		List<ExamStudent> examStudents = examStudentRepo.findAll(specification,new Sort(Direction.DESC,"id"));
+		processExamStudent(examStudents);
+        return examStudents;
+    }
+
+	/**
+	 * 处理考生集合(设置学习中心考试时间)
+	 * @param examStudents
+     */
+    private void processExamStudent(List<ExamStudent> examStudents){
+		for(ExamStudent examStudent:examStudents){
+			//设置学习中心考试时间
+			setExamOrgTime(examStudent);
+		}
+	}
+
+	/**
+	 * 设置学习中心考试时间
+	 * @param examStudent
+     */
+	private void setExamOrgTime(ExamStudent examStudent){
+		Exam exam = examStudent.getExam();
+		if(exam != null){
+			if(exam.getExamType() == ExamType.OFFLINE){
+				Long examId = exam.getId();
+				Long orgId = examStudent.getOrgId();
+				ExamOrgTime examOrgTime = examOrgTimeRepo.findFirstByExamIdAndOrgId(examId,orgId);
+				if(examOrgTime != null){
+					String examBeginTime = String.valueOf(examOrgTime.getBeginTime().getTime());
+					String examEndTime = String.valueOf(examOrgTime.getEndTime().getTime());
+					examStudent.setExamBeginTime(examBeginTime);
+					examStudent.setExamEndTime(examEndTime);
+					examStudent.setCanUpload(getCanUpload(examOrgTime));
+				}
+			}else{
+				String examBeginTime = String.valueOf(exam.getBeginTime().getTime());
+				String examEndTime = String.valueOf(exam.getEndTime().getTime());
+				examStudent.setExamBeginTime(examBeginTime);
+				examStudent.setExamEndTime(examEndTime);
+			}
+		}
+	}
+
+	private Boolean getCanUpload(ExamOrgTime examOrgTime){
+		if(examOrgTime.getCanUpload() == null){
+			Date now = new Date();
+			if(now.after(examOrgTime.getEndTime())){
+				return false;
+			}else{
+				return true;
+			}
+		}else{
+			return examOrgTime.getCanUpload();
+		}
+	}
+
+	public ExamStudent findById(Long id){
+		ExamStudent examStudent = examStudentRepo.findOne(id);
+		setExamOrgTime(examStudent);
+		return examStudent;
+	}
+
+    /**
+     * 按考试批次获取学生
+     * @param examId
+     * @return 
+     * @return
+     */
+    public Page<ExamStudent> getExamStudentByExamId(Long examId,Pageable pageable){
+        return examStudentRepo.findByExamId(examId,pageable);
+    }
+
+    /**
+     * 保存考试学生
+     * @param examStudent
+     * @return
+     */
+    public ExamStudent saveExamStudent(ExamStudent examStudent)throws Exception{
+    	checkExamStudent(examStudent);
+        return saveStudent(examStudent);
+    }
+
+    /**
+     * 导入考试学生
+     * @return
+     */
+	public List<ExcelError> importExamStudent(Long examId, InputStream inputStream) {
+		log.info("导入考生开始");
+		Exam exam = examRepo.findOne(examId);
+		List<ExcelError> excelErrors = new ArrayList<ExcelError>();
+		if(exam == null){
+			ExcelError excelError = new ExcelError(1,"请先创建考试");
+			excelErrors.add(excelError);
+			return excelErrors;
+		}
+		List<ExamStudent> examStudents = new ArrayList<ExamStudent>();
+		ExcelReader excelReader = new ExcelReader(ExamStudentDTO.class);
+        excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
+            @Override
+            public ExcelError handle(Object obj) {
+                ExamStudentDTO dto = (ExamStudentDTO) obj;
+                dto.setRootOrgId(exam.getOrgId());
+                dto.setExam(exam);
+                ExcelError error = importCheck(dto);
+                if (error == null) {
+                	examStudents.add(examStudentAssembler.toDomain(dto));
+                }
+                int stu_num = examStudents.size();
+                if (stu_num % 5000 == 0) {
+                	saveStudentList(examStudents);
+					log.info("已导入"+stu_num+"条数据");
+                }
+                return error;
+            }
+
+        });
+		int stu_num = examStudents.size();
+        saveStudentList(examStudents);
+		log.info("已导入"+stu_num+"条数据");
+		log.info("导入考生结束");
+        return excelErrors;
+	}
+	
+
+	private void saveStudentList(List<ExamStudent> examStudents) {
+		for (ExamStudent examStudent : examStudents) {
+			saveStudent(examStudent);
+		}
+		examStudents.removeAll(examStudents);
+	}
+
+	private ExamStudent saveStudent(ExamStudent examStudent){
+		if(examStudent.getStudentId() == null){
+			Student student = new Student();
+			student.setIdentityNumber(examStudent.getIdentityNumber());
+			student.setName(examStudent.getName());
+			student.setStudentCode(examStudent.getStudentCode());
+			student.setRootOrgId(examStudent.getRootOrgId());
+			student.setOrgId(examStudent.getOrgId());
+			User user = new User();
+			user.setOrgId(examStudent.getOrgId());
+			user.setEnable(true);
+			user.setType(UserType.STUDENT);
+			user.setRootOrgId(examStudent.getRootOrgId());
+			student.setUser(user);
+			student = studentService.addStudent(student);
+			examStudent.setStudentId(student.getId());
+		}else{
+			Student student = studentService.getStudent(examStudent.getStudentId());
+			student.setOrgId(examStudent.getOrgId());
+			student.setName(examStudent.getName());
+			student.setRootOrgId(examStudent.getRootOrgId());
+			student.setStudentCode(examStudent.getStudentCode());
+			student.setIdentityNumber(examStudent.getIdentityNumber());
+			studentService.updateStudent(student);
+		}
+		examStudent.setFinished(false);
+		examStudent.setGraduated(false);
+		examStudent.setDegree(false);
+		examStudent.setRepair(false);
+		return examStudentRepo.save(examStudent);
+	}
+
+	public void checkExamStudent(ExamStudent examStudent){
+		if(examStudent.getId() != null){
+			if(examStudentRepo.checkExamStuById(examStudent.getExam().getId(),
+												examStudent.getRootOrgId(),
+												examStudent.getIdentityNumber(),
+												examStudent.getCourseCode(),
+												examStudent.getId()) > 0){
+				throw new RuntimeException("该考生已存在");
+			}
+		}else{
+			if(examStudentRepo.checkExamStu(examStudent.getExam().getId(),
+											examStudent.getRootOrgId(),
+											examStudent.getIdentityNumber(),
+											examStudent.getCourseCode()) > 0){
+				throw new RuntimeException("该考生已存在");
+			}
+		}
+	}
+	
+	/**
+	 * 考生导入验证
+	 * @param dto
+	 * @return
+	 */
+	public ExcelError importCheck(ExamStudentDTO dto){
+		if(StringUtils.isEmpty(dto.getName())){
+			return new ExcelError("姓名不能为空");
+		}
+		if(StringUtils.isEmpty(dto.getStudentCode())||StringUtils.isEmpty(dto.getIdentityNumber())){
+			return new ExcelError("学号或身份证号不能为空");
+		}else{
+			if(!StringUtils.isEmpty(dto.getStudentCode()) && dto.getStudentCode().length() < 6){
+				return new ExcelError("学号至少为6位");
+			}
+			if(!StringUtils.isEmpty(dto.getIdentityNumber()) && dto.getIdentityNumber().length() < 6){
+				return new ExcelError("身份证号至少为6位");
+			}
+		}
+		if(StringUtils.isEmpty(dto.getCourseCode())){
+			return new ExcelError("课程代码不能为空");
+		}
+		if(StringUtils.isEmpty(dto.getOrgCode())){
+			return new ExcelError("学习中心代码不能为空");
+		}
+//		if(StringUtils.isEmpty(dto.getSpecialtyCode())){
+//			return new ExcelError("专业代码不能为空");
+//		}
+//
+//		Specialty specialty = specialtyService.findByOrgIdAndCode(dto.getOrgId(),dto.getSpecialtyCode());
+//		if(specialty == null || !specialty.getEnable()){
+//			return new ExcelError("专业代码不存在/被禁用");
+//		}
+//		dto.setSpecialtyName(specialty.getName());
+
+		Course course = courseService.findByOrgIdAndCode(dto.getRootOrgId(), dto.getCourseCode());
+		if(course == null || !course.getEnable()){
+			return new ExcelError("课程不存在/被禁用");
+		}
+		dto.setCourseLevel(course.getLevel().toString());
+		dto.setCourseName(course.getName());
+		Org org = orgService.findByParentIdAndCode(dto.getRootOrgId(), dto.getOrgCode());
+		if(org == null || !org.getEnable()){
+			return new ExcelError("学习中心不存在/禁用");
+		}
+		dto.setOrgId(org.getId());
+		dto.setOrgName(org.getName());
+		stuCheck(dto);
+		if(StringUtils.isEmpty(dto.getPaperType())){
+			dto.setPaperType("O");
+		}
+		return null;
+	}
+
+	public void stuCheck(ExamStudentDTO dto){
+		ExamStudent examStudent = null;
+		if(!StringUtils.isEmpty(dto.getIdentityNumber())) {
+			examStudent = examStudentRepo.findFirstByExamId(dto.getExam().getId(), dto.getCourseCode(), dto.getIdentityNumber());
+		}else{
+			examStudent = examStudentRepo.findFirstByExamId(dto.getExam().getId(), dto.getCourseCode(), dto.getStudentCode());
+		}
+		if(examStudent != null){
+			dto.setId(examStudent.getId());
+			dto.setStudentId(examStudent.getStudentId());
+		}
+	}
+
+	/**
+	 * 照片检验
+	 * @param examId
+	 * @return
+	 */
+	public List<ErrorMsg> photoCheck(Long examId) {
+		List<ErrorMsg> msgs = new ArrayList<ErrorMsg>();
+		List<ExamStudent> examStudents = examStudentRepo.findByExamId(examId);
+		for (ExamStudent examStudent : examStudents) {
+			ErrorMsg errorMsg = null;
+			if(!StringUtils.isEmpty(examStudent.getStudentCode())){
+				
+				errorMsg = new ErrorMsg(examStudent.getStudentCode());
+			}else if(!StringUtils.isEmpty(examStudent.getIdentityNumber())){
+				
+				errorMsg =  new ErrorMsg(examStudent.getIdentityNumber());
+			}
+			if(errorMsg != null){
+				msgs.add(errorMsg);
+			}
+		}
+		return msgs;
+	}
+	
+	/**
+	 * 获取重考考生
+	 * @param examCriteria
+	 * @param curPage
+	 * @param pageSize
+	 * @return
+	 */
+    public Page<ExamStudent> getReexamineStudent(CommonExamStudent examCriteria,Integer curPage,Integer pageSize){
+    	if(examCriteria.getExamId() == null){
+    		return null;
+    	}
+    	StringBuffer sql = new StringBuffer();
+    	sql.append("select "
+				   + "t1.id 				id,"
+				   + "t1.exam_id 			exam_id,"
+				   + "t1.org_id 			org_id,"
+				   + "t1.org_name 			org_name,"
+				   + "t1.course_code 		course_code,"
+				   + "t1.course_name 		course_name,"
+				   + "t1.course_level 		course_level,"
+				   + "t1.name 				name,"
+				   + "t1.student_code 	 	student_code,"
+				   + "t1.identity_number 	identity_number"
+				+ " from ecs_exam_student t1 "
+				+ " where t1.exam_id="+examCriteria.getExamId());
+    	sql.append(" and  t1.normal_exam_times >= ( select t2.exam_times from ecs_exam t2 where t2.id = t1.exam_id ) ");
+    	//没设置重考的或者设置了重考,重考已完成的
+    	sql.append(" and ((t1.is_reexamine is null OR t1.is_reexamine = 0) OR (t1.is_reexamine = 1 and t1.reexamine_completed = 1)) ");
+    	sql.append(" and NOT EXISTS ( select * from oe_exam_record t3 where t3.exam_student_id = t1.id and t3.status = 'EXAM_ING') ");
+    	sql.append(getSqlSpecification(examCriteria));
+    	sql.append(" limit "+(curPage-1)*pageSize+","+pageSize);
+    	
+    	Exam exam = examRepo.findOne(examCriteria.getExamId());
+    	List<ExamStudent> examStudents = this.jdbcTemplate.query(sql.toString(), new RowMapper<ExamStudent>(){
+			@Override
+			public ExamStudent mapRow(ResultSet rs, int arg)throws SQLException {
+				ExamStudent examStudent = new ExamStudent();
+				examStudent.setId(rs.getLong("id"));
+				examStudent.setExam(exam);
+				examStudent.setOrgId(rs.getLong("org_id"));
+				examStudent.setOrgName(rs.getString("org_name"));
+				examStudent.setCourseCode(rs.getString("course_code"));
+				examStudent.setCourseName(rs.getString("course_name"));
+				examStudent.setCourseLevel(rs.getString("course_level"));
+				examStudent.setName(rs.getString("name"));
+				examStudent.setStudentCode(rs.getString("student_code"));
+				examStudent.setIdentityNumber(rs.getString("identity_number"));
+				return examStudent;
+			}
+    	});
+    	int total = countReexamineStudent(examCriteria);
+    	return new PageImpl<>(examStudents,null,total);
+    }
+	
+	private int countReexamineStudent(CommonExamStudent examCriteria) {
+		StringBuffer sql = new StringBuffer();
+    	sql.append("select count(t1.id) from ecs_exam_student t1 where t1.normal_exam_times = ( "+
+    				" select t2.exam_times from ecs_exam t2 where t2.id = t1.exam_id "+
+    			")");
+    	sql.append(" and t1.exam_id="+examCriteria.getExamId());
+    	//没设置重考的或者设置了重考,重考已完成的
+    	sql.append(" and ((t1.is_reexamine is null OR t1.is_reexamine = 0) OR (t1.is_reexamine = 1 and t1.reexamine_completed = 1)) ");
+    	sql.append(" and NOT EXISTS ( select * from oe_exam_record t3 where t3.exam_student_id = t1.id and t3.status = 'EXAM_ING') ");
+    	sql.append(getSqlSpecification(examCriteria));
+		return this.jdbcTemplate.queryForObject(sql.toString(), Integer.class);
+	}
+
+	private String getSqlSpecification(CommonExamStudent examCriteria){
+		StringBuffer sql = new StringBuffer(""); 
+		if(!StringUtils.isEmpty(examCriteria.getOrgId())){
+			sql.append(" and t1.org_id = "+examCriteria.getOrgId());
+	    }
+		if(!StringUtils.isEmpty(examCriteria.getName())){
+			sql.append(" and t1.name LIKE '%"+examCriteria.getName()+"%'");
+	    }
+		if(!StringUtils.isEmpty(examCriteria.getStudentCode())){
+			sql.append(" and t1.student_code LIKE '%"+examCriteria.getStudentCode()+"%'");
+	    }
+		if(!StringUtils.isEmpty(examCriteria.getCourseCode())){
+			sql.append(" and t1.course_code = '"+examCriteria.getCourseCode()+"'");
+		}
+		if(!StringUtils.isEmpty(examCriteria.getCourseLevel())){
+			sql.append(" and t1.course_level = '"+examCriteria.getCourseLevel()+"'");
+		}
+		if(!StringUtils.isEmpty(examCriteria.getIdentityNumber())){
+			sql.append(" and t1.identity_number LIKE '%"+examCriteria.getIdentityNumber()+"%'");
+		}
+		sql.append(" order by t1.id ");
+		return sql.toString();
+	}
+	
+	/**
+	 * 生成查询条件
+	 * @param examCriteria
+	 * @return
+	 */
+	private Specification<ExamStudent> getSpecification(ExamStudentDTO examCriteria) {
+		Specification<ExamStudent> specification = (root, query, cb) -> {
+		    List<Predicate> predicates = new ArrayList<>();
+			if(!StringUtils.isEmpty(examCriteria.getStudentId())){
+				predicates.add(cb.equal(root.get("studentId"),examCriteria.getStudentId()));
+			}
+		    if(!StringUtils.isEmpty(examCriteria.getRootOrgId())){
+		    	predicates.add(cb.equal(root.get("rootOrgId"),examCriteria.getRootOrgId()));
+		    }
+		    if(!StringUtils.isEmpty(examCriteria.getOrgId())){
+		    	predicates.add(cb.equal(root.get("orgId"),examCriteria.getOrgId()));
+		    }
+		    if(!StringUtils.isEmpty(examCriteria.getOrgName())){
+		    	predicates.add(cb.like(root.get("orgName"),"%"+examCriteria.getOrgName()+"%"));
+		    }
+		    if(!StringUtils.isEmpty(examCriteria.getExamId())){
+		    	predicates.add(cb.equal(root.get("exam").get("id"),examCriteria.getExamId()));
+		    }
+		    if(!StringUtils.isEmpty(examCriteria.getName())){
+		    	predicates.add(cb.like(root.get("name"),"%"+examCriteria.getName()+"%"));
+		    }
+		    if(!StringUtils.isEmpty(examCriteria.getStudentCode())){
+		    	predicates.add(cb.like(root.get("studentCode"),"%"+examCriteria.getStudentCode()+"%"));
+		    }
+			if(!StringUtils.isEmpty(examCriteria.getCourseCode())){
+				predicates.add(cb.equal(root.get("courseCode"),examCriteria.getCourseCode()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getCourseLevel())){
+				predicates.add(cb.equal(root.get("courseLevel"),examCriteria.getCourseLevel()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getCourseName())){
+				predicates.add(cb.like(root.get("courseName"),"%"+examCriteria.getCourseName()+"%"));
+			}
+		    if(!StringUtils.isEmpty(examCriteria.getFinished())){
+		    	predicates.add(cb.equal(root.get("finished"),examCriteria.getFinished()));
+		    }
+			if(!StringUtils.isEmpty(examCriteria.getExamSite())){
+				predicates.add(cb.like(root.get("examSite"),"%"+examCriteria.getExamSite()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getIdentityNumber())){
+				predicates.add(cb.equal(root.get("identityNumber"),examCriteria.getIdentityNumber()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getSpecialtyName())){
+				predicates.add(cb.like(root.get("specialtyName"),"%"+examCriteria.getSpecialtyName()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getPaperType())){
+				predicates.add(cb.equal(root.get("paperType"),examCriteria.getPaperType()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getDegree())){
+				predicates.add(cb.equal(root.get("degree"),examCriteria.getDegree()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getRepair())){
+				predicates.add(cb.equal(root.get("repair"),examCriteria.getRepair()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getGraduated())){
+				predicates.add(cb.equal(root.get("graduated"),examCriteria.getGraduated()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getGrade())){
+				predicates.add(cb.like(root.get("grade"),"%"+examCriteria.getGrade()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getExamNumber())){
+				predicates.add(cb.like(root.get("examNumber"),"%"+examCriteria.getExamNumber()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getInfoCollector())){
+				predicates.add(cb.like(root.get("infoCollector"),"%"+examCriteria.getInfoCollector()+"%"));
+			}
+		    return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+		return specification;
+	}
+
+	/**
+	 * 生成查询条件
+	 * @param examCriteria
+	 * @return
+	 */
+	private Specification<ExamStudent> getPageSpecification(ExamStudentDTO examCriteria) {
+		Specification<ExamStudent> specification = (root, query, cb) -> {
+			List<Predicate> predicates = new ArrayList<>();
+			if(!StringUtils.isEmpty(examCriteria.getStudentId())){
+				predicates.add(cb.equal(root.get("studentId"),examCriteria.getStudentId()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getRootOrgId())){
+				predicates.add(cb.equal(root.get("rootOrgId"),examCriteria.getRootOrgId()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getOrgId())){
+				predicates.add(cb.equal(root.get("orgId"),examCriteria.getOrgId()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getOrgName())){
+				predicates.add(cb.like(root.get("orgName"),"%"+examCriteria.getOrgName()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getExamId())){
+				predicates.add(cb.equal(root.get("exam").get("id"),examCriteria.getExamId()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getName())){
+				predicates.add(cb.like(root.get("name"),"%"+examCriteria.getName()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getStudentCode())){
+				predicates.add(cb.like(root.get("studentCode"),"%"+examCriteria.getStudentCode()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getCourseCode())){
+				predicates.add(cb.equal(root.get("courseCode"),examCriteria.getCourseCode()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getCourseLevel())){
+				predicates.add(cb.equal(root.get("courseLevel"),examCriteria.getCourseLevel()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getCourseName())){
+				predicates.add(cb.like(root.get("courseName"),"%"+examCriteria.getCourseName()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getFinished())){
+				predicates.add(cb.equal(root.get("finished"),examCriteria.getFinished()));
+			}
+
+			if(!StringUtils.isEmpty(examCriteria.getExamSite())){
+				predicates.add(cb.like(root.get("examSite"),"%"+examCriteria.getExamSite()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getIdentityNumber())){
+				predicates.add(cb.like(root.get("identityNumber"),"%"+examCriteria.getIdentityNumber()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getSpecialtyName())){
+				predicates.add(cb.like(root.get("specialtyName"),"%"+examCriteria.getSpecialtyName()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getPaperType())){
+				predicates.add(cb.equal(root.get("paperType"),examCriteria.getPaperType()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getDegree())){
+				predicates.add(cb.equal(root.get("degree"),examCriteria.getDegree()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getRepair())){
+				predicates.add(cb.equal(root.get("repair"),examCriteria.getRepair()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getGraduated())){
+				predicates.add(cb.equal(root.get("graduated"),examCriteria.getGraduated()));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getGrade())){
+				predicates.add(cb.like(root.get("grade"),"%"+examCriteria.getGrade()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getExamNumber())){
+				predicates.add(cb.like(root.get("examNumber"),"%"+examCriteria.getExamNumber()+"%"));
+			}
+			if(!StringUtils.isEmpty(examCriteria.getInfoCollector())){
+				predicates.add(cb.like(root.get("infoCollector"),"%"+examCriteria.getInfoCollector()+"%"));
+			}
+			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+		};
+		return specification;
+	}
+
+	/**
+	 * 复制考生
+	 * @param sourceExamId
+	 * @param targetExamId
+     */
+	public void copyExamStudent(Long sourceExamId,Long targetExamId){
+		List<ExamStudent> sourceExamStudents = examStudentRepo.findByExamId(sourceExamId);
+		List<ExamStudent> targetExamStudents = new ArrayList<ExamStudent>();
+		Exam targetExam = examRepo.findOne(targetExamId);
+		sourceExamStudents.stream().forEach(examStudent -> {
+			if(examStudentRepo.checkExamStu(targetExam.getId(),
+					examStudent.getRootOrgId(),
+					examStudent.getIdentityNumber(),
+					examStudent.getCourseCode()) == 0){
+				ExamStudent tempStudent = BeanCopierUtil.copyProperties(examStudent,ExamStudent.class);
+				tempStudent.setId(null);
+				tempStudent.setFinished(false);
+				tempStudent.setGraduated(false);
+				tempStudent.setDegree(false);
+				tempStudent.setRepair(false);
+				tempStudent.setNormalExamTimes(null);
+				tempStudent.setIsReexamine(null);
+				tempStudent.setReexamineType(null);
+				tempStudent.setReexamineDetail(null);
+				tempStudent.setReexamineCompleted(null);
+				tempStudent.setExam(targetExam);
+				targetExamStudents.add(tempStudent);
+			}
+		});
+		examStudentRepo.save(targetExamStudents);
+		sourceExamStudents.clear();
+		targetExamStudents.clear();
+	}
+
+	public void deleteExamStudent(List<Long> ids)throws Exception{
+		List<ExamStudent> examStudents = examStudentRepo.findByIdIn(ids);
+		for(ExamStudent examStudent : examStudents){
+			if(examStudent.getExam().getCanStuDel()){
+				examStudentRepo.delete(examStudent);
+			}else{
+				throw new RuntimeException(examStudent.getName()+"已开始考试,不能删除");
+			}
+		}
+	}
+
+	public void deleteExamStudents(Long examId)throws Exception{
+		Exam exam = examRepo.findOne(examId);
+		if(exam.getCanStuDel()){
+			examStudentRepo.deleteByExamId(examId);
+		}else{
+			throw new RuntimeException("该考试已开始,不能删除");
+		}
+	}
+	
+	/**
+	 * 学习中心考试进度信息
+	 * @param examId
+	 * @param orgCode
+	 * @return
+	 */
+	public List<OrgExamInfoDTO> 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<OrgExamInfoDTO>(){
+			@Override
+			public OrgExamInfoDTO mapRow(ResultSet rs, int rowNum)throws SQLException {
+				OrgExamInfoDTO orgExamInfoDTO = new OrgExamInfoDTO();
+				orgExamInfoDTO.setOrgId(rs.getLong("orgid")+"");
+				orgExamInfoDTO.setOrgCode(rs.getString("orgcode"));
+				orgExamInfoDTO.setOrgName(rs.getString("orgname"));
+				orgExamInfoDTO.setAllNum(rs.getInt("allNum"));
+				orgExamInfoDTO.setCompletedNum(rs.getInt("completedNum"));
+				if(orgExamInfoDTO.getCompletedNum()==0){
+					orgExamInfoDTO.setProportion("0");
+				}else{
+					DecimalFormat df = new DecimalFormat("#.00");
+					double proportion = (double) orgExamInfoDTO.getCompletedNum()/ orgExamInfoDTO.getAllNum();
+					orgExamInfoDTO.setProportion(df.format(proportion*100));
+				}
+				return orgExamInfoDTO;
+			}
+		});
+	}
+	
+	/**
+	 * 根据考试和学习中心查询课程
+	 * @param examId
+	 * @param orgId
+	 * @return
+	 */
+	public List<Course> findCoursesFromExamStudent(String examId,String orgId){
+		List<Object> paramsList = new ArrayList<Object>();
+		if(StringUtils.isEmpty(examId)){
+			return null;
+		}
+		StringBuilder sql = new StringBuilder();
+		paramsList.add(examId);
+		sql.append("SELECT t.course_code course_code,"
+						+ "t.course_level course_level,"
+						+ "t.course_name course_name "+
+				   " FROM ecs_exam_student t  "+
+				   " where  t.exam_id = ? ");
+				   
+		if(!StringUtils.isEmpty(orgId)){
+			sql.append(" and t.org_id = ? ");
+			paramsList.add(orgId);
+		}
+		sql.append(" group by course_code");
+		Object[] params = new Object[paramsList.size()];
+		for(int i = 0;i<paramsList.size();i++){
+			params[i] = paramsList.get(i);
+		}
+		return jdbcTemplate.query(sql.toString(),params,new RowMapper<Course>(){
+			@Override
+			public Course mapRow(ResultSet resultSet, int rowNum) throws SQLException {
+				Course course = new Course();
+				course.setCode(resultSet.getString("course_code"));
+				course.setName(resultSet.getString("course_name"));
+				return course;
+			}
+		});
+	}
+	
+	/**
+	 * 当考生进入考试时
+	 * 1.设置考生不缺考
+	 * 2.考生考试次数加1
+	 * @param examStuId
+	 */
+	public void updateExamStudentInfo(Long examStuId){
+		 ExamStudent examStudent = examStudentRepo.findOne(examStuId);
+	     examStudent.setFinished(true);
+	     /**
+	      * 进入考试时,判断正常考试次数是否小于考试信息(ecs_exam)中的考试次数
+	      * 如果是,考试次数加一,将重考标识设置成false
+	      */
+	     long examTimes = examStudent.getExam().getExamTimes();
+	     if(examTimes > examStudent.getNormalExamTimes()){
+	        examStudent.setNormalExamTimes(examStudent.getNormalExamTimes()+1);
+	        examStudent.setIsReexamine(null);
+	        examStudent.setReexamineCompleted(null);
+	     }
+	     //考生开始重考时,将重考已完成设置为true
+	     if(examStudent.getIsReexamine()!=null&&examStudent.getIsReexamine()){
+	    	 examStudent.setReexamineCompleted(true);
+	     }
+	     examStudentRepo.save(examStudent);
+	}
+	
+	
+	
+	/**
+	 * 设置考生重考信息
+	 * @param commonExamStudent
+	 */
+	public void setExamStudentIsReexamine(CommonExamStudent commonExamStudent){
+		if(commonExamStudent.getId() == null){
+			return;
+		}
+		ExamStudent examStudent = examStudentRepo.findOne(commonExamStudent.getId());
+		if(examStudent!=null){
+			examStudent.setIsReexamine(true);
+			//设置了重考,但考生重考未完成,考生开始重考时,该字段改为true
+			examStudent.setReexamineCompleted(false);
+			examStudent.setReexamineType(commonExamStudent.getReexamineType());
+			examStudent.setReexamineDetail(commonExamStudent.getReexamineDetail());
+			examStudentRepo.save(examStudent);
+		}
+	}
+
+	/**
+	 * 按照数量限制查询考生
+	 * @param examId		考试ID
+	 * @param startLimit	数量开始限制
+	 * @param endLimit		数量结束限制
+	 * @return
+	 */
+	public List<ExamStudent> getExamStudentByLimit(Long examId, Integer startLimit,Integer endLimit) {
+		if(examId==null||startLimit==null||endLimit==null||startLimit>endLimit){
+			return null;
+		}
+		return examStudentRepo.findByLimit(examId, startLimit-1,(endLimit-startLimit+1));
+	}
+}

+ 34 - 34
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/CourseService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/CourseService.java

@@ -1,34 +1,34 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import cn.com.qmth.examcloud.common.dto.core.Course;
-import cn.com.qmth.examcloud.common.util.GsonUtil;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.client.CourseClient;
-import java.util.List;
-
-/**
- * 
- * @author ting.yin
- * @date 2017年1月14日
- */
-@Service
-public class CourseService {
-
-	@Autowired
-	CourseClient courseClient;
-
-	public Course findByOrgIdAndCode(Long orgId,String code) {
-		String json = courseClient.findByOrgIdAndCode(orgId,code);
-		Course domain = GsonUtil.getInstanceByJson(json, Course.class);
-		return domain;
-	}
-
-	public List<Course> findByOrgId(Long orgId) {
-		String json = courseClient.findByOrgId(orgId);
-		List<Course> courseList = GsonUtil.jsonToArrayList(json, Course.class);
-		return courseList;
-	}
-
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.common.dto.core.Course;
+import cn.com.qmth.examcloud.common.util.GsonUtil;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.client.CourseClient;
+import java.util.List;
+
+/**
+ * 
+ * @author ting.yin
+ * @date 2017年1月14日
+ */
+@Service
+public class CourseService {
+
+	@Autowired
+	CourseClient courseClient;
+
+	public Course findByOrgIdAndCode(Long orgId,String code) {
+		String json = courseClient.findByOrgIdAndCode(orgId,code);
+		Course domain = GsonUtil.getInstanceByJson(json, Course.class);
+		return domain;
+	}
+
+	public List<Course> findByOrgId(Long orgId) {
+		String json = courseClient.findByOrgId(orgId);
+		List<Course> courseList = GsonUtil.jsonToArrayList(json, Course.class);
+		return courseList;
+	}
+
+}

+ 23 - 23
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/OeService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/OeService.java

@@ -1,23 +1,23 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc;
-
-import cn.com.qmth.examcloud.service.examwork.service.rpc.client.OeClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * Created by songyue on 17/7/20.
- */
-@Service
-public class OeService {
-
-    @Autowired
-    OeClient oeClient;
-
-    public int checkExamRecord(Long examId,String identityNumber){
-        return oeClient.checkExamRecord(examId,identityNumber);
-    }
-
-    public int checkExamRecord(Long examId){
-        return oeClient.checkExamRecord(examId);
-    }
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc;
+
+import cn.com.qmth.examcloud.service.examwork.service.rpc.client.OeClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by songyue on 17/7/20.
+ */
+@Service
+public class OeService {
+
+    @Autowired
+    OeClient oeClient;
+
+    public int checkExamRecord(Long examId,String identityNumber){
+        return oeClient.checkExamRecord(examId,identityNumber);
+    }
+
+    public int checkExamRecord(Long examId){
+        return oeClient.checkExamRecord(examId);
+    }
+}

+ 35 - 35
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/OrgService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/OrgService.java

@@ -1,35 +1,35 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import cn.com.qmth.examcloud.common.dto.core.Org;
-import cn.com.qmth.examcloud.common.util.GsonUtil;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.client.OrgClient;
-
-import java.util.List;
-
-/**
- * 
- * @author ting.yin
- * @date 2017年1月14日
- */
-@Service
-public class OrgService {
-
-	@Autowired
-	OrgClient orgClient;
-
-	public Org findByParentIdAndCode(Long orgId,String code) {
-		String json = orgClient.findByParentIdAndCode(orgId, code);
-		Org domain = GsonUtil.getInstanceByJson(json, Org.class);
-		return domain;
-	}
-
-	public List<Org> findByParentId(String token,Long orgId) {
-		String json = orgClient.findByParentId(token,orgId);
-		List<Org> orgList = GsonUtil.jsonToArrayList(json, Org.class);
-		return orgList;
-	}
-
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.common.dto.core.Org;
+import cn.com.qmth.examcloud.common.util.GsonUtil;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.client.OrgClient;
+
+import java.util.List;
+
+/**
+ * 
+ * @author ting.yin
+ * @date 2017年1月14日
+ */
+@Service
+public class OrgService {
+
+	@Autowired
+	OrgClient orgClient;
+
+	public Org findByParentIdAndCode(Long orgId,String code) {
+		String json = orgClient.findByParentIdAndCode(orgId, code);
+		Org domain = GsonUtil.getInstanceByJson(json, Org.class);
+		return domain;
+	}
+
+	public List<Org> findByParentId(String token,Long orgId) {
+		String json = orgClient.findByParentId(token,orgId);
+		List<Org> orgList = GsonUtil.jsonToArrayList(json, Org.class);
+		return orgList;
+	}
+
+}

+ 29 - 29
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/SpecialtyService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/SpecialtyService.java

@@ -1,29 +1,29 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc;
-
-import cn.com.qmth.examcloud.common.dto.core.Course;
-import cn.com.qmth.examcloud.common.dto.core.Specialty;
-import cn.com.qmth.examcloud.common.util.GsonUtil;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.client.CourseClient;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.client.SpecialtyClient;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * 专业服务类
- * Created by songyue on 17/1/14.
- */
-@Service
-public class SpecialtyService {
-
-	@Autowired
-	SpecialtyClient specialtyClient;
-
-	public Specialty findByOrgIdAndCode(Long orgId, String code) {
-		String json = specialtyClient.findByOrgIdAndCode(orgId,code);
-		Specialty domain = GsonUtil.getInstanceByJson(json, Specialty.class);
-		return domain;
-	}
-
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc;
+
+import cn.com.qmth.examcloud.common.dto.core.Course;
+import cn.com.qmth.examcloud.common.dto.core.Specialty;
+import cn.com.qmth.examcloud.common.util.GsonUtil;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.client.CourseClient;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.client.SpecialtyClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 专业服务类
+ * Created by songyue on 17/1/14.
+ */
+@Service
+public class SpecialtyService {
+
+	@Autowired
+	SpecialtyClient specialtyClient;
+
+	public Specialty findByOrgIdAndCode(Long orgId, String code) {
+		String json = specialtyClient.findByOrgIdAndCode(orgId,code);
+		Specialty domain = GsonUtil.getInstanceByJson(json, Specialty.class);
+		return domain;
+	}
+
+}

+ 49 - 49
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/StudentService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/StudentService.java

@@ -1,49 +1,49 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import cn.com.qmth.examcloud.common.dto.core.Student;
-import cn.com.qmth.examcloud.common.util.GsonUtil;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.client.StudentClient;
-
-/**
- * 
- * @author ting.yin
- * @date 2017年1月14日
- */
-@Service
-public class StudentService {
-
-	@Autowired
-	StudentClient studentClient;
-
-	public Student updatePhoto(String identityNumber) {
-		String json = studentClient.updatePhoto(identityNumber);
-		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
-		return domain;
-	}
-	
-	public Student addStudent(Student student) {
-		String json = studentClient.addStudent(student);
-		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
-		return domain;
-	}
-
-	public Student updateStudent(Student student) {
-		String json = studentClient.updateStudent(student);
-		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
-		return domain;
-	}
-
-	public Student getStudent(Long id) {
-		String json = studentClient.getStudent(id);
-		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
-		return domain;
-	}
-
-	public void deleteStudent(Long id) {
-		studentClient.deleteStudent(id);
-	}
-
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.common.dto.core.Student;
+import cn.com.qmth.examcloud.common.util.GsonUtil;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.client.StudentClient;
+
+/**
+ * 
+ * @author ting.yin
+ * @date 2017年1月14日
+ */
+@Service
+public class StudentService {
+
+	@Autowired
+	StudentClient studentClient;
+
+	public Student updatePhoto(String identityNumber) {
+		String json = studentClient.updatePhoto(identityNumber);
+		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
+		return domain;
+	}
+	
+	public Student addStudent(Student student) {
+		String json = studentClient.addStudent(student);
+		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
+		return domain;
+	}
+
+	public Student updateStudent(Student student) {
+		String json = studentClient.updateStudent(student);
+		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
+		return domain;
+	}
+
+	public Student getStudent(Long id) {
+		String json = studentClient.getStudent(id);
+		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
+		return domain;
+	}
+
+	public void deleteStudent(Long id) {
+		studentClient.deleteStudent(id);
+	}
+
+}

+ 24 - 24
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/CourseClient.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/CourseClient.java

@@ -1,24 +1,24 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
-
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-/**
- * @Description: TODO
- * @author ting.yin
- * @date 2017年1月14日
- */
-@FeignClient(value = "ExamCloud-service-core")
-public interface CourseClient {
-
-	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/course")
-	String findByOrgIdAndCode(@RequestParam("orgId") Long orgId,@RequestParam("code") String code);
-
-
-	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/course/org/{orgId}")
-	String findByOrgId(@PathVariable("orgId") Long orgId);
-
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
+
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * @Description: TODO
+ * @author ting.yin
+ * @date 2017年1月14日
+ */
+@FeignClient(value = "ExamCloud-service-core")
+public interface CourseClient {
+
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/course")
+	String findByOrgIdAndCode(@RequestParam("orgId") Long orgId,@RequestParam("code") String code);
+
+
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/course/org/{orgId}")
+	String findByOrgId(@PathVariable("orgId") Long orgId);
+
+}

+ 19 - 19
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/OeClient.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/OeClient.java

@@ -1,19 +1,19 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
-
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-/**
- * Created by songyue on 17/7/20.
- */
-@FeignClient(value = "ExamCloud-SERVICE-OE")
-public interface OeClient {
-
-    @RequestMapping(method = RequestMethod.GET, value = "/api/exam_record/count")
-    int checkExamRecord(@RequestParam("examId") Long examId, @RequestParam(value = "identityNumber", required = false) String identityNumber);
-
-    @RequestMapping(method = RequestMethod.GET, value = "/api/exam_record/count")
-    int checkExamRecord(@RequestParam("examId") Long examId);
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
+
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Created by songyue on 17/7/20.
+ */
+@FeignClient(value = "ExamCloud-SERVICE-OE")
+public interface OeClient {
+
+    @RequestMapping(method = RequestMethod.GET, value = "/api/exam_record/count")
+    int checkExamRecord(@RequestParam("examId") Long examId, @RequestParam(value = "identityNumber", required = false) String identityNumber);
+
+    @RequestMapping(method = RequestMethod.GET, value = "/api/exam_record/count")
+    int checkExamRecord(@RequestParam("examId") Long examId);
+}

+ 21 - 21
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/OrgClient.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/OrgClient.java

@@ -1,21 +1,21 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
-
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * @Description: TODO
- * @author ting.yin
- * @date 2017年1月14日
- */
-@FeignClient(value = "ExamCloud-service-core")
-public interface OrgClient {
-
-	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/org")
-	String findByParentIdAndCode(@RequestParam("parentId") Long parentId,@RequestParam("code") String code);
-
-	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/org/sub/{parentId}")
-	String findByParentId(@RequestHeader("user_token") String token,
-						  @PathVariable("parentId") Long parentId);
-
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
+
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Description: TODO
+ * @author ting.yin
+ * @date 2017年1月14日
+ */
+@FeignClient(value = "ExamCloud-service-core")
+public interface OrgClient {
+
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/org")
+	String findByParentIdAndCode(@RequestParam("parentId") Long parentId,@RequestParam("code") String code);
+
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/org/sub/{parentId}")
+	String findByParentId(@RequestHeader("user_token") String token,
+						  @PathVariable("parentId") Long parentId);
+
+}

+ 19 - 19
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/SpecialtyClient.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/SpecialtyClient.java

@@ -1,19 +1,19 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
-
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-
-/**
- * Created by songyue on 17/7/20.
- */
-@FeignClient(value = "ExamCloud-service-core")
-public interface SpecialtyClient {
-
-	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/specialty")
-	String findByOrgIdAndCode(@RequestParam("orgId") Long orgId, @RequestParam("code") String code);
-
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
+
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+
+/**
+ * Created by songyue on 17/7/20.
+ */
+@FeignClient(value = "ExamCloud-service-core")
+public interface SpecialtyClient {
+
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/specialty")
+	String findByOrgIdAndCode(@RequestParam("orgId") Long orgId, @RequestParam("code") String code);
+
+}

+ 31 - 31
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/StudentClient.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/StudentClient.java

@@ -1,31 +1,31 @@
-package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
-
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.web.bind.annotation.*;
-
-import cn.com.qmth.examcloud.common.dto.core.Student;
-
-/**
- * @Description: TODO
- * @author ting.yin
- * @date 2017年1月14日
- */
-@FeignClient(value = "ExamCloud-service-core")
-public interface StudentClient {
-
-	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/student")
-	String updatePhoto(@RequestParam("identityNumber") String identityNumber);
-
-	@RequestMapping(method = RequestMethod.POST, value = "${app.api.core}/student")
-	String addStudent(@RequestBody Student student);
-
-	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/student/{id}")
-	String getStudent(@PathVariable("id") Long id);
-
-	@RequestMapping(method = RequestMethod.PUT, value = "${app.api.core}/student")
-	String updateStudent(@RequestBody Student student);
-
-	@RequestMapping(method = RequestMethod.DELETE, value = "${app.api.core}/student/{id}")
-	void deleteStudent(@PathVariable("id") Long id);
-
-}
+package cn.com.qmth.examcloud.service.examwork.service.rpc.client;
+
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+import cn.com.qmth.examcloud.common.dto.core.Student;
+
+/**
+ * @Description: TODO
+ * @author ting.yin
+ * @date 2017年1月14日
+ */
+@FeignClient(value = "ExamCloud-service-core")
+public interface StudentClient {
+
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/student")
+	String updatePhoto(@RequestParam("identityNumber") String identityNumber);
+
+	@RequestMapping(method = RequestMethod.POST, value = "${app.api.core}/student")
+	String addStudent(@RequestBody Student student);
+
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/student/{id}")
+	String getStudent(@PathVariable("id") Long id);
+
+	@RequestMapping(method = RequestMethod.PUT, value = "${app.api.core}/student")
+	String updateStudent(@RequestBody Student student);
+
+	@RequestMapping(method = RequestMethod.DELETE, value = "${app.api.core}/student/{id}")
+	void deleteStudent(@PathVariable("id") Long id);
+
+}

+ 81 - 81
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/sync/DataReceiveService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/sync/DataReceiveService.java

@@ -1,81 +1,81 @@
-package cn.com.qmth.examcloud.service.examwork.service.sync;
-
-import cn.com.qmth.examcloud.service.examwork.dao.ExamStudentRepo;
-import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
-import com.qmth.commons.dataSync.core.annotations.DataReceive;
-import com.qmth.commons.dataSync.core.entity.BaseSyncData;
-import com.qmth.commons.dataSync.core.service.DataSyncService;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import java.util.List;
-
-/**
- * Created by songyue on 17/8/3.
- */
-@Service
-public class DataReceiveService {
-
-    private static final Logger log = LoggerFactory.getLogger(DataReceiveService.class);
-
-    @Autowired
-    DataSyncService dataSyncService;
-
-    @Autowired
-    ExamStudentRepo examStudentRepo;
-
-    @DataReceive(domain = "cn.com.qmth.examcloud.common.dto.core.CourseSync")
-    public synchronized void readCourse(BaseSyncData baseSyncData) {
-        if (dataSyncService.expired(baseSyncData)) {
-            return;
-        }
-        log.info("-----------coursesync start---------");
-        log.info(baseSyncData.toString());
-        String courseCode = baseSyncData.getEntity().get("code");
-        String orgId = baseSyncData.getEntity().get("orgId");
-        String courseName = baseSyncData.getEntity().get("name");
-        String courseLevel = baseSyncData.getEntity().get("level");
-        if(StringUtils.isEmpty(courseCode)
-                || StringUtils.isEmpty(orgId)
-                || StringUtils.isEmpty(courseName)
-                || StringUtils.isEmpty(courseLevel)){
-            return;
-        }
-        List<ExamStudent> examStudents = examStudentRepo.findByCourseCode(Long.valueOf(orgId),courseCode);
-        for(ExamStudent examStudent:examStudents){
-            if(!examStudent.getCourseLevel().equals(courseLevel)){
-                examStudent.setCourseLevel(courseLevel);
-            }
-            if(!examStudent.getCourseName().equals(courseName)){
-                examStudent.setCourseName(courseName);
-            }
-        }
-        examStudentRepo.save(examStudents);
-        log.info("-----------coursesync end---------");
-    }
-
-    @DataReceive(domain = "cn.com.qmth.examcloud.common.dto.core.OrgSync")
-    public synchronized void readOrg(BaseSyncData baseSyncData) {
-        if (dataSyncService.expired(baseSyncData)) {
-            return;
-        }
-        log.info("-----------orgsync start---------");
-        log.info(baseSyncData.toString());
-        String orgId = baseSyncData.getPk();
-        String name = baseSyncData.getEntity().get("name");
-        if(StringUtils.isEmpty(orgId)
-                || StringUtils.isEmpty(name)){
-            return;
-        }
-        List<ExamStudent> examStudents = examStudentRepo.findByOrgId(Long.valueOf(orgId));
-        for(ExamStudent examStudent:examStudents){
-            if(!examStudent.getOrgName().equals(name)){
-                examStudent.setOrgName(name);
-            }
-        }
-        examStudentRepo.save(examStudents);
-        log.info("-----------orgsync end---------");
-    }
-}
+package cn.com.qmth.examcloud.service.examwork.service.sync;
+
+import cn.com.qmth.examcloud.service.examwork.dao.ExamStudentRepo;
+import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
+import com.qmth.commons.dataSync.core.annotations.DataReceive;
+import com.qmth.commons.dataSync.core.entity.BaseSyncData;
+import com.qmth.commons.dataSync.core.service.DataSyncService;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import java.util.List;
+
+/**
+ * Created by songyue on 17/8/3.
+ */
+@Service
+public class DataReceiveService {
+
+    private static final Logger log = LoggerFactory.getLogger(DataReceiveService.class);
+
+    @Autowired
+    DataSyncService dataSyncService;
+
+    @Autowired
+    ExamStudentRepo examStudentRepo;
+
+    @DataReceive(domain = "cn.com.qmth.examcloud.common.dto.core.CourseSync")
+    public synchronized void readCourse(BaseSyncData baseSyncData) {
+        if (dataSyncService.expired(baseSyncData)) {
+            return;
+        }
+        log.info("-----------coursesync start---------");
+        log.info(baseSyncData.toString());
+        String courseCode = baseSyncData.getEntity().get("code");
+        String orgId = baseSyncData.getEntity().get("orgId");
+        String courseName = baseSyncData.getEntity().get("name");
+        String courseLevel = baseSyncData.getEntity().get("level");
+        if(StringUtils.isEmpty(courseCode)
+                || StringUtils.isEmpty(orgId)
+                || StringUtils.isEmpty(courseName)
+                || StringUtils.isEmpty(courseLevel)){
+            return;
+        }
+        List<ExamStudent> examStudents = examStudentRepo.findByCourseCode(Long.valueOf(orgId),courseCode);
+        for(ExamStudent examStudent:examStudents){
+            if(!examStudent.getCourseLevel().equals(courseLevel)){
+                examStudent.setCourseLevel(courseLevel);
+            }
+            if(!examStudent.getCourseName().equals(courseName)){
+                examStudent.setCourseName(courseName);
+            }
+        }
+        examStudentRepo.save(examStudents);
+        log.info("-----------coursesync end---------");
+    }
+
+    @DataReceive(domain = "cn.com.qmth.examcloud.common.dto.core.OrgSync")
+    public synchronized void readOrg(BaseSyncData baseSyncData) {
+        if (dataSyncService.expired(baseSyncData)) {
+            return;
+        }
+        log.info("-----------orgsync start---------");
+        log.info(baseSyncData.toString());
+        String orgId = baseSyncData.getPk();
+        String name = baseSyncData.getEntity().get("name");
+        if(StringUtils.isEmpty(orgId)
+                || StringUtils.isEmpty(name)){
+            return;
+        }
+        List<ExamStudent> examStudents = examStudentRepo.findByOrgId(Long.valueOf(orgId));
+        for(ExamStudent examStudent:examStudents){
+            if(!examStudent.getOrgName().equals(name)){
+                examStudent.setOrgName(name);
+            }
+        }
+        examStudentRepo.save(examStudents);
+        log.info("-----------orgsync end---------");
+    }
+}

+ 26 - 26
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/service/sync/DataSendService.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/service/sync/DataSendService.java

@@ -1,26 +1,26 @@
-package cn.com.qmth.examcloud.service.examwork.service.sync;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import cn.com.qmth.examcloud.common.dto.em.ExamSync;
-import cn.com.qmth.examcloud.common.util.BeanCopierUtil;
-import cn.com.qmth.examcloud.service.examwork.entity.Exam;
-
-import com.qmth.commons.dataSync.core.service.DataSyncService;
-
-@Service
-public class DataSendService {
-	
-	@Autowired
-    DataSyncService dataSyncService;
-	
-	/**
-	 * 发送exam
-	 * @param exam
-	 */
-	public void sendExam(Exam exam){
-		ExamSync examSync = BeanCopierUtil.copyProperties(exam,ExamSync.class);
-		dataSyncService.send(examSync);
-	}
-}
+package cn.com.qmth.examcloud.service.examwork.service.sync;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.common.dto.em.ExamSync;
+import cn.com.qmth.examcloud.common.util.BeanCopierUtil;
+import cn.com.qmth.examcloud.service.examwork.entity.Exam;
+
+import com.qmth.commons.dataSync.core.service.DataSyncService;
+
+@Service
+public class DataSendService {
+	
+	@Autowired
+    DataSyncService dataSyncService;
+	
+	/**
+	 * 发送exam
+	 * @param exam
+	 */
+	public void sendExam(Exam exam){
+		ExamSync examSync = BeanCopierUtil.copyProperties(exam,ExamSync.class);
+		dataSyncService.send(examSync);
+	}
+}

+ 37 - 37
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/util/ExportUtils.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/util/ExportUtils.java

@@ -1,37 +1,37 @@
-package cn.com.qmth.examcloud.service.examwork.util;
-
-import java.net.URLEncoder;
-import java.util.Collection;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-
-import cn.com.qmth.examcloud.common.util.excel.ExcelWriter;
-
-
-/*
- * excel导出工具
- */
-public class ExportUtils {
-
-    private static final String DEFALUT_CONTENT_TYPE = "application/vnd.ms-excel";
-
-    private static final String DEFALUT_EXT = ".xlsx";
-
-    public static void exportEXCEL(String fileName,Class<?> dataClass,
-                             Collection<?> dataset,HttpServletResponse response) {
-        try {
-        	
-            response.setHeader("Content-Disposition", "inline; filename="
-                    +URLEncoder.encode(fileName, "UTF-8") + DEFALUT_EXT);
-            response.setContentType(DEFALUT_CONTENT_TYPE);
-            ServletOutputStream outputStream = response.getOutputStream();
-            ExcelWriter excelExporter = new ExcelWriter(dataClass);
-            excelExporter.write("sheet1",dataset,outputStream);
-            outputStream.flush();
-            outputStream.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}
+package cn.com.qmth.examcloud.service.examwork.util;
+
+import java.net.URLEncoder;
+import java.util.Collection;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.com.qmth.examcloud.common.util.excel.ExcelWriter;
+
+
+/*
+ * excel导出工具
+ */
+public class ExportUtils {
+
+    private static final String DEFALUT_CONTENT_TYPE = "application/vnd.ms-excel";
+
+    private static final String DEFALUT_EXT = ".xlsx";
+
+    public static void exportEXCEL(String fileName,Class<?> dataClass,
+                             Collection<?> dataset,HttpServletResponse response) {
+        try {
+        	
+            response.setHeader("Content-Disposition", "inline; filename="
+                    +URLEncoder.encode(fileName, "UTF-8") + DEFALUT_EXT);
+            response.setContentType(DEFALUT_CONTENT_TYPE);
+            ServletOutputStream outputStream = response.getOutputStream();
+            ExcelWriter excelExporter = new ExcelWriter(dataClass);
+            excelExporter.write("sheet1",dataset,outputStream);
+            outputStream.flush();
+            outputStream.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 58 - 58
examcloud-core-examwork-export/src/main/java/cn/com/qmth/examcloud/service/examwork/util/ImportUtils.java → examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/service/examwork/util/ImportUtils.java

@@ -1,58 +1,58 @@
-package cn.com.qmth.examcloud.service.examwork.util;
-
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.commons.CommonsMultipartFile;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-
-/**
- * Created by songyue on 17/7/14.
- */
-public final class ImportUtils {
-
-    protected static final Logger logger = LoggerFactory.getLogger(ImportUtils.class);
-
-    public static final String TEMP_FILE_IMP = "fileImport/";
-
-    public static final String TEMP_FILE_EXP = "fileExport/";
-
-    static {
-        init();
-    }
-
-    /**
-     * 初始化文件夹
-     */
-    public static void init() {
-        File temp_file_exp = new File(TEMP_FILE_EXP);
-        File temp_file_imp = new File(TEMP_FILE_IMP);
-        // 如果输出目标文件夹不存在,则创建
-        if (!temp_file_imp.exists()) {
-            temp_file_imp.mkdirs();
-        }
-        if (!temp_file_exp.exists()) {
-            temp_file_exp.mkdirs();
-        }
-    }
-
-    /**
-     * 获取上传文件
-     *
-     * @param file
-     * @return
-     */
-    public static File getUploadFile(MultipartFile file) throws Exception {
-        String fileName = file.getOriginalFilename();
-        File tempFile = new File(TEMP_FILE_IMP + fileName);
-        OutputStream os = new FileOutputStream(tempFile);
-        IOUtils.copyLarge(file.getInputStream(), os);
-        IOUtils.closeQuietly(os);
-        return tempFile;
-    }
-
-}
+package cn.com.qmth.examcloud.service.examwork.util;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+/**
+ * Created by songyue on 17/7/14.
+ */
+public final class ImportUtils {
+
+    protected static final Logger logger = LoggerFactory.getLogger(ImportUtils.class);
+
+    public static final String TEMP_FILE_IMP = "fileImport/";
+
+    public static final String TEMP_FILE_EXP = "fileExport/";
+
+    static {
+        init();
+    }
+
+    /**
+     * 初始化文件夹
+     */
+    public static void init() {
+        File temp_file_exp = new File(TEMP_FILE_EXP);
+        File temp_file_imp = new File(TEMP_FILE_IMP);
+        // 如果输出目标文件夹不存在,则创建
+        if (!temp_file_imp.exists()) {
+            temp_file_imp.mkdirs();
+        }
+        if (!temp_file_exp.exists()) {
+            temp_file_exp.mkdirs();
+        }
+    }
+
+    /**
+     * 获取上传文件
+     *
+     * @param file
+     * @return
+     */
+    public static File getUploadFile(MultipartFile file) throws Exception {
+        String fileName = file.getOriginalFilename();
+        File tempFile = new File(TEMP_FILE_IMP + fileName);
+        OutputStream os = new FileOutputStream(tempFile);
+        IOUtils.copyLarge(file.getInputStream(), os);
+        IOUtils.closeQuietly(os);
+        return tempFile;
+    }
+
+}