浏览代码

提交代码...

weiwenhai 6 年之前
父节点
当前提交
1d02d47a61

+ 5 - 0
examcloud-core-questions-base/pom.xml

@@ -104,6 +104,11 @@
 			<artifactId>examcloud-core-examwork-api-client</artifactId>
 			<version>${examcloud.version}</version>
 		</dependency>
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.rmi</groupId>
+			<artifactId>examcloud-core-basic-api-client</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
 	</dependencies>
 
 </project>

+ 10 - 0
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/CourseProperty.java

@@ -37,6 +37,8 @@ public class CourseProperty implements Serializable{
 	private String courseCode;
 	
 	private Boolean enable;
+	
+	private String courseName;
 
 	public CourseProperty(){}
 	
@@ -106,5 +108,13 @@ public class CourseProperty implements Serializable{
 	public void setCourseCode(String courseCode) {
 		this.courseCode = courseCode;
 	}
+
+	public String getCourseName() {
+		return courseName;
+	}
+
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
+	}
 	
 }

+ 10 - 0
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/PaperStruct.java

@@ -43,6 +43,8 @@ public class PaperStruct implements Serializable {
 
     private String courseNo;
     
+    private String courseName;
+    
     /**
      * 试卷结构类型  :  精确组卷    蓝图组卷
      */
@@ -204,5 +206,13 @@ public class PaperStruct implements Serializable {
 	public void setExamRemark(String examRemark) {
 		this.examRemark = examRemark;
 	}
+
+	public String getCourseName() {
+		return courseName;
+	}
+
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
+	}
 	
 }

+ 25 - 17
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperStructService.java

@@ -6,6 +6,9 @@ import java.util.Collection;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
+import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
 import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
 import cn.com.qmth.examcloud.core.questions.dao.QuesTypeNameRepo;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyNumberDto;
@@ -45,6 +48,9 @@ public class PaperStructService {
 
     @Autowired
     MongoTemplate mongoTemplate;
+    
+    @Autowired
+    CourseCloudService courseCloudService;
 
     /**
      * 获取所有试卷结构(分页)
@@ -55,17 +61,6 @@ public class PaperStructService {
      * @return
      */
     public Page<PaperStruct> getPaperStructs(PaperStructSearchInfo searchInfo, int curPage, int pageSize) {
-        /*formatSearchInfo(searchInfo);
-        PaperStruct paperStruct = BeanCopierUtil.copyProperties(searchInfo, PaperStruct.class);
-        formatPaperStruct(paperStruct);
-        ExampleMatcher matcher = ExampleMatcher.matching()
-                .withMatcher("name",contains())
-                .withMatcher("creator",contains())
-                .withMatcher("orgId",exact())
-                .withIgnoreNullValues();
-        return paperStructRepo.findAll(Example.of(paperStruct, matcher), new PageRequest(curPage - 1, pageSize));*/
-
-    	//create by weiwenhai
     	Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(searchInfo.getOrgId()));
         query.addCriteria(Criteria.where("type").is(searchInfo.getType()));
@@ -94,6 +89,20 @@ public class PaperStructService {
         query.limit(pageSize);
         query.skip((curPage - 1) * pageSize);
         List<PaperStruct> paperList = this.mongoTemplate.find(query, PaperStruct.class);
+        //远程调用rmi,查询课程名称
+        if(paperList != null && paperList.size()>0){
+        	for(PaperStruct paperStruct:paperList){
+        		if(StringUtils.isBlank(paperStruct.getCourseNo())){
+        			paperStruct.setCourseName("公用");
+        		}else {
+        			GetCourseReq req = new GetCourseReq();
+            		req.setRootOrgId(Long.valueOf(paperStruct.getOrgId()));
+            		req.setCode(paperStruct.getCourseNo());
+            		GetCourseResp resp = courseCloudService.getCourse(req);
+            		paperStruct.setCourseName(resp.getCourseBean().getName());
+				}
+        	}
+        }
         return new PageImpl<PaperStruct>(paperList, new PageRequest(curPage - 1, pageSize), count);
     }
 
@@ -366,12 +375,11 @@ public class PaperStructService {
 	}
 
     public PaperStruct checkNameUnique(String name, String orgId, String type) {
-        PaperStruct paperTemp = new PaperStruct();
-        paperTemp.setCreateTime(null);
-        paperTemp.setName(name.trim());
-        paperTemp.setOrgId(orgId);
-        paperTemp.setType(type);
-        PaperStruct paperStruct = paperStructRepo.findOne(Example.of(paperTemp));
+    	Query query = new Query();
+    	query.addCriteria(Criteria.where("orgId").is(orgId));
+    	query.addCriteria(Criteria.where("name").is(name.trim()));
+    	query.addCriteria(Criteria.where("type").is(type));
+    	PaperStruct paperStruct = this.mongoTemplate.findOne(query, PaperStruct.class);
         return paperStruct;
     }
 

+ 16 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/CoursePropertyServiceImpl.java

@@ -12,6 +12,9 @@ import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
+import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
 import cn.com.qmth.examcloud.core.questions.dao.CoursePropertyRepo;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyDto;
 import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
@@ -27,6 +30,9 @@ public class CoursePropertyServiceImpl implements CoursePropertyService{
 	
 	@Autowired
 	private CoursePropertyRepo coursePropertyRepo;
+	
+	@Autowired
+    CourseCloudService courseCloudService;
 
 	@Override
 	public List<CourseProperty> findAllByOrgId(Long orgId) {
@@ -49,6 +55,16 @@ public class CoursePropertyServiceImpl implements CoursePropertyService{
 	public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable) {
 		Specification<CourseProperty> specification = getSpecification(coursePropertyDto);
 		Page<CourseProperty> coursePropertyies = coursePropertyRepo.findAll(specification, pageable);
+		List<CourseProperty> list = coursePropertyies.getContent();
+		if(list != null && list.size()>0){
+			for(CourseProperty courseProperty:list){
+				GetCourseReq req = new GetCourseReq();
+				req.setId(courseProperty.getCourseId());
+				req.setRootOrgId(Long.valueOf(courseProperty.getOrgId()));
+				GetCourseResp resp = courseCloudService.getCourse(req);
+				courseProperty.setCourseName(resp.getCourseBean().getName());
+			}
+		}
 		return coursePropertyies;
 	}
 

+ 5 - 1
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuestionProviderServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.regex.Pattern;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -220,8 +221,11 @@ public class QuestionProviderServiceImpl implements QuestionProviderService{
 		query.addCriteria(Criteria.where("isolated").is(true));
 		if(map != null && map.size()>0){
 			for(Map.Entry<String, String> entry:map.entrySet()){
+				 String la = entry.getValue();
+				 la = la.replaceAll(",", "*");
+				 Pattern pattern=Pattern.compile(la, Pattern.CASE_INSENSITIVE);
 				 String key = "properties." + entry.getKey();
-				 query.addCriteria(Criteria.where(key).is(entry.getValue()));
+				 query.addCriteria(Criteria.where(key).regex(pattern));
 			 }
 		}
 		long count = this.mongoTemplate.count(query, Question.class);