@@ -3,18 +3,24 @@ package com.ningdatech.pmapi.ding.task; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.ningdatech.basic.model.GenericResult; | |||
import com.ningdatech.pmapi.common.config.GovDingProperties; | |||
import com.ningdatech.pmapi.organization.entity.DingEmployeeInfo; | |||
import com.ningdatech.pmapi.organization.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import com.ningdatech.zwdd.client.ZwddClient; | |||
import com.ningdatech.zwdd.model.Page; | |||
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 org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @author liuxinxin | |||
@@ -26,17 +32,25 @@ public class EmployeeBatchGetTask { | |||
private final static Integer PAGE_SIZE = 20; | |||
private final static Integer GROUP_SIZE = 100; | |||
@Autowired | |||
private ZwddClient zwddClient; | |||
@Autowired | |||
private IDingOrganizationService iDingOrganizationService; | |||
@Autowired | |||
private IDingEmployeeInfoService iDingEmployeeInfoService; | |||
@Transactional(rollbackFor = Exception.class) | |||
public void batchGetEmployeeTask() { | |||
// 获取所有的组织列表 | |||
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(); | |||
if (CollUtil.isNotEmpty(dingOrganizationList)) { | |||
List<OrganizationEmployeePosition> allOrganizationEmployeePositionList = new ArrayList<>(); | |||
for (DingOrganization dingOrganization : dingOrganizationList) { | |||
List<OrganizationEmployeePosition> allOrganizationEmployeePositionList = new ArrayList<>(); | |||
String organizationCode = dingOrganization.getOrganizationCode(); | |||
PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); | |||
query.setEmployeeStatus("A"); | |||
@@ -65,13 +79,67 @@ public class EmployeeBatchGetTask { | |||
} | |||
} | |||
List<DingEmployeeInfo> dingEmployeeInfoList = new ArrayList<>(); | |||
if (allOrganizationEmployeePositionList.size() <= GROUP_SIZE) { | |||
List<String> employeeCodes = allOrganizationEmployeePositionList.stream().map(OrganizationEmployeePosition::getEmployeeCode).collect(Collectors.toList()); | |||
GenericResult<List<EmployeeAccountIdDTO>> listGenericResult = zwddClient.listEmployeeAccountIds(employeeCodes); | |||
// List<EmployeeAccountIdDTO> employeeAccountIdDTOList = listGenericResult.getData(); | |||
} else { | |||
// iDingEmployeeInfoService.saveBatch(); | |||
} | |||
// 批量保存用户信息 | |||
saveBatch(allOrganizationEmployeePositionList); | |||
} | |||
} | |||
} | |||
private List<DingEmployeeInfo> buildDingEmployeeInfoRecord(List<OrganizationEmployeePosition> allOrganizationEmployeePositionList) { | |||
List<DingEmployeeInfo> saveRecordList = new ArrayList<>(); | |||
for (OrganizationEmployeePosition organizationEmployeePosition : allOrganizationEmployeePositionList) { | |||
List<GovEmployeePosition> govEmployeePositions = organizationEmployeePosition.getGovEmployeePositions(); | |||
if (CollUtil.isNotEmpty(govEmployeePositions)) { | |||
List<DingEmployeeInfo> segmentSaveRecordList = new ArrayList<>(); | |||
for (GovEmployeePosition govEmployeePosition : govEmployeePositions) { | |||
DingEmployeeInfo dingEmployeeInfo = new DingEmployeeInfo(); | |||
BeanUtils.copyProperties(organizationEmployeePosition, dingEmployeeInfo); | |||
dingEmployeeInfo.setMainJob(govEmployeePosition.getMainJob()); | |||
dingEmployeeInfo.setEmpPosUnitCode(govEmployeePosition.getEmpPosUnitCode()); | |||
dingEmployeeInfo.setEmpPosEmployeeRoleCode(govEmployeePosition.getEmpPosEmployeeRoleCode()); | |||
dingEmployeeInfo.setEmpPosInnerInstitutionCode(govEmployeePosition.getEmpPosInnerInstitutionCode()); | |||
dingEmployeeInfo.setEmployeeCode(govEmployeePosition.getEmployeeCode()); | |||
dingEmployeeInfo.setJobAttributesCode(govEmployeePosition.getJobAttributesCode()); | |||
dingEmployeeInfo.setOrganizationCode(govEmployeePosition.getOrganizationCode()); | |||
dingEmployeeInfo.setEmpPosVirtualOrganizationCode(govEmployeePosition.getEmpPosVirtualOrganizationCode()); | |||
dingEmployeeInfo.setEmpStatus(govEmployeePosition.getStatus()); | |||
segmentSaveRecordList.add(dingEmployeeInfo); | |||
} | |||
saveRecordList.addAll(segmentSaveRecordList); | |||
} else { | |||
DingEmployeeInfo dingEmployeeInfo = new DingEmployeeInfo(); | |||
BeanUtils.copyProperties(organizationEmployeePosition, dingEmployeeInfo); | |||
saveRecordList.add(dingEmployeeInfo); | |||
} | |||
// zwddClient.pageOrganizationEmployeePositions(query); | |||
} | |||
return null; | |||
} | |||
private void saveBatch(List<OrganizationEmployeePosition> allOrganizationEmployeePositionList) { | |||
// // 批量保存 | |||
// 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); | |||
// } | |||
// } | |||
} | |||
} |
@@ -3,8 +3,10 @@ package com.ningdatech.pmapi.user.controller; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.pmapi.user.manage.UserInfoManage; | |||
import com.ningdatech.pmapi.user.model.po.ReqUserDetailEditPO; | |||
import com.ningdatech.pmapi.user.model.po.ReqUserDisablePO; | |||
import com.ningdatech.pmapi.user.model.po.ReqUserInfoListPO; | |||
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO; | |||
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
@@ -40,8 +42,21 @@ public class UserInfoController { | |||
@ApiOperation(value = "用户禁用", notes = "用户禁用") | |||
@PostMapping("/disable") | |||
public void disable(@Valid @RequestBody ReqUserDisablePO reqUserDisablePO){ | |||
public void disable(@Valid @RequestBody ReqUserDisablePO reqUserDisablePO) { | |||
userInfoManage.disable(reqUserDisablePO); | |||
} | |||
@ApiOperation(value = "用户详情", notes = "用户详情") | |||
@PostMapping("/detail") | |||
public ResUserDetailVO userInfoDetail(@Valid @RequestBody ReqUserInfoListPO reqUserInfoListPO) { | |||
return userInfoManage.userInfoDetail(reqUserInfoListPO); | |||
} | |||
@ApiOperation(value = "用户详情编辑", notes = "用户详情编辑") | |||
@PostMapping("/detail/edit") | |||
public void userInfoDetailEdit(@Valid @RequestBody ReqUserDetailEditPO reqUserDetailEditPO) { | |||
userInfoManage.userInfoDetailEdit(reqUserDetailEditPO); | |||
} | |||
} |
@@ -2,8 +2,10 @@ package com.ningdatech.pmapi.user.manage; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.pmapi.user.mapper.UserInfoMapper; | |||
import com.ningdatech.pmapi.user.model.po.ReqUserDetailEditPO; | |||
import com.ningdatech.pmapi.user.model.po.ReqUserDisablePO; | |||
import com.ningdatech.pmapi.user.model.po.ReqUserInfoListPO; | |||
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO; | |||
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.stereotype.Component; | |||
@@ -26,4 +28,12 @@ public class UserInfoManage { | |||
public void disable(ReqUserDisablePO reqUserDisablePO) { | |||
} | |||
public ResUserDetailVO userInfoDetail(ReqUserInfoListPO reqUserInfoListPO) { | |||
return null; | |||
} | |||
public void userInfoDetailEdit(ReqUserDetailEditPO reqUserDetailEditPO) { | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
package com.ningdatech.pmapi.user.model.base; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.Size; | |||
import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE; | |||
/** | |||
* @author liuxinxin | |||
* @date 2022/8/22 下午4:12 | |||
*/ | |||
@Data | |||
@ApiModel("用户角色信息") | |||
public class UserRoleInfo { | |||
@ApiModelProperty(value = "名称") | |||
private String name; | |||
@ApiModelProperty(value = "枚举code") | |||
private String code; | |||
@ApiModelProperty(value = "描述") | |||
@Size(max = 100, message = "描述长度不能超过100") | |||
@TableField(value = "describe", condition = LIKE) | |||
private String describe; | |||
@ApiModelProperty(value = "排序") | |||
private Integer roleSort; | |||
} |
@@ -0,0 +1,29 @@ | |||
package com.ningdatech.pmapi.user.model.po; | |||
import com.ningdatech.pmapi.user.model.base.UserRoleInfo; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
* @author liuxinxin | |||
* @date 2023/2/15 上午8:43 | |||
*/ | |||
@Data | |||
@ApiModel("获取用户详情编辑请求") | |||
public class ReqUserDetailEditPO { | |||
@ApiModelProperty("userId") | |||
private Long userId; | |||
@ApiModelProperty("手机号") | |||
private String phoneNo; | |||
@ApiModelProperty("状态 启用/禁用") | |||
private Boolean status; | |||
@ApiModelProperty("用户角色信息列表") | |||
private List<UserRoleInfo> userRoleInfoList; | |||
} |
@@ -0,0 +1,20 @@ | |||
package com.ningdatech.pmapi.user.model.po; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* @author liuxinxin | |||
* @date 2023/2/15 上午8:43 | |||
*/ | |||
@Data | |||
@ApiModel("获取用户详情请求") | |||
public class ReqUserDetailPO { | |||
@NotNull(message = "用户id 不能为空") | |||
@ApiModelProperty("用户id") | |||
private Long userId; | |||
} |
@@ -0,0 +1,29 @@ | |||
package com.ningdatech.pmapi.user.model.vo; | |||
import com.ningdatech.pmapi.user.model.base.UserRoleInfo; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
* @author liuxinxin | |||
* @date 2023/2/15 上午8:43 | |||
*/ | |||
@Data | |||
@ApiModel("获取用户详情请求") | |||
public class ResUserDetailVO { | |||
@ApiModelProperty("userId") | |||
private Long userId; | |||
@ApiModelProperty("手机号") | |||
private String phoneNo; | |||
@ApiModelProperty("状态 启用/禁用") | |||
private Boolean status; | |||
@ApiModelProperty("用户角色信息列表") | |||
private List<UserRoleInfo> userRoleInfoList; | |||
} |
@@ -1,6 +1,7 @@ | |||
package com.ningdatech.pmapi.organization; | |||
import com.ningdatech.pmapi.AppTests; | |||
import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask; | |||
import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask; | |||
import com.ningdatech.zwdd.client.ZwddAuthClient; | |||
import com.ningdatech.zwdd.client.ZwddClient; | |||
@@ -23,9 +24,17 @@ class OrganizationTest extends AppTests { | |||
@Autowired | |||
private OrganizationBatchGetTask organizationBatchGetTask; | |||
@Autowired | |||
private EmployeeBatchGetTask employeeBatchGetTask; | |||
@Test | |||
public void testBatchGetOrganization() { | |||
organizationBatchGetTask.batchGetOrganizationTask(); | |||
} | |||
@Test | |||
public void testEmployeeBatchGetTask(){ | |||
employeeBatchGetTask.batchGetEmployeeTask(); | |||
} | |||
} |