|
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -76,15 +77,16 @@ public class SyncGraduateService {
|
|
|
/**
|
|
/**
|
|
|
* 全量同步研究生数据
|
|
* 全量同步研究生数据
|
|
|
*
|
|
*
|
|
|
|
|
+ * @param curYearIncrement 是否只同步当前年
|
|
|
* @return Boolean
|
|
* @return Boolean
|
|
|
*/
|
|
*/
|
|
|
- public Boolean syncGraduate() {
|
|
|
|
|
|
|
+ public Boolean syncGraduate(boolean curYearIncrement) {
|
|
|
HttpRequest req = CreateHttpRequest.createRequest();
|
|
HttpRequest req = CreateHttpRequest.createRequest();
|
|
|
req.body(getQueryBodyForGraduate());
|
|
req.body(getQueryBodyForGraduate());
|
|
|
|
|
|
|
|
try (HttpResponse res = req.execute()) {
|
|
try (HttpResponse res = req.execute()) {
|
|
|
SyncFullDataBo dataBo = JSONUtil.toBean(res.body(), SyncFullDataBo.class);
|
|
SyncFullDataBo dataBo = JSONUtil.toBean(res.body(), SyncFullDataBo.class);
|
|
|
- List<ResourcePerson> resourcePersonList = getResourcePeople(dataBo);
|
|
|
|
|
|
|
+ List<ResourcePerson> resourcePersonList = getResourcePeople(dataBo, curYearIncrement);
|
|
|
log.info("[全量获取到的研究生数据]-共[{}]条-[{}]", resourcePersonList.size(), JSONUtil.toJsonStr(dataBo));
|
|
log.info("[全量获取到的研究生数据]-共[{}]条-[{}]", resourcePersonList.size(), JSONUtil.toJsonStr(dataBo));
|
|
|
|
|
|
|
|
ISyncUserStrategy syncUserStrategy = SpringUtils.getBean(SyncResourceConstants.GRADUATE, ISyncUserStrategy.class);
|
|
ISyncUserStrategy syncUserStrategy = SpringUtils.getBean(SyncResourceConstants.GRADUATE, ISyncUserStrategy.class);
|
|
@@ -99,10 +101,11 @@ public class SyncGraduateService {
|
|
|
* 研究生数据预处理
|
|
* 研究生数据预处理
|
|
|
*
|
|
*
|
|
|
* @param dataBo 研究生数据
|
|
* @param dataBo 研究生数据
|
|
|
|
|
+ * @param curYearIncrement 是否只同步当前年
|
|
|
* @return 处理结果
|
|
* @return 处理结果
|
|
|
*/
|
|
*/
|
|
|
@NotNull
|
|
@NotNull
|
|
|
- private List<ResourcePerson> getResourcePeople(SyncFullDataBo dataBo) {
|
|
|
|
|
|
|
+ private List<ResourcePerson> getResourcePeople(SyncFullDataBo dataBo, boolean curYearIncrement) {
|
|
|
List<ResourcePerson> resourcePersonList = new ArrayList<>();
|
|
List<ResourcePerson> resourcePersonList = new ArrayList<>();
|
|
|
for (List<String> list : dataBo.getResponseParam().getResourceInfos().get(0).getDataInfo()) {
|
|
for (List<String> list : dataBo.getResponseParam().getResourceInfos().get(0).getDataInfo()) {
|
|
|
ResourcePerson person = new ResourcePerson();
|
|
ResourcePerson person = new ResourcePerson();
|
|
@@ -114,6 +117,24 @@ public class SyncGraduateService {
|
|
|
person.setIdNumber(list.get(4));
|
|
person.setIdNumber(list.get(4));
|
|
|
}
|
|
}
|
|
|
person.setDeptId(list.get(5));
|
|
person.setDeptId(list.get(5));
|
|
|
|
|
+ try {
|
|
|
|
|
+ //设置lifespan 默认10月1日
|
|
|
|
|
+ String s = list.get(7);
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(s)) {
|
|
|
|
|
+ String s1 = s.split("-")[0];
|
|
|
|
|
+ if(curYearIncrement){
|
|
|
|
|
+ int year = Integer.parseInt(s1);
|
|
|
|
|
+ int nowYear = Integer.parseInt(DateUtil.format(new Date(), "yyyy"));
|
|
|
|
|
+ if(year-nowYear<3){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ person.setLifespan(DateUtil.parse(s1+"-10-01", "yyyy-MM-dd"));
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("[同步研究生数据]-处理lifespan解析异常-[{}]", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
person.setCategory(DefaultConstants.CATEGORY_GRADUATE);
|
|
person.setCategory(DefaultConstants.CATEGORY_GRADUATE);
|
|
|
person.setPostCode(DefaultConstants.GRADUATE_CODE);
|
|
person.setPostCode(DefaultConstants.GRADUATE_CODE);
|
|
|
person.setOperatorId(DefaultConstants.FULL_SYNC_ADMIN);
|
|
person.setOperatorId(DefaultConstants.FULL_SYNC_ADMIN);
|