ting.yin hace 8 años
padre
commit
613ca840ca

+ 21 - 8
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamApi.java

@@ -1,17 +1,29 @@
 package cn.com.qmth.examcloud.service.examwork.api;
 
-import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
-import cn.com.qmth.examcloud.service.examwork.entity.Exam;
-import cn.com.qmth.examcloud.service.examwork.service.ExamService;
 import io.swagger.annotations.ApiOperation;
 
+import java.util.Date;
+
+import javax.servlet.http.HttpServletRequest;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
-import java.util.Date;
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
+import cn.com.qmth.examcloud.service.examwork.entity.Exam;
+import cn.com.qmth.examcloud.service.examwork.service.ExamService;
 
 /**
  * 考试服务API
@@ -39,10 +51,11 @@ public class ExamApi {
         return new ResponseEntity(examService.getAllExam(examCriteria), HttpStatus.OK);
     }
 
-    @ApiOperation(value="查询所有考试批次",notes = "不分页不带查询")
+    @ApiOperation(value="查询所有考试批次(orgId)",notes = "不分页不带查询")
     @GetMapping("/exam")
-    public ResponseEntity getAllExam(){
-        return new ResponseEntity(examService.getAllExam(), HttpStatus.OK);
+    public ResponseEntity getAllExam(HttpServletRequest request){
+    	AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
+        return new ResponseEntity(examRepo.findByOrgId(accessUser.getOrgId()), HttpStatus.OK);
     }
 
     @ApiOperation(value="按ID查询考试批次",notes = "ID查询")

+ 11 - 11
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamStudentApi.java

@@ -96,17 +96,17 @@ public class ExamStudentApi {
 		}
     }
     
-    @ApiOperation(value="导入学生照片",notes = "导入")
-    @PostMapping("/exam_student/import_photo")
-    public ResponseEntity importPhoto(@RequestParam Long examId,@RequestParam MultipartFile file){
-    	try {
-    		List<ErrorMsg> errorMsgs = examStudentService.importPhoto(examId,file.getInputStream());
-    		return new ResponseEntity(errorMsgs,HttpStatus.OK);
-		} catch (IOException e) {
-			e.printStackTrace();
-			return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
-		}
-    }
+//    @ApiOperation(value="导入学生照片",notes = "导入")
+//    @PostMapping("/exam_student/import_photo")
+//    public ResponseEntity importPhoto(@RequestParam Long examId,@RequestParam MultipartFile file){
+//    	try {
+//    		List<ErrorMsg> errorMsgs = examStudentService.importPhoto(examId,file.getInputStream());
+//    		return new ResponseEntity(errorMsgs,HttpStatus.OK);
+//		} catch (IOException e) {
+//			e.printStackTrace();
+//			return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
+//		}
+//    }
     
     @ApiOperation(value="照片检验",notes = "检验")
     @PostMapping("/exam_student/photo_check")

+ 11 - 117
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java

@@ -2,23 +2,13 @@ package cn.com.qmth.examcloud.service.examwork.service;
 
 import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
 
 import javax.persistence.criteria.Predicate;
 
-import org.json.JSONArray;
-import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.Example;
 import org.springframework.data.domain.ExampleMatcher;
 import org.springframework.data.domain.Page;
@@ -35,10 +25,6 @@ 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.entity.Exam;
 import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
-import cn.com.qmth.examcloud.service.examwork.service.rpc.StudentService;
-
-import com.facepp.http.HttpRequests;
-import com.facepp.http.PostParameters;
 
 /**
  * 考试学生服务类
@@ -50,17 +36,13 @@ public class ExamStudentService {
     ExamStudentRepo examStudentRepo;
     @Autowired
     ExamRepo examRepo;
-    @Autowired
-    StudentService studentService;
     
-    @Value("${app.em.photo.path}")
-    private String PHOTO_PATH ;
-    @Value("${app.em.facepp.key}")
-    private String FACEPP_KEY;
-    @Value("${app.em.facepp.secret}")
-    private String FACEPP_SECRET;
-    
-    private static final String JPG = ".jpg";
+//    @Value("${app.em.photo.path}")
+//    private String PHOTO_PATH ;
+//    @Value("${app.em.facepp.key}")
+//    private String FACEPP_KEY;
+//    @Value("${app.em.facepp.secret}")
+//    private String FACEPP_SECRET;
     
     /**
      * 获取所有考试学生(分页)
@@ -170,6 +152,7 @@ public class ExamStudentService {
         examStudents.removeAll(examStudents);
         return excelErrors;
 	}
+	
 	/**
 	 * 考生导入验证
 	 * @param stu
@@ -179,67 +162,6 @@ public class ExamStudentService {
 		
 		return null;
 	}
-
-	/**
-	 * 导入照片
-	 * @param examId 
-	 * @param photoFile
-	 * @throws IOException 
-	 */
-	public List<ErrorMsg> importPhoto(Long examId, InputStream inputStream) throws IOException {
-		List<ErrorMsg> errorMsgs = new ArrayList<ErrorMsg>();
-		Exam exam = examRepo.findOne(examId);
-		ZipInputStream zin = new ZipInputStream(inputStream);
-		ZipEntry ze;
-		try {
-			while ((ze = zin.getNextEntry()) != null) {
-				if (ze.isDirectory()) {
-					
-				} else {
-					if(!ze.getName().endsWith(JPG)){
-						errorMsgs.add(new ErrorMsg(ze.getName()+"格式错误,文件名格式必须是jpg(小写)"));
-					}
-					if(ze.getSize()>300000){
-						errorMsgs.add(new ErrorMsg(ze.getName()+"大于300KB,请处理后重新上传"));
-					}
-					String savePath = PHOTO_PATH + File.separator + exam.getOrgId() + File.separator + "photo";
-					uploadPhoto(savePath, zin, ze);
-				}
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-			errorMsgs.add(new ErrorMsg("压缩文件中有中文名称文件或文件夹,请修改后重新上传"));
-		}finally{
-			zin.closeEntry();
-		}
-		return errorMsgs;
-	}
-	
-	/**
-	 * 考生照片上传照片到服务器
-	 */
-	public void uploadPhoto(String filePath,ZipInputStream zin,ZipEntry ze){
-		try {
-			File out = new File(filePath);
-			if (!out.exists()) {
-				out.mkdirs();
-			}
-			File outFile = new File(filePath + File.separator + ze.getName());
-			if (!outFile.exists()) {
-				outFile.createNewFile();
-			}
-			OutputStream output = new FileOutputStream(outFile);
-			int temp = 0;
-			while ((temp = zin.read()) != -1) {
-				output.write(temp);
-			}
-			output.close();
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
 	
 	/**
 	 * 照片检验
@@ -251,41 +173,13 @@ public class ExamStudentService {
 		List<ExamStudent> examStudents = examStudentRepo.findByExamId(examId);
 		for (ExamStudent examStudent : examStudents) {
 			ErrorMsg errorMsg = null;
-			if(!StringUtils.isEmpty(examStudent.getIdentityNumber())){
-				errorMsg = checkExamStudent(examStudent.getOrgId(),examStudent.getIdentityNumber());
-				msgs.add(errorMsg);
+			if(!StringUtils.isEmpty(examStudent.getStudentCode())){
+				
+			}else if(!StringUtils.isEmpty(examStudent.getIdentityNumber())){
+				
 			}
 		}
 		return msgs;
 	}
 
-	/**
-	 * 身份证号检查
-	 * @param orgId
-	 * @param identityNumber
-	 * @return
-	 */
-	private ErrorMsg checkExamStudent(Long orgId,String identityNumber) {
-		ErrorMsg error = null;
-		String filePath = PHOTO_PATH + File.separator + orgId + File.separator+"photo"+ File.separator;
-		HttpRequests httpRequests = new HttpRequests(FACEPP_KEY, FACEPP_SECRET);
-		try {
-			JSONObject face = httpRequests.detectionDetect(new PostParameters()
-					.setImg(new File(filePath + identityNumber + JPG)));
-			JSONArray faceArray = face.getJSONArray("face");
-			if (faceArray.length() > 0) {
-				//人脸识别成功
-				studentService.updatePhoto(identityNumber);
-			} else {
-				error = new ErrorMsg(identityNumber + JPG + "不能被识别人脸,请换一张清晰的照片重新上传!");
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-			error = new ErrorMsg("人脸识别服务器错误,请联系技术人员!");
-		}
-		return error;
-	}
-
-	
-	
 }

+ 1 - 1
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/StudentClient.java

@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 @FeignClient(value = "ExamCloud-service-core")
 public interface StudentClient {
 
-	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/student/update")
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/student/")
 	String updatePhoto(@RequestParam("identityNumber") String identityNumber);
 
 }

+ 6 - 1
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/dao/ExamRepo.java

@@ -1,8 +1,13 @@
 package cn.com.qmth.examcloud.service.examwork.dao;
 
+import java.util.List;
+
 import org.springframework.data.jpa.repository.JpaRepository;
-import cn.com.qmth.examcloud.service.examwork.entity.Exam;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
+import cn.com.qmth.examcloud.service.examwork.entity.Exam;
+
 public interface ExamRepo extends JpaRepository<Exam, Long>,QueryByExampleExecutor<Exam>{
+
+	List<Exam> findByOrgId(Long orgId);
 }

+ 29 - 14
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/entity/ExamStudent.java

@@ -47,11 +47,18 @@ public class ExamStudent implements Serializable {
 	private String courseCode;
 
 	private String courseName;
-
-	private String degree;
-
-	private String specialtyLevel;
 	
+	private String courseLevel;
+	
+	/**
+	 * 试卷类型
+	 */
+	private String examType;
+	/**
+	 * 学位
+	 */
+	private boolean degree;
+
 	private String specialtyName;
 	
 	/**
@@ -148,22 +155,14 @@ public class ExamStudent implements Serializable {
 		this.courseName = courseName;
 	}
 
-	public String getDegree() {
+	public boolean isDegree() {
 		return degree;
 	}
 
-	public void setDegree(String degree) {
+	public void setDegree(boolean degree) {
 		this.degree = degree;
 	}
 
-	public String getSpecialtyLevel() {
-		return specialtyLevel;
-	}
-
-	public void setSpecialtyLevel(String specialtyLevel) {
-		this.specialtyLevel = specialtyLevel;
-	}
-
 	public String getSpecialtyName() {
 		return specialtyName;
 	}
@@ -248,6 +247,22 @@ public class ExamStudent implements Serializable {
 		this.orgCode = orgCode;
 	}
 
+	public String getExamType() {
+		return examType;
+	}
+
+	public void setExamType(String examType) {
+		this.examType = examType;
+	}
+
+	public String getCourseLevel() {
+		return courseLevel;
+	}
+
+	public void setCourseLevel(String courseLevel) {
+		this.courseLevel = courseLevel;
+	}
+
 	public ExamStudent() {
 	}
 }