diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/config/ProvincialProperties.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/config/ProvincialProperties.java deleted file mode 100644 index 2c12cd9..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/config/ProvincialProperties.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.hz.pm.api.common.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -/** - * @author zpf - * @date 2023/3/2 下午5:37 - */ -@Data -@Configuration -@ConfigurationProperties(prefix = "provincial") -public class ProvincialProperties { - private String host; - - private String pushUrl; - - private String detailUrl; - - private String domainUrl; - - private String key; - - private String secret; -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/UserInfoHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/UserInfoHelper.java index 30194be..cb7f074 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/UserInfoHelper.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/UserInfoHelper.java @@ -50,5 +50,5 @@ public interface UserInfoHelper { List listUserFullInfoByUnitIdsAndRole(Collection unitIds, RoleEnum role); - List getEmployeeCodesByRoleEnum(RoleEnum roleEnum); + List listUsersByRole(RoleEnum roleEnum); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java index b647f41..eba3442 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/UserInfoHelperImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.model.constant.BizConst; +import com.hz.pm.api.common.model.constant.ExistsSqlConst; import com.hz.pm.api.common.model.constant.MhUnitConst; import com.hz.pm.api.common.util.StrUtils; import com.hz.pm.api.sys.mapper.RoleMapper; @@ -39,7 +40,7 @@ public class UserInfoHelperImpl implements UserInfoHelper { private final IUserInfoService userInfoService; - private final IUserRoleService iUserRoleService; + private final IUserRoleService userRoleService; private final RoleMapper roleMapper; private final MhUnitCache mhUnitCache; @@ -70,7 +71,7 @@ public class UserInfoHelperImpl implements UserInfoHelper { public UserFullInfoDTO getUserFullInfo(UserInfo userInfo) { UserFullInfoDTO userFullInfo = new UserFullInfoDTO(); // 获取用户角色列表信息 - List userRoleList = iUserRoleService.listByUserId(userInfo.getId()); + List userRoleList = userRoleService.listByUserId(userInfo.getId()); if (CollUtil.isNotEmpty(userRoleList)) { List roleIdList = userRoleList.stream() .map(UserRole::getRoleId).distinct() @@ -189,24 +190,22 @@ public class UserInfoHelperImpl implements UserInfoHelper { } LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) .in(UserInfo::getMhUnitId, unitIds) - .exists("select 1 from nd_user_role nur where nur.user_id = nd_user_info.id" + - " and nur.role_id = {0}", role.getId()); + .exists(ExistsSqlConst.USER_EXISTS_ROLE + " and nur.role_id = {0}", role.getId()); List userInfos = userInfoService.list(query); return CollUtils.convert(userInfos, this::convert); } @Override - public List getEmployeeCodesByRoleEnum(RoleEnum roleEnum) { + public List listUsersByRole(RoleEnum roleEnum) { LambdaQueryWrapper rQuery = Wrappers.lambdaQuery(Role.class) .eq(Role::getCode, roleEnum.name()) .last(BizConst.LIMIT_1); Role role = roleMapper.selectOne(rQuery); if (role != null) { - LambdaQueryWrapper query = Wrappers.lambdaQuery(UserRole.class) - .eq(UserRole::getRoleId, role.getId()); - List userRoles = iUserRoleService.list(query); - List userIdList = userRoles.stream().map(UserRole::getUserId).collect(Collectors.toList()); - return userInfoService.listByIds(userIdList); + List userIds = userRoleService.listUserIdByRoleId(role.getId()); + if (CollUtil.isNotEmpty(userIds)) { + return userInfoService.listByIds(userIds); + } } return Collections.emptyList(); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/ExistsSqlConst.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/ExistsSqlConst.java index a4d6257..b7554b7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/ExistsSqlConst.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/ExistsSqlConst.java @@ -25,4 +25,6 @@ public class ExistsSqlConst { public static final String PURCHASE_EXISTS_STATUS_CHANGE = "select 1 from nd_purchase_status_change npsc where npsc.bid_id = nd_purchase.id "; + public static final String USER_EXISTS_ROLE = "select 1 from nd_user_role nur where nur.user_id = nd_user_info.id " + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java index 826dbb2..7ee748e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java @@ -14,7 +14,6 @@ import com.hz.pm.api.sys.model.entity.ProjectEarlyWarning; import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords; import com.hz.pm.api.sys.service.IEarlyWarningRecordsService; import org.apache.commons.lang3.StringUtils; -import org.checkerframework.checker.nullness.qual.Nullable; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -30,18 +29,15 @@ import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; import com.hz.pm.api.common.util.EnvironmentUtil; import com.hz.pm.api.common.util.StrUtils; -import com.hz.pm.api.projectdeclared.service.IOperationService; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; import com.hz.pm.api.projectlib.model.enumeration.WarningFlowTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.WarningNoticeTypeEnum; -import com.hz.pm.api.projectlib.service.IProjectRenewalFundDeclarationService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; import com.hz.pm.api.scheduler.contants.TaskConstant; import com.hz.pm.api.sys.enumeration.ProjectEarlyWarningStatusEnum; import com.hz.pm.api.sys.manage.EarlyWarningManage; -import com.hz.pm.api.sys.manage.RoleManage; import com.hz.pm.api.sys.service.IProjectEarlyWarningService; import com.hz.pm.api.user.helper.MhUnitCache; import com.hz.pm.api.user.model.entity.UserInfo; @@ -253,13 +249,13 @@ public class EarlyWarningWithoutSubmitTask { List batchEmployees = Lists.newArrayList(); if (StringUtils.isNotBlank(notice) && notice.contains(WarningNoticeTypeEnum.SUPER_ADMIN.getCode().toString())) { // 获取超级管理员用户信息 - List superAdminUsers = userInfoHelper.getEmployeeCodesByRoleEnum(RoleEnum.SUPER_ADMIN); + List superAdminUsers = userInfoHelper.listUsersByRole(RoleEnum.SUPER_ADMIN); List superAdminEmployeeCodes = superAdminUsers.stream().map(UserInfo::getEmployeeCode).collect(Collectors.toList()); batchEmployees.addAll(superAdminEmployeeCodes); } if (StringUtils.isNotBlank(notice) && notice.contains(WarningNoticeTypeEnum.UNIT_ADMIN.getCode().toString())) { // 获取单位管理员用户信息 - List unitAdminUsers = userInfoHelper.getEmployeeCodesByRoleEnum(RoleEnum.COMPANY_MANAGER); + List unitAdminUsers = userInfoHelper.listUsersByRole(RoleEnum.COMPANY_MANAGER); // 过滤出当前项目所属单位的单位管理员 List unitAdminEmployeeCodes = unitAdminUsers.stream().filter(user -> Objects.equals(user.getMhUnitId().toString(), project.getBuildOrgCode())) .map(UserInfo::getEmployeeCode).collect(Collectors.toList()); diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java b/hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java index 544a0a7..28a8311 100644 --- a/hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java +++ b/hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java @@ -1,7 +1,5 @@ package com.hz.pm.api.warning; -import javax.annotation.Resource; - import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.StopWatch; import cn.hutool.core.map.MapUtil; @@ -38,7 +36,6 @@ import com.hz.pm.api.sys.service.IProjectEarlyWarningService; import com.hz.pm.api.user.helper.MhUnitCache; import com.hz.pm.api.user.model.entity.UserInfo; import com.hz.pm.api.user.model.enumeration.RoleEnum; -import com.hz.pm.api.user.service.IUserInfoService; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.StrPool; import com.wflow.bean.entity.WflowEarlyWarning; @@ -46,21 +43,16 @@ import com.wflow.bean.entity.WflowModels; import com.wflow.enums.WarningRuleTypeEnum; import com.wflow.service.IEarlyWarningService; import com.wflow.workflow.service.ProcessModelService; -import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.checkerframework.checker.nullness.qual.Nullable; import org.flowable.engine.TaskService; import org.flowable.task.api.Task; import org.junit.Test; import com.alibaba.fastjson.JSON; import com.hz.pm.api.AppTests; -import com.hz.pm.api.projectdeclared.model.entity.ProjectDraft; -import com.hz.pm.api.projectdeclared.service.IProjectDraftService; import org.springframework.beans.factory.annotation.Autowired; -import java.time.Duration; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.*; @@ -269,13 +261,13 @@ public class DelayWarningTest extends AppTests { List batchEmployees = Lists.newArrayList(); if (StringUtils.isNotBlank(notice) && notice.contains(WarningNoticeTypeEnum.SUPER_ADMIN.getCode().toString())) { // 获取超级管理员用户信息 - List superAdminUsers = userInfoHelper.getEmployeeCodesByRoleEnum(RoleEnum.SUPER_ADMIN); + List superAdminUsers = userInfoHelper.listUsersByRole(RoleEnum.SUPER_ADMIN); List superAdminEmployeeCodes = superAdminUsers.stream().map(UserInfo::getEmployeeCode).collect(Collectors.toList()); batchEmployees.addAll(superAdminEmployeeCodes); } if (StringUtils.isNotBlank(notice) && notice.contains(WarningNoticeTypeEnum.UNIT_ADMIN.getCode().toString())) { // 获取单位管理员用户信息 - List unitAdminUsers = userInfoHelper.getEmployeeCodesByRoleEnum(RoleEnum.COMPANY_MANAGER); + List unitAdminUsers = userInfoHelper.listUsersByRole(RoleEnum.COMPANY_MANAGER); // 过滤出当前项目所属单位的单位管理员 List unitAdminEmployeeCodes = unitAdminUsers.stream().filter(user -> Objects.equals(user.getMhUnitId().toString(), project.getBuildOrgCode())) .map(UserInfo::getEmployeeCode).collect(Collectors.toList());