wangwei 5 years ago
parent
commit
8205e38f25

+ 7 - 1
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/SyncCloudServiceProvider.java

@@ -16,6 +16,9 @@ import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import com.google.common.collect.Lists;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -62,7 +65,10 @@ public class SyncCloudServiceProvider  extends ControllerSupport implements Hand
     		}
     	}else if("update".equals(req.getSyncType())){
 	        ExamStudentInfo examStudent = ExamStudentBeanConvert.of(req);
-	        examStudentService.syncExamStudentAllData(Lists.newArrayList(examStudent));
+	        List<Long> examStudentIdList = examStudentService.saveExamStudentList(Lists.newArrayList(examStudent));
+	        for (Long cur : examStudentIdList) {
+	        	examStudentCache.refresh(cur);
+			}
     	}
     	
     	SyncExamStudentResp resp = new SyncExamStudentResp();

+ 2 - 2
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamStudentService.java

@@ -28,12 +28,12 @@ import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentQ
 public interface ExamStudentService {
 
     /**
-     * 同步考生(全部)数据
+     * 保存考生数据
      *
      * @param examStudents
      * @return
      */
-    void syncExamStudentAllData(List<ExamStudentInfo> examStudents);
+	List<Long> saveExamStudentList(List<ExamStudentInfo> examStudents);
 
     /**
      * 同步考生(部分)数据

+ 3 - 6
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamStudentServiceImpl.java

@@ -94,14 +94,13 @@ public class ExamStudentServiceImpl implements ExamStudentService {
     @Autowired
     private LocalCacheService localCacheService;
     @Autowired
-    private ExamStudentCache examStudentCache;
-    @Autowired
     private ExamCloudService examCloudService;
     @Autowired
     private RedisClient redisClient;
     
+    @Transactional
     @Override
-    public void syncExamStudentAllData(List<ExamStudentInfo> examStudents) {
+    public List<Long> saveExamStudentList(List<ExamStudentInfo> examStudents) {
         Check.isEmpty(examStudents, "考生信息不能为空!");
 		List<Long> examStudentIdList = Lists.newArrayList();
         //封装并校验数据
@@ -155,9 +154,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
             }
         }
         
-        for (Long cur : examStudentIdList) {
-        	examStudentCache.remove(cur);
-		}
+        return examStudentIdList;
     }
 
     @Override