|
|
@@ -5,7 +5,9 @@ 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; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.model.GenericResult; |
|
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; |
|
|
|
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; |
|
|
|
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; |
|
|
@@ -335,13 +337,76 @@ public class EmployeeBatchGetTask { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// if (saveList.size() <= GROUP_SIZE) { |
|
|
|
// iDingEmployeeInfoService.saveBatch(saveList); |
|
|
|
// } else { |
|
|
|
// List<List<DingEmployeeInfo>> split = Lists.partition(saveList, GROUP_SIZE); |
|
|
|
// for (List<DingEmployeeInfo> segment : split) { |
|
|
|
// iDingEmployeeInfoService.saveBatch(segment); |
|
|
|
// } |
|
|
|
// } |
|
|
|
public void batchGetEmployeeTaskByOrdCode(String orgCode) { |
|
|
|
DingOrganization org = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
.eq(DingOrganization::getOrganizationCode, orgCode) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
VUtils.isTrue(Objects.isNull(org)).throwMessage("单位不存在"); |
|
|
|
log.info("所属单位 {} 要更新员工信息了",org.getOrganizationName()); |
|
|
|
|
|
|
|
List<OrganizationEmployeePosition> allOrganizationEmployeePositionList = new ArrayList<>(); |
|
|
|
String organizationCode = orgCode; |
|
|
|
PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); |
|
|
|
query.setEmployeeStatus("A"); |
|
|
|
query.setOrganizationCode(organizationCode); |
|
|
|
query.setReturnTotalSize(true); |
|
|
|
query.setTenantId(zwddIntegrationProperties.getTenantId()); |
|
|
|
int pageNo = 1; |
|
|
|
query.setPageNo(pageNo); |
|
|
|
query.setPageSize(PAGE_SIZE); |
|
|
|
|
|
|
|
// 查询组织下 用户信息 |
|
|
|
GenericResult<Page<OrganizationEmployeePosition>> firstPageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); |
|
|
|
Page<OrganizationEmployeePosition> data = firstPageGenericResult.getData(); |
|
|
|
if (Objects.isNull(data)){ |
|
|
|
log.info("响应为空:{}",organizationCode); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (CollUtil.isNotEmpty(data.getData())) { |
|
|
|
allOrganizationEmployeePositionList.addAll(data.getData()); |
|
|
|
} |
|
|
|
Long totalSize = data.getTotalSize(); |
|
|
|
|
|
|
|
log.info("dingOrganization :{}", JSON.toJSONString(org)); |
|
|
|
|
|
|
|
log.info("totalSize :{},{}", totalSize,org.getOrganizationName()); |
|
|
|
if (totalSize > PAGE_SIZE) { |
|
|
|
if (totalSize > MAX_SIZE) { |
|
|
|
//超过1万 按1万的处理 |
|
|
|
totalSize = MAX_SIZE.longValue(); |
|
|
|
} |
|
|
|
|
|
|
|
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(pageNo); |
|
|
|
GenericResult<Page<OrganizationEmployeePosition>> pageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); |
|
|
|
// log.info("pageGenericResult :{}", JSON.toJSONString(pageGenericResult)); |
|
|
|
if(pageGenericResult.isSuccess()){ |
|
|
|
allOrganizationEmployeePositionList.addAll(pageGenericResult.getData().getData()); |
|
|
|
}else{ |
|
|
|
log.error(pageGenericResult.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 批量查询 成员的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); |
|
|
|
} |
|
|
|
} |
|
|
|
// 批量保存用户信息 |
|
|
|
saveBatch(dingEmployeeInfoSaveRecordList); |
|
|
|
|
|
|
|
log.info("员工同步完成"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |