Browse Source

修复bug

宋悦 7 years ago
parent
commit
224e9ca56d

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

@@ -6,7 +6,9 @@ import java.util.List;
 
 import javax.persistence.criteria.Predicate;
 
+import cn.com.qmth.examcloud.common.dto.core.*;
 import cn.com.qmth.examcloud.common.util.BeanCopierUtil;
+import cn.com.qmth.examcloud.service.examwork.service.rpc.SpecialtyService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,10 +18,6 @@ import org.springframework.data.jpa.domain.Specification;
 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.util.ErrorMsg;
 import cn.com.qmth.examcloud.common.util.excel.ExcelError;
@@ -62,6 +60,9 @@ public class ExamStudentService {
     @Autowired
     OrgService orgService;
 
+	@Autowired
+	SpecialtyService specialtyService;
+
 
 //    @Value("${app.em.photo.path}")
 //    private String PHOTO_PATH ;
@@ -247,6 +248,16 @@ public class ExamStudentService {
 		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("课程不存在/被禁用");
@@ -349,7 +360,7 @@ public class ExamStudentService {
 				predicates.add(cb.like(root.get("examSite"),"%"+examCriteria.getExamSite()+"%"));
 			}
 			if(!StringUtils.isEmpty(examCriteria.getIdentityNumber())){
-				predicates.add(cb.equal(root.get("identityNumber"),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()+"%"));

+ 29 - 0
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/SpecialtyService.java

@@ -0,0 +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;
+	}
+
+}

+ 19 - 0
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/SpecialtyClient.java

@@ -0,0 +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);
+
+}

+ 2 - 0
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/assembler/ExamStudentAssembler.java

@@ -30,6 +30,7 @@ public class ExamStudentAssembler {
 			dto.setPaperType(examStudent.getPaperType());
 			dto.setRepair(examStudent.getRepair());
 			dto.setRootOrgId(examStudent.getRootOrgId());
+			dto.setSpecialtyCode(examStudent.getSpecialtyCode());
 			dto.setSpecialtyName(examStudent.getSpecialtyName());
 			dto.setStudentCode(examStudent.getStudentCode());
 		}
@@ -59,6 +60,7 @@ public class ExamStudentAssembler {
 			domain.setRemark(dto.getRemark());
 			domain.setRepair(dto.getRepair());
 			domain.setRootOrgId(dto.getRootOrgId());
+			domain.setSpecialtyCode(dto.getSpecialtyCode());
 			domain.setSpecialtyName(dto.getSpecialtyName());
 			domain.setStudentCode(dto.getStudentCode());
 			domain.setInfoCollector(dto.getInfoCollector());

+ 17 - 4
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/dto/ExamStudentDTO.java

@@ -51,6 +51,11 @@ public class ExamStudentDTO {
 	 * 学位
 	 */
 	private Boolean degree;
+
+
+
+	private String specialtyCode;
+
 	@ExcelProperty(index = 6,name = "专业")
 	private String specialtyName;
 	
@@ -156,12 +161,12 @@ public class ExamStudentDTO {
 		this.courseName = courseName;
 	}
 
-	public String getSpecialtyName() {
-		return specialtyName;
+	public String getSpecialtyCode() {
+		return specialtyCode;
 	}
 
-	public void setSpecialtyName(String specialtyName) {
-		this.specialtyName = specialtyName;
+	public void setSpecialtyCode(String specialtyCode) {
+		this.specialtyCode = specialtyCode;
 	}
 
 	public String getRemark() {
@@ -300,6 +305,14 @@ public class ExamStudentDTO {
 		this.phone = phone;
 	}
 
+	public String getSpecialtyName() {
+		return specialtyName;
+	}
+
+	public void setSpecialtyName(String specialtyName) {
+		this.specialtyName = specialtyName;
+	}
+
 	public ExamStudentDTO() {
 	}
 }

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

@@ -62,6 +62,8 @@ public class ExamStudent implements Serializable {
 	private Boolean degree;
 
 	private String specialtyName;
+
+	private String specialtyCode;
 	
 	/**
 	 * 是否重修
@@ -313,6 +315,14 @@ public class ExamStudent implements Serializable {
 		this.phone = phone;
 	}
 
+	public String getSpecialtyCode() {
+		return specialtyCode;
+	}
+
+	public void setSpecialtyCode(String specialtyCode) {
+		this.specialtyCode = specialtyCode;
+	}
+
 	public ExamStudent() {
 	}
 }