@@ -89,6 +89,11 @@ public class DingInfoPullController { | |||||
organizationBatchGetTask.organizationGetSubs(orgCode); | organizationBatchGetTask.organizationGetSubs(orgCode); | ||||
} | } | ||||
@GetMapping("/organization-sub/{orgCode}") | |||||
public void organizationSubGetOrgs(@PathVariable String orgCode) { | |||||
organizationBatchGetTask.organizationSubGetOrgs(orgCode); | |||||
} | |||||
@GetMapping("/employeeByRegionCode/{regionCode}") | @GetMapping("/employeeByRegionCode/{regionCode}") | ||||
public void employeeBatchGetByRegionCode(@PathVariable String regionCode) { | public void employeeBatchGetByRegionCode(@PathVariable String regionCode) { | ||||
employeeBatchGetTask.batchGetEmployeeTaskByRegionCode(regionCode); | employeeBatchGetTask.batchGetEmployeeTaskByRegionCode(regionCode); | ||||
@@ -223,8 +223,8 @@ public class EmployeeBatchGetTask { | |||||
String employeeCode = dingEmployeeInfo.getEmployeeCode(); | String employeeCode = dingEmployeeInfo.getEmployeeCode(); | ||||
DingEmployeeInfo employeeInfo = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | DingEmployeeInfo employeeInfo = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | ||||
.eq(DingEmployeeInfo::getEmpPosUnitCode, dingEmployeeInfo.getEmpPosUnitCode()) | |||||
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode)); | |||||
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode) | |||||
.last(BizConst.LIMIT_1)); | |||||
if (Objects.isNull(employeeInfo)) { | if (Objects.isNull(employeeInfo)) { | ||||
iDingEmployeeInfoService.save(dingEmployeeInfo); | iDingEmployeeInfoService.save(dingEmployeeInfo); | ||||
} else { | } else { | ||||
@@ -261,6 +261,12 @@ public class EmployeeBatchGetTask { | |||||
iUserInfoService.save(userInfo); | iUserInfoService.save(userInfo); | ||||
}else{ | }else{ | ||||
userInfo.setAvatar(dingEmployeeInfo.getAvatar()); | userInfo.setAvatar(dingEmployeeInfo.getAvatar()); | ||||
userInfo.setEmpPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode()); | |||||
if(StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())){ | |||||
DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode()); | |||||
userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); | |||||
userInfo.setRegionCode(dingOrganization.getDivisionCode()); | |||||
} | |||||
iUserInfoService.updateById(userInfo); | iUserInfoService.updateById(userInfo); | ||||
} | } | ||||
} | } | ||||
@@ -45,6 +45,9 @@ public class OrganizationBatchGetTask { | |||||
@Autowired | @Autowired | ||||
private IDingOrganizationService iDingOrganizationService; | private IDingOrganizationService iDingOrganizationService; | ||||
@Autowired | |||||
private EmployeeBatchGetTask employeeBatchGetTask; | |||||
/** | /** | ||||
* 获取浙政钉组织架构 | * 获取浙政钉组织架构 | ||||
*/ | */ | ||||
@@ -115,11 +118,16 @@ public class OrganizationBatchGetTask { | |||||
.eq(DingOrganization::getOrganizationCode, orgCode) | .eq(DingOrganization::getOrganizationCode, orgCode) | ||||
.last(BizConst.LIMIT_1)); | .last(BizConst.LIMIT_1)); | ||||
// 顶级组织code | // 顶级组织code | ||||
GenericResult<PageSubOrganizationCodeDTO> subOrganizationResult = zwddClient.pageSubOrganizationCodes(1, 10000, orgCode); | |||||
GenericResult<PageSubOrganizationCodeDTO> subOrganizationResult = zwddClient.pageSubOrganizationCodes(1, 100, orgCode); | |||||
log.info("subOrganizationResult: {}" + JSON.toJSONString(subOrganizationResult)); | log.info("subOrganizationResult: {}" + JSON.toJSONString(subOrganizationResult)); | ||||
PageSubOrganizationCodeDTO data = subOrganizationResult.getData(); | PageSubOrganizationCodeDTO data = subOrganizationResult.getData(); | ||||
List<String> subOrganizationCodeList = data.getSubOrganizationCodeList(); | List<String> subOrganizationCodeList = data.getSubOrganizationCodeList(); | ||||
if(Objects.isNull(subOrganizationCodeList)){ | |||||
log.info("subOrganizationCodeList为null"); | |||||
return; | |||||
} | |||||
for(String subOrganizationCode : subOrganizationCodeList){ | for(String subOrganizationCode : subOrganizationCodeList){ | ||||
GenericResult<DingOrgInfoDTO> organizationByCode = zwddClient.getOrganizationByCode(subOrganizationCode); | GenericResult<DingOrgInfoDTO> organizationByCode = zwddClient.getOrganizationByCode(subOrganizationCode); | ||||
DingOrgInfoDTO dingOrgInfo = organizationByCode.getData(); | DingOrgInfoDTO dingOrgInfo = organizationByCode.getData(); | ||||
@@ -128,6 +136,8 @@ public class OrganizationBatchGetTask { | |||||
.last(BizConst.LIMIT_1)); | .last(BizConst.LIMIT_1)); | ||||
if(Objects.nonNull(old)){ | if(Objects.nonNull(old)){ | ||||
log.info("该单位已经存在 :{}",old.getOrganizationName()); | log.info("该单位已经存在 :{}",old.getOrganizationName()); | ||||
organizationGetSubs(dingOrgInfo.getOrganizationCode()); | |||||
employeeBatchGetTask.batchGetEmployeeTaskByOrdCode(dingOrgInfo.getOrganizationCode()); | |||||
continue; | continue; | ||||
} | } | ||||
@@ -146,12 +156,36 @@ public class OrganizationBatchGetTask { | |||||
organization.setParentName(dingOrgInfo.getParentName()); | organization.setParentName(dingOrgInfo.getParentName()); | ||||
if(iDingOrganizationService.save(organization)){ | if(iDingOrganizationService.save(organization)){ | ||||
organizationGetSubs(organization.getOrganizationCode()); | organizationGetSubs(organization.getOrganizationCode()); | ||||
employeeBatchGetTask.batchGetEmployeeTaskByOrdCode(organization.getOrganizationCode()); | |||||
} | } | ||||
} | } | ||||
log.info("----拉取浙政钉组织子单位结束---,顶级code:" + orgCode); | log.info("----拉取浙政钉组织子单位结束---,顶级code:" + orgCode); | ||||
} | } | ||||
/** | |||||
* 查看下 当前的子单位信息 | |||||
* @param orgCode | |||||
*/ | |||||
public void organizationSubGetOrgs(String orgCode) { | |||||
// 顶级组织code | |||||
GenericResult<PageSubOrganizationCodeDTO> subOrganizationResult = zwddClient.pageSubOrganizationCodes(1, 100, orgCode); | |||||
log.info("subOrganizationResult: {}" + JSON.toJSONString(subOrganizationResult)); | |||||
PageSubOrganizationCodeDTO data = subOrganizationResult.getData(); | |||||
List<String> subOrganizationCodeList = data.getSubOrganizationCodeList(); | |||||
if(Objects.isNull(subOrganizationCodeList)){ | |||||
log.info("subOrganizationCodeList为null"); | |||||
return; | |||||
} | |||||
for(String subOrganizationCode : subOrganizationCodeList){ | |||||
GenericResult<DingOrgInfoDTO> organizationByCode = zwddClient.getOrganizationByCode(subOrganizationCode); | |||||
DingOrgInfoDTO dingOrgInfo = organizationByCode.getData(); | |||||
log.info("dingOrgInfo :{}",JSON.toJSONString(dingOrgInfo)); | |||||
} | |||||
} | |||||
private void buildSaveRecordList(List<DingOrgInfoTreeDTO> treeDTOList, List<DingOrganization> saveRecordList) { | private void buildSaveRecordList(List<DingOrgInfoTreeDTO> treeDTOList, List<DingOrganization> saveRecordList) { | ||||
if (CollectionUtils.isEmpty(treeDTOList)) { | if (CollectionUtils.isEmpty(treeDTOList)) { | ||||
return; | return; | ||||
@@ -216,7 +250,6 @@ public class OrganizationBatchGetTask { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -0,0 +1,75 @@ | |||||
package com.ningdatech.pmapi.employee; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.ningdatech.pmapi.AppTests; | |||||
import com.ningdatech.pmapi.common.constant.BizConst; | |||||
import com.ningdatech.pmapi.common.constant.RegionConst; | |||||
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | |||||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | |||||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||||
import org.junit.Test; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import java.time.LocalDateTime; | |||||
import java.util.List; | |||||
import java.util.Objects; | |||||
/** | |||||
* @Classname EmployeeTest | |||||
* @Description | |||||
* @Date 2023/9/6 14:34 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
public class EmployeeTest extends AppTests { | |||||
@Autowired | |||||
private IDingEmployeeInfoService dingEmployeeInfoService; | |||||
@Autowired | |||||
private IDingOrganizationService dingOrganizationService; | |||||
@Autowired | |||||
private IUserInfoService userInfoService; | |||||
@Test | |||||
public void test(){ | |||||
List<DingEmployeeInfo> employees = dingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||||
.eq(DingEmployeeInfo::getEmployeeName, "吴玉斌")); | |||||
for(DingEmployeeInfo employee : employees){ | |||||
UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) | |||||
.eq(UserInfo::getEmployeeCode, employee.getEmployeeCode()) | |||||
.last(BizConst.LIMIT_1)); | |||||
if(Objects.nonNull(user)){ | |||||
DingOrganization organization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.eq(DingOrganization::getOrganizationCode, employee.getOrganizationCode()) | |||||
.last(BizConst.LIMIT_1)); | |||||
user.setRegionCode(RegionConst.LS_KF); | |||||
user.setEmpPosUnitCode(employee.getEmpPosUnitCode()); | |||||
user.setEmpPosUnitName(organization.getOrganizationName()); | |||||
userInfoService.updateById(user); | |||||
}else{ | |||||
DingOrganization organization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||||
.eq(DingOrganization::getOrganizationCode, employee.getOrganizationCode()) | |||||
.last(BizConst.LIMIT_1)); | |||||
UserInfo saveUser = new UserInfo(); | |||||
saveUser.setRegionCode(RegionConst.LS_KF); | |||||
saveUser.setEmpPosUnitCode(employee.getEmpPosUnitCode()); | |||||
saveUser.setEmpPosUnitName(organization.getOrganizationName()); | |||||
saveUser.setCreateOn(LocalDateTime.now()); | |||||
saveUser.setUsername("吴玉斌"); | |||||
saveUser.setRealName("吴玉斌"); | |||||
saveUser.setUpdateOn(LocalDateTime.now()); | |||||
saveUser.setAccountId(employee.getAccountId()); | |||||
saveUser.setEmployeeCode(employee.getEmployeeCode()); | |||||
userInfoService.save(saveUser); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -13,9 +13,9 @@ spring: | |||||
namespace: "spring:session" | namespace: "spring:session" | ||||
redis: | redis: | ||||
timeout: 5000 | timeout: 5000 | ||||
host: 10.53.168.116 | |||||
port: 6379 | |||||
database: 0 | |||||
host: 47.98.125.47 | |||||
port: 26379 | |||||
database: 4 | |||||
password: Ndkj1234 | password: Ndkj1234 | ||||
jedis: | jedis: | ||||
pool: | pool: | ||||
@@ -1,3 +1,3 @@ | |||||
spring: | spring: | ||||
profiles: | profiles: | ||||
active: dev | |||||
active: prod |