Przeglądaj źródła

Merge branch 'master' of http://git.ningdatech.com/liushuai/project-management into 20230913_project_declared_new

master
PoffyZhang 1 rok temu
rodzic
commit
27c6661cd5
2 zmienionych plików z 80 dodań i 8 usunięć
  1. +6
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java
  2. +74
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java

+ 6
- 1
pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java Wyświetl plik

@@ -10,6 +10,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -62,6 +63,10 @@ public class IrsController {
@ApiOperation(value = "强制刷新核心业务", notes = "强制刷新核心业务")
@GetMapping("/refresh-core-biz")
public void refreshCoreBiz(@RequestParam(required = false) String orgCode) throws UnknownHostException {
projectCoreBizTask.doTask(orgCode);
if(StringUtils.isNotBlank(orgCode)){
projectCoreBizTask.doTask(orgCode);
}else{
projectCoreBizTask.doTask();
}
}
}

+ 74
- 7
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/SynProjectCoreBizTask.java Wyświetl plik

@@ -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);
}
});
}
}
}

/**
* 生成 编号


Ładowanie…
Anuluj
Zapisz