Conflicts: pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.javatags/24080901
@@ -24,6 +24,8 @@ public interface RegionConst { | |||
* 丽水行政区划编码 | |||
*/ | |||
String RC_LS = "331100"; | |||
String LS_KF = "331118"; | |||
String LS_KF_IRS = "331151"; | |||
String RC_LS_SBJ_IRS = "331101"; | |||
//遂昌县 | |||
String RC_SC = "331123"; | |||
@@ -89,6 +89,11 @@ public class DingInfoPullController { | |||
organizationBatchGetTask.organizationGetSubs(orgCode); | |||
} | |||
@GetMapping("/organization-sub/{orgCode}") | |||
public void organizationSubGetOrgs(@PathVariable String orgCode) { | |||
organizationBatchGetTask.organizationSubGetOrgs(orgCode); | |||
} | |||
@GetMapping("/employeeByRegionCode/{regionCode}") | |||
public void employeeBatchGetByRegionCode(@PathVariable String regionCode) { | |||
employeeBatchGetTask.batchGetEmployeeTaskByRegionCode(regionCode); | |||
@@ -223,8 +223,8 @@ public class EmployeeBatchGetTask { | |||
String employeeCode = dingEmployeeInfo.getEmployeeCode(); | |||
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)) { | |||
iDingEmployeeInfoService.save(dingEmployeeInfo); | |||
} else { | |||
@@ -261,6 +261,12 @@ public class EmployeeBatchGetTask { | |||
iUserInfoService.save(userInfo); | |||
}else{ | |||
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); | |||
} | |||
} | |||
@@ -45,6 +45,9 @@ public class OrganizationBatchGetTask { | |||
@Autowired | |||
private IDingOrganizationService iDingOrganizationService; | |||
@Autowired | |||
private EmployeeBatchGetTask employeeBatchGetTask; | |||
/** | |||
* 获取浙政钉组织架构 | |||
*/ | |||
@@ -115,17 +118,28 @@ public class OrganizationBatchGetTask { | |||
.eq(DingOrganization::getOrganizationCode, orgCode) | |||
.last(BizConst.LIMIT_1)); | |||
// 顶级组织code | |||
List<String> topOrgCodes = Lists.newArrayList(orgCode); | |||
GenericResult<List<DingOrgInfoDTO>> listGenericResult = zwddClient.listOrganizationsByCodes(topOrgCodes); | |||
log.info("listGenericResult: {}" + JSON.toJSONString(listGenericResult)); | |||
List<DingOrgInfoDTO> dingOrgInfoDtos = listGenericResult.getData(); | |||
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(DingOrgInfoDTO dingOrgInfo : dingOrgInfoDtos){ | |||
employeeBatchGetTask.batchGetEmployeeTaskByOrdCode(orgCode); | |||
for(String subOrganizationCode : subOrganizationCodeList){ | |||
GenericResult<DingOrgInfoDTO> organizationByCode = zwddClient.getOrganizationByCode(subOrganizationCode); | |||
DingOrgInfoDTO dingOrgInfo = organizationByCode.getData(); | |||
DingOrganization old = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getOrganizationCode, dingOrgInfo.getOrganizationCode()) | |||
.last(BizConst.LIMIT_1)); | |||
if(Objects.nonNull(old)){ | |||
log.info("该单位已经存在 :{}",old.getOrganizationName()); | |||
organizationGetSubs(dingOrgInfo.getOrganizationCode()); | |||
// employeeBatchGetTask.batchGetEmployeeTaskByOrdCode(dingOrgInfo.getOrganizationCode()); | |||
continue; | |||
} | |||
@@ -142,11 +156,36 @@ public class OrganizationBatchGetTask { | |||
organization.setGmtCreate(LocalDateTime.now()); | |||
organization.setInstitutionLevelCode(dingOrgInfo.getInstitutionLevelCode()); | |||
organization.setParentName(dingOrgInfo.getParentName()); | |||
iDingOrganizationService.save(organization); | |||
if(iDingOrganizationService.save(organization)){ | |||
organizationGetSubs(organization.getOrganizationCode()); | |||
// employeeBatchGetTask.batchGetEmployeeTaskByOrdCode(organization.getOrganizationCode()); | |||
} | |||
} | |||
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) { | |||
@@ -55,6 +55,9 @@ public class GovBizProjectBaseinfoDTO implements Serializable { | |||
@ApiModelProperty("上级主管单位钉id") | |||
private String baseProvManDeprtDing; | |||
@ApiModelProperty("是否省级 1省级 2非省级") | |||
private Integer baseProvManDeprtType; | |||
@ApiModelProperty("本级主管单位") | |||
private String baseManDeprt; | |||
@@ -57,6 +57,9 @@ public class GovBizProjectBaseinfo implements Serializable { | |||
@ApiModelProperty("信息是否有效") | |||
private String isEffective; | |||
@ApiModelProperty("是否省级 1省级 2非省级") | |||
private Integer baseProvManDeprtType; | |||
@ApiModelProperty("上级主管单位") | |||
private String baseProvManDeprt; | |||
@@ -51,6 +51,9 @@ public class GovBizProjectBaseinfoVO implements Serializable { | |||
@ApiModelProperty("信息是否有效") | |||
private String isEffective; | |||
@ApiModelProperty("是否省级 1省级 2非省级") | |||
private Integer baseProvManDeprtType; | |||
@ApiModelProperty("上级主管单位") | |||
private String baseProvManDeprt; | |||
@@ -235,10 +235,11 @@ public class AppIrsManage { | |||
"&appKey=" + searchAppKey + "&pageSize=1000&" + | |||
"pageNum=1&areaCode=" + areaCode + | |||
"&deptCode=&name="; | |||
log.info("查询应用目录:{}",url); | |||
RestTemplate restTemplate = new RestTemplate(); | |||
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class); | |||
log.info("查询应用目录 : {}", forEntity.getStatusCode()); | |||
log.info("查询应用目录 : {}", forEntity.getBody()); | |||
if (Objects.nonNull(forEntity.getBody())) { | |||
JSONObject body = JSON.parseObject(forEntity.getBody()); | |||
@@ -260,13 +261,15 @@ public class AppIrsManage { | |||
} | |||
/** | |||
* 如果是市本级的 结尾改成01 | |||
* 如果是市本级的 结尾改成01 还要转换开发区的code | |||
* @param areaCode | |||
* @return | |||
*/ | |||
private String convertAreaCode(String areaCode) { | |||
if(RegionConst.RC_LS.equals(areaCode)){ | |||
return RegionConst.RC_LS_SBJ_IRS; | |||
}else if(RegionConst.LS_KF.equals(areaCode)){ | |||
return RegionConst.LS_KF_IRS; | |||
} | |||
return areaCode; | |||
} | |||
@@ -109,7 +109,6 @@ public class PerformanceAppraisalPlanManage { | |||
if(CollUtil.isEmpty(page.getRecords())){ | |||
return PageVo.empty(); | |||
} | |||
List<Long> paIds = page.getRecords().stream().map(PerformanceAppraisal::getId).collect(Collectors.toList()); | |||
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) | |||
.in(PerformanceAppraisalProject::getAppraisalId, paIds)); | |||
@@ -0,0 +1,96 @@ | |||
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.ding.task.EmployeeBatchGetTask; | |||
import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask; | |||
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; | |||
@Autowired | |||
private OrganizationBatchGetTask organizationBatchGetTask; | |||
@Autowired | |||
private EmployeeBatchGetTask employeeBatchGetTask; | |||
@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); | |||
} | |||
} | |||
} | |||
@Test | |||
public void test2(){ | |||
String orgCode = "GO_4e6be07f25594df88e7bd1b7b7cdf9a8"; | |||
organizationBatchGetTask.organizationGetSubs(orgCode); | |||
} | |||
@Test | |||
public void test3(){ | |||
String orgCode = "GO_1aceac0b3a664afbb31ea0d627189781"; | |||
employeeBatchGetTask.batchGetEmployeeTaskByOrdCode(orgCode); | |||
} | |||
} |