From 8e1c250d17b2415660f3840bba9fbdbd47688bfa Mon Sep 17 00:00:00 2001 From: liuxinxin Date: Wed, 15 Feb 2023 08:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AF=A6=E6=83=85=E7=BC=96?= =?UTF-8?q?=E8=BE=91=20=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/ding/task/EmployeeBatchGetTask.java | 74 +++++++++++++++++++++- .../pmapi/user/controller/UserInfoController.java | 17 ++++- .../pmapi/user/manage/UserInfoManage.java | 10 +++ .../pmapi/user/model/base/UserRoleInfo.java | 33 ++++++++++ .../pmapi/user/model/po/ReqUserDetailEditPO.java | 29 +++++++++ .../pmapi/user/model/po/ReqUserDetailPO.java | 20 ++++++ .../pmapi/user/model/vo/ResUserDetailVO.java | 29 +++++++++ .../pmapi/organization/OrganizationTest.java | 9 +++ 8 files changed, 217 insertions(+), 4 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/user/model/base/UserRoleInfo.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailEditPO.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailPO.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserDetailVO.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java index b5b3f89..f5365c9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/task/EmployeeBatchGetTask.java @@ -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 dingOrganizationList = iDingOrganizationService.list(); if (CollUtil.isNotEmpty(dingOrganizationList)) { - List allOrganizationEmployeePositionList = new ArrayList<>(); - for (DingOrganization dingOrganization : dingOrganizationList) { + List allOrganizationEmployeePositionList = new ArrayList<>(); String organizationCode = dingOrganization.getOrganizationCode(); PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); query.setEmployeeStatus("A"); @@ -65,13 +79,67 @@ public class EmployeeBatchGetTask { } } + List dingEmployeeInfoList = new ArrayList<>(); + if (allOrganizationEmployeePositionList.size() <= GROUP_SIZE) { + List employeeCodes = allOrganizationEmployeePositionList.stream().map(OrganizationEmployeePosition::getEmployeeCode).collect(Collectors.toList()); + GenericResult> listGenericResult = zwddClient.listEmployeeAccountIds(employeeCodes); +// List employeeAccountIdDTOList = listGenericResult.getData(); + } else { +// iDingEmployeeInfoService.saveBatch(); + } + // 批量保存用户信息 + saveBatch(allOrganizationEmployeePositionList); + } + + } + + + } + private List buildDingEmployeeInfoRecord(List allOrganizationEmployeePositionList) { + List saveRecordList = new ArrayList<>(); + for (OrganizationEmployeePosition organizationEmployeePosition : allOrganizationEmployeePositionList) { + List govEmployeePositions = organizationEmployeePosition.getGovEmployeePositions(); + if (CollUtil.isNotEmpty(govEmployeePositions)) { + List 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 allOrganizationEmployeePositionList) { + +// // 批量保存 +// if (saveRecordList.size() <= GROUP_SIZE) { +// iDingOrganizationService.saveBatch(saveRecordList); +// } else { +// List> split = Lists.partition(saveRecordList, GROUP_SIZE); +// for (List segment : split) { +// iDingOrganizationService.saveBatch(segment); +// } +// } } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java index 8e2ae4c..9c80c1e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java @@ -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); + } + + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java index 39d3812..ffcf71a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java @@ -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) { + + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/model/base/UserRoleInfo.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/base/UserRoleInfo.java new file mode 100644 index 0000000..e5450dc --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/base/UserRoleInfo.java @@ -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; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailEditPO.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailEditPO.java new file mode 100644 index 0000000..cc35679 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailEditPO.java @@ -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 userRoleInfoList; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailPO.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailPO.java new file mode 100644 index 0000000..c162e0b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailPO.java @@ -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; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserDetailVO.java new file mode 100644 index 0000000..e040015 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserDetailVO.java @@ -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 userRoleInfoList; +} diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java index 0fd3585..9a0fd88 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/organization/OrganizationTest.java @@ -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(); + } + }