|
@@ -44,94 +44,94 @@ import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
|
|
|
|
/**
|
|
|
- * @author weiwenhai
|
|
|
- * @date 2018.10.11
|
|
|
- * @company qmth
|
|
|
- * @description 同步课程
|
|
|
- * @code 018
|
|
|
+ * @author weiwenhai
|
|
|
+ * @date 2018.10.11
|
|
|
+ * @company qmth
|
|
|
+ * @description 同步课程
|
|
|
+ * @code 018
|
|
|
*/
|
|
|
@Transactional
|
|
|
@RestController
|
|
|
@RequestMapping("${$rmp.cloud.questions}" + "dataSync")
|
|
|
public class HandleSyncCloudServiceProvider extends ControllerSupport implements HandleSyncCloudService {
|
|
|
|
|
|
- private static final long serialVersionUID = -2121791220624238299L;
|
|
|
+ private static final long serialVersionUID = -2121791220624238299L;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Autowired
|
|
|
ExtractConfigRepo extractConfigRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+
|
|
|
+ @Autowired
|
|
|
QuesRepo quesRepo;
|
|
|
|
|
|
@Autowired
|
|
|
PaperRepo paperRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
+
|
|
|
+ @Autowired
|
|
|
MongoTemplate mongoTemplate;
|
|
|
-
|
|
|
- @ApiOperation(value = "同步课程")
|
|
|
- @PostMapping("syncCourse")
|
|
|
- @Override
|
|
|
- public SyncCourseResp syncCourse(@RequestBody SyncCourseReq req) {
|
|
|
- String courseCode = req.getCode();
|
|
|
- Long rootOrgId = req.getRootOrgId();
|
|
|
- String courseName = req.getName();
|
|
|
- String courseLevel = req.getLevel();
|
|
|
- Boolean enable = req.getEnable();
|
|
|
- Long courseId = req.getId();
|
|
|
- if (StringUtils.isBlank(courseName)) {
|
|
|
- throw new StatusException("Q-018073", "courseName is null");
|
|
|
- }
|
|
|
- if (null == courseId) {
|
|
|
- throw new StatusException("Q-018076", "courseId is null");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(courseLevel)) {
|
|
|
- throw new StatusException("Q-018079", "courseLevel is null");
|
|
|
- }
|
|
|
- if (null == rootOrgId) {
|
|
|
- throw new StatusException("Q-018082", "rootOrgId is null");
|
|
|
- }
|
|
|
- //同步调卷规则
|
|
|
- List<ExtractConfig> extractConfigs= extractConfigRepo.findByCourseCodeAndOrgId(courseCode,rootOrgId.toString());
|
|
|
- if (extractConfigs != null && extractConfigs.size() > 0) {
|
|
|
- int i = 0;
|
|
|
- for (ExtractConfig extractConfig : extractConfigs) {
|
|
|
- extractConfig.setCourseName(courseName);
|
|
|
- Course course = extractConfig.getCourse();
|
|
|
- if(course != null){
|
|
|
- course.setName(courseName);
|
|
|
- course.setLevel(courseLevel);
|
|
|
- course.setEnable(enable.toString());
|
|
|
- course.setUpdateTime(CommonUtils.getCurDateTime());
|
|
|
- extractConfig.setCourse(course);
|
|
|
- }else{
|
|
|
- Course tempCourse = new Course();
|
|
|
- tempCourse.setCode(courseCode);
|
|
|
- tempCourse.setName(courseName);
|
|
|
- tempCourse.setLevel(courseLevel);
|
|
|
- tempCourse.setEnable(enable.toString());
|
|
|
- tempCourse.setOrgId(rootOrgId.toString());
|
|
|
- tempCourse.setCreateTime(CommonUtils.getCurDateTime());
|
|
|
- extractConfig.setCourse(tempCourse);
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- extractConfigRepo.saveAll(extractConfigs);
|
|
|
- log.debug("调卷规则同步完成,已经同步数量:"+ i);
|
|
|
- }
|
|
|
- //同步试卷
|
|
|
- List<Paper> papers = paperRepo.findByCourseNoAndOrgId(courseCode, rootOrgId.toString());
|
|
|
+
|
|
|
+ @ApiOperation(value = "同步课程")
|
|
|
+ @PostMapping("syncCourse")
|
|
|
+ @Override
|
|
|
+ public SyncCourseResp syncCourse(@RequestBody SyncCourseReq req) {
|
|
|
+ String courseCode = req.getCode();
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ String courseName = req.getName();
|
|
|
+ String courseLevel = req.getLevel();
|
|
|
+ Boolean enable = req.getEnable();
|
|
|
+ Long courseId = req.getId();
|
|
|
+ if (StringUtils.isBlank(courseName)) {
|
|
|
+ throw new StatusException("Q-018073", "courseName is null");
|
|
|
+ }
|
|
|
+ if (null == courseId) {
|
|
|
+ throw new StatusException("Q-018076", "courseId is null");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(courseLevel)) {
|
|
|
+ throw new StatusException("Q-018079", "courseLevel is null");
|
|
|
+ }
|
|
|
+ if (null == rootOrgId) {
|
|
|
+ throw new StatusException("Q-018082", "rootOrgId is null");
|
|
|
+ }
|
|
|
+ //同步调卷规则
|
|
|
+ List<ExtractConfig> extractConfigs = extractConfigRepo.findByCourseCodeAndOrgId(courseCode, rootOrgId.toString());
|
|
|
+ if (extractConfigs != null && extractConfigs.size() > 0) {
|
|
|
+ int i = 0;
|
|
|
+ for (ExtractConfig extractConfig : extractConfigs) {
|
|
|
+ extractConfig.setCourseName(courseName);
|
|
|
+ Course course = extractConfig.getCourse();
|
|
|
+ if (course != null) {
|
|
|
+ course.setName(courseName);
|
|
|
+ course.setLevel(courseLevel);
|
|
|
+ course.setEnable(enable.toString());
|
|
|
+ course.setUpdateTime(CommonUtils.getCurDateTime());
|
|
|
+ extractConfig.setCourse(course);
|
|
|
+ } else {
|
|
|
+ Course tempCourse = new Course();
|
|
|
+ tempCourse.setCode(courseCode);
|
|
|
+ tempCourse.setName(courseName);
|
|
|
+ tempCourse.setLevel(courseLevel);
|
|
|
+ tempCourse.setEnable(enable.toString());
|
|
|
+ tempCourse.setOrgId(rootOrgId.toString());
|
|
|
+ tempCourse.setCreateTime(CommonUtils.getCurDateTime());
|
|
|
+ extractConfig.setCourse(tempCourse);
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ extractConfigRepo.saveAll(extractConfigs);
|
|
|
+ log.debug("调卷规则同步完成,已经同步数量:" + i);
|
|
|
+ }
|
|
|
+ //同步试卷
|
|
|
+ List<Paper> papers = paperRepo.findByCourseNoAndOrgId(courseCode, rootOrgId.toString());
|
|
|
if (papers != null && papers.size() > 0) {
|
|
|
- int i = 0;
|
|
|
+ int i = 0;
|
|
|
for (Paper paper : papers) {
|
|
|
Course course = paper.getCourse();
|
|
|
- if(course != null){
|
|
|
+ if (course != null) {
|
|
|
course.setName(courseName);
|
|
|
course.setLevel(courseLevel);
|
|
|
course.setEnable(enable.toString());
|
|
|
course.setUpdateTime(CommonUtils.getCurDateTime());
|
|
|
paper.setCourse(course);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Course tempCourse = new Course();
|
|
|
tempCourse.setCode(courseCode);
|
|
|
tempCourse.setName(courseName);
|
|
@@ -144,7 +144,7 @@ public class HandleSyncCloudServiceProvider extends ControllerSupport implements
|
|
|
i++;
|
|
|
}
|
|
|
paperRepo.saveAll(papers);
|
|
|
- log.debug("试卷同步完成,已经同步数量:"+ i);
|
|
|
+ log.debug("试卷同步完成,已经同步数量:" + i);
|
|
|
}
|
|
|
//同步试题
|
|
|
Query query = new Query();
|
|
@@ -152,16 +152,16 @@ public class HandleSyncCloudServiceProvider extends ControllerSupport implements
|
|
|
query.addCriteria(Criteria.where("course.code").is(courseCode));
|
|
|
List<Question> questions = this.mongoTemplate.find(query, Question.class);
|
|
|
if (questions != null && questions.size() > 0) {
|
|
|
- int i = 0;
|
|
|
+ int i = 0;
|
|
|
for (Question question : questions) {
|
|
|
Course course = question.getCourse();
|
|
|
- if(course != null){
|
|
|
+ if (course != null) {
|
|
|
course.setName(courseName);
|
|
|
course.setLevel(courseLevel);
|
|
|
course.setEnable(enable.toString());
|
|
|
course.setUpdateTime(CommonUtils.getCurDateTime());
|
|
|
question.setCourse(course);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Course tempCourse = new Course();
|
|
|
tempCourse.setCode(courseCode);
|
|
|
tempCourse.setName(courseName);
|
|
@@ -174,81 +174,81 @@ public class HandleSyncCloudServiceProvider extends ControllerSupport implements
|
|
|
i++;
|
|
|
}
|
|
|
quesRepo.saveAll(questions);
|
|
|
- log.debug("试题同步完成,已经同步数量:"+ i);
|
|
|
+ log.debug("试题同步完成,已经同步数量:" + i);
|
|
|
}
|
|
|
SyncCourseResp resp = new SyncCourseResp();
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public SyncOrgResp syncOrg(SyncOrgReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public SyncStudentResp syncStudent(SyncStudentReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public SyncExamStudentResp syncExamStudent(SyncExamStudentReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public SyncSpecialtyResp syncSpecialty(SyncSpecialtyReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "同步考试")
|
|
|
- @PostMapping("syncExam")
|
|
|
- @Override
|
|
|
- public SyncExamResp syncExam(@RequestBody SyncExamReq req) {
|
|
|
- Long rootOrgId = req.getRootOrgId();
|
|
|
- Long id = req.getId();
|
|
|
- String name = req.getName();
|
|
|
- String examType = req.getExamType();
|
|
|
- if (StringUtils.isBlank(name)) {
|
|
|
- throw new StatusException("Q-018213", "name is null");
|
|
|
- }
|
|
|
- if (null == id) {
|
|
|
- throw new StatusException("Q-018216", "id is null");
|
|
|
- }
|
|
|
- if (null == rootOrgId) {
|
|
|
- throw new StatusException("Q-018219", "rootOrgId is null");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(examType)) {
|
|
|
- throw new StatusException("Q-018223", "examType is null");
|
|
|
- }
|
|
|
- //同步调卷规则
|
|
|
- Query query = new Query();
|
|
|
- query.addCriteria(Criteria.where("orgId").is(rootOrgId.toString()));
|
|
|
- query.addCriteria(Criteria.where("examId").is(id));
|
|
|
- List<ExtractConfig> extractConfigs = this.mongoTemplate.find(query, ExtractConfig.class);
|
|
|
- log.debug("调卷规则总数量:"+extractConfigs.size());
|
|
|
- if (extractConfigs != null && extractConfigs.size() > 0) {
|
|
|
- int i = 0;
|
|
|
- for (ExtractConfig extractConfig : extractConfigs) {
|
|
|
- i++;
|
|
|
- extractConfig.setExamName(name);
|
|
|
- extractConfig.setExamType(examType);
|
|
|
- extractConfig.setExamType(examType);
|
|
|
- }
|
|
|
- extractConfigRepo.saveAll(extractConfigs);
|
|
|
- log.debug("调卷规则同步完成,已经同步数量:"+ i);
|
|
|
- }
|
|
|
- SyncExamResp resp = new SyncExamResp();
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public SyncUserResp syncUser(SyncUserReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SyncOrgResp syncOrg(SyncOrgReq req) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SyncStudentResp syncStudent(SyncStudentReq req) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SyncExamStudentResp syncExamStudent(SyncExamStudentReq req) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SyncSpecialtyResp syncSpecialty(SyncSpecialtyReq req) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "同步考试")
|
|
|
+ @PostMapping("syncExam")
|
|
|
+ @Override
|
|
|
+ public SyncExamResp syncExam(@RequestBody SyncExamReq req) {
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ Long id = req.getId();
|
|
|
+ String name = req.getName();
|
|
|
+ String examType = req.getExamType();
|
|
|
+ if (StringUtils.isBlank(name)) {
|
|
|
+ throw new StatusException("Q-018213", "name is null");
|
|
|
+ }
|
|
|
+ if (null == id) {
|
|
|
+ throw new StatusException("Q-018216", "id is null");
|
|
|
+ }
|
|
|
+ if (null == rootOrgId) {
|
|
|
+ throw new StatusException("Q-018219", "rootOrgId is null");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(examType)) {
|
|
|
+ throw new StatusException("Q-018223", "examType is null");
|
|
|
+ }
|
|
|
+ //同步调卷规则
|
|
|
+ Query query = new Query();
|
|
|
+ query.addCriteria(Criteria.where("orgId").is(rootOrgId.toString()));
|
|
|
+ query.addCriteria(Criteria.where("examId").is(id));
|
|
|
+ List<ExtractConfig> extractConfigs = this.mongoTemplate.find(query, ExtractConfig.class);
|
|
|
+ log.debug("调卷规则总数量:" + extractConfigs.size());
|
|
|
+ if (extractConfigs != null && extractConfigs.size() > 0) {
|
|
|
+ int i = 0;
|
|
|
+ for (ExtractConfig extractConfig : extractConfigs) {
|
|
|
+ i++;
|
|
|
+ extractConfig.setExamName(name);
|
|
|
+ extractConfig.setExamType(examType);
|
|
|
+ extractConfig.setExamType(examType);
|
|
|
+ }
|
|
|
+ extractConfigRepo.saveAll(extractConfigs);
|
|
|
+ log.debug("调卷规则同步完成,已经同步数量:" + i);
|
|
|
+ }
|
|
|
+ SyncExamResp resp = new SyncExamResp();
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SyncUserResp syncUser(SyncUserReq req) {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|