【7.6.0】【personal】更新当前公司部门数

pull/57/head
fengshuonan 2023-07-02 08:42:09 +08:00
parent 6b3ad58210
commit 74a147085c
2 changed files with 35 additions and 5 deletions

View File

@ -121,6 +121,16 @@ public interface HrOrganizationService extends IService<HrOrganization> {
*/
CompanyDeptDTO getOrgCompanyInfo(HrOrganization hrOrganization);
/**
* idid
*
* @param orgId id
* @return
* @author fengshuonan
* @since 2023/7/2 8:38
*/
CompanyDeptDTO getOrgCompanyInfo(Long orgId);
/**
*
* <p>

View File

@ -19,7 +19,6 @@ import cn.stylefeng.roses.kernel.sys.api.callback.RemoveOrgCallbackApi;
import cn.stylefeng.roses.kernel.sys.api.enums.org.OrgTypeEnum;
import cn.stylefeng.roses.kernel.sys.api.exception.enums.OrgExceptionEnum;
import cn.stylefeng.roses.kernel.sys.api.pojo.org.CompanyDeptDTO;
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserOrgDTO;
import cn.stylefeng.roses.kernel.sys.modular.org.constants.OrgConstants;
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
import cn.stylefeng.roses.kernel.sys.modular.org.factory.OrganizationFactory;
@ -277,6 +276,27 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
return this.getOrgCompanyInfo(parentOrgInfo);
}
@Override
public CompanyDeptDTO getOrgCompanyInfo(Long orgId) {
if (orgId == null) {
return null;
}
// 查询组织机构对应的信息
LambdaQueryWrapper<HrOrganization> hrOrganizationLambdaQueryWrapper = new LambdaQueryWrapper<>();
hrOrganizationLambdaQueryWrapper.eq(HrOrganization::getOrgId, orgId);
hrOrganizationLambdaQueryWrapper.select(HrOrganization::getOrgType, HrOrganization::getOrgId, HrOrganization::getOrgParentId);
HrOrganization hrOrganization = this.getOne(hrOrganizationLambdaQueryWrapper, false);
if (hrOrganization == null) {
return null;
}
// 查询机构对应的公司部门信息
return this.getOrgCompanyInfo(hrOrganization);
}
@Override
public HomeCompanyInfo orgStatInfo() {
@ -297,17 +317,17 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
homeCompanyInfo.setPositionNum(totalPositionCount);
// 4. 当前公司下的机构数量
Long userId = LoginContext.me().getLoginUser().getUserId();
UserOrgDTO userMainOrgInfo = sysUserOrgService.getUserMainOrgInfo(userId);
Long currentOrgId = LoginContext.me().getLoginUser().getCurrentOrgId();
CompanyDeptDTO orgCompanyInfo = this.getOrgCompanyInfo(currentOrgId);
// 当前用户没公司则直接设置为0
if (userMainOrgInfo == null) {
if (currentOrgId == null || orgCompanyInfo == null) {
homeCompanyInfo.setCurrentCompanyPersonNum(0L);
homeCompanyInfo.setCurrentCompanyPersonNum(0L);
return homeCompanyInfo;
}
Long companyId = userMainOrgInfo.getCompanyId();
Long companyId = orgCompanyInfo.getCompanyId();
// 获取当前公司的所有子公司数量(含当前公司)
LambdaQueryWrapper<HrOrganization> wrapper = Wrappers.lambdaQuery(HrOrganization.class)