|
@@ -5,6 +5,7 @@ import com.qmth.commons.dataSync.core.entity.BaseSyncData;
|
|
|
import com.qmth.commons.dataSync.core.service.DataSyncService;
|
|
|
import com.qmth.cqb.base.dao.CourseRepo;
|
|
|
import com.qmth.cqb.base.model.Course;
|
|
|
+import com.qmth.cqb.base.model.Specialty;
|
|
|
import com.qmth.cqb.paper.dao.ExtractConfigRepo;
|
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
|
import com.qmth.cqb.paper.model.ExtractConfig;
|
|
@@ -12,12 +13,14 @@ import com.qmth.cqb.paper.model.Paper;
|
|
|
import com.qmth.cqb.question.dao.QuesRepo;
|
|
|
import com.qmth.cqb.question.model.Question;
|
|
|
import com.qmth.cqb.utils.CommonUtils;
|
|
|
+
|
|
|
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.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -158,5 +161,73 @@ public class DataReceiveService {
|
|
|
log.info("-----------coursesync end---------");
|
|
|
}
|
|
|
|
|
|
+ @DataReceive(domain = "cn.com.qmth.examcloud.common.dto.core.SpecialtySync")
|
|
|
+ public synchronized void readSpecialty(BaseSyncData baseSyncData) {
|
|
|
+ log.info("-----------specialty start---------");
|
|
|
+ log.info(baseSyncData.toString());
|
|
|
+ String specialtyCode = baseSyncData.getEntity().get("code");
|
|
|
+ String orgId = baseSyncData.getEntity().get("orgId");
|
|
|
+ String specialtyName = baseSyncData.getEntity().get("name");
|
|
|
+ String enable = baseSyncData.getEntity().get("enable");
|
|
|
+ if (StringUtils.isEmpty(specialtyCode)
|
|
|
+ || StringUtils.isEmpty(orgId)
|
|
|
+ || StringUtils.isEmpty(specialtyName)
|
|
|
+ || StringUtils.isEmpty(enable)) {
|
|
|
+ log.error("entity value is null");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean specialtyEnable = false;
|
|
|
+ if(enable == "true"){
|
|
|
+ specialtyEnable = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Paper> papers = paperRepo.findBySpecialtyCodeAndOrgId(specialtyCode, orgId);
|
|
|
+ if (papers != null && papers.size() > 0) {
|
|
|
+ for (Paper paper : papers) {
|
|
|
+ Specialty specialty = paper.getSpecialty();
|
|
|
+ if(specialty != null){
|
|
|
+ specialty.setName(specialtyName);
|
|
|
+ specialty.setEnable(specialtyEnable);
|
|
|
+ specialty.setUpdateTime(new Date());
|
|
|
+ paper.setSpecialty(specialty);
|
|
|
+ }else{
|
|
|
+ Specialty tempSpecialty = new Specialty();
|
|
|
+ tempSpecialty.setCode(specialtyCode);
|
|
|
+ tempSpecialty.setCreateTime(new Date());
|
|
|
+ tempSpecialty.setEnable(specialtyEnable);
|
|
|
+ tempSpecialty.setOrgId(Long.valueOf(orgId));
|
|
|
+ tempSpecialty.setName(specialtyName);
|
|
|
+ paper.setSpecialty(tempSpecialty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ paperRepo.save(papers);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Question> questions = quesRepo.findBySpecialtyCodeAndOrgId(specialtyCode, orgId);
|
|
|
+ if (questions != null && questions.size() > 0) {
|
|
|
+ for (Question question : questions) {
|
|
|
+ Specialty specialty = question.getSpecialty();
|
|
|
+ if(specialty != null){
|
|
|
+ specialty.setName(specialtyName);
|
|
|
+ specialty.setEnable(specialtyEnable);
|
|
|
+ specialty.setUpdateTime(new Date());
|
|
|
+ question.setSpecialty(specialty);
|
|
|
+ }else{
|
|
|
+ Specialty tempSpecialty = new Specialty();
|
|
|
+ tempSpecialty.setCode(specialtyCode);
|
|
|
+ tempSpecialty.setCreateTime(new Date());
|
|
|
+ tempSpecialty.setEnable(specialtyEnable);
|
|
|
+ tempSpecialty.setOrgId(Long.valueOf(orgId));
|
|
|
+ tempSpecialty.setName(specialtyName);
|
|
|
+ question.setSpecialty(tempSpecialty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ quesRepo.save(questions);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("-----------coursesync end---------");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|