Browse Source

跑组织数据

tags/24080901
PoffyZhang 1 year ago
parent
commit
0410f65e70
5 changed files with 28 additions and 4 deletions
  1. +18
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/ding/task/GovBusinessStripsTask.java
  3. +3
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java
  4. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingEmployeeInfo.java
  5. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java

+ 18
- 2
pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java View File

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


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/ding/task/GovBusinessStripsTask.java View File

@@ -35,7 +35,7 @@ public class GovBusinessStripsTask {
private IGovBusinessStripService iGovBusinessStripService;

@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 1 * * ?")
// @Scheduled(cron = "0 0 1 * * ?")
public void batchGetGovBusinessStripsTask() {
PageSubGovBusinessStripsQuery pageSubGovBusinessStripsQuery = new PageSubGovBusinessStripsQuery();
pageSubGovBusinessStripsQuery.setPageNo(1);


+ 3
- 1
pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java View File

@@ -2,6 +2,7 @@
package com.ningdatech.pmapi.ding.task;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -46,7 +47,7 @@ public class OrganizationBatchGetTask {
* 获取浙政钉组织架构
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 1 * * ?")
// @Scheduled(cron = "0 0 1 * * ?")
public void batchGetOrganizationTask() {
// List<DingOrganization> allList = iDingOrganizationService.list();
// List<String> currentAllOrganizationCodeList = allList.stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toList());
@@ -62,6 +63,7 @@ public class OrganizationBatchGetTask {
log.info("顶级组织code: size = " + deptVisibleScopes.size() + "列表:" + JSONObject.toJSONString(deptVisibleScopes));
// 获取顶级节点信息
GenericResult<List<DingOrgInfoDTO>> listGenericResult = zwddClient.listOrganizationsByCodes(deptVisibleScopes);
log.info("listGenericResult: {}" + JSON.toJSONString(listGenericResult));
List<DingOrgInfoDTO> dingOrgInfoDtos = listGenericResult.getData();
for (String orgCode : deptVisibleScopes) {
// if (currentAllOrganizationCodeList.contains(orgCode)) {


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingEmployeeInfo.java View File

@@ -1,5 +1,7 @@
package com.ningdatech.pmapi.organization.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@@ -22,6 +24,7 @@ public class DingEmployeeInfo implements Serializable {

private static final long serialVersionUID = 1L;

@TableId(type = IdType.AUTO)
private Long id;

private LocalDateTime createOn;


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/entity/DingOrganization.java View File

@@ -1,5 +1,7 @@
package com.ningdatech.pmapi.organization.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@@ -22,6 +24,7 @@ public class DingOrganization implements Serializable {

private static final long serialVersionUID = 1L;

@TableId(type = IdType.AUTO)
private Long id;

private String institutionLevelCode;


Loading…
Cancel
Save