|
@@ -10,12 +10,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.api.HandleSyncCloudService;
|
|
import cn.com.qmth.examcloud.commons.api.HandleSyncCloudService;
|
|
import cn.com.qmth.examcloud.commons.api.request.SyncBaseRequest;
|
|
import cn.com.qmth.examcloud.commons.api.request.SyncBaseRequest;
|
|
-import cn.com.qmth.examcloud.commons.api.request.SyncCourseReq;
|
|
|
|
-import cn.com.qmth.examcloud.commons.api.request.SyncExamReq;
|
|
|
|
-import cn.com.qmth.examcloud.commons.api.request.SyncExamStudentReq;
|
|
|
|
-import cn.com.qmth.examcloud.commons.api.request.SyncOrgReq;
|
|
|
|
-import cn.com.qmth.examcloud.commons.api.request.SyncSpecialtyReq;
|
|
|
|
-import cn.com.qmth.examcloud.commons.api.request.SyncStudentReq;
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.util.JsonUtil;
|
|
import cn.com.qmth.examcloud.commons.base.util.JsonUtil;
|
|
import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
|
|
import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
|
|
@@ -40,14 +34,8 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
@Autowired
|
|
@Autowired
|
|
HandleSyncCloudService handleSyncCloudService;
|
|
HandleSyncCloudService handleSyncCloudService;
|
|
|
|
|
|
- /**
|
|
|
|
- * 方法注释
|
|
|
|
- *
|
|
|
|
- * @author WANGWEI
|
|
|
|
- * @param methodName
|
|
|
|
- * @param req
|
|
|
|
- */
|
|
|
|
- private void sync(String methodName, SyncBaseRequest req) {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean sync(String methodName, SyncBaseRequest req, Boolean retry) {
|
|
String group = PropertiesUtil.getString("$sync." + methodName + ".group");
|
|
String group = PropertiesUtil.getString("$sync." + methodName + ".group");
|
|
if (StringUtils.isBlank(group)) {
|
|
if (StringUtils.isBlank(group)) {
|
|
throw new StatusException("T-001001", "group is not configured");
|
|
throw new StatusException("T-001001", "group is not configured");
|
|
@@ -59,15 +47,29 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
throw new StatusException("T-001001", "no component");
|
|
throw new StatusException("T-001001", "no component");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ boolean successful = true;
|
|
for (String component : componentList) {
|
|
for (String component : componentList) {
|
|
- String url = PropertiesUtil
|
|
|
|
- .getString("$sync." + methodName + ".component." + component);
|
|
|
|
- req.setUrl(url);
|
|
|
|
- try {
|
|
|
|
- Method method = handleSyncCloudService.getClass().getMethod(methodName,
|
|
|
|
- req.getClass());
|
|
|
|
- method.invoke(handleSyncCloudService, req);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
|
+ boolean result = sync(component, methodName, req, retry);
|
|
|
|
+ if (!result) {
|
|
|
|
+ successful = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return successful;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean sync(String component, String methodName, SyncBaseRequest req, Boolean retry) {
|
|
|
|
+ String url = PropertiesUtil.getString("$sync." + methodName + ".component." + component);
|
|
|
|
+ req.setUrl(url);
|
|
|
|
+
|
|
|
|
+ boolean successful = false;
|
|
|
|
+ try {
|
|
|
|
+ Method method = handleSyncCloudService.getClass().getMethod(methodName, req.getClass());
|
|
|
|
+ method.invoke(handleSyncCloudService, req);
|
|
|
|
+ successful = true;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ if (retry) {
|
|
DataSyncEntity entity = new DataSyncEntity();
|
|
DataSyncEntity entity = new DataSyncEntity();
|
|
entity.setComponent(component);
|
|
entity.setComponent(component);
|
|
entity.setMethodName(methodName);
|
|
entity.setMethodName(methodName);
|
|
@@ -77,36 +79,8 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
dataSyncRepo.saveAndFlush(entity);
|
|
dataSyncRepo.saveAndFlush(entity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void syncCourse(SyncCourseReq req) {
|
|
|
|
- sync("syncCourse", req);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void syncOrg(SyncOrgReq req) {
|
|
|
|
- sync("syncOrg", req);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void syncStudent(SyncStudentReq req) {
|
|
|
|
- sync("syncStudent", req);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void syncExamStudent(SyncExamStudentReq req) {
|
|
|
|
- sync("syncExamStudent", req);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void syncSpecialty(SyncSpecialtyReq req) {
|
|
|
|
- sync("syncSpecialty", req);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public void syncExam(SyncExamReq req) {
|
|
|
|
- sync("syncExam", req);
|
|
|
|
|
|
+ return successful;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|