Browse Source

浙政钉组织架构

master
liuxinxin 1 year ago
parent
commit
ad3c224ce5
8 changed files with 411 additions and 1 deletions
  1. +1
    -1
      ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java
  2. +154
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java
  3. +20
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java
  4. +179
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/entity/DingOrganization.java
  5. +16
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/mapper/DingOrganizationMapper.java
  6. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/mapper/DingOrganizationMapper.xml
  7. +16
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/service/IDingOrganizationService.java
  8. +20
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/service/impl/DingOrganizationServiceImpl.java

+ 1
- 1
ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java View File

@@ -56,7 +56,7 @@ public class GeneratorCodeKingbaseConfig {
}

public static void main(String[] args) {
generate("WendyYang", "projectlib", PATH_YYD, "nd_project_application");
generate("Lierbao", "organization", PATH_LXX, "ding_organization");
}

}

+ 154
- 0
pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java View File

@@ -0,0 +1,154 @@
//package com.ningdatech.pmapi.ding.task;
//
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
//import com.google.common.collect.Lists;
//import com.ningdatech.basic.model.GenericResult;
//import com.ningdatech.zwdd.client.ZwddAuthClient;
//import com.ningdatech.zwdd.client.ZwddClient;
//import com.ningdatech.zwdd.model.dto.DingOrgInfoDTO;
//import com.ningdatech.zwdd.model.dto.DingScopesV2DTO;
//import com.ningdatech.zwdd.model.dto.PageSubOrganizationCodeDTO;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
///**
// * @author liuxinxin
// * @date 2023/2/7 上午10:15
// */
//
//@Component
//public class OrganizationBatchGetTask {
//
// @Autowired
// private ZwddClient zwddClient;
//
// @Autowired
// private ZwddAuthClient zwddAuthClient;
//
// public OrganizationBatchGetTask() {
// // 获取通讯录权限范围 获取顶级组织code
// GenericResult<DingScopesV2DTO> scopesV2Result = zwddClient.getScopesV2();
// DingScopesV2DTO data = scopesV2Result.getData();
//
// if (Objects.nonNull(data)) {
//
// }
//
//// // 根据组织code查询详情获取部门信息
//// List<String> deptVisibleScopes = data.getDeptVisibleScopes();
//// for (String deptVisibleScope : deptVisibleScopes) {
//// GenericResult<DingOrgInfoDTO> organizationByCodeResult = zwddClient.getOrganizationByCode(deptVisibleScope);
//// DingOrgInfoDTO dingOrgInfoDTO = organizationByCodeResult.getData();
////// dingOrgInfoDTO
//// }
// List<String> currentAllOrganizationCodeList = new ArrayList<>();
//
//
// List<String> deptVisibleScopes = data.getDeptVisibleScopes();
// for (String orgCode : deptVisibleScopes) {
// if (currentAllOrganizationCodeList.contains(orgCode)) {
//// log.info("已存在组织架构---{}", orgCode);
// continue;
// }
// List<DingOrgInfoTreeDTO> treeDTOList = new ArrayList<>();
//
// DingOrgInfoTreeDTO childDingOrgInfoTreeDTO = new DingOrgInfoTreeDTO();
// //设置节点详情
// if (dingOrgInfoDtos != null && !dingOrgInfoDtos.isEmpty()) {
// for (DingOrgInfoDTO orgInfo : dingOrgInfoDtos) {
// if (orgInfo.getOrganizationCode().equals(orgCode)) {
// childDingOrgInfoTreeDTO.setDingOrgInfoDTO(orgInfo);
// }
// }
// }
// childDingOrgInfoTreeDTO.setCode(orgCode);
// childDingOrgInfoTreeDTO.setChildCodes(new ArrayList<>());
// getDingOrgChild(childDingOrgInfoTreeDTO);
// treeDTOList.add(childDingOrgInfoTreeDTO);
//
// if (CollectionUtils.isNotEmpty(treeDTOList)) {
// List<DingOrganization> saveRecordList = new ArrayList<>();
// buildSaveRecordList(treeDTOList, saveRecordList);
//
// // 批量保存
// if (saveRecordList.size() <= GROUP_SIZE) {
// iDingOrganizationService.saveBatch(saveRecordList);
// } else {
// List<List<DingOrganization>> split = Lists.partition(saveRecordList, GROUP_SIZE);
// for (List<DingOrganization> segment : split) {
// iDingOrganizationService.saveBatch(segment);
// }
// }
// }
// log.info("----拉取浙政钉组织结构结束---,顶级code:" + orgCode);
// }
// }
//
//
// private void getDingOrgChild(DingOrgInfoTreeDTO parentDingOrgInfoTreeDTO) {
// String parentOrgCode = parentDingOrgInfoTreeDTO.getCode();
// DingOrgInfoDTO orgInfoDTO = parentDingOrgInfoTreeDTO.getDingOrgInfoDTO();
// boolean leaf = orgInfoDTO.getLeaf();
// if (!leaf) {
// int currentPage = 1;
// int pageSize = 100;
// PageSubOrganizationCodeDTO pageSubOrganizationCodeDTO =
// dingApiClient.pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode);
// List<String> subOrganizationCodeList = new ArrayList<>(pageSubOrganizationCodeDTO.getSubOrganizationCodeList());
// Long totalSize = pageSubOrganizationCodeDTO.getTotalSize();
//
// while (totalSize > (long) currentPage * pageSize) {
// PageSubOrganizationCodeDTO subOrganizationCodeDTO = dingApiClient
// .pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode);
// if (CollectionUtils.isNotEmpty(subOrganizationCodeDTO.getSubOrganizationCodeList())) {
// subOrganizationCodeList.addAll(subOrganizationCodeDTO.getSubOrganizationCodeList());
// }
// }
//
// if (CollectionUtils.isNotEmpty(subOrganizationCodeList)) {
// List<DingOrgInfoDTO> dingOrgInfoDtos = dingApiClient
// .listOrganizationsByCodes(subOrganizationCodeList);
// List<DingOrgInfoTreeDTO> dingOrgInfoTreeDTOList = dingOrgInfoDtos.stream().map(r -> {
// DingOrgInfoTreeDTO dingOrgInfoTreeDTO = new DingOrgInfoTreeDTO();
// dingOrgInfoTreeDTO.setCode(r.getOrganizationCode());
// dingOrgInfoTreeDTO.setDingOrgInfoDTO(r);
// dingOrgInfoTreeDTO.setChildCodes(new ArrayList<>());
// getDingOrgChild(dingOrgInfoTreeDTO);
// return dingOrgInfoTreeDTO;
// }).collect(Collectors.toList());
// parentDingOrgInfoTreeDTO.setChildCodes(dingOrgInfoTreeDTOList);
// }
//
// }
// }
//
//
// private void buildSaveRecordList(List<DingOrgInfoTreeDTO> treeDTOList, List<DingOrganization> saveRecordList) {
// if (CollectionUtils.isEmpty(treeDTOList)) {
// return;
// }
// for (DingOrgInfoTreeDTO dingOrgInfoTreeDTO : treeDTOList) {
// DingOrganization saveRecord = new DingOrganization();
// DingOrgInfoDTO dingOrgInfoDTO = dingOrgInfoTreeDTO.getDingOrgInfoDTO();
// List<DingOrgInfoTreeDTO> childCodes = dingOrgInfoTreeDTO.getChildCodes();
// saveRecord.setDeptSort(dingOrgInfoDTO.getDisplayOrder());
// saveRecord.setEnabled("1");
// saveRecord.setParentCode(dingOrgInfoDTO.getParentCode());
// saveRecord.setOrganizationCode(dingOrgInfoDTO.getOrganizationCode());
// saveRecord.setSubCount((long) dingOrgInfoTreeDTO.getChildCodes().size());
// saveRecord.setName(dingOrgInfoDTO.getOrganizationName());
// saveRecordList.add(saveRecord);
// if (CollectionUtils.isNotEmpty(childCodes)) {
// buildSaveRecordList(childCodes, saveRecordList);
// }
// }
//
// }
//
//
//}

+ 20
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/controller/DingOrganizationController.java View File

@@ -0,0 +1,20 @@
package com.ningdatech.pmapi.organization.controller;


import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

/**
* <p>
* 前端控制器
* </p>
*
* @author Lierbao
* @since 2023-02-09
*/
@Controller
@RequestMapping("/pmapi.organization/ding-organization")
public class DingOrganizationController {

}

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

@@ -0,0 +1,179 @@
package com.ningdatech.pmapi.organization.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
* <p>
*
* </p>
*
* @author Lierbao
* @since 2023-02-09
*/
@TableName("ding_organization")
@ApiModel(value = "DingOrganization对象", description = "")
public class DingOrganization implements Serializable {

private static final long serialVersionUID = 1L;

private Long id;

private String institutionLevelCode;

private String address;

private String organizationName;

private Long displayOrder;

private Long typeName;

private Integer leaf;

private LocalDateTime gmtCreate;

private String typeCode;

private String divisionCode;

private String parentName;

private String parentCode;

private String organizationCode;

private String businessStripCodes;

private String status;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}
public String getInstitutionLevelCode() {
return institutionLevelCode;
}

public void setInstitutionLevelCode(String institutionLevelCode) {
this.institutionLevelCode = institutionLevelCode;
}
public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}
public String getOrganizationName() {
return organizationName;
}

public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
public Long getDisplayOrder() {
return displayOrder;
}

public void setDisplayOrder(Long displayOrder) {
this.displayOrder = displayOrder;
}
public Long getTypeName() {
return typeName;
}

public void setTypeName(Long typeName) {
this.typeName = typeName;
}
public Integer getLeaf() {
return leaf;
}

public void setLeaf(Integer leaf) {
this.leaf = leaf;
}
public LocalDateTime getGmtCreate() {
return gmtCreate;
}

public void setGmtCreate(LocalDateTime gmtCreate) {
this.gmtCreate = gmtCreate;
}
public String getTypeCode() {
return typeCode;
}

public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
public String getDivisionCode() {
return divisionCode;
}

public void setDivisionCode(String divisionCode) {
this.divisionCode = divisionCode;
}
public String getParentName() {
return parentName;
}

public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getParentCode() {
return parentCode;
}

public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getOrganizationCode() {
return organizationCode;
}

public void setOrganizationCode(String organizationCode) {
this.organizationCode = organizationCode;
}
public String getBusinessStripCodes() {
return businessStripCodes;
}

public void setBusinessStripCodes(String businessStripCodes) {
this.businessStripCodes = businessStripCodes;
}
public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

@Override
public String toString() {
return "DingOrganization{" +
"id=" + id +
", institutionLevelCode=" + institutionLevelCode +
", address=" + address +
", organizationName=" + organizationName +
", displayOrder=" + displayOrder +
", typeName=" + typeName +
", leaf=" + leaf +
", gmtCreate=" + gmtCreate +
", typeCode=" + typeCode +
", divisionCode=" + divisionCode +
", parentName=" + parentName +
", parentCode=" + parentCode +
", organizationCode=" + organizationCode +
", businessStripCodes=" + businessStripCodes +
", status=" + status +
"}";
}
}

+ 16
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/mapper/DingOrganizationMapper.java View File

@@ -0,0 +1,16 @@
package com.ningdatech.pmapi.organization.mapper;

import com.ningdatech.pmapi.organization.entity.DingOrganization;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
* <p>
* Mapper 接口
* </p>
*
* @author Lierbao
* @since 2023-02-09
*/
public interface DingOrganizationMapper extends BaseMapper<DingOrganization> {

}

+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/mapper/DingOrganizationMapper.xml View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ningdatech.pmapi.organization.mapper.DingOrganizationMapper">

</mapper>

+ 16
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/service/IDingOrganizationService.java View File

@@ -0,0 +1,16 @@
package com.ningdatech.pmapi.organization.service;

import com.ningdatech.pmapi.organization.entity.DingOrganization;
import com.baomidou.mybatisplus.extension.service.IService;

/**
* <p>
* 服务类
* </p>
*
* @author Lierbao
* @since 2023-02-09
*/
public interface IDingOrganizationService extends IService<DingOrganization> {

}

+ 20
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/service/impl/DingOrganizationServiceImpl.java View File

@@ -0,0 +1,20 @@
package com.ningdatech.pmapi.organization.service.impl;

import com.ningdatech.pmapi.organization.entity.DingOrganization;
import com.ningdatech.pmapi.organization.mapper.DingOrganizationMapper;
import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
* <p>
* 服务实现类
* </p>
*
* @author Lierbao
* @since 2023-02-09
*/
@Service
public class DingOrganizationServiceImpl extends ServiceImpl<DingOrganizationMapper, DingOrganization> implements IDingOrganizationService {

}

Loading…
Cancel
Save