|
|
@@ -1,6 +1,7 @@ |
|
|
|
package com.ningdatech.pmapi.ding.task; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.google.common.collect.Lists; |
|
|
@@ -19,6 +20,7 @@ import com.ningdatech.zwdd.model.dto.EmployeeAccountIdDTO; |
|
|
|
import com.ningdatech.zwdd.model.query.PageOrganizationEmployeePositionsQuery; |
|
|
|
import com.ningdatech.zwdd.model.response.OrganizationEmployeePosition; |
|
|
|
import com.ningdatech.zwdd.model.response.OrganizationEmployeePosition.GovEmployeePosition; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
@@ -35,6 +37,7 @@ import java.util.stream.Collectors; |
|
|
|
*/ |
|
|
|
|
|
|
|
@Component |
|
|
|
@Slf4j |
|
|
|
public class EmployeeBatchGetTask { |
|
|
|
|
|
|
|
private final static Integer PAGE_SIZE = 20; |
|
|
@@ -57,12 +60,16 @@ public class EmployeeBatchGetTask { |
|
|
|
private IUserInfoService iUserInfoService; |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Scheduled(cron = "0 0 1 * * ?") |
|
|
|
// @Scheduled(cron = "0 0 1 * * ?") |
|
|
|
public void batchGetEmployeeTask() { |
|
|
|
// 获取所有的组织列表用户获取组织下的 用户信息 |
|
|
|
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(); |
|
|
|
if (CollUtil.isNotEmpty(dingOrganizationList)) { |
|
|
|
for (DingOrganization dingOrganization : dingOrganizationList) { |
|
|
|
if(!"GOV_UNIT".equals(dingOrganization.getTypeCode())){ |
|
|
|
log.info("不是单位的 跳过 :{}",dingOrganization.getTypeCode()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
List<OrganizationEmployeePosition> allOrganizationEmployeePositionList = new ArrayList<>(); |
|
|
|
String organizationCode = dingOrganization.getOrganizationCode(); |
|
|
|
PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); |
|
|
@@ -81,12 +88,19 @@ public class EmployeeBatchGetTask { |
|
|
|
allOrganizationEmployeePositionList.addAll(data.getData()); |
|
|
|
} |
|
|
|
Long totalSize = data.getTotalSize(); |
|
|
|
|
|
|
|
log.info("dingOrganization :{}", JSON.toJSONString(dingOrganization)); |
|
|
|
|
|
|
|
log.info("totalSize :{}", totalSize); |
|
|
|
if (totalSize > PAGE_SIZE) { |
|
|
|
int restPageNo = totalSize % PAGE_SIZE > 0 ? 1 : 0; |
|
|
|
int maxPageNo = (int) Math.ceil(totalSize / PAGE_SIZE) + restPageNo; |
|
|
|
for (pageNo = 2; pageNo <= maxPageNo; pageNo++) { |
|
|
|
query.setPageNo(maxPageNo); |
|
|
|
query.setPageNo(pageNo); |
|
|
|
log.info("PAGE_SIZE :{}", PAGE_SIZE); |
|
|
|
log.info("PAGE_NO :{}", pageNo); |
|
|
|
GenericResult<Page<OrganizationEmployeePosition>> pageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); |
|
|
|
// log.info("pageGenericResult :{}", JSON.toJSONString(pageGenericResult)); |
|
|
|
if (CollUtil.isNotEmpty(pageGenericResult.getData().getData())) { |
|
|
|
allOrganizationEmployeePositionList.addAll(pageGenericResult.getData().getData()); |
|
|
|
} |
|
|
@@ -96,8 +110,10 @@ public class EmployeeBatchGetTask { |
|
|
|
// 批量查询 成员的accountId |
|
|
|
List<DingEmployeeInfo> dingEmployeeInfoSaveRecordList = new ArrayList<>(); |
|
|
|
if (allOrganizationEmployeePositionList.size() <= GROUP_SIZE) { |
|
|
|
log.info("assemblerAccountId :{}", allOrganizationEmployeePositionList.size()); |
|
|
|
assemblerAccountId(allOrganizationEmployeePositionList, dingEmployeeInfoSaveRecordList); |
|
|
|
} else { |
|
|
|
log.info("assemblerAccountId :{}", allOrganizationEmployeePositionList.size()); |
|
|
|
List<List<OrganizationEmployeePosition>> split = Lists.partition(allOrganizationEmployeePositionList, GROUP_SIZE); |
|
|
|
for (List<OrganizationEmployeePosition> segment : split) { |
|
|
|
assemblerAccountId(segment, dingEmployeeInfoSaveRecordList); |
|
|
|