|
|
@@ -29,7 +29,9 @@ import java.net.InetAddress; |
|
|
|
import java.net.UnknownHostException; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author ZPF |
|
|
@@ -58,9 +60,11 @@ public class SynProjectCoreBizTask { |
|
|
|
@Autowired |
|
|
|
private ProjectIrsManage projectIrsManage; |
|
|
|
|
|
|
|
private final Integer MAX_PAGE_SIZE = 1000; |
|
|
|
|
|
|
|
/** |
|
|
|
* 前置机每天晚上10点自动清空,第二天早上6点获取数据 |
|
|
|
* 定时同步前置机数据 每天1点开始执行一次 |
|
|
|
* 定时同步前置机数据 每天1点开始执行一次 不按照单位 |
|
|
|
* |
|
|
|
*/ |
|
|
|
@Scheduled(cron = "0 0 2 * * ?") |
|
|
@@ -75,12 +79,7 @@ public class SynProjectCoreBizTask { |
|
|
|
StopWatch stopWatch = new StopWatch(); |
|
|
|
stopWatch.start(); |
|
|
|
|
|
|
|
List<DingOrganization> orgs = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
.in(DingOrganization::getTypeCode, Lists.newArrayList(DingOrganizationContant.UNIT_TYPE |
|
|
|
, DingOrganizationContant.GOV_TEMPORARY))); |
|
|
|
log.info("总共需要同步 orgs size :{}",orgs.size()); |
|
|
|
|
|
|
|
syncCoreBiz(orgs); |
|
|
|
syncCoreBiz(); |
|
|
|
stopWatch.stop(); |
|
|
|
log.info("同步项目核心业务结束====={}s",stopWatch.getTotalTimeSeconds()); |
|
|
|
} |
|
|
@@ -158,6 +157,74 @@ public class SynProjectCoreBizTask { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void syncCoreBiz() { |
|
|
|
Map<String,DingOrganization> map = organizationService.list().stream().distinct().collect(Collectors.toMap(DingOrganization::getOrganizationCode, o -> o)); |
|
|
|
|
|
|
|
Integer currentSize = MAX_PAGE_SIZE; |
|
|
|
Integer page = 1; |
|
|
|
while (currentSize.equals(MAX_PAGE_SIZE)) { |
|
|
|
//去请求IRS接口 |
|
|
|
JSONObject jsonObject = projectIrsManage.searchCoreBiz(null, null, MAX_PAGE_SIZE, page); |
|
|
|
|
|
|
|
JSONArray jsonArray = jsonObject.getJSONArray(BizConst.RESPONSE_KEY_DATA); |
|
|
|
currentSize = jsonArray.size(); |
|
|
|
if (CollUtil.isNotEmpty(jsonArray)) { |
|
|
|
if (currentSize.equals(MAX_PAGE_SIZE)) { |
|
|
|
page++; |
|
|
|
} |
|
|
|
jsonArray.forEach(j -> { |
|
|
|
JSONObject jsonData = JSON.parseObject(JSON.toJSONString(j)); |
|
|
|
ProjectCoreBiz coreBiz = new ProjectCoreBiz(); |
|
|
|
// |
|
|
|
Long irsId = jsonData.getLong(BizConst.RESPONSE_KEY_ID); |
|
|
|
String dingCode = jsonData.getString(BizConst.RESPONSE_KEY_DING_CODE); |
|
|
|
String matterName = jsonData.getString(BizConst.RESPONSE_KEY_MATTER_NAME); |
|
|
|
String orgName = jsonData.getString(BizConst.RESPONSE_KEY_ORG_NAME); |
|
|
|
String userState = jsonData.getString(BizConst.RESPONSE_KEY_USER_STATE); |
|
|
|
String areaName = jsonData.getString(BizConst.RESPONSE_KEY_AREA_NAME); |
|
|
|
ProjectCoreBiz old = projectCoreBizService.getOne(Wrappers.lambdaQuery(ProjectCoreBiz.class) |
|
|
|
.eq(ProjectCoreBiz::getIrsId, irsId) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
|
|
|
|
if (Objects.nonNull(old)) { |
|
|
|
coreBiz.setId(old.getId()); |
|
|
|
} else { |
|
|
|
coreBiz.setCreateOn(LocalDateTime.now()); |
|
|
|
} |
|
|
|
|
|
|
|
if(map.containsKey(dingCode)){ |
|
|
|
DingOrganization organization = map.get(dingCode); |
|
|
|
|
|
|
|
String unifiedSocialCreditCode = organization.getUnifiedSocialCreditCode(); |
|
|
|
if(StringUtils.isBlank(unifiedSocialCreditCode)){ |
|
|
|
GenericResult<DingOrgInfoDTO> dingResult = zwddClient.getOrganizationByCode(organization.getOrganizationCode()); |
|
|
|
|
|
|
|
log.info("ding org result : {}",JSON.toJSONString(dingResult)); |
|
|
|
|
|
|
|
if(dingResult.isSuccess()){ |
|
|
|
DingOrgInfoDTO data = dingResult.getData(); |
|
|
|
unifiedSocialCreditCode = data.getUnifiedSocialCreditCode(); |
|
|
|
organization.setUnifiedSocialCreditCode(unifiedSocialCreditCode); |
|
|
|
organizationService.updateById(organization); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
coreBiz.setUpdateOn(LocalDateTime.now()); |
|
|
|
coreBiz.setIrsId(irsId); |
|
|
|
coreBiz.setMatterName(matterName); |
|
|
|
coreBiz.setOrgCode(dingCode); |
|
|
|
coreBiz.setOrgName(orgName); |
|
|
|
coreBiz.setUserState(userState); |
|
|
|
coreBiz.setAreaName(areaName); |
|
|
|
coreBiz.setMatterCode(irsId.toString()); |
|
|
|
projectCoreBizService.saveOrUpdate(coreBiz); |
|
|
|
coreBiz.setMatterCode(genirate(unifiedSocialCreditCode, coreBiz.getId())); |
|
|
|
projectCoreBizService.updateById(coreBiz); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成 编号 |
|
|
|