【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); CompanyDeptDTO getOrgCompanyInfo(HrOrganization hrOrganization);
/**
* idid
*
* @param orgId id
* @return
* @author fengshuonan
* @since 2023/7/2 8:38
*/
CompanyDeptDTO getOrgCompanyInfo(Long orgId);
/** /**
* *
* <p> * <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.enums.org.OrgTypeEnum;
import cn.stylefeng.roses.kernel.sys.api.exception.enums.OrgExceptionEnum; 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.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.constants.OrgConstants;
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization; import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrganization;
import cn.stylefeng.roses.kernel.sys.modular.org.factory.OrganizationFactory; import cn.stylefeng.roses.kernel.sys.modular.org.factory.OrganizationFactory;
@ -277,6 +276,27 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
return this.getOrgCompanyInfo(parentOrgInfo); 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 @Override
public HomeCompanyInfo orgStatInfo() { public HomeCompanyInfo orgStatInfo() {
@ -297,17 +317,17 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
homeCompanyInfo.setPositionNum(totalPositionCount); homeCompanyInfo.setPositionNum(totalPositionCount);
// 4. 当前公司下的机构数量 // 4. 当前公司下的机构数量
Long userId = LoginContext.me().getLoginUser().getUserId(); Long currentOrgId = LoginContext.me().getLoginUser().getCurrentOrgId();
UserOrgDTO userMainOrgInfo = sysUserOrgService.getUserMainOrgInfo(userId); CompanyDeptDTO orgCompanyInfo = this.getOrgCompanyInfo(currentOrgId);
// 当前用户没公司则直接设置为0 // 当前用户没公司则直接设置为0
if (userMainOrgInfo == null) { if (currentOrgId == null || orgCompanyInfo == null) {
homeCompanyInfo.setCurrentCompanyPersonNum(0L); homeCompanyInfo.setCurrentCompanyPersonNum(0L);
homeCompanyInfo.setCurrentCompanyPersonNum(0L); homeCompanyInfo.setCurrentCompanyPersonNum(0L);
return homeCompanyInfo; return homeCompanyInfo;
} }
Long companyId = userMainOrgInfo.getCompanyId(); Long companyId = orgCompanyInfo.getCompanyId();
// 获取当前公司的所有子公司数量(含当前公司) // 获取当前公司的所有子公司数量(含当前公司)
LambdaQueryWrapper<HrOrganization> wrapper = Wrappers.lambdaQuery(HrOrganization.class) LambdaQueryWrapper<HrOrganization> wrapper = Wrappers.lambdaQuery(HrOrganization.class)