From bdde1639d3df9dad1e8c1a7088e73a27ed135707 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Thu, 15 Jun 2023 17:16:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90portal=E3=80=91=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=81=8C=E5=8A=A1=E4=BF=A1=E6=81=AF=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../position/service/HrPositionService.java | 9 +++ .../service/impl/HrPositionServiceImpl.java | 59 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/system/modular/position/service/HrPositionService.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/system/modular/position/service/HrPositionService.java index 52e187fec..a5c12abb0 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/system/modular/position/service/HrPositionService.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/system/modular/position/service/HrPositionService.java @@ -26,6 +26,7 @@ package cn.stylefeng.roses.kernel.system.modular.position.service; import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; import cn.stylefeng.roses.kernel.system.api.PositionServiceApi; +import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationDTO; import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionRequest; import cn.stylefeng.roses.kernel.system.modular.position.entity.HrPosition; import com.baomidou.mybatisplus.extension.service.IService; @@ -115,4 +116,12 @@ public interface HrPositionService extends IService, PositionService */ void batchDel(HrPositionRequest hrPositionRequest); + /** + * 填充用户的职务信息 + * + * @author fengshuonan + * @since 2023/6/15 16:58 + */ + void fillDutyInfo(Long userId, List results); + } diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/system/modular/position/service/impl/HrPositionServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/system/modular/position/service/impl/HrPositionServiceImpl.java index 679327c68..cf982d7b1 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/system/modular/position/service/impl/HrPositionServiceImpl.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/system/modular/position/service/impl/HrPositionServiceImpl.java @@ -31,17 +31,24 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.stylefeng.roses.kernel.db.api.factory.PageFactory; import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory; +import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseExpandFieldEntity; import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; import cn.stylefeng.roses.kernel.rule.enums.StatusEnum; import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; import cn.stylefeng.roses.kernel.system.api.UserOrgServiceApi; import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException; import cn.stylefeng.roses.kernel.system.api.exception.enums.organization.PositionExceptionEnum; +import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationDTO; import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionDTO; import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionRequest; +import cn.stylefeng.roses.kernel.system.modular.organization.service.HrOrganizationService; import cn.stylefeng.roses.kernel.system.modular.position.entity.HrPosition; import cn.stylefeng.roses.kernel.system.modular.position.mapper.HrPositionMapper; +import cn.stylefeng.roses.kernel.system.modular.position.pojo.DutyItem; +import cn.stylefeng.roses.kernel.system.modular.position.pojo.ExpandDutyInfo; import cn.stylefeng.roses.kernel.system.modular.position.service.HrPositionService; +import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser; +import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -50,6 +57,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * 系统职位表 服务实现类 @@ -63,6 +71,12 @@ public class HrPositionServiceImpl extends ServiceImpl results) { + + // 获取用户拓展字段中的职务信息 + LambdaQueryWrapper sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); + sysUserLambdaQueryWrapper.eq(SysUser::getUserId, userId); + sysUserLambdaQueryWrapper.select(BaseExpandFieldEntity::getExpandField); + SysUser currentUser = this.sysUserService.getOne(sysUserLambdaQueryWrapper, false); + Map expandField = currentUser.getExpandField(); + + if (ObjectUtil.isEmpty(expandField)) { + return; + } + + // 获取职务的信息包装 + ExpandDutyInfo expandDutyInfo = BeanUtil.mapToBean(expandField, ExpandDutyInfo.class, false, CopyOptions.create().ignoreError()); + + // 多组织的职务列表 + List ptDuty = expandDutyInfo.getPtDuty(); + + // 如果多组织列表为空,则直接返回默认的职务名称 + if (ObjectUtil.isEmpty(ptDuty)) { + for (HrOrganizationDTO result : results) { + result.setPositionName(expandDutyInfo.getDuty()); + } + } + + // 多组织的职务列表不为空,则获取职务的masterOrgId对应的公司id + for (DutyItem dutyItem : ptDuty) { + + String masterOrgId = dutyItem.getOrgId(); + Long masterOrgIdCompanyId = this.hrOrganizationService.getMasterOrgIdCompanyId(masterOrgId); + if (masterOrgIdCompanyId == null) { + continue; + } + + // 遍历参数的组织机构列表,填充职务名称 + for (HrOrganizationDTO result : results) { + if (result.getOrgId().equals(masterOrgIdCompanyId)) { + result.setPositionName(dutyItem.getDutyName()); + } + } + } + } + @Override public Integer positionNum() { return Convert.toInt(this.count());