diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/RegionLimitHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/RegionLimitHelper.java index bb5a8c0..f4883ff 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/RegionLimitHelper.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/RegionLimitHelper.java @@ -39,14 +39,4 @@ public interface RegionLimitHelper { */ RegionContainsBO getContainsRegionBo(Integer regionLevel, String regionCode); - - - /** - * 根据专家管理员用户id 获取专家管理员管辖区域列表 - * - * @param expertAdminUserId 专家管理员用户id - * @return - */ - List getExpertAdminContainsRegion(Long expertAdminUserId); - } 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 8670bec..72cbdb2 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 @@ -1,7 +1,9 @@ package com.hz.pm.api.common.helper; +import cn.hutool.core.util.NumberUtil; import com.hz.pm.api.user.model.entity.UserInfo; import com.hz.pm.api.user.security.model.UserFullInfoDTO; +import com.ningdatech.basic.util.CollUtils; import java.util.Collection; import java.util.List; @@ -14,18 +16,17 @@ import java.util.List; public interface UserInfoHelper { - /** - * 根据用户id 获取 用户所属组织code organizationCode - * - * @param userId \ - * @return \ - */ - String getOrganizationCode(Long userId); - UserFullInfoDTO getUserFullInfoByMhUserIdOrOpenId(String mhUserId); UserFullInfoDTO getUserFullInfo(Long userId); + default UserFullInfoDTO getUserFullInfo(String userId) { + if (NumberUtil.isLong(userId)) { + return getUserFullInfo(Long.parseLong(userId)); + } + return null; + } + UserFullInfoDTO getUserFullInfo(UserInfo userInfo); List getUserFullInfos(List userInfos); @@ -39,16 +40,11 @@ public interface UserInfoHelper { */ boolean isSuperOrRegionAdmin(Long userId); - UserFullInfoDTO getUserFullInfoByEmployeeCode(String employeeCode); + List listUserFullInfoByUserIds(Collection userIds); - List getUserFullInfoByEmployeeCodes(Collection employeeCodes); - - /** - * 获取用户任职所在单位code \ - * - * @return \ - */ - String getUserEmpPosUnitCode(Long userId); + default List listUserFullInfoByUserIds(List userIds){ + List userIdsLong = CollUtils.convert(userIds, Long::parseLong); + return listUserFullInfoByUserIds(userIdsLong); + } - String getMainOrgCode(String empPosUnitCode); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/RegionLimitHelperImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/RegionLimitHelperImpl.java index 23dc863..215967f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/RegionLimitHelperImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/helper/impl/RegionLimitHelperImpl.java @@ -1,15 +1,10 @@ package com.hz.pm.api.common.helper.impl; -import cn.hutool.core.collection.CollectionUtil; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.helper.basic.AbstractRegionLimitHelper; import com.hz.pm.api.expert.service.IExpertUserFullInfoService; import com.hz.pm.api.meta.model.bo.RegionContainsBO; -import com.hz.pm.api.sys.model.entity.Region; import com.hz.pm.api.sys.service.IRegionService; -import com.hz.pm.api.user.model.entity.UserInfo; import com.hz.pm.api.user.service.IUserInfoService; import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; @@ -28,8 +23,6 @@ import java.util.Objects; @Component public class RegionLimitHelperImpl extends AbstractRegionLimitHelper { - private static final Logger logger = LoggerFactory.getLogger(RegionLimitHelperImpl.class); - public RegionLimitHelperImpl(RegionCacheHelper regionCache, IExpertUserFullInfoService expertUserFullInfoService , IUserInfoService iUserInfoService, IRegionService regionService) { super(regionCache, expertUserFullInfoService, iUserInfoService, regionService); @@ -91,29 +84,4 @@ public class RegionLimitHelperImpl extends AbstractRegionLimitHelper { return regionContains; } - - @Override - public List getExpertAdminContainsRegion(Long expertAdminUserId) { - if (Objects.isNull(expertAdminUserId)) { - logger.error("getExpertAdminContainsRegion expertAdminUserId is null"); - return new ArrayList<>(); - } - UserInfo userInfo = iUserInfoService.getById(expertAdminUserId); - if (Objects.isNull(userInfo) || StringUtils.isBlank(userInfo.getRegionCode())) { - logger.error("getExpertAdminContainsRegion userInfo is null Or regionCode is null"); - return new ArrayList<>(); - } - String regionCode = userInfo.getRegionCode(); - List regionList = regionService.list(Wrappers.lambdaQuery(Region.class) - .eq(Region::getRegionCode, regionCode) - .orderByDesc(Region::getRegionLevel)); - Region region = regionList.get(0); - Collection regionCodes = regionCache - .listChildRegionCodeList(region.getRegionCode(), region.getRegionLevel()); - RegionContainsBO regionContainsBO = new RegionContainsBO(); - regionContainsBO.setContainsRegionCodeList(new ArrayList<>(regionCodes)); - regionContainsBO.setParentRegionTreeLevel(region.getRegionLevel()); - return CollectionUtil.toList(regionContainsBO); - } - } 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 a2c067b..f7464f1 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 @@ -1,31 +1,28 @@ package com.hz.pm.api.common.helper.impl; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.helper.UserInfoHelper; -import com.hz.pm.api.organization.model.entity.DingEmployeeInfo; -import com.hz.pm.api.organization.model.entity.DingOrganization; -import com.hz.pm.api.organization.service.IDingEmployeeInfoService; -import com.hz.pm.api.organization.service.IDingOrganizationService; +import com.hz.pm.api.common.util.StrUtils; import com.hz.pm.api.sys.mapper.RoleMapper; import com.hz.pm.api.sys.model.entity.Role; import com.hz.pm.api.sys.model.entity.UserRole; import com.hz.pm.api.sys.service.IUserRoleService; -import com.hz.pm.api.user.model.enumeration.UserAvailableEnum; import com.hz.pm.api.user.model.entity.UserInfo; import com.hz.pm.api.user.model.enumeration.RoleEnum; +import com.hz.pm.api.user.model.enumeration.UserAvailableEnum; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.service.IUserInfoService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * @author liuxinxin @@ -37,22 +34,14 @@ public class UserInfoHelperImpl implements UserInfoHelper { private final IUserInfoService userInfoService; - private final IDingEmployeeInfoService iDingEmployeeInfoService; - private final IDingOrganizationService iDingOrganizationService; private final IUserRoleService iUserRoleService; private final RoleMapper roleMapper; @Override - public String getOrganizationCode(Long userId) { - UserFullInfoDTO userFullInfo = getUserFullInfo(userId); - return userFullInfo.getOrganizationCode(); - } - - @Override public UserFullInfoDTO getUserFullInfoByMhUserIdOrOpenId(String mhUserId) { LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getMhUserId, mhUserId) - .or(q1 -> q1.eq(UserInfo::getWechatOpenId,mhUserId)); + .or(q1 -> q1.eq(UserInfo::getWechatOpenId, mhUserId)); UserInfo userInfo = userInfoService.getOne(query); if (Objects.isNull(userInfo)) { return null; @@ -74,61 +63,22 @@ public class UserInfoHelperImpl implements UserInfoHelper { @Override public UserFullInfoDTO getUserFullInfo(UserInfo userInfo) { UserFullInfoDTO userFullInfo = new UserFullInfoDTO(); - // 获取浙政钉雇员信息 组织信息 - String employeeCode = userInfo.getEmployeeCode(); - if (StringUtils.isNotBlank(employeeCode)) { - List dingEmployeeInfoList = iDingEmployeeInfoService - .list(Wrappers.lambdaQuery(DingEmployeeInfo.class) - .eq(DingEmployeeInfo::getEmployeeCode, employeeCode) - .eq(DingEmployeeInfo::getMainJob, "true")); - DingEmployeeInfo dingEmployeeInfo = dingEmployeeInfoList.get(0); - - - // 装配用户任职所在单位 - String empPosUnitCode = dingEmployeeInfo.getEmpPosUnitCode(); - if (StringUtils.isNotBlank(empPosUnitCode)) { - DingOrganization dingOrganization = iDingOrganizationService.getByOrgCode(empPosUnitCode); - if (Objects.nonNull(dingOrganization)) { - userFullInfo.setEmpPosUnitCode(empPosUnitCode); - userFullInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); - userFullInfo.setRegionCode(dingOrganization.getDivisionCode()); - } - } - - // 装配用户所在orgCode - String organizationCode = dingEmployeeInfo.getOrganizationCode(); - List dingOrganizationList = iDingOrganizationService.list(Wrappers - .lambdaQuery(DingOrganization.class) - .eq(DingOrganization::getOrganizationCode, organizationCode)); - if (CollectionUtil.isNotEmpty(dingOrganizationList)) { - DingOrganization dingOrganization = dingOrganizationList.get(0); - userFullInfo.setOrganizationCode(dingOrganization.getOrganizationCode()); - userFullInfo.setOrganizationName(dingOrganization.getOrganizationName()); - // 测试使用 - userFullInfo.setRegionLevel(3); - } - } - - List roleList = new ArrayList<>(); // 获取用户角色列表信息 - List userRoleList = iUserRoleService - .list(Wrappers.lambdaQuery(UserRole.class) - .eq(UserRole::getUserId, userInfo.getId())); - if (CollectionUtil.isNotEmpty(userRoleList)) { + List userRoleList = iUserRoleService.listByUserId(userInfo.getId()); + if (CollUtil.isNotEmpty(userRoleList)) { List roleIdList = userRoleList.stream() .map(UserRole::getRoleId).distinct() .collect(Collectors.toList()); - roleList = roleMapper.selectBatchIds(roleIdList); + userFullInfo.setUserRoleList(roleMapper.selectBatchIds(roleIdList)); } - userFullInfo.setUserRoleList(roleList); - - // 装配用户任职所在单位 // 装配返回 userFullInfo.setUserId(userInfo.getId()); + userFullInfo.setMhUserId(userInfo.getMhUserId()); userFullInfo.setIdentifier(userInfo.getRealName()); userFullInfo.setRealName(userInfo.getRealName()); - userFullInfo.setEmployeeCode(employeeCode); + userFullInfo.setMhUnitId(userFullInfo.getMhUnitId()); + userFullInfo.setMhUnitName(userFullInfo.getMhUnitName()); userFullInfo.setUsername(userInfo.getRealName()); userFullInfo.setMobile(userInfo.getMobile()); userFullInfo.setAccountId(userInfo.getAccountId()); @@ -151,60 +101,20 @@ public class UserInfoHelperImpl implements UserInfoHelper { if (CollUtil.isEmpty(userInfos)) { return Collections.emptyList(); } - Map userMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode, e -> e)); - // 获取浙政钉雇员信息 组织信息 - List employeeCodes = userInfos.stream().map(UserInfo::getEmployeeCode).collect(Collectors.toList()); - List dingEmployeeInfoList = iDingEmployeeInfoService - .list(Wrappers.lambdaQuery(DingEmployeeInfo.class) - .in(DingEmployeeInfo::getEmployeeCode, employeeCodes) - .eq(DingEmployeeInfo::getMainJob, "true")); - - if (CollUtil.isEmpty(dingEmployeeInfoList)) { - return Collections.emptyList(); - } - - // 装配用户任职所在单位 - List empPosUnitCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getEmpPosUnitCode).collect(Collectors.toList()); - List orgCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getOrganizationCode).collect(Collectors.toList()); - List allOrgCodes = Stream.concat(empPosUnitCodes.stream(), orgCodes.stream()).collect(Collectors.toList()); - if (CollUtil.isEmpty(allOrgCodes)) { - return Collections.emptyList(); - } - List dingOrganizations = iDingOrganizationService.listByCodes(allOrgCodes); - if (CollUtil.isEmpty(dingOrganizations)) { - return Collections.emptyList(); - } - Map orgMap = dingOrganizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode, d -> d)); - - return dingEmployeeInfoList.stream().map(e -> { + return userInfos.stream().map(userInfo -> { UserFullInfoDTO userFullInfo = new UserFullInfoDTO(); - if (orgMap.containsKey(e.getEmpPosUnitCode())) { - DingOrganization organization = orgMap.get(e.getEmpPosUnitCode()); - userFullInfo.setEmpPosUnitCode(e.getEmpPosUnitCode()); - userFullInfo.setEmpPosUnitName(organization.getOrganizationName()); - userFullInfo.setRegionCode(organization.getDivisionCode()); - } - if (orgMap.containsKey(e.getOrganizationCode())) { - DingOrganization organization = orgMap.get(e.getOrganizationCode()); - userFullInfo.setOrganizationCode(organization.getOrganizationCode()); - userFullInfo.setOrganizationName(organization.getOrganizationName()); - // 测试使用 - userFullInfo.setRegionLevel(3); - } - if (userMap.containsKey(e.getEmployeeCode())) { - UserInfo userInfo = userMap.get(e.getEmployeeCode()); - // 装配返回 - userFullInfo.setUserId(userInfo.getId()); - userFullInfo.setIdentifier(userInfo.getRealName()); - userFullInfo.setRealName(userInfo.getRealName()); - userFullInfo.setEmployeeCode(e.getEmployeeCode()); - userFullInfo.setUsername(userInfo.getRealName()); - userFullInfo.setMobile(userInfo.getMobile()); - userFullInfo.setAccountId(userInfo.getAccountId()); - String available = userInfo.getAvailable(); - if (StringUtils.isNotBlank(available)) { - userFullInfo.setAvailable(UserAvailableEnum.valueOf(available)); - } + // 装配返回 + userFullInfo.setMhUnitName(userInfo.getMhUnitName()); + userFullInfo.setMhUnitId(userInfo.getMhUnitId()); + userFullInfo.setUserId(userInfo.getId()); + userFullInfo.setIdentifier(userInfo.getRealName()); + userFullInfo.setRealName(userInfo.getRealName()); + userFullInfo.setUsername(userInfo.getRealName()); + userFullInfo.setMobile(userInfo.getMobile()); + userFullInfo.setAccountId(userInfo.getAccountId()); + String available = userInfo.getAvailable(); + if (StrUtils.isNotBlank(available)) { + userFullInfo.setAvailable(UserAvailableEnum.valueOf(available)); } return userFullInfo; }).collect(Collectors.toList()); @@ -231,31 +141,9 @@ public class UserInfoHelperImpl implements UserInfoHelper { } @Override - public UserFullInfoDTO getUserFullInfoByEmployeeCode(String employeeCode) { - UserInfo userInfo = userInfoService.getUserInfoByEmployeeCode(employeeCode); - return getUserFullInfo(userInfo); - } - - @Override - public List getUserFullInfoByEmployeeCodes(Collection employeeCodes) { - List userInfos = userInfoService.getUserInfoByEmployeeCodes(employeeCodes); + public List listUserFullInfoByUserIds(Collection userIds) { + List userInfos = userInfoService.listByIds(userIds); return getUserFullInfos(userInfos); } - @Override - public String getUserEmpPosUnitCode(Long userId) { - UserFullInfoDTO userFullInfo = getUserFullInfo(userId); - return userFullInfo.getEmpPosUnitCode(); - } - - @Override - public String getMainOrgCode(String empPosUnitCode) { - DingOrganization org = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) - .eq(DingOrganization::getOrganizationCode, empPosUnitCode) - .last(BizConst.LIMIT_1)); - if(Objects.isNull(org)){ - return null; - } - return org.getParentCode(); - } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/StateMachineConst.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/StateMachineConst.java index c9ce670..a1d0ff9 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/StateMachineConst.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/constant/StateMachineConst.java @@ -7,8 +7,10 @@ package com.hz.pm.api.common.model.constant; public class StateMachineConst { + private StateMachineConst() { + } + public static final String PROJECT_DECLARE = "projectDeclare"; public static final String APPLICATION_DECLARE = "applicationDeclare"; - public static final String LI_SHUI_CITY_AREA_CODE = "331100"; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineLQBuilder.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineLQBuilder.java index 5e871ff..d539c3c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineLQBuilder.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/builder/ProjectDeclareStateMachineLQBuilder.java @@ -264,16 +264,16 @@ public class ProjectDeclareStateMachineLQBuilder implements ProjectDeclareStateM @Bean(name = "projectDeclareStateMachineLQPersister") @Override public StateMachinePersister getProjectPersister() { - StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist() { + StateMachinePersister sp = new DefaultStateMachinePersister<>(new StateMachinePersist() { @Override public void write(StateMachineContext context, Project contextObj) { + logger.info(contextObj.toString()); } @Override public StateMachineContext read(Project contextObj) { - StateMachineContext result = new DefaultStateMachineContext(ProjectStatusEnum.match(contextObj.getStatus()), + return new DefaultStateMachineContext<>(ProjectStatusEnum.match(contextObj.getStatus()), null, null, null, null, RegionContant.LS_LQ_CODE); - return result; } }); stateMachinePersister = sp; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/contant/RegionContant.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/contant/RegionContant.java index 619445f..b3684ec 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/contant/RegionContant.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/statemachine/contant/RegionContant.java @@ -7,6 +7,10 @@ package com.hz.pm.api.common.statemachine.contant; * @Author PoffyZhang */ public class RegionContant { + + private RegionContant() { + } + //市本级 public static final String LS_SBJ_CODE = "330100"; //莲都区 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/SendWorkNoticeUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/SendWorkNoticeUtil.java index 00c71a5..6d6e2ef 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/SendWorkNoticeUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/SendWorkNoticeUtil.java @@ -1,15 +1,16 @@ package com.hz.pm.api.common.util; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.model.GenericResult; import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo; +import com.ningdatech.basic.model.GenericResult; import com.ningdatech.zwdd.client.ZwddClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; -import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ThreadPoolExecutor; /** * 异步发送工作通知工具类 @@ -18,8 +19,8 @@ import java.util.concurrent.*; * @since 2023/02/23 13:50 */ @Slf4j -@RequiredArgsConstructor @Component +@RequiredArgsConstructor public class SendWorkNoticeUtil { private final ZwddClient zwddClient; @@ -27,10 +28,21 @@ public class SendWorkNoticeUtil { /** * 初始化线程池 */ - public static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(2, 10, - 60, TimeUnit.SECONDS, new ArrayBlockingQueue(10), new ThreadPoolExecutor.AbortPolicy()); + public static final ThreadPoolTaskExecutor EXECUTOR; - public Boolean sendWorkNotice(WorkNoticeInfo workNoticeInfo){ + static { + EXECUTOR = new ThreadPoolTaskExecutor(); + EXECUTOR.setCorePoolSize(2); + EXECUTOR.setMaxPoolSize(4); + EXECUTOR.setQueueCapacity(200); + EXECUTOR.setKeepAliveSeconds(120); + EXECUTOR.setThreadNamePrefix("sendWorkNotice-"); + EXECUTOR.setWaitForTasksToCompleteOnShutdown(true); + EXECUTOR.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); + EXECUTOR.initialize(); + } + + public Boolean sendWorkNotice(WorkNoticeInfo workNoticeInfo) { // 将发送工作通知交给异步任务Future String msg = workNoticeInfo.getMsg(); @@ -44,23 +56,18 @@ public class SendWorkNoticeUtil { log.info("异步任务执行完成, " + workNoticeInfo.getBizMsgId() + " 当前线程:" + Thread.currentThread().getName()); long endTime = System.currentTimeMillis(); log.info("方法执行完成返回,耗时:" + (endTime - startTime)); - }else { + } else { return "发送工作通知失败!"; } return "发送工作通知成功!"; - }, threadPool); - String s; - try { - s = future.get(); - } catch (Exception e) { - throw new BizException("获取异步线程处理结果失败!"); - } - threadPool.shutdown(); - while (!threadPool.isTerminated()) { - log.info(s); - return Boolean.FALSE; - } - log.info(s); - return Boolean.TRUE; + }, EXECUTOR); + try { + future.get(); + } catch (InterruptedException | ExecutionException e) { + log.error("获取异步线程处理结果失败!", e); + Thread.currentThread().interrupt(); + } + return Boolean.TRUE; } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/constant/AnalysisBasicConstant.java b/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/constant/AnalysisBasicConstant.java index ec980d2..f34b260 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/constant/AnalysisBasicConstant.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/constant/AnalysisBasicConstant.java @@ -7,6 +7,8 @@ package com.hz.pm.api.dashboard.constant; public class AnalysisBasicConstant { + private AnalysisBasicConstant() { + } /** * 丽水市区域编码 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/handle/CockpitStatsHandler.java b/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/handle/CockpitStatsHandler.java index bdf16d5..eff102f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/handle/CockpitStatsHandler.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/handle/CockpitStatsHandler.java @@ -5,13 +5,13 @@ import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.helper.RegionCacheHelper; -import com.hz.pm.api.dashboard.constant.DashboardConstant; +import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.dashboard.enums.CockpitAppcationTypeEnum; import com.hz.pm.api.dashboard.model.entity.CockpitApplication; import com.hz.pm.api.dashboard.model.entity.CockpitStats; import com.hz.pm.api.dashboard.model.vo.CockpitStatsVO; +import com.hz.pm.api.dashboard.model.vo.CockpitStatsVO.*; import com.hz.pm.api.dashboard.service.ICockpitStatsService; import com.hz.pm.api.sys.model.dto.RegionDTO; import lombok.RequiredArgsConstructor; @@ -24,6 +24,8 @@ import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; +import static com.hz.pm.api.dashboard.constant.DashboardConstant.CockpitStats.*; + /** * @Classname CockpitStatsHandler * @Description @@ -39,23 +41,23 @@ public class CockpitStatsHandler { private final ICockpitStatsService cockpitStatsService; - private static final List years = Lists.newArrayList(2021,2022,2023,2024,2025); + private static final List years = Lists.newArrayList(2021, 2022, 2023, 2024, 2025); public CockpitStatsVO convertCockpitStats(CockpitStats cockpitStats, String regionCode, Integer year , List appDatas) { - CockpitStatsVO res = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.class); + CockpitStatsVO res = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.class); - if(Objects.isNull(cockpitStats)){ + if (Objects.isNull(cockpitStats)) { return res; } //监测数据 - res.setMonitorData(convertMonitor(cockpitStats,regionCode)); + res.setMonitorData(convertMonitor(cockpitStats, regionCode)); //专家数据 res.setExpertData(convertExpertData(cockpitStats)); //顶部数据 res.setTopData(convertTopData(cockpitStats)); //地图数据 - res.setMapProjectData(convertMapProjectsData(cockpitStats,year)); + res.setMapProjectData(convertMapProjectsData(cockpitStats, year)); //项目项目数据 res.setStatusProjectsData(convertStatusProjectsData(cockpitStats)); //项目效益 优秀项目 @@ -69,23 +71,23 @@ public class CockpitStatsHandler { //最佳/重大应用 res.setAppDatas(convertCockpitApps(appDatas)); //数据质量分数 - res.setQualityDatas(convertQualityDatas(year)); + res.setQualityDatas(convertQualityData(year)); return res; } - private List convertQualityDatas(Integer year) { - List datas = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class) + private List convertQualityData(Integer year) { + List dataList = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class) .eq(Objects.nonNull(year), CockpitStats::getYear, year) - .eq(Objects.isNull(year), CockpitStats::getYear, DashboardConstant.CockpitStats.NONE_YEAR) - .ne(CockpitStats::getRegionCode,DashboardConstant.CockpitStats.TOTAL) + .eq(Objects.isNull(year), CockpitStats::getYear, NONE_YEAR) + .ne(CockpitStats::getRegionCode, TOTAL) .orderByAsc(CockpitStats::getRegionCode)); - if(CollUtil.isEmpty(datas)){ + if (CollUtil.isEmpty(dataList)) { return Collections.emptyList(); } - return datas.stream().map(d -> { - CockpitStatsVO.QualityData data = new CockpitStatsVO.QualityData(); + return dataList.stream().map(d -> { + QualityData data = new QualityData(); data.setRegionCode(d.getRegionCode()); data.setRegionName(d.getRegionName()); data.setQuality(d.getDataQuality()); @@ -105,150 +107,144 @@ public class CockpitStatsHandler { } private CockpitStatsVO.PerformanceData convertPerformanceData(CockpitStats cockpitStats) { - CockpitStatsVO.PerformanceData data = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.PerformanceData.class); + CockpitStatsVO.PerformanceData data = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.PerformanceData.class); data.setPerformanceTops(convertTops(cockpitStats)); return data; } - private List convertTops(CockpitStats cockpitStats) { - List tops = Lists.newArrayList(); - tops.add(new CockpitStatsVO.PerformanceTop("一星",cockpitStats.getPerformanceTop1Score(),cockpitStats.getPerformanceTop1Name())); - tops.add(new CockpitStatsVO.PerformanceTop("二星",cockpitStats.getPerformanceTop2Score(),cockpitStats.getPerformanceTop2Name())); - tops.add(new CockpitStatsVO.PerformanceTop("三星",cockpitStats.getPerformanceTop3Score(),cockpitStats.getPerformanceTop3Name())); - tops.add(new CockpitStatsVO.PerformanceTop("四星",cockpitStats.getPerformanceTop4Score(),cockpitStats.getPerformanceTop4Name())); - tops.add(new CockpitStatsVO.PerformanceTop("五星",cockpitStats.getPerformanceTop5Score(),cockpitStats.getPerformanceTop5Name())); + private List convertTops(CockpitStats cockpitStats) { + List tops = Lists.newArrayList(); + tops.add(new PerformanceTop("一星", cockpitStats.getPerformanceTop1Score(), cockpitStats.getPerformanceTop1Name())); + tops.add(new PerformanceTop("二星", cockpitStats.getPerformanceTop2Score(), cockpitStats.getPerformanceTop2Name())); + tops.add(new PerformanceTop("三星", cockpitStats.getPerformanceTop3Score(), cockpitStats.getPerformanceTop3Name())); + tops.add(new PerformanceTop("四星", cockpitStats.getPerformanceTop4Score(), cockpitStats.getPerformanceTop4Name())); + tops.add(new PerformanceTop("五星", cockpitStats.getPerformanceTop5Score(), cockpitStats.getPerformanceTop5Name())); return tops; } private CockpitStatsVO.ProduceData convertProduceData(CockpitStats cockpitStats) { - return BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.ProduceData.class); + return BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.ProduceData.class); } private CockpitStatsVO.ReduceData convertReduceData(CockpitStats cockpitStats) { - CockpitStatsVO.ReduceData data = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.ReduceData.class); + CockpitStatsVO.ReduceData data = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.ReduceData.class); data.setAmountComparisonCharts(convertAmountComparisonChart(cockpitStats)); return data; } - private List convertAmountComparisonChart(CockpitStats cockpitStats) { - List res = Lists.newArrayList(); - res.add(new CockpitStatsVO.AmountComparisonChart("申报", cockpitStats.getDeclaredAmountApprove(),cockpitStats.getApprovalAmountApprove(),cockpitStats.getDifferenceApprove())); - res.add(new CockpitStatsVO.AmountComparisonChart("批复", cockpitStats.getDeclaredAmountApproval(),cockpitStats.getApprovalAmountApproval(),cockpitStats.getDifferenceApproval())); - res.add(new CockpitStatsVO.AmountComparisonChart("合同", cockpitStats.getDeclaredAmountContract(),cockpitStats.getApprovalAmountContract(),cockpitStats.getDifferenceContract())); + private List convertAmountComparisonChart(CockpitStats cockpitStats) { + List res = Lists.newArrayList(); + res.add(new AmountComparisonChart("申报", cockpitStats.getDeclaredAmountApprove(), cockpitStats.getApprovalAmountApprove(), cockpitStats.getDifferenceApprove())); + res.add(new AmountComparisonChart("批复", cockpitStats.getDeclaredAmountApproval(), cockpitStats.getApprovalAmountApproval(), cockpitStats.getDifferenceApproval())); + res.add(new AmountComparisonChart("合同", cockpitStats.getDeclaredAmountContract(), cockpitStats.getApprovalAmountContract(), cockpitStats.getDifferenceContract())); return res; } private CockpitStatsVO.ExcellentData convertExcellentData(CockpitStats cockpitStats) { - CockpitStatsVO.ExcellentData data = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.ExcellentData.class); + CockpitStatsVO.ExcellentData data = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.ExcellentData.class); data.setExcellentProjects(Lists.newArrayList()); return data; } private CockpitStatsVO.StatusProjectsData convertStatusProjectsData(CockpitStats cockpitStats) { - return BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.StatusProjectsData.class); + return BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.StatusProjectsData.class); } - private List convertMapProjectsData(CockpitStats cockpitStats,Integer year) { + private List convertMapProjectsData(CockpitStats cockpitStats, Integer year) { List mapProjectsDatas = Lists.newArrayList(); List regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY); regions = regions.stream().filter(r -> r.getRegionLevel() != 2).sorted(Comparator.comparing(RegionDTO::getRegionCode)).collect(Collectors.toList()); List cockpitStatsAll = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class) .eq(Objects.nonNull(year), CockpitStats::getYear, year) - .eq(Objects.isNull(year), CockpitStats::getYear, DashboardConstant.CockpitStats.NONE_YEAR)); - Map totalMap = cockpitStatsAll.stream().filter(c -> Objects.nonNull(c.getRegionCode()) && Objects.nonNull(c.getProjectsTotal())) - .collect(Collectors.toMap(c -> c.getRegionCode(), c -> c.getProjectsTotal())); + .eq(Objects.isNull(year), CockpitStats::getYear, NONE_YEAR)); + Map totalMap = cockpitStatsAll.stream() + .filter(c -> Objects.nonNull(c.getRegionCode()) && Objects.nonNull(c.getProjectsTotal())) + .collect(Collectors.toMap(CockpitStats::getRegionCode, CockpitStats::getProjectsTotal)); - for(RegionDTO region : regions){ + for (RegionDTO region : regions) { CockpitStatsVO.MapProjectsData mapProjectsData = new CockpitStatsVO.MapProjectsData(); mapProjectsData.setRegionCode(region.getRegionCode()); mapProjectsData.setRegionName(region.getRegionName()); - if(totalMap.containsKey(mapProjectsData.getRegionCode())){ - mapProjectsData.setProjectsNum(totalMap.get(mapProjectsData.getRegionCode())); - }else{ - mapProjectsData.setProjectsNum(0); - } + mapProjectsData.setProjectsNum(totalMap.getOrDefault(mapProjectsData.getRegionCode(), 0)); mapProjectsDatas.add(mapProjectsData); } return mapProjectsDatas; } private CockpitStatsVO.TopData convertTopData(CockpitStats cockpitStats) { - return BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.TopData.class); + return BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.TopData.class); } private CockpitStatsVO.Expert convertExpertData(CockpitStats cockpitStats) { - CockpitStatsVO.Expert expert = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.Expert.class); - expert.setExpertRegionData(buidExpertRegionData(cockpitStats)); + CockpitStatsVO.Expert expert = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.Expert.class); + expert.setExpertRegionData(buildExpertRegionData(cockpitStats)); return expert; } - private List buidExpertRegionData(CockpitStats cockpitStats) { + private List buildExpertRegionData(CockpitStats cockpitStats) { List regionData = Lists.newArrayList(); List regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY); regions = regions.stream().filter(r -> r.getRegionLevel() != 2).sorted(Comparator.comparing(RegionDTO::getRegionCode)).collect(Collectors.toList()); List cs = cockpitStatsService.list(); Map csMap = cs.stream().collect(Collectors.toMap(c -> c.getRegionCode() + c.getYear(), CockpitStats::getExpertTotalNum)); - for(RegionDTO region : regions){ + for (RegionDTO region : regions) { CockpitStatsVO.ExpertRegion expertRegion = new CockpitStatsVO.ExpertRegion(); expertRegion.setRegionCode(region.getRegionCode()); expertRegion.setRegionName(region.getRegionName()); - if(csMap.containsKey(region.getRegionCode() + 0)){ - expertRegion.setExpertNum(csMap.get(region.getRegionCode() + 0)); - }else{ - expertRegion.setExpertNum(0); - } + expertRegion.setExpertNum(csMap.getOrDefault(region.getRegionCode() + 0, 0)); regionData.add(expertRegion); } return regionData; } - private CockpitStatsVO.Monitor convertMonitor(CockpitStats cockpitStats,String regionCode) { - CockpitStatsVO.Monitor monitor = BeanUtil.copyProperties(cockpitStats,CockpitStatsVO.Monitor.class); - monitor.setPasswordGradeCharts(buidPasswordGradeCharts(cockpitStats)); - monitor.setSecrecyGradeCharts(buidSecrecyGradeCharts(cockpitStats)); + private CockpitStatsVO.Monitor convertMonitor(CockpitStats cockpitStats, String regionCode) { + CockpitStatsVO.Monitor monitor = BeanUtil.copyProperties(cockpitStats, CockpitStatsVO.Monitor.class); + monitor.setPasswordGradeCharts(buildPasswordGradeCharts(cockpitStats)); + monitor.setSecrecyGradeCharts(buildSecrecyGradeCharts(cockpitStats)); monitor.setMonitorSafetyInputRate(computeSafetyRate(regionCode)); return monitor; } /** * 安全投入 比 图 + * * @param regionCode * @return */ private List computeSafetyRate(String regionCode) { List cocks = cockpitStatsService.list(Wrappers.lambdaQuery(CockpitStats.class) .eq(StringUtils.isNotBlank(regionCode), CockpitStats::getRegionCode, regionCode) - .eq(StringUtils.isBlank(regionCode), CockpitStats::getRegionCode, DashboardConstant.CockpitStats.TOTAL) + .eq(StringUtils.isBlank(regionCode), CockpitStats::getRegionCode, TOTAL) .in(CockpitStats::getYear, years) .orderByAsc(CockpitStats::getYear)); return cocks.stream().map(c -> { CockpitStatsVO.SafetyInput safetyInput = new CockpitStatsVO.SafetyInput(); safetyInput.setYear(c.getYear()); safetyInput.setRate(Objects.nonNull(c.getMonitorDeclaredAmount()) && c.getMonitorDeclaredAmount().compareTo(BigDecimal.ZERO) > 0 ? - c.getMonitorSafetyInputAmount().multiply(BigDecimal.valueOf(100)).divide(c.getMonitorDeclaredAmount(),2, RoundingMode.CEILING): BigDecimal.ZERO); + c.getMonitorSafetyInputAmount().multiply(BigDecimal.valueOf(100)).divide(c.getMonitorDeclaredAmount(), 2, RoundingMode.CEILING) : BigDecimal.ZERO); return safetyInput; }).collect(Collectors.toList()); } - private List buidSecrecyGradeCharts(CockpitStats cockpitStats) { - List chars = Lists.newArrayList(); - chars.add(new CockpitStatsVO.SecrecyGradeChart(1,cockpitStats.getMonitorSecrecyGrade1Num())); - chars.add(new CockpitStatsVO.SecrecyGradeChart(2,cockpitStats.getMonitorSecrecyGrade2Num())); - chars.add(new CockpitStatsVO.SecrecyGradeChart(3,cockpitStats.getMonitorSecrecyGrade3Num())); - chars.add(new CockpitStatsVO.SecrecyGradeChart(4,cockpitStats.getMonitorSecrecyGrade4Num())); - chars.add(new CockpitStatsVO.SecrecyGradeChart(5,cockpitStats.getMonitorSecrecyGrade5Num())); + private List buildSecrecyGradeCharts(CockpitStats cockpitStats) { + List chars = Lists.newArrayList(); + chars.add(new SecrecyGradeChart(1, cockpitStats.getMonitorSecrecyGrade1Num())); + chars.add(new SecrecyGradeChart(2, cockpitStats.getMonitorSecrecyGrade2Num())); + chars.add(new SecrecyGradeChart(3, cockpitStats.getMonitorSecrecyGrade3Num())); + chars.add(new SecrecyGradeChart(4, cockpitStats.getMonitorSecrecyGrade4Num())); + chars.add(new SecrecyGradeChart(5, cockpitStats.getMonitorSecrecyGrade5Num())); return chars; } - private List buidPasswordGradeCharts(CockpitStats cockpitStats) { - List chars = Lists.newArrayList(); - chars.add(new CockpitStatsVO.PasswordGradeChart(1,cockpitStats.getMonitorPasswordGrade1Num())); - chars.add(new CockpitStatsVO.PasswordGradeChart(2,cockpitStats.getMonitorPasswordGrade2Num())); - chars.add(new CockpitStatsVO.PasswordGradeChart(3,cockpitStats.getMonitorPasswordGrade3Num())); - chars.add(new CockpitStatsVO.PasswordGradeChart(4,cockpitStats.getMonitorPasswordGrade4Num())); - chars.add(new CockpitStatsVO.PasswordGradeChart(5,cockpitStats.getMonitorPasswordGrade5Num())); + private List buildPasswordGradeCharts(CockpitStats cockpitStats) { + List chars = Lists.newArrayList(); + chars.add(new PasswordGradeChart(1, cockpitStats.getMonitorPasswordGrade1Num())); + chars.add(new PasswordGradeChart(2, cockpitStats.getMonitorPasswordGrade2Num())); + chars.add(new PasswordGradeChart(3, cockpitStats.getMonitorPasswordGrade3Num())); + chars.add(new PasswordGradeChart(4, cockpitStats.getMonitorPasswordGrade4Num())); + chars.add(new PasswordGradeChart(5, cockpitStats.getMonitorPasswordGrade5Num())); return chars; } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/EarlyWarningStatisticsManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/EarlyWarningStatisticsManage.java index 09e5009..122eac8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/EarlyWarningStatisticsManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/manage/EarlyWarningStatisticsManage.java @@ -71,7 +71,7 @@ public class EarlyWarningStatisticsManage { EarlyWarningStatisticsVO res = new EarlyWarningStatisticsVO(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class); - EarlyWarningUtil.buildPermissonWrapper(wrapper,user); + EarlyWarningUtil.buildPermissionWrapper(wrapper,user); List records = earlyWarningRecordsService.list(wrapper); //累积总告警数 res.setAccumulatedAlarmsTotal(records.size()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/model/vo/ProjectStatisticsVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/model/vo/ProjectStatisticsVO.java index 336507e..3a10d89 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/model/vo/ProjectStatisticsVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/dashboard/model/vo/ProjectStatisticsVO.java @@ -5,13 +5,11 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.io.Serializable; import java.util.List; @Data @ApiModel(value = "项目统计") -public class ProjectStatisticsVO implements Serializable { - private static final long serialVersionUID = 1L; +public class ProjectStatisticsVO { @ApiModelProperty("项目计划数") private Integer planTotal = 0; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/model/DataScopeDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/model/DataScopeDTO.java index fe34a59..697fa50 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/model/DataScopeDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/model/DataScopeDTO.java @@ -7,7 +7,7 @@ import java.util.List; /** *

- * DataScopeDto + * DataScopeDTO *

* * @author WendyYang @@ -18,14 +18,8 @@ public class DataScopeDTO { private RoleEnum role; - private List regionIds; - - private List regionCodes; - private String orgCode; - private String employeeCode; - private Long userId; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java index 3c05d8a..731b334 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/DashboardUserDataScopeProviderImpl.java @@ -1,6 +1,5 @@ package com.hz.pm.api.datascope.provider.impl; -import com.google.common.collect.Lists; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.provider.DataScopeProvider; @@ -30,23 +29,19 @@ public class DashboardUserDataScopeProviderImpl implements DataScopeProvider { @Override public Optional findDataFieldProperty() { - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); DataScopeDTO ds = new DataScopeDTO(); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); - ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); - ds.setUserId(userFullInfo.getUserId()); + ds.setUserId(user.getUserId()); ds.setRole(RoleEnum.DASHBOARD); - return Optional.ofNullable(ds); + return Optional.of(ds); } @Override public Optional findDataFieldProperty(Long userId) { - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId); DataScopeDTO ds = new DataScopeDTO(); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); - ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); - ds.setUserId(userFullInfo.getUserId()); + ds.setUserId(user.getUserId()); ds.setRole(RoleEnum.DASHBOARD); - return Optional.ofNullable(ds); + return Optional.of(ds); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertAdminDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertAdminDataScopeProviderImpl.java index a8682a4..4c82ce2 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertAdminDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertAdminDataScopeProviderImpl.java @@ -1,11 +1,8 @@ package com.hz.pm.api.datascope.provider.impl; -import com.ningdatech.basic.util.CollUtils; -import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.provider.DataScopeProvider; -import com.hz.pm.api.sys.model.dto.RegionDTO; import com.hz.pm.api.user.model.enumeration.RoleEnum; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.security.model.UserInfoDetails; @@ -13,9 +10,6 @@ import com.hz.pm.api.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import java.util.Collections; -import java.util.List; -import java.util.Objects; import java.util.Optional; /** @@ -30,25 +24,15 @@ import java.util.Optional; @RequiredArgsConstructor public class ExpertAdminDataScopeProviderImpl implements DataScopeProvider { - private final RegionCacheHelper regionCacheHelper; private final UserInfoHelper userInfoHelper; @Override public Optional findDataFieldProperty() { UserInfoDetails user = LoginUserUtil.loginUserDetail(); DataScopeDTO ds = new DataScopeDTO(); - if (Objects.isNull(user.getRegionLevel())) { - ds.setRegionIds(Collections.emptyList()); - ds.setRegionCodes(Collections.emptyList()); - } else { - List regions = regionCacheHelper.listChildren(user.getRegionCode(), user.getRegionLevel()); - ds.setRegionCodes(CollUtils.fieldList(regions, RegionDTO::getRegionCode)); - ds.setRegionIds(CollUtils.fieldList(regions, RegionDTO::getId)); - } ds.setRole(RoleEnum.EXPERT_ADMIN); ds.setUserId(user.getUserId()); - ds.setEmployeeCode(user.getEmployeeCode()); - ds.setOrgCode(user.getOrganizationCode()); + ds.setOrgCode(user.getMhUnitIdStr()); return Optional.of(ds); } @@ -56,18 +40,9 @@ public class ExpertAdminDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty(Long userId) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId); DataScopeDTO ds = new DataScopeDTO(); - if (Objects.isNull(user.getRegionLevel())) { - ds.setRegionIds(Collections.emptyList()); - ds.setRegionCodes(Collections.emptyList()); - } else { - List regions = regionCacheHelper.listChildren(user.getRegionCode(), user.getRegionLevel()); - ds.setRegionCodes(CollUtils.fieldList(regions, RegionDTO::getRegionCode)); - ds.setRegionIds(CollUtils.fieldList(regions, RegionDTO::getId)); - } ds.setRole(RoleEnum.EXPERT_ADMIN); ds.setUserId(user.getUserId()); - ds.setEmployeeCode(user.getEmployeeCode()); - ds.setOrgCode(user.getOrganizationCode()); + ds.setOrgCode(user.getMhUnitIdStr()); return Optional.of(ds); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertDataScopeProviderImpl.java index 4382699..cb0528b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/ExpertDataScopeProviderImpl.java @@ -1,6 +1,5 @@ package com.hz.pm.api.datascope.provider.impl; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.datascope.model.DataScopeDTO; @@ -12,9 +11,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import java.util.Collection; import java.util.Optional; -import java.util.stream.Collectors; /** *

@@ -36,30 +33,18 @@ public class ExpertDataScopeProviderImpl implements DataScopeProvider { @Override public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - //所有 丽水市的code - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_HZ, - RegionConst.RL_CITY); - DataScopeDTO ds = new DataScopeDTO(); - ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList())); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.EXPERT); - return Optional.ofNullable(ds); + return Optional.of(ds); } @Override public Optional findDataFieldProperty(Long userId) { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - //所有 丽水市的code - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_HZ, - RegionConst.RL_CITY); - DataScopeDTO ds = new DataScopeDTO(); - ds.setRegionCodes(regionCodes.stream().collect(Collectors.toList())); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.EXPERT); - return Optional.ofNullable(ds); + return Optional.of(ds); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/HigherUserDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/HigherUserDataScopeProviderImpl.java index e2eb72b..76ff250 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/HigherUserDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/HigherUserDataScopeProviderImpl.java @@ -1,9 +1,5 @@ package com.hz.pm.api.datascope.provider.impl; -import cn.hutool.core.collection.CollUtil; -import com.google.common.collect.Lists; -import com.hz.pm.api.common.model.constant.RegionConst; -import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.provider.DataScopeProvider; @@ -14,8 +10,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.Collection; import java.util.Optional; /** @@ -31,26 +25,14 @@ import java.util.Optional; @Component("HIGH_MEMBER") public class HigherUserDataScopeProviderImpl implements DataScopeProvider { - private final RegionCacheHelper regionCacheHelper; private final UserInfoHelper userInfoHelper; //和区域管理员一样 @Override public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - //借由 丽水市的code 来映射市本级的regionCode - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(), - RegionConst.RL_CITY); - //如果不是市本级的话 就直接放入本区域的县就好了 - if(CollUtil.isEmpty(regionCodes)){ - regionCodes = Lists.newArrayList(); - regionCodes.add(userFullInfo.getRegionCode()); - } - DataScopeDTO ds = new DataScopeDTO(); - ds.setRegionCodes(new ArrayList<>(regionCodes)); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.REGION_MANAGER); return Optional.of(ds); } @@ -59,18 +41,9 @@ public class HigherUserDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty(Long userId) { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); //借由 丽水市的code 来映射市本级的regionCode - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(), - RegionConst.RL_CITY); - //如果不是市本级的话 就直接放入本区域的县就好了 - if(CollUtil.isEmpty(regionCodes)){ - regionCodes = Lists.newArrayList(); - regionCodes.add(userFullInfo.getRegionCode()); - } DataScopeDTO ds = new DataScopeDTO(); - ds.setRegionCodes(new ArrayList<>(regionCodes)); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.REGION_MANAGER); return Optional.of(ds); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java index 7023b7f..bb45be9 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrdinaryUserDataScopeProviderImpl.java @@ -1,6 +1,5 @@ package com.hz.pm.api.datascope.provider.impl; -import com.google.common.collect.Lists; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.provider.DataScopeProvider; @@ -10,6 +9,7 @@ import com.hz.pm.api.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; + import java.util.Optional; /** @@ -31,21 +31,18 @@ public class OrdinaryUserDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); DataScopeDTO ds = new DataScopeDTO(); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); - ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); ds.setUserId(userFullInfo.getUserId()); ds.setRole(RoleEnum.NORMAL_MEMBER); - return Optional.ofNullable(ds); + return Optional.of(ds); } @Override public Optional findDataFieldProperty(Long userId) { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); DataScopeDTO ds = new DataScopeDTO(); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); - ds.setRegionCodes(Lists.newArrayList(userFullInfo.getRegionCode())); ds.setUserId(userFullInfo.getUserId()); ds.setRole(RoleEnum.NORMAL_MEMBER); - return Optional.ofNullable(ds); + return Optional.of(ds); } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java index f148a16..ea6ffab 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/OrgAdminDataScopeProviderImpl.java @@ -9,6 +9,7 @@ import com.hz.pm.api.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; + import java.util.Optional; /** @@ -30,9 +31,8 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); DataScopeDTO ds = new DataScopeDTO(); - ds.setOrgCode(userFullInfo.getEmpPosUnitCode()); + ds.setOrgCode(String.valueOf(userFullInfo.getMhUnitId())); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.COMPANY_MANAGER); return Optional.of(ds); } @@ -41,9 +41,8 @@ public class OrgAdminDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty(Long userId) { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); DataScopeDTO ds = new DataScopeDTO(); - ds.setOrgCode(userFullInfo.getEmpPosUnitCode()); + ds.setOrgCode(String.valueOf(userFullInfo.getMhUnitId())); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.COMPANY_MANAGER); return Optional.of(ds); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java index 4e68d35..e8a87b7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/RegionAdminDataScopeProviderImpl.java @@ -1,8 +1,5 @@ package com.hz.pm.api.datascope.provider.impl; -import cn.hutool.core.collection.CollUtil; -import com.google.common.collect.Lists; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.datascope.model.DataScopeDTO; @@ -14,8 +11,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.Collection; import java.util.Optional; /** @@ -37,19 +32,8 @@ public class RegionAdminDataScopeProviderImpl implements DataScopeProvider { @Override public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - //借由 丽水市的code 来映射市本级的regionCode - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(), - RegionConst.RL_CITY); - //如果不是市本级的话 就直接放入本区域的县就好了 - if(CollUtil.isEmpty(regionCodes)){ - regionCodes = Lists.newArrayList(); - regionCodes.add(userFullInfo.getRegionCode()); - } - DataScopeDTO ds = new DataScopeDTO(); - ds.setRegionCodes(new ArrayList<>(regionCodes)); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.REGION_MANAGER); return Optional.of(ds); } @@ -57,19 +41,8 @@ public class RegionAdminDataScopeProviderImpl implements DataScopeProvider { @Override public Optional findDataFieldProperty(Long userId) { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - //借由 丽水市的code 来映射市本级的regionCode - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(userFullInfo.getRegionCode(), - RegionConst.RL_CITY); - //如果不是市本级的话 就直接放入本区域的县就好了 - if(CollUtil.isEmpty(regionCodes)){ - regionCodes = Lists.newArrayList(); - regionCodes.add(userFullInfo.getRegionCode()); - } - DataScopeDTO ds = new DataScopeDTO(); - ds.setRegionCodes(new ArrayList<>(regionCodes)); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.REGION_MANAGER); return Optional.of(ds); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java index 8205ed4..0b131c7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/SuperAdminDataScopeProviderImpl.java @@ -1,6 +1,5 @@ package com.hz.pm.api.datascope.provider.impl; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.datascope.model.DataScopeDTO; @@ -12,8 +11,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.Collection; import java.util.Optional; /** @@ -37,13 +34,8 @@ public class SuperAdminDataScopeProviderImpl implements DataScopeProvider { public Optional findDataFieldProperty() { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); //所有 丽水市的code - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_HZ, - RegionConst.RL_CITY); - DataScopeDTO ds = new DataScopeDTO(); - ds.setRegionCodes(new ArrayList<>(regionCodes)); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.SUPER_ADMIN); return Optional.of(ds); } @@ -51,14 +43,8 @@ public class SuperAdminDataScopeProviderImpl implements DataScopeProvider { @Override public Optional findDataFieldProperty(Long userId) { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - //所有 丽水市的code - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(RegionConst.RC_HZ, - RegionConst.RL_CITY); - DataScopeDTO ds = new DataScopeDTO(); - ds.setRegionCodes(new ArrayList<>(regionCodes)); ds.setUserId(userFullInfo.getUserId()); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.SUPER_ADMIN); return Optional.of(ds); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitoyDataScopeProviderImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitorDataScopeProviderImpl.java similarity index 57% rename from hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitoyDataScopeProviderImpl.java rename to hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitorDataScopeProviderImpl.java index 5ae6341..173136d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitoyDataScopeProviderImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/datascope/provider/impl/VisitorDataScopeProviderImpl.java @@ -1,14 +1,12 @@ package com.hz.pm.api.datascope.provider.impl; -import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.provider.DataScopeProvider; import com.hz.pm.api.user.model.enumeration.RoleEnum; -import com.hz.pm.api.user.security.model.UserFullInfoDTO; -import com.hz.pm.api.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; + import java.util.Optional; /** @@ -22,24 +20,19 @@ import java.util.Optional; @Slf4j @RequiredArgsConstructor @Component("VISITOR") -public class VisitoyDataScopeProviderImpl implements DataScopeProvider { - private final UserInfoHelper userInfoHelper; +public class VisitorDataScopeProviderImpl implements DataScopeProvider { @Override public Optional findDataFieldProperty() { - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); DataScopeDTO ds = new DataScopeDTO(); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.SUPER_ADMIN); - return Optional.ofNullable(ds); + return Optional.of(ds); } @Override public Optional findDataFieldProperty(Long userId) { - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); DataScopeDTO ds = new DataScopeDTO(); - ds.setEmployeeCode(userFullInfo.getEmployeeCode()); ds.setRole(RoleEnum.SUPER_ADMIN); - return Optional.ofNullable(ds); + return Optional.of(ds); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/ding/task/EmployeeBatchGetTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/ding/task/EmployeeBatchGetTask.java index 2f6409f..e63d828 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/ding/task/EmployeeBatchGetTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/ding/task/EmployeeBatchGetTask.java @@ -5,17 +5,16 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; -import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.GenericResult; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.ding.constants.DingOrganizationContant; import com.hz.pm.api.organization.model.entity.DingEmployeeInfo; import com.hz.pm.api.organization.model.entity.DingOrganization; import com.hz.pm.api.organization.service.IDingEmployeeInfoService; import com.hz.pm.api.organization.service.IDingOrganizationService; -import com.hz.pm.api.user.model.enumeration.UserAvailableEnum; import com.hz.pm.api.user.model.entity.UserInfo; import com.hz.pm.api.user.service.IUserInfoService; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.GenericResult; import com.ningdatech.zwdd.ZwddIntegrationProperties; import com.ningdatech.zwdd.client.ZwddAuthClient; import com.ningdatech.zwdd.client.ZwddClient; @@ -25,9 +24,9 @@ import com.ningdatech.zwdd.model.dto.EmployeeInfoDTO; import com.ningdatech.zwdd.model.query.PageOrganizationEmployeePositionsQuery; import com.ningdatech.zwdd.model.response.OrganizationEmployeePosition; import com.ningdatech.zwdd.model.response.OrganizationEmployeePosition.GovEmployeePosition; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -40,49 +39,42 @@ import java.util.stream.Collectors; * @date 2023/2/10 上午9:52 */ -@Component @Slf4j +@Component +@RequiredArgsConstructor public class EmployeeBatchGetTask { - private final static Integer PAGE_SIZE = 20; + private static final int PAGE_SIZE = 20; + private static final int GROUP_SIZE = 100; + private static final long MAX_SIZE = 10000; - private final static Integer GROUP_SIZE = 100; + //================================================================================================================== - private final static Integer MAX_SIZE = 10000; + private final ZwddClient zwddClient; + private final ZwddAuthClient zwddAuthClient; + private final IDingOrganizationService dingOrganizationService; + private final IDingEmployeeInfoService dingEmployeeInfoService; + private final ZwddIntegrationProperties zwddIntegrationProperties; + private final IUserInfoService userInfoService; - @Autowired - private ZwddClient zwddClient; - - @Autowired - private ZwddAuthClient zwddAuthClient; - - @Autowired - private IDingOrganizationService iDingOrganizationService; - - @Autowired - private IDingEmployeeInfoService iDingEmployeeInfoService; - - @Autowired - private ZwddIntegrationProperties zwddIntegrationProperties; - - @Autowired - private IUserInfoService iUserInfoService; + //================================================================================================================== @Transactional(rollbackFor = Exception.class) // @Scheduled(cron = "0 0 1 * * ?") public void batchGetEmployeeTask() { - // 获取所有的组织列表用户获取组织下的 用户信息(暂时 只查 单位的类型) - List dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) - .eq(DingOrganization::getTypeCode, DingOrganizationContant.UNIT_TYPE)); + // 获取所有的组织列表用户获取组织下的 用户信息(暂时只查单位的类型) + List dingOrganizationList = dingOrganizationService.list( + Wrappers.lambdaQuery(DingOrganization.class) + .eq(DingOrganization::getTypeCode, DingOrganizationContant.UNIT_TYPE)); log.info("所有待更新员工的单位数:{}", dingOrganizationList.size()); if (CollUtil.isNotEmpty(dingOrganizationList)) { //记录任务 单位数 Integer index = 0; - for (DingOrganization dingOrganization : dingOrganizationList) { - log.info("当前单位:{},下标数,{}", dingOrganization.getOrganizationName(), index); + for (DingOrganization dingOrg : dingOrganizationList) { + log.info("当前单位:{},下标数,{}", dingOrg.getOrganizationName(), index); index++; List allOrganizationEmployeePositionList = new ArrayList<>(); - String organizationCode = dingOrganization.getOrganizationCode(); + String organizationCode = dingOrg.getOrganizationCode(); PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); query.setEmployeeStatus("A"); query.setOrganizationCode(organizationCode); @@ -104,13 +96,13 @@ public class EmployeeBatchGetTask { } Long totalSize = data.getTotalSize(); - log.info("dingOrganization :{}", JSON.toJSONString(dingOrganization)); + log.info("dingOrg :{}", JSON.toJSONString(dingOrg)); - log.info("totalSize :{},{}", totalSize, dingOrganization.getOrganizationName()); + log.info("totalSize :{},{}", totalSize, dingOrg.getOrganizationName()); if (totalSize > PAGE_SIZE) { if (totalSize > MAX_SIZE) { //超过1万 按1万的处理 - totalSize = MAX_SIZE.longValue(); + totalSize = MAX_SIZE; } int restPageNo = totalSize % PAGE_SIZE > 0 ? 1 : 0; @@ -118,7 +110,6 @@ public class EmployeeBatchGetTask { for (pageNo = 2; pageNo <= maxPageNo; pageNo++) { query.setPageNo(pageNo); GenericResult> pageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); -// log.info("pageGenericResult :{}", JSON.toJSONString(pageGenericResult)); if (pageGenericResult.isSuccess()) { allOrganizationEmployeePositionList.addAll(pageGenericResult.getData().getData()); } else { @@ -216,57 +207,21 @@ public class EmployeeBatchGetTask { } } - List organizations = iDingOrganizationService.list(); + List organizations = dingOrganizationService.list(); Map organizationMap = organizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode, o -> o)); for (DingEmployeeInfo dingEmployeeInfo : saveList) { String employeeCode = dingEmployeeInfo.getEmployeeCode(); - DingEmployeeInfo employeeInfo = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) + DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) .eq(DingEmployeeInfo::getEmployeeCode, employeeCode) .last(BizConst.LIMIT_1)); if (Objects.isNull(employeeInfo)) { - iDingEmployeeInfoService.save(dingEmployeeInfo); + dingEmployeeInfoService.save(dingEmployeeInfo); } else { dingEmployeeInfo.setId(employeeInfo.getId()); - iDingEmployeeInfoService.saveOrUpdate(dingEmployeeInfo); + dingEmployeeInfoService.saveOrUpdate(dingEmployeeInfo); } - generateOrUpdateUserInfo(dingEmployeeInfo, organizationMap); - } - } - - public void generateOrUpdateUserInfo(DingEmployeeInfo dingEmployeeInfo, Map organizationMap) { - String employeeCode = dingEmployeeInfo.getEmployeeCode(); - UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) - .eq(UserInfo::getEmployeeCode, employeeCode)); - if (Objects.isNull(userInfo)) { - userInfo = new UserInfo(); - userInfo.setAccountId(dingEmployeeInfo.getAccountId()); - userInfo.setUsername(dingEmployeeInfo.getEmployeeName()); - userInfo.setRealName(dingEmployeeInfo.getEmployeeName()); - userInfo.setEmployeeCode(dingEmployeeInfo.getEmployeeCode()); - userInfo.setAvailable(UserAvailableEnum.DISABLE.name()); - userInfo.setCreateBy(-1L); - userInfo.setUpdateBy(-1L); - userInfo.setCreateOn(LocalDateTime.now()); - userInfo.setUpdateOn(LocalDateTime.now()); - userInfo.setEmpPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode()); - userInfo.setAvatar(dingEmployeeInfo.getAvatar()); - if (StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())) { - DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode()); - userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); - userInfo.setRegionCode(dingOrganization.getDivisionCode()); - } - iUserInfoService.save(userInfo); - } else { - userInfo.setAvatar(dingEmployeeInfo.getAvatar()); - userInfo.setEmpPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode()); - if (StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())) { - DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode()); - userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); - userInfo.setRegionCode(dingOrganization.getDivisionCode()); - } - iUserInfoService.updateById(userInfo); } } @@ -276,7 +231,7 @@ public class EmployeeBatchGetTask { * @param regionCode */ public void batchGetEmployeeTaskByRegionCode(String regionCode) { - List units = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) + List units = dingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) .eq(DingOrganization::getTypeCode, DingOrganizationContant.UNIT_TYPE) .eq(DingOrganization::getDivisionCode, regionCode)); @@ -317,7 +272,7 @@ public class EmployeeBatchGetTask { if (totalSize > PAGE_SIZE) { if (totalSize > MAX_SIZE) { //超过1万 按1万的处理 - totalSize = MAX_SIZE.longValue(); + totalSize = MAX_SIZE; } int restPageNo = totalSize % PAGE_SIZE > 0 ? 1 : 0; @@ -325,7 +280,6 @@ public class EmployeeBatchGetTask { for (pageNo = 2; pageNo <= maxPageNo; pageNo++) { query.setPageNo(pageNo); GenericResult> pageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); -// log.info("pageGenericResult :{}", JSON.toJSONString(pageGenericResult)); if (pageGenericResult.isSuccess()) { allOrganizationEmployeePositionList.addAll(pageGenericResult.getData().getData()); } else { @@ -354,17 +308,16 @@ public class EmployeeBatchGetTask { } public void batchGetEmployeeTaskByOrdCode(String orgCode) { - DingOrganization org = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) + DingOrganization org = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) .eq(DingOrganization::getOrganizationCode, orgCode) .last(BizConst.LIMIT_1)); VUtils.isTrue(Objects.isNull(org)).throwMessage("单位不存在"); log.info("所属单位 {} 要更新员工信息了", org.getOrganizationName()); List allOrganizationEmployeePositionList = new ArrayList<>(); - String organizationCode = orgCode; PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); query.setEmployeeStatus("A"); - query.setOrganizationCode(organizationCode); + query.setOrganizationCode(orgCode); query.setReturnTotalSize(true); query.setTenantId(zwddIntegrationProperties.getTenantId()); int pageNo = 1; @@ -375,7 +328,7 @@ public class EmployeeBatchGetTask { GenericResult> firstPageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); Page data = firstPageGenericResult.getData(); if (Objects.isNull(data)) { - log.info("响应为空:{}", organizationCode); + log.info("响应为空:{}", orgCode); return; } if (CollUtil.isNotEmpty(data.getData())) { @@ -389,7 +342,7 @@ public class EmployeeBatchGetTask { if (totalSize > PAGE_SIZE) { if (totalSize > MAX_SIZE) { //超过1万 按1万的处理 - totalSize = MAX_SIZE.longValue(); + totalSize = MAX_SIZE; } int restPageNo = totalSize % PAGE_SIZE > 0 ? 1 : 0; @@ -444,22 +397,22 @@ public class EmployeeBatchGetTask { return; } - DingEmployeeInfo emp = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) + DingEmployeeInfo emp = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) .eq(DingEmployeeInfo::getEmployeeCode, empCode) .last(BizConst.LIMIT_1)); if (Objects.nonNull(emp)) { emp.setAvatar(data.getGovEmpAvatar()); - iDingEmployeeInfoService.updateById(emp); + dingEmployeeInfoService.updateById(emp); } - UserInfo user = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getEmployeeCode, empCode) .last(BizConst.LIMIT_1)); if (Objects.nonNull(user)) { user.setAvatar(data.getGovEmpAvatar()); - iUserInfoService.updateById(user); + userInfoService.updateById(user); } } @@ -470,7 +423,7 @@ public class EmployeeBatchGetTask { */ public void getBatchEmployeeByCode(String orgCode) { - List employees = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) + List employees = dingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) .eq(DingEmployeeInfo::getEmpPosUnitCode, orgCode)); for (DingEmployeeInfo employee : employees) { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/model/SensitiveModifySegment.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/model/SensitiveModifySegment.java index 7748dcf..6727739 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/model/SensitiveModifySegment.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/model/SensitiveModifySegment.java @@ -78,7 +78,7 @@ public class SensitiveModifySegment { return false; } for (SensitiveModifySegment segment : segmentList) { - if (!segment.isValueEquals()) { + if (Boolean.FALSE.equals(segment.isValueEquals())) { return true; } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/sms/SmsServiceClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/sms/SmsServiceClient.java index cbb8a04..d8135d5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/sms/SmsServiceClient.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/sms/SmsServiceClient.java @@ -56,7 +56,7 @@ public class SmsServiceClient { * @return */ public SmsDto smsSend(String content, List phones) { - String phonesSplit = String.join(",", phones);; + String phonesSplit = String.join(",", phones); String refreshUrl = smsUrl + SMS_SEND; Map map = new HashMap<>(); map.put("content",content); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java index 416e5fd..ddb2ff9 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java @@ -54,11 +54,8 @@ public class TodoServiceClient { map.put("wkType",addSingleWkHandleDTO.getWkType()); map.put("wkUser",addSingleWkHandleDTO.getWkUser()); String responseResult = HttpUtil.post(url, JSON.toJSONString(map)); - TodoDto todoDto = JSON.parseObject(responseResult, new TypeReference() { + return JSON.parseObject(responseResult, new TypeReference() { }); -// return JSON.parseObject(responseResult, new TypeReference>() { -// }).get("data"); - return todoDto; } /** @@ -74,9 +71,8 @@ public class TodoServiceClient { .form("wkhandleId",wkhandleId); HttpResponse response = request.execute(); String responseBody = response.body(); - TodoDto todoDto = JSON.parseObject(responseBody, new TypeReference() { + return JSON.parseObject(responseBody, new TypeReference() { }); - return todoDto; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java index 5ed6fb2..ebc4dca 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java @@ -13,9 +13,7 @@ import java.io.Serializable; @Data @AllArgsConstructor @NoArgsConstructor -public class AddSingleWkHandleDTO implements Serializable { - - private static final long serialVersionUID = -2067546352159912820L; +public class AddSingleWkHandleDTO { // 待办参数,ObjectJson字符串 private Object params; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/manage/ProjectFileManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/manage/ProjectFileManage.java index 8ee17e6..a2e0980 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/manage/ProjectFileManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/manage/ProjectFileManage.java @@ -5,9 +5,13 @@ import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; +import com.hz.pm.api.common.util.StrUtils; +import com.hz.pm.api.user.helper.MhUnitCache; +import com.hz.pm.api.user.model.dto.MhUnitDTO; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; @@ -106,7 +110,6 @@ public class ProjectFileManage { private final IProjectInstService projectInstService; private final HistoryService historyService; private final INdProjectApplyBorrowService projectApplyBorrowService; - private final IDingOrganizationService dingOrganizationService; private final IProjectApplicationService projectApplicationService; private final TaskService taskService; private final IPurchaseService purchaseService; @@ -116,69 +119,70 @@ public class ProjectFileManage { private final PurchaseManage purchaseManage; private final ConstructionManage constructionManage; private final FinalAcceptanceManage finalAcceptanceManage; + private final MhUnitCache mhUnitCache; - public PageVo list(ProjectFileListParam param) { - - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = userFullInfo.getEmployeeCode(); - String empPosUnitCode = userFullInfo.getEmpPosUnitCode(); + public PageVo list(ProjectFileListParam req) { + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - Page page = param.page(); - projectService.page(page, Wrappers.lambdaQuery(Project.class) - .like(StringUtils.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName()) - .like(StringUtils.isNotBlank(param.getBuildOrgName()), Project::getBuildOrgName, param.getBuildOrgName()) + LambdaQueryWrapper query = Wrappers.lambdaQuery(Project.class) + .like(StrUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()) + .like(StrUtils.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName()) .eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode()) - .orderByDesc(Project::getUpdateOn)); - + .orderByDesc(Project::getUpdateOn); + Page page = projectService.page(req.page(), query); if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } - // 获取本单位及下属单位的单位code - Set subOrgSet = getSubOrgList(empPosUnitCode); + List subOrgSet = getSubOrgList(user.getMhUnitId()); List vos = page.getRecords().stream().map(p -> { ProjectFileListVO vo = new ProjectFileListVO(); vo.setId(p.getId()); // 用户只可查阅自己及下属单位的项目档案和已经申请借阅通过的项目档案 - if (subOrgSet.contains(p.getBuildOrgCode()) || checkCanRead(subOrgSet, p)) { + if (StrUtils.isBlank(p.getBuildOrgCode()) + || subOrgSet.contains(Long.parseLong(p.getBuildOrgCode())) + || checkCanRead(subOrgSet, p)) { vo.setCanRead(Boolean.TRUE); } vo.setBuildOrgName(p.getBuildOrgName()); vo.setPojectCode(p.getProjectCode()); vo.setProjectName(p.getProjectName()); // 判断当前项目,当前登录用户是否已经开启了申请借阅并且没有审批完成 - ProjectApplyBorrow projectApplyBorrow = projectApplyBorrowService.getOne(Wrappers.lambdaQuery(ProjectApplyBorrow.class) - .eq(ProjectApplyBorrow::getApplyBorrowEmployeeCode, employeeCode) + ProjectApplyBorrow projectApplyBorrow = projectApplyBorrowService.getOne(Wrappers + .lambdaQuery(ProjectApplyBorrow.class) + .eq(ProjectApplyBorrow::getApplyBorrowUserId, user.getUserId()) .eq(ProjectApplyBorrow::getProjectId, p.getId()) .orderByDesc(ProjectApplyBorrow::getCreateOn) .last("limit 1")); if (Objects.nonNull(projectApplyBorrow)) { String instCode = projectApplyBorrow.getInstanceId(); // 获取流程实例 - HistoricProcessInstance newInstance = - historyService.createHistoricProcessInstanceQuery().processInstanceId(instCode).singleResult(); + HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery() + .processInstanceId(instCode) + .singleResult(); if (newInstance == null) { vo.setCanApplyBorrow(Boolean.FALSE); return vo; } - ProjectInst projectInst = projectInstService - .getOne(Wrappers.lambdaQuery(ProjectInst.class).eq(ProjectInst::getInstCode, instCode)); + ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) + .eq(ProjectInst::getInstCode, instCode)); // 推送省局联审的项目流程实例为EMPTY if (Objects.nonNull(projectInst)) { Integer instType = projectInst.getInstType(); // 从申请借阅信息表中查询当前项目是否有当前登录用户发起的申请借阅审批流程 ProjectApplyBorrow applyBorrow = projectApplyBorrowService.getOne(Wrappers - .lambdaQuery(ProjectApplyBorrow.class).eq(ProjectApplyBorrow::getApplyBorrowEmployeeCode, employeeCode) - .eq(ProjectApplyBorrow::getProjectId, p.getId()).eq(ProjectApplyBorrow::getInstanceId, instCode)); + .lambdaQuery(ProjectApplyBorrow.class) + .eq(ProjectApplyBorrow::getApplyBorrowUserId, user.getUserId()) + .eq(ProjectApplyBorrow::getProjectId, p.getId()) + .eq(ProjectApplyBorrow::getInstanceId, instCode)); // 延期申请流程还未审核结束 if (Objects.nonNull(applyBorrow) && InstTypeEnum.APPLY_BORROW.getCode().equals(instType) && Objects.isNull(newInstance.getEndActivityId())) { vo.setCanApplyBorrow(Boolean.FALSE); - } - // 如果是延期申请审核被驳回,设置项目可以申请延期申报 - else if (InstTypeEnum.APPLY_BORROW.getCode().equals(instType) && + } else if (InstTypeEnum.APPLY_BORROW.getCode().equals(instType) && HisProInsEndActId.REJECT.equals(newInstance.getEndActivityId())) { + // 如果是延期申请审核被驳回,设置项目可以申请延期申报 vo.setCanApplyBorrow(Boolean.TRUE); } } @@ -189,39 +193,30 @@ public class ProjectFileManage { return PageVo.of(vos, page.getTotal()); } - private boolean checkCanRead(Set subOrgSet, Project project) { + private boolean checkCanRead(List subOrgSet, Project project) { // 从申请借阅信息表中查出本单位及下属单位审批通过的项目 HashSet borrowProjectIdSet = new HashSet<>(); List applyBorrowProjectIdList = projectApplyBorrowService .list(Wrappers.lambdaQuery(ProjectApplyBorrow.class) - .in(ProjectApplyBorrow::getApplyBorrowEmpPosUnitCode, subOrgSet) + .in(ProjectApplyBorrow::getApplyBorrowOrgCode, subOrgSet) .eq(ProjectApplyBorrow::getIsSuccess, Boolean.TRUE)) - .stream().map(ProjectApplyBorrow::getProjectId).filter(borrowProjectIdSet::add).collect(Collectors.toList()); + .stream().map(ProjectApplyBorrow::getProjectId) + .filter(borrowProjectIdSet::add) + .collect(Collectors.toList()); return applyBorrowProjectIdList.contains(project.getId()); } - private Set getSubOrgList(String empPosUnitCode) { - HashSet orgSet = new HashSet<>(); - // 先将自己加入子集 - orgSet.add(empPosUnitCode); - Set subOrgList = dingOrganizationService - .list(Wrappers.lambdaQuery(DingOrganization.class).eq(DingOrganization::getParentCode, empPosUnitCode)) - .stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toSet()); - // 遍历子集 - for (String orgCode : subOrgList) { - orgSet.addAll(getSubOrgList(orgCode)); - } - return orgSet; + private List getSubOrgList(Long mhUnitId) { + List childIds = mhUnitCache.getChildrenIdsRecursion(mhUnitId); + childIds.add(mhUnitId); + return childIds; } public ProjectFileVO file(Long projectId) { - - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String empPosUnitCode = userFullInfo.getEmpPosUnitCode(); - + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); // 判断该项目是否为本单位或下属单位的项目或者已经申请借阅成功的项目 Project project = projectService.getById(projectId); - Set subOrgList = getSubOrgList(empPosUnitCode); + List subOrgList = getSubOrgList(user.getMhUnitId()); if (!checkCanRead(subOrgList, project)) { throw new BizException("您没有权限查看此项目档案!"); @@ -253,28 +248,22 @@ public class ProjectFileManage { public String startApplyBorrowProcess(Long projectId) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); - Project project = projectService.getNewProject(projectId); VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!"); // 首先要判断 项目当前状态 是不是 已归档 VUtils.isTrue(!ProjectStatusEnum.ACCEPTED.getCode().equals(project.getStatus())).throwMessage("提交失败 该项目不是 已归档"); - String regionCode = user.getRegionCode(); - WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) - .eq(WflowModels::getRegionCode, regionCode) - .eq(WflowModels::getProcessType, ProjectProcessStageEnum.APPLY_BORROW.getCode()).last(BizConst.LIMIT_1)); + .eq(WflowModels::getProcessType, ProjectProcessStageEnum.APPLY_BORROW.getCode()) + .last(BizConst.LIMIT_1)); if (Objects.isNull(model)) { - log.error("此 【{}】区域找不到申请借阅流程配置", regionCode); - throw new BusinessException(String.format("此 【%s】区域找不到申请借阅流程配置", regionCode)); + throw new BusinessException("找不到申请借阅流程配置"); } ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); + params.setUser(defaultDeclaredProjectManage.buildUser(user.getUserId())); params.setProcessUsers(Collections.emptyMap()); // 放入条件判断的项目字段 // 把条件值给放入工作流 @@ -544,19 +533,15 @@ public class ProjectFileManage { } ProjectApplyBorrowVO vo = BeanUtil.copyProperties(apply, ProjectApplyBorrowVO.class); - if (StringUtils.isNotBlank(vo.getApplyBorrowEmployeeCode())) { - UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(vo.getApplyBorrowEmployeeCode()); + if (StrUtils.isNotBlank(vo.getApplyBorrowUserId())) { + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(Long.valueOf(vo.getApplyBorrowUserId())); if (Objects.nonNull(user)) { - vo.setApplyBorrowEmployeeName(user.getUsername()); + vo.setApplyBorrowUserName(user.getUsername()); } } - if (StringUtils.isNotBlank(vo.getApplyBorrowEmpPosUnitCode())) { - DingOrganization organization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) - .eq(DingOrganization::getOrganizationCode, vo.getApplyBorrowEmpPosUnitCode()) - .last(BizConst.LIMIT_1)); - if (Objects.nonNull(organization)) { - vo.setApplyBorrowEmpPosUnitName(organization.getOrganizationName()); - } + if (StrUtils.isNotBlank(vo.getApplyBorrowOrgCode())) { + MhUnitDTO mhUnit = mhUnitCache.getById(Long.parseLong(vo.getApplyBorrowOrgCode())); + vo.setApplyBorrowOrgName(mhUnit.getName()); } if (Objects.nonNull(vo.getProjectId())) { Project project = projectService.getById(vo.getProjectId()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/entity/ProjectApplyBorrow.java b/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/entity/ProjectApplyBorrow.java index 592112b..a531103 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/entity/ProjectApplyBorrow.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/entity/ProjectApplyBorrow.java @@ -32,10 +32,10 @@ public class ProjectApplyBorrow implements Serializable { private Long projectId; @ApiModelProperty("申请借阅员工code") - private String applyBorrowEmployeeCode; + private String applyBorrowUserId; @ApiModelProperty("申请借阅用户任职单位code") - private String applyBorrowEmpPosUnitCode; + private String applyBorrowOrgCode; @ApiModelProperty("申请借阅审批流程ID") private String instanceId; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/vo/ProjectApplyBorrowVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/vo/ProjectApplyBorrowVO.java index f11ac43..a12d80e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/vo/ProjectApplyBorrowVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/filemanage/model/vo/ProjectApplyBorrowVO.java @@ -31,16 +31,16 @@ public class ProjectApplyBorrowVO implements Serializable { private String projectName; @ApiModelProperty("申请借阅员工code") - private String applyBorrowEmployeeCode; + private String applyBorrowUserId; @ApiModelProperty("申请借阅员工名字") - private String applyBorrowEmployeeName; + private String applyBorrowUserName; @ApiModelProperty("申请借阅用户任职单位code") - private String applyBorrowEmpPosUnitCode; + private String applyBorrowOrgCode; @ApiModelProperty("申请借阅用户任职单位") - private String applyBorrowEmpPosUnitName; + private String applyBorrowOrgName; @ApiModelProperty("申请借阅审批流程ID") private String instanceId; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/controller/CompanyFiscalCodeController.java b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/controller/CompanyFiscalCodeController.java index dab39b4..1d54af5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/controller/CompanyFiscalCodeController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/controller/CompanyFiscalCodeController.java @@ -3,9 +3,9 @@ package com.hz.pm.api.fiscal.controller; import com.ningdatech.log.annotation.WebLog; import com.hz.pm.api.fiscal.manage.CompanyFiscalCodeManage; -import com.hz.pm.api.fiscal.model.po.ReqCompanyFiscalCodeAndSealSnPO; +import com.hz.pm.api.fiscal.model.po.CompanyFiscalCodeAndSealSnReq; import com.hz.pm.api.fiscal.model.po.ReqGetCompanyFiscalCodeAndSealSnPO; -import com.hz.pm.api.fiscal.model.vo.ResCompanyFiscalCodeAndSealSnVO; +import com.hz.pm.api.fiscal.model.vo.CompanyFiscalCodeAndSealSnVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -35,13 +35,13 @@ public class CompanyFiscalCodeController { @ApiOperation(value = "财政编码-配置", notes = "财政编码配置") @PostMapping("/fiscal-and-seal/configure") @WebLog("财政编码-配置") - public void fiscalAndSealCodeConfigure(@Valid @RequestBody ReqCompanyFiscalCodeAndSealSnPO reqCompanyFiscalCodeAndSealSnPO) { - companyFiscalCodeManage.fiscalCodeConfigure(reqCompanyFiscalCodeAndSealSnPO); + public void fiscalAndSealCodeConfigure(@Valid @RequestBody CompanyFiscalCodeAndSealSnReq companyFiscalCodeAndSealSnReq) { + companyFiscalCodeManage.fiscalCodeConfigure(companyFiscalCodeAndSealSnReq); } @ApiOperation(value = "获取财政编码-配置", notes = "获取财政编码配置") @PostMapping("/fiscal-and-seal/get-configure") - public ResCompanyFiscalCodeAndSealSnVO getFiscalAndSealCodeConfigure(@Valid @RequestBody ReqGetCompanyFiscalCodeAndSealSnPO request) { + public CompanyFiscalCodeAndSealSnVO getFiscalAndSealCodeConfigure(@Valid @RequestBody ReqGetCompanyFiscalCodeAndSealSnPO request) { return companyFiscalCodeManage.getFiscalCodeConfigure(request); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/manage/CompanyFiscalCodeManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/manage/CompanyFiscalCodeManage.java index 935d18c..c6eb529 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/manage/CompanyFiscalCodeManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/manage/CompanyFiscalCodeManage.java @@ -1,16 +1,17 @@ package com.hz.pm.api.fiscal.manage; import com.hz.pm.api.common.helper.UserInfoHelper; +import com.hz.pm.api.common.util.StrUtils; import com.hz.pm.api.fiscal.entity.CompanyFiscalCode; -import com.hz.pm.api.fiscal.model.po.ReqCompanyFiscalCodeAndSealSnPO; +import com.hz.pm.api.fiscal.model.po.CompanyFiscalCodeAndSealSnReq; import com.hz.pm.api.fiscal.model.po.ReqGetCompanyFiscalCodeAndSealSnPO; -import com.hz.pm.api.fiscal.model.vo.ResCompanyFiscalCodeAndSealSnVO; +import com.hz.pm.api.fiscal.model.vo.CompanyFiscalCodeAndSealSnVO; import com.hz.pm.api.fiscal.service.ICompanyFiscalCodeService; import com.hz.pm.api.signature.entity.CompanySignature; import com.hz.pm.api.signature.service.ICompanySignatureService; +import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import java.time.LocalDateTime; @@ -30,58 +31,59 @@ public class CompanyFiscalCodeManage { private final ICompanySignatureService iCompanySignatureService; - public void fiscalCodeConfigure(ReqCompanyFiscalCodeAndSealSnPO reqCompanyFiscalCodeAndSealSnPO) { - Long userId = LoginUserUtil.getUserId(); - - String organizationCode = reqCompanyFiscalCodeAndSealSnPO.getOrganizationCode(); - if (StringUtils.isBlank(organizationCode)) { - organizationCode = userInfoHelper.getUserEmpPosUnitCode(userId); + public void fiscalCodeConfigure(CompanyFiscalCodeAndSealSnReq req) { + UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + String temOrgCode; + if (StrUtils.isBlank(req.getOrganizationCode())) { + temOrgCode = String.valueOf(userDetail.getMhUnitId()); + } else { + temOrgCode = req.getOrganizationCode(); } // TODO 校验用户权限 - // 保存财政编码配置 - CompanyFiscalCode companyFiscalCode = iCompanyFiscalCodeService.getByOrganizationCode(organizationCode); + CompanyFiscalCode companyFiscalCode = iCompanyFiscalCodeService.getByOrganizationCode(temOrgCode); if (Objects.isNull(companyFiscalCode)) { companyFiscalCode = new CompanyFiscalCode(); - companyFiscalCode.setOrganizationCode(organizationCode); + companyFiscalCode.setOrganizationCode(temOrgCode); companyFiscalCode.setCreateOn(LocalDateTime.now()); - companyFiscalCode.setCreateBy(userId); + companyFiscalCode.setCreateBy(userDetail.getUserId()); } - String fiscalCode = reqCompanyFiscalCodeAndSealSnPO.getFiscalCode(); + String fiscalCode = req.getFiscalCode(); companyFiscalCode.setFiscalCode(fiscalCode); companyFiscalCode.setUpdateOn(LocalDateTime.now()); - companyFiscalCode.setUpdateBy(userId); + companyFiscalCode.setUpdateBy(userDetail.getUserId()); iCompanyFiscalCodeService.saveOrUpdate(companyFiscalCode); // 保存印章配置 - CompanySignature companySignature = iCompanySignatureService.getByOrganizationCode(organizationCode); - if (Objects.isNull(companySignature)) { - companySignature = new CompanySignature(); - companySignature.setOrganizationCode(organizationCode); - companySignature.setCreateOn(LocalDateTime.now()); + CompanySignature signature = iCompanySignatureService.getByOrganizationCode(temOrgCode); + if (Objects.isNull(signature)) { + signature = new CompanySignature(); + signature.setOrganizationCode(temOrgCode); + signature.setCreateOn(LocalDateTime.now()); } - String sealSn = reqCompanyFiscalCodeAndSealSnPO.getSealSn(); - companySignature.setSealSn(sealSn); - companySignature.setUpdateOn(LocalDateTime.now()); - companySignature.setCreateBy(userId); - companySignature.setUpdateBy(userId); - iCompanySignatureService.saveOrUpdate(companySignature); + String sealSn = req.getSealSn(); + signature.setSealSn(sealSn); + signature.setUpdateOn(LocalDateTime.now()); + signature.setCreateBy(userDetail.getUserId()); + signature.setUpdateBy(userDetail.getUserId()); + iCompanySignatureService.saveOrUpdate(signature); } - public ResCompanyFiscalCodeAndSealSnVO getFiscalCodeConfigure(ReqGetCompanyFiscalCodeAndSealSnPO request) { - Long userId = LoginUserUtil.getUserId(); - String organizationCode = request.getOrganizationCode(); - if (StringUtils.isBlank(organizationCode)) { - organizationCode = userInfoHelper.getUserEmpPosUnitCode(userId); + public CompanyFiscalCodeAndSealSnVO getFiscalCodeConfigure(ReqGetCompanyFiscalCodeAndSealSnPO request) { + UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + String temOrgCode; + if (StrUtils.isBlank(request.getOrganizationCode())) { + temOrgCode = String.valueOf(userDetail.getMhUnitId()); + } else { + temOrgCode = request.getOrganizationCode(); } - CompanySignature companySignature = iCompanySignatureService.getByOrganizationCode(organizationCode); - CompanyFiscalCode companyFiscalCode = iCompanyFiscalCodeService.getByOrganizationCode(organizationCode); - - ResCompanyFiscalCodeAndSealSnVO returnVO = new ResCompanyFiscalCodeAndSealSnVO(); + CompanySignature companySignature = iCompanySignatureService.getByOrganizationCode(temOrgCode); if (Objects.isNull(companySignature)) { return null; } + CompanyFiscalCode companyFiscalCode = iCompanyFiscalCodeService.getByOrganizationCode(temOrgCode); + CompanyFiscalCodeAndSealSnVO returnVO = new CompanyFiscalCodeAndSealSnVO(); returnVO.setCreateTime(companySignature.getCreateOn()); returnVO.setUpdateTime(companySignature.getUpdateOn()); returnVO.setFiscalCode(companyFiscalCode.getFiscalCode()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/po/CompanyFiscalCodeAndSealSnReq.java similarity index 85% rename from hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java rename to hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/po/CompanyFiscalCodeAndSealSnReq.java index 04fe139..009e47b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/po/ReqCompanyFiscalCodeAndSealSnPO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/po/CompanyFiscalCodeAndSealSnReq.java @@ -12,9 +12,8 @@ import javax.validation.constraints.NotBlank; */ @Data @ApiModel("财政编码配置") -public class ReqCompanyFiscalCodeAndSealSnPO { +public class CompanyFiscalCodeAndSealSnReq { -// @NotBlank(message = "组织编码 不能为空") @ApiModelProperty("组织编码(需传入用户任职单位code)") private String organizationCode; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/vo/ResCompanyFiscalCodeAndSealSnVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/vo/CompanyFiscalCodeAndSealSnVO.java similarity index 93% rename from hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/vo/ResCompanyFiscalCodeAndSealSnVO.java rename to hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/vo/CompanyFiscalCodeAndSealSnVO.java index b07d00d..facc051 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/vo/ResCompanyFiscalCodeAndSealSnVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/model/vo/CompanyFiscalCodeAndSealSnVO.java @@ -13,7 +13,7 @@ import java.time.LocalDateTime; @Data @ApiModel("财政编码配置VO") -public class ResCompanyFiscalCodeAndSealSnVO { +public class CompanyFiscalCodeAndSealSnVO { @ApiModelProperty("组织编码") private String organizationCode; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/gov/manage/GovProjectCollectionManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/gov/manage/GovProjectCollectionManage.java index d5726df..05c429a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/gov/manage/GovProjectCollectionManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/gov/manage/GovProjectCollectionManage.java @@ -3,15 +3,16 @@ package com.hz.pm.api.gov.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.model.constant.RegionConst; -import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.gov.contants.BizProjectContant; import com.hz.pm.api.gov.convert.ProjectConvert; import com.hz.pm.api.gov.model.dto.*; @@ -29,9 +30,9 @@ import com.hz.pm.api.projectdeclared.service.IOperationService; import com.hz.pm.api.projectdeclared.service.IPreInsAcceptancePersonService; import com.hz.pm.api.projectdeclared.service.IPurchaseService; import com.hz.pm.api.projectdeclared.utils.GenerateProjectCodeUtil; +import com.hz.pm.api.projectlib.model.entity.*; import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; -import com.hz.pm.api.projectlib.model.entity.*; import com.hz.pm.api.projectlib.model.req.ProjectListReq; import com.hz.pm.api.projectlib.service.*; import com.hz.pm.api.safety.model.entity.PersonSafetyInfo; @@ -79,7 +80,7 @@ import java.util.stream.Collectors; /** * @author zpf - * @date 2023/8/21 下午2:27 + * @since 2023/8/21 下午2:27 */ @Component @@ -173,8 +174,8 @@ public class GovProjectCollectionManage { /** * 分页查 项目归集 * - * @param req - * @return + * @param req \ + * @return \ */ public PageVo list(ProjectListReq req) { Page page = req.page(); @@ -195,7 +196,6 @@ public class GovProjectCollectionManage { ProjectTypeNewEnum.XU_OPERA.getCode())) .eq(GovBizProjectBaseinfo::getDeleted, Boolean.FALSE) .orderByDesc(GovBizProjectBaseinfo::getBizTime); -// permissions(wrapper); baseinfoService.page(page, wrapper); if (CollUtil.isEmpty(page.getRecords())) { @@ -381,22 +381,6 @@ public class GovProjectCollectionManage { return PageVo.of(res, page.getTotal()); } - /** - * 数据权限 - * - * @param wrapper - */ - private void permissions(LambdaQueryWrapper wrapper) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - //超管和区域管理员 - if (user.getSuperAdmin() || user.getRegionAdmin()) { - log.info("超管和区管 可以看所有"); - return; - } - - wrapper.eq(GovBizProjectBaseinfo::getBaseBuildDeprtDing, user.getEmpPosUnitCode()); - } - public Long count(ProjectListReq req) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) .like(StringUtils.isNotBlank(req.getProjectName()), GovBizProjectBaseinfo::getBaseProjName, req.getProjectName()) @@ -692,14 +676,12 @@ public class GovProjectCollectionManage { GovBizProjectBaseinfoDTO base = saveDTO.getBaseinfo(); String baseProjId = saveDTO.getBaseProjId(); - String baseAreaCode = user.getRegionCode() + BizConst.NINE_AREA_CODE_LAST; String baseProjName = base.getBaseProjName(); //1.保存基本信息 GovBizProjectBaseinfoDTO baseinfo = saveDTO.getBaseinfo(); baseinfo.setBaseProjId(baseProjId); baseinfo.setBaseProjName(baseProjName); - baseinfo.setBaseAreaCode(baseAreaCode); baseinfo.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); GovBizProjectBaseinfo oldBaseInfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) .eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId) @@ -715,8 +697,6 @@ public class GovProjectCollectionManage { saveBase.setBaseAreaCode(null); } else { saveBase.setTongTime(LocalDateTime.now()); - saveBase.setBaseAreaCode(baseAreaCode); - saveBase.setBaseAreaName(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); } saveBase.setAreaCode(RegionConst.RC_HZ); saveBase.setBizTime(LocalDateTime.now()); @@ -854,21 +834,18 @@ public class GovProjectCollectionManage { procureService.remove(Wrappers.lambdaQuery(GovBizProjectProcure.class) .eq(GovBizProjectProcure::getBaseProjId, baseProjId)); - String finalBaseProjId = baseProjId; - UserInfoDetails finalUser = user; - Integer index = 1; for (GovBizProjectProcureDTO procure : procures) { - procure.setBaseProjId(finalBaseProjId); + procure.setBaseProjId(baseProjId); procure.setBaseProjName(baseProjName); - procure.setBaseBidCode(finalBaseProjId + StrPool.DASH + String.format(StrPool.FORMAT_DATE_SINGLE_DIGITS, index)); + procure.setBaseBidCode(baseProjId + StrPool.DASH + String.format(StrPool.FORMAT_DATE_SINGLE_DIGITS, index)); GovBizProjectProcure saveProcure = BeanUtil.copyProperties(procure, GovBizProjectProcure.class); - saveProcure.setBaseProjId(finalBaseProjId); + saveProcure.setBaseProjId(baseProjId); saveProcure.setId(null); saveProcure.setAreaCode(RegionConst.RC_HZ); saveProcure.setTongTime(LocalDateTime.now()); saveProcure.setBizTime(LocalDateTime.now()); - saveProcure.setUpdateBy(finalUser.getUsername()); + saveProcure.setUpdateBy(user.getUsername()); saveProcure.setUpdateOn(LocalDateTime.now()); if (procureService.save(saveProcure)) { threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssProcure(procure, null, saveProcure)); @@ -878,9 +855,6 @@ public class GovProjectCollectionManage { } - //7. 推送数据(改为定时推送了) -// pushProject(saveDTO); - //如果是草稿箱来的 就要删除 if (Objects.nonNull(saveDTO.getDraftId())) { draftService.removeById(saveDTO.getDraftId()); } @@ -895,6 +869,7 @@ public class GovProjectCollectionManage { * @param user * @return */ + @Transactional(rollbackFor = Exception.class) public String operationSave(GovOperationProjectSaveDTO saveDTO, UserInfoDetails user) { if (Objects.isNull(user)) { user = LoginUserUtil.loginUserDetail(); @@ -902,14 +877,12 @@ public class GovProjectCollectionManage { GovOperationProjectBaseinfoDTO base = saveDTO.getBaseinfo(); String baseProjId = saveDTO.getBaseProjId(); - String baseAreaCode = user.getRegionCode() + BizConst.NINE_AREA_CODE_LAST; String baseProjName = base.getBaseProjName(); //1.保存基本信息 GovOperationProjectBaseinfoDTO baseinfo = saveDTO.getBaseinfo(); baseinfo.setBaseProjId(baseProjId); baseinfo.setBaseProjName(baseProjName); - baseinfo.setBaseAreaCode(baseAreaCode); baseinfo.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); GovOperationProjectBaseinfo oldBaseInfo = operationProjectBaseinfoService.getOne(Wrappers.lambdaQuery(GovOperationProjectBaseinfo.class) .eq(GovOperationProjectBaseinfo::getBaseProjId, baseProjId) @@ -924,11 +897,8 @@ public class GovProjectCollectionManage { saveBase.setId(oldBaseInfo.getId()); saveBase.setBaseAreaCode(null); } else { - saveBase.setBaseAreaCode(baseAreaCode); saveBase.setTongTime(LocalDateTime.now()); - saveBase.setBaseAreaName(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); } - saveBase.setAreaCode(RegionConst.RC_HZ); saveBase.setBizTime(LocalDateTime.now()); saveBase.setUpdateBy(user.getUsername()); saveBase.setUpdateOn(LocalDateTime.now()); @@ -1064,21 +1034,18 @@ public class GovProjectCollectionManage { procureService.remove(Wrappers.lambdaQuery(GovBizProjectProcure.class) .eq(GovBizProjectProcure::getBaseProjId, baseProjId)); - String finalBaseProjId = baseProjId; - UserInfoDetails finalUser = user; - Integer index = 1; for (GovBizProjectProcureDTO procure : procures) { - procure.setBaseProjId(finalBaseProjId); + procure.setBaseProjId(baseProjId); procure.setBaseProjName(baseProjName); - procure.setBaseBidCode(finalBaseProjId + StrPool.DASH + String.format(StrPool.FORMAT_DATE_SINGLE_DIGITS, index)); + procure.setBaseBidCode(baseProjId + StrPool.DASH + String.format(StrPool.FORMAT_DATE_SINGLE_DIGITS, index)); GovBizProjectProcure saveProcure = BeanUtil.copyProperties(procure, GovBizProjectProcure.class); - saveProcure.setBaseProjId(finalBaseProjId); + saveProcure.setBaseProjId(baseProjId); saveProcure.setId(null); saveProcure.setAreaCode(RegionConst.RC_HZ); saveProcure.setTongTime(LocalDateTime.now()); saveProcure.setBizTime(LocalDateTime.now()); - saveProcure.setUpdateBy(finalUser.getUsername()); + saveProcure.setUpdateBy(user.getUsername()); saveProcure.setUpdateOn(LocalDateTime.now()); if (procureService.save(saveProcure)) { threadPoolTaskScheduler.execute(() -> uploadFileToProvincialOssProcure(procure, null, saveProcure)); @@ -1088,8 +1055,6 @@ public class GovProjectCollectionManage { } - //7. 推送数据(改为定时推送了) -// pushProject(saveDTO); //如果是草稿箱来的 就要删除 if (Objects.nonNull(saveDTO.getDraftId())) { operationProjectDraftService.removeById(saveDTO.getDraftId()); @@ -1130,14 +1095,12 @@ public class GovProjectCollectionManage { GovBizProjectDraft draft = new GovBizProjectDraft(); //草稿id Long draftId = saveDTO.getDraftId(); - String baseAreaCode = user.getRegionCode() + BizConst.NINE_AREA_CODE_LAST; if (Objects.nonNull(draftId)) { GovBizProjectDraft oldDraft = draftService.getById(draftId); VUtils.isTrue(Objects.isNull(oldDraft)).throwMessage("该草稿不存在!"); draft.setId(draftId); } else { draft.setTongTime(LocalDateTime.now()); - draft.setBaseAreaCode(baseAreaCode); draft.setCreateId(user.getUserId()); draft.setTongTime(LocalDateTime.now()); } @@ -1227,14 +1190,12 @@ public class GovProjectCollectionManage { GovOperationProjectDraft draft = new GovOperationProjectDraft(); //草稿id Long draftId = saveDTO.getDraftId(); - String baseAreaCode = user.getRegionCode() + BizConst.NINE_AREA_CODE_LAST; if (Objects.nonNull(draftId)) { GovOperationProjectDraft oldDraft = operationProjectDraftService.getById(draftId); VUtils.isTrue(Objects.isNull(oldDraft)).throwMessage("该草稿不存在!"); draft.setId(draftId); } else { draft.setTongTime(LocalDateTime.now()); - draft.setBaseAreaCode(baseAreaCode); draft.setCreateId(user.getUserId()); draft.setTongTime(LocalDateTime.now()); } @@ -1722,26 +1683,23 @@ public class GovProjectCollectionManage { throw BizException.wrap("pdf转换无效"); } - private Boolean checkFieldNotPdf(String field, Object record, String fieldName) { - if (StringUtils.isBlank(field)) { + private boolean checkFieldNotPdf(String field, Object record, String fieldName) { + if (StrUtil.isBlank(field)) { return Boolean.FALSE; } - - //如果没有老值 + // 如果没有老值 if (Objects.isNull(record)) { return Boolean.TRUE; } - //和老值做个对比 不一样则true + // 和老值做个对比 不一样则true Class clazz = record.getClass(); String oldFiled = StringUtils.EMPTY; try { Field fieldDeclared = clazz.getDeclaredField(fieldName); fieldDeclared.setAccessible(Boolean.TRUE); oldFiled = Objects.nonNull(fieldDeclared.get(record)) ? String.valueOf(fieldDeclared.get(record)) : null; - } catch (NoSuchFieldException e) { - log.error("转换PDF文件出错" + e); - } catch (IllegalAccessException e) { + } catch (NoSuchFieldException | IllegalAccessException e) { log.error("转换PDF文件出错" + e); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/irs/manage/IrsProjectManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/irs/manage/IrsProjectManage.java index f2d2f2f..0005d94 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/irs/manage/IrsProjectManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/irs/manage/IrsProjectManage.java @@ -18,6 +18,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; + import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -37,6 +38,7 @@ public class IrsProjectManage { /** * IRS档案 项目列表 + * * @param req * @return */ @@ -44,39 +46,39 @@ public class IrsProjectManage { Page page = req.page(); UserInfoDetails user = LoginUserUtil.loginUserDetail(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) - .eq(StringUtils.isNotBlank(req.getAreaCode()),Project::getAreaCode,req.getAreaCode()) - .eq(StringUtils.isNotBlank(req.getRegionCode()),Project::getAreaCode,req.getRegionCode()) - .eq(StringUtils.isNotBlank(req.getProjectType()),Project::getProjectType,req.getProjectType()) - .eq(Objects.nonNull(req.getStatus()),Project::getStatus,req.getStatus()) - .eq(Objects.nonNull(req.getStage()),Project::getStage,req.getStage()) - .ge(Objects.nonNull(req.getApproveAmountMin()),Project::getApprovalAmount,req.getApproveAmountMin()) - .le(Objects.nonNull(req.getApproveAmountMax()),Project::getApprovalAmount,req.getApproveAmountMax()) - .eq(Objects.nonNull(req.getProjectYear()),Project::getProjectYear,req.getProjectYear()) - .ge(Objects.nonNull(req.getCreateOnMin()),Project::getCreateOn,req.getCreateOnMin()) - .le(Objects.nonNull(req.getCreateOnMax()),Project::getCreateOn,req.getCreateOnMax()) - .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()) - .like(StringUtils.isNotBlank(req.getBuildOrgName()),Project::getBuildOrgName,req.getBuildOrgName()) + .eq(StringUtils.isNotBlank(req.getAreaCode()), Project::getAreaCode, req.getAreaCode()) + .eq(StringUtils.isNotBlank(req.getRegionCode()), Project::getAreaCode, req.getRegionCode()) + .eq(StringUtils.isNotBlank(req.getProjectType()), Project::getProjectType, req.getProjectType()) + .eq(Objects.nonNull(req.getStatus()), Project::getStatus, req.getStatus()) + .eq(Objects.nonNull(req.getStage()), Project::getStage, req.getStage()) + .ge(Objects.nonNull(req.getApproveAmountMin()), Project::getApprovalAmount, req.getApproveAmountMin()) + .le(Objects.nonNull(req.getApproveAmountMax()), Project::getApprovalAmount, req.getApproveAmountMax()) + .eq(Objects.nonNull(req.getProjectYear()), Project::getProjectYear, req.getProjectYear()) + .ge(Objects.nonNull(req.getCreateOnMin()), Project::getCreateOn, req.getCreateOnMin()) + .le(Objects.nonNull(req.getCreateOnMax()), Project::getCreateOn, req.getCreateOnMax()) + .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()) + .like(StringUtils.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName()) .gt(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) - .eq(Project::getNewest,Boolean.TRUE) + .eq(Project::getNewest, Boolean.TRUE) .eq(Project::getIncludeApplication, CommonEnum.YES.getCode()) .orderByDesc(Project::getUpdateOn); - buildPermission(wrapper,user); - projectService.page(page,wrapper); + buildPermission(wrapper, user); + projectService.page(page, wrapper); - if(CollUtil.isEmpty(page.getRecords())){ + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } - List res = page.getRecords().stream().map(p -> BeanUtil.copyProperties(p,ProjectLibListItemVO.class)).collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + List res = page.getRecords().stream() + .map(p -> BeanUtil.copyProperties(p, ProjectLibListItemVO.class)) + .collect(Collectors.toList()); + return PageVo.of(res, page.getTotal()); } private void buildPermission(LambdaQueryWrapper wrapper, UserInfoDetails user) { - if(user.getSuperAdmin()){ + if (user.getSuperAdmin() || user.getRegionAdmin()) { log.info("超管 都可看 项目档案列表"); - }else if(user.getRegionAdmin()){ - wrapper.eq(Project::getAreaCode,user.getRegionCode()); - }else{ - wrapper.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); + } else { + wrapper.eq(Project::getBuildOrgCode, user.getMhUnitId()); } } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingDataScopeHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingDataScopeHelper.java deleted file mode 100644 index b5eeac3..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingDataScopeHelper.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.hz.pm.api.meeting.helper; - -import com.ningdatech.basic.util.CollUtils; -import com.hz.pm.api.common.helper.RegionCacheHelper; -import com.hz.pm.api.common.model.entity.ViewRegionDTO; -import com.hz.pm.api.sys.model.entity.Role; -import com.hz.pm.api.user.model.enumeration.RoleEnum; -import com.hz.pm.api.user.security.model.UserInfoDetails; -import com.hz.pm.api.user.util.LoginUserUtil; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Component; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - *

- * MeetingDataScopeHelper - *

- * - * @author WendyYang - * @since 2023/4/27 - **/ -@Component -@AllArgsConstructor -public class MeetingDataScopeHelper { - - private final RegionCacheHelper regionCacheHelper; - - private static RoleEnum getRolePriorityMax() { - List roleList = LoginUserUtil.loginUserDetail().getUserRoleList(); - List roleCodeList = CollUtils.fieldList(roleList, Role::getCode); - if (roleCodeList.contains(RoleEnum.SUPER_ADMIN.name())) { - return RoleEnum.SUPER_ADMIN; - } - if (roleCodeList.contains(RoleEnum.REGION_MANAGER.name())) { - return RoleEnum.REGION_MANAGER; - } - return RoleEnum.EXPERT_ADMIN; - } - - public ViewRegionDTO meetingListViewRegions() { - RoleEnum role = getRolePriorityMax(); - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - String regionCode = user.getRegionCode(); - Integer regionLevel = user.getRegionLevel(); - Collection regions; - switch (role) { - case SUPER_ADMIN: - regions = null; - break; - case REGION_MANAGER: - regions = regionCacheHelper.listChildRegionCodeList(regionCode, regionLevel); - break; - case EXPERT_ADMIN: - regions = Collections.singletonList(regionCode); - break; - default: - regions = Collections.emptyList(); - break; - } - return new ViewRegionDTO(regions, regionLevel); - } - -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java index 8ab55e6..a98c3cb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java @@ -30,7 +30,6 @@ import com.hz.pm.api.meeting.entity.req.*; import com.hz.pm.api.meeting.entity.vo.*; import com.hz.pm.api.meeting.helper.ExpertInviteHelper; import com.hz.pm.api.meeting.helper.MeetingCallOrMsgHelper; -import com.hz.pm.api.meeting.helper.MeetingDataScopeHelper; import com.hz.pm.api.meeting.helper.MeetingManageHelper; import com.hz.pm.api.meeting.service.*; import com.hz.pm.api.meeting.task.ExpertRandomInviteTask; @@ -89,13 +88,10 @@ public class MeetingManage { private final DistributedLock distributedLock; private final IProjectService projectService; private final IMeetingInnerProjectService meetingInnerProjectService; - private final IMeetingOuterProjectService meetingOuterProjectService; private final IBelongOrgService belongOrgService; private final IDingOrganizationService dingOrganizationService; - private final IExpertReviewService expertReviewService; private final ExpertInviteHelper expertInviteHelper; private final MeetingCallOrMsgHelper meetingCallOrMsgHelper; - private final MeetingDataScopeHelper meetingDataScopeHelper; private final IMeetingExpertJudgeService expertJudgeService; private final IMeetingExpertJudgeService meetingExpertJudgeService; @@ -130,8 +126,8 @@ public class MeetingManage { // 保存会议基本信息 Meeting meeting = BeanUtil.copyProperties(meetingBasic, Meeting.class); meeting.setStatus(MeetingStatusEnum.NORMAL.getCode()); - meeting.setHoldOrg(userDetail.getOrganizationName()); - meeting.setHoldOrgCode(userDetail.getOrganizationCode()); + meeting.setHoldOrg(String.valueOf(userDetail.getMhUnitId())); + meeting.setHoldOrgCode(userDetail.getMhUnitName()); meeting.setCreator(userDetail.getUsername()); meeting.setInviteStatus(Boolean.FALSE); meeting.setConfirmedRoster(Boolean.FALSE); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/helper/impl/TemplateDetailBuildHelperImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/helper/impl/TemplateDetailBuildHelperImpl.java index 85cdecc..a315633 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/helper/impl/TemplateDetailBuildHelperImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/helper/impl/TemplateDetailBuildHelperImpl.java @@ -73,7 +73,8 @@ public class TemplateDetailBuildHelperImpl implements TemplateDetailBuildHelper .eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode,projectCode) .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode())); if (CollUtil.isNotEmpty(reAppraisalScoreInfo)) { - Map> reAppScoreInfoMap = reAppraisalScoreInfo.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)); + Map> reAppScoreInfoMap = reAppraisalScoreInfo.stream() + .collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalUserName)); HashMap scoreMap = MapUtil.newHashMap(); for (String name : reAppScoreInfoMap.keySet()) { List scoreInfos = reAppScoreInfoMap.get(name); @@ -97,13 +98,13 @@ public class TemplateDetailBuildHelperImpl implements TemplateDetailBuildHelper .eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode,projectCode) .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode())); if (CollUtil.isNotEmpty(verifyScoreInfo)) { - Map> verifyScoreInfoMap = verifyScoreInfo.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)); + Map> verifyScoreInfoMap = verifyScoreInfo.stream() + .collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalUserName)); HashMap scoreMap = MapUtil.newHashMap(); for (String name : verifyScoreInfoMap.keySet()) { List scoreInfos = verifyScoreInfoMap.get(name); BigDecimal totalScore = scoreInfos.stream().map(PerformanceAppraisalScoreInfo::getAppraisalScore) - .filter(Objects::nonNull) - .reduce(BigDecimal.ZERO, BigDecimal::add); + .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); scoreMap.put(name, totalScore); } detailThirdVo.setVerifyTotalScoreInfo(scoreMap); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/AppAppraisalManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/AppAppraisalManage.java index 492c638..8212c95 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/AppAppraisalManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/AppAppraisalManage.java @@ -1,47 +1,49 @@ package com.hz.pm.api.performance.manage; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; import cn.hutool.core.map.MapUtil; -import com.hz.pm.api.performance.enumration.AppIndexTypeEnum; -import com.hz.pm.api.performance.model.dto.AppAppraisalInfoDTO; -import com.hz.pm.api.performance.model.vo.*; -import com.hz.pm.api.projectlib.model.entity.ProjectApplication; -import com.hz.pm.api.projectlib.service.IProjectApplicationService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Component; - import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.StrPool; import com.hz.pm.api.performance.constant.ProjectBizConst; +import com.hz.pm.api.performance.enumration.AppIndexTypeEnum; +import com.hz.pm.api.performance.model.dto.AppAppraisalInfoDTO; import com.hz.pm.api.performance.model.dto.ProjectAppraisalDTO; import com.hz.pm.api.performance.model.entity.*; import com.hz.pm.api.performance.model.req.PerformanceAppraisalListReq; +import com.hz.pm.api.performance.model.vo.*; import com.hz.pm.api.performance.service.*; +import com.hz.pm.api.projectlib.model.entity.ProjectApplication; +import com.hz.pm.api.projectlib.service.IProjectApplicationService; import com.hz.pm.api.sys.model.entity.Role; import com.hz.pm.api.sys.service.IRoleService; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; /** * AppAppraisalManage - * @return + * * @author CMM + * @return * @since 2023/08/10 8:55 */ @Component @@ -56,8 +58,10 @@ public class AppAppraisalManage { private final IPerformanceAppraisalApplicationService performanceAppraisalApplicationService; private final IPerformanceAppraisalAppIndicatorService performanceAppraisalAppIndicatorService; private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService; + /** * 应用评价-评价计划列表 + * * @param req * @return */ @@ -68,31 +72,31 @@ public class AppAppraisalManage { List roleIdList = userRoleList.stream().map(Role::getId).collect(Collectors.toList()); Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class) .eq(Role::getName, ProjectBizConst.REAPPRAISAL_ROLE)); - if (Objects.isNull(role)){ + if (Objects.isNull(role)) { throw new BizException("登录用户没有复评员角色!"); } // 登录用户不是复评员,不能查看复评计划列表 - if (!roleIdList.contains(role.getId())){ + if (!roleIdList.contains(role.getId())) { return PageVo.empty(); } // 获取所有已添加到评价计划中的应用信息 List paas = performanceAppraisalApplicationService.list(); // 没有包含应用的评价计划 - if (CollUtil.isEmpty(paas)){ + if (CollUtil.isEmpty(paas)) { return PageVo.empty(); } Set paIds = paas.stream().map(PerformanceAppraisalApplication::getAppraisalId).collect(Collectors.toSet()); Page page = req.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) - .in(PerformanceAppraisal::getId,paIds) + .in(PerformanceAppraisal::getId, paIds) .orderByDesc(PerformanceAppraisal::getUpdateOn); - performanceAppraisalService.page(page,wrapper); + performanceAppraisalService.page(page, wrapper); List res = page.getRecords().stream() .map(p -> BeanUtil.copyProperties(p, PerformanceAppraisalVO.class)) .collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } @@ -108,7 +112,7 @@ public class AppAppraisalManage { .eq(PerformanceAppraisalApplication::getAppraisalId, planId) .eq(PerformanceAppraisalApplication::getIsCompleteAppraisal, Boolean.FALSE)); // 没有当前用户待评价的应用信息 - if (CollUtil.isEmpty(paas)){ + if (CollUtil.isEmpty(paas)) { return PageVo.empty(); } List ids = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); @@ -126,36 +130,36 @@ public class AppAppraisalManage { } appIds = ids; // 没有当前用户待评价的应用信息 - if(CollUtil.isEmpty(appIds)){ + if (CollUtil.isEmpty(appIds)) { return PageVo.empty(); } Page page = req.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(ProjectApplication.class) .in(ProjectApplication::getId, appIds) - .like(StringUtils.isNotBlank(req.getApplicationName()),ProjectApplication::getApplicationName,req.getApplicationName()); - projectApplicationService.page(page,wrapper); + .like(StringUtils.isNotBlank(req.getApplicationName()), ProjectApplication::getApplicationName, req.getApplicationName()); + projectApplicationService.page(page, wrapper); - if(CollUtil.isEmpty(page.getRecords())){ + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } List res = page.getRecords().stream() .map(p -> { PerformanceAppraisalAppVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalAppVO.class); - vo.setCanAppraisal(checkCanAppraisal(employeeCode,p.getId(),planId)); + vo.setCanAppraisal(checkCanAppraisal(employeeCode, p.getId(), planId)); vo.setApplicationName(StringUtils.isNotBlank(p.getApplicationName()) ? p.getApplicationName() : p.getRelatedExistsApplication()); vo.setAppraisalId(planId); return vo; }) .collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } public PageVo evaluatedList(Long planId, PerformanceAppraisalListReq req) { UserInfoDetails user = LoginUserUtil.loginUserDetail(); - String employeeCode = user.getEmployeeCode(); + String employeeCode = user.getUserIdStr(); PerformanceAppraisal plan = performanceAppraisalService.getById(planId); VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!"); @@ -164,7 +168,7 @@ public class AppAppraisalManage { List paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) .eq(PerformanceAppraisalApplication::getAppraisalId, planId) .eq(PerformanceAppraisalApplication::getIsCompleteAppraisal, Boolean.TRUE)); - if (CollUtil.isEmpty(paas)){ + if (CollUtil.isEmpty(paas)) { return PageVo.empty(); } // 从绩效评价打分信息表中获取上述绩效评价计划应用的打分信息 @@ -173,39 +177,38 @@ public class AppAppraisalManage { List appIds = Lists.newArrayList(); if (CollUtil.isNotEmpty(appraisalScoreInfos)) { // 筛选出当前登录用户已进行打分的应用信息 - List scoredAppIds = appraisalScoreInfos.stream() + appIds = appraisalScoreInfos.stream() .filter(a -> employeeCode.equals(a.getAppraisalEmployeeCode())) .map(PerformanceAppraisalAppScoreInfo::getApplicationId) .collect(Collectors.toList()); - appIds = scoredAppIds; } // 没有当前用户已评价的应用信息 - if(CollUtil.isEmpty(appIds)){ + if (CollUtil.isEmpty(appIds)) { return PageVo.empty(); } Page page = req.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(ProjectApplication.class) .in(ProjectApplication::getId, appIds) - .like(StringUtils.isNotBlank(req.getApplicationName()),ProjectApplication::getApplicationName,req.getApplicationName()); - projectApplicationService.page(page,wrapper); + .like(StringUtils.isNotBlank(req.getApplicationName()), ProjectApplication::getApplicationName, req.getApplicationName()); + projectApplicationService.page(page, wrapper); - if(CollUtil.isEmpty(page.getRecords())){ + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } List res = page.getRecords().stream() .map(p -> { PerformanceAppraisalAppVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalAppVO.class); - vo.setCanAppraisal(checkCanAppraisal(employeeCode,p.getId(),planId)); + vo.setCanAppraisal(checkCanAppraisal(employeeCode, p.getId(), planId)); vo.setApplicationName(StringUtils.isNotBlank(p.getApplicationName()) ? p.getApplicationName() : p.getRelatedExistsApplication()); vo.setAppraisalId(planId); return vo; }) .collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } /** @@ -216,14 +219,14 @@ public class AppAppraisalManage { * @param appraisalId * @return */ - private Boolean checkCanAppraisal(String employeeCode, Long appId, Long appraisalId) { + private Boolean checkCanAppraisal(String employeeCode, Long appId, Long appraisalId) { // 从绩效评价应用打分信息表中查询打分人员为当前登录复评用户的打分信息 // 如果没有相关的打分信息,说明是当前登录复评用户是首次评价 List scoreInfos = performanceAppraisalAppScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) - .eq(PerformanceAppraisalAppScoreInfo::getApplicationId,appId) - .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId,appraisalId) + .eq(PerformanceAppraisalAppScoreInfo::getApplicationId, appId) + .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, appraisalId) .eq(PerformanceAppraisalAppScoreInfo::getAppraisalEmployeeCode, employeeCode)); - if (CollUtil.isEmpty(scoreInfos)){ + if (CollUtil.isEmpty(scoreInfos)) { return true; } return Boolean.FALSE; @@ -233,28 +236,26 @@ public class AppAppraisalManage { public AppAppraisalIndexDetailVO detail(Long planId, Long appId) { ProjectApplication projectApplication = projectApplicationService.getById(appId); - VUtils.isTrue(Objects.isNull(projectApplication)).throwMessage("应用不存在!"); + Assert.notNull(projectApplication, "应用不存在!"); AppAppraisalIndexDetailVO resVo = new AppAppraisalIndexDetailVO(); if (StringUtils.isNotBlank(projectApplication.getApplicationName())) { resVo.setApplicationName(projectApplication.getApplicationName()); - }else { + } else { resVo.setApplicationName(projectApplication.getRelatedExistsApplication()); } - if (Objects.nonNull(projectApplication)){ - resVo.setBuildOrgName(projectApplication.getBuildOrgName()); - // todo 应用状态 需通过appCode通过IRS接口获取,这里暂时写死 已验收 - resVo.setApplicationStatus("已验收"); - } + resVo.setBuildOrgName(projectApplication.getBuildOrgName()); + // todo 应用状态 需通过appCode通过IRS接口获取,这里暂时写死 已验收 + resVo.setApplicationStatus("已验收"); // 获取指标配置的应用指标信息 // 通用指标 List commonIndexList = performanceAppraisalAppIndicatorService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppIndicator.class) .eq(PerformanceAppraisalAppIndicator::getIndexType, AppIndexTypeEnum.COMMON.getCode()) - .eq(PerformanceAppraisalAppIndicator::getIsDisplay,Boolean.TRUE) - .orderBy(Boolean.TRUE,Boolean.TRUE,PerformanceAppraisalAppIndicator::getSort)); + .eq(PerformanceAppraisalAppIndicator::getIsDisplay, Boolean.TRUE) + .orderBy(Boolean.TRUE, Boolean.TRUE, PerformanceAppraisalAppIndicator::getSort)); // 获取当前应用通用指标的的打分信息 Map commonScoreInfoMap = performanceAppraisalAppScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) - .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId,planId) + .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, planId) .eq(PerformanceAppraisalAppScoreInfo::getApplicationId, appId) .eq(PerformanceAppraisalAppScoreInfo::getIndexType, AppIndexTypeEnum.COMMON.getCode())) .stream().collect(Collectors.toMap(PerformanceAppraisalAppScoreInfo::getIndexId, p -> p)); @@ -274,11 +275,11 @@ public class AppAppraisalManage { // 辅助指标 List auxIndexList = performanceAppraisalAppIndicatorService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppIndicator.class) .eq(PerformanceAppraisalAppIndicator::getIndexType, AppIndexTypeEnum.AUX.getCode()) - .eq(PerformanceAppraisalAppIndicator::getIsDisplay,Boolean.TRUE) - .orderBy(Boolean.TRUE,Boolean.TRUE,PerformanceAppraisalAppIndicator::getSort)); + .eq(PerformanceAppraisalAppIndicator::getIsDisplay, Boolean.TRUE) + .orderBy(Boolean.TRUE, Boolean.TRUE, PerformanceAppraisalAppIndicator::getSort)); // 获取当前应用辅助指标的的打分信息 Map auxScoreInfoMap = performanceAppraisalAppScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) - .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId,planId) + .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, planId) .eq(PerformanceAppraisalAppScoreInfo::getApplicationId, appId) .eq(PerformanceAppraisalAppScoreInfo::getIndexType, AppIndexTypeEnum.AUX.getCode())) .stream().collect(Collectors.toMap(PerformanceAppraisalAppScoreInfo::getIndexId, p -> p)); @@ -299,7 +300,7 @@ public class AppAppraisalManage { .eq(ProjectCoreBusinessIndicators::getApplicationId, appId)); // 获取当前应用业务指标的的打分信息 Map businessScoreInfoMap = performanceAppraisalAppScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) - .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId,planId) + .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, planId) .eq(PerformanceAppraisalAppScoreInfo::getApplicationId, appId) .eq(PerformanceAppraisalAppScoreInfo::getIndexType, AppIndexTypeEnum.BUSINESS.getCode())) .stream().collect(Collectors.toMap(PerformanceAppraisalAppScoreInfo::getIndexId, p -> p)); @@ -333,7 +334,7 @@ public class AppAppraisalManage { .eq(PerformanceAppraisalApplication::getApplicationId, applicationId)); List indexIds = appAppraisalInfoList.stream().filter(a -> AppIndexTypeEnum.COMMON.getCode().equals(a.getIndexType()) || - AppIndexTypeEnum.AUX.getCode().equals(a.getIndexType())) + AppIndexTypeEnum.AUX.getCode().equals(a.getIndexType())) .map(AppAppraisalInfoDTO::getIndexId) .collect(Collectors.toList()); List businessIndexIds = appAppraisalInfoList.stream() @@ -366,18 +367,18 @@ public class AppAppraisalManage { Map finalBusinessIndexMap = businessIndexMap; List scoreInfos = appAppraisalInfoList.stream().map(a -> { if (AppIndexTypeEnum.COMMON.getCode().equals(a.getIndexType()) || - AppIndexTypeEnum.AUX.getCode().equals(a.getIndexType())){ + AppIndexTypeEnum.AUX.getCode().equals(a.getIndexType())) { PerformanceAppraisalAppIndicator appIndicator = finalIndexMap.get(a.getIndexId()); BigDecimal score = a.getScore(); BigDecimal indexScore = appIndicator.getIndexScore(); - if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){ + if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0) { throw new BizException("评价得分必须大于等于0且小于等于指标分值!"); } } else if (AppIndexTypeEnum.BUSINESS.getCode().equals(a.getIndexType())) { ProjectCoreBusinessIndicators coreBusinessIndicators = finalBusinessIndexMap.get(a.getIndexId()); BigDecimal score = a.getScore(); BigDecimal indexScore = coreBusinessIndicators.getScore(); - if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){ + if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0) { throw new BizException("评价得分必须大于等于0且小于等于指标分值!"); } } @@ -396,7 +397,7 @@ public class AppAppraisalManage { scoreInfo.setUpdateBy(username); return scoreInfo; }).collect(Collectors.toList()); - if (performanceAppraisalAppScoreInfoService.saveBatch(scoreInfos)){ + if (performanceAppraisalAppScoreInfoService.saveBatch(scoreInfos)) { // 计算评价总分并保存 BigDecimal appraisalTotalScore = appAppraisalInfoList.stream() .map(AppAppraisalInfoDTO::getScore) @@ -412,18 +413,5 @@ public class AppAppraisalManage { } return "提交失败"; } - private void judgeCompleteAppraisal(PerformanceAppraisalProjectGroup group, PerformanceAppraisalApplication appraisalApplication) { - // 获取该评价应用的复评打分信息 - List scoreInfos = performanceAppraisalAppScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) - .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, group.getAppraisalId()) - .eq(PerformanceAppraisalAppScoreInfo::getApplicationId, appraisalApplication.getApplicationId())); - String reAppraisalUsers = group.getReAppraisalUsers(); - List users = scoreInfos.stream().map(PerformanceAppraisalAppScoreInfo::getAppraisalEmployeeCode).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(users)){ - String join = String.join(StrPool.COMMA, users); - if (join.equals(reAppraisalUsers)) { - appraisalApplication.setIsCompleteAppraisal(Boolean.TRUE); - } - } - } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/OrgSelfAppraisalManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/OrgSelfAppraisalManage.java index 173b3ce..3342b60 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/OrgSelfAppraisalManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/OrgSelfAppraisalManage.java @@ -4,40 +4,44 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.StrPool; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; import com.hz.pm.api.performance.constant.ProjectBizConst; import com.hz.pm.api.performance.enumration.AppraisalTypeEnum; import com.hz.pm.api.performance.helper.TemplateDetailBuildHelper; -import com.hz.pm.api.performance.model.dto.SelfAppraisalScoreExportDTO; import com.hz.pm.api.performance.model.dto.ProjectAppraisalDTO; import com.hz.pm.api.performance.model.dto.ProjectAppraisalInfoDTO; +import com.hz.pm.api.performance.model.dto.SelfAppraisalScoreExportDTO; import com.hz.pm.api.performance.model.entity.*; import com.hz.pm.api.performance.model.req.PerformanceAppraisalExportReq; import com.hz.pm.api.performance.model.req.PerformanceAppraisalListReq; -import com.hz.pm.api.performance.model.vo.*; +import com.hz.pm.api.performance.model.vo.PerformanceAppraisalProjectVO; +import com.hz.pm.api.performance.model.vo.PerformanceAppraisalVO; +import com.hz.pm.api.performance.model.vo.ProjectAppraisalIndexDetailVO; +import com.hz.pm.api.performance.model.vo.ProjectTemplateDetailVO; import com.hz.pm.api.performance.service.*; import com.hz.pm.api.performance.util.ExcelFillCellMergeStrategy; import com.hz.pm.api.performance.util.MultiColumnMergeStrategy; import com.hz.pm.api.portrait.model.entity.ProjectTag; import com.hz.pm.api.portrait.service.IProjectTagService; +import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; -import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.sys.model.entity.Role; import com.hz.pm.api.sys.service.IRoleService; import com.hz.pm.api.user.model.enumeration.RoleEnum; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.StrPool; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -48,7 +52,10 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; /** @@ -71,8 +78,10 @@ public class OrgSelfAppraisalManage { private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService; private final IProjectTagService projectTagService; private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService; + /** * 绩效列表 + * * @param req * @return */ @@ -80,51 +89,51 @@ public class OrgSelfAppraisalManage { UserInfoDetails user = LoginUserUtil.loginUserDetail(); //当前登录用户 单位code - String empPosUnitCode = user.getEmpPosUnitCode(); + String mhUnitId = user.getMhUnitIdStr(); // 获取当前登录用户的角色列表,只有单位管理员才能查看该列表 List userRoleList = user.getUserRoleList(); List roleIdList = userRoleList.stream().map(Role::getId).collect(Collectors.toList()); Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class) .eq(Role::getName, RoleEnum.COMPANY_MANAGER.getDesc())); - if (Objects.isNull(role)){ + if (Objects.isNull(role)) { throw new BizException("登录用户没有单位管理员角色!"); } // 登录用户不是单位管理员,不能查看本单位的自评计划列表 - if (!roleIdList.contains(role.getId())){ + if (!roleIdList.contains(role.getId())) { return PageVo.empty(); } // 获取登录用户所在单位的所有已终验项目信息 List projectLists = projectService.list(Wrappers.lambdaQuery(Project.class) .eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode()) - .eq(Project::getBuildOrgCode, empPosUnitCode)); + .eq(Project::getBuildOrgCode, mhUnitId)); - if(CollUtil.isEmpty(projectLists)){ + if (CollUtil.isEmpty(projectLists)) { return PageVo.empty(); } List projectIds = projectLists.stream().map(Project::getId).collect(Collectors.toList()); // 获取添加过该单位项目的所有评价计划信息 List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .in(PerformanceAppraisalProject::getProjectId, projectIds)); - if(CollUtil.isEmpty(paps)){ + if (CollUtil.isEmpty(paps)) { return PageVo.empty(); } Set paIds = paps.stream().map(PerformanceAppraisalProject::getAppraisalId).collect(Collectors.toSet()); // 获取评价计划列表 Page page = req.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) - .in(PerformanceAppraisal::getId,paIds) + .in(PerformanceAppraisal::getId, paIds) .orderByDesc(PerformanceAppraisal::getUpdateOn); - performanceAppraisalService.page(page,wrapper); - if(CollUtil.isEmpty(page.getRecords())){ + performanceAppraisalService.page(page, wrapper); + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } List res = page.getRecords().stream() .map(p -> BeanUtil.copyProperties(p, PerformanceAppraisalVO.class)) .collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } public PageVo pendingList(Long planId, PerformanceAppraisalListReq req) { @@ -135,11 +144,11 @@ public class OrgSelfAppraisalManage { // 获取评价计划内已添加的待评价项目信息 List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() + .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() .filter(p -> Objects.isNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); Map papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); - if(CollUtil.isEmpty(paps)){ + if (CollUtil.isEmpty(paps)) { return PageVo.empty(); } @@ -149,19 +158,19 @@ public class OrgSelfAppraisalManage { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) .in(Project::getProjectCode, projectCodes) .eq(Project::getNewest, Boolean.TRUE) - .eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) - .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); - projectService.page(page,wrapper); + .eq(Project::getBuildOrgCode, user.getMhUnitId()) + .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); + projectService.page(page, wrapper); - if(CollUtil.isEmpty(page.getRecords())){ + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } - List res = page.getRecords().stream() - .map(p -> { - PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); + List res = page.getRecords().stream().map(p -> { + PerformanceAppraisalProjectVO vo = new PerformanceAppraisalProjectVO(); + BeanUtil.copyProperties(p, vo); PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); - BeanUtil.copyProperties(appraisalProject,vo); + BeanUtil.copyProperties(appraisalProject, vo); vo.setProjectId(appraisalProject.getProjectId()); vo.setProjectTypeName(ProjectTypeNewEnum.getDesc(p.getProjectType())); vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject)); @@ -170,7 +179,7 @@ public class OrgSelfAppraisalManage { }) .collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } /** @@ -188,11 +197,11 @@ public class OrgSelfAppraisalManage { // 获取评价计划内已添加的已评价项目信息 List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() + .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() .filter(p -> Objects.nonNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); Map papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); - if(CollUtil.isEmpty(paps)){ + if (CollUtil.isEmpty(paps)) { return PageVo.empty(); } @@ -202,18 +211,18 @@ public class OrgSelfAppraisalManage { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) .in(Project::getProjectCode, projectCodes) .eq(Project::getNewest, Boolean.TRUE) - .eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) - .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); - projectService.page(page,wrapper); + .eq(Project::getBuildOrgCode, user.getMhUnitId()) + .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); + projectService.page(page, wrapper); - if(CollUtil.isEmpty(page.getRecords())){ + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } List res = page.getRecords().stream() .map(p -> { PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); - BeanUtil.copyProperties(appraisalProject,vo); + BeanUtil.copyProperties(appraisalProject, vo); vo.setProjectId(appraisalProject.getProjectId()); vo.setProjectTypeName(ProjectTypeNewEnum.getDesc(p.getProjectType())); vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject)); @@ -222,30 +231,27 @@ public class OrgSelfAppraisalManage { }) .collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } /** * 是否可以自评 + * * @param appraisalProject * @return */ private Boolean checkCanSelfAppraisal(PerformanceAppraisalProject appraisalProject) { // 在自评时间段内,且是首次自评(打分时间为空) - if(LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalStart()) > 0 && + if (LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalStart()) > 0 && LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalEnd()) < 0 && - Objects.isNull(appraisalProject.getSelfAppraisalScoreTime())){ + Objects.isNull(appraisalProject.getSelfAppraisalScoreTime())) { return Boolean.TRUE; } return Boolean.FALSE; } public ProjectAppraisalIndexDetailVO getAppraisalTemplateDetail(String projectCode) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - String regionCode = user.getRegionCode(); - ProjectAppraisalIndexDetailVO vo = new ProjectAppraisalIndexDetailVO(); - // 根据项目编码获取最新版本的项目信息 Project project = projectService.getProjectByCode(projectCode); VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); @@ -256,7 +262,7 @@ public class OrgSelfAppraisalManage { VUtils.isTrue(Objects.isNull(approvalAmount)).throwMessage("未获取到该项目的立项批复金额"); // 根据项目code获取项目标签ID列表 List tagIdList = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) - .eq(ProjectTag::getProjectCode, projectCode)).stream() + .eq(ProjectTag::getProjectCode, projectCode)).stream() .map(ProjectTag::getTagId).collect(Collectors.toList()); VUtils.isTrue(CollUtil.isEmpty(tagIdList)).throwMessage("当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!"); @@ -264,25 +270,24 @@ public class OrgSelfAppraisalManage { String projectTagIds = String.join(StrPool.COMMA, strIdList); Integer amountRange = null; - if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) < 0){ + if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) < 0) { amountRange = ProjectBizConst.AMOUNT_RANGE_ONE; } else if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) >= 0 && approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.TWENTY_MILLION)) < 0) { amountRange = ProjectBizConst.AMOUNT_RANGE_TWO; - }else if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.TWENTY_MILLION)) >= 0){ + } else if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.TWENTY_MILLION)) >= 0) { amountRange = ProjectBizConst.AMOUNT_RANGE_THREE; } LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class) - .eq(PerformanceIndicatorProjectTemplate::getRegionCode, regionCode) .eq(PerformanceIndicatorProjectTemplate::getProjectType, projectType) .eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) .eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) - .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) - .eq(PerformanceIndicatorProjectTemplate::getStatus,CommonEnum.YES.getCode()) + .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds, projectTagIds) + .eq(PerformanceIndicatorProjectTemplate::getStatus, CommonEnum.YES.getCode()) .orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); List templates = indicatorProjectTemplateService.list(wrapper); VUtils.isTrue(CollUtil.isEmpty(templates)).throwMessage("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); - if (templates.size() > 1){ + if (templates.size() > 1) { throw new BizException("当前项目匹配到多个模板,请返回模板库检查模板配置!"); } PerformanceIndicatorProjectTemplate projectTemplate = templates.get(0); @@ -290,13 +295,13 @@ public class OrgSelfAppraisalManage { // 获取模版绩效指标详情 List templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) - .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.FALSE)); + .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional, Boolean.FALSE)); // 获取模版附加绩效指标详情 List additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) - .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); - List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,projectCode,vo); - List additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails,projectCode,vo); + .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional, Boolean.TRUE)); + List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails, projectCode, vo); + List additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails, projectCode, vo); vo.setProjectName(project.getProjectName()); vo.setBuildOrgName(project.getBuildOrgName()); vo.setProjectStatus(project.getStatus()); @@ -310,8 +315,6 @@ public class OrgSelfAppraisalManage { @Transactional(rollbackFor = Exception.class) public String submitSelfAppraisal(ProjectAppraisalDTO param) { UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); - String employeeCode = userDetail.getEmployeeCode(); - String username = userDetail.getUsername(); Long appraisalId = param.getAppraisalId(); Long appraisalProjectId = param.getAppraisalProjectId(); String appraisalProjectCode = param.getAppraisalProjectCode(); @@ -320,12 +323,12 @@ public class OrgSelfAppraisalManage { PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId) .eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId) - .eq(PerformanceAppraisalProject::getProjectCode,appraisalProjectCode)); - if (Objects.isNull(appraisalProject)){ + .eq(PerformanceAppraisalProject::getProjectCode, appraisalProjectCode)); + if (Objects.isNull(appraisalProject)) { throw new BizException("该项目已被移除评价计划,请返回上一页或者刷新重试!"); } // 根据项目模板详情ID保存自评得分、打分时间 - if (CollUtil.isEmpty(appraisalInfoList)){ + if (CollUtil.isEmpty(appraisalInfoList)) { throw new BizException("填写所有自评得分后才能提交!"); } List ids = appraisalInfoList.stream() @@ -334,7 +337,7 @@ public class OrgSelfAppraisalManage { // 查出项目模版详情信息 List detailList = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .in(PerformanceIndicatorProjectTemplateDetail::getId, ids)); - if (CollUtil.isEmpty(detailList)){ + if (CollUtil.isEmpty(detailList)) { throw new BizException("评价指标不存在!"); } Map detailMap = detailList.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, d -> d)); @@ -342,7 +345,7 @@ public class OrgSelfAppraisalManage { PerformanceIndicatorProjectTemplateDetail templateDetail = detailMap.get(a.getProjectTemplateDetailId()); BigDecimal score = a.getScore(); BigDecimal indexScore = templateDetail.getIndexScore(); - if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){ + if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0) { throw new BizException("自评得分必须大于等于0且小于等于指标分值!"); } // 保存自评分数信息 @@ -353,17 +356,17 @@ public class OrgSelfAppraisalManage { scoreInfo.setAppraisalType(AppraisalTypeEnum.SELF_APPRAISAL.getCode()); scoreInfo.setTemplateDetailId(templateDetail.getId()); scoreInfo.setTemplateId(templateDetail.getTemplateId()); - scoreInfo.setAppraisalEmployeeCode(employeeCode); - scoreInfo.setAppraisalEmployeeName(username); + scoreInfo.setAppraisalUserId(String.valueOf(userDetail.getUserId())); + scoreInfo.setAppraisalUserName(userDetail.getRealName()); scoreInfo.setAppraisalId(appraisalId); scoreInfo.setAppraisalProjectId(appraisalProjectId); scoreInfo.setAppraisalProjectCode(appraisalProjectCode); scoreInfo.setCreateOn(LocalDateTime.now()); - scoreInfo.setCreateBy(username); + scoreInfo.setCreateBy(userDetail.getRealName()); return scoreInfo; }).collect(Collectors.toList()); - if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)){ + if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)) { // 计算自评总分并保存 BigDecimal selfAppraisalTotalScore = appraisalInfoList.stream() .map(ProjectAppraisalInfoDTO::getScore) @@ -373,7 +376,7 @@ public class OrgSelfAppraisalManage { appraisalProject.setSelfAppraisalScoreTime(LocalDateTime.now()); appraisalProject.setIsCompleteSelfAppraisal(Boolean.TRUE); appraisalProject.setUpdateOn(LocalDateTime.now()); - appraisalProject.setUpdateBy(username); + appraisalProject.setUpdateBy(userDetail.getRealName()); performanceAppraisalProjectService.updateById(appraisalProject); return "提交成功"; } @@ -381,48 +384,41 @@ public class OrgSelfAppraisalManage { } public void exportScore(HttpServletResponse response, PerformanceAppraisalExportReq param) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - String regionCode = user.getRegionCode(); String projectCode = param.getProjectCode(); Long appraisalId = param.getAppraisalId(); // 根据项目编码获取最新版本的项目信息 Project project = projectService.getProjectByCode(projectCode); - VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); + Assert.notNull(project, "项目不存在!"); // 根据项目类型、预算年度、批复金额、项目标签匹配本区域指标模版 String projectType = project.getProjectType(); Integer projectYear = project.getProjectYear(); BigDecimal approvalAmount = project.getApprovalAmount(); - VUtils.isTrue(Objects.isNull(approvalAmount)).throwMessage("未获取到该项目的立项批复金额"); + Assert.notNull(approvalAmount, "未获取到该项目的立项批复金额"); // 根据项目code获取项目标签ID列表 - List tagIdList = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) + String tagIdStr = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) .eq(ProjectTag::getProjectCode, projectCode)).stream() - .map(ProjectTag::getTagId).collect(Collectors.toList()); - VUtils.isTrue(CollUtil.isEmpty(tagIdList)).throwMessage("当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!"); - - List strIdList = tagIdList.stream().map(String::valueOf).collect(Collectors.toList()); - String projectTagIds = String.join(StrPool.COMMA, strIdList); - + .map(w -> w.getTagId().toString()).collect(Collectors.joining(",")); + Assert.notEmpty(tagIdStr, "当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!"); Integer amountRange = null; - if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) < 0){ + if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) < 0) { amountRange = ProjectBizConst.AMOUNT_RANGE_ONE; } else if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) >= 0 && approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.TWENTY_MILLION)) < 0) { amountRange = ProjectBizConst.AMOUNT_RANGE_TWO; - }else if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.TWENTY_MILLION)) >= 0){ + } else if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.TWENTY_MILLION)) >= 0) { amountRange = ProjectBizConst.AMOUNT_RANGE_THREE; } LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class) - .eq(PerformanceIndicatorProjectTemplate::getRegionCode, regionCode) .eq(PerformanceIndicatorProjectTemplate::getProjectType, projectType) .eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) .eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) - .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) - .eq(PerformanceIndicatorProjectTemplate::getStatus,CommonEnum.YES.getCode()) + .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds, tagIdStr) + .eq(PerformanceIndicatorProjectTemplate::getStatus, CommonEnum.YES.getCode()) .orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); List templates = indicatorProjectTemplateService.list(wrapper); VUtils.isTrue(CollUtil.isEmpty(templates)).throwMessage("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); - if (templates.size() > 1){ + if (templates.size() > 1) { throw new BizException("当前项目匹配到多个模板,请返回模板库检查模板配置!"); } PerformanceIndicatorProjectTemplate projectTemplate = templates.get(0); @@ -442,7 +438,7 @@ public class OrgSelfAppraisalManage { .orderBy(Boolean.TRUE, Boolean.TRUE, PerformanceAppraisalScoreInfo::getTemplateDetailId)); Map scoreInfoMap = scoreInfoList.stream() .collect(Collectors.toMap(PerformanceAppraisalScoreInfo::getTemplateDetailId, p -> p)); - + // 筛选出所有打分的三级指标模板详情ID for (PerformanceAppraisalScoreInfo scoreInfo : scoreInfoList) { SelfAppraisalScoreExportDTO thirdDto = new SelfAppraisalScoreExportDTO(); @@ -471,7 +467,7 @@ public class OrgSelfAppraisalManage { thirdDto.setSecondIndexName(secondTemplateDetail.getName()); // 一级指标名称 Long firstId = secondTemplateDetail.getParentId(); - if (Objects.nonNull(firstId)){ + if (Objects.nonNull(firstId)) { PerformanceIndicatorProjectTemplateDetail firstTemplateDetail = templateDetailMap.get(firstId); if (Objects.nonNull(firstTemplateDetail)) { thirdDto.setFirstIndexName(firstTemplateDetail.getName()); @@ -481,7 +477,7 @@ public class OrgSelfAppraisalManage { } if (Boolean.FALSE.equals(thirdTemplateDetail.getIsAdditional())) { exportDataList.add(thirdDto); - }else { + } else { exportAdditionalDataList.add(thirdDto); } } @@ -496,14 +492,13 @@ public class OrgSelfAppraisalManage { try { EasyExcel.write(response.getOutputStream(), SelfAppraisalScoreExportDTO.class) .autoCloseStream(false) - .registerWriteHandler(new MultiColumnMergeStrategy(exportDataList.size(),0,1)) - .registerWriteHandler(new ExcelFillCellMergeStrategy(mergeRowIndex,mergeColumnIndex)) + .registerWriteHandler(new MultiColumnMergeStrategy(exportDataList.size(), 0, 1)) + .registerWriteHandler(new ExcelFillCellMergeStrategy(mergeRowIndex, mergeColumnIndex)) .registerWriteHandler(ExcelExportStyle.formalStyle()) .sheet(fileName) .doWrite(exportDataList); } catch (IOException e) { throw new BizException(e); } - } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/PerformanceAppraisalPlanManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/PerformanceAppraisalPlanManage.java index f8e58ba..e8b8e45 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/PerformanceAppraisalPlanManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/PerformanceAppraisalPlanManage.java @@ -1,19 +1,9 @@ package com.hz.pm.api.performance.manage; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -import com.hz.pm.api.performance.model.entity.*; -import com.hz.pm.api.performance.service.*; -import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; -import com.hz.pm.api.projectlib.manage.ProjectLibManage; -import com.hz.pm.api.projectlib.model.req.ProjectListReq; -import com.hz.pm.api.projectlib.model.vo.ProjectApplicationVO; -import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.NumberUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -21,29 +11,31 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.NdDateUtils; -import com.ningdatech.basic.util.StrPool; +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.CommonConst; -import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.CodeUtil; import com.hz.pm.api.performance.convert.PerformanceAppraisalConveter; import com.hz.pm.api.performance.enumration.EvalObjectEnum; import com.hz.pm.api.performance.model.dto.*; +import com.hz.pm.api.performance.model.entity.*; import com.hz.pm.api.performance.model.req.PerformanceAppraisalListReq; import com.hz.pm.api.performance.model.vo.PerformanceAppraisalApplicationVO; import com.hz.pm.api.performance.model.vo.PerformanceAppraisalProjectGroupVO; import com.hz.pm.api.performance.model.vo.PerformanceAppraisalProjectVO; import com.hz.pm.api.performance.model.vo.PerformanceAppraisalVO; -import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; +import com.hz.pm.api.performance.service.*; +import com.hz.pm.api.projectlib.manage.ProjectLibManage; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectApplication; import com.hz.pm.api.projectlib.model.entity.ProjectInst; +import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; +import com.hz.pm.api.projectlib.model.req.ProjectListReq; +import com.hz.pm.api.projectlib.model.vo.ProjectApplicationVO; +import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; import com.hz.pm.api.projectlib.service.IProjectApplicationService; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; @@ -51,15 +43,22 @@ import com.hz.pm.api.todocenter.utils.BuildUserUtils; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.NdDateUtils; +import com.ningdatech.basic.util.StrPool; import com.wflow.workflow.bean.process.ProgressNode; import com.wflow.workflow.bean.vo.ProcessProgressVo; import com.wflow.workflow.service.ProcessInstanceService; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; /** * @Classname PerformanceAppraisalManage @@ -89,6 +88,7 @@ public class PerformanceAppraisalPlanManage { /** * 绩效列表 + * * @param req * @return */ @@ -96,64 +96,64 @@ public class PerformanceAppraisalPlanManage { Page page = req.page(); String regionCode = req.getRegionCode(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) - .like(StringUtils.isNotBlank(req.getPlanName()),PerformanceAppraisal::getName,req.getPlanName()) - .ge(Objects.nonNull(req.getStart()),PerformanceAppraisal::getCreateOn,req.getStart()) - .le(Objects.nonNull(req.getEnd()),PerformanceAppraisal::getCreateOn,req.getEnd()) - .eq(StringUtils.isNotBlank(regionCode), PerformanceAppraisal::getRegionCode,regionCode) + .like(StringUtils.isNotBlank(req.getPlanName()), PerformanceAppraisal::getName, req.getPlanName()) + .ge(Objects.nonNull(req.getStart()), PerformanceAppraisal::getCreateOn, req.getStart()) + .le(Objects.nonNull(req.getEnd()), PerformanceAppraisal::getCreateOn, req.getEnd()) + .eq(StringUtils.isNotBlank(regionCode), PerformanceAppraisal::getRegionCode, regionCode) .orderByDesc(PerformanceAppraisal::getUpdateOn); // 如果登录用户是区域管理员,能看到本区域的评价计划 - performanceAppraisalService.page(page,wrapper); - if(CollUtil.isEmpty(page.getRecords())){ + performanceAppraisalService.page(page, wrapper); + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } - List paIds = page.getRecords().stream().map(PerformanceAppraisal::getId).collect(Collectors.toList()); + List paIds = page.getRecords().stream().map(PerformanceAppraisal::getId).collect(Collectors.toList()); List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .in(PerformanceAppraisalProject::getAppraisalId, paIds)); - Map projectMap = Maps.newHashMap(); - Map> papsGroupMap = Maps.newHashMap(); - if(CollUtil.isNotEmpty(paps)){ + Map projectMap = Maps.newHashMap(); + Map> papsGroupMap = Maps.newHashMap(); + if (CollUtil.isNotEmpty(paps)) { papsGroupMap = paps.stream().collect(Collectors.groupingBy(PerformanceAppraisalProject::getAppraisalId)); List projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); List projects = projectService.list(Wrappers.lambdaQuery(Project.class) .in(Project::getProjectCode, projectCodes) .eq(Project::getNewest, Boolean.TRUE)); - if(CollUtil.isNotEmpty(projects)){ - projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); + if (CollUtil.isNotEmpty(projects)) { + projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode, p -> p)); } } List paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) .in(PerformanceAppraisalApplication::getAppraisalId, paIds)); - Map applicationMap = Maps.newHashMap(); - Map> paasGroupMap = Maps.newHashMap(); - if(CollUtil.isNotEmpty(paas)){ + Map applicationMap = Maps.newHashMap(); + Map> paasGroupMap = Maps.newHashMap(); + if (CollUtil.isNotEmpty(paas)) { paasGroupMap = paas.stream().collect(Collectors.groupingBy(PerformanceAppraisalApplication::getAppraisalId)); List applicationIds = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); List apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .in(ProjectApplication::getId, applicationIds)); - if(CollUtil.isNotEmpty(apps)){ - applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId,a -> a)); + if (CollUtil.isNotEmpty(apps)) { + applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId, a -> a)); } } Map> finalPapsGroupMap = papsGroupMap; - Map> finalPaasGroupMap = paasGroupMap; - Map finalProjectMap = projectMap; - Map finalApplicationMap = applicationMap; + Map> finalPaasGroupMap = paasGroupMap; + Map finalProjectMap = projectMap; + Map finalApplicationMap = applicationMap; List res = page.getRecords().stream().map(p -> { - PerformanceAppraisalVO vo = BeanUtil.copyProperties(p,PerformanceAppraisalVO.class); - if(finalPapsGroupMap.containsKey(p.getId())){ - vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(p.getId()),finalProjectMap)); + PerformanceAppraisalVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalVO.class); + if (finalPapsGroupMap.containsKey(p.getId())) { + vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(p.getId()), finalProjectMap)); } - if(finalPaasGroupMap.containsKey(p.getId())){ - vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(p.getId()),finalApplicationMap)); + if (finalPaasGroupMap.containsKey(p.getId())) { + vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(p.getId()), finalApplicationMap)); } return vo; }).collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } public PerformanceAppraisalVO detail(Long id) { @@ -161,56 +161,56 @@ public class PerformanceAppraisalPlanManage { PerformanceAppraisal pa = performanceAppraisalService.getById(id); VUtils.isTrue(Objects.isNull(pa)).throwMessage("该计划不存在"); - PerformanceAppraisalVO vo = BeanUtil.copyProperties(pa,PerformanceAppraisalVO.class); + PerformanceAppraisalVO vo = BeanUtil.copyProperties(pa, PerformanceAppraisalVO.class); //绩效关联的项目 List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .eq(PerformanceAppraisalProject::getAppraisalId, id)); - Map projectMap = Maps.newHashMap(); - Map> papsGroupMap = Maps.newHashMap(); - if(CollUtil.isNotEmpty(paps)){ + Map projectMap = Maps.newHashMap(); + Map> papsGroupMap = Maps.newHashMap(); + if (CollUtil.isNotEmpty(paps)) { papsGroupMap = paps.stream().collect(Collectors.groupingBy(PerformanceAppraisalProject::getAppraisalId)); List projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); List projects = projectService.list(Wrappers.lambdaQuery(Project.class) .in(Project::getProjectCode, projectCodes) .eq(Project::getNewest, Boolean.TRUE)); - if(CollUtil.isNotEmpty(projects)){ - projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); + if (CollUtil.isNotEmpty(projects)) { + projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode, p -> p)); } } //绩效关联的应用 List paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) .eq(PerformanceAppraisalApplication::getAppraisalId, id)); - Map applicationMap = Maps.newHashMap(); - Map> paasGroupMap = Maps.newHashMap(); - if(CollUtil.isNotEmpty(paas)){ + Map applicationMap = Maps.newHashMap(); + Map> paasGroupMap = Maps.newHashMap(); + if (CollUtil.isNotEmpty(paas)) { paasGroupMap = paas.stream().collect(Collectors.groupingBy(PerformanceAppraisalApplication::getAppraisalId)); List applicationIds = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); List apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .in(ProjectApplication::getId, applicationIds)); - if(CollUtil.isNotEmpty(apps)){ - applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId,a -> a)); + if (CollUtil.isNotEmpty(apps)) { + applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId, a -> a)); } } Map> finalPapsGroupMap = papsGroupMap; - Map> finalPaasGroupMap = paasGroupMap; - Map finalProjectMap = projectMap; - Map finalApplicationMap = applicationMap; - if(finalPapsGroupMap.containsKey(vo.getId())){ - vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(vo.getId()),finalProjectMap)); + Map> finalPaasGroupMap = paasGroupMap; + Map finalProjectMap = projectMap; + Map finalApplicationMap = applicationMap; + if (finalPapsGroupMap.containsKey(vo.getId())) { + vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(vo.getId()), finalProjectMap)); } - if(finalPaasGroupMap.containsKey(vo.getId())){ - vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(vo.getId()),finalApplicationMap)); + if (finalPaasGroupMap.containsKey(vo.getId())) { + vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(vo.getId()), finalApplicationMap)); } // 评价计划关联的分组信息 List groupList = groupService.list(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) .eq(PerformanceAppraisalProjectGroup::getAppraisalId, id)); // 对计划内待评价项目进行了分组 - if (CollUtil.isNotEmpty(groupList)){ + if (CollUtil.isNotEmpty(groupList)) { // 获取分组信息 List groups = groupList.stream().map(g -> { PerformanceAppraisalProjectGroupVO groupVo = new PerformanceAppraisalProjectGroupVO(); @@ -219,14 +219,14 @@ public class PerformanceAppraisalPlanManage { groupVo.setName(g.getName()); String reAppraisalUsersStr = g.getReAppraisalUsers(); List reAppraisalUsers = Arrays.stream(reAppraisalUsersStr.split(StrPool.COMMA)) - .map(userInfoHelper::getUserFullInfoByEmployeeCode).collect(Collectors.toList()); + .map(w -> userInfoHelper.getUserFullInfo(Long.parseLong(w))).collect(Collectors.toList()); groupVo.setReAppraisalUsers(reAppraisalUsers); String verificationUsersStr = g.getVerificationUsers(); List verificationUsers = Arrays.stream(verificationUsersStr.split(StrPool.COMMA)) - .map(userInfoHelper::getUserFullInfoByEmployeeCode).collect(Collectors.toList()); + .map(w -> userInfoHelper.getUserFullInfo(Long.parseLong(w))).collect(Collectors.toList()); groupVo.setVerificationUsers(verificationUsers); - if (StringUtils.isNotBlank(g.getVerifyLeader())){ - UserFullInfoDTO dto = userInfoHelper.getUserFullInfoByEmployeeCode(g.getVerifyLeader()); + if (StringUtils.isNotBlank(g.getVerifyLeader())) { + UserFullInfoDTO dto = userInfoHelper.getUserFullInfo(Long.valueOf(g.getVerifyLeader())); groupVo.setVerifyLeader(dto); } groupVo.setCreateOn(g.getCreateOn()); @@ -239,6 +239,7 @@ public class PerformanceAppraisalPlanManage { /** * 新建计划 + * * @param createDTO * @return */ @@ -247,26 +248,25 @@ public class PerformanceAppraisalPlanManage { UserInfoDetails user = LoginUserUtil.loginUserDetail(); // 计划名称重复校验 deduplicationName(createDTO); - PerformanceAppraisal pa = BeanUtil.copyProperties(createDTO,PerformanceAppraisal.class); + PerformanceAppraisal pa = BeanUtil.copyProperties(createDTO, PerformanceAppraisal.class); pa.setCreateOn(LocalDateTime.now()); pa.setCreateBy(user.getUsername()); pa.setUpdateOn(LocalDateTime.now()); pa.setUpdateBy(user.getUsername()); - pa.setRegionCode(user.getRegionCode()); performanceAppraisalService.save(pa); - if(CollUtil.isNotEmpty(createDTO.getProjects()) + if (CollUtil.isNotEmpty(createDTO.getProjects()) && StringUtils.isNotBlank(createDTO.getTarget()) - && createDTO.getTarget().contains(EvalObjectEnum.PROJECT.getCode())){ - saveProjects(createDTO,pa.getId(),user); + && createDTO.getTarget().contains(EvalObjectEnum.PROJECT.getCode())) { + saveProjects(createDTO, pa.getId(), user); } - if(CollUtil.isNotEmpty(createDTO.getApplicationIds()) + if (CollUtil.isNotEmpty(createDTO.getApplicationIds()) && StringUtils.isNotBlank(createDTO.getTarget()) - && createDTO.getTarget().contains(EvalObjectEnum.APP.getCode())){ - saveApplications(createDTO,pa.getId(),user); + && createDTO.getTarget().contains(EvalObjectEnum.APP.getCode())) { + saveApplications(createDTO, pa.getId(), user); } return "新建成功"; @@ -275,6 +275,7 @@ public class PerformanceAppraisalPlanManage { /** * 编辑计划 + * * @param editDTO * @return */ @@ -284,34 +285,34 @@ public class PerformanceAppraisalPlanManage { deduplicationName(editDTO); - PerformanceAppraisal pa = BeanUtil.copyProperties(editDTO,PerformanceAppraisal.class); + PerformanceAppraisal pa = BeanUtil.copyProperties(editDTO, PerformanceAppraisal.class); pa.setUpdateOn(LocalDateTime.now()); pa.setUpdateBy(user.getUsername()); performanceAppraisalService.updateById(pa); String target = editDTO.getTarget(); // 如果新编辑的评价计划不包含项目,删除原计划添加的评价项目信息 - if (StringUtils.isNotBlank(target) && !target.contains(EvalObjectEnum.PROJECT.getCode())){ + if (StringUtils.isNotBlank(target) && !target.contains(EvalObjectEnum.PROJECT.getCode())) { performanceAppraisalProjectService.remove(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId,editDTO.getId())); + .eq(PerformanceAppraisalProject::getAppraisalId, editDTO.getId())); } // 如果新编辑的评价计划不包含应用,删除原计划添加的评价应用信息 - if (StringUtils.isNotBlank(target) && !target.contains(EvalObjectEnum.APP.getCode())){ + if (StringUtils.isNotBlank(target) && !target.contains(EvalObjectEnum.APP.getCode())) { performanceAppraisalApplicationService.remove(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) - .eq(PerformanceAppraisalApplication::getAppraisalId,editDTO.getId())); + .eq(PerformanceAppraisalApplication::getAppraisalId, editDTO.getId())); } - if(StringUtils.isNotBlank(target) && + if (StringUtils.isNotBlank(target) && target.contains(EvalObjectEnum.PROJECT.getCode()) && - CollUtil.isNotEmpty(editDTO.getProjects())){ - saveProjects(editDTO,user); + CollUtil.isNotEmpty(editDTO.getProjects())) { + saveProjects(editDTO, user); } - if(StringUtils.isNotBlank(target) && + if (StringUtils.isNotBlank(target) && target.contains(EvalObjectEnum.APP.getCode()) && - CollUtil.isNotEmpty(editDTO.getApplicationIds())){ - saveApplications(editDTO,user); + CollUtil.isNotEmpty(editDTO.getApplicationIds())) { + saveApplications(editDTO, user); } return "编辑成功"; @@ -319,6 +320,7 @@ public class PerformanceAppraisalPlanManage { /** * 名称去重 + * * @param dto */ private void deduplicationName(PerformanceAppraisalCreateDTO dto) { @@ -328,17 +330,17 @@ public class PerformanceAppraisalPlanManage { } private void deduplicationName(PerformanceAppraisalEditDTO dto) { - if(StringUtils.isNotBlank(dto.getName())){ - long count =performanceAppraisalService.count(Wrappers.lambdaQuery(PerformanceAppraisal.class) - .eq(PerformanceAppraisal::getName,dto.getName()) - .ne(Objects.nonNull(dto.getId()),PerformanceAppraisal::getId,dto.getId())); + if (StringUtils.isNotBlank(dto.getName())) { + long count = performanceAppraisalService.count(Wrappers.lambdaQuery(PerformanceAppraisal.class) + .eq(PerformanceAppraisal::getName, dto.getName()) + .ne(Objects.nonNull(dto.getId()), PerformanceAppraisal::getId, dto.getId())); VUtils.isTrue(count > 0).throwMessage("名称已经存在"); } } @Transactional - public void saveProjects(PerformanceAppraisalCreateDTO createDTO,Long id,UserInfoDetails user) { - if(CollUtil.isEmpty(createDTO.getProjects())){ + public void saveProjects(PerformanceAppraisalCreateDTO createDTO, Long id, UserInfoDetails user) { + if (CollUtil.isEmpty(createDTO.getProjects())) { return; } Integer startSelfDays = createDTO.getStartSelfDays(); @@ -350,7 +352,7 @@ public class PerformanceAppraisalPlanManage { List projectIdList = projects.stream().map(AppraisalProjectDTO::getId).collect(Collectors.toList()); // 判断提交时,项目是否已经被添加到其他评价计划中 - if (Boolean.TRUE.equals(haveIntersection(projectIdList, proIdList))){ + if (Boolean.TRUE.equals(haveIntersection(projectIdList, proIdList))) { // 得到交集 List intersection = Lists.newArrayList(projectIdList); intersection.retainAll(proIdList); @@ -365,7 +367,7 @@ public class PerformanceAppraisalPlanManage { throw new BizException(names + CommonConst.PROJECT_REPEAT); } - for(AppraisalProjectDTO appraisalProject : projects){ + for (AppraisalProjectDTO appraisalProject : projects) { Project newProject = projectService.getNewProject(appraisalProject.getId()); VUtils.isTrue(Objects.isNull(newProject)).throwMessage("项目不存在 " + appraisalProject.getId()); // 获取项目终验完成的时间 @@ -399,7 +401,7 @@ public class PerformanceAppraisalPlanManage { .orderByDesc(ProjectInst::getCreatOn) .last(BizConst.LIMIT_1)); - if (Objects.isNull(projectInst)){ + if (Objects.isNull(projectInst)) { throw new BizException("未获取到项目终验审批流程信息!"); } @@ -412,15 +414,15 @@ public class PerformanceAppraisalPlanManage { buildUserUtils.buildUserByProcessInfo(progressInfo); ProgressNode progressNode = progressInfo.get(progressInfo.size() - 1); finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime()); - }else { + } else { finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime()); } return finishTime; } @Transactional - public void saveApplications(PerformanceAppraisalCreateDTO createDTO,Long id,UserInfoDetails user) { - if(CollUtil.isEmpty(createDTO.getApplicationIds())){ + public void saveApplications(PerformanceAppraisalCreateDTO createDTO, Long id, UserInfoDetails user) { + if (CollUtil.isEmpty(createDTO.getApplicationIds())) { return; } @@ -430,7 +432,7 @@ public class PerformanceAppraisalPlanManage { .map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); // 如果有交集,说明选择的应用中,有已经在其他评价计划中的应用 - if (Boolean.TRUE.equals(haveIntersection(applicationIdList, applicationIds))){ + if (Boolean.TRUE.equals(haveIntersection(applicationIdList, applicationIds))) { // 得到交集 List intersection = Lists.newArrayList(applicationIdList); intersection.retainAll(applicationIds); @@ -449,12 +451,12 @@ public class PerformanceAppraisalPlanManage { Map applicationMap = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .in(ProjectApplication::getId, applicationIdList)).stream() .collect(Collectors.toMap(ProjectApplication::getId, a -> a)); - for(Long applicationId : applicationIdList){ + for (Long applicationId : applicationIdList) { PerformanceAppraisalApplication paa = new PerformanceAppraisalApplication(); paa.setAppraisalId(id); paa.setApplicationId(applicationId); ProjectApplication projectApplication = applicationMap.get(applicationId); - if (Objects.nonNull(projectApplication)){ + if (Objects.nonNull(projectApplication)) { paa.setAppraisalProjectId(projectApplication.getProjectId()); paa.setAppraisalProjectCode(projectApplication.getProjectCode()); } @@ -467,29 +469,29 @@ public class PerformanceAppraisalPlanManage { } @Transactional - public void saveProjects(PerformanceAppraisalEditDTO editDTO,UserInfoDetails user) { - if(Objects.isNull(editDTO.getProjects())){ + public void saveProjects(PerformanceAppraisalEditDTO editDTO, UserInfoDetails user) { + if (Objects.isNull(editDTO.getProjects())) { return; } // 删除计划内的项目 performanceAppraisalProjectService.remove(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId,editDTO.getId())); + .eq(PerformanceAppraisalProject::getAppraisalId, editDTO.getId())); // 删除项目的打分信息 List projectIds = editDTO.getProjects().stream().map(AppraisalProjectDTO::getId).collect(Collectors.toList()); - if (CollUtil.isEmpty(projectIds)){ + if (CollUtil.isEmpty(projectIds)) { throw new BizException("请选择至少一个评价项目!"); } List projectCodes = projectService.listByIds(projectIds).stream().map(Project::getProjectCode).collect(Collectors.toList()); // 删除项目的打分信息 performanceAppraisalScoreInfoService.remove(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) - .eq(PerformanceAppraisalScoreInfo::getAppraisalId,editDTO.getId()) - .in(PerformanceAppraisalScoreInfo::getAppraisalProjectCode,projectCodes)); + .eq(PerformanceAppraisalScoreInfo::getAppraisalId, editDTO.getId()) + .in(PerformanceAppraisalScoreInfo::getAppraisalProjectCode, projectCodes)); Integer startSelfDays = editDTO.getStartSelfDays(); Integer completeSelfDays = editDTO.getCompleteSelfDays(); List projects = editDTO.getProjects(); - for(AppraisalProjectDTO appraisalProject : projects){ + for (AppraisalProjectDTO appraisalProject : projects) { Project newProject = projectService.getNewProject(appraisalProject.getId()); VUtils.isTrue(Objects.isNull(newProject)).throwMessage("项目不存在 " + appraisalProject.getId()); // 获取项目终验完成的时间 @@ -513,32 +515,32 @@ public class PerformanceAppraisalPlanManage { } @Transactional - public void saveApplications(PerformanceAppraisalEditDTO editDTO,UserInfoDetails user) { - if(Objects.isNull(editDTO.getApplicationIds())){ + public void saveApplications(PerformanceAppraisalEditDTO editDTO, UserInfoDetails user) { + if (Objects.isNull(editDTO.getApplicationIds())) { return; } // 删除计划内的应用 performanceAppraisalApplicationService.remove(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) - .eq(PerformanceAppraisalApplication::getAppraisalId,editDTO.getId())); + .eq(PerformanceAppraisalApplication::getAppraisalId, editDTO.getId())); // 删除计划内应用的打分信息 List applicationIdList = editDTO.getApplicationIds(); - if (CollUtil.isEmpty(applicationIdList)){ + if (CollUtil.isEmpty(applicationIdList)) { throw new BizException("请选择至少一个应用!"); } // 删除应用的打分信息 performanceAppraisalAppScoreInfoService.remove(Wrappers.lambdaQuery(PerformanceAppraisalAppScoreInfo.class) - .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId,editDTO.getId()) - .in(PerformanceAppraisalAppScoreInfo::getApplicationId,applicationIdList)); + .eq(PerformanceAppraisalAppScoreInfo::getAppraisalId, editDTO.getId()) + .in(PerformanceAppraisalAppScoreInfo::getApplicationId, applicationIdList)); Map applicationMap = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .in(ProjectApplication::getId, applicationIdList)).stream() .collect(Collectors.toMap(ProjectApplication::getId, a -> a)); - for(Long applicationId : applicationIdList){ + for (Long applicationId : applicationIdList) { PerformanceAppraisalApplication paa = new PerformanceAppraisalApplication(); paa.setAppraisalId(editDTO.getId()); paa.setApplicationId(applicationId); ProjectApplication projectApplication = applicationMap.get(applicationId); - if (Objects.nonNull(projectApplication)){ + if (Objects.nonNull(projectApplication)) { paa.setAppraisalProjectId(projectApplication.getProjectId()); paa.setAppraisalProjectCode(projectApplication.getProjectCode()); } @@ -553,6 +555,7 @@ public class PerformanceAppraisalPlanManage { /** * 删除绩效评价计划 * 连带删除 其下所有 + * * @param id * @return */ @@ -563,17 +566,17 @@ public class PerformanceAppraisalPlanManage { // 获取评价计划内的待评价项目信息,并按自评开始时间排序 List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .eq(PerformanceAppraisalProject::getAppraisalId, id) - .orderBy(Boolean.TRUE,Boolean.TRUE,PerformanceAppraisalProject::getSelfAppraisalStart)); + .orderBy(Boolean.TRUE, Boolean.TRUE, PerformanceAppraisalProject::getSelfAppraisalStart)); // 获取计划内项目的自评开始时间 Optional min = paps.stream().map(PerformanceAppraisalProject::getSelfAppraisalStart).min(LocalDateTime::compareTo); - if (min.isPresent()){ + if (min.isPresent()) { // 比较当前时间与自评开始时间最小值 - if (LocalDateTime.now().isAfter(min.get())){ + if (LocalDateTime.now().isAfter(min.get())) { throw new BizException("评价计划内已有项目到达自评时间,无法删除!"); } } - if(performanceAppraisalService.removeById(id)){ + if (performanceAppraisalService.removeById(id)) { // 删除评价计划关联的项目 //绩效关联的项目 if (CollUtil.isNotEmpty(paps)) { @@ -586,7 +589,6 @@ public class PerformanceAppraisalPlanManage { if (CollUtil.isNotEmpty(scoreInfos)) { performanceAppraisalScoreInfoService.removeBatchByIds(scoreInfos); } - } // 删除评价计划关联的应用 //绩效关联的应用 @@ -606,56 +608,52 @@ public class PerformanceAppraisalPlanManage { } // 删除评级计划关联的分组信息 groupService.remove(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) - .eq(PerformanceAppraisalProjectGroup::getAppraisalId,id)); + .eq(PerformanceAppraisalProjectGroup::getAppraisalId, id)); return "删除成功"; } return "删除失败"; } - public List groupList(Long appraisalId,String name) { + public List groupList(Long appraisalId, String name) { List groups = groupService.list( Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) .eq(PerformanceAppraisalProjectGroup::getAppraisalId, appraisalId) - .like(StringUtils.isNotBlank(name),PerformanceAppraisalProjectGroup::getName,name) + .like(StringUtils.isNotBlank(name), PerformanceAppraisalProjectGroup::getName, name) .orderByDesc(PerformanceAppraisalProjectGroup::getCreateOn)); - if(CollUtil.isEmpty(groups)){ + if (CollUtil.isEmpty(groups)) { return Collections.emptyList(); } Set allEmployeeCodes = Sets.newHashSet(); Set projectCodes = Sets.newHashSet(); - Map userMap = Maps.newHashMap(); + Map userMap = Maps.newHashMap(); Map projectMap = Maps.newHashMap(); - groups.stream().forEach(g -> { + groups.forEach(g -> { allEmployeeCodes.addAll(CodeUtil.convertStrToList(g.getReAppraisalUsers())); allEmployeeCodes.addAll(CodeUtil.convertStrToList(g.getVerificationUsers())); projectCodes.addAll(CodeUtil.convertStrToList(g.getProjectCodes())); }); - if(CollUtil.isNotEmpty(allEmployeeCodes)){ + if (CollUtil.isNotEmpty(allEmployeeCodes)) { List users = Lists.newArrayList(); for (String employeeCode : allEmployeeCodes) { - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); + UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(Long.parseLong(employeeCode)); users.add(userFullInfo); } - if(CollUtil.isNotEmpty(users)){ - userMap = users.stream().collect(Collectors.toMap(UserFullInfoDTO::getEmployeeCode,u -> u)); - } + users.forEach(w -> userMap.put(w.getUserId(), w)); } - if(CollUtil.isNotEmpty(projectCodes)){ + if (CollUtil.isNotEmpty(projectCodes)) { List projects = projectService.list(Wrappers.lambdaQuery(Project.class) - .in(Project::getProjectCode,projectCodes) - .eq(Project::getNewest,Boolean.TRUE)); - if(CollUtil.isNotEmpty(projects)){ - projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); + .in(Project::getProjectCode, projectCodes) + .eq(Project::getNewest, Boolean.TRUE)); + if (CollUtil.isNotEmpty(projects)) { + projects.forEach(w -> projectMap.put(w.getProjectCode(), w)); } } - Map finalProjectMap = projectMap; - Map finalUserMap = userMap; return groups.stream().map(g -> { - PerformanceAppraisalProjectGroupVO vo = new PerformanceAppraisalProjectGroupVO(); + PerformanceAppraisalProjectGroupVO vo = new PerformanceAppraisalProjectGroupVO(); vo.setAppraisalId(g.getAppraisalId()); vo.setName(g.getName()); vo.setCreateOn(g.getCreateOn()); @@ -663,11 +661,11 @@ public class PerformanceAppraisalPlanManage { vo.setUpdateBy(g.getUpdateBy()); vo.setUpdateOn(g.getUpdateOn()); vo.setId(g.getId()); - vo.setProjects(checkProject(g.getProjectCodes(), finalProjectMap)); - vo.setReAppraisalUsers(checkUser(g.getReAppraisalUsers(), finalUserMap)); - vo.setVerificationUsers(checkUser(g.getVerificationUsers(), finalUserMap)); - if (StringUtils.isNotBlank(g.getVerifyLeader())){ - UserFullInfoDTO userFullInfoDto = finalUserMap.get(g.getVerifyLeader()); + vo.setProjects(checkProject(g.getProjectCodes(), projectMap)); + vo.setReAppraisalUsers(checkUser(g.getReAppraisalUsers(), userMap)); + vo.setVerificationUsers(checkUser(g.getVerificationUsers(), userMap)); + if (StringUtils.isNotBlank(g.getVerifyLeader())) { + UserFullInfoDTO userFullInfoDto = userMap.get(Long.parseLong(g.getVerifyLeader())); vo.setVerifyLeader(userFullInfoDto); } return vo; @@ -676,38 +674,36 @@ public class PerformanceAppraisalPlanManage { /** * 分组详情 + * * @param id * @return */ public PerformanceAppraisalProjectGroupVO groupDetail(Long id) { PerformanceAppraisalProjectGroup group = groupService.getById(id); - - if(Objects.isNull(group)){ + if (Objects.isNull(group)) { return null; } Map projectMap = Maps.newHashMap(); List projects = projectService.list(Wrappers.lambdaQuery(Project.class) - .in(StringUtils.isNotBlank(group.getProjectCodes()),Project::getProjectCode, - Arrays.stream(group.getProjectCodes().split(StrPool.COMMA)).collect(Collectors.toList())) - .eq(Project::getNewest,Boolean.TRUE)); - if(CollUtil.isNotEmpty(projects)){ - projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); + .in(StringUtils.isNotBlank(group.getProjectCodes()), + Project::getProjectCode, Arrays.stream(group.getProjectCodes() + .split(StrPool.COMMA)).collect(Collectors.toList())) + .eq(Project::getNewest, Boolean.TRUE)); + if (CollUtil.isNotEmpty(projects)) { + projects.forEach(w -> projectMap.put(w.getProjectCode(), w)); } - Map userMap = Maps.newHashMap(); + Map userMap = Maps.newHashMap(); Set allEmployeeCodes = Sets.newHashSet(); allEmployeeCodes.addAll(CodeUtil.convertStrToList(group.getReAppraisalUsers())); allEmployeeCodes.addAll(CodeUtil.convertStrToList(group.getVerificationUsers())); - if(CollUtil.isNotEmpty(allEmployeeCodes)){ + if (CollUtil.isNotEmpty(allEmployeeCodes)) { List users = Lists.newArrayList(); for (String employeeCode : allEmployeeCodes) { - UserFullInfoDTO userFullInfoDto = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); - users.add(userFullInfoDto); - } - if(CollUtil.isNotEmpty(users)){ - userMap = users.stream().collect(Collectors.toMap(UserFullInfoDTO::getEmployeeCode,u -> u)); + users.add(userInfoHelper.getUserFullInfo(Long.valueOf(employeeCode))); } + users.forEach(w -> userMap.put(w.getUserId(), w)); } PerformanceAppraisalProjectGroupVO vo = new PerformanceAppraisalProjectGroupVO(); @@ -721,8 +717,8 @@ public class PerformanceAppraisalPlanManage { vo.setProjects(checkProject(group.getProjectCodes(), projectMap)); vo.setReAppraisalUsers(checkUser(group.getReAppraisalUsers(), userMap)); vo.setVerificationUsers(checkUser(group.getVerificationUsers(), userMap)); - if (StringUtils.isNotBlank(group.getVerifyLeader())){ - UserFullInfoDTO dto = userMap.get(group.getVerifyLeader()); + if (StringUtils.isNotBlank(group.getVerifyLeader())) { + UserFullInfoDTO dto = userMap.get(Long.parseLong(group.getVerifyLeader())); vo.setVerifyLeader(dto); } return vo; @@ -730,6 +726,7 @@ public class PerformanceAppraisalPlanManage { /** * 分组 保存 + * * @param dto * @return */ @@ -740,11 +737,11 @@ public class PerformanceAppraisalPlanManage { // 获取当前评价计划内的分组信息 List groupList = groupService.list(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) .eq(PerformanceAppraisalProjectGroup::getAppraisalId, dto.getAppraisalId())); - if(Objects.isNull(dto.getId())){ + if (Objects.isNull(dto.getId())) { group.setId(null); group.setCreateOn(LocalDateTime.now()); group.setCreateBy(user.getUsername()); - }else{ + } else { // 编辑分组 PerformanceAppraisalProjectGroup old = groupService.getById(dto.getId()); VUtils.isTrue(Objects.isNull(old)).throwMessage("该分组不存在 编辑失败!"); @@ -752,7 +749,7 @@ public class PerformanceAppraisalPlanManage { // 先删除旧的分组 groupList.remove(old); } - if(CollUtil.isNotEmpty(dto.getProjectCodes())){ + if (CollUtil.isNotEmpty(dto.getProjectCodes())) { // 判断选择的项目是否已经在当前评价计划的其他分组内 // 获取当前评价计划的其他分组的项目信息 List projectCodeList = groupList.stream() @@ -760,17 +757,17 @@ public class PerformanceAppraisalPlanManage { .collect(Collectors.toList()); List compareCodes = Lists.newArrayList(); for (String projectCode : projectCodeList) { - if (projectCode.contains(StrPool.COMMA)){ + if (projectCode.contains(StrPool.COMMA)) { List codes = Arrays.asList(projectCode.split(StrPool.COMMA)); compareCodes.addAll(codes); - }else { + } else { compareCodes.add(projectCode); } } - checkProjectCodes(dto.getProjectCodes(),compareCodes); + checkProjectCodes(dto.getProjectCodes(), compareCodes); group.setProjectCodes(String.join(StrPool.COMMA, dto.getProjectCodes())); } - if(CollUtil.isNotEmpty(dto.getReAppraisalUsers())){ + if (CollUtil.isNotEmpty(dto.getReAppraisalUsers())) { // 判断选择的复评人员是否已经在当前评价计划的其他分组内 // 获取当前评价计划的其他分组的复评人员信息 List reUserList = groupList.stream() @@ -778,17 +775,17 @@ public class PerformanceAppraisalPlanManage { .collect(Collectors.toList()); List compareUsers = Lists.newArrayList(); for (String reUser : reUserList) { - if (reUser.contains(StrPool.COMMA)){ + if (reUser.contains(StrPool.COMMA)) { List users = Arrays.asList(reUser.split(StrPool.COMMA)); compareUsers.addAll(users); - }else { + } else { compareUsers.add(reUser); } } - checkReAppraisalAndVerifyUsers(dto.getReAppraisalUsers(),compareUsers,CommonConst.REAPPRAISAL_TYPE); + checkReAppraisalAndVerifyUsers(dto.getReAppraisalUsers(), compareUsers, CommonConst.REAPPRAISAL_TYPE); group.setReAppraisalUsers(String.join(StrPool.COMMA, dto.getReAppraisalUsers())); } - if(CollUtil.isNotEmpty(dto.getVerificationUsers())){ + if (CollUtil.isNotEmpty(dto.getVerificationUsers())) { // 判断选择的核查人员是否已经在当前评价计划的其他分组内 // 获取当前评价计划的其他分组的核查人员信息 List verifyList = groupList.stream() @@ -796,14 +793,14 @@ public class PerformanceAppraisalPlanManage { .collect(Collectors.toList()); List compareUsers = Lists.newArrayList(); for (String verifyUser : verifyList) { - if (verifyUser.contains(StrPool.COMMA)){ + if (verifyUser.contains(StrPool.COMMA)) { List users = Arrays.asList(verifyUser.split(StrPool.COMMA)); compareUsers.addAll(users); - }else { + } else { compareUsers.add(verifyUser); } } - checkReAppraisalAndVerifyUsers(dto.getVerificationUsers(),compareUsers,CommonConst.VERIFY_TYPE); + checkReAppraisalAndVerifyUsers(dto.getVerificationUsers(), compareUsers, CommonConst.VERIFY_TYPE); group.setVerificationUsers(String.join(StrPool.COMMA, dto.getVerificationUsers())); } group.setUpdateOn(LocalDateTime.now()); @@ -815,13 +812,13 @@ public class PerformanceAppraisalPlanManage { private void checkProjectCodes(List projectCodes, List projectCodeList) { // 判断选择的项目是否已经在当前评价计划的其他分组内 // 如果提交的项目在该评价计划其他分组中 - if (!CollectionUtil.intersection(projectCodes,projectCodeList).isEmpty()){ + if (!CollectionUtil.intersection(projectCodes, projectCodeList).isEmpty()) { ArrayList proCodes = Lists.newArrayList(projectCodes); proCodes.retainAll(projectCodeList); // 获取重复添加的项目Code String names = proCodes.stream().map(i -> { Project project = projectService.getProjectByCode(i); - if (Objects.nonNull(project)){ + if (Objects.nonNull(project)) { return project.getProjectName(); } return StrPool.EMPTY; @@ -832,20 +829,20 @@ public class PerformanceAppraisalPlanManage { private void checkReAppraisalAndVerifyUsers(List checkUsers, List compareUsers, Integer type) { // 如果提交的复评/核查人员在该评价计划其他分组中 - if (!CollectionUtil.intersection(checkUsers,compareUsers).isEmpty()){ + if (!CollectionUtil.intersection(checkUsers, compareUsers).isEmpty()) { ArrayList reUsers = Lists.newArrayList(checkUsers); reUsers.retainAll(compareUsers); // 获取重复添加的复评/核查人员名字 String names = reUsers.stream().map(i -> { - UserFullInfoDTO info = userInfoHelper.getUserFullInfoByEmployeeCode(i); - if (Objects.nonNull(info)){ + UserFullInfoDTO info = userInfoHelper.getUserFullInfo(Long.valueOf(i)); + if (Objects.nonNull(info)) { return info.getUsername(); } return StrPool.EMPTY; }).collect(Collectors.joining(StrPool.COMMA)); if (CommonConst.REAPPRAISAL_TYPE.equals(type)) { throw new BizException("复评人员:" + names + CommonConst.REPEAT); - }else if (CommonConst.VERIFY_TYPE.equals(type)){ + } else if (CommonConst.VERIFY_TYPE.equals(type)) { throw new BizException("核查人员:" + names + CommonConst.REPEAT); } } @@ -853,6 +850,7 @@ public class PerformanceAppraisalPlanManage { /** * 删除分组 + * * @param id * @return */ @@ -866,19 +864,19 @@ public class PerformanceAppraisalPlanManage { PerformanceAppraisal pa = performanceAppraisalService.getById(appraisalId); VUtils.isTrue(Objects.isNull(pa)).throwMessage("评价不存在"); - if(groupService.removeById(id)){ + if (groupService.removeById(id)) { return "删除成功"; } return "删除失败"; } private List checkProject(String projectIds, Map projectMap) { - if(StringUtils.isBlank(projectIds)){ + if (StringUtils.isBlank(projectIds)) { return Collections.emptyList(); } return Arrays.stream(projectIds.split(StrPool.COMMA)).map(projectCode -> { PerformanceAppraisalProjectVO vo = new PerformanceAppraisalProjectVO(); - if(projectMap.containsKey(projectCode)){ + if (projectMap.containsKey(projectCode)) { Project project = projectMap.get(projectCode); vo.setProjectName(project.getProjectName()); vo.setProjectTypeName(BizUtils.getProjectTypeName(project.getProjectType())); @@ -892,33 +890,33 @@ public class PerformanceAppraisalPlanManage { }).collect(Collectors.toList()); } - private List checkUser(String users, Map userMap) { - if(StringUtils.isBlank(users)){ + private List checkUser(String users, Map userMap) { + if (StringUtils.isBlank(users)) { return Collections.emptyList(); } - return Arrays.stream(users.split(StrPool.COMMA)).map(userMap::get).collect(Collectors.toList()); + return Arrays.stream(users.split(StrPool.COMMA)) + .filter(NumberUtil::isLong) + .map(w -> userMap.get(Long.parseLong(w))) + .collect(Collectors.toList()); } public PageVo applicationList(PerformanceAppraisalListReq req) { Page page = req.page(); // 获取登录用户所在区域已验收项目 - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - String regionCode = user.getRegionCode(); List projects = projectService.list(Wrappers.lambdaQuery(Project.class) - .eq(Project::getAreaCode,regionCode) .eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode()) .eq(Project::getNewest, Boolean.TRUE)); // 获取已验收项目关联的应用信息 List projectVersions = projects.stream().map(Project::getVersion).collect(Collectors.toList()); List projectCodes = projects.stream().map(Project::getProjectCode).collect(Collectors.toList()); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(ProjectApplication.class) - .like(StringUtils.isNotBlank(req.getApplicationName()),ProjectApplication::getApplicationName,req.getApplicationName()) - .like(StringUtils.isNotBlank(req.getBuildOrgName()),ProjectApplication::getBuildOrgName,req.getBuildOrgName()) - .in(ProjectApplication::getProjectCode,projectCodes) - .in(ProjectApplication::getProjectVersion,projectVersions) + .like(StringUtils.isNotBlank(req.getApplicationName()), ProjectApplication::getApplicationName, req.getApplicationName()) + .like(StringUtils.isNotBlank(req.getBuildOrgName()), ProjectApplication::getBuildOrgName, req.getBuildOrgName()) + .in(ProjectApplication::getProjectCode, projectCodes) + .in(ProjectApplication::getProjectVersion, projectVersions) .orderByDesc(ProjectApplication::getCreateOn); - applicationService.page(page,wrapper); - if(CollUtil.isEmpty(page.getRecords())){ + applicationService.page(page, wrapper); + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } List res = page.getRecords().stream().map(r -> { @@ -933,12 +931,12 @@ public class PerformanceAppraisalPlanManage { vo.setPublishSide(r.getPublishSide()); return vo; }).collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } public String addProject(AddAppraisalObjectDTO addDTO) { List projectIdList = addDTO.getProjectIds(); - if (CollUtil.isEmpty(projectIdList)){ + if (CollUtil.isEmpty(projectIdList)) { throw new BizException("请选择至少一个评价项目!"); } // 获取已经创建的评价计划中添加的评价项目ID @@ -947,7 +945,7 @@ public class PerformanceAppraisalPlanManage { Long appraisalId = addDTO.getAppraisalId(); // 如果评价计划不为空,说明是编辑评价计划, // 评价计划中原来已经勾选的待评价项目,不作为判断重复添加的内容 - if (Objects.nonNull(appraisalId)){ + if (Objects.nonNull(appraisalId)) { // 获取当前编辑的评价计划中选择的项目 List proIds = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId)).stream() @@ -956,7 +954,7 @@ public class PerformanceAppraisalPlanManage { projectIds.removeAll(proIds); } // 如果有交集,说明选择的项目中,有已经在其他评价计划中的项目 - if (Boolean.TRUE.equals(haveIntersection(projectIdList, projectIds))){ + if (Boolean.TRUE.equals(haveIntersection(projectIdList, projectIds))) { // 得到交集 List intersection = Lists.newArrayList(projectIdList); intersection.retainAll(projectIds); @@ -976,7 +974,7 @@ public class PerformanceAppraisalPlanManage { public String addApplication(AddAppraisalObjectDTO addDTO) { List applicationIdList = addDTO.getApplicationIds(); - if (CollUtil.isEmpty(applicationIdList)){ + if (CollUtil.isEmpty(applicationIdList)) { throw new BizException("请选择至少一个评应用!"); } // 获取已经创建的评价计划中添加的评价应用ID @@ -985,7 +983,7 @@ public class PerformanceAppraisalPlanManage { Long appraisalId = addDTO.getAppraisalId(); // 如果评价计划不为空,说明是编辑评价计划, // 评价计划中原来已经勾选的待评价应用,不作为判断重复添加的内容 - if (Objects.nonNull(appraisalId)){ + if (Objects.nonNull(appraisalId)) { // 获取当前编辑的评价计划中选择的应用 List appIds = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) .eq(PerformanceAppraisalApplication::getAppraisalId, appraisalId)).stream() @@ -994,7 +992,7 @@ public class PerformanceAppraisalPlanManage { applicationIds.removeAll(appIds); } // 如果有交集,说明选择的应用中,有已经在其他评价计划中的应用 - if (Boolean.TRUE.equals(haveIntersection(applicationIdList, applicationIds))){ + if (Boolean.TRUE.equals(haveIntersection(applicationIdList, applicationIds))) { // 得到交集 List intersection = Lists.newArrayList(applicationIdList); intersection.retainAll(applicationIds); @@ -1025,7 +1023,7 @@ public class PerformanceAppraisalPlanManage { List appraisalProjectList = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId)); List projectCodes = appraisalProjectList.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); - if (CollUtil.isEmpty(projectCodes)){ + if (CollUtil.isEmpty(projectCodes)) { return PageVo.empty(); } LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) @@ -1033,12 +1031,12 @@ public class PerformanceAppraisalPlanManage { .eq(Project::getNewest, Boolean.TRUE); // 如果对项目名称进行模糊查询 - if (StringUtils.isNotBlank(projectName) && StringUtils.isBlank(buildOrgName)){ - wrapper.like(Project::getProjectName,projectName); + if (StringUtils.isNotBlank(projectName) && StringUtils.isBlank(buildOrgName)) { + wrapper.like(Project::getProjectName, projectName); } // 如果对申报单位进行模糊查询 else if (StringUtils.isNotBlank(buildOrgName) && StringUtils.isBlank(projectName)) { - wrapper.like(Project::getBuildOrgName,buildOrgName); + wrapper.like(Project::getBuildOrgName, buildOrgName); } // 同时对项目名称和申报单位进行模糊查询 else if (StringUtils.isNotBlank(projectName) && StringUtils.isNotBlank(buildOrgName)) { @@ -1046,7 +1044,7 @@ public class PerformanceAppraisalPlanManage { .like(Project::getBuildOrgName, buildOrgName); } List projects = projectService.list(wrapper); - if (CollUtil.isEmpty(projects)){ + if (CollUtil.isEmpty(projects)) { return PageVo.empty(); } List voList = projects.stream().map(p -> { @@ -1055,7 +1053,7 @@ public class PerformanceAppraisalPlanManage { appraisalProjectVo.setProjectTypeName(ProjectTypeNewEnum.getDesc(p.getProjectType())); return appraisalProjectVo; }).collect(Collectors.toList()); - return PageVo.of(voList,voList.size()); + return PageVo.of(voList, voList.size()); } public PageVo finalProjectList(PerformanceAppraisalListReq req) { @@ -1073,7 +1071,6 @@ public class PerformanceAppraisalPlanManage { param.setBuildOrgName(buildOrgName); param.setProjectType(projectType); param.setProjectYear(projectYear); - param.setRegionCode(user.getRegionCode()); param.setStatus(ProjectStatusEnum.ACCEPTED.getCode()); // 获取已添加到评价计划中的项目 List projectCodes = performanceAppraisalProjectService.list().stream() @@ -1082,19 +1079,17 @@ public class PerformanceAppraisalPlanManage { if (Objects.nonNull(appraisalId)) { List projects = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId)); - if (CollUtil.isNotEmpty(projects)){ + if (CollUtil.isNotEmpty(projects)) { List projectCodeList = projects.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); projectCodes.removeAll(projectCodeList); } } // 过滤掉已经添加到评价计划中的项目(如果是编辑评价计划,保留当前计划已添加的项目) param.setProjectCodes(projectCodes); - return projectLibManage.projectLibListWithPermission(param, user); + return projectLibManage.projectLibListWithPermission(param, user); } public PageVo finalApplicationList(PerformanceAppraisalListReq req) { - UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String regionCode = user.getRegionCode(); Long appraisalId = req.getAppraisalId(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(ProjectApplication.class) @@ -1106,19 +1101,18 @@ public class PerformanceAppraisalPlanManage { } // 获取本区域已验收的项目关联的应用 List projectList = projectService.list(Wrappers.lambdaQuery(Project.class) - .eq(Project::getAreaCode, regionCode) - .eq(Project::getNewest,Boolean.TRUE) + .eq(Project::getNewest, Boolean.TRUE) .eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode())); - if (CollUtil.isEmpty(projectList)){ + if (CollUtil.isEmpty(projectList)) { return PageVo.empty(); } List projectCodeList = projectList.stream().map(Project::getProjectCode).collect(Collectors.toList()); List projectVersionList = projectList.stream().map(Project::getVersion).collect(Collectors.toList()); - wrapper.in(ProjectApplication::getProjectCode,projectCodeList); - wrapper.in(ProjectApplication::getProjectVersion,projectVersionList); + wrapper.in(ProjectApplication::getProjectCode, projectCodeList); + wrapper.in(ProjectApplication::getProjectVersion, projectVersionList); wrapper.orderByDesc(ProjectApplication::getUpdateOn); List appList = projectApplicationService.list(wrapper); - if (CollUtil.isEmpty(appList)){ + if (CollUtil.isEmpty(appList)) { return PageVo.empty(); } @@ -1129,12 +1123,12 @@ public class PerformanceAppraisalPlanManage { for (Map.Entry> entry : appMap.entrySet()) { List applications = entry.getValue(); Optional max = applications.stream().max(Comparator.comparingInt(ProjectApplication::getProjectVersion)); - if (max.isPresent()){ + if (max.isPresent()) { ProjectApplication application = max.get(); applicationList.add(application); } } - if (CollUtil.isEmpty(applicationList)){ + if (CollUtil.isEmpty(applicationList)) { return PageVo.empty(); } // 获取已添加到评价计划中的应用 @@ -1144,13 +1138,13 @@ public class PerformanceAppraisalPlanManage { if (Objects.nonNull(appraisalId)) { List projectApplications = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) .eq(PerformanceAppraisalApplication::getAppraisalId, appraisalId)); - if (CollUtil.isNotEmpty(projectApplications)){ + if (CollUtil.isNotEmpty(projectApplications)) { List appIdList = projectApplications.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); applicationIdList.removeAll(appIdList); } } List resList = applicationList.stream().filter(a -> !applicationIdList.contains(a.getId())).collect(Collectors.toList()); - if (CollUtil.isEmpty(resList)){ + if (CollUtil.isEmpty(resList)) { return PageVo.empty(); } //List relatedAppList = Lists.newArrayList(); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/ReAppraisalManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/ReAppraisalManage.java index 3632145..217090e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/ReAppraisalManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/ReAppraisalManage.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.CharsetUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.write.builder.ExcelWriterBuilder; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; @@ -25,8 +26,8 @@ import com.hz.pm.api.performance.service.*; import com.hz.pm.api.performance.util.*; import com.hz.pm.api.portrait.model.entity.ProjectTag; import com.hz.pm.api.portrait.service.IProjectTagService; -import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.sys.model.entity.Role; import com.hz.pm.api.sys.service.IRoleService; @@ -115,10 +116,7 @@ public class ReAppraisalManage { } else { empCodeList.add(reAppraisalUsers); } - if (empCodeList.contains(employeeCode)) { - return true; - } - return false; + return empCodeList.contains(employeeCode); }).collect(Collectors.toList()); // 当前登录复评员用户,没有参加评价计划 if (CollUtil.isEmpty(groupList)) { @@ -150,12 +148,12 @@ public class ReAppraisalManage { /** * 是否可以复评 * - * @param employeeCode - * @param projectCode - * @param appraisalId - * @return + * @param userId \ + * @param projectCode \ + * @param appraisalId \ + * @return \ */ - private Boolean checkCanReAppraisal(String employeeCode, String projectCode, Long appraisalId) { + private Boolean checkCanReAppraisal(String userId, String projectCode, Long appraisalId) { // 首次复评(复评打分时间为空) // 从绩效评价打分信息表中查询打分类型为复评、打分人员为当前登录复评用户的打分信息 // 如果没有相关的打分信息,说明是当前登录复评用户是首次复评 @@ -163,7 +161,7 @@ public class ReAppraisalManage { .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode()) .eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode, projectCode) .eq(PerformanceAppraisalScoreInfo::getAppraisalId, appraisalId) - .eq(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode, employeeCode)); + .eq(PerformanceAppraisalScoreInfo::getAppraisalUserId, userId)); if (CollUtil.isEmpty(scoreInfos)) { return true; } @@ -230,7 +228,7 @@ public class ReAppraisalManage { @Transactional(rollbackFor = Exception.class) public String submitReAppraisal(ProjectAppraisalDTO param) { UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); - String employeeCode = userDetail.getEmployeeCode(); + String userIdStr = String.valueOf(userDetail.getMhUserId()); String username = userDetail.getUsername(); Long appraisalId = param.getAppraisalId(); Long appraisalProjectId = param.getAppraisalProjectId(); @@ -270,8 +268,8 @@ public class ReAppraisalManage { scoreInfo.setAppraisalType(AppraisalTypeEnum.RE_APPRAISAL.getCode()); scoreInfo.setTemplateDetailId(templateDetail.getId()); scoreInfo.setTemplateId(templateDetail.getTemplateId()); - scoreInfo.setAppraisalEmployeeCode(employeeCode); - scoreInfo.setAppraisalEmployeeName(username); + scoreInfo.setAppraisalUserId(userIdStr); + scoreInfo.setAppraisalUserName(username); scoreInfo.setAppraisalId(appraisalId); scoreInfo.setAppraisalProjectId(appraisalProjectId); scoreInfo.setAppraisalProjectCode(appraisalProjectCode); @@ -317,7 +315,7 @@ public class ReAppraisalManage { .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode())); // 判断打分人员是否为分组内的复评人员 if (CollUtil.isNotEmpty(scoreInfoList)) { - Set users = scoreInfoList.stream().map(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode).collect(Collectors.toSet()); + Set users = scoreInfoList.stream().map(PerformanceAppraisalScoreInfo::getAppraisalUserId).collect(Collectors.toSet()); if (CollUtil.isNotEmpty(users)) { String reAppraisalUsers = group.getReAppraisalUsers(); String join = String.join(StrPool.COMMA, users); @@ -330,27 +328,22 @@ public class ReAppraisalManage { } public void exportScore(HttpServletResponse response, PerformanceAppraisalExportReq param) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - String regionCode = user.getRegionCode(); String projectCode = param.getProjectCode(); Long appraisalId = param.getAppraisalId(); // 根据项目编码获取最新版本的项目信息 Project project = projectService.getProjectByCode(projectCode); - VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); + Assert.notNull(project, "项目不存在!"); // 根据项目类型、预算年度、批复金额、项目标签匹配本区域指标模版 String projectType = project.getProjectType(); Integer projectYear = project.getProjectYear(); BigDecimal approvalAmount = project.getApprovalAmount(); - VUtils.isTrue(Objects.isNull(approvalAmount)).throwMessage("未获取到该项目的立项批复金额"); + Assert.notNull(approvalAmount, "未获取到该项目的立项批复金额"); // 根据项目code获取项目标签ID列表 - List tagIdList = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) + String tagIdStr = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) .eq(ProjectTag::getProjectCode, projectCode)).stream() - .map(ProjectTag::getTagId).collect(Collectors.toList()); - VUtils.isTrue(CollUtil.isEmpty(tagIdList)).throwMessage("当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!"); - - List strIdList = tagIdList.stream().map(String::valueOf).collect(Collectors.toList()); - String projectTagIds = String.join(StrPool.COMMA, strIdList); + .map(w -> w.getTagId().toString()).collect(Collectors.joining(",")); + Assert.notEmpty(tagIdStr, "当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!"); Integer amountRange = null; if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) < 0) { @@ -362,15 +355,14 @@ public class ReAppraisalManage { amountRange = ProjectBizConst.AMOUNT_RANGE_THREE; } LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class) - .eq(PerformanceIndicatorProjectTemplate::getRegionCode, regionCode) .eq(PerformanceIndicatorProjectTemplate::getProjectType, projectType) .eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) .eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) - .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds, projectTagIds) + .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds, tagIdStr) .eq(PerformanceIndicatorProjectTemplate::getStatus, CommonEnum.YES.getCode()) .orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); List templates = indicatorProjectTemplateService.list(wrapper); - VUtils.isTrue(CollUtil.isEmpty(templates)).throwMessage("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); + Assert.notEmpty(templates, "该项目匹配不到指标模板,请返回上一页或者刷新重试。"); if (templates.size() > 1) { throw new BizException("当前项目匹配到多个模板,请返回模板库检查模板配置!"); } @@ -398,7 +390,7 @@ public class ReAppraisalManage { .filter(s -> AppraisalTypeEnum.RE_APPRAISAL.getCode().equals(s.getAppraisalType())) .collect(Collectors.toList()); List reUserList = reScoreInfoList.stream() - .map(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName) + .map(PerformanceAppraisalScoreInfo::getAppraisalUserName) .collect(Collectors.toList()); // 筛选出所有打分的三级指标模板详情ID @@ -434,8 +426,8 @@ public class ReAppraisalManage { scoreMap.put(ProjectBizConst.SELF_APPRAISAL_BASIS, appraisalScoreInfo.getAppraisalBasis()); scoreMap.put(ProjectBizConst.SELF_APPRAISAL_SCORE, appraisalScoreInfo.getAppraisalScore()); } else if (AppraisalTypeEnum.RE_APPRAISAL.getCode().equals(appraisalScoreInfo.getAppraisalType())) { - scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + ProjectBizConst.RE_APPRAISAL_BASIS, appraisalScoreInfo.getAppraisalBasis()); - scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + ProjectBizConst.RE_APPRAISAL_SCORE, appraisalScoreInfo.getAppraisalScore()); + scoreMap.put(appraisalScoreInfo.getAppraisalUserName() + ProjectBizConst.RE_APPRAISAL_BASIS, appraisalScoreInfo.getAppraisalBasis()); + scoreMap.put(appraisalScoreInfo.getAppraisalUserName() + ProjectBizConst.RE_APPRAISAL_SCORE, appraisalScoreInfo.getAppraisalScore()); } if (Boolean.TRUE.equals(thirdTemplateDetail.getIsAdditional())) { @@ -456,21 +448,21 @@ public class ReAppraisalManage { // 需要从第几行开始合并 int mergeRowIndex = 2; - List headList = Lists.newArrayList(); - headList.add(new ExcelHead(ProjectBizConst.FIRST_INDEX_NAME, ProjectBizConst.FIRST_INDEX_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.SECOND_INDEX_NAME, ProjectBizConst.SECOND_INDEX_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.THIRD_INDEX_NAME, ProjectBizConst.THIRD_INDEX_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.INDEX_SCORE, ProjectBizConst.INDEX_SCORE_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.INDEX_DETAIL, ProjectBizConst.INDEX_DETAIL_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.GRADE_DETAIL, ProjectBizConst.GRADE_DETAIL_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.SUPPORT_MATERIAL, ProjectBizConst.SUPPORT_MATERIAL_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.SELF_APPRAISAL_BASIS, ProjectBizConst.SELF_APPRAISAL_BASIS_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.SELF_APPRAISAL_SCORE, ProjectBizConst.SELF_APPRAISAL_SCORE_TITLE, StrPool.EMPTY)); + List> headList = Lists.newArrayList(); + headList.add(new ExcelHead<>(ProjectBizConst.FIRST_INDEX_NAME, ProjectBizConst.FIRST_INDEX_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.SECOND_INDEX_NAME, ProjectBizConst.SECOND_INDEX_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.THIRD_INDEX_NAME, ProjectBizConst.THIRD_INDEX_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.INDEX_SCORE, ProjectBizConst.INDEX_SCORE_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.INDEX_DETAIL, ProjectBizConst.INDEX_DETAIL_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.GRADE_DETAIL, ProjectBizConst.GRADE_DETAIL_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.SUPPORT_MATERIAL, ProjectBizConst.SUPPORT_MATERIAL_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.SELF_APPRAISAL_BASIS, ProjectBizConst.SELF_APPRAISAL_BASIS_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.SELF_APPRAISAL_SCORE, ProjectBizConst.SELF_APPRAISAL_SCORE_TITLE, StrPool.EMPTY)); for (String reUser : reUserList) { - headList.add(new ExcelHead(reUser + ProjectBizConst.RE_APPRAISAL_BASIS, ProjectBizConst.RE_APPRAISAL_BASIS_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(reUser + ProjectBizConst.RE_APPRAISAL_SCORE, ProjectBizConst.RE_APPRAISAL_SCORE_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(reUser + ProjectBizConst.RE_APPRAISAL_BASIS, ProjectBizConst.RE_APPRAISAL_BASIS_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(reUser + ProjectBizConst.RE_APPRAISAL_SCORE, ProjectBizConst.RE_APPRAISAL_SCORE_TITLE, StrPool.EMPTY)); } - headList.add(new ExcelHead(ProjectBizConst.IS_ADDITIONAL, ProjectBizConst.IS_ADDITIONAL_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.IS_ADDITIONAL, ProjectBizConst.IS_ADDITIONAL_TITLE, StrPool.EMPTY)); // 数据导出处理函数 try { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/RectifyAuditManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/RectifyAuditManage.java index 4b6fe00..a323c30 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/RectifyAuditManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/RectifyAuditManage.java @@ -1,52 +1,50 @@ package com.hz.pm.api.performance.manage; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.text.StrPool; -import com.google.common.collect.Lists; -import com.hz.pm.api.performance.enumration.AppraisalTypeEnum; -import com.hz.pm.api.performance.enumration.RectifyAuditEnum; -import com.hz.pm.api.performance.model.dto.ProjectAppraisalInfoDTO; -import com.hz.pm.api.performance.model.entity.*; -import com.hz.pm.api.performance.service.*; -import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; -import org.apache.commons.lang3.StringUtils; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.PageVo; +import com.google.common.collect.Lists; import com.hz.pm.api.common.helper.UserInfoHelper; +import com.hz.pm.api.performance.enumration.AppraisalTypeEnum; +import com.hz.pm.api.performance.enumration.RectifyAuditEnum; import com.hz.pm.api.performance.enumration.RectifyStatusEnum; import com.hz.pm.api.performance.model.dto.ProjectAppraisalDTO; +import com.hz.pm.api.performance.model.dto.ProjectAppraisalInfoDTO; +import com.hz.pm.api.performance.model.entity.*; import com.hz.pm.api.performance.model.req.PerformanceAppraisalListReq; import com.hz.pm.api.performance.model.vo.PerformanceAppraisalProjectVO; import com.hz.pm.api.performance.model.vo.PerformanceAppraisalVO; +import com.hz.pm.api.performance.service.*; import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.sys.model.entity.Role; import com.hz.pm.api.sys.service.IRoleService; import com.hz.pm.api.user.model.enumeration.RoleEnum; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; /** * RectifyAuditManage - * - * @return + * * @author CMM + * @return * @since 2023/08/12 17:36 */ @Component @@ -62,9 +60,10 @@ public class RectifyAuditManage { private final IPerformanceAppraisalProjectGroupService groupService; private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService; private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService; + /** * 绩效列表 - * + * * @param req * @return */ @@ -163,9 +162,9 @@ public class RectifyAuditManage { // 因为一个核查用户只能出现在一个评价计划中的一个分组中,所以根据评价计划ID和核查组长信息可以确定分组内项目信息 PerformanceAppraisalProjectGroup projectGroup = - groupService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) - .eq(PerformanceAppraisalProjectGroup::getAppraisalId, planId) - .eq(PerformanceAppraisalProjectGroup::getVerifyLeader, employeeCode)); + groupService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) + .eq(PerformanceAppraisalProjectGroup::getAppraisalId, planId) + .eq(PerformanceAppraisalProjectGroup::getVerifyLeader, employeeCode)); // 当前登录专家没有为核查组长的绩效分组信息 if (Objects.isNull(projectGroup)) { return PageVo.empty(); @@ -180,25 +179,25 @@ public class RectifyAuditManage { } // 获取评价计划内已添加的核查组长为当前登录专家用户的待整改审核项目信息 List paps = - performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId()) - .in(PerformanceAppraisalProject::getProjectCode, codes) - .eq(PerformanceAppraisalProject::getIsRectify, Boolean.TRUE) - .eq(PerformanceAppraisalProject::getRectifyStatus, RectifyStatusEnum.TO_BE_REVIEWED.getCode())); + performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId()) + .in(PerformanceAppraisalProject::getProjectCode, codes) + .eq(PerformanceAppraisalProject::getIsRectify, Boolean.TRUE) + .eq(PerformanceAppraisalProject::getRectifyStatus, RectifyStatusEnum.TO_BE_REVIEWED.getCode())); if (CollUtil.isEmpty(paps)) { return PageVo.empty(); } Map papsMap = - paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); + paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); // 获取本单位在当前评价计划内的项目 Set projectCodes = - paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); + paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); Page page = req.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) - .in(Project::getProjectCode, projectCodes).eq(Project::getNewest, Boolean.TRUE) - .like(StringUtils.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName()) - .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); + .in(Project::getProjectCode, projectCodes).eq(Project::getNewest, Boolean.TRUE) + .like(StringUtils.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName()) + .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); projectService.page(page, wrapper); if (CollUtil.isEmpty(page.getRecords())) { @@ -231,9 +230,9 @@ public class RectifyAuditManage { // 因为一个核查用户只能出现在一个评价计划中的一个分组中,所以根据评价计划ID和核查组长信息可以确定分组内项目信息 PerformanceAppraisalProjectGroup projectGroup = - groupService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) - .eq(PerformanceAppraisalProjectGroup::getAppraisalId, planId) - .eq(PerformanceAppraisalProjectGroup::getVerifyLeader, employeeCode)); + groupService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) + .eq(PerformanceAppraisalProjectGroup::getAppraisalId, planId) + .eq(PerformanceAppraisalProjectGroup::getVerifyLeader, employeeCode)); // 当前登录专家没有为核查组长的绩效分组信息 if (Objects.isNull(projectGroup)) { return PageVo.empty(); @@ -248,28 +247,28 @@ public class RectifyAuditManage { } // 获取评价计划内已添加的核查组长为当前登录专家用户的已整改审核项目信息 List< - PerformanceAppraisalProject> paps = + PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId()) - .in(PerformanceAppraisalProject::getProjectCode, codes) - .eq(PerformanceAppraisalProject::getIsRectify, Boolean.TRUE) - .and(wp -> wp - .eq(PerformanceAppraisalProject::getRectifyStatus, RectifyStatusEnum.NOT_APPROVED.getCode()) - .or().eq(PerformanceAppraisalProject::getRectifyStatus, RectifyStatusEnum.APPROVED.getCode()))); + .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId()) + .in(PerformanceAppraisalProject::getProjectCode, codes) + .eq(PerformanceAppraisalProject::getIsRectify, Boolean.TRUE) + .and(wp -> wp + .eq(PerformanceAppraisalProject::getRectifyStatus, RectifyStatusEnum.NOT_APPROVED.getCode()) + .or().eq(PerformanceAppraisalProject::getRectifyStatus, RectifyStatusEnum.APPROVED.getCode()))); if (CollUtil.isEmpty(paps)) { return PageVo.empty(); } Map papsMap = - paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); + paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); // 获取评价计划内的项目 Set projectCodes = - paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); + paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); Page page = req.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) - .in(Project::getProjectCode, projectCodes).eq(Project::getNewest, Boolean.TRUE) - .like(StringUtils.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName()) - .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); + .in(Project::getProjectCode, projectCodes).eq(Project::getNewest, Boolean.TRUE) + .like(StringUtils.isNotBlank(req.getBuildOrgName()), Project::getBuildOrgName, req.getBuildOrgName()) + .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); projectService.page(page, wrapper); if (CollUtil.isEmpty(page.getRecords())) { @@ -296,7 +295,7 @@ public class RectifyAuditManage { @Transactional(rollbackFor = Exception.class) public String submit(ProjectAppraisalDTO param) { UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); - String employeeCode = userDetail.getEmployeeCode(); + String userIdStr = String.valueOf(userDetail.getUserId()); String username = userDetail.getUsername(); Long appraisalId = param.getAppraisalId(); Long appraisalProjectId = param.getAppraisalProjectId(); @@ -305,13 +304,11 @@ public class RectifyAuditManage { String rectifyAuditOpinion = param.getRectifyAuditOpinion(); String rectifyAuditAppendix = param.getRectifyAuditAppendix(); List appraisalInfoList = param.getAppraisalInfoList(); - Long groupId = param.getGroupId(); - PerformanceAppraisalProjectGroup group = groupService.getById(groupId); // 获取评价项目 PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId) - .eq(PerformanceAppraisalProject::getProjectCode,appraisalProjectCode) + .eq(PerformanceAppraisalProject::getProjectCode, appraisalProjectCode) .eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId)); List ids = appraisalInfoList.stream() @@ -320,7 +317,7 @@ public class RectifyAuditManage { // 查出项目模版详情信息 List detailList = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .in(PerformanceIndicatorProjectTemplateDetail::getId, ids)); - if (CollUtil.isEmpty(detailList)){ + if (CollUtil.isEmpty(detailList)) { throw new BizException("评价指标不存在!"); } Map detailMap = detailList.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, d -> d)); @@ -328,7 +325,7 @@ public class RectifyAuditManage { PerformanceIndicatorProjectTemplateDetail templateDetail = detailMap.get(a.getProjectTemplateDetailId()); BigDecimal score = a.getScore(); BigDecimal indexScore = templateDetail.getIndexScore(); - if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){ + if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0) { throw new BizException("核查审核得分必须大于等于0且小于等于指标分值!"); } // 保存核查分数信息 @@ -339,8 +336,8 @@ public class RectifyAuditManage { scoreInfo.setAppraisalType(AppraisalTypeEnum.EXPERT_RECTIFY_AUDIT.getCode()); scoreInfo.setTemplateDetailId(templateDetail.getId()); scoreInfo.setTemplateId(templateDetail.getTemplateId()); - scoreInfo.setAppraisalEmployeeCode(employeeCode); - scoreInfo.setAppraisalEmployeeName(username); + scoreInfo.setAppraisalUserId(userIdStr); + scoreInfo.setAppraisalUserName(username); scoreInfo.setAppraisalId(appraisalId); scoreInfo.setAppraisalProjectId(appraisalProjectId); scoreInfo.setAppraisalProjectCode(appraisalProjectCode); @@ -349,7 +346,7 @@ public class RectifyAuditManage { return scoreInfo; }).collect(Collectors.toList()); - if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)){ + if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)) { // 计算核查总分并保存 BigDecimal rectifyTotalScore = appraisalInfoList.stream() .map(ProjectAppraisalInfoDTO::getScore) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/RectifyManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/RectifyManage.java index ed1486a..bade195 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/RectifyManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/RectifyManage.java @@ -2,10 +2,13 @@ package com.hz.pm.api.performance.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.helper.UserInfoHelper; +import com.hz.pm.api.common.util.StrUtils; import com.hz.pm.api.performance.enumration.RectifyStatusEnum; import com.hz.pm.api.performance.model.dto.ProjectAppraisalDTO; import com.hz.pm.api.performance.model.entity.PerformanceAppraisal; @@ -70,12 +73,12 @@ public class RectifyManage { UserInfoDetails user = LoginUserUtil.loginUserDetail(); // 当前登录用户 单位code - String empPosUnitCode = user.getEmpPosUnitCode(); + String mhUnitId = user.getMhUnitIdStr(); // 获取当前登录用户的角色列表,只有单位管理员才能查看该列表 List userRoleList = user.getUserRoleList(); List roleIdList = userRoleList.stream().map(Role::getId).collect(Collectors.toList()); - Role role = - roleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getName, RoleEnum.COMPANY_MANAGER.getDesc())); + Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class) + .eq(Role::getName, RoleEnum.COMPANY_MANAGER.getDesc())); if (Objects.isNull(role)) { throw new BizException("登录用户没有单位管理员角色!"); } @@ -87,7 +90,7 @@ public class RectifyManage { // 获取登录用户所在单位的所有已终验项目信息 List projectLists = projectService.list(Wrappers.lambdaQuery(Project.class) - .eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode()).eq(Project::getBuildOrgCode, empPosUnitCode)); + .eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode()).eq(Project::getBuildOrgCode, mhUnitId)); if (CollUtil.isEmpty(projectLists)) { return PageVo.empty(); @@ -161,7 +164,7 @@ public class RectifyManage { Page page = req.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class).in(Project::getProjectCode, projectCodes) - .eq(Project::getNewest, Boolean.TRUE).eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) + .eq(Project::getNewest, Boolean.TRUE).eq(Project::getBuildOrgCode, user.getMhUnitId()) .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); projectService.page(page, wrapper); @@ -189,7 +192,7 @@ public class RectifyManage { UserInfoDetails user = LoginUserUtil.loginUserDetail(); PerformanceAppraisal plan = performanceAppraisalService.getById(planId); - VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!"); + Assert.notNull(plan, "该评价计划不存在!"); // 获取评价计划内已添加的已整改项目信息 List paps = @@ -199,8 +202,6 @@ public class RectifyManage { .and(wp -> wp .eq(PerformanceAppraisalProject::getRectifyStatus, RectifyStatusEnum.TO_BE_REVIEWED.getCode()).or() .eq(PerformanceAppraisalProject::getRectifyStatus, RectifyStatusEnum.APPROVED.getCode()))); - Map papsMap = - paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); if (CollUtil.isEmpty(paps)) { return PageVo.empty(); @@ -210,15 +211,19 @@ public class RectifyManage { Set projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); Page page = req.page(); - LambdaQueryWrapper wrapper = - Wrappers.lambdaQuery(Project.class).in(Project::getProjectCode, projectCodes) - .eq(Project::getNewest, Boolean.TRUE).eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) - .like(StringUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) + .in(Project::getProjectCode, projectCodes) + .eq(Project::getNewest, Boolean.TRUE) + .eq(Project::getBuildOrgCode, user.getMhUnitId()) + .like(StrUtils.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()); projectService.page(page, wrapper); if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } + Map papsMap = paps.stream() + .collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); + List res = page.getRecords().stream().map(p -> { PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); @@ -239,19 +244,20 @@ public class RectifyManage { RectifyDetailVO vo = new RectifyDetailVO(); // 根据评价计划ID和项目编号获取评价项目信息 PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers - .lambdaQuery(PerformanceAppraisalProject.class).eq(PerformanceAppraisalProject::getAppraisalId, planId) + .lambdaQuery(PerformanceAppraisalProject.class) + .eq(PerformanceAppraisalProject::getAppraisalId, planId) .eq(PerformanceAppraisalProject::getProjectCode, projectCode)); - VUtils.isTrue(Objects.isNull(appraisalProject)).throwMessage("该项目已被移除评价计划,请返回上一页或者刷新重试!!"); + Assert.notNull(appraisalProject, "该项目已被移除评价计划,请返回上一页或者刷新重试!"); BeanUtils.copyProperties(appraisalProject, vo); - String rectifySubmitEmployeeCode = appraisalProject.getRectifySubmitEmployeeCode(); - if (StringUtils.isNotBlank(rectifySubmitEmployeeCode)) { - UserFullInfoDTO userFullInfoDto = userInfoHelper.getUserFullInfoByEmployeeCode(rectifySubmitEmployeeCode); - vo.setRectifySubmitEmployee(userFullInfoDto); + String rectifySubmitUserId = appraisalProject.getRectifySubmitUserId(); + if (StrUtils.isNotBlank(rectifySubmitUserId)) { + UserFullInfoDTO userFullInfoDto = userInfoHelper.getUserFullInfo(rectifySubmitUserId); + vo.setRectifySubmitUser(userFullInfoDto); } - String rectifyResSubEmpCode = appraisalProject.getRectifyResSubEmpCode(); - if (StringUtils.isNotBlank(rectifyResSubEmpCode)) { - UserFullInfoDTO userFullInfoDto = userInfoHelper.getUserFullInfoByEmployeeCode(rectifyResSubEmpCode); - vo.setRectifyResSubEmployee(userFullInfoDto); + String rectifyResSubUserId = appraisalProject.getRectifyResSubUserId(); + if (StrUtils.isNotBlank(rectifyResSubUserId)) { + UserFullInfoDTO userFullInfoDto = userInfoHelper.getUserFullInfo(rectifyResSubUserId); + vo.setRectifyResSubUser(userFullInfoDto); } vo.setRectifyStatusName(RectifyStatusEnum.getDesc(appraisalProject.getRectifyStatus())); return vo; @@ -260,7 +266,7 @@ public class RectifyManage { @Transactional(rollbackFor = Exception.class) public String fillOutResult(ProjectAppraisalDTO param) { UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); - String employeeCode = userDetail.getEmployeeCode(); + String userIdStr = String.valueOf(userDetail.getUserId()); String username = userDetail.getUsername(); Long appraisalId = param.getAppraisalId(); @@ -270,16 +276,17 @@ public class RectifyManage { String rectifyResultAppendix = param.getRectifyResultAppendix(); // 判断该项目是否还存在于计划或分组中 - PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers - .lambdaQuery(PerformanceAppraisalProject.class).eq(PerformanceAppraisalProject::getAppraisalId, appraisalId) + Wrapper query = Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId) .eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId) - .eq(PerformanceAppraisalProject::getProjectCode, appraisalProjectCode)); + .eq(PerformanceAppraisalProject::getProjectCode, appraisalProjectCode); + PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(query); if (Objects.isNull(appraisalProject)) { throw new BizException("该项目已被移除评价计划,请返回上一页或者刷新重试!"); } appraisalProject.setRectifyResult(rectifyResult); appraisalProject.setRectifyResultAppendix(rectifyResultAppendix); - appraisalProject.setRectifyResSubEmpCode(employeeCode); + appraisalProject.setRectifyResSubUserId(userIdStr); appraisalProject.setRectifyResSubTime(LocalDateTime.now()); // 更新整改状态为整改待审核 appraisalProject.setRectifyStatus(RectifyStatusEnum.TO_BE_REVIEWED.getCode()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/VerifyManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/VerifyManage.java index c103136..85a14b4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/VerifyManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/manage/VerifyManage.java @@ -2,15 +2,19 @@ package com.hz.pm.api.performance.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.NumberUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.write.builder.ExcelWriterBuilder; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.hz.pm.api.common.enumeration.CommonEnum; +import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.performance.constant.ProjectBizConst; import com.hz.pm.api.performance.enumration.AppraisalTypeEnum; @@ -26,8 +30,8 @@ import com.hz.pm.api.performance.service.*; import com.hz.pm.api.performance.util.*; import com.hz.pm.api.portrait.model.entity.ProjectTag; import com.hz.pm.api.portrait.service.IProjectTagService; -import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.sys.model.entity.Role; import com.hz.pm.api.sys.service.IRoleService; @@ -47,6 +51,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -139,31 +144,28 @@ public class VerifyManage { /** * 是否可以核查 * - * @param employeeCode - * @param projectCode - * @param appraisalId - * @return + * @param userId \ + * @param projectCode \ + * @param appraisalId \ + * @return \ */ - private Boolean checkCanVerify(String employeeCode, String projectCode, Long appraisalId) { - + private Boolean checkCanVerify(String userId, String projectCode, Long appraisalId) { // 首次核查(核查打分信息为空) // 从绩效评价打分信息表中查询打分类型为专家核查、打分人员为当前登录专家用户的打分信息 // 如果没有相关的打分信息,说明是当前登录复评用户是首次核查 - List scoreInfos = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + Wrapper query = Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode()) .eq(PerformanceAppraisalScoreInfo::getAppraisalId, appraisalId) .eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode, projectCode) - .eq(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode, employeeCode)); - if (CollUtil.isEmpty(scoreInfos)) { - return true; - } - return Boolean.FALSE; + .eq(PerformanceAppraisalScoreInfo::getAppraisalUserId, userId) + .last(BizConst.LIMIT_1); + return performanceAppraisalScoreInfoService.count(query) == 0; } public PageVo groupProjectList(Long groupId, PerformanceAppraisalListReq req) { UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); - String employeeCode = userDetail.getEmployeeCode(); + String userIdStr = String.valueOf(userDetail.getUserId()); // 获取分组内的项目信息 PerformanceAppraisalProjectGroup projectGroup = groupService.getById(groupId); @@ -204,10 +206,10 @@ public class VerifyManage { BeanUtil.copyProperties(appraisalProject, vo); vo.setProjectId(appraisalProject.getProjectId()); vo.setProjectTypeName(ProjectTypeNewEnum.getDesc(p.getProjectType())); - vo.setCanVerify(checkCanVerify(employeeCode, appraisalProject.getProjectCode(), appraisalId)); + vo.setCanVerify(checkCanVerify(userIdStr, appraisalProject.getProjectCode(), appraisalId)); // 如果登录用户是核查组长,该项目可填写整改意见 String verifyLeader = projectGroup.getVerifyLeader(); - if (employeeCode.equals(verifyLeader)) { + if (userIdStr.equals(verifyLeader)) { vo.setCanRectify(Boolean.TRUE); } vo.setGroupId(groupId); @@ -220,7 +222,7 @@ public class VerifyManage { @Transactional(rollbackFor = Exception.class) public String submitVerify(ProjectAppraisalDTO param) { UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); - String employeeCode = userDetail.getEmployeeCode(); + String userIdStr = String.valueOf(userDetail.getUserId()); String username = userDetail.getUsername(); Long appraisalId = param.getAppraisalId(); Long appraisalProjectId = param.getAppraisalProjectId(); @@ -260,8 +262,8 @@ public class VerifyManage { scoreInfo.setAppraisalType(AppraisalTypeEnum.EXPERT_VERIFY.getCode()); scoreInfo.setTemplateDetailId(templateDetail.getId()); scoreInfo.setTemplateId(templateDetail.getTemplateId()); - scoreInfo.setAppraisalEmployeeCode(employeeCode); - scoreInfo.setAppraisalEmployeeName(username); + scoreInfo.setAppraisalUserName(username); + scoreInfo.setAppraisalUserId(userIdStr); scoreInfo.setAppraisalId(appraisalId); scoreInfo.setAppraisalProjectId(appraisalProjectId); scoreInfo.setAppraisalProjectCode(appraisalProjectCode); @@ -281,7 +283,7 @@ public class VerifyManage { if (Objects.nonNull(appraisalProject.getVerifyTotalScore())) { // 已经进行了核查,计算两个分值的平均分 BigDecimal add = verifyTotalScore.add(appraisalProject.getReAppraisalTotalScore()); - lastVerifyTotalScore = add.divide(BigDecimal.valueOf(2)); + lastVerifyTotalScore = add.divide(BigDecimal.valueOf(2), RoundingMode.HALF_UP); } else { // 还没有进行过复评 lastVerifyTotalScore = verifyTotalScore; @@ -298,7 +300,7 @@ public class VerifyManage { StringUtils.isNotBlank(param.getRectifyOpinion())) { appraisalProject.setIsRectify(param.getIsRectify()); appraisalProject.setRectifyOpinion(param.getRectifyOpinion()); - appraisalProject.setRectifySubmitEmployeeCode(employeeCode); + appraisalProject.setRectifySubmitUserId(userIdStr); appraisalProject.setRectifySubmitTime(LocalDateTime.now()); appraisalProject.setRectifyStatus(RectifyStatusEnum.TO_BE_SUBMITTED.getCode()); } @@ -317,7 +319,9 @@ public class VerifyManage { // 判断打分人员是否为分组内的核查人员 if (CollUtil.isNotEmpty(scoreInfoList)) { - Set users = scoreInfoList.stream().map(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode).collect(Collectors.toSet()); + Set users = scoreInfoList.stream() + .map(PerformanceAppraisalScoreInfo::getAppraisalUserId) + .collect(Collectors.toSet()); if (CollUtil.isNotEmpty(users)) { String verificationUsers = group.getVerificationUsers(); String join = String.join(StrPool.COMMA, users); @@ -330,29 +334,24 @@ public class VerifyManage { } public void exportScore(HttpServletResponse response, PerformanceAppraisalExportReq param) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - String regionCode = user.getRegionCode(); String projectCode = param.getProjectCode(); Long appraisalId = param.getAppraisalId(); // 根据项目编码获取最新版本的项目信息 Project project = projectService.getProjectByCode(projectCode); - VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); + Assert.notNull(project, "项目不存在!"); // 根据项目类型、预算年度、批复金额、项目标签匹配本区域指标模版 String projectType = project.getProjectType(); Integer projectYear = project.getProjectYear(); BigDecimal approvalAmount = project.getApprovalAmount(); - VUtils.isTrue(Objects.isNull(approvalAmount)).throwMessage("未获取到该项目的立项批复金额"); + Assert.notNull(approvalAmount, "未获取到该项目的立项批复金额"); // 根据项目code获取项目标签ID列表 - List tagIdList = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) + String tagIdStr = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) .eq(ProjectTag::getProjectCode, projectCode)).stream() - .map(ProjectTag::getTagId).collect(Collectors.toList()); - VUtils.isTrue(CollUtil.isEmpty(tagIdList)).throwMessage("当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!"); + .map(w -> w.getTagId().toString()).collect(Collectors.joining(",")); + Assert.notEmpty(tagIdStr, "当前项目未设置标签,请至项目库或评价计划编辑页面设置标签!"); - List strIdList = tagIdList.stream().map(String::valueOf).collect(Collectors.toList()); - String projectTagIds = String.join(StrPool.COMMA, strIdList); - - Integer amountRange = null; + Integer amountRange; if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) < 0) { amountRange = ProjectBizConst.AMOUNT_RANGE_ONE; } else if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.FIVE_MILLION)) >= 0 && @@ -360,19 +359,20 @@ public class VerifyManage { amountRange = ProjectBizConst.AMOUNT_RANGE_TWO; } else if (approvalAmount.compareTo(BigDecimal.valueOf(ProjectBizConst.TWENTY_MILLION)) >= 0) { amountRange = ProjectBizConst.AMOUNT_RANGE_THREE; + } else { + amountRange = null; } - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class) - .eq(PerformanceIndicatorProjectTemplate::getRegionCode, regionCode) + LambdaQueryWrapper wrapper = Wrappers + .lambdaQuery(PerformanceIndicatorProjectTemplate.class) .eq(PerformanceIndicatorProjectTemplate::getProjectType, projectType) .eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) .eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) - .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds, projectTagIds) + .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds, tagIdStr) .eq(PerformanceIndicatorProjectTemplate::getStatus, CommonEnum.YES.getCode()) .orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); List templates = indicatorProjectTemplateService.list(wrapper); - VUtils.isTrue(CollUtil.isEmpty(templates)).throwMessage("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); - if (templates.size() > 1) { - throw new BizException("当前项目匹配到多个模板,请返回模板库检查模板配置!"); + if (templates.size() != 1) { + throw BizException.wrap("当前项目模版配置错误!"); } PerformanceIndicatorProjectTemplate projectTemplate = templates.get(0); // 装配项目指标详情及分数信息 @@ -384,11 +384,12 @@ public class VerifyManage { List> exportDataList = Lists.newArrayList(); List> exportAdditionalDataList = Lists.newArrayList(); // 构建指标和打分详情 - List scoreInfoList = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + List scoreInfoList = performanceAppraisalScoreInfoService.list(Wrappers + .lambdaQuery(PerformanceAppraisalScoreInfo.class) .eq(PerformanceAppraisalScoreInfo::getAppraisalId, appraisalId) - .and(wp -> wp.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.SELF_APPRAISAL.getCode()).or() - .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode()).or() - .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode())) + .and(wp -> wp.eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.SELF_APPRAISAL.getCode()) + .or().eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode()) + .or().eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode())) .eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode, projectCode) .orderBy(Boolean.TRUE, Boolean.TRUE, PerformanceAppraisalScoreInfo::getTemplateDetailId)); Map scoreInfoMap = scoreInfoList.stream() @@ -399,7 +400,7 @@ public class VerifyManage { .filter(s -> AppraisalTypeEnum.RE_APPRAISAL.getCode().equals(s.getAppraisalType())) .collect(Collectors.toList()); List reUserList = reScoreInfoList.stream() - .map(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName) + .map(PerformanceAppraisalScoreInfo::getAppraisalUserName) .collect(Collectors.toList()); // 获取核查打分人员信息 @@ -407,12 +408,12 @@ public class VerifyManage { .filter(s -> AppraisalTypeEnum.EXPERT_VERIFY.getCode().equals(s.getAppraisalType())) .collect(Collectors.toList()); List verifyUserList = verifyScoreInfoList.stream() - .map(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName) + .map(PerformanceAppraisalScoreInfo::getAppraisalUserName) .collect(Collectors.toList()); // 筛选出所有打分的三级指标模板详情ID for (PerformanceAppraisalScoreInfo scoreInfo : scoreInfoList) { - HashMap scoreMap = MapUtil.newHashMap(); + Map scoreMap = MapUtil.newHashMap(); Long detailId = scoreInfo.getTemplateDetailId(); PerformanceIndicatorProjectTemplateDetail thirdTemplateDetail = templateDetailMap.get(detailId); @@ -444,11 +445,11 @@ public class VerifyManage { scoreMap.put(ProjectBizConst.SELF_APPRAISAL_BASIS, appraisalScoreInfo.getAppraisalBasis()); scoreMap.put(ProjectBizConst.SELF_APPRAISAL_SCORE, appraisalScoreInfo.getAppraisalScore()); } else if (AppraisalTypeEnum.RE_APPRAISAL.getCode().equals(appraisalScoreInfo.getAppraisalType())) { - scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + ProjectBizConst.RE_APPRAISAL_BASIS, appraisalScoreInfo.getAppraisalBasis()); - scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + ProjectBizConst.RE_APPRAISAL_SCORE, appraisalScoreInfo.getAppraisalScore()); + scoreMap.put(appraisalScoreInfo.getAppraisalUserName() + ProjectBizConst.RE_APPRAISAL_BASIS, appraisalScoreInfo.getAppraisalBasis()); + scoreMap.put(appraisalScoreInfo.getAppraisalUserName() + ProjectBizConst.RE_APPRAISAL_SCORE, appraisalScoreInfo.getAppraisalScore()); } else if (AppraisalTypeEnum.EXPERT_VERIFY.getCode().equals(appraisalScoreInfo.getAppraisalType())) { - scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + ProjectBizConst.VERIFY_BASIS, appraisalScoreInfo.getAppraisalBasis()); - scoreMap.put(appraisalScoreInfo.getAppraisalEmployeeName() + ProjectBizConst.VERIFY_SCORE, appraisalScoreInfo.getAppraisalScore()); + scoreMap.put(appraisalScoreInfo.getAppraisalUserName() + ProjectBizConst.VERIFY_BASIS, appraisalScoreInfo.getAppraisalBasis()); + scoreMap.put(appraisalScoreInfo.getAppraisalUserName() + ProjectBizConst.VERIFY_SCORE, appraisalScoreInfo.getAppraisalScore()); } if (Boolean.TRUE.equals(thirdTemplateDetail.getIsAdditional())) { @@ -469,26 +470,26 @@ public class VerifyManage { // 需要从第几行开始合并 int mergeRowIndex = 2; - List headList = Lists.newArrayList(); - headList.add(new ExcelHead(ProjectBizConst.FIRST_INDEX_NAME, ProjectBizConst.FIRST_INDEX_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.SECOND_INDEX_NAME, ProjectBizConst.SECOND_INDEX_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.THIRD_INDEX_NAME, ProjectBizConst.THIRD_INDEX_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.INDEX_SCORE, ProjectBizConst.INDEX_SCORE_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.INDEX_DETAIL, ProjectBizConst.INDEX_DETAIL_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.GRADE_DETAIL, ProjectBizConst.GRADE_DETAIL_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.SUPPORT_MATERIAL, ProjectBizConst.SUPPORT_MATERIAL_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.SELF_APPRAISAL_BASIS, ProjectBizConst.SELF_APPRAISAL_BASIS_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(ProjectBizConst.SELF_APPRAISAL_SCORE, ProjectBizConst.SELF_APPRAISAL_SCORE_TITLE, StrPool.EMPTY)); + List> headList = Lists.newArrayList(); + headList.add(new ExcelHead<>(ProjectBizConst.FIRST_INDEX_NAME, ProjectBizConst.FIRST_INDEX_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.SECOND_INDEX_NAME, ProjectBizConst.SECOND_INDEX_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.THIRD_INDEX_NAME, ProjectBizConst.THIRD_INDEX_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.INDEX_SCORE, ProjectBizConst.INDEX_SCORE_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.INDEX_DETAIL, ProjectBizConst.INDEX_DETAIL_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.GRADE_DETAIL, ProjectBizConst.GRADE_DETAIL_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.SUPPORT_MATERIAL, ProjectBizConst.SUPPORT_MATERIAL_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.SELF_APPRAISAL_BASIS, ProjectBizConst.SELF_APPRAISAL_BASIS_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.SELF_APPRAISAL_SCORE, ProjectBizConst.SELF_APPRAISAL_SCORE_TITLE, StrPool.EMPTY)); for (String reUser : reUserList) { - headList.add(new ExcelHead(reUser + ProjectBizConst.RE_APPRAISAL_BASIS, ProjectBizConst.RE_APPRAISAL_BASIS_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(reUser + ProjectBizConst.RE_APPRAISAL_SCORE, ProjectBizConst.RE_APPRAISAL_SCORE_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(reUser + ProjectBizConst.RE_APPRAISAL_BASIS, ProjectBizConst.RE_APPRAISAL_BASIS_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(reUser + ProjectBizConst.RE_APPRAISAL_SCORE, ProjectBizConst.RE_APPRAISAL_SCORE_TITLE, StrPool.EMPTY)); } for (String verifyUser : verifyUserList) { - headList.add(new ExcelHead(verifyUser + ProjectBizConst.VERIFY_BASIS, ProjectBizConst.VERIFY_BASIS_TITLE, StrPool.EMPTY)); - headList.add(new ExcelHead(verifyUser + ProjectBizConst.VERIFY_SCORE, ProjectBizConst.VERIFY_SCORE_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(verifyUser + ProjectBizConst.VERIFY_BASIS, ProjectBizConst.VERIFY_BASIS_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(verifyUser + ProjectBizConst.VERIFY_SCORE, ProjectBizConst.VERIFY_SCORE_TITLE, StrPool.EMPTY)); } - headList.add(new ExcelHead(ProjectBizConst.IS_ADDITIONAL, ProjectBizConst.IS_ADDITIONAL_TITLE, StrPool.EMPTY)); + headList.add(new ExcelHead<>(ProjectBizConst.IS_ADDITIONAL, ProjectBizConst.IS_ADDITIONAL_TITLE, StrPool.EMPTY)); // 数据导出处理函数 try { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/entity/PerformanceAppraisalProject.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/entity/PerformanceAppraisalProject.java index c75c383..6ccdb1e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/entity/PerformanceAppraisalProject.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/entity/PerformanceAppraisalProject.java @@ -82,7 +82,7 @@ public class PerformanceAppraisalProject implements Serializable { private String rectifyOpinion; @ApiModelProperty("整改提交人员工code") - private String rectifySubmitEmployeeCode; + private String rectifySubmitUserId; @ApiModelProperty("整改提交时间") private LocalDateTime rectifySubmitTime; @@ -106,7 +106,7 @@ public class PerformanceAppraisalProject implements Serializable { private String rectifyResultAppendix; @ApiModelProperty("整改结果提交人员工code") - private String rectifyResSubEmpCode; + private String rectifyResSubUserId; @ApiModelProperty("整改结果提交时间") private LocalDateTime rectifyResSubTime; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/entity/PerformanceAppraisalScoreInfo.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/entity/PerformanceAppraisalScoreInfo.java index 2d158b0..249d86b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/entity/PerformanceAppraisalScoreInfo.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/entity/PerformanceAppraisalScoreInfo.java @@ -54,10 +54,10 @@ public class PerformanceAppraisalScoreInfo implements Serializable { private String appraisalBasisAppendix; @ApiModelProperty("评价人员code") - private String appraisalEmployeeCode; + private String appraisalUserId; @ApiModelProperty("评价人员姓名") - private String appraisalEmployeeName; + private String appraisalUserName; @ApiModelProperty("评价类型 1 单位自评、2 复评人员复评、3 专家核查、4 专家整改审核、5 应用评价") private Integer appraisalType; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/vo/RectifyDetailVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/vo/RectifyDetailVO.java index 5677f15..fa2c05b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/vo/RectifyDetailVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/model/vo/RectifyDetailVO.java @@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.io.Serializable; import java.time.LocalDateTime; /** @@ -16,15 +15,13 @@ import java.time.LocalDateTime; */ @Data @ApiModel(value = "整改详情", description = "整改详情") -public class RectifyDetailVO implements Serializable { - - private static final long serialVersionUID = 1L; +public class RectifyDetailVO { @ApiModelProperty("整改意见") private String rectifyOpinion; @ApiModelProperty("整改提交人") - private UserFullInfoDTO rectifySubmitEmployee; + private UserFullInfoDTO rectifySubmitUser; @ApiModelProperty("整改提交时间") private LocalDateTime rectifySubmitTime; @@ -36,7 +33,7 @@ public class RectifyDetailVO implements Serializable { private String rectifyResultAppendix; @ApiModelProperty("整改结果提交人") - private UserFullInfoDTO rectifyResSubEmployee; + private UserFullInfoDTO rectifyResSubUser; @ApiModelProperty("整改结果提交时间") private LocalDateTime rectifyResSubTime; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/performance/util/ExcelUtils.java b/hz-pm-api/src/main/java/com/hz/pm/api/performance/util/ExcelUtils.java index baa2a13..b46292a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/performance/util/ExcelUtils.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/performance/util/ExcelUtils.java @@ -50,12 +50,12 @@ public class ExcelUtils { * @param dataList 表内容数据转换 * @return List> */ - public static List> convertData(List headList, List> dataList) { + public static List> convertData(List> headList, List> dataList) { List> result = Lists.newArrayList(); //对 dataList 转为 easyExcel 的数据格式 for (Map data : dataList) { List row = Lists.newArrayList(); - for (ExcelHead h : headList) { + for (ExcelHead h : headList) { Object o = data.get(h.getFieldName()); //需要对null的处理,转换为空字符串 row.add(handler(o, h.getNullValue())); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/portrait/manage/TagManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/portrait/manage/TagManage.java index 164ae81..68748c6 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/portrait/manage/TagManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/portrait/manage/TagManage.java @@ -59,6 +59,7 @@ public class TagManage { /** * 标签分页 + * * @param areaCode * @param req * @return @@ -67,57 +68,51 @@ public class TagManage { RegionDTO regionDto = regionCacheHelper.getByCodeAndLevel(areaCode, RegionConst.RL_COUNTY); String regionCode = Objects.nonNull(regionDto) ? regionDto.getRegionCode() : null; LambdaQueryWrapper query = Wrappers.lambdaQuery(Tag.class) - .eq(Objects.nonNull(regionCode),Tag::getAreaCode, regionCode) - .like(StringUtils.isNotBlank(req.getName()),Tag::getName,req.getName()) + .eq(Objects.nonNull(regionCode), Tag::getAreaCode, regionCode) + .like(StringUtils.isNotBlank(req.getName()), Tag::getName, req.getName()) .orderByDesc(Tag::getUpdateOn); - checkAuth(query,LoginUserUtil.loginUserDetail()); + checkAuth(query, LoginUserUtil.loginUserDetail()); Page page = tagService.page(req.page(), query); long total; if ((total = page.getTotal()) == 0) { return PageVo.empty(); } List records = CollUtils.convert(page.getRecords(), - t -> BeanUtil.copyProperties(t,TagVO.class)); + t -> BeanUtil.copyProperties(t, TagVO.class)); return PageVo.of(records, total); } /** * 权限控制 - * @param query - * @param user + * + * @param query \ + * @param user \ */ private void checkAuth(LambdaQueryWrapper query, UserInfoDetails user) { //如果是超管 - if(user.getSuperAdmin()){ + if (user.getSuperAdmin() || user.getRegionAdmin()) { log.info(user.getUsername() + " 是超管,可以看所有标签"); - }else if(user.getRegionAdmin()){ - //如果是区域管理员 - log.info(user.getUsername() + " 是区管,可以看本区域" + user.getRegionCode() + "标签"); - if(!RegionConst.RC_HZ.equals(user.getRegionCode())){ - //非市本级的区管 只可以看自己区域的 - query.eq(Tag::getAreaCode,user.getRegionCode()); - } - //市本级 能看所有区域 - }else{ + } else { //其它角色全都看不见 - query.eq(Tag::getId,0L); + query.eq(Tag::getId, 0L); } } /** * 保存标签 - * @param dto - * @return + * + * @param dto \ + * @return \ */ public String save(TagDTO dto) { deduplicationName(dto); UserInfoDetails user = LoginUserUtil.loginUserDetail(); - Tag entity = BeanUtil.copyProperties(dto,Tag.class); - if(Objects.nonNull(dto.getId())){ + Tag entity = BeanUtil.copyProperties(dto, Tag.class); + if (Objects.nonNull(dto.getId())) { Tag old = tagService.getById(dto.getId()); VUtils.isTrue(Objects.isNull(old)).throwMessage("此id标签不存在!"); entity.setId(old.getId()); - }else{ + } else { entity.setId(null); entity.setCreateOn(LocalDateTime.now()); entity.setCreateBy(user.getUsername()); @@ -131,10 +126,11 @@ public class TagManage { /** * 标签名 去重 + * * @param dto */ private void deduplicationName(TagDTO dto) { - if(StringUtils.isNotBlank(dto.getName())){ + if (StringUtils.isNotBlank(dto.getName())) { long count = tagService.count(Wrappers.lambdaQuery(Tag.class) .eq(Tag::getAreaCode, dto.getAreaCode()) .eq(Tag::getName, dto.getName()) @@ -144,7 +140,7 @@ public class TagManage { } public String saveToProject(List dtos) { - if(CollUtil.isEmpty(dtos)){ + if (CollUtil.isEmpty(dtos)) { return "参入的标签为空"; } UserInfoDetails user = LoginUserUtil.loginUserDetail(); @@ -155,10 +151,10 @@ public class TagManage { .last(BizConst.LIMIT_1)); VUtils.isTrue(Objects.isNull(project) && Objects.isNull(baseinfo)).throwMessage("项目不存在!"); projectTagService.remove(Wrappers.lambdaQuery(ProjectTag.class) - .eq(ProjectTag::getProjectCode,projectCode)); + .eq(ProjectTag::getProjectCode, projectCode)); //去重 dtos = dtos.stream().distinct().collect(Collectors.toList()); - for(TagToProjectDTO dto : dtos){ + for (TagToProjectDTO dto : dtos) { Long tagId = dto.getTagId(); Tag tag = tagService.getById(tagId); VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!"); @@ -178,7 +174,8 @@ public class TagManage { public String removeTagToProject(TagToProjectDTO dto) { String projectCode = dto.getProjectCode(); Project project = projectService.getProjectByCode(projectCode); - GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) + GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers + .lambdaQuery(GovBizProjectBaseinfo.class) .eq(GovBizProjectBaseinfo::getBaseProjId, projectCode) .last(BizConst.LIMIT_1)); VUtils.isTrue(Objects.isNull(project) && Objects.isNull(baseinfo)).throwMessage("项目不存在!"); @@ -202,6 +199,7 @@ public class TagManage { /** * 删除标签 + * * @param id * @return */ @@ -210,10 +208,10 @@ public class TagManage { VUtils.isTrue(Objects.isNull(tag)) .throwMessage("删除失败 此标签ID不存在!"); - if(tagService.removeById(id)){ + if (tagService.removeById(id)) { //关联关系 也要删 projectTagService.remove(Wrappers.lambdaQuery(ProjectTag.class) - .eq(ProjectTag::getTagId,id)); + .eq(ProjectTag::getTagId, id)); return "删除成功"; } return "删除失败"; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/DeclaredProjectController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/DeclaredProjectController.java index 7b6c6fc..5e10f1c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/DeclaredProjectController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/controller/DeclaredProjectController.java @@ -66,7 +66,7 @@ public class DeclaredProjectController { @ApiOperation(value = "申报项目草稿箱详情", notes = "申报项目草稿箱详情") @GetMapping("/draft/{id}") public ProjectDraftVO draft(@PathVariable(value = "id") Long id) { - return declaredProjectManage.draftDatail(id); + return declaredProjectManage.draftDetail(id); } @ApiOperation(value = "申报项目保存至草稿箱", notes = "申报项目保存至草稿箱") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java index 381ca93..50c4746 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java @@ -7,8 +7,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; -import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.helper.UserInfoHelper; +import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.statemachine.util.StateMachineUtil; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; @@ -25,10 +25,10 @@ import com.hz.pm.api.projectdeclared.service.IContractService; import com.hz.pm.api.projectdeclared.service.IPaymentPlanService; import com.hz.pm.api.projectdeclared.service.IPreInsAcceptancePersonService; import com.hz.pm.api.projectdeclared.service.IPurchaseService; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; -import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.helper.ProjectHelper; import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.model.req.ProjectListReq; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; import com.hz.pm.api.projectlib.service.IProjectService; @@ -89,7 +89,6 @@ public class ConstructionManage { */ public PageVo projectLibList(ProjectListReq req) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); //建设中状态 query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); @@ -97,7 +96,7 @@ public class ConstructionManage { query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getNewest, Boolean.TRUE); //只能看自己单位的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); query.orderByAsc(Project::getTransactionTime); Page page = projectService.page(req.page(), query); long total; @@ -136,7 +135,6 @@ public class ConstructionManage { */ public PageVo projectlistPerfect(ProjectListReq req) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); //建设中状态以后的 都是 query.and(q1 -> q1.gt(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) @@ -144,7 +142,7 @@ public class ConstructionManage { .isNotNull(Project::getContractAmount))); query.eq(Project::getNewest, Boolean.TRUE); //只能看自己单位的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); query.orderByAsc(Project::getUpdateOn); Page page = projectService.page(req.page(), query); @@ -172,9 +170,9 @@ public class ConstructionManage { /** * 判断 是否需要补充 * - * @param w - * @param paymentMap - * @return + * @param w \ + * @param paymentMap \ + * @return \ */ private Boolean checkIsSupplement(Project w, Map> paymentMap) { if (paymentMap.containsKey(w.getProjectCode())) { @@ -194,7 +192,6 @@ public class ConstructionManage { public void exportList(HttpServletResponse response, ProjectListReq param) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(param); //待采购状态 query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); @@ -296,9 +293,6 @@ public class ConstructionManage { */ public String submitContract(ContractSaveDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); - Long projectId = dto.getProjectId(); VUtils.isTrue(Objects.isNull(projectId)).throwMessage("提交失败 缺少项目ID!"); Project project = projectService.getNewProject(dto.getProjectId()); @@ -317,7 +311,7 @@ public class ConstructionManage { BeanUtil.copyProperties(dto, contractEntity); if (Objects.isNull(contract)) { contractEntity.setCreateOn(LocalDateTime.now()); - contractEntity.setCreateBy(employeeCode); + contractEntity.setCreateBy(user.getUserIdStr()); } else { contractEntity.setId(contract.getId()); } @@ -336,8 +330,8 @@ public class ConstructionManage { plan.setProjectCode(project.getProjectCode()); plan.setCreateOn(LocalDateTime.now()); plan.setUpdateOn(LocalDateTime.now()); - plan.setCreateBy(employeeCode); - plan.setUpdateBy(employeeCode); + plan.setCreateBy(user.getUserIdStr()); + plan.setUpdateBy(user.getUserIdStr()); return plan; }).collect(Collectors.toList()); @@ -378,7 +372,7 @@ public class ConstructionManage { query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getNewest, Boolean.TRUE); //只能看自己单位的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); //交货时间 排序 query.isNotNull(Project::getDeliveryTime); query.orderByAsc(Project::getDeliveryTime); @@ -420,7 +414,7 @@ public class ConstructionManage { LambdaQueryWrapper query = ProjectHelper.projectQuery(param); //待采购状态 //只能看自己单位的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getNewest, Boolean.TRUE); @@ -503,9 +497,6 @@ public class ConstructionManage { */ public String submitPreIns(PreInsSaveDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); - Long projectId = dto.getProjectId(); VUtils.isTrue(Objects.isNull(projectId)).throwMessage("提交失败 缺少项目ID!"); Project project = projectService.getNewProject(dto.getProjectId()); @@ -527,8 +518,8 @@ public class ConstructionManage { person.setProjectId(projectId); person.setCreateOn(LocalDateTime.now()); person.setUpdateOn(LocalDateTime.now()); - person.setCreateBy(employeeCode); - person.setUpdateBy(employeeCode); + person.setCreateBy(user.getUserIdStr()); + person.setUpdateBy(user.getMhUnitIdStr()); return person; }).collect(Collectors.toList()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionPlanManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionPlanManage.java index 501006f..1a4b381 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionPlanManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionPlanManage.java @@ -5,13 +5,12 @@ import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.model.constant.CommonConst; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.RegionCacheHelper; 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.CommonConst; import com.hz.pm.api.common.statemachine.util.StateMachineUtil; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; @@ -21,14 +20,14 @@ import com.hz.pm.api.projectdeclared.model.dto.DefaultDeclaredDTO; import com.hz.pm.api.projectdeclared.model.entity.ProjectConstructionSuggestions; import com.hz.pm.api.projectdeclared.model.req.ConstrctionPlanListReq; import com.hz.pm.api.projectdeclared.service.IConstrctionSuggestionsService; -import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; -import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.helper.ProjectHelper; import com.hz.pm.api.projectlib.manage.ProjectLibManage; import com.hz.pm.api.projectlib.model.dto.ProjectDTO; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectInst; +import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.model.req.ProjectListReq; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; import com.hz.pm.api.projectlib.service.IProjectInstService; @@ -100,29 +99,20 @@ public class ConstructionPlanManage { @Transactional(rollbackFor = Exception.class) public String startTheProcess(DefaultDeclaredDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(Objects.isNull(user) || Objects.isNull(employeeCode)) - .throwMessage("获取登录用户失败!"); - + Long userId = user.getUserId(); ProjectDTO projectInfo = dto.getProjectInfo(); Long projectInfoId = projectInfo.getId(); - VUtils.isTrue(Objects.isNull(projectInfoId)).throwMessage("提交失败 缺少项目ID!"); + VUtils.isTrue(Objects.isNull(projectInfoId)).throwMessage("提交失败,缺少项目ID!"); Project oldProject = projectService.getById(projectInfoId); - VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!"); - VUtils.isTrue(StringUtils.isBlank(projectInfo.getConstructionPlanFile())).throwMessage("提交失败 请提交建设方案!"); + VUtils.isTrue(StringUtils.isBlank(projectInfo.getConstructionPlanFile())).throwMessage("提交失败,请提交建设方案!"); // 判断 项目当前状态 是不是 方案待申报 VUtils.isTrue(!ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode().equals(oldProject.getStatus()) || !ProjectStatusEnum.NOT_APPROVED.getCode().equals(oldProject.getStage())) .throwMessage("提交失败 该项目不是 方案待申报状态或者未立项阶段"); - if (StringUtils.isNotBlank(user.getRegionCode())) { - projectInfo.setAreaCode(user.getRegionCode()); - projectInfo.setArea(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); - } - - projectInfo.setBuildOrgCode(user.getEmpPosUnitCode()); - projectInfo.setBuildOrgName(user.getEmpPosUnitName()); + projectInfo.setBuildOrgCode(user.getMhUnitIdStr()); + projectInfo.setBuildOrgName(user.getMhUnitName()); // 项目名称去重 if (StringUtils.isNotBlank(projectInfo.getProjectName()) && !projectInfo.getProjectName() @@ -135,8 +125,8 @@ public class ConstructionPlanManage { //如果主管单位没有 那么主管单位就是自己 if (CommonEnum.NO.getCode().equals(projectInfo.getIsSuperOrg())) { - projectInfo.setSuperOrgCode(user.getEmpPosUnitCode()); - projectInfo.setSuperOrg(user.getEmpPosUnitName()); + projectInfo.setSuperOrgCode(user.getMhUnitIdStr()); + projectInfo.setSuperOrg(user.getMhUnitName()); } Project constructProject = new Project(); @@ -144,16 +134,12 @@ public class ConstructionPlanManage { constructProject.setStatus(oldProject.getStatus()); constructProject.setStage(oldProject.getStage()); - String regionCode = user.getRegionCode(); - WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) - .eq(WflowModels::getRegionCode, regionCode) .eq(WflowModels::getProcessType, ProjectProcessStageEnum.CONSTRUCTION_PROJECT_APPROVAL_PROCESS.getCode()) .last(BizConst.LIMIT_1)); if (Objects.isNull(model)) { - log.error("此 【{}】区域找不到 建设申报流程配置", regionCode); - throw new BusinessException(String.format("此 【%s】区域找不到 建设申报流程配置", regionCode)); + throw new BusinessException("找不到建设申报流程配置"); } //如果被禁用了的话 直接跳过 进入到下一个状态 @@ -167,13 +153,13 @@ public class ConstructionPlanManage { } ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(declaredProjectManage.buildUser(employeeCode)); + params.setUser(declaredProjectManage.buildUser(userId)); params.setProcessUsers(Collections.emptyMap()); //放入条件判断的项目字段 //把条件值给放入工作流 defaultDeclaredProjectManage.buildCondition(params, oldProject, dto); // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 - Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode, constructProject); + Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(userId, constructProject); String instanceId = processService.startProcessLs(model, params, orgModelMap); log.info("建设方案项目申报成功 【{}】", instanceId); @@ -183,7 +169,7 @@ public class ConstructionPlanManage { //如果是重新提交 不用生成新版本 前面已经生成过了 buildProject = contructionPlanModifyProject(oldProject, instanceId); } else { - buildProject = projectLibManage.saveConstructProjectInDeclared(projectInfo, instanceId, employeeCode, oldProject); + buildProject = projectLibManage.saveConstructProjectInDeclared(projectInfo, instanceId, userId, oldProject); } //发送给第一个审批人消息 @@ -219,10 +205,6 @@ public class ConstructionPlanManage { */ @Transactional(rollbackFor = Exception.class) public String restartTheProcess(DefaultDeclaredDTO dto) { - UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user) || Objects.isNull(user.getEmployeeCode())) - .throwMessage("获取登录用户失败!"); - ProjectDTO projectDto = dto.getProjectInfo(); VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); Project projectInfo = projectService.getById(projectDto.getId()); @@ -282,7 +264,7 @@ public class ConstructionPlanManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); //放入用户的单位 - req.setBuildOrgCode(user.getEmpPosUnitCode()); + req.setBuildOrgCode(user.getMhUnitIdStr()); return projectLibManage.projectLibList(req); } @@ -296,7 +278,7 @@ public class ConstructionPlanManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); //放入用户的单位 - req.setBuildOrgCode(user.getEmpPosUnitCode()); + req.setBuildOrgCode(user.getMhUnitIdStr()); req.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); req.setPageSize(CommonConst.EXPORT_PAGE_SIZE); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java index 851f9b5..c56b597 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DeclaredProjectManage.java @@ -8,16 +8,17 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; +import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.NdDateUtils; import com.ningdatech.basic.util.StrPool; import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.RegionCacheHelper; @@ -92,7 +93,7 @@ public class DeclaredProjectManage { private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; private final NoticeManage noticeManage; - + private final UserInfoHelper userInfoHelper; private final RegionCacheHelper regionCacheHelper; @@ -113,18 +114,10 @@ public class DeclaredProjectManage { @Transactional(rollbackFor = Exception.class) public String startTheProcess(DefaultDeclaredDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); - ProjectDTO projectInfo = dto.getProjectInfo(); - if(StringUtils.isNotBlank(user.getRegionCode())){ - projectInfo.setAreaCode(user.getRegionCode()); - projectInfo.setArea(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); - } - - projectInfo.setBuildOrgCode(user.getEmpPosUnitCode()); - projectInfo.setBuildOrgName(user.getEmpPosUnitName()); + projectInfo.setBuildOrgCode(user.getMhUnitIdStr()); + projectInfo.setBuildOrgName(user.getMhUnitName()); //项目名称去重 defaultDeclaredProjectManage.checkDuplication(projectInfo); @@ -136,31 +129,27 @@ public class DeclaredProjectManage { projectInfo.setIsSuperOrg(CommonEnum.YES.getCode()); //如果主管单位没有 那么主管单位就是自己 - if(CommonEnum.NO.getCode().equals(projectInfo.getIsSuperOrg())){ - projectInfo.setSuperOrgCode(user.getEmpPosUnitCode()); - projectInfo.setSuperOrg(user.getEmpPosUnitName()); + if (CommonEnum.NO.getCode().equals(projectInfo.getIsSuperOrg())) { + projectInfo.setSuperOrgCode(user.getMhUnitIdStr()); + projectInfo.setSuperOrg(user.getMhUnitName()); } //如果是重新提交的话 判断下 项目是否存在 - if(Objects.nonNull(projectInfo.getId())){ + if (Objects.nonNull(projectInfo.getId())) { //新申报的项目不允许带项目id projectInfo.setId(null); } - String regionCode = user.getRegionCode(); - WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) - .eq(WflowModels::getRegionCode, regionCode) .eq(WflowModels::getProcessType, ProjectProcessStageEnum.ORG_INTERNAL_APPROVAL_PROCESS.getCode()) .last(BizConst.LIMIT_1)); if (Objects.isNull(model)) { - log.error("此 【{}】区域找不到单位流程配置", regionCode); - throw new BusinessException(String.format("此 【%s】区域找不到单位流程配置", regionCode)); + throw new BusinessException("找不到单位流程配置"); } ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); + params.setUser(defaultDeclaredProjectManage.buildUser(user.getUserId())); params.setProcessUsers(Collections.emptyMap()); //放入条件判断的项目字段 ProjectConditionDTO conditionDto = new ProjectConditionDTO(); @@ -173,21 +162,21 @@ public class DeclaredProjectManage { //开始申报 // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 Project project = new Project(); - BeanUtils.copyProperties(projectInfo,project); - Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode,project); - String instanceId = processService.startProcessLs(model, params,orgModelMap); + BeanUtils.copyProperties(projectInfo, project); + Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(user.getUserId(), project); + String instanceId = processService.startProcessLs(model, params, orgModelMap); log.info("申报项目成功 【{}】", instanceId); //如果是重新提交的话 判断下 项目是否存在 //保存项目相关 - Project buildProject = projectLibManage.saveProjectInDeclared(projectInfo,instanceId,employeeCode); - if(Objects.nonNull(projectInfo.getDraftId())){ + Project buildProject = projectLibManage.saveProjectInDeclared(projectInfo, instanceId, user.getUserId()); + if (Objects.nonNull(projectInfo.getDraftId())) { //如果是草稿箱提交 删除对应的草稿箱 projectDraftService.removeById(projectInfo.getDraftId()); } //发送给第一个审批人消息 - noticeManage.sendFirtUser(buildProject,model.getFormName(),instanceId, + noticeManage.sendFirtUser(buildProject, model.getFormName(), instanceId, WorkNoticeConstant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); return instanceId; @@ -203,22 +192,17 @@ public class DeclaredProjectManage { @Transactional(rollbackFor = Exception.class) public String reStartTheProcess(DefaultDeclaredDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user) || Objects.isNull(user.getEmployeeCode())) - .throwMessage("获取登录用户失败!"); - String employeeCode = user.getEmployeeCode(); ProjectDTO projectDto = dto.getProjectInfo(); - projectDto.setAreaCode(user.getRegionCode()); - projectDto.setArea(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); - projectDto.setBuildOrgCode(user.getEmpPosUnitCode()); - projectDto.setBuildOrgName(user.getEmpPosUnitName()); + projectDto.setBuildOrgCode(user.getMhUnitIdStr()); + projectDto.setBuildOrgName(user.getMhUnitName()); VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); Project projectInfo = projectService.getById(projectDto.getId()); VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!"); //项目名称去重 - if(StringUtils.isNotBlank(projectDto.getProjectName()) && - !projectDto.getProjectName().equals(projectInfo.getProjectName())){ + if (StringUtils.isNotBlank(projectDto.getProjectName()) && + !projectDto.getProjectName().equals(projectInfo.getProjectName())) { projectDto.setProjectCode(projectInfo.getProjectCode()); defaultDeclaredProjectManage.checkDuplication(projectDto); } @@ -228,25 +212,22 @@ public class DeclaredProjectManage { projectInfo.setIsSuperOrg(CommonEnum.YES.getCode()); //如果主管单位没有 那么主管单位就是自己 - if(CommonEnum.NO.getCode().equals(projectDto.getIsSuperOrg())){ - projectInfo.setSuperOrgCode(user.getEmpPosUnitCode()); - projectInfo.setSuperOrg(user.getEmpPosUnitName()); - projectDto.setSuperOrgCode(user.getEmpPosUnitCode()); - projectDto.setSuperOrg(user.getEmpPosUnitName()); + if (CommonEnum.NO.getCode().equals(projectDto.getIsSuperOrg())) { + projectInfo.setSuperOrgCode(user.getMhUnitIdStr()); + projectInfo.setSuperOrg(user.getMhUnitName()); + projectDto.setSuperOrgCode(user.getMhUnitIdStr()); + projectDto.setSuperOrg(user.getMhUnitName()); } //判断申报金额 是否等于总的 判断年度支付金额 是否等于总金额 defaultDeclaredProjectManage.checkAmount(projectDto); - String regionCode = projectInfo.getAreaCode(); WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) - .eq(WflowModels::getRegionCode, regionCode) .eq(WflowModels::getProcessType, ProjectProcessStageEnum.ORG_INTERNAL_APPROVAL_PROCESS.getCode()) .last(BizConst.LIMIT_1)); if (Objects.isNull(model)) { - log.error("此 【{}】区域找不到单位流程配置", regionCode); - throw new BusinessException(String.format("此 【%s】区域找不到单位流程配置", regionCode)); + throw new BusinessException("找不到单位流程配置"); } //首先要判断 项目当前状态 是不是 单位内部拒绝 @@ -255,24 +236,24 @@ public class DeclaredProjectManage { .throwMessage("提交失败 该项目不是 单位内部拒绝审核状态或者未立项阶段"); ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); + params.setUser(defaultDeclaredProjectManage.buildUser(user.getUserId())); params.setProcessUsers(Collections.emptyMap()); //把条件值给放入工作流 - defaultDeclaredProjectManage.buildCondition(params,dto); + defaultDeclaredProjectManage.buildCondition(params, dto); // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 Project project = new Project(); - BeanUtils.copyProperties(projectDto,project); - Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode,project); - String instanceId = processService.startProcessLs(model, params,orgModelMap); + BeanUtils.copyProperties(projectDto, project); + Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(user.getUserId(), project); + String instanceId = processService.startProcessLs(model, params, orgModelMap); log.info("重新申报项目成功 【{}】", instanceId); //保存项目相关 - Project buildProject = projectLibManage.saveProjectInDeclared(projectDto,instanceId,employeeCode); + Project buildProject = projectLibManage.saveProjectInDeclared(projectDto, instanceId, user.getUserId()); //发送给第一个审批人消息 - noticeManage.sendFirtUser(buildProject,model.getFormName(),instanceId, + noticeManage.sendFirtUser(buildProject, model.getFormName(), instanceId, WorkNoticeConstant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); return instanceId; @@ -282,7 +263,7 @@ public class DeclaredProjectManage { Long userId = LoginUserUtil.getUserId(); Page page = params.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(ProjectDraft.class) - .eq(ProjectDraft::getUserId,userId) + .eq(ProjectDraft::getUserId, userId) .ge(Objects.nonNull(params.getStartTime()), ProjectDraft::getCreateOn, params.getStartTime()) .le(Objects.nonNull(params.getEndTime()), ProjectDraft::getCreateOn, params.getEndTime()) .eq(Objects.nonNull(params.getProjectType()), ProjectDraft::getProjectType, params.getProjectType()) @@ -304,16 +285,16 @@ public class DeclaredProjectManage { return PageVo.of(res, page.getTotal()); } - public ProjectDraftVO draftDatail(Long id) { + public ProjectDraftVO draftDetail(Long id) { ProjectDraft draft = projectDraftService.getById(id); ProjectDraftVO vo = new ProjectDraftVO(); BeanUtils.copyProperties(draft, vo); vo.setBizDomain(Objects.nonNull(draft.getBizDomain()) ? String.valueOf(draft.getBizDomain()) : StringUtils.EMPTY); - if(StringUtils.isNotBlank(draft.getProjectApplicationList())){ - vo.setApplicationList(JSON.parseArray(draft.getProjectApplicationList(),ProjectApplication.class)); + if (StringUtils.isNotBlank(draft.getProjectApplicationList())) { + vo.setApplicationList(JSON.parseArray(draft.getProjectApplicationList(), ProjectApplication.class)); } - if(StringUtils.isNotBlank(draft.getDynamicForm())){ - vo.setDynamicForm(JSON.parseObject(draft.getDynamicForm(),Map.class)); + if (StringUtils.isNotBlank(draft.getDynamicForm())) { + vo.setDynamicForm(JSON.parseObject(draft.getDynamicForm(), Map.class)); } return vo; } @@ -335,21 +316,20 @@ public class DeclaredProjectManage { draft.setIsHigherSuperOrg(CommonEnum.YES.getCode()); draft.setIsSuperOrg(CommonEnum.YES.getCode()); draft.setUserId(String.valueOf(userId)); - draft.setBuildOrgCode(user.getEmpPosUnitCode()); - draft.setBuildOrgName(user.getEmpPosUnitName()); - draft.setAreaCode(user.getRegionCode()); + draft.setBuildOrgCode(user.getMhUnitIdStr()); + draft.setBuildOrgName(user.getMhUnitName()); - if(CollUtil.isNotEmpty(projectInfo.getDynamicForm())){ + if (CollUtil.isNotEmpty(projectInfo.getDynamicForm())) { draft.setDynamicForm(JSON.toJSONString(projectInfo.getDynamicForm())); } - if(CollUtil.isNotEmpty(projectInfo.getApplicationList())){ + if (CollUtil.isNotEmpty(projectInfo.getApplicationList())) { draft.setProjectApplicationList(JSON.toJSONString(projectInfo.getApplicationList())); } if (Objects.isNull(draft.getId())) { draft.setCreateOn(LocalDateTime.now()); - }else{ + } else { ProjectDraft old = projectDraftService.getById(draft.getId()); - if(Objects.isNull(old)){ + if (Objects.isNull(old)) { draft.setCreateOn(LocalDateTime.now()); } } @@ -361,45 +341,44 @@ public class DeclaredProjectManage { /** * 项目列表 + * * @param req * @return */ public PageVo projectLibList(ProjectListReq req) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); - //当非预审申报的时候 是自己单位 当是预审申报的时候 要主管单位 - preQuery(query,user); - query.eq(Project::getNewest,Boolean.TRUE); + // 当非预审申报的时候 是自己单位 当是预审申报的时候 要主管单位 + preQuery(query, user); + query.eq(Project::getNewest, Boolean.TRUE); Page page = projectService.page(req.page(), query); long total; if ((total = page.getTotal()) == 0) { return PageVo.empty(); } - List records = CollUtils.convert(page.getRecords(), w -> BeanUtil.copyProperties(w,ProjectLibListItemVO.class)); + List records = CollUtils.convert(page.getRecords(), w -> BeanUtil.copyProperties(w, ProjectLibListItemVO.class)); return PageVo.of(records, total); } //当非预审申报的时候 是自己单位 当是预审申报的时候 要主管单位 并且他是单位管理员 - private void preQuery(LambdaQueryWrapper query,UserFullInfoDTO user) { + private void preQuery(LambdaQueryWrapper query, UserFullInfoDTO user) { //如果当前登录是单位管理员 - if(user.getIsOrgAdmin()){ - query.and(s1 -> s1.eq(Project::getStatus,ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode()) - .eq(Project::getSuperOrgCode,user.getEmpPosUnitCode()) - .or(q2 -> q2.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()))); - }else{ + if (user.getIsOrgAdmin()) { + query.and(s1 -> s1.eq(Project::getStatus, ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode()) + .eq(Project::getSuperOrgCode, user.getMhUnitId()) + .or(q2 -> q2.eq(Project::getBuildOrgCode, user.getMhUnitId()))); + } else { //否则 只能看到 非预审 并且 - query.and(q2 -> q2.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode())); + query.and(q2 -> q2.eq(Project::getBuildOrgCode, user.getMhUnitId())); } } public void exportList(HttpServletResponse response, ProjectListReq param) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(param); //当非预审申报的时候 是自己单位 当是预审申报的时候 要主管单位 - preQuery(query,user); - query.eq(Project::getNewest,Boolean.TRUE); + preQuery(query, user); + query.eq(Project::getNewest, Boolean.TRUE); List records = projectService.list(query); AtomicInteger serialNumber = new AtomicInteger(0); @@ -414,7 +393,7 @@ public class DeclaredProjectManage { return exportDTO; }).collect(Collectors.toList()); String fileName = "项目申报列表"; - ExcelDownUtil.setFileName(fileName,response); + ExcelDownUtil.setFileName(fileName, response); //数据导出处理函数 try { EasyExcel.write(response.getOutputStream(), DeclaredProjectExportDTO.class) @@ -423,58 +402,59 @@ public class DeclaredProjectManage { .sheet(fileName) .doWrite(collect); } catch (IOException e) { - throw new RuntimeException(e); + throw new BizException(e); } } /** * 查询 核心业务 - * @param businessName - * @return + * + * @param businessName \ + * @return \ */ - public JSONObject bizList(String businessName,Integer limit, Integer page,String orgCode) { + public JSONObject bizList(String businessName, Integer limit, Integer page, String orgCode) { JSONObject jsonObject = new JSONObject(); UserInfoDetails user = LoginUserUtil.loginUserDetail(); - if(BizConst.DEV.equals(active)){ + if (BizConst.DEV.equals(active)) { jsonObject = JSONObject.parseObject(DeclaredProjectConst.Biz.CORE_BIZ); - if(CollUtil.isEmpty(jsonObject)){ + if (CollUtil.isEmpty(jsonObject)) { return jsonObject; } - if(StringUtils.isNotBlank(businessName)){ + if (StringUtils.isNotBlank(businessName)) { JSONArray dataArray = jsonObject.getJSONArray(BizConst.RESPONSE_KEY_DATA); - if(CollUtil.isEmpty(dataArray)){ + if (CollUtil.isEmpty(dataArray)) { return new JSONObject(); } - Iterator iter = dataArray.stream().iterator(); + Iterator iter = dataArray.stream().iterator(); JSONArray dataArrayRes = new JSONArray(); while (iter.hasNext()) { JSONObject value = (JSONObject) iter.next(); String businessValue = value.getString("matterName"); - if(StringUtils.isNotBlank(businessValue) && businessValue.contains(businessName)){ + if (StringUtils.isNotBlank(businessValue) && businessValue.contains(businessName)) { dataArrayRes.add(value); } } - jsonObject.put("data",dataArrayRes); - jsonObject.put("total",dataArrayRes.size()); + jsonObject.put("data", dataArrayRes); + jsonObject.put("total", dataArrayRes.size()); } - }else if(BizConst.PRE.equals(active) || - BizConst.PROD.equals(active)){ - if(StringUtils.isNotBlank(orgCode)){ + } else if (BizConst.PRE.equals(active) || + BizConst.PROD.equals(active)) { + if (StringUtils.isNotBlank(orgCode)) { String[] orgCodes = orgCode.split(StrPool.COMMA); JSONArray finalArray = new JSONArray(); - for(String og : orgCodes){ - JSONObject res = projectIrsManage.searchCoreBiz(businessName,og,limit,page); - if(Objects.nonNull(res)){ + for (String og : orgCodes) { + JSONObject res = projectIrsManage.searchCoreBiz(businessName, og, limit, page); + if (Objects.nonNull(res)) { JSONArray dataArray = res.getJSONArray(BizConst.RESPONSE_KEY_DATA); - if(CollUtil.isNotEmpty(dataArray)){ + if (CollUtil.isNotEmpty(dataArray)) { finalArray.addAll(dataArray); } } } - jsonObject.put("data",finalArray); - jsonObject.put("total",finalArray.size()); - }else{ - jsonObject = projectIrsManage.searchCoreBiz(businessName,user.getEmpPosUnitCode(),limit,page); + jsonObject.put("data", finalArray); + jsonObject.put("total", finalArray.size()); + } else { + jsonObject = projectIrsManage.searchCoreBiz(businessName, user.getMhUnitIdStr(), limit, page); } } return jsonObject; @@ -482,13 +462,13 @@ public class DeclaredProjectManage { /** * 预审失败的时候 可以删除项目 - * @param projectCode + * + * @param projectCode \ */ @Transactional public String removeProject(String projectCode) { Project project = projectService.getProjectByCode(projectCode); - VUtils.isTrue(Objects.isNull(project)) - .throwMessage("该项目不存在"); + Assert.notNull(project, "该项目不存在"); VUtils.isTrue(Objects.isNull(project.getStatus()) || !ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode().equals(project.getStatus())) .throwMessage("不是预审不通过 状态 不能删除!"); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DefaultDeclaredProjectManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DefaultDeclaredProjectManage.java index d9b43ef..4f0e67e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DefaultDeclaredProjectManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DefaultDeclaredProjectManage.java @@ -4,11 +4,10 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Maps; -import com.ningdatech.basic.function.VUtils; -import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.enumeration.CommonEnum; 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.RegionConst; import com.hz.pm.api.projectdeclared.model.dto.DefaultDeclaredDTO; import com.hz.pm.api.projectdeclared.model.dto.ProjectConditionDTO; import com.hz.pm.api.projectdeclared.model.po.DeclaredProjectStatisticsPO; @@ -17,6 +16,7 @@ import com.hz.pm.api.projectlib.model.dto.ProjectDTO; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.user.security.model.UserFullInfoDTO; +import com.ningdatech.basic.function.VUtils; import com.wflow.bean.entity.WflowModels; import com.wflow.bean.entity.WflowOrgModels; import com.wflow.enums.OrgTypeEnum; @@ -31,13 +31,13 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; + import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; /** * @Classname DefaultDeclaredProjectManage - * * @Description * @Date 2023/2/14 17:12 * @Author PoffyZhang @@ -59,24 +59,22 @@ public class DefaultDeclaredProjectManage { /** * 公共的发起流程方法 */ - public void startProcess(ProjectDTO projectDTO,UserFullInfoDTO user,Integer processType){ + public void startProcess(ProjectDTO projectDTO, UserFullInfoDTO user, Integer processType) { WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class) - .eq(WflowModels::getRegionCode, user.getRegionCode()) .eq(WflowModels::getProcessType, processType) .last(BizConst.LIMIT_1)); if (Objects.isNull(model)) { - log.error("此 【{}】区域找不到对应流程配置", user.getRegionCode()); - throw new BusinessException(String.format("此 【%s】区域找不到对应流程配置", user.getRegionCode())); + throw new BusinessException("找不到对应流程配置"); } ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(buildUser(user.getEmployeeCode())); + params.setUser(buildUser(user.getUserId())); params.setProcessUsers(Collections.emptyMap()); //放入条件判断的项目字段 ProjectConditionDTO conditionDto = new ProjectConditionDTO(); BeanUtils.copyProperties(projectDTO, conditionDto); - Map formData = Maps.newHashMap(); + Map formData = Maps.newHashMap(); formData.putAll( JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { }) @@ -86,16 +84,16 @@ public class DefaultDeclaredProjectManage { } //项目名称去重 - public void checkDuplication(ProjectDTO project){ + public void checkDuplication(ProjectDTO project) { VUtils.isTrue(projectService.count(Wrappers.lambdaQuery(Project.class) - .eq(Project::getProjectName,project.getProjectName()) - .eq(Project::getNewest,Boolean.TRUE) - .ne(Objects.nonNull(project.getProjectCode()),Project::getProjectCode,project.getProjectCode())) > 0) - .throwMessage(String.format("修改失败 此项目名 【%s】 已存在!",project.getProjectName())); + .eq(Project::getProjectName, project.getProjectName()) + .eq(Project::getNewest, Boolean.TRUE) + .ne(Objects.nonNull(project.getProjectCode()), Project::getProjectCode, project.getProjectCode())) > 0) + .throwMessage(String.format("修改失败 此项目名 【%s】 已存在!", project.getProjectName())); } public void checkAmount(ProjectDTO projectInfo) { - if(Objects.nonNull(projectInfo.getDeclareAmount())){ + if (Objects.nonNull(projectInfo.getDeclareAmount())) { BigDecimal declareAmount = projectInfo.getDeclareAmount(); BigDecimal govSuperFinanceAmount = projectInfo.getDeclareGovSuperiorFinanceAmount(); BigDecimal govOwnFinanceAmount = projectInfo.getDeclareGovOwnFinanceAmount(); @@ -105,16 +103,16 @@ public class DefaultDeclaredProjectManage { BigDecimal totalAmount = govSuperFinanceAmount .add(govOwnFinanceAmount).add(bankLendingAmount).add(haveAmount).add(otherAmount); VUtils.isTrue(declareAmount.compareTo(totalAmount) != 0) - .throwMessage(String.format("申报失败! 申报总金额【%s】 不等于其它申报金额 【%s】",declareAmount,totalAmount)); + .throwMessage(String.format("申报失败! 申报总金额【%s】 不等于其它申报金额 【%s】", declareAmount, totalAmount)); //判断 年度计划金额 如果开着的话 - if(Objects.nonNull(projectInfo.getAnnualPlanAmount())){ + if (Objects.nonNull(projectInfo.getAnnualPlanAmount())) { BigDecimal annualPlanAmount = projectInfo.getAnnualPlanAmount(); VUtils.isTrue(annualPlanAmount.compareTo(BigDecimal.ZERO) <= 0) - .throwMessage(String.format("申报失败! 年度支付总金额【%s】 不能小于等于0",annualPlanAmount)); + .throwMessage(String.format("申报失败! 年度支付总金额【%s】 不能小于等于0", annualPlanAmount)); VUtils.isTrue(annualPlanAmount.compareTo(declareAmount) > 0) - .throwMessage(String.format("申报失败! 年度支付总金额【%s】 不能大于申报金额 【%s】",annualPlanAmount,declareAmount)); + .throwMessage(String.format("申报失败! 年度支付总金额【%s】 不能大于申报金额 【%s】", annualPlanAmount, declareAmount)); BigDecimal annualGovSuperAmount = projectInfo.getAnnualPlanGovSuperiorFinanceAmount(); BigDecimal annualOwnSuperAmount = projectInfo.getAnnualPlanGovOwnFinanceAmount(); @@ -124,46 +122,46 @@ public class DefaultDeclaredProjectManage { BigDecimal totalAnnual = annualGovSuperAmount .add(annualOwnSuperAmount).add(annualBankLendingAmount).add(annualHaveAmount).add(anualOtherAmount); VUtils.isTrue(annualPlanAmount.compareTo(totalAnnual) != 0) - .throwMessage(String.format("申报失败! 年度支付总金额【%s】 不等于其它年度支付金额 【%s】",annualPlanAmount,totalAnnual)); + .throwMessage(String.format("申报失败! 年度支付总金额【%s】 不等于其它年度支付金额 【%s】", annualPlanAmount, totalAnnual)); } } } - public ProcessInstanceUserDto buildUser(String employeeCode){ - UserFullInfoDTO userInfoDetail = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); + public ProcessInstanceUserDto buildUser(Long userId) { + UserFullInfoDTO userInfoDetail = userInfoHelper.getUserFullInfo(userId); VUtils.isTrue(Objects.isNull(userInfoDetail)) - .throwMessage(String.format("【%s】获取不到用户!",employeeCode)); + .throwMessage(String.format("【%s】获取不到用户!", userId)); return ProcessInstanceUserDto.builder() - .userId(String.valueOf(userInfoDetail.getEmployeeCode())) + .userId(String.valueOf(userInfoDetail.getUserId())) .userName(userInfoDetail.getRealName()) - .orgCode(userInfoDetail.getEmpPosUnitCode()) - .orgName(userInfoDetail.getEmpPosUnitName()) + .orgCode(String.valueOf(userInfoDetail.getMhUnitId())) + .orgName(userInfoDetail.getMhUnitName()) .build(); } - public Map buildOrgModelMap(String employeeCode,Project project) { + public Map buildOrgModelMap(Long userId, Project project) { Map orgMap = new HashMap<>(); // 查出所有的单位流程配置 List orgModelsList = orgProcdefService.list(); - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); - if(Objects.isNull(userFullInfo)){ + UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); + if (Objects.isNull(userFullInfo)) { log.warn("取不到员工 返回空map"); return Collections.emptyMap(); } - String startOrgCode = userFullInfo.getEmpPosUnitCode(); - String startOrgName = userFullInfo.getEmpPosUnitName(); + String startOrgCode = String.valueOf(userFullInfo.getMhUnitId()); + String startOrgName = userFullInfo.getMhUnitName(); String startOrgParentCode; String startOrgParentName; // 如果申报时 上级主管单位,由该单位自己审核 - if (CommonEnum.NO.getCode().equals(project.getIsSuperOrg())){ + if (CommonEnum.NO.getCode().equals(project.getIsSuperOrg())) { startOrgParentCode = startOrgCode; startOrgParentName = startOrgName; - }else { + } else { startOrgParentCode = project.getSuperOrgCode(); startOrgParentName = project.getSuperOrg(); } @@ -175,7 +173,7 @@ public class DefaultDeclaredProjectManage { startOrgInfoDto.setOrgModelMap(orgModelsList.stream() .filter(v -> v.getOrgCode().equals(startOrgCode) && Boolean.FALSE.equals(v.getIsDelete()) - && (ProcessDefTypeEnum.SEAL.name().equals(v.getType())|| + && (ProcessDefTypeEnum.SEAL.name().equals(v.getType()) || ProcessDefTypeEnum.JOINT_REVIEW.name().equals(v.getType()) || ProcessDefTypeEnum.DEFAULT.name().equals(v.getType()))) .collect(Collectors.toMap(WflowOrgModels::getType, v -> v))); @@ -191,18 +189,18 @@ public class DefaultDeclaredProjectManage { ProcessDefTypeEnum.DEFAULT.name().equals(v.getType()))) .collect(Collectors.toMap(WflowOrgModels::getType, v -> v))); - orgMap.put(OrgTypeEnum.TARGET_OWNER.name(),startOrgInfoDto); - orgMap.put(OrgTypeEnum.TARGET_MANAGEMENT.name(),parentOrgInfoDto); + orgMap.put(OrgTypeEnum.TARGET_OWNER.name(), startOrgInfoDto); + orgMap.put(OrgTypeEnum.TARGET_MANAGEMENT.name(), parentOrgInfoDto); // 如果是指定单位,直接根据流程定义ID放入map OrgInfoDTO orgInfoDTO = new OrgInfoDTO(); orgInfoDTO.setOrgModelMap(orgModelsList.stream() .collect(Collectors.toMap(WflowOrgModels::getProcessDefId, v -> v))); - orgMap.put(OrgTypeEnum.TARGET_LABEL.name(),orgInfoDTO); + orgMap.put(OrgTypeEnum.TARGET_LABEL.name(), orgInfoDTO); //如果有上级条线主管单位 并且 不是市本级 - if(!RegionConst.RC_HZ.equals(project.getAreaCode()) && - CommonEnum.YES.getCode().equals(project.getIsHigherSuperOrg())){ + if (!RegionConst.RC_HZ.equals(project.getAreaCode()) && + CommonEnum.YES.getCode().equals(project.getIsHigherSuperOrg())) { OrgInfoDTO parentLineOrgInfoDto = new OrgInfoDTO(); parentLineOrgInfoDto.setOrganizationCode(project.getHigherSuperOrgCode()); parentLineOrgInfoDto.setOrganizationName(project.getHigherSuperOrg()); @@ -214,7 +212,7 @@ public class DefaultDeclaredProjectManage { ProcessDefTypeEnum.DEFAULT.name().equals(v.getType()))) .collect(Collectors.toMap(WflowOrgModels::getType, v -> v))); - orgMap.put(OrgTypeEnum.TARGET_LINE_MANAGEMENT.name(),parentLineOrgInfoDto); + orgMap.put(OrgTypeEnum.TARGET_LINE_MANAGEMENT.name(), parentLineOrgInfoDto); } return orgMap; } @@ -230,10 +228,10 @@ public class DefaultDeclaredProjectManage { String startOrgParentCode; String startOrgParentName; // 如果申报时 上级主管单位,由该单位自己审核 - if (CommonEnum.NO.getCode().equals(project.getIsSuperOrg())){ + if (CommonEnum.NO.getCode().equals(project.getIsSuperOrg())) { startOrgParentCode = startOrgCode; startOrgParentName = startOrgName; - }else { + } else { startOrgParentCode = project.getSuperOrgCode(); startOrgParentName = project.getSuperOrg(); } @@ -261,18 +259,18 @@ public class DefaultDeclaredProjectManage { ProcessDefTypeEnum.DEFAULT.name().equals(v.getType()))) .collect(Collectors.toMap(WflowOrgModels::getType, v -> v))); - orgMap.put(OrgTypeEnum.TARGET_OWNER.name(),startOrgInfoDto); - orgMap.put(OrgTypeEnum.TARGET_MANAGEMENT.name(),parentOrgInfoDto); + orgMap.put(OrgTypeEnum.TARGET_OWNER.name(), startOrgInfoDto); + orgMap.put(OrgTypeEnum.TARGET_MANAGEMENT.name(), parentOrgInfoDto); // 如果是指定单位,直接根据流程定义ID放入map OrgInfoDTO orgInfoDTO = new OrgInfoDTO(); orgInfoDTO.setOrgModelMap(orgModelsList.stream() .collect(Collectors.toMap(WflowOrgModels::getProcessDefId, v -> v))); - orgMap.put(OrgTypeEnum.TARGET_LABEL.name(),orgInfoDTO); + orgMap.put(OrgTypeEnum.TARGET_LABEL.name(), orgInfoDTO); //如果有上级条线主管单位 并且 不是市本级 - if(!RegionConst.RC_HZ.equals(project.getAreaCode()) && - CommonEnum.YES.getCode().equals(project.getIsHigherSuperOrg())){ + if (!RegionConst.RC_HZ.equals(project.getAreaCode()) && + CommonEnum.YES.getCode().equals(project.getIsHigherSuperOrg())) { OrgInfoDTO parentLineOrgInfoDto = new OrgInfoDTO(); parentLineOrgInfoDto.setOrganizationCode(project.getHigherSuperOrgCode()); parentLineOrgInfoDto.setOrganizationName(project.getHigherSuperOrg()); @@ -284,25 +282,26 @@ public class DefaultDeclaredProjectManage { ProcessDefTypeEnum.DEFAULT.name().equals(v.getType()))) .collect(Collectors.toMap(WflowOrgModels::getType, v -> v))); - orgMap.put(OrgTypeEnum.TARGET_LINE_MANAGEMENT.name(),parentLineOrgInfoDto); + orgMap.put(OrgTypeEnum.TARGET_LINE_MANAGEMENT.name(), parentLineOrgInfoDto); } return orgMap; } //根据提交者的单位 - public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year, UserFullInfoDTO user){ + public DeclaredProjectStatisticsPO declaredProjectOrgStatistics(Integer year, UserFullInfoDTO user) { //查此人建设单位的项目 - return statisticsService.getOrgStatistics(user.getEmpPosUnitCode(),year); + return statisticsService.getOrgStatistics(user.getMhUnitIdStr(), year); } //根据提交者的区域 他是区管或者超管 - public DeclaredProjectStatisticsPO declaredProjectRegionStatistics(Integer year, UserFullInfoDTO user){ + public DeclaredProjectStatisticsPO declaredProjectRegionStatistics(Integer year, UserFullInfoDTO user) { //查此人建设单位的项目 - return statisticsService.getRegionStatistics(user.getRegionCode(),year); + return statisticsService.getRegionStatistics(null, year); } /** * 把条件值放入工作流 用于判断条件 根据dto + * * @param params * @param dto */ @@ -319,6 +318,7 @@ public class DefaultDeclaredProjectManage { /** * 把条件值放入工作流 用于判断条件 根据d项目实体 + * * @param params * @param projectInfo */ @@ -330,19 +330,19 @@ public class DefaultDeclaredProjectManage { })); } - public void buildCondition(ProcessStartParamsVo params, Project projectInfo,DefaultDeclaredDTO dto) { + public void buildCondition(ProcessStartParamsVo params, Project projectInfo, DefaultDeclaredDTO dto) { //放入条件判断的项目字段 优先取dto的 再取项目的 ProjectDTO pdto = dto.getProjectInfo(); ProjectConditionDTO conditionDto = new ProjectConditionDTO(); conditionDto.setProjectId(projectInfo.getId()); conditionDto.setDeclareAmount(Objects.nonNull(pdto) && Objects.nonNull(pdto.getDeclareAmount()) - ?pdto.getDeclareAmount() : projectInfo.getDeclareAmount()); + ? pdto.getDeclareAmount() : projectInfo.getDeclareAmount()); conditionDto.setIsDigitalReform(Objects.nonNull(pdto) && Objects.nonNull(pdto.getIsDigitalReform()) - ?pdto.getIsDigitalReform() : projectInfo.getIsDigitalReform()); + ? pdto.getIsDigitalReform() : projectInfo.getIsDigitalReform()); conditionDto.setIsTemporaryAugment(Objects.nonNull(pdto) && Objects.nonNull(pdto.getIsTemporaryAugment()) - ?pdto.getIsTemporaryAugment() : projectInfo.getIsTemporaryAugment()); + ? pdto.getIsTemporaryAugment() : projectInfo.getIsTemporaryAugment()); conditionDto.setBizDomain(Objects.nonNull(pdto) && Objects.nonNull(pdto.getBizDomain()) - ?pdto.getBizDomain() : projectInfo.getBizDomain()); + ? pdto.getBizDomain() : projectInfo.getBizDomain()); params.setFormData(JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference>() { })); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DelayedApplyManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DelayedApplyManage.java index 1a7e573..864fe9f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DelayedApplyManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/DelayedApplyManage.java @@ -97,9 +97,9 @@ public class DelayedApplyManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); - //待终验 并且已经过期 - //只能看自己单位的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + // 待终验 并且已经过期 + // 只能看自己单位的 + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); query.eq(Project::getStatus, ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.lt(Project::getPlanAcceptanceTime, LocalDateTime.now()); @@ -167,9 +167,9 @@ public class DelayedApplyManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(param); - //待终验 - //只能看自己单位的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + // 待终验 + // 只能看自己单位的 + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); query.eq(Project::getStatus, ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getNewest, Boolean.TRUE); @@ -197,7 +197,7 @@ public class DelayedApplyManage { String fileName = "待终验申请项目列表"; ExcelDownUtil.setFileName(fileName, response); - //数据导出处理函数 + // 数据导出处理函数 try { EasyExcel.write(response.getOutputStream(), DeclaredProjectExportDTO.class) .autoCloseStream(false) @@ -218,9 +218,6 @@ public class DelayedApplyManage { */ public String delayedApply(DelayedApplyDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); - Long projectId = dto.getProjectId(); Project project = projectService.getNewProject(projectId); VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!"); @@ -246,9 +243,6 @@ public class DelayedApplyManage { @Transactional(rollbackFor = Exception.class) public String startDelayedApplyProcess(DelayedApplyDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); - Long projectId = dto.getProjectId(); Project project = projectService.getNewProject(projectId); VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!"); @@ -275,7 +269,7 @@ public class DelayedApplyManage { } ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); + params.setUser(defaultDeclaredProjectManage.buildUser(user.getUserId())); params.setProcessUsers(Collections.emptyMap()); //放入条件判断的项目字段 //把条件值给放入工作流 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java index 6d17295..bbf32d6 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java @@ -87,11 +87,10 @@ public class FinalAcceptanceManage { */ public PageVo projectLibList(ProjectListReq req) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); //待终验 并且还未过期 //只能看自己单位的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); query.eq(Project::getStatus, ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.ge(Project::getPlanAcceptanceTime, LocalDateTime.now()); @@ -132,11 +131,10 @@ public class FinalAcceptanceManage { public void exportList(HttpServletResponse response, ProjectListReq param) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(param); //待终验 //只能看自己单位的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); query.eq(Project::getStatus, ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getNewest, Boolean.TRUE); @@ -199,10 +197,6 @@ public class FinalAcceptanceManage { */ public String startProcess(DefaultDeclaredDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(Objects.isNull(user) || Objects.isNull(employeeCode)) - .throwMessage("获取登录用户失败!"); - ProjectDTO projectDto = dto.getProjectInfo(); VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); Project projectInfo = projectService.getNewProject(projectDto.getId()); @@ -228,13 +222,13 @@ public class FinalAcceptanceManage { .throwMessage("提交失败 该项目不是 待终验状态|不通过或者已立项阶段"); ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(declaredProjectManage.buildUser(employeeCode)); + params.setUser(declaredProjectManage.buildUser(user.getUserId())); params.setProcessUsers(Collections.emptyMap()); //放入条件判断的项目字段 //把条件值给放入工作流 declaredProjectManage.buildCondition(params, projectInfo); // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 - Map orgModelMap = declaredProjectManage.buildOrgModelMap(employeeCode, projectInfo); + Map orgModelMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), projectInfo); String instanceId = processInstanceService.startProcessLs(model, params, orgModelMap); log.info("终验方案项目申报成功 【{}】", instanceId); @@ -258,10 +252,6 @@ public class FinalAcceptanceManage { */ public String restartProcess(DefaultDeclaredDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(Objects.isNull(user) || Objects.isNull(employeeCode)) - .throwMessage("获取登录用户失败!"); - ProjectDTO projectDto = dto.getProjectInfo(); VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("重新提交失败 缺少项目ID!"); Project projectInfo = projectService.getNewProject(projectDto.getId()); @@ -287,13 +277,13 @@ public class FinalAcceptanceManage { .throwMessage("提交失败 该项目不是 待终验状态|不通过或者已立项阶段"); ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(declaredProjectManage.buildUser(employeeCode)); + params.setUser(declaredProjectManage.buildUser(user.getUserId())); params.setProcessUsers(Collections.emptyMap()); //放入条件判断的项目字段 //把条件值给放入工作流 declaredProjectManage.buildCondition(params, projectInfo, dto); // 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 - Map orgModelMap = declaredProjectManage.buildOrgModelMap(employeeCode, projectInfo); + Map orgModelMap = declaredProjectManage.buildOrgModelMap(user.getUserId(), projectInfo); String instanceId = processInstanceService.startProcessLs(model, params, orgModelMap); log.info("终验方案项目重新申报成功 【{}】", instanceId); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PrequalificationDeclaredProjectManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PrequalificationDeclaredProjectManage.java index a3849f6..4e2f66b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PrequalificationDeclaredProjectManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PrequalificationDeclaredProjectManage.java @@ -28,7 +28,7 @@ import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.staging.enums.MsgTypeEnum; import com.hz.pm.api.staging.service.IProjectStagingService; import com.hz.pm.api.sys.manage.NoticeManage; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.todocenter.constant.WorkNoticeConstant; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.util.LoginUserUtil; @@ -98,18 +98,15 @@ public class PrequalificationDeclaredProjectManage { @Transactional(rollbackFor = Exception.class) public String startTheProcess(DefaultDeclaredDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(Objects.isNull(employeeCode)).throwMessage("获取登录用户失败!"); - ProjectDTO projectDto = dto.getProjectInfo(); VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); Project projectInfo = projectService.getNewProject(projectDto.getId()); VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!"); //要判断 当前操作人 是不是项目主管单位的人 - VUtils.isTrue(Objects.isNull(user.getEmpPosUnitCode())) + VUtils.isTrue(Objects.isNull(user.getMhUnitId())) .throwMessage(String.format("当前登录人没有单位 【%s】", user.getRealName())); - VUtils.isTrue(!user.getEmpPosUnitCode().equals(projectInfo.getSuperOrgCode())) + VUtils.isTrue(!user.getMhUnitIdStr().equals(projectInfo.getSuperOrgCode())) .throwMessage(String.format("只有主管单位 【%s】的人 才能够提交", projectInfo.getSuperOrg())); //首先要判断 项目当前状态 是不是 待预审 @@ -130,10 +127,10 @@ public class PrequalificationDeclaredProjectManage { //入库暂存表 后续处理 对接外部接口 projectInfo.setUpdateOn(LocalDateTime.now()); //保存一下 当前的主管单位发起人 - projectInfo.setPreStartUserId(employeeCode); + projectInfo.setPreStartUserId(user.getUserIdStr()); //当前实例置为空 - projectInfo.setInstCode(TodoCenterConstant.Declared.NULL_INST_CODE); - if (projectStagingService.addByProject(projectInfo, "省级部门联审") + projectInfo.setInstCode(TodoCenterConst.Declared.NULL_INST_CODE); + if (Boolean.TRUE.equals(projectStagingService.addByProject(projectInfo, "省级部门联审")) && projectService.updateById(projectInfo)) { return "提交省级部门联审成功"; } @@ -141,7 +138,7 @@ public class PrequalificationDeclaredProjectManage { } else if (ProjectStatusEnum.PRE_APPLYING .getCode().equals(projectInfo.getStatus())) { //如果是非省级联审的项目 直接提交 预审 - instanceId = directStartProcess(projectInfo, employeeCode, dto.getRestart()); + instanceId = directStartProcess(projectInfo, user.getUserId(), dto.getRestart()); } else { throw new BusinessException("项目状态 错误 project :" + projectInfo.getId() + "," + projectInfo.getStatus()); } @@ -157,10 +154,6 @@ public class PrequalificationDeclaredProjectManage { */ @Transactional(rollbackFor = Exception.class) public String restartTheProcess(DefaultDeclaredDTO dto) { - UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(Objects.isNull(employeeCode)).throwMessage("获取登录用户失败!"); - ProjectDTO projectDto = dto.getProjectInfo(); VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); Project projectInfo = projectService.getById(projectDto.getId()); @@ -174,12 +167,12 @@ public class PrequalificationDeclaredProjectManage { } //直接提交预审方法 提取 在省级联审通过的时候 也可以用 - public String directStartProcess(Project projectInfo, String employeeCode, Boolean restart) { - VUtils.isTrue(Objects.isNull(employeeCode)) + public String directStartProcess(Project projectInfo, Long userId, Boolean restart) { + VUtils.isTrue(Objects.isNull(userId)) .throwMessage("发起人 员工code 不能为空!"); ProcessStartParamsVo params = new ProcessStartParamsVo(); - params.setUser(defaultDeclaredProjectManage.buildUser(employeeCode)); + params.setUser(defaultDeclaredProjectManage.buildUser(userId)); params.setProcessUsers(Collections.emptyMap()); //把条件值给放入工作流 @@ -198,7 +191,7 @@ public class PrequalificationDeclaredProjectManage { } // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 - Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode, projectInfo); + Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(userId, projectInfo); String instanceId = processInstanceService.startProcessLs(model, params, orgModelMap); log.info("提交预审项目成功 【{}】", instanceId); @@ -288,8 +281,8 @@ public class PrequalificationDeclaredProjectManage { if (user.getIsOrgAdmin() && (ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) || ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode().equals(item.getStatus())) - && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getEmpPosUnitCode()) - && w.getSuperOrgCode().equals(user.getEmpPosUnitCode())) { + && StringUtils.isNotBlank(w.getSuperOrgCode()) + && w.getSuperOrgCode().equals(user.getMhUnitIdStr())) { item.setCanPreDeclared(Boolean.TRUE); } return item; @@ -305,13 +298,13 @@ public class PrequalificationDeclaredProjectManage { public UserFullInfoDTO buildPermission(LambdaQueryWrapper query, UserFullInfoDTO user) { if (user.getIsOrgAdmin()) { //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 - query.and(q1 -> q1.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) + query.and(q1 -> q1.eq(Project::getBuildOrgCode, user.getMhUnitId()) .or(q2 -> q2.eq(Project::getStage, ProjectStatusEnum.NOT_APPROVED.getCode()) .and(s1 -> s1.eq(Project::getStatus, ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) .or(s2 -> s2.eq(Project::getStatus, ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS_SUCCESS.getCode()))) - .eq(Project::getSuperOrgCode, user.getEmpPosUnitCode()))); + .eq(Project::getSuperOrgCode, user.getMhUnitId()))); } else { - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); } return user; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectAdjustmentManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectAdjustmentManage.java index 2753b95..f5798ef 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectAdjustmentManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectAdjustmentManage.java @@ -152,7 +152,7 @@ public class ProjectAdjustmentManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); //放入用户的单位 - req.setBuildOrgCode(user.getEmpPosUnitCode()); + req.setBuildOrgCode(user.getMhUnitIdStr()); return projectLibManage.projectLibList(req); } @@ -167,7 +167,7 @@ public class ProjectAdjustmentManage { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); //放入用户的单位 - req.setBuildOrgCode(user.getEmpPosUnitCode()); + req.setBuildOrgCode(user.getMhUnitIdStr()); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); List records = projectService.list(query); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 26bdf16..f8dc01d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -6,11 +6,6 @@ import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.basic.util.NdDateUtils; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.statemachine.util.StateMachineUtil; import com.hz.pm.api.common.util.ExcelDownUtil; @@ -20,18 +15,22 @@ import com.hz.pm.api.projectdeclared.model.dto.PurchaseSaveDTO; import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.model.vo.PurchaseVO; import com.hz.pm.api.projectdeclared.service.IPurchaseService; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; -import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.helper.ProjectHelper; import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.projectlib.model.req.ProjectListReq; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.util.LoginUserUtil; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.basic.util.NdDateUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; @@ -74,7 +73,7 @@ public class PurchaseManage { VUtils.isTrue(Objects.isNull(user)).throwMessage("获取登录用户失败!"); LambdaQueryWrapper query = ProjectHelper.projectQuery(req); //只能看自己单位的 - query.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); //待采购状态 query.in(Project::getStatus, Lists.newArrayList(ProjectStatusEnum.TO_BE_PURCHASED.getCode(), ProjectStatusEnum.OPERATION.getCode())); @@ -114,7 +113,7 @@ public class PurchaseManage { LambdaQueryWrapper query = ProjectHelper.projectQuery(param); //待采购状态 //只能看自己单位的 - query.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); query.eq(Project::getStatus, ProjectStatusEnum.TO_BE_PURCHASED.getCode()); query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); query.eq(Project::getNewest, Boolean.TRUE); @@ -171,9 +170,6 @@ public class PurchaseManage { */ public String submitResult(PurchaseSaveDTO dto) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String employeeCode = user.getEmployeeCode(); - VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!"); - Long projectId = dto.getProjectId(); VUtils.isTrue(Objects.isNull(projectId)).throwMessage("提交失败 缺少项目ID!"); Project project = projectService.getNewProject(dto.getProjectId()); @@ -190,23 +186,12 @@ public class PurchaseManage { Purchase purchase = BeanUtil.copyProperties(w, Purchase.class); purchase.setProjectId(projectId); if (!purchaseMap.containsKey(w.getId())) { - purchase.setCreateBy(employeeCode); + purchase.setCreateBy(user.getUserIdStr()); } return purchase; }); if (purchaseService.saveOrUpdateBatch(purchaseEntities)) { - // 如果 需要推送项目和应用管理的话 只有遂昌县才有 - // String areaCode = project.getAreaCode(); - // String appCode = dto.getAppCode(); - // if(RegionConst.RC_SC.equals(areaCode) && StringUtils.isNotBlank(appCode)){ - // try{ - // - // }catch (Exception e){ - // log.info("绑定以及推送项目和应用关系 失败! {}" + e.getMessage()); - // } - // } - //进入到下一状态 stateMachineUtil.pass(project); project.setUpdateOn(LocalDateTime.now()); @@ -214,9 +199,7 @@ public class PurchaseManage { LocalDateTime lastTransactionTime = null; BigDecimal transactionAmountTotal = BigDecimal.ZERO; for (Purchase purchase : purchaseEntities) { - if (lastTransactionTime == null) { - lastTransactionTime = purchase.getTransactionTime(); - } else if (purchase.getTransactionTime().isAfter(lastTransactionTime)) { + if (lastTransactionTime == null || purchase.getTransactionTime().isAfter(lastTransactionTime)) { lastTransactionTime = purchase.getTransactionTime(); } transactionAmountTotal = transactionAmountTotal.add(purchase.getTransactionAmount()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewByDeptJointManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewByDeptJointManage.java index 6db0e29..acdd7b0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewByDeptJointManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewByDeptJointManage.java @@ -23,6 +23,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; + import java.time.LocalDateTime; import java.util.Collections; import java.util.Map; @@ -54,13 +55,14 @@ public class ReviewByDeptJointManage { /** * 部门联审 + * * @param project * @return */ @Transactional(rollbackFor = Exception.class) public Boolean startTheProcess(Project project) { //这里是任务发起的 所以用项目发起人 - String startUserCode = project.getSponsor(); + Long startUserCode = Long.parseLong(project.getSponsor()); VUtils.isTrue(Objects.isNull(project.getId())).throwMessage("提交失败 缺少项目ID!"); Project projectInfo = projectService.getNewProject(project.getId()); @@ -87,47 +89,24 @@ public class ReviewByDeptJointManage { ProcessStartParamsVo params = new ProcessStartParamsVo(); //发起人的信息 - params.setUser(declaredProjectManage.buildUser(projectInfo.getSponsor())); + params.setUser(declaredProjectManage.buildUser(Long.valueOf(projectInfo.getSponsor()))); params.setProcessUsers(Collections.emptyMap()); - - Map formData = Maps.newHashMap(); //放入条件判断的项目字段 //把条件值给放入工作流 - defaultDeclaredProjectManage.buildCondition(params,projectInfo); + defaultDeclaredProjectManage.buildCondition(params, projectInfo); // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 - Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(startUserCode,project); - String instanceId = processService.startProcessLs(model, params,orgModelMap); + Map orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(startUserCode, project); + String instanceId = processService.startProcessLs(model, params, orgModelMap); log.info("部门联审申报成功 【{}】", instanceId); //保存项目信息 - projectInfo = projectLibManage.saveProjectWithVersion(projectInfo,instanceId,ProjectProcessStageEnum.DEPARTMENT_JOINT_APPROVAL_PROCESS.getCode()); + projectInfo = projectLibManage.saveProjectWithVersion(projectInfo, instanceId, ProjectProcessStageEnum.DEPARTMENT_JOINT_APPROVAL_PROCESS.getCode()); //发送给第一个审批人消息 - noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, + noticeManage.sendFirtUser(projectInfo, model.getFormName(), instanceId, WorkNoticeConstant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); - return Boolean.TRUE; } - private Boolean modifyProject(Project project, String instanceId) { - //流程启动之后 入库项目 重要业务信息 用于列表查询 展示 - try { - project.setUpdateOn(LocalDateTime.now()); - project.setInstCode(instanceId); - projectService.updateById(project); - //保存项目和实例的关系 - ProjectInst projectInst = new ProjectInst(); - projectInst.setProjectId(project.getId()); - projectInst.setInstCode(instanceId); - projectInst.setCreatOn(LocalDateTime.now()); - projectInst.setUpdateOn(LocalDateTime.now()); - projectInst.setInstType(ProjectProcessStageEnum.DEPARTMENT_JOINT_APPROVAL_PROCESS.getCode()); - projectInstService.save(projectInst); - } catch (Exception e) { - log.error("部门联审 修改项目信息 错误 ", e); - throw new BusinessException("部门联审 修改项目信息 错误 :" + e.getMessage()); - } - return Boolean.TRUE; - } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewByProvincialDeptManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewByProvincialDeptManage.java index 9614e79..a551ce7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewByProvincialDeptManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewByProvincialDeptManage.java @@ -11,7 +11,7 @@ import com.hz.pm.api.projectlib.model.entity.ProjectApplication; import com.hz.pm.api.projectlib.service.IProjectApplicationService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.provincial.service.IJoinReviewProvincialBureauService; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.ningdatech.basic.function.VUtils; import com.ningdatech.file.service.FileService; import com.wflow.exception.BusinessException; @@ -105,7 +105,7 @@ public class ReviewByProvincialDeptManage { //保存一下 当前的主管单位发起人 p.setPreStartUserId(p.getSponsor()); //当前实例置为空 - p.setInstCode(TodoCenterConstant.Declared.NULL_INST_CODE); + p.setInstCode(TodoCenterConst.Declared.NULL_INST_CODE); declaringDTO.getProjectInfo().setId(p.getId()); projectService.updateById(p); if (!joinReviewProvincialBureauService.pushImportProject( diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewChecklistManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewChecklistManage.java index 35cdc40..7fdb5cb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewChecklistManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ReviewChecklistManage.java @@ -2,6 +2,7 @@ package com.hz.pm.api.projectdeclared.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -90,16 +91,15 @@ public class ReviewChecklistManage { Map> approveMap = approves.stream().collect(Collectors.groupingBy(ReviewChecklistApprove::getProjectCode)); - List reviewHumans; + List reviewHumans; + // TODO if (BizConst.DEV.equals(active)) { - reviewHumans = DeclaredProjectConst.ReviewChecklist.REVIEW_HUMANS_ZYD; + reviewHumans = new ArrayList<>(); } else { - reviewHumans = DeclaredProjectConst.ReviewChecklist.REVIEW_HUMANS_ZZD; + reviewHumans = new ArrayList<>(); } - List users = userInfoHelper.getUserFullInfoByEmployeeCodes(reviewHumans); - Set userSet = Sets.newHashSet(); - Map userMap = users.stream().filter(u -> userSet.add(u.getEmployeeCode())) - .collect(Collectors.toMap(UserFullInfoDTO::getEmployeeCode, UserFullInfoDTO::getUsername)); + List users = userInfoHelper.listUserFullInfoByUserIds(reviewHumans); + Map userMap = CollUtils.listToMap(users, UserFullInfoDTO::getUserId, UserFullInfoDTO::getUsername); List records = CollUtils.convert(page.getRecords(), w -> { ProjectReviewCheckListItemVO item = new ProjectReviewCheckListItemVO(); item.setId(w.getId()); @@ -128,7 +128,7 @@ public class ReviewChecklistManage { } private String computeVerify(ProjectReviewCheckListItemVO item, List reviewChecklistApproves, - Map userMap, UserInfoDetails user) { + Map userMap, UserInfoDetails user) { List reviewHumans; if (BizConst.DEV.equals(active)) { reviewHumans = DeclaredProjectConst.ReviewChecklist.REVIEW_HUMANS_ZYD; @@ -161,38 +161,18 @@ public class ReviewChecklistManage { return finishNums + StrPool.SLASH + maxNums; } - private String convertUser(Map userMap, Set computeHumanSet) { + private String convertUser(Map userMap, Set computeHumanSet) { if (CollUtil.isEmpty(userMap) || CollUtil.isEmpty(computeHumanSet)) { return StringUtils.EMPTY; } - return computeHumanSet.stream().filter(s -> StringUtils.isNotBlank(s) && userMap.containsKey(s)) - .map(userMap::get).collect(Collectors.joining(StrPool.COMMA)); + return computeHumanSet.stream() + .filter(NumberUtil::isNumber) + .map(w -> userMap.get(Long.parseLong(w))) + .collect(Collectors.joining(StrPool.COMMA)); } public UserFullInfoDTO buildReviewCheckPermission(LambdaQueryWrapper query, UserInfoDetails user) { UserFullInfoDTO userDto = BeanUtil.copyProperties(user, UserFullInfoDTO.class); - //1.只有 市本级能看到 - String regionCode = user.getRegionCode(); - String employeeCode = user.getEmployeeCode(); - //如果是七大审查之一 就可以看 - List reviewHumans; - if (BizConst.DEV.equals(active)) { - reviewHumans = DeclaredProjectConst.ReviewChecklist.REVIEW_HUMANS_ZYD; - } else { - reviewHumans = DeclaredProjectConst.ReviewChecklist.REVIEW_HUMANS_ZZD; - } - if (reviewHumans.contains(employeeCode)) { - log.warn("为七大审查人之一 可以查看"); - return userDto; - } - - if (!regionCode.equals(RegionConst.RC_HZ) || StringUtils.isBlank(employeeCode)) { - log.info("当前操作人 不是市本级 或者没有钉钉工号 :{},{},{}", user.getUsername(), - user.getRegionCode(), user.getEmployeeCode()); - query.eq(Project::getId, 0L); - return userDto; - } - Optional currentUserDataScope = DataScopeUtil.getCurrentUserDataScope(userDto); if (!currentUserDataScope.isPresent()) { log.warn("没有取到权限信息 当前查询 没有权限条件"); @@ -228,8 +208,8 @@ public class ReviewChecklistManage { /** * 去审批 * - * @param dtos - * @return + * @param dtos \ + * @return \ */ public String approve(List dtos) { if (CollUtil.isEmpty(dtos)) { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/mapper/DeclaredStatisticsMapper.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/mapper/DeclaredStatisticsMapper.java index 597892f..f4c7705 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/mapper/DeclaredStatisticsMapper.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/mapper/DeclaredStatisticsMapper.java @@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param; /** *

- * Mapper 接口 + * Mapper 接口 *

* * @author zpf @@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Param; */ public interface DeclaredStatisticsMapper extends BaseMapper { - DeclaredProjectStatisticsPO getOrgStatistics(@Param("orgCode") String orgCode,@Param("year") Integer year); + DeclaredProjectStatisticsPO getOrgStatistics(@Param("orgCode") String orgCode, @Param("year") Integer year); - DeclaredProjectStatisticsPO getRegionStatistics(@Param("regionCode") String regionCode,@Param("year") Integer year); + DeclaredProjectStatisticsPO getRegionStatistics(@Param("year") Integer year); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/mapper/DeclaredStatisticsMapper.xml b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/mapper/DeclaredStatisticsMapper.xml index 41d0e3b..f7eb0f7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/mapper/DeclaredStatisticsMapper.xml +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/mapper/DeclaredStatisticsMapper.xml @@ -33,6 +33,6 @@ sum(p.approval_amount) approvalAmount FROM nd_project p - WHERE area_code = #{regionCode} and project_year = #{year} and newest = 1 + WHERE project_year = #{year} and newest = 1 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/impl/DeclaredStatisticsServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/impl/DeclaredStatisticsServiceImpl.java index bda7334..0a389b1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/impl/DeclaredStatisticsServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/impl/DeclaredStatisticsServiceImpl.java @@ -8,7 +8,7 @@ import org.springframework.stereotype.Service; /** *

- * 服务实现类 + * 服务实现类 *

* * @author zpf @@ -22,21 +22,23 @@ public class DeclaredStatisticsServiceImpl implements IDeclaredStatisticsService /** * 根据userId 去查询 申报项目统计 根据单位 + * * @param orgCode * @return */ @Override - public DeclaredProjectStatisticsPO getOrgStatistics(String orgCode,Integer year) { - return declaredStatisticsMapper.getOrgStatistics(orgCode,year); + public DeclaredProjectStatisticsPO getOrgStatistics(String orgCode, Integer year) { + return declaredStatisticsMapper.getOrgStatistics(orgCode, year); } /** * 根据userId 去查询 申报项目统计 根据区域 + * * @param regionCode * @return */ @Override - public DeclaredProjectStatisticsPO getRegionStatistics(String regionCode,Integer year) { - return declaredStatisticsMapper.getRegionStatistics(regionCode,year); + public DeclaredProjectStatisticsPO getRegionStatistics(String regionCode, Integer year) { + return declaredStatisticsMapper.getRegionStatistics(year); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectRenewalFundDeclarationController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectRenewalFundDeclarationController.java index a2351f7..960044f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectRenewalFundDeclarationController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectRenewalFundDeclarationController.java @@ -49,7 +49,7 @@ public class ProjectRenewalFundDeclarationController { @ApiOperation("项目续建资金库能关联的项目列表") public PageVo projectlist(ProjectRenewalListReq req) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - return projectRenewalFundManage.projectlist(req,user); + return projectRenewalFundManage.projectList(req,user); } @GetMapping("/{id}") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AbstractProcessBusinessHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AbstractProcessBusinessHandle.java index 97c0c3e..30c17b8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AbstractProcessBusinessHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/AbstractProcessBusinessHandle.java @@ -15,7 +15,9 @@ public abstract class AbstractProcessBusinessHandle { /** * 构造,子类必须实现 */ - public AbstractProcessBusinessHandle(){} + protected AbstractProcessBusinessHandle(){ + + } /** * 抽象的,所有具体处理者应该实现的处理逻辑 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ConstructionPlanReviewHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ConstructionPlanReviewHandle.java index d663d62..b136c5b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ConstructionPlanReviewHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ConstructionPlanReviewHandle.java @@ -11,7 +11,7 @@ import com.hz.pm.api.projectlib.model.entity.ProjectInst; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.projectlib.utils.ProjectVersionUtil; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.todocenter.utils.BuildUserUtils; import com.ningdatech.basic.util.NdDateUtils; import com.wflow.workflow.bean.process.ProgressNode; @@ -63,7 +63,7 @@ public class ConstructionPlanReviewHandle extends AbstractProcessBusinessHandle ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, allVersionProjectIds) .eq(ProjectInst::getInstType, InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode()) - .ne(ProjectInst::getInstCode, TodoCenterConstant.Declared.NULL_INST_CODE) + .ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE) .orderByDesc(ProjectInst::getCreatOn) .last(BizConst.LIMIT_1)); ProcessProgressVo instanceDetail = null; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/DeptUnitedReviewHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/DeptUnitedReviewHandle.java index 16bbb0d..01fd70d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/DeptUnitedReviewHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/DeptUnitedReviewHandle.java @@ -9,7 +9,7 @@ import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.model.entity.ProjectInst; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.todocenter.utils.BuildUserUtils; import com.ningdatech.basic.util.NdDateUtils; import com.wflow.workflow.bean.process.ProgressNode; @@ -64,7 +64,7 @@ public class DeptUnitedReviewHandle extends AbstractProcessBusinessHandle { ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, allVersionProjectIds) .eq(ProjectInst::getInstType, InstTypeEnum.DEPT_UNITED_REVIEW.getCode()) - .ne(ProjectInst::getInstCode, TodoCenterConstant.Declared.NULL_INST_CODE) + .ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE) .orderByDesc(ProjectInst::getCreatOn) .last(BizConst.LIMIT_1)); if (Objects.isNull(projectInst)) { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/PreliminaryPreviewHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/PreliminaryPreviewHandle.java index 98edfc0..b68ce96 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/PreliminaryPreviewHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/PreliminaryPreviewHandle.java @@ -12,7 +12,7 @@ import com.hz.pm.api.projectlib.model.entity.ProjectInst; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.projectlib.utils.ProjectVersionUtil; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.todocenter.utils.BuildUserUtils; import com.wflow.workflow.bean.process.ProgressNode; import com.wflow.workflow.bean.vo.ProcessDetailVO; @@ -67,7 +67,7 @@ public class PreliminaryPreviewHandle extends AbstractProcessBusinessHandle { ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, allVersionProjectIds) .eq(ProjectInst::getInstType, InstTypeEnum.PRELIMINARY_PREVIEW.getCode()) - .ne(ProjectInst::getInstCode, TodoCenterConstant.Declared.NULL_INST_CODE) + .ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE) .orderByDesc(ProjectInst::getCreatOn) .last("limit 1")); ProcessProgressVo instanceDetail = null; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectFinalInspectionHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectFinalInspectionHandle.java index 4a53a4c..b69521b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectFinalInspectionHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProjectFinalInspectionHandle.java @@ -13,7 +13,7 @@ import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectInst; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.todocenter.utils.BuildUserUtils; import com.wflow.workflow.bean.process.ProgressNode; import com.wflow.workflow.bean.vo.ProcessDetailVO; @@ -61,7 +61,7 @@ public class ProjectFinalInspectionHandle extends AbstractProcessBusinessHandle ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, allVersionProjectIds) .eq(ProjectInst::getInstType, InstTypeEnum.PROJECT_FINAL_INSPECTION.getCode()) - .ne(ProjectInst::getInstCode, TodoCenterConstant.Declared.NULL_INST_CODE) + .ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE) .orderByDesc(ProjectInst::getCreatOn) .last(BizConst.LIMIT_1)); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProvinceUnitedReviewHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProvinceUnitedReviewHandle.java index d72e9f8..801f9c1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProvinceUnitedReviewHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/ProvinceUnitedReviewHandle.java @@ -92,7 +92,6 @@ public class ProvinceUnitedReviewHandle extends AbstractProcessBusinessHandle { processSchedule.add(processDetailVO); return; } -// processDetailVO.setProcessProgressVo(project.getSjlsResult()); processDetailVO.setContent(project.getSjlsResult()); processDetailVO.setProcessName(CommonConst.PROVINCE_UNITED_REVIEW); processSchedule.add(processDetailVO); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/UnitInnerAuditHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/UnitInnerAuditHandle.java index 266a648..73c4cbc 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/UnitInnerAuditHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/handle/UnitInnerAuditHandle.java @@ -11,7 +11,7 @@ import com.hz.pm.api.projectlib.model.entity.ProjectInst; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.projectlib.utils.ProjectVersionUtil; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.todocenter.utils.BuildUserUtils; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.util.NdDateUtils; @@ -66,7 +66,7 @@ public class UnitInnerAuditHandle extends AbstractProcessBusinessHandle { ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, allVersionProjectIds) .eq(ProjectInst::getInstType, InstTypeEnum.UNIT_INNER_AUDIT.getCode()) - .ne(ProjectInst::getInstCode, TodoCenterConstant.Declared.NULL_INST_CODE) + .ne(ProjectInst::getInstCode, TodoCenterConst.Declared.NULL_INST_CODE) .orderByDesc(ProjectInst::getCreatOn) .last(BizConst.LIMIT_1)); ProcessProgressVo instanceDetail = null; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java index 1dbba65..0937703 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AnnualPlanLibManage.java @@ -10,6 +10,7 @@ import cn.hutool.poi.excel.ExcelUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.hz.pm.api.common.model.constant.CommonConst; @@ -38,7 +39,7 @@ import com.hz.pm.api.projectlib.model.vo.AnnualPlanListItemVO; import com.hz.pm.api.projectlib.service.IProjectApplicationService; import com.hz.pm.api.projectlib.service.IProjectRenewalFundDeclarationService; import com.hz.pm.api.projectlib.service.IProjectService; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.util.LoginUserUtil; import com.ningdatech.basic.exception.BizException; @@ -171,7 +172,7 @@ public class AnnualPlanLibManage { // 项目编号不变,版本号加1 project.setProjectCode(oldProject.getProjectCode()); project.setVersion(oldProject.getVersion() + 1); - project.setInstCode(TodoCenterConstant.Declared.NULL_INST_CODE); + project.setInstCode(TodoCenterConst.Declared.NULL_INST_CODE); project.setId(null); if (projectService.save(project)) { applicationService.saveApplication(project, oldProject, Boolean.TRUE); @@ -251,19 +252,15 @@ public class AnnualPlanLibManage { switch (currentUserDataScope.get().getRole()) { case NORMAL_MEMBER: // 普通用户 只能看到自己单位去申报的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); break; case COMPANY_MANAGER: // 单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); break; case SUPER_ADMIN: // 超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 break; - case REGION_MANAGER: - // 区域管理员 看到自己区域的项目 - query.eq(Project::getAreaCode, user.getRegionCode()); - break; default: // 没有权限的话 就让它查不到 query.eq(Project::getId, "NULL"); @@ -367,16 +364,16 @@ public class AnnualPlanLibManage { public void exportModifyList(ProjectListReq param, HttpServletResponse response) { int year = LocalDateTime.now().getYear(); Integer isTemporaryAugment = param.getIsTemporaryAugment(); - if (Objects.isNull(isTemporaryAugment)) { - throw new BizException("请传入是否临时增补标志!"); - } + Assert.notNull(isTemporaryAugment, "请传入是否临时增补标志"); param.setIsTemporaryAugment(isTemporaryAugment); - String fileName = null; + String fileName; // 设置excel的文件名称和是否增补 if (CommonEnum.NO.getCode().equals(isTemporaryAugment)) { - fileName = "丽水市" + year + "年数字化项目年度计划库编辑表"; + fileName = "杭州市" + year + "年数字化项目年度计划库编辑表"; } else if (CommonEnum.YES.getCode().equals(isTemporaryAugment)) { - fileName = "丽水市" + year + "年数字化项目年度计划增补库编辑表"; + fileName = "杭州市" + year + "年数字化项目年度计划增补库编辑表"; + } else { + throw BizException.wrap("是否临时增补标志无效"); } LambdaQueryWrapper query = ProjectHelper.projectQuery(param); query.eq(Project::getNewest, Boolean.TRUE); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ApplicationManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ApplicationManage.java index 367a935..fc81cfc 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ApplicationManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ApplicationManage.java @@ -68,6 +68,7 @@ public class ApplicationManage { /** * 保存 appCode + * * @param dto * @return */ @@ -79,7 +80,7 @@ public class ApplicationManage { app.setAppCode(dto.getAppCode()); app.setUpdateOn(LocalDateTime.now()); app.setUpdateBy(userId); - if(applicationService.updateById(app)){ + if (applicationService.updateById(app)) { return BizConst.SAVE_SUCCESS; } return BizConst.SAVE_FAIL; @@ -87,6 +88,7 @@ public class ApplicationManage { /** * 获取试运行报告 + * * @param appCode * @return */ @@ -98,33 +100,33 @@ public class ApplicationManage { //请求头 HttpHeaders headers = new HttpHeaders(); - for(Map.Entry entry : header.entrySet()){ + for (Map.Entry entry : header.entrySet()) { headers.add(entry.getKey(), entry.getValue()); } //封装请求头 HttpEntity> formEntity = new HttpEntity<>(headers); RestTemplate restTemplate = new RestTemplate(); - ResponseEntity forEntity = restTemplate.exchange(appUrl, HttpMethod.GET,formEntity, ApiResponse.class); + ResponseEntity forEntity = restTemplate.exchange(appUrl, HttpMethod.GET, formEntity, ApiResponse.class); - log.info("forEntity:",JSON.toJSONString(forEntity)); - log.info("body:",forEntity.getBody()); + log.info("forEntity:", JSON.toJSONString(forEntity)); + log.info("body:", forEntity.getBody()); ApiResponse body = forEntity.getBody(); - if(!body.getCode().equals(HttpStatus.OK.value())){ + if (!body.getCode().equals(HttpStatus.OK.value())) { throw new BizException(body.getMessage()); } Object data = body.getData(); - if(Objects.nonNull(data)){ + if (Objects.nonNull(data)) { JSONObject dataJson = JSON.parseObject(JSON.toJSONString(data)); JSONArray resourceList = dataJson.getJSONArray("resourceList"); - if(CollUtil.isNotEmpty(resourceList)){ + if (CollUtil.isNotEmpty(resourceList)) { JSONObject resource = JSON.parseObject(JSON.toJSONString(resourceList.get(0))); - if(StringUtils.isBlank(resource.getString("reportOss"))){ + if (StringUtils.isBlank(resource.getString("reportOss"))) { //暂时没有 appCode 所以先返回测试数据 return "https://irs-yyyw.oss-cn-hangzhou-zwynet-d01-a.internet.cloud.zj.gov.cn/tmp/%E6%B8%A9%E5%B7%9E%E5%B8%82%E4%B9%90%E6%B8%85%E5%B8%82%E5%8C%BA%E5%9F%9F%E4%BD%93%E6%A3%80%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F_9cf0b901f2ca4fbf8ff274da359ad219.html?Expires=1687833685&OSSAccessKeyId=wMhEw2BhpIDc1xwO&Signature=UPAbMdDy23FI1sNemszg5WH%2BG40%3D"; - }else{ + } else { return resource.getString("reportOss"); } } @@ -134,19 +136,19 @@ public class ApplicationManage { /** * 查询 待注册的 + * * @param req * @return */ public PageVo toRegisterAppProjectLibList(ProjectListReq req) { UserInfoDetails user = LoginUserUtil.loginUserDetail(); //建设单位 就是当前人的单位 - String orgCode = user.getEmpPosUnitCode(); Page page = req.page(); - projectService.page(page,Wrappers.lambdaQuery(Project.class) + projectService.page(page, Wrappers.lambdaQuery(Project.class) .eq(Project::getStage, ProjectStatusEnum.NOT_APPROVED.getCode()) .eq(Project::getStatus, ProjectStatusEnum.TO_BE_APP_REGISTER.getCode()) - .eq(Project::getBuildOrgCode,orgCode)); - if(CollUtil.isEmpty(page.getRecords())){ + .eq(Project::getBuildOrgCode, user.getMhUnitId())); + if (CollUtil.isEmpty(page.getRecords())) { return PageVo.empty(); } @@ -154,24 +156,24 @@ public class ApplicationManage { //要去查询应用 此阶段 必定是 建设方案后的 所以直接查 建设方案的应用 List apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .in(ProjectApplication::getProjectCode, projectCodes) - .eq(ProjectApplication::getIsConstruct,Boolean.TRUE)); + .eq(ProjectApplication::getIsConstruct, Boolean.TRUE)); Map> appMap = apps.stream().collect(Collectors.groupingBy(ProjectApplication::getProjectCode)); List res = page.getRecords().stream().map(p -> { - ProjectDetailVO vo = BeanUtil.copyProperties(p,ProjectDetailVO.class); - if(appMap.containsKey(p.getProjectCode())){ + ProjectDetailVO vo = BeanUtil.copyProperties(p, ProjectDetailVO.class); + if (appMap.containsKey(p.getProjectCode())) { List projectApplications = appMap.get(p.getProjectCode()); vo.setProjectApplications(convert(projectApplications)); } return vo; }).collect(Collectors.toList()); - return PageVo.of(res,page.getTotal()); + return PageVo.of(res, page.getTotal()); } private List convert(List projectApplications) { - if(CollUtil.isNotEmpty(projectApplications)){ + if (CollUtil.isNotEmpty(projectApplications)) { return projectApplications.stream() - .map(a -> BeanUtil.copyProperties(a,ProjectApplicationVO.class)) + .map(a -> BeanUtil.copyProperties(a, ProjectApplicationVO.class)) .collect(Collectors.toList()); } return Collections.emptyList(); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java index a0a1be6..ea0fed2 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java @@ -3,6 +3,7 @@ package com.hz.pm.api.projectlib.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -10,20 +11,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.file.entity.File; -import com.ningdatech.file.service.FileService; import com.hz.pm.api.common.compare.CompareUtils; -import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.model.constant.CommonConst; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum; import com.hz.pm.api.common.helper.RegionCacheHelper; 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.CommonConst; import com.hz.pm.api.common.model.entity.ExcelExportWriter; import com.hz.pm.api.common.statemachine.util.StateMachineUtil; import com.hz.pm.api.common.util.BizUtils; @@ -38,7 +32,6 @@ import com.hz.pm.api.filemanage.model.entity.ProjectApplyBorrow; import com.hz.pm.api.filemanage.service.INdProjectApplyBorrowService; import com.hz.pm.api.gov.model.vo.GovBizProjectDetailVO; import com.hz.pm.api.gov.utils.ProjectConvertUtil; -import com.hz.pm.api.organization.model.entity.DingOrganization; import com.hz.pm.api.organization.service.IDingOrganizationService; import com.hz.pm.api.performance.model.dto.ProjectCoreBusinessDTO; import com.hz.pm.api.performance.model.entity.ProjectCoreBusinessIndicators; @@ -53,14 +46,14 @@ import com.hz.pm.api.projectdeclared.model.entity.*; import com.hz.pm.api.projectdeclared.model.vo.*; import com.hz.pm.api.projectdeclared.service.*; import com.hz.pm.api.projectdeclared.utils.GenerateProjectCodeUtil; -import com.hz.pm.api.projectlib.model.constant.ProjectConstant; -import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; -import com.hz.pm.api.projectlib.model.enumeration.ProjectRenewalApprovalStatusEnum; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.handle.ProcessExecuteChainHandle; import com.hz.pm.api.projectlib.helper.ProjectHelper; +import com.hz.pm.api.projectlib.model.constant.ProjectConstant; import com.hz.pm.api.projectlib.model.dto.ProjectDTO; import com.hz.pm.api.projectlib.model.entity.*; +import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectRenewalApprovalStatusEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.po.ProjectPO; import com.hz.pm.api.projectlib.model.req.ProjectApplicationListReq; import com.hz.pm.api.projectlib.model.req.ProjectListReq; @@ -81,6 +74,11 @@ import com.hz.pm.api.todocenter.service.ITodoService; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.file.entity.File; +import com.ningdatech.file.service.FileService; import com.wflow.exception.BusinessException; import com.wflow.workflow.bean.vo.ProcessDetailVO; import lombok.RequiredArgsConstructor; @@ -264,8 +262,8 @@ public class ProjectLibManage { item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); if (finalUser.getIsOrgAdmin() && ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) - && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(finalUser.getEmpPosUnitCode()) - && w.getSuperOrgCode().equals(finalUser.getEmpPosUnitCode())) { + && StringUtils.isNotBlank(w.getSuperOrgCode()) + && w.getSuperOrgCode().equals(finalUser.getMhUnitIdStr())) { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); @@ -312,7 +310,7 @@ public class ProjectLibManage { .asc() .list(); Map> map = Maps.newHashMap(); - Map userMap = Maps.newHashMap(); + Map userMap = Maps.newHashMap(); if (CollUtil.isNotEmpty(tasks)) { map = tasks.stream() .collect(Collectors.groupingBy(Task::getProcessInstanceId)); @@ -341,8 +339,8 @@ public class ProjectLibManage { item.setApproveUsers(buildApproveUsers(w.getInstCode(), map, userMap)); if (finalUser.getIsOrgAdmin() && ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) - && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(finalUser.getEmpPosUnitCode()) - && w.getSuperOrgCode().equals(finalUser.getEmpPosUnitCode())) { + && StringUtils.isNotBlank(w.getSuperOrgCode()) + && w.getSuperOrgCode().equals(finalUser.getMhUnitIdStr())) { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); @@ -354,27 +352,23 @@ public class ProjectLibManage { } private List buildApproveUsers(String instCode, Map> map, - Map userMap) { + Map userMap) { if (map.containsKey(instCode)) { List tasks = map.get(instCode); - return tasks.stream().map(task -> userMap.get(task.getAssignee())) + return tasks.stream().map(task -> userMap.get(Long.parseLong(task.getAssignee()))) .filter(Objects::nonNull).collect(Collectors.toList()); } return Collections.emptyList(); } - private Map searchUser(List tasks, UserInfoHelper userInfoHelper) { + private Map searchUser(List tasks, UserInfoHelper userInfoHelper) { if (CollUtil.isEmpty(tasks)) { return Collections.emptyMap(); } - List users = userInfoHelper.getUserFullInfoByEmployeeCodes( - tasks.stream().map(Task::getAssignee).collect(Collectors.toSet())); - if (CollUtil.isNotEmpty(users)) { - Set employeeSet = Sets.newHashSet(); - return users.stream().filter(u -> employeeSet.add(u.getEmployeeCode())).collect(Collectors - .toMap(UserFullInfoDTO::getEmployeeCode, u -> u)); - } - return Collections.emptyMap(); + List users = userInfoHelper.listUserFullInfoByUserIds( + tasks.stream().map(w -> Long.parseLong(w.getAssignee())) + .collect(Collectors.toSet())); + return users.stream().collect(Collectors.toMap(UserFullInfoDTO::getUserId, u -> u)); } /** @@ -444,8 +438,8 @@ public class ProjectLibManage { item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); if (user.getIsOrgAdmin() && ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) - && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getEmpPosUnitCode()) - && w.getSuperOrgCode().equals(user.getEmpPosUnitCode())) { + && StringUtils.isNotBlank(w.getSuperOrgCode()) + && w.getSuperOrgCode().equals(user.getMhUnitIdStr())) { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); @@ -525,8 +519,8 @@ public class ProjectLibManage { item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); if (user.getIsOrgAdmin() && ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) - && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getEmpPosUnitCode()) - && w.getSuperOrgCode().equals(user.getEmpPosUnitCode())) { + && StringUtils.isNotBlank(w.getSuperOrgCode()) + && w.getSuperOrgCode().equals(user.getMhUnitIdStr())) { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); @@ -564,7 +558,7 @@ public class ProjectLibManage { .asc() .list(); Map> map = Maps.newHashMap(); - Map userMap = Maps.newHashMap(); + Map userMap = Maps.newHashMap(); if (CollUtil.isNotEmpty(tasks)) { map = tasks.stream() .collect(Collectors.groupingBy(Task::getProcessInstanceId)); @@ -593,8 +587,8 @@ public class ProjectLibManage { item.setApproveUsers(buildApproveUsers(w.getInstCode(), map, userMap)); if (user.getIsOrgAdmin() && ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) - && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(user.getEmpPosUnitCode()) - && w.getSuperOrgCode().equals(user.getEmpPosUnitCode())) { + && StringUtils.isNotBlank(w.getSuperOrgCode()) + && w.getSuperOrgCode().equals(user.getMhUserId())) { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); @@ -841,12 +835,11 @@ public class ProjectLibManage { * * @param projectDto * @param instanceId - * @param employeeCode * @return */ public Project saveProjectInDeclared(ProjectDTO projectDto, String instanceId, - String employeeCode) { - Project project = saveProjectNewVersion(projectDto, instanceId, employeeCode, Boolean.FALSE); + Long userId) { + Project project = saveProjectNewVersion(projectDto, instanceId, userId, Boolean.FALSE); //保存项目和实例的关系 ProjectInst projectInst = new ProjectInst(); projectInst.setProjectId(project.getId()); @@ -862,16 +855,16 @@ public class ProjectLibManage { /** * 建设方案申报项目时 保存项目信息和其它相关联的信息 * - * @param projectDto - * @param instanceId - * @param employeeCode - * @param oldProject - * @return + * @param projectDto \ + * @param instanceId \ + * @param userId \ + * @param oldProject \ + * @return \ */ public Project saveConstructProjectInDeclared(ProjectDTO projectDto, String instanceId, - String employeeCode, Project oldProject) { + Long userId, Project oldProject) { - Project project = saveConstructProjectNewVersion(projectDto, instanceId, employeeCode, oldProject); + Project project = saveConstructProjectNewVersion(projectDto, instanceId, userId, oldProject); // 将旧的项目状态、阶段置为null,防止项目还会出现在待申报列表 LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(Project.class); updateWrapper.set(Project::getStage, null) @@ -894,11 +887,10 @@ public class ProjectLibManage { * * @param projectDto * @param instanceId - * @param employeeCode * @return */ public Project saveProjectNewVersion(ProjectDTO projectDto, String instanceId, - String employeeCode, Boolean isContruct) { + Long userId, Boolean isContruct) { //流程启动之后 入库项目 重要业务信息 用于列表查询 展示 try { Project project = new Project(); @@ -910,7 +902,7 @@ public class ProjectLibManage { project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); project.setStatus(ProjectStatusEnum.UNDER_INTERNAL_AUDIT.getCode()); project.setInstCode(instanceId); - project.setSponsor(employeeCode); + project.setSponsor(String.valueOf(userId)); String projectCode = generateProjectCodeUtil.generateProjectCode(projectDto); project.setProjectCode(projectCode); if (projectService.save(project)) { @@ -921,7 +913,7 @@ public class ProjectLibManage { project = newProjectWithVersion(projectDto, isContruct); if (Objects.nonNull(project)) { project.setInstCode(instanceId); - project.setSponsor(employeeCode); + project.setSponsor(String.valueOf(userId)); projectService.updateById(project); } } @@ -935,14 +927,14 @@ public class ProjectLibManage { /** * 建设方案申报项目时 保存项目信息和其它相关联的信息 * - * @param projectDto - * @param instanceId - * @param employeeCode - * @param oldProject - * @return + * @param projectDto \ + * @param instanceId \ + * @param userId \ + * @param oldProject \ + * @return \ */ public Project saveConstructProjectNewVersion(ProjectDTO projectDto, String instanceId, - String employeeCode, Project oldProject) { + Long userId, Project oldProject) { //流程启动之后 入库项目 重要业务信息 用于列表查询 展示 try { Project project = new Project(); @@ -956,7 +948,7 @@ public class ProjectLibManage { project.setStage(ProjectStatusEnum.NOT_APPROVED.getCode()); project.setStatus(ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode()); project.setInstCode(instanceId); - project.setSponsor(employeeCode); + project.setSponsor(String.valueOf(userId)); // 项目编号不变,版本号加1 project.setProjectCode(oldProject.getProjectCode()); project.setVersion(oldProject.getVersion() + 1); @@ -981,7 +973,7 @@ public class ProjectLibManage { project = newProjectWithVersion(projectDto, Boolean.TRUE); if (Objects.nonNull(project)) { project.setInstCode(instanceId); - project.setSponsor(employeeCode); + project.setSponsor(String.valueOf(userId)); projectService.updateById(project); } } @@ -1038,14 +1030,13 @@ public class ProjectLibManage { return project; } - public Project saveProjectWithVersionAndStatus(ProjectDTO projecDto, Integer stageCode, Integer statusCode, Boolean isConstruct) { - Project oldProject = projectService.getById(projecDto.getId()); + public Project saveProjectWithVersionAndStatus(ProjectDTO projectDto, Integer stageCode, Integer statusCode, Boolean isConstruct) { + Project oldProject = projectService.getById(projectDto.getId()); Project project = new Project(); - VUtils.isTrue(Objects.isNull(oldProject)) - .throwMessage("项目不存在!"); + Assert.notNull(oldProject, "项目不存在"); BeanUtil.copyProperties(oldProject, project, CopyOptions.create() .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); - BeanUtil.copyProperties(projecDto, project, CopyOptions.create() + BeanUtil.copyProperties(projectDto, project, CopyOptions.create() .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); project.setVersion(oldProject.getVersion() + 1); project.setId(null); @@ -1065,20 +1056,20 @@ public class ProjectLibManage { if (projectService.save(project)) { projectService.reverseNewest(project.getProjectCode(), project.getId()); - saveApplication(projecDto, project, isConstruct); + saveApplication(projectDto, project, isConstruct); } return project; } - public Project saveProjectWithVersion(ProjectDTO projecDto, String instanceId, Integer instType, Boolean isConstruct) { - Project oldProject = projectService.getById(projecDto.getId()); + public Project saveProjectWithVersion(ProjectDTO projectDto, String instanceId, Integer instType, Boolean isConstruct) { + Project oldProject = projectService.getById(projectDto.getId()); Project project = new Project(); VUtils.isTrue(Objects.isNull(oldProject)) .throwMessage("项目不存在!"); BeanUtil.copyProperties(oldProject, project, CopyOptions.create() .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); - BeanUtil.copyProperties(projecDto, project, CopyOptions.create() + BeanUtil.copyProperties(projectDto, project, CopyOptions.create() .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); project.setVersion(oldProject.getVersion() + 1); project.setId(null); @@ -1099,7 +1090,7 @@ public class ProjectLibManage { projectService.reverseNewest(project.getProjectCode(), project.getId()); //app - saveApplication(projecDto, project, isConstruct); + saveApplication(projectDto, project, isConstruct); } return project; @@ -1107,8 +1098,7 @@ public class ProjectLibManage { public Project saveProjectWithVersion(Project oldProject, String instanceId, Integer instType) { Project project = new Project(); - VUtils.isTrue(Objects.isNull(oldProject)) - .throwMessage("项目不存在!"); + Assert.notNull(oldProject, "项目不存在"); BeanUtil.copyProperties(oldProject, project, CopyOptions.create() .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); project.setVersion(oldProject.getVersion() + 1); @@ -1250,27 +1240,12 @@ public class ProjectLibManage { // 从申请借阅信息表中查出本单位及下属单位审批通过的项目 LambdaQueryWrapper query = Wrappers.lambdaQuery(ProjectApplyBorrow.class) .select(ProjectApplyBorrow::getProjectId) - .in(ProjectApplyBorrow::getApplyBorrowEmpPosUnitCode, subOrgSet) + .in(ProjectApplyBorrow::getApplyBorrowOrgCode, subOrgSet) .eq(ProjectApplyBorrow::getIsSuccess, Boolean.TRUE); List applyBorrowProjectIdList = CollUtils.fieldList(projectApplyBorrowService.list(query), ProjectApplyBorrow::getProjectId); return applyBorrowProjectIdList.contains(project.getId()); } - private Set getSubOrgList(String empPosUnitCode) { - Set orgSet = new HashSet<>(); - // 先将自己加入子集 - orgSet.add(empPosUnitCode); - Set subOrgList = dingOrganizationService - .list(Wrappers.lambdaQuery(DingOrganization.class).eq(DingOrganization::getParentCode, empPosUnitCode)) - .stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toSet()); - // 遍历子集 - for (String orgCode : subOrgList) { - orgSet.addAll(getSubOrgList(orgCode)); - } - return orgSet; - } - - public void exportList(ProjectListReq param, HttpServletResponse response) { param.setPageNumber(CommonConst.EXPORT_PAGE_NUMBER); param.setPageSize(CommonConst.EXPORT_PAGE_SIZE); @@ -1313,28 +1288,18 @@ public class ProjectLibManage { switch (currentUserDataScope.get().getRole()) { case NORMAL_MEMBER: //普通用户 只能看到自己单位去申报的 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); break; case COMPANY_MANAGER: //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 - query.and(q1 -> q1.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()).or(q2 -> + query.and(q1 -> q1.eq(Project::getBuildOrgCode, user.getMhUnitId()).or(q2 -> q2.eq(Project::getStage, ProjectStatusEnum.NOT_APPROVED.getCode()) .eq(Project::getStatus, ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) - .eq(Project::getSuperOrgCode, user.getEmpPosUnitCode()))); + .eq(Project::getSuperOrgCode, user.getMhUnitId()))); break; case SUPER_ADMIN: //超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 break; - case REGION_MANAGER: - //区域管理员 看到自己区域的项目 如果是市本级 就看全市的 - if (RegionConst.RC_HZ.equals(user.getRegionCode())) { - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(user.getRegionCode(), - RegionConst.RL_CITY); - query.in(Project::getAreaCode, regionCodes); - } else { - query.eq(Project::getAreaCode, user.getRegionCode()); - } - break; case VISITOR: //访客可以看全市的 break; @@ -1359,27 +1324,16 @@ public class ProjectLibManage { case NORMAL_MEMBER: //普通用户 只能看到自己单位去申报的 req.setUserType("normal"); - req.setUserValue(user.getEmpPosUnitCode()); + req.setUserValue(user.getMhUnitIdStr()); break; case COMPANY_MANAGER: //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 req.setUserType("org"); - req.setUserValue(user.getEmpPosUnitCode()); + req.setUserValue(user.getMhUnitIdStr()); break; case SUPER_ADMIN: //超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 break; - case REGION_MANAGER: - //区域管理员 看到自己区域的项目 如果是市本级 就看全市的 - if (RegionConst.RC_HZ.equals(user.getRegionCode())) { - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(user.getRegionCode(), - RegionConst.RL_CITY); - req.setRegionCodes(regionCodes); - } else { - req.setUserRegionCode(user.getRegionCode()); - } - req.setUserType("region"); - break; case VISITOR: //访客可以看全市的 break; @@ -1434,8 +1388,8 @@ public class ProjectLibManage { // 保存项目借阅信息 ProjectApplyBorrow projectApplyBorrow = new ProjectApplyBorrow(); projectApplyBorrow.setProjectId(project.getId()); - projectApplyBorrow.setApplyBorrowEmployeeCode(user.getEmployeeCode()); - projectApplyBorrow.setApplyBorrowEmpPosUnitCode(user.getEmpPosUnitCode()); + projectApplyBorrow.setApplyBorrowUserId(user.getUserIdStr()); + projectApplyBorrow.setApplyBorrowOrgCode(user.getMhUnitIdStr()); projectApplyBorrow.setInstanceId(instanceId); projectApplyBorrow.setCreateOn(LocalDateTime.now()); projectApplyBorrow.setCreateBy(LoginUserUtil.getUserId()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java index 51e4f6d..e4b4e0a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectRenewalFundManage.java @@ -114,12 +114,12 @@ public class ProjectRenewalFundManage { return PageVo.of(records, total); } - public PageVo projectlist(ProjectRenewalListReq req, UserFullInfoDTO user) { + public PageVo projectList(ProjectRenewalListReq req, UserFullInfoDTO user) { LambdaQueryWrapper query = ProjectRenewFundHelper.projectQuery(req); //项目查最新 query.eq(Project::getNewest, Boolean.TRUE); //自己单位 - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); //立项批复后 都可以 query.gt(Project::getStatus, ProjectStatusEnum.APPROVED_AFTER_CHOICE.getCode()); Page page = projectService.page(req.page(), query); @@ -162,8 +162,8 @@ public class ProjectRenewalFundManage { item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); if (finalUser.getIsOrgAdmin() && ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) - && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(finalUser.getEmpPosUnitCode()) - && w.getSuperOrgCode().equals(finalUser.getEmpPosUnitCode())) { + && StringUtils.isNotBlank(w.getSuperOrgCode()) + && w.getSuperOrgCode().equals(finalUser.getMhUnitIdStr())) { item.setCanPreDeclared(Boolean.TRUE); } item.setApprovedAmount(w.getApprovalAmount()); @@ -601,25 +601,15 @@ public class ProjectRenewalFundManage { case NORMAL_MEMBER: //普通用户 只能看到自己单位去申报的 req.setUserType("normal"); - req.setUserValue(user.getEmpPosUnitCode()); + req.setUserValue(user.getMhUnitIdStr()); break; case COMPANY_MANAGER: case SUPER_ADMIN: + case REGION_MANAGER: //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 //超级管理员 也只能看本单位的 req.setUserType("org"); - req.setUserValue(user.getEmpPosUnitCode()); - break; - case REGION_MANAGER: - //区域管理员 看到自己区域的项目 如果是市本级 就看全市的 - if (RegionConst.RC_HZ.equals(user.getRegionCode())) { - Collection regionCodes = regionCacheHelper.listChildRegionCodeList(user.getRegionCode(), - RegionConst.RL_CITY); - req.setRegionCodes(regionCodes); - } else { - req.setUserRegionCode(user.getRegionCode()); - } - req.setUserType("region"); + req.setUserValue(user.getMhUnitIdStr()); break; case VISITOR: //访客可以看全市的 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/AnalysisEventMonitor.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/AnalysisEventMonitor.java deleted file mode 100644 index d4cd959..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/AnalysisEventMonitor.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.hz.pm.api.projectlib.model.entity; - -import com.alibaba.excel.context.AnalysisContext; -import com.alibaba.excel.event.AnalysisEventListener; -import com.ningdatech.basic.exception.BizException; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.*; - -/** - * @author CMM - * @since 2023/04/17 18:26 - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class AnalysisEventMonitor extends AnalysisEventListener> { - - private final List records = new ArrayList<>(); - - /** - * 存储Key - */ - Map key = new HashMap<>(); - /** - * keyList - */ - List keyList = new ArrayList<>(); - - @Override - public void onException(Exception exception, AnalysisContext context) throws Exception { - super.onException(exception, context); - throw BizException.wrap("导入年度计划解析失败"); - } - - @Override - public void invokeHeadMap(Map headMap, AnalysisContext context) { - Set integerSet = headMap.keySet(); - for (Integer integer : integerSet) { - keyList.add(headMap.get(integer)); - } - key.putAll(headMap); - } - - @Override - public void invoke(Map integerStringMap, AnalysisContext context) { - //Project project = new Project(); - //project.setId(data.getProjectId()); - //project.setProjectName(data.getProjectName()); - //project.setProjectIntroduction(data.getProjectIntroduction()); - //// 建设依据忽略 - //project.setIsFirst(CommonConst.NEW_CONSTRUCTION.equals(data.getIsFirst()) ? 1 : 0); - //String[] dataArr = data.getBuildCycle().split(CommonConst.ZHI); - //project.setBeginTime(dataArr[0].trim()); - //project.setEndTime(dataArr[1].trim()); - //project.setDeclareAmount(data.getDeclaredAmount()); - //project.setAnnualPlanAmount(data.getAnnualPlanAmount()); - //project.setDeclareHaveAmount(data.getDeclareHaveAmount()); - //project.setDeclareGovOwnFinanceAmount(data.getDeclareGovOwnFinanceAmount()); - //project.setDeclareGovSuperiorFinanceAmount(data.getDeclareGovSuperiorFinanceAmount()); - //project.setDeclareBankLendingAmount(data.getDeclareBankLendingAmount()); - //project.setDeclareOtherAmount(data.getDeclareOtherAmount()); - //project.setEngineeringSpeedOne(data.getFirstQuarter()); - //project.setEngineeringSpeedTwo(data.getSecondQuarter()); - //project.setEngineeringSpeedThree(data.getThirdQuarter()); - //project.setEngineeringSpeedFour(data.getFourthQuarter()); - //project.setBuildOrgName(data.getBuildUnitName()); - //project.setContactName(data.getContactName()); - //project.setResponsibleMan(data.getResponsibleMan()); - //project.setProjectRemarks(data.getProjectRemarks()); - //records.add(project); - } - - @Override - public void doAfterAllAnalysed(AnalysisContext context) { - //if (records.isEmpty()) { - // throw BizException.wrap("导入年度计划为空"); - //} - //List projectIds = CollUtils.fieldList(records, Project::getId); - //long count = projectService.count(Wrappers.lambdaQuery(Project.class) - // .in(Project::getId, projectIds)); - //if (count != records.size()) { - // throw BizException.wrap("请确保所有项目都存在"); - //} - //projectService.updateBatchById(records); - } -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectInst.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectInst.java index 7537377..2e7e20f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectInst.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectInst.java @@ -19,7 +19,7 @@ import lombok.Data; */ @TableName("nd_project_inst") @Data -@ApiModel(value = "NdProjectInst对象", description = "") +@ApiModel(value = "NdProjectInst对象") public class ProjectInst implements Serializable { private static final long serialVersionUID = 1L; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/po/ProjectPO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/po/ProjectPO.java index 0beb067..572339b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/po/ProjectPO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/po/ProjectPO.java @@ -19,7 +19,7 @@ import java.time.LocalDateTime; * @since 2023-09-26 */ @Data -@ApiModel(value = "NdProject对象", description = "") +@ApiModel(value = "NdProject对象") public class ProjectPO implements Serializable { private static final long serialVersionUID = 1L; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectLibListItemVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectLibListItemVO.java index bd01ced..654f9a3 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectLibListItemVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectLibListItemVO.java @@ -3,13 +3,9 @@ package com.hz.pm.api.projectlib.model.vo; import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonFormat; import com.hz.pm.api.common.compare.Compare; -import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.portrait.model.vo.TagVO; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.hz.pm.api.user.security.model.UserFullInfoDTO; -import com.hz.pm.api.user.security.model.UserInfoDetails; -import com.hz.pm.api.user.util.LoginUserUtil; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Builder; @@ -167,17 +163,5 @@ public class ProjectLibListItemVO { @ApiModelProperty("年度投资金额总额") private BigDecimal annualAccumulateAmount; private List annualAccumulateAmountList; - public Boolean getNeedUploadSuperLineFile() { - UserInfoDetails userInfoDetail = LoginUserUtil.loginUserDetail(); - //要满足条件 1.当前登录人是市本级单位 2.有上级条线单位 3.项目状态是待预审 - if (Objects.nonNull(userInfoDetail) && userInfoDetail.getIsMunicipalOrg() - && Objects.nonNull(this.isHigherSuperOrg) - && ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(this.status) - && CommonEnum.YES.getCode().equals(this.isHigherSuperOrg)) { - this.needUploadSuperLineFile = Boolean.TRUE; - return this.needUploadSuperLineFile; - } - this.needUploadSuperLineFile = null; - return this.needUploadSuperLineFile; - } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectRenewalFundDeclarationVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectRenewalFundDeclarationVO.java index c58c619..38b33e5 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectRenewalFundDeclarationVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectRenewalFundDeclarationVO.java @@ -6,7 +6,6 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.apache.commons.lang3.StringUtils; -import java.io.Serializable; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -22,7 +21,7 @@ import java.util.Objects; */ @ApiModel(value = "NdProjectRenewalFundDeclarationVO", description = "续建项目资金申请表") @Data -public class ProjectRenewalFundDeclarationVO implements Serializable { +public class ProjectRenewalFundDeclarationVO { private static final long serialVersionUID = 1L; @@ -97,8 +96,8 @@ public class ProjectRenewalFundDeclarationVO implements Serializable { @ApiModelProperty("年度投资金额详情") private List annualAccumulateAmountList; - public String getProjectTypeName(){ - if(Objects.nonNull(this.projectType)){ + public String getProjectTypeName() { + if (Objects.nonNull(this.projectType)) { return ProjectTypeNewEnum.getDesc(this.projectType); } return StringUtils.EMPTY; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/provincial/controller/TestController.java b/hz-pm-api/src/main/java/com/hz/pm/api/provincial/controller/TestController.java index e93b011..78645e4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/provincial/controller/TestController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/provincial/controller/TestController.java @@ -6,6 +6,7 @@ import com.hz.pm.api.provincial.model.res.SjApiResponse; import com.hz.pm.api.provincial.service.IJoinReviewProvincialBureauService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -25,15 +26,13 @@ import java.io.InputStream; */ @Slf4j @RestController +@RequiredArgsConstructor @RequestMapping("/api/v1/test") @Api(tags = "测试省局接口") public class TestController { - @Autowired - private IJoinReviewProvincialBureauService joinReviewProvincialBureauService; - - @Autowired - private ReviewByProvincialDeptManage provincialDeptManage; + private final IJoinReviewProvincialBureauService joinReviewProvincialBureauService; + private final ReviewByProvincialDeptManage provincialDeptManage; @GetMapping("/push") @ApiOperation("测试推送") @@ -52,9 +51,6 @@ public class TestController { @GetMapping("/path") @ApiOperation("测试获取详情") public String path() throws IOException { -// String template = ResourceUtil.getResource("template").getPath(); -// return template; - InputStream in = this.getClass().getResourceAsStream("/template/simsun.ttc"); StringBuilder sb = new StringBuilder(); int n; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/provincial/model/res/ProvincialProjectRes.java b/hz-pm-api/src/main/java/com/hz/pm/api/provincial/model/res/ProvincialProjectRes.java index d341502..600dcfe 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/provincial/model/res/ProvincialProjectRes.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/provincial/model/res/ProvincialProjectRes.java @@ -7,7 +7,6 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import java.io.Serializable; import java.math.BigDecimal; import java.util.List; @@ -21,8 +20,8 @@ import java.util.List; @Builder @AllArgsConstructor @NoArgsConstructor -@ApiModel(value = "ProvincialProjectDTO", description = "") -public class ProvincialProjectRes implements Serializable { +@ApiModel(value = "ProvincialProjectDTO") +public class ProvincialProjectRes { @ApiModelProperty("项目审核结果 1审核中 2审核通过 3审核不通过") private Integer projectStatus; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/provincial/model/res/SjApiResponse.java b/hz-pm-api/src/main/java/com/hz/pm/api/provincial/model/res/SjApiResponse.java index 5c3ea1c..414d1c4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/provincial/model/res/SjApiResponse.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/provincial/model/res/SjApiResponse.java @@ -65,7 +65,7 @@ public class SjApiResponse implements Serializable { * @return ApiResponse */ public static SjApiResponse of(Integer code, String msg, T data) { - return new SjApiResponse(code, msg, data); + return new SjApiResponse<>(code, msg, data); } /** diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/safety/manage/SafetyRiskManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/safety/manage/SafetyRiskManage.java index 2004695..b475e83 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/safety/manage/SafetyRiskManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/safety/manage/SafetyRiskManage.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.model.constant.BizConst; @@ -87,20 +88,12 @@ public class SafetyRiskManage { */ private void checkAuth(LambdaQueryWrapper query, UserInfoDetails user) { //如果是超管 - if (user.getSuperAdmin()) { + if (user.getSuperAdmin() || user.getRegionAdmin()) { log.info(user.getUsername() + " 是超管,可以看所有项目"); - } else if (user.getRegionAdmin()) { - //如果是区域管理员 - log.info(user.getUsername() + " 是区管,可以看本区域" + user.getRegionCode() + "项目"); - if (!RegionConst.RC_HZ.equals(user.getRegionCode())) { - //不是丽水市本级的话 就只看 自己区域的 - query.eq(Project::getAreaCode, user.getRegionCode()); - } - //如果是市本级 就能看所有的 } else if (user.getIsOrgAdmin()) { //单位管理员 - log.info(user.getUsername() + " 是单位管理员,可以看单位 " + user.getEmpPosUnitName() + " 项目"); - query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); + log.info(user.getUsername() + " 是单位管理员,可以看单位 " + user.getMhUnitId() + " 项目"); + query.eq(Project::getBuildOrgCode, user.getMhUnitId()); } else { //其它角色全都看不见 query.eq(Project::getId, 0L); @@ -186,7 +179,7 @@ public class SafetyRiskManage { .eq(Project::getProjectCode, projectCode) .last(BizConst.LIMIT_1)); - VUtils.isTrue(Objects.isNull(project)).throwMessage("此项目并不存在!"); + Assert.notNull(project, "此项目并不存在!"); SupplierSafetyQualification entity = BeanUtil.copyProperties(dto, SupplierSafetyQualification.class); entity.setCreateBy(user.getUsername()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/CcTaskListener.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/CcTaskListener.java index 2f1a36f..2f21cbd 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/CcTaskListener.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/CcTaskListener.java @@ -111,7 +111,7 @@ public class CcTaskListener { Long projectId = projectInst.getProjectId(); Project project = projectService.getNewProject(projectId); - UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(task.getUserId()); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(Long.valueOf(task.getUserId())); //发送消息 noticeManage.sendNotice(task.getUserId(), Objects.nonNull(user) ? user.getUserId() : 93L, project, instance.getProcessDefinitionName(), diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/EarlyWarningListener.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/EarlyWarningListener.java index e2064c6..5258b16 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/EarlyWarningListener.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/EarlyWarningListener.java @@ -23,6 +23,7 @@ import org.flowable.engine.history.HistoricProcessInstance; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; + import java.time.ZoneId; import java.util.List; import java.util.Objects; @@ -106,11 +107,11 @@ public class EarlyWarningListener { //项目 预警信息 projectEarlyWarningService.earlyWarning(project, - WarningRuleTypeEnum.PROCESS_WARNING.getCode(),noticeType); + WarningRuleTypeEnum.PROCESS_WARNING.getCode(), noticeType); - if(StringUtils.isBlank(noticeMethod) || + if (StringUtils.isBlank(noticeMethod) || (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && - !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ + !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) { log.info("通知方式为空或者错误!"); return; } @@ -118,15 +119,15 @@ public class EarlyWarningListener { //这一批员工要通知的员工号 String batchEmployees = hais.stream().map(HistoricActivityInstance::getAssignee) .collect(Collectors.joining(StrPool.COMMA)); - for(HistoricActivityInstance hai : hais){ + for (HistoricActivityInstance hai : hais) { String employeeCode = hai.getAssignee(); String taskId = hai.getTaskId(); - String path = "toDoCenter/handleDuringExamine?instanceId=" + + String path = "toDoCenter/handleDuringExamine?instanceId=" + instanceId + "&projectId=" + projectId + "&nodeId=" + nodeId + "&taskId=" + taskId; - earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,timeout,overTimeout, pi.getInstType(), + earlyWarningManage.doEarlyWarning(noticeMethod, noticeContent, timeout, overTimeout, pi.getInstType(), hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() - ,employeeCode,project,WarningRuleTypeEnum.PROCESS_WARNING.getCode(),noticeType, - path,batchEmployees,nodeId); + , Long.valueOf(employeeCode), project, WarningRuleTypeEnum.PROCESS_WARNING.getCode(), noticeType, + path, batchEmployees, nodeId); } } } \ No newline at end of file diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/ProcessEndListener.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/ProcessEndListener.java index 757b9a2..08ee29f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/ProcessEndListener.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/ProcessEndListener.java @@ -39,6 +39,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; + import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -92,7 +93,7 @@ public class ProcessEndListener { try { Thread.sleep(3000); } catch (InterruptedException e) { - throw new RuntimeException(e); + throw new BizException(e); } //1.去查找 项目实例关系表 @@ -116,26 +117,22 @@ public class ProcessEndListener { //已经没有任务了 if (CollUtil.isEmpty(tasks) && CollUtil.isEmpty(historyTasks)) { - List historyTasksFinished = historyService.createHistoricTaskInstanceQuery() - .processInstanceId(instCode) - .finished() - .list(); - Long projectId = projectInst.getProjectId(); Project project = projectService.getNewProject(projectId); HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(instCode).singleResult(); //通过审核后 所处理的逻辑 - afterPassTodo(project,instance); + afterPassTodo(project, instance); } } /** * 审核通过后 所处理的逻辑 - * @param declaredProject - * @param instance + * + * @param declaredProject \ + * @param instance \ */ - public void afterPassTodo(Project declaredProject, HistoricProcessInstance instance){ + public void afterPassTodo(Project declaredProject, HistoricProcessInstance instance) { Long userId = 110L; // 获取流程通过后的流程实例 HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery() @@ -148,7 +145,7 @@ public class ProcessEndListener { .last(BizConst.LIMIT_1)); Integer instType = projectInst.getInstType(); InstTypeEnum instTypeEnum = InstTypeEnum.getByCode(instType); - if (Objects.isNull(instTypeEnum)){ + if (Objects.isNull(instTypeEnum)) { throw new BizException("当前审批流类型不存在,流程类型code:" + instType); } @@ -184,20 +181,20 @@ public class ProcessEndListener { // 并向流程发起人发送浙政钉工作通知:【项目名称】已通过【流程名称】,请及时开始下一步操作。 if (HisProInsEndActId.END.equals(newInstance.getEndActivityId())) { // 如果是申请延期和申请借阅审批流程,不走状态机 - if (InstTypeEnum.APPLY_DELAY.getCode().equals(instType) || InstTypeEnum.APPLY_BORROW.getCode().equals(instType)){ + if (InstTypeEnum.APPLY_DELAY.getCode().equals(instType) || InstTypeEnum.APPLY_BORROW.getCode().equals(instType)) { switch (instTypeEnum) { case APPLY_DELAY: // 保存延期申请记录,更新项目建设周期和计划验收时间 - handlerManage.updateProjectDelayApplyInfo(declaredProject,instanceId); + handlerManage.updateProjectDelayApplyInfo(declaredProject, instanceId); break; case APPLY_BORROW: // 更新申请借阅状态为成功 - handlerManage.updateProjectApplyBorrowInfo(declaredProject,instanceId); + handlerManage.updateProjectApplyBorrowInfo(declaredProject, instanceId); break; default: throw new BizException("传入实例类型错误: " + instTypeEnum); } - }else { + } else { switch (Objects.requireNonNull(ProjectStatusEnum.match(declaredProject.getStatus()))) { // 当前项目状态是预审中 case PRE_APPLYING: @@ -219,7 +216,7 @@ public class ProcessEndListener { .list(Wrappers.lambdaQuery(ProjectApplication.class) .eq(ProjectApplication::getProjectId, declaredProject.getId())); joinReviewProvincialBureauService.pushImportProject( - ApplicationConverter.convertProject(declaredProject, applications, fileService,active)); + ApplicationConverter.convertProject(declaredProject, applications, fileService, active)); handlerManage.updatePassProjectStatus(userId, declaredProject); break; } catch (Exception e) { @@ -238,7 +235,7 @@ public class ProcessEndListener { } } //发送消息 - noticeManage.sendNotice(instance.getStartUserId(),userId,declaredProject,instance.getProcessDefinitionName(), + noticeManage.sendNotice(instance.getStartUserId(), userId, declaredProject, instance.getProcessDefinitionName(), PASS_MSG_TEMPLATE2, MsgTypeEnum.PROJECT_REVIEW_PASS); } else { // 若有下一个审核人(当前节点的用户),会签/或签会有多个 @@ -249,8 +246,8 @@ public class ProcessEndListener { throw new BizException("审核人信息不存在!"); } //发送消息 - noticeManage.sendNotice(currentEmployeeCode,userId,declaredProject,instance.getProcessDefinitionName(), - PASS_MSG_TEMPLATE,MsgTypeEnum.PROJECT_REVIEW); + noticeManage.sendNotice(currentEmployeeCode, userId, declaredProject, instance.getProcessDefinitionName(), + PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); } } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CockpitStatsStatisticsTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CockpitStatsStatisticsTask.java index 573fb32..fa5909c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CockpitStatsStatisticsTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CockpitStatsStatisticsTask.java @@ -2,14 +2,15 @@ package com.hz.pm.api.scheduler.task; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.StopWatch; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; +import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.model.constant.RegionConst; -import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.statemachine.contant.RegionContant; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.dashboard.constant.DashboardConstant; @@ -27,10 +28,10 @@ import com.hz.pm.api.meta.model.entity.ExpertTag; import com.hz.pm.api.meta.service.IExpertTagService; import com.hz.pm.api.performance.model.entity.PerformanceAppraisalProject; import com.hz.pm.api.performance.service.IPerformanceAppraisalProjectService; -import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectInst; +import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; +import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.sys.model.dto.RegionDTO; @@ -44,6 +45,7 @@ import org.flowable.engine.history.HistoricActivityInstance; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; + import java.math.BigDecimal; import java.net.InetAddress; import java.net.UnknownHostException; @@ -85,22 +87,20 @@ public class CockpitStatsStatisticsTask { private final IExpertIntentionWorkRegionService expertIntentionWorkRegionService; private final IExpertTagService expertTagService; - private List years = Lists.newArrayList(2021,2022,2023,2024,2025); - + private List years = Lists.newArrayList(2021, 2022, 2023, 2024, 2025); /** * 定义统计 驾驶舱数据 每天3点开始执行一次 - * */ @Scheduled(cron = "0 0 3 * * ?") public void doTask() throws UnknownHostException { if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { log.info("定时器没开启或者host不对! {}:{}", - HOST,InetAddress.getLocalHost().getHostName()); + HOST, InetAddress.getLocalHost().getHostName()); return; } - if(BizConst.PRE.equals(active)){ + if (BizConst.PRE.equals(active)) { log.info("预发环境不用同步!"); return; } @@ -114,24 +114,24 @@ public class CockpitStatsStatisticsTask { //1.根据2个维度来统计 区域和分年 //1.总的 res.add(statisticsData(DashboardConstant.CockpitStats.TOTAL, - DashboardConstant.CockpitStats.TOTAL,DashboardConstant.CockpitStats.NONE_YEAR)); - for(Integer year : years){ + DashboardConstant.CockpitStats.TOTAL, DashboardConstant.CockpitStats.NONE_YEAR)); + for (Integer year : years) { res.add(statisticsData(DashboardConstant.CockpitStats.TOTAL, - DashboardConstant.CockpitStats.TOTAL,year)); + DashboardConstant.CockpitStats.TOTAL, year)); } List regions = regionCacheHelper.listChildren(RegionConst.RC_HZ, RegionConst.RL_CITY); regions = regions.stream().filter(r -> r.getRegionLevel() != RegionConst.RL_CITY).collect(Collectors.toList()); - for(RegionDTO regionDto : regions){ - res.add(statisticsData(regionDto.getRegionCode(),regionDto.getRegionName(), + for (RegionDTO regionDto : regions) { + res.add(statisticsData(regionDto.getRegionCode(), regionDto.getRegionName(), DashboardConstant.CockpitStats.NONE_YEAR)); - for(Integer year : years){ - res.add(statisticsData(regionDto.getRegionCode(),regionDto.getRegionName(),year)); + for (Integer year : years) { + res.add(statisticsData(regionDto.getRegionCode(), regionDto.getRegionName(), year)); } } //如果结果不为空 就删除之前的 插入最新的数据 - if(CollUtil.isNotEmpty(res)){ + if (CollUtil.isNotEmpty(res)) { //计算增长率 computeRates(res); List list = cockpitStatsService.list(); @@ -141,25 +141,25 @@ public class CockpitStatsStatisticsTask { } stopWatch.stop(); - log.info("驾驶舱数据统计任务结束====={}s",stopWatch.getTotalTimeSeconds()); + log.info("驾驶舱数据统计任务结束====={}s", stopWatch.getTotalTimeSeconds()); } private void computeRates(List res) { Map map = res.stream().collect(Collectors.toMap(r -> r.getRegionCode() + r.getYear(), r -> r)); - for(CockpitStats cockpitStats : res){ - if(Objects.isNull(cockpitStats.getYear())){ + for (CockpitStats cockpitStats : res) { + if (Objects.isNull(cockpitStats.getYear())) { continue; } //算增长率 //去年的数据 用于算 增长比例 - if(cockpitStats.getYear().equals(DashboardConstant.CockpitStats.NONE_YEAR)){ - Integer thisYear = LocalDateTime.now().getYear(); + if (cockpitStats.getYear().equals(DashboardConstant.CockpitStats.NONE_YEAR)) { + int thisYear = LocalDateTime.now().getYear(); CockpitStats thisYearData = map.get(cockpitStats.getRegionCode() + thisYear); CockpitStats lastYearData = map.get(cockpitStats.getRegionCode() + (thisYear - 1)); - buildMonitorRise(cockpitStats,thisYearData,lastYearData); - }else{ + buildMonitorRise(cockpitStats, thisYearData, lastYearData); + } else { CockpitStats lastYearData = map.get(cockpitStats.getRegionCode() + (cockpitStats.getYear() - 1)); - buildMonitorRise(cockpitStats,cockpitStats,lastYearData); + buildMonitorRise(cockpitStats, cockpitStats, lastYearData); } } @@ -167,6 +167,7 @@ public class CockpitStatsStatisticsTask { /** * 统计的具体逻辑 + * * @param regionCode * @param regionName * @param year @@ -179,38 +180,38 @@ public class CockpitStatsStatisticsTask { cockpitStats.setYear(year); //申报项目 + boolean condition = Objects.nonNull(year) && !year.equals(DashboardConstant.CockpitStats.NONE_YEAR); + boolean condition1 = Objects.isNull(year) || year.equals(DashboardConstant.CockpitStats.NONE_YEAR); List projects = projectService.list(Wrappers.lambdaQuery(Project.class) .eq(Project::getNewest, Boolean.TRUE) .eq(StringUtils.isNotBlank(regionCode) && !DashboardConstant.CockpitStats.TOTAL.equals(regionCode), Project::getAreaCode, regionCode) - .eq(Objects.nonNull(year) && !year.equals(DashboardConstant.CockpitStats.NONE_YEAR), - Project::getProjectYear, year) - .in(Objects.isNull(year) || year.equals(DashboardConstant.CockpitStats.NONE_YEAR), - Project::getProjectYear, years)); + .eq(condition, Project::getProjectYear, year) + .in(condition1, Project::getProjectYear, years)); //项目归集 List applieYears = applyService.list(Wrappers.lambdaQuery(GovBizProjectApply.class) - .eq(Objects.nonNull(year) && !year.equals(DashboardConstant.CockpitStats.NONE_YEAR), + .eq(condition, GovBizProjectApply::getBaseProjSetYear, year) - .in(Objects.isNull(year) || year.equals(DashboardConstant.CockpitStats.NONE_YEAR), + .in(condition1, GovBizProjectApply::getBaseProjSetYear, years)); List yearProjIds = applieYears.stream().map(GovBizProjectApply::getBaseProjId) .collect(Collectors.toList()); List baseInfos = Lists.newArrayList(); - if(CollUtil.isNotEmpty(yearProjIds)){ + if (CollUtil.isNotEmpty(yearProjIds)) { baseInfos = baseinfoService.list(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) .eq(GovBizProjectBaseinfo::getDeleted, Boolean.FALSE) .eq(StringUtils.isNotBlank(regionCode) && !DashboardConstant.CockpitStats.TOTAL.equals(regionCode), GovBizProjectBaseinfo::getBaseAreaCode, regionCode + RegionContant.MORE_CODE) - .in(GovBizProjectBaseinfo::getBaseProjId,yearProjIds)); + .in(GovBizProjectBaseinfo::getBaseProjId, yearProjIds)); } List approves = Lists.newArrayList(); List applies = Lists.newArrayList(); List procures = Lists.newArrayList(); List cimplements = Lists.newArrayList(); - if(CollUtil.isNotEmpty(baseInfos)){ + if (CollUtil.isNotEmpty(baseInfos)) { List baseProjIds = baseInfos.stream().map(GovBizProjectBaseinfo::getBaseProjId).collect(Collectors.toList()); approves = approveService.list(Wrappers.lambdaQuery(GovBizProjectApprove.class) .in(GovBizProjectApprove::getBaseProjId, baseProjIds)); @@ -227,35 +228,35 @@ public class CockpitStatsStatisticsTask { //1.项目监测 //1.1 超期在建项目 - Integer overdueConstructionProjectsNum = projects.stream().filter(p -> { - if(Objects.nonNull(p.getPlanAcceptanceTime()) && + Integer overdueConstructionProjectsNum = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getPlanAcceptanceTime()) && p.getPlanAcceptanceTime().compareTo(LocalDateTime.now()) < 0 && - Objects.nonNull(p.getStatus()) && p.getStatus().compareTo(ProjectStatusEnum.ACCEPTED.getCode()) < 0){ + Objects.nonNull(p.getStatus()) && p.getStatus().compareTo(ProjectStatusEnum.ACCEPTED.getCode()) < 0) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setMonitorOverdueConstructionProjectsNum(overdueConstructionProjectsNum); //1.2 环节滞后项目 cockpitStats.setMonitorLaggingProjectsNum(computeLagging(projects)); //1.3预审驳回项目 - Integer preFailed = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && - p.getStatus().equals(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode())){ + Integer preFailed = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && + p.getStatus().equals(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setMonitorRejectedPreReviewProjectsNum(preFailed); //1.4 建设方案评审失败 - Integer constructionFailed = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && p.getStatus().equals(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode())){ + Integer constructionFailed = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && p.getStatus().equals(ProjectStatusEnum.SCHEME_REVIEW_FAILED.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setMonitorRejectedApproveProjectsNum(constructionFailed); //1.5 验收不达标 cockpitStats.setMonitorAcceptConditionsNotStandardsNum(0); @@ -265,16 +266,16 @@ public class CockpitStatsStatisticsTask { cockpitStats.setMonitorDeclaredAmount(BigDecimal.valueOf(totalDeclaredAmount)); //1.7 总安全投入 double totalSafetyAmount = projects.stream().mapToDouble(p -> { - if(Objects.nonNull(p.getSafetyInputDescribe())){ + if (Objects.nonNull(p.getSafetyInputDescribe())) { final Double[] total = {0.0}; - try{ + try { JSONArray array = JSON.parseArray(p.getSafetyInputDescribe()); array.forEach(j -> { JSONObject json = JSON.parseObject(JSON.toJSONString(j)); Double safetyInputAmount = json.getDouble(DashboardConstant.Protrait.FEILD_SAFETYMONEY); total[0] += safetyInputAmount; }); - }catch (Exception e){ + } catch (Exception e) { } return total[0]; @@ -292,10 +293,10 @@ public class CockpitStatsStatisticsTask { Integer guijiSecerecyGrade4 = 0; Integer guijiSecerecyGrade5 = 0; //项目归集 评审信息 - for (GovBizProjectApprove approve : approves){ + for (GovBizProjectApprove approve : approves) { String equalProtectionLevel = approve.getEqualProtectionLevel(); - if(StringUtils.isNotBlank(equalProtectionLevel)){ - switch (equalProtectionLevel){ + if (StringUtils.isNotBlank(equalProtectionLevel)) { + switch (equalProtectionLevel) { case "01": guijiSecerecyGrade1++; break; @@ -318,13 +319,13 @@ public class CockpitStatsStatisticsTask { } Integer passwordGradeNumGov = 0; - for (GovBizProjectCimplement cimplement : cimplements){ - if(StringUtils.isNotBlank(cimplement.getBaseInforLevelFile())){ - passwordGradeNumGov ++; + for (GovBizProjectCimplement cimplement : cimplements) { + if (StringUtils.isNotBlank(cimplement.getBaseInforLevelFile())) { + passwordGradeNumGov++; } } - if(Objects.nonNull(secrecyPasswordGradePo)){ + if (Objects.nonNull(secrecyPasswordGradePo)) { cockpitStats.setMonitorSecrecyGrade1Num(secrecyPasswordGradePo.getMonitorSecrecyGrade1Num() + guijiSecerecyGrade1); cockpitStats.setMonitorSecrecyGrade2Num(secrecyPasswordGradePo.getMonitorSecrecyGrade2Num() + guijiSecerecyGrade2); cockpitStats.setMonitorSecrecyGrade3Num(secrecyPasswordGradePo.getMonitorSecrecyGrade3Num() + guijiSecerecyGrade3); @@ -335,7 +336,7 @@ public class CockpitStatsStatisticsTask { cockpitStats.setMonitorPasswordGrade3Num(secrecyPasswordGradePo.getMonitorPasswordGrade3Num()); cockpitStats.setMonitorPasswordGrade4Num(secrecyPasswordGradePo.getMonitorPasswordGrade4Num()); cockpitStats.setMonitorPasswordGrade5Num(secrecyPasswordGradePo.getMonitorPasswordGrade5Num()); - }else{ + } else { cockpitStats.setMonitorSecrecyGrade1Num(guijiSecerecyGrade1); cockpitStats.setMonitorSecrecyGrade2Num(guijiSecerecyGrade2); cockpitStats.setMonitorSecrecyGrade3Num(guijiSecerecyGrade3); @@ -345,7 +346,7 @@ public class CockpitStatsStatisticsTask { } //2.专家统计 - List lsRegionCodes = RegionConst.LS_ARR; + List lsRegionCodes = RegionConst.LS_ARR; List intentions = expertIntentionWorkRegionService.list(Wrappers.lambdaQuery(ExpertIntentionWorkRegion.class) .eq(StringUtils.isNotBlank(regionCode) && !DashboardConstant.CockpitStats.TOTAL.equals(regionCode), ExpertIntentionWorkRegion::getRegionCode, regionCode) @@ -353,7 +354,7 @@ public class CockpitStatsStatisticsTask { ExpertIntentionWorkRegion::getRegionCode, lsRegionCodes)); List experts = Lists.newArrayList(); - if(CollUtil.isNotEmpty(intentions)){ + if (CollUtil.isNotEmpty(intentions)) { List userIds = intentions.stream().map(ExpertIntentionWorkRegion::getUserId) .collect(Collectors.toList()); experts = expertUserFullInfoService.list(Wrappers.lambdaQuery(ExpertUserFullInfo.class) @@ -371,8 +372,8 @@ public class CockpitStatsStatisticsTask { String dangzhengCode = DashboardConstant.Expert.DANGZHENG_CODE; String ruanyingCode = DashboardConstant.Expert.RUANYING_CODE; String caiwuCode = DashboardConstant.Expert.CAIWU_CODE; - List specialTags = Lists.newArrayList(networkCode,xinchuangCode,fanganCode,jishuCode, - dangzhengCode,ruanyingCode,caiwuCode); + List specialTags = Lists.newArrayList(networkCode, xinchuangCode, fanganCode, jishuCode, + dangzhengCode, ruanyingCode, caiwuCode); cockpitStats.setExpertTotalNum(experts.size()); Integer financialNum = 0; @@ -384,38 +385,38 @@ public class CockpitStatsStatisticsTask { Integer softHardPricingNum = 0; Integer technicalFeasibilityAssessmentNum = 0; Integer specialExpertNum = 0; - for(ExpertUserFullInfo e : experts){ - if(tagMap.containsKey(e.getUserId())){ + for (ExpertUserFullInfo e : experts) { + if (tagMap.containsKey(e.getUserId())) { List expertTags = tagMap.get(e.getUserId()); - Boolean isContain = Boolean.FALSE; - for(ExpertTag expertTag : expertTags){ - if(expertTag.getTagCode().equals(networkCode)){ + boolean isContain = Boolean.FALSE; + for (ExpertTag expertTag : expertTags) { + if (expertTag.getTagCode().equals(networkCode)) { networkSecurityNum++; } - if(expertTag.getTagCode().equals(caiwuCode)){ - financialNum ++; + if (expertTag.getTagCode().equals(caiwuCode)) { + financialNum++; } - if(expertTag.getTagCode().equals(xinchuangCode)){ - xinchuangNum ++; + if (expertTag.getTagCode().equals(xinchuangCode)) { + xinchuangNum++; } - if(expertTag.getTagCode().equals(fanganCode)){ + if (expertTag.getTagCode().equals(fanganCode)) { planRationalityNum++; } - if(expertTag.getTagCode().equals(jishuCode)){ - technicalFeasibilityAssessmentNum ++; + if (expertTag.getTagCode().equals(jishuCode)) { + technicalFeasibilityAssessmentNum++; } - if(expertTag.getTagCode().equals(dangzhengCode)){ - partyGovInfoNum ++; + if (expertTag.getTagCode().equals(dangzhengCode)) { + partyGovInfoNum++; } - if(expertTag.getTagCode().equals(ruanyingCode)){ - softHardPricingNum ++; + if (expertTag.getTagCode().equals(ruanyingCode)) { + softHardPricingNum++; } - if(specialTags.contains(expertTag.getTagCode())){ + if (specialTags.contains(expertTag.getTagCode())) { isContain = Boolean.TRUE; } } - if(isContain){ - specialExpertNum ++; + if (isContain) { + specialExpertNum++; } } } @@ -434,53 +435,52 @@ public class CockpitStatsStatisticsTask { //3.顶部数据 //3.1 计划项目数(申报项目:完成年度计划的项目总数 // 项目归集:评审中、待立项、已立项、已采购、已初验、已终验项目总和) - Integer planProjectNum = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && - p.getStatus().compareTo(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) >= 0){ - return Boolean.TRUE; - } - return Boolean.FALSE; - }).collect(Collectors.toList()).size(); - Integer planProjectNumGov = baseInfos.stream().filter(p -> { - if(Objects.nonNull(p.getBaseProjSetProg()) && + Integer planProjectNum = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && + p.getStatus().compareTo(ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()) >= 0) { + return Boolean.TRUE; + } + return Boolean.FALSE; + }).count(); + Integer planProjectNumGov = (int) baseInfos.stream().filter(p -> { + if (Objects.nonNull(p.getBaseProjSetProg()) && //排除 已驳回 已终止 (!Lists.newArrayList(GovProjectStatusEnum.REJECTED.getCode(), - GovProjectStatusEnum.TERMINATED.getCode()).contains(p.getBaseProjSetProg()))){ + GovProjectStatusEnum.TERMINATED.getCode()).contains(p.getBaseProjSetProg()))) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setTopPlanProjectsNum(planProjectNum + planProjectNumGov); //3.2 批复项目数(申报项目:完成立项批复流程项目总数 项目归集:已立项、已采购、已初验、已终验项目总和) - Integer approvalNumDeclared = projects.stream().filter(p -> { - if(Objects.nonNull(p.getApprovalAmount())){ + Integer approvalNumDeclared = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getApprovalAmount())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); - Integer approvalNumGov = baseInfos.stream().filter(p -> { - if(Objects.nonNull(p.getBaseProjSetProg()) && Lists.newArrayList(GovProjectStatusEnum.APPROVED.getCode(), - GovProjectStatusEnum.PURCHASED.getCode(),GovProjectStatusEnum.HAS_PRE_INS.getCode(), - GovProjectStatusEnum.HAS_FINAL_INS.getCode()).contains(p.getBaseProjSetProg())){ + }).count(); + Integer approvalNumGov = (int) baseInfos.stream().filter(p -> { + if (Objects.nonNull(p.getBaseProjSetProg()) && Lists.newArrayList(GovProjectStatusEnum.APPROVED.getCode(), + GovProjectStatusEnum.PURCHASED.getCode(), GovProjectStatusEnum.HAS_PRE_INS.getCode(), + GovProjectStatusEnum.HAS_FINAL_INS.getCode()).contains(p.getBaseProjSetProg())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); BigDecimal approvalAmount = projects.stream().filter(p -> { - if(Objects.nonNull(p.getApprovalAmount())){ + if (Objects.nonNull(p.getApprovalAmount())) { return Boolean.TRUE; } return Boolean.FALSE; - }).map(Project::getApprovalAmount).reduce(BigDecimal::add).get(); + }).map(Project::getApprovalAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); - BigDecimal approvalAmountGov = approves.stream().filter(a -> { - if(Objects.nonNull(a.getBaseInitialReviewTotalMoney())){ - return Boolean.TRUE; - } - return Boolean.FALSE; - }).map(GovBizProjectApprove::getBaseInitialReviewTotalMoney).reduce(BigDecimal::add).get(); + BigDecimal approvalAmountGov = approves.stream() + .map(GovBizProjectApprove::getBaseInitialReviewTotalMoney) + .filter(Objects::nonNull) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO); cockpitStats.setTopApprovalProjectsNum(approvalNumDeclared + approvalNumGov); cockpitStats.setTopApprovalProjectsAmount(approvalAmount.add(approvalAmountGov)); @@ -488,158 +488,157 @@ public class CockpitStatsStatisticsTask { OptionalDouble od = Stream.concat(projects.stream().map(Project::getBuildCycle), applies.stream().map(GovBizProjectApply::getBaseProjDuration)).mapToInt(c -> { try { - Integer buildCycle = Integer.valueOf(c); - return buildCycle; + return Integer.parseInt(c); } catch (Exception e) { return 0; } }).average(); - Double average = od.isPresent() ? od.getAsDouble() : 0.0; - cockpitStats.setTopAverageConstructionPeriod(average.intValue()); + double average = od.isPresent() ? od.getAsDouble() : 0.0; + cockpitStats.setTopAverageConstructionPeriod((int) average); //3.4 在建项目数 采购备案后的项目 - Integer contructionNum = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && + Integer constructionNum = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && p.getStatus().compareTo(ProjectStatusEnum.TO_BE_PURCHASED.getCode()) >= 0 - && p.getStatus().compareTo(ProjectStatusEnum.ACCEPTED.getCode()) < 0){ + && p.getStatus().compareTo(ProjectStatusEnum.ACCEPTED.getCode()) < 0) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); - Integer contructionNumGov = baseInfos.stream().filter(b -> { - if(Objects.nonNull(b.getBaseProjSetProg()) && - Lists.newArrayList(GovProjectStatusEnum.PURCHASED.getCode(),GovProjectStatusEnum.HAS_PRE_INS.getCode()).contains(b.getBaseProjSetProg())){ + }).count(); + Integer constructionNumGov = (int) baseInfos.stream().filter(b -> { + if (Objects.nonNull(b.getBaseProjSetProg()) && + Lists.newArrayList(GovProjectStatusEnum.PURCHASED.getCode(), GovProjectStatusEnum.HAS_PRE_INS.getCode()).contains(b.getBaseProjSetProg())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); - cockpitStats.setTopOngoingProjectsNum(contructionNum + contructionNumGov); + }).count(); + cockpitStats.setTopOngoingProjectsNum(constructionNum + constructionNumGov); //4.地图 只要放总数 取的时候 会有逻辑(也要取项目归集) cockpitStats.setProjectsTotal(projects.size() + baseInfos.size()); //5.下面项目状态数 //5.1 计划(申报项目:项目预审完成到年度计划未完成 项目归集:评审中) - Integer inPlanNum = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && + Integer inPlanNum = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && p.getStatus().compareTo(ProjectStatusEnum.PREQUALIFICATION_FAILED.getCode()) > 0 && - p.getStatus().compareTo(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode()) <= 0){ + p.getStatus().compareTo(ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode()) <= 0) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); - Integer inPlanNumGov = baseInfos.stream().filter(p -> { - if(Objects.nonNull(p.getBaseProjSetProg()) && - p.getBaseProjSetProg().equals(GovProjectStatusEnum.APPROVAL.getCode())){ + }).count(); + Integer inPlanNumGov = (int) baseInfos.stream().filter(p -> { + if (Objects.nonNull(p.getBaseProjSetProg()) && + p.getBaseProjSetProg().equals(GovProjectStatusEnum.APPROVAL.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setProjectsTotalPlan(inPlanNum + inPlanNumGov); //5.2 处于申报(申报项目:年度计划完成到建设方案审批第一个节点审批未通过前 项目归集:待立项) - Integer inApplyNum = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && + Integer inApplyNum = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && (ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode().equals(p.getStatus()) || (ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode().equals(p.getStatus()) && - searchSchemaReviewFlow(p.getProjectCode())))){ + searchSchemaReviewFlow(p.getProjectCode())))) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); - Integer inApplyNumGov = baseInfos.stream().filter(p -> { - if(Objects.nonNull(p.getBaseProjSetProg()) && - p.getBaseProjSetProg().equals(GovProjectStatusEnum.PENDING.getCode())){ + }).count(); + Integer inApplyNumGov = (int) baseInfos.stream().filter(p -> { + if (Objects.nonNull(p.getBaseProjSetProg()) && + p.getBaseProjSetProg().equals(GovProjectStatusEnum.PENDING.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setProjectsTotalApply(inApplyNum + inApplyNumGov); //5.3 处于审批 (申报项目:建设方案审批第一个节点审批通过到立项批复未完成 项目归集:已立项) - Integer inApproveNum = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && + Integer inApproveNum = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && (ProjectStatusEnum.TO_BE_APPROVED.getCode().equals(p.getStatus()) || p.getStatus().compareTo(ProjectStatusEnum.APPROVED_AFTER_CHOICE.getCode()) > 0 || (ProjectStatusEnum.SCHEME_UNDER_REVIEW.getCode().equals(p.getStatus()) && - searchSchemaReviewedFlow(p.getProjectCode())))){ + searchSchemaReviewedFlow(p.getProjectCode())))) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); - Integer inApproveNumGov = baseInfos.stream().filter(p -> { - if(Objects.nonNull(p.getBaseProjSetProg()) && - p.getBaseProjSetProg().equals(GovProjectStatusEnum.APPROVED.getCode())){ + }).count(); + Integer inApproveNumGov = (int) baseInfos.stream().filter(p -> { + if (Objects.nonNull(p.getBaseProjSetProg()) && + p.getBaseProjSetProg().equals(GovProjectStatusEnum.APPROVED.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setProjectsTotalApprove(inApproveNum + inApproveNumGov); //5.4 建设 (申报项目:立项批复完成到项目初验未完成 项目归集:已采购) - Integer inConstructionNum = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && + Integer inConstructionNum = (int) projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && (p.getStatus().compareTo(ProjectStatusEnum.APPROVED_AFTER_CHOICE.getCode()) > 0 && p.getStatus().compareTo(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) < 0) || //如果在建设中 那么初验材料为空代表 初验未完成 (p.getStatus().equals(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) && - StringUtils.isBlank(p.getPreliminaryInspectionMaterials()))){ + StringUtils.isBlank(p.getPreliminaryInspectionMaterials()))) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); - Integer inConstructionNumGov = baseInfos.stream().filter(p -> { - if(Objects.nonNull(p.getBaseProjSetProg()) && - p.getBaseProjSetProg().equals(GovProjectStatusEnum.PURCHASED.getCode())){ + }).count(); + Integer inConstructionNumGov = (int) baseInfos.stream().filter(p -> { + if (Objects.nonNull(p.getBaseProjSetProg()) && + p.getBaseProjSetProg().equals(GovProjectStatusEnum.PURCHASED.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setProjectsTotalConstruction(inConstructionNum + inConstructionNumGov); //5.5 验收 (申报项目:项目初验完成到项目终验未完成 项目归集:已初验) - List inAccpetProjects = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && + List inAcceptProjects = projects.stream().filter(p -> { + if (Objects.nonNull(p.getStatus()) && p.getStatus().compareTo(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) > 0 && p.getStatus().compareTo(ProjectStatusEnum.ACCEPTED.getCode()) < 0 || //如果在建设中 那么初验材料不为空代表 初验完成 (p.getStatus().equals(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) && - StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials()))){ + StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials()))) { return Boolean.TRUE; } return Boolean.FALSE; }).collect(Collectors.toList()); - List inAccpetProjectsGov = baseInfos.stream().filter(b -> { - if(Objects.nonNull(b.getBaseProjSetProg()) && - b.getBaseProjSetProg().equals(GovProjectStatusEnum.HAS_PRE_INS.getCode())){ + List inAcceptProjectsGov = baseInfos.stream().filter(b -> { + if (Objects.nonNull(b.getBaseProjSetProg()) && + b.getBaseProjSetProg().equals(GovProjectStatusEnum.HAS_PRE_INS.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; }).collect(Collectors.toList()); - cockpitStats.setProjectsTotalAccept(inAccpetProjects.size() + inAccpetProjectsGov.size()); + cockpitStats.setProjectsTotalAccept(inAcceptProjects.size() + inAcceptProjectsGov.size()); //5.6 运维(申报项目:项目验收完成后且项目未注销 项目归集:已终验) List inOperationProjects = projects.stream().filter(p -> { - if(Objects.nonNull(p.getStatus()) && - p.getStatus().equals(ProjectStatusEnum.ACCEPTED.getCode())){ + if (Objects.nonNull(p.getStatus()) && + p.getStatus().equals(ProjectStatusEnum.ACCEPTED.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; }).collect(Collectors.toList()); - Integer inOperationProjectsGov = baseInfos.stream().filter(b -> { - if(Objects.nonNull(b.getBaseProjSetProg()) && - b.getBaseProjSetProg().equals(GovProjectStatusEnum.HAS_FINAL_INS.getCode())){ + int inOperationProjectsGov = (int) baseInfos.stream().filter(b -> { + if (Objects.nonNull(b.getBaseProjSetProg()) && + b.getBaseProjSetProg().equals(GovProjectStatusEnum.HAS_FINAL_INS.getCode())) { return Boolean.TRUE; } return Boolean.FALSE; - }).collect(Collectors.toList()).size(); + }).count(); cockpitStats.setProjectsTotalOperation(inOperationProjects.size() + inOperationProjectsGov); //5.7 绩效(申报项目:项目验收完成后且未完成绩效自评 项目归集:无) - List inAccpetCodes = inOperationProjects.stream().map(Project::getProjectCode).collect(Collectors.toList()); + List inAcceptCodes = inOperationProjects.stream().map(Project::getProjectCode).collect(Collectors.toList()); List performances = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .in(CollUtil.isNotEmpty(inAccpetCodes),PerformanceAppraisalProject::getProjectCode, inAccpetCodes) - .in(CollUtil.isEmpty(inAccpetCodes),PerformanceAppraisalProject::getProjectCode, Lists.newArrayList("NONE")) - .eq(PerformanceAppraisalProject::getIsReAppraisal,Boolean.TRUE) + .in(CollUtil.isNotEmpty(inAcceptCodes), PerformanceAppraisalProject::getProjectCode, inAcceptCodes) + .in(CollUtil.isEmpty(inAcceptCodes), PerformanceAppraisalProject::getProjectCode, Lists.newArrayList("NONE")) + .eq(PerformanceAppraisalProject::getIsReAppraisal, Boolean.TRUE) .isNull(PerformanceAppraisalProject::getReAppraisalTotalScore) ); cockpitStats.setProjectsTotalPerformance(performances.size()); @@ -664,7 +663,7 @@ public class CockpitStatsStatisticsTask { return p.getDeclareAmount(); } return BigDecimal.ZERO; - }).reduce(BigDecimal::add).get(); + }).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); cockpitStats.setRejectSavingsFunds(rejectPreSum); //7.3 柱状图 @@ -681,30 +680,21 @@ public class CockpitStatsStatisticsTask { //申报的申报金额(申报项目:初步方案申报金额 项目归集:项目总投资) final BigDecimal[] declaredAmountApprove = {BigDecimal.ZERO}; - normalProjects.stream().map(p -> { - BigDecimal declareAmount = Objects.nonNull(p.getDeclareAmount()) ? - p.getDeclareAmount() : BigDecimal.ZERO; - return declareAmount; - }).reduce(BigDecimal::add).ifPresent(b -> declaredAmountApprove[0] = b); + normalProjects.stream().map(p -> ObjectUtil.defaultIfNull(p.getDeclareAmount(), BigDecimal.ZERO)) + .reduce(BigDecimal::add).ifPresent(b -> declaredAmountApprove[0] = b); final BigDecimal[] declaredAmountApproveGov = {BigDecimal.ZERO}; - applies.stream().map(g -> { - BigDecimal totalAmount = Objects.nonNull(g.getBaseProjTotalAmount()) ? g.getBaseProjTotalAmount() : BigDecimal.ZERO; - return totalAmount; - }).reduce(BigDecimal::add).ifPresent(b -> declaredAmountApproveGov[0] = b); + applies.stream().map(g -> ObjectUtil.defaultIfNull(g.getBaseProjTotalAmount(), BigDecimal.ZERO)) + .reduce(BigDecimal::add).ifPresent(b -> declaredAmountApproveGov[0] = b); BigDecimal declaredAmountApproveTotal = declaredAmountApprove[0].add(declaredAmountApproveGov[0]); cockpitStats.setDeclaredAmountApprove(declaredAmountApproveTotal); //申报的批复金额(申报项目:建设方案申报金额 项目归集:建议总投资) final BigDecimal[] approvalAmountApprove = {BigDecimal.ZERO}; - normalProjects.stream().map(p -> { - BigDecimal declareAmount = Objects.nonNull(p.getApprovalAmount()) ? p.getApprovalAmount() : BigDecimal.ZERO; - return declareAmount; - }).reduce(BigDecimal::add).ifPresent(b -> approvalAmountApprove[0] = b); + normalProjects.stream().map(p -> ObjectUtil.defaultIfNull(p.getApprovalAmount(), BigDecimal.ZERO)) + .reduce(BigDecimal::add).ifPresent(b -> approvalAmountApprove[0] = b); final BigDecimal[] approvalAmountApproveGov = {BigDecimal.ZERO}; - approves.stream().map(p -> { - BigDecimal expertTotalMoney = Objects.nonNull(p.getBaseExpertTotalMoney()) ? p.getBaseExpertTotalMoney() : BigDecimal.ZERO; - return expertTotalMoney; - }).reduce(BigDecimal::add).ifPresent(b -> approvalAmountApproveGov[0] = b); + approves.stream().map(p -> ObjectUtil.defaultIfNull(p.getBaseExpertTotalMoney(), BigDecimal.ZERO)) + .reduce(BigDecimal::add).ifPresent(b -> approvalAmountApproveGov[0] = b); BigDecimal approvalAmountApproveTotal = approvalAmountApprove[0].add(approvalAmountApproveGov[0]); cockpitStats.setApprovalAmountApprove(approvalAmountApproveTotal); //申报的差额 @@ -716,15 +706,11 @@ public class CockpitStatsStatisticsTask { //批复的批复金额(申报项目:归集信息建议批复总投资 项目归集:建议批复总投资) final BigDecimal[] approvalAmountApproval = {BigDecimal.ZERO}; - normalProjects.stream().map(p -> { - BigDecimal proposeTotalInvest = Objects.nonNull(p.getProposeTotalInvest()) ? p.getProposeTotalInvest() : BigDecimal.ZERO; - return proposeTotalInvest; - }).reduce(BigDecimal::add).ifPresent(b -> approvalAmountApproval[0] = b); + normalProjects.stream().map(p -> ObjectUtil.defaultIfNull(p.getProposeTotalInvest(), BigDecimal.ZERO)) + .reduce(BigDecimal::add).ifPresent(b -> approvalAmountApproval[0] = b); final BigDecimal[] approvalAmountApprovalGov = {BigDecimal.ZERO}; - approves.stream().map(p -> { - BigDecimal reviewTotalMoney = Objects.nonNull(p.getBaseInitialReviewTotalMoney()) ? p.getBaseInitialReviewTotalMoney() : BigDecimal.ZERO; - return reviewTotalMoney; - }).reduce(BigDecimal::add).ifPresent(b -> approvalAmountApprovalGov[0] = b); + approves.stream().map(p -> ObjectUtil.defaultIfNull(p.getBaseInitialReviewTotalMoney(), BigDecimal.ZERO)) + .reduce(BigDecimal::add).ifPresent(b -> approvalAmountApprovalGov[0] = b); BigDecimal approvalAmountApprovalTotal = approvalAmountApproval[0].add(approvalAmountApprovalGov[0]); cockpitStats.setApprovalAmountApproval(approvalAmountApprovalTotal); @@ -737,16 +723,12 @@ public class CockpitStatsStatisticsTask { //合同的批复金额(申报项目:成交金额 项目归集:成交金额) final BigDecimal[] approvalAmountContract = {BigDecimal.ZERO}; - normalProjects.stream().map(p -> { - BigDecimal transactionAmount = Objects.nonNull(p.getTransactionAmount()) ? p.getTransactionAmount() : BigDecimal.ZERO; - return transactionAmount; - }).reduce(BigDecimal::add).ifPresent(b -> approvalAmountContract[0] = b); + normalProjects.stream().map(p -> Objects.nonNull(p.getTransactionAmount()) ? p.getTransactionAmount() : BigDecimal.ZERO) + .reduce(BigDecimal::add).ifPresent(b -> approvalAmountContract[0] = b); final BigDecimal[] approvalAmountContractGov = {BigDecimal.ZERO}; - procures.stream().map(p -> { - BigDecimal purchaseAmount = Objects.nonNull(p.getBaseProjPurchaseAmount()) ? - p.getBaseProjPurchaseAmount() : BigDecimal.ZERO; - return purchaseAmount; - }).reduce(BigDecimal::add).ifPresent(b -> approvalAmountContractGov[0] = b); + procures.stream().map(p -> Objects.nonNull(p.getBaseProjPurchaseAmount()) ? + p.getBaseProjPurchaseAmount() : BigDecimal.ZERO).reduce(BigDecimal::add) + .ifPresent(b -> approvalAmountContractGov[0] = b); BigDecimal approvalAmountContractTotal = approvalAmountContract[0].add(approvalAmountContractGov[0]); cockpitStats.setApprovalAmountContract(approvalAmountContractTotal); @@ -765,7 +747,7 @@ public class CockpitStatsStatisticsTask { //9.绩效 List projectCodes = projects.stream().map(Project::getProjectCode).collect(Collectors.toList()); - if(CollUtil.isNotEmpty(projectCodes)){ + if (CollUtil.isNotEmpty(projectCodes)) { List performanceAll = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .in(PerformanceAppraisalProject::getProjectCode, projectCodes)); List verified = performanceAll.stream().filter(p -> { @@ -836,12 +818,13 @@ public class CockpitStatsStatisticsTask { /** * 建设方案申报了 但未开始审核的项目 + * * @param projectCode * @return */ private boolean searchSchemaReviewFlow(String projectCode) { Project project = projectService.getProjectByCode(projectCode); - if(Objects.isNull(project)){ + if (Objects.isNull(project)) { return Boolean.FALSE; } List allVersionProjectId = projectService.getAllVersionProjectId(project); @@ -849,7 +832,7 @@ public class CockpitStatsStatisticsTask { .in(ProjectInst::getProjectId, allVersionProjectId) .eq(ProjectInst::getInstType, InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode()) .last(BizConst.LIMIT_1)); - if(Objects.isNull(pi)){ + if (Objects.isNull(pi)) { return Boolean.FALSE; } String instCode = pi.getInstCode(); @@ -866,15 +849,16 @@ public class CockpitStatsStatisticsTask { .asc() .list(); //已经完成的没有 未完成的有 则可计算 - if(CollUtil.isNotEmpty(unfinished) && CollUtil.isEmpty(finished)){ + if (CollUtil.isNotEmpty(unfinished) && CollUtil.isEmpty(finished)) { return Boolean.TRUE; } return Boolean.FALSE; } + //已经开始审批 private boolean searchSchemaReviewedFlow(String projectCode) { Project project = projectService.getProjectByCode(projectCode); - if(Objects.isNull(project)){ + if (Objects.isNull(project)) { return Boolean.FALSE; } List allVersionProjectId = projectService.getAllVersionProjectId(project); @@ -882,7 +866,7 @@ public class CockpitStatsStatisticsTask { .in(ProjectInst::getProjectId, allVersionProjectId) .eq(ProjectInst::getInstType, InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode()) .last(BizConst.LIMIT_1)); - if(Objects.isNull(pi)){ + if (Objects.isNull(pi)) { return Boolean.FALSE; } String instCode = pi.getInstCode(); @@ -893,7 +877,7 @@ public class CockpitStatsStatisticsTask { .asc() .list(); //已经完成的 则可计算 - if(CollUtil.isNotEmpty(finished)){ + if (CollUtil.isNotEmpty(finished)) { return Boolean.TRUE; } return Boolean.FALSE; @@ -901,6 +885,7 @@ public class CockpitStatsStatisticsTask { /** * 计算环节滞后项目 + * * @param projects * @return */ @@ -908,18 +893,18 @@ public class CockpitStatsStatisticsTask { List projectCodes = projects.stream().map(Project::getProjectCode).collect(Collectors.toList()); Map map = projects.stream().collect(Collectors.toMap(Project::getProjectCode, p -> p)); List records = Lists.newArrayList(); - if(CollUtil.isNotEmpty(projectCodes)){ + if (CollUtil.isNotEmpty(projectCodes)) { records = earlyWarningRecordsService.list(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) .in(WflowEarlyWarningRecords::getProjectCode, projectCodes)); } return records.stream().mapToInt(r -> { - if(!map.containsKey(r.getProjectCode())){ + if (!map.containsKey(r.getProjectCode())) { return 0; } Project project = map.get(r.getProjectCode()); //如果状态 相等 说明预警了 但是没处理 +1 - if(Objects.nonNull(project.getStatus()) && Objects.nonNull(r.getProjectStatus()) && - project.getStatus().equals(r.getProjectStatus())){ + if (Objects.nonNull(project.getStatus()) && Objects.nonNull(r.getProjectStatus()) && + project.getStatus().equals(r.getProjectStatus())) { return 1; } return 0; @@ -927,7 +912,7 @@ public class CockpitStatsStatisticsTask { } private void buildMonitorRise(CockpitStats cockpitStats, CockpitStats thisYearData, CockpitStats lastYearData) { - if(Objects.isNull(thisYearData) || Objects.isNull(lastYearData)){ + if (Objects.isNull(thisYearData) || Objects.isNull(lastYearData)) { return; } cockpitStats.setMonitorOverdueConstructionProjectsRise(BizUtils.computeRise(thisYearData.getMonitorOverdueConstructionProjectsNum(), diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CommonLogTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CommonLogTask.java deleted file mode 100644 index dec7f64..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/CommonLogTask.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.hz.pm.api.scheduler.task; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.file.FileReader; -import cn.hutool.core.io.file.FileWriter; -import cn.hutool.core.lang.UUID; -import cn.hutool.json.JSONUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.log.mapper.OptLogMapper; -import com.ningdatech.log.model.domain.OptLog; -import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.common.model.constant.RegionConst; -import com.hz.pm.api.organization.mapper.DingEmployeeInfoMapper; -import com.hz.pm.api.organization.model.entity.DingEmployeeInfo; -import com.hz.pm.api.scheduler.task.model.CommonLog; -import com.hz.pm.api.user.model.entity.UserInfo; -import com.hz.pm.api.user.service.IUserInfoService; -import lombok.RequiredArgsConstructor; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.List; - -/** - * 通用日志写入任务 - * @author liushuai - */ -@Component -@RequiredArgsConstructor -public class CommonLogTask { - private final OptLogMapper optLogMapper; - private final IUserInfoService userInfoService; - private final DingEmployeeInfoMapper dingEmployeeInfoMapper; - /** - * 日志记录文件位置 - */ - private final static String LOG_RECORD_ADDRESS = "/opt/log/"; - private final static String LOG_ID_FILE = "logId.txt"; - private final static String LOG_FILE = "common_log_"; - - @Value("${hostname}") - private String HOST_NAME; - - @Scheduled(fixedDelay = 120000) - public void writeLog() throws UnknownHostException { - // - if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { - return; - } - //获取记录ID文件 - boolean idFileExist = FileUtil.exist(LOG_RECORD_ADDRESS + LOG_ID_FILE); - if (!idFileExist){ - FileUtil.touch(LOG_RECORD_ADDRESS + LOG_ID_FILE); - } - FileReader fileReader = new FileReader(LOG_RECORD_ADDRESS + LOG_ID_FILE); - String result = fileReader.readString(); - long startLogId = 0L; - if (StringUtils.isNotBlank(result)){ - startLogId = Long.parseLong(result); - } - LambdaQueryWrapper query = Wrappers.lambdaQuery(OptLog.class).gt(OptLog::getId,startLogId); - //查询日志 - List logList = optLogMapper.selectList(query); - DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - if (CollectionUtil.isNotEmpty(logList)){ - for (OptLog optLog : logList){ - CommonLog commonLog = new CommonLog(); - UserInfo userInfo = userInfoService.getById(optLog.getCreateBy()); - if (userInfo == null){ - continue; - } - String employeeCode = userInfo.getEmployeeCode(); - if (StringUtils.isNotBlank(employeeCode)){ - DingEmployeeInfo dingEmployeeInfo = dingEmployeeInfoMapper.selectOne(new LambdaQueryWrapper() - .eq(DingEmployeeInfo::getEmployeeCode,employeeCode) - .last(BizConst.LIMIT_1)); - if (dingEmployeeInfo != null){ - commonLog.setUserId(String.valueOf(dingEmployeeInfo.getAccountId())); - } - }else { - commonLog.setUserId(String.valueOf(userInfo.getId())); - } - commonLog.setUserRole("政府工作人员"); - commonLog.setAreaCode(userInfo.getRegionCode() + RegionConst.NINE_CODE_LAST); - String description = optLog.getDescription(); - if ("用户登录".equals(description)){ - commonLog.setActionType(1); - }else if (description.contains("退出登录")){ - commonLog.setActionType(2); - }else { - commonLog.setActionType(3); - } - String actionId = UUID.randomUUID().toString(); - commonLog.setActionId(actionId); - commonLog.setActionTime(df.format(optLog.getStartTime())); - commonLog.setActionDuration(optLog.getConsumingTime()); - commonLog.setActionStatus(0); - commonLog.setAppCode("A331101453557202109017383"); - //判断当天日志文件是否存在 - DateTimeFormatter dfNow = DateTimeFormatter.ofPattern("yyyyMMdd"); - String fileName = LOG_RECORD_ADDRESS + LOG_FILE + dfNow.format(LocalDateTime.now()) + ".log"; - boolean fileExist = FileUtil.exist(fileName); - if (!fileExist){ - //不存在则创建当天日志文件 - FileUtil.touch(fileName); - } - //写入通用规则 - FileWriter writer = new FileWriter(fileName); - writer.append(JSONUtil.toJsonStr(commonLog)); - writer.append("\n"); - if (commonLog.getActionType() == 3){ - CommonLog commonLogEnd = new CommonLog(); - BeanUtil.copyProperties(commonLog,commonLogEnd); - commonLogEnd.setActionType(4); - writer.append(JSONUtil.toJsonStr(commonLogEnd)); - writer.append("\n"); - } - } - //记录最后一个节点位置 - FileWriter writer = new FileWriter(LOG_RECORD_ADDRESS + LOG_ID_FILE); - writer.write(String.valueOf(logList.get(logList.size() - 1).getId())); - } - } -} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java index 27e2d41..1f6bcd7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java @@ -8,16 +8,15 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.hz.pm.api.projectlib.model.enumeration.*; -import com.ningdatech.basic.util.StrPool; -import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.common.enumeration.CommonEnum; +import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.projectdeclared.model.entity.Contract; import com.hz.pm.api.projectdeclared.model.entity.Operation; import com.hz.pm.api.projectdeclared.service.IContractService; 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.ProjectRenewalFundDeclaration; +import com.hz.pm.api.projectlib.model.enumeration.*; import com.hz.pm.api.projectlib.service.IProjectRenewalFundDeclarationService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.sys.manage.EarlyWarningManage; @@ -26,6 +25,7 @@ import com.hz.pm.api.sys.service.IProjectEarlyWarningService; 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.StrPool; import com.wflow.bean.entity.WflowEarlyWarning; import com.wflow.enums.WarningRuleTypeEnum; import com.wflow.service.IEarlyWarningService; @@ -35,9 +35,11 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; + import java.net.InetAddress; import java.net.UnknownHostException; -import java.time.*; +import java.time.Duration; +import java.time.LocalDateTime; import java.util.List; import java.util.Map; import java.util.Objects; @@ -87,17 +89,17 @@ public class EarlyWarningInstanceNotStartTask { // 1.查询 填报的 预警规则 填报类型的 每个区域 每个规则 List warnings = earlyWarningService.list(Wrappers.lambdaQuery(WflowEarlyWarning.class) .eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DECLARED_WARNING.getCode())); - for(WflowEarlyWarning warning : warnings){ + for (WflowEarlyWarning warning : warnings) { //2. 取出rule的数据 - if(!warning.getIsOpen()){ + if (!warning.getIsOpen()) { log.info(warning.getId() + " 此规则关闭了"); continue; } String noticeMethod = warning.getNoticeMethod(); - if(StringUtils.isBlank(noticeMethod) || + if (StringUtils.isBlank(noticeMethod) || (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && - !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ + !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) { log.info("通知方式为空或者错误!"); return; } @@ -105,27 +107,27 @@ public class EarlyWarningInstanceNotStartTask { String noticeContent = warning.getNoticeContent(); String adventContent = warning.getAdventContent(); String rule = warning.getRule(); - if(StringUtils.isNotBlank(rule)){ + if (StringUtils.isNotBlank(rule)) { JSONArray ruleArray = JSON.parseArray(rule); - if(CollUtil.isNotEmpty(ruleArray)){ + if (CollUtil.isNotEmpty(ruleArray)) { ruleArray.forEach(r -> { JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); Integer time = rJson.getInteger("time"); Integer biz = rJson.getInteger("biz"); String notice = rJson.getString("notice"); Integer adventTime = rJson.getInteger("adventTime"); - if((Objects.isNull(time) && Objects.isNull(adventTime)) || Objects.isNull(biz)){ - log.info("规则数据 错误 :{}",rJson); + if ((Objects.isNull(time) && Objects.isNull(adventTime)) || Objects.isNull(biz)) { + log.info("规则数据 错误 :{}", rJson); return; } - if(StringUtils.isBlank(notice)){ + if (StringUtils.isBlank(notice)) { log.info("取不到提醒人配置 : " + rJson); return; } WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz); - if(Objects.isNull(flowTypeEnum)){ + if (Objects.isNull(flowTypeEnum)) { log.info("匹配不到 业务类型"); return; } @@ -139,99 +141,99 @@ public class EarlyWarningInstanceNotStartTask { List needNextProjects = projectService.list(Wrappers.lambdaQuery(Project.class) .eq(Project::getAreaCode, areaCode) .eq(Project::getNewest, Boolean.TRUE) - .eq(Project::getStatus,projectStutas)); + .eq(Project::getStatus, projectStutas)); - Map> noticeMap = Maps.newHashMap(); + Map> noticeMap = Maps.newHashMap(); //需要发通知的项目 List needToWaringProjects = needNextProjects.stream() .filter(p -> { //判断 当状态在 建设中的时候 是不是要初验了 - if(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)){ + if (ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)) { List allVersionProjectId = projectService.getAllVersionProjectId(p); //如果合同信息提交过了 才是 待初验状态 - if(StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())){ - if(0L == contractService.count(Wrappers.lambdaQuery(Contract.class) - .in(Contract::getProjectId, allVersionProjectId))){ + if (StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())) { + if (0L == contractService.count(Wrappers.lambdaQuery(Contract.class) + .in(Contract::getProjectId, allVersionProjectId))) { return Boolean.FALSE; } } } List noticeTypes = Lists.newArrayList(); - if(Objects.nonNull(time) && Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 - Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() <= time * 60 + 1){ //time * 60 + if (Objects.nonNull(time) && Duration.between(p.getUpdateOn(), LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 + Duration.between(p.getUpdateOn(), LocalDateTime.now()).toMinutes() <= time * 60 + 1) { //time * 60 noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode()); } - if(Objects.nonNull(adventTime) && Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 - Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1){ + if (Objects.nonNull(adventTime) && Duration.between(p.getUpdateOn(), LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 + Duration.between(p.getUpdateOn(), LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1) { noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); } - if(CollUtil.isNotEmpty(noticeTypes)){ - noticeMap.put(p.getProjectCode(),noticeTypes); + if (CollUtil.isNotEmpty(noticeTypes)) { + noticeMap.put(p.getProjectCode(), noticeTypes); //项目 填报预警 projectEarlyWarningService.earlyWarning(p, - WarningRuleTypeEnum.DECLARED_WARNING.getCode(),noticeTypes); + WarningRuleTypeEnum.DECLARED_WARNING.getCode(), noticeTypes); return Boolean.TRUE; } return Boolean.FALSE; }) .collect(Collectors.toList()); - if(StringUtils.isBlank(noticeMethod) || + if (StringUtils.isBlank(noticeMethod) || (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && - !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ + !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) { log.info("通知方式为空或者错误!"); return; } - for(Project needToWaringProject : needToWaringProjects){ + for (Project needToWaringProject : needToWaringProjects) { String username = null; String mobile = null; //去预警通知人 1.项目联系人 2.项目负责人 如果都包含 都要发 List batchEmployees = Lists.newArrayList(); - if(notice.contains(WarningNoticeTypeEnum.CONTACT.getCode().toString())){ + if (notice.contains(WarningNoticeTypeEnum.CONTACT.getCode().toString())) { String employeeCode = null; username = needToWaringProject.getContactName(); mobile = needToWaringProject.getContactPhone(); - if(StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)){ + if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)) { UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getUsername, username) .eq(UserInfo::getMobile, mobile) .last(BizConst.LIMIT_1)); - if(Objects.nonNull(user)){ + if (Objects.nonNull(user)) { employeeCode = user.getEmployeeCode(); } - if(Objects.nonNull(employeeCode)){ + if (Objects.nonNull(employeeCode)) { batchEmployees.add(employeeCode); } } } - if(notice.contains(WarningNoticeTypeEnum.RESPONSIBLE.getCode().toString())){ + if (notice.contains(WarningNoticeTypeEnum.RESPONSIBLE.getCode().toString())) { String employeeCode = null; username = needToWaringProject.getResponsibleMan(); mobile = needToWaringProject.getResponsibleManMobile(); - if(StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)){ + if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)) { UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getUsername, username) .eq(UserInfo::getMobile, mobile) .last(BizConst.LIMIT_1)); - if(Objects.nonNull(user)){ + if (Objects.nonNull(user)) { employeeCode = user.getEmployeeCode(); } - if(Objects.nonNull(employeeCode)){ + if (Objects.nonNull(employeeCode)) { batchEmployees.add(employeeCode); } } } - if(CollUtil.isNotEmpty(batchEmployees)){ - String batchEmployeesStr = batchEmployees.stream().collect(Collectors.joining(StrPool.COMMA)); - if(noticeMap.containsKey(needToWaringProject.getProjectCode())){ + if (CollUtil.isNotEmpty(batchEmployees)) { + String batchEmployeesStr = String.join(StrPool.COMMA, batchEmployees); + if (noticeMap.containsKey(needToWaringProject.getProjectCode())) { List noticeTypes = noticeMap.get(needToWaringProject.getProjectCode()); - for(Integer noticeType : noticeTypes) { + for (Integer noticeType : noticeTypes) { for (String employeeCode : batchEmployees) { earlyWarningManage.doEarlyWarning(noticeMethod, Objects.nonNull(noticeType) && noticeType.equals(1) ? noticeContent : adventContent, - adventTime,time, biz, - needToWaringProject.getUpdateOn(),employeeCode, needToWaringProject, + adventTime, time, biz, + needToWaringProject.getUpdateOn(), Long.valueOf(employeeCode), needToWaringProject, WarningRuleTypeEnum.DECLARED_WARNING.getCode(), noticeType, path, batchEmployeesStr, null); } @@ -261,17 +263,17 @@ public class EarlyWarningInstanceNotStartTask { // 1.查询 填报的 预警规则 填报类型的 每个区域 每个规则 List warnings = earlyWarningService.list(Wrappers.lambdaQuery(WflowEarlyWarning.class) .eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.OPERATION_WARNING.getCode())); - for(WflowEarlyWarning warning : warnings){ + for (WflowEarlyWarning warning : warnings) { //2. 取出rule的数据 - if(!warning.getIsOpen()){ + if (!warning.getIsOpen()) { log.info(warning.getId() + " 此规则关闭了"); continue; } String noticeMethod = warning.getNoticeMethod(); - if(StringUtils.isBlank(noticeMethod) || + if (StringUtils.isBlank(noticeMethod) || (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && - !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ + !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) { log.info("通知方式为空或者错误!"); return; } @@ -279,22 +281,22 @@ public class EarlyWarningInstanceNotStartTask { String noticeContent = warning.getNoticeContent(); String adventContent = warning.getAdventContent(); String rule = warning.getRule(); - if(StringUtils.isNotBlank(rule)){ + if (StringUtils.isNotBlank(rule)) { JSONArray ruleArray = JSON.parseArray(rule); - if(CollUtil.isNotEmpty(ruleArray)){ + if (CollUtil.isNotEmpty(ruleArray)) { ruleArray.forEach(r -> { JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); Integer time = rJson.getInteger("time"); Integer adventTime = rJson.getInteger("adventTime"); Integer biz = rJson.getInteger("biz"); String notice = rJson.getString("notice"); - if((Objects.isNull(time) && Objects.isNull(adventTime)) || Objects.isNull(biz)){ - log.info("规则数据 错误 :{}",rJson); + if ((Objects.isNull(time) && Objects.isNull(adventTime)) || Objects.isNull(biz)) { + log.info("规则数据 错误 :{}", rJson); return; } WarningOperationTypeEnum operationTypeEnum = WarningOperationTypeEnum.getByCode(biz); - if(Objects.isNull(operationTypeEnum)){ + if (Objects.isNull(operationTypeEnum)) { log.info("匹配不到 业务类型"); return; } @@ -308,131 +310,131 @@ public class EarlyWarningInstanceNotStartTask { List needNextProjects = projectService.list(Wrappers.lambdaQuery(Project.class) .eq(Project::getAreaCode, areaCode) .eq(Project::getNewest, Boolean.TRUE) - .eq(Project::getStatus,projectStutas)); + .eq(Project::getStatus, projectStutas)); List projectCodes = needNextProjects.stream().map(Project::getProjectCode).collect(Collectors.toList()); List operations = operationService.list(Wrappers.lambdaQuery(Operation.class) .in(Operation::getProjectCode, projectCodes)); - Map operationMap = operations.stream().collect(Collectors.toMap(Operation::getProjectCode,o -> o)); - Map> noticeMap = Maps.newHashMap(); + Map operationMap = operations.stream().collect(Collectors.toMap(Operation::getProjectCode, o -> o)); + Map> noticeMap = Maps.newHashMap(); //需要发通知的项目 List needToWaringProjects = needNextProjects.stream() .filter(p -> { //判断 当状态在 建设中的时候 是不是要初验了 - if(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)){ + if (ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)) { List allVersionProjectId = projectService.getAllVersionProjectId(p); //如果合同信息提交过了 才是 待初验状态 - if(StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())){ - if(0L == contractService.count(Wrappers.lambdaQuery(Contract.class) - .in(Contract::getProjectId, allVersionProjectId))){ + if (StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())) { + if (0L == contractService.count(Wrappers.lambdaQuery(Contract.class) + .in(Contract::getProjectId, allVersionProjectId))) { return Boolean.FALSE; } } } //判断 实施信息中 初验和终验的时间 - if(!operationMap.containsKey(p.getProjectCode())){ + if (!operationMap.containsKey(p.getProjectCode())) { return Boolean.FALSE; } Operation operation = operationMap.get(p.getProjectCode()); List noticeTypes = Lists.newArrayList(); - if(WarningOperationTypeEnum.CHUYAN.getCode().equals(biz)){ + if (WarningOperationTypeEnum.CHUYAN.getCode().equals(biz)) { //初验 - if(Objects.nonNull(time) && Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 - Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() <= time * 60 + 1){ //time * 60 + if (Objects.nonNull(time) && Duration.between(operation.getInitialInspectionDate(), LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 + Duration.between(operation.getInitialInspectionDate(), LocalDateTime.now()).toMinutes() <= time * 60 + 1) { //time * 60 noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode()); } - if(Objects.nonNull(adventTime) && Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 - Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1){ + if (Objects.nonNull(adventTime) && Duration.between(operation.getInitialInspectionDate(), LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 + Duration.between(operation.getInitialInspectionDate(), LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1) { noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); } - }else if(WarningOperationTypeEnum.ZHONGYAN.getCode().equals(biz)){ + } else if (WarningOperationTypeEnum.ZHONGYAN.getCode().equals(biz)) { //终验 - if(Objects.nonNull(time) && Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 - Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() <= time * 60 + 1){ //time * 60 + if (Objects.nonNull(time) && Duration.between(operation.getFinalInspectionDate(), LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 + Duration.between(operation.getFinalInspectionDate(), LocalDateTime.now()).toMinutes() <= time * 60 + 1) { //time * 60 noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode()); } - if(Objects.nonNull(adventTime) && Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 - Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1){ //time * 60 + if (Objects.nonNull(adventTime) && Duration.between(operation.getFinalInspectionDate(), LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 + Duration.between(operation.getFinalInspectionDate(), LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1) { //time * 60 noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); } } - if(CollUtil.isNotEmpty(noticeTypes)){ - noticeMap.put(p.getProjectCode(),noticeTypes); + if (CollUtil.isNotEmpty(noticeTypes)) { + noticeMap.put(p.getProjectCode(), noticeTypes); //项目 运维预警 projectEarlyWarningService.earlyWarning(p, - WarningRuleTypeEnum.OPERATION_WARNING.getCode(),noticeTypes); + WarningRuleTypeEnum.OPERATION_WARNING.getCode(), noticeTypes); return Boolean.TRUE; } return Boolean.FALSE; }) .collect(Collectors.toList()); - if(StringUtils.isBlank(noticeMethod) || + if (StringUtils.isBlank(noticeMethod) || (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && - !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ + !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) { log.info("通知方式为空或者错误!"); return; } - for(Project needToWaringProject : needToWaringProjects){ + for (Project needToWaringProject : needToWaringProjects) { //去预警通知 List batchEmployees = Lists.newArrayList(); - if(StringUtils.isBlank(notice)){ + if (StringUtils.isBlank(notice)) { String sponsor = needToWaringProject.getSponsor(); batchEmployees.add(sponsor); - }else{ + } else { //去预警通知人 1.项目联系人 2.项目负责人 如果都包含 都要发 - if(notice.contains(WarningNoticeTypeEnum.CONTACT.getCode().toString())){ + if (notice.contains(WarningNoticeTypeEnum.CONTACT.getCode().toString())) { String employeeCode = null; String username = needToWaringProject.getContactName(); String mobile = needToWaringProject.getContactPhone(); - if(StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)){ + if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)) { UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getUsername, username) .eq(UserInfo::getMobile, mobile) .last(BizConst.LIMIT_1)); - if(Objects.nonNull(user)){ + if (Objects.nonNull(user)) { employeeCode = user.getEmployeeCode(); } - if(Objects.nonNull(employeeCode)){ + if (Objects.nonNull(employeeCode)) { batchEmployees.add(employeeCode); } } } - if(notice.contains(WarningNoticeTypeEnum.RESPONSIBLE.getCode().toString())){ + if (notice.contains(WarningNoticeTypeEnum.RESPONSIBLE.getCode().toString())) { String employeeCode = null; String username = needToWaringProject.getResponsibleMan(); String mobile = needToWaringProject.getResponsibleManMobile(); - if(StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)){ + if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)) { UserInfo user = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getUsername, username) .eq(UserInfo::getMobile, mobile) .last(BizConst.LIMIT_1)); - if(Objects.nonNull(user)){ + if (Objects.nonNull(user)) { employeeCode = user.getEmployeeCode(); } - if(Objects.nonNull(employeeCode)){ + if (Objects.nonNull(employeeCode)) { batchEmployees.add(employeeCode); } } } } - if(noticeMap.containsKey(needToWaringProject.getProjectCode())){ + if (noticeMap.containsKey(needToWaringProject.getProjectCode())) { List noticeTypes = noticeMap.get(needToWaringProject.getProjectCode()); - for(Integer noticeType : noticeTypes){ + for (Integer noticeType : noticeTypes) { for (String employeeCode : batchEmployees) { - earlyWarningManage.doEarlyWarning(noticeMethod,Objects.nonNull(noticeType)&¬iceType.equals(1) ? noticeContent : adventContent, - adventTime,time,biz, - needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, - WarningRuleTypeEnum.OPERATION_WARNING.getCode(),noticeType,path, - batchEmployees.stream().collect(Collectors.joining(StrPool.COMMA)),null); + earlyWarningManage.doEarlyWarning(noticeMethod, Objects.nonNull(noticeType) && noticeType.equals(1) ? noticeContent : adventContent, + adventTime, time, biz, + needToWaringProject.getUpdateOn(), Long.valueOf(employeeCode), needToWaringProject, + WarningRuleTypeEnum.OPERATION_WARNING.getCode(), noticeType, path, + batchEmployees.stream().collect(Collectors.joining(StrPool.COMMA)), null); } } } @@ -449,6 +451,7 @@ public class EarlyWarningInstanceNotStartTask { /** * 续建项目资金 超时未审批定时器 + * * @throws UnknownHostException */ @Scheduled(cron = "20 0/2 * * * ?") @@ -464,9 +467,9 @@ public class EarlyWarningInstanceNotStartTask { // 1.查询 填报的 预警规则 填报类型的 每个区域 续建项目资金审批 List warnings = earlyWarningService.list(Wrappers.lambdaQuery(WflowEarlyWarning.class) .eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.RENEWAL_FUND.getCode())); - for(WflowEarlyWarning warning : warnings){ + for (WflowEarlyWarning warning : warnings) { //2. 取出rule的数据 - if(!warning.getIsOpen()){ + if (!warning.getIsOpen()) { log.info(warning.getId() + " 此规则关闭了"); continue; } @@ -474,23 +477,23 @@ public class EarlyWarningInstanceNotStartTask { String noticeMethod = warning.getNoticeMethod(); String noticeContent = warning.getNoticeContent(); String adventContent = warning.getAdventContent(); - if(StringUtils.isBlank(noticeMethod) || + if (StringUtils.isBlank(noticeMethod) || (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && - !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ + !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) { log.info("通知方式为空或者错误!"); return; } String rule = warning.getRule(); - if(StringUtils.isNotBlank(rule)){ + if (StringUtils.isNotBlank(rule)) { JSONArray ruleArray = JSON.parseArray(rule); - if(CollUtil.isNotEmpty(ruleArray)){ + if (CollUtil.isNotEmpty(ruleArray)) { ruleArray.forEach(r -> { JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); Integer time = rJson.getInteger("time"); Integer adventTime = rJson.getInteger("adventTime"); - if((Objects.isNull(time) && Objects.isNull(adventTime)) && Objects.isNull(adventTime)){ - log.info("规则数据 错误 :{}",rJson); + if ((Objects.isNull(time) && Objects.isNull(adventTime)) && Objects.isNull(adventTime)) { + log.info("规则数据 错误 :{}", rJson); return; } @@ -500,56 +503,56 @@ public class EarlyWarningInstanceNotStartTask { //查询 所有这个区域的项目 未提交的项目 List needNextProjects = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class) .eq(ProjectRenewalFundDeclaration::getRegionCode, areaCode) - .eq(ProjectRenewalFundDeclaration::getDeleted,Boolean.FALSE) + .eq(ProjectRenewalFundDeclaration::getDeleted, Boolean.FALSE) .eq(ProjectRenewalFundDeclaration::getApprovalStatus, ProjectRenewalApprovalStatusEnum.PENDING.name())); - Map> noticeTypeMap = Maps.newHashMap(); + Map> noticeTypeMap = Maps.newHashMap(); //需要发通知的项目 List needToWaringProjects = needNextProjects.stream() .filter(p -> { //超时未审批 List noticeTypes = Lists.newArrayList(); - if(Objects.nonNull(time) && Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 - Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() <= time * 60 + 1){ //time * 60 + if (Objects.nonNull(time) && Duration.between(p.getCreateOn(), LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 + Duration.between(p.getCreateOn(), LocalDateTime.now()).toMinutes() <= time * 60 + 1) { //time * 60 noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode()); } - if(Objects.nonNull(adventTime) && Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 - Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1){ //time * 60 + if (Objects.nonNull(adventTime) && Duration.between(p.getCreateOn(), LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 + Duration.between(p.getCreateOn(), LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1) { //time * 60 noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); } - if(CollUtil.isNotEmpty(noticeTypes)){ - noticeTypeMap.put(p.getProjectCode(),noticeTypes); + if (CollUtil.isNotEmpty(noticeTypes)) { + noticeTypeMap.put(p.getProjectCode(), noticeTypes); //项目 运维预警 projectEarlyWarningService.earlyWarning(p.getProjectCode(), - WarningRuleTypeEnum.OPERATION_WARNING.getCode(),noticeTypes); + WarningRuleTypeEnum.OPERATION_WARNING.getCode(), noticeTypes); return Boolean.TRUE; } return Boolean.FALSE; }) .collect(Collectors.toList()); - if(StringUtils.isBlank(noticeMethod) || + if (StringUtils.isBlank(noticeMethod) || (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && - !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ + !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))) { log.info("通知方式为空或者错误!"); return; } - for(ProjectRenewalFundDeclaration needToWaringProject : needToWaringProjects){ + for (ProjectRenewalFundDeclaration needToWaringProject : needToWaringProjects) { String path = "projectStoreManage/renewalProjectAsscess?projectRenewalId=" + needToWaringProject.getId(); Project project = projectService.getProjectByCode(needToWaringProject.getProjectCode()); //去预警通知 发给区管 - List users = roleManage.getUsersByRoleType(RoleEnum.REGION_MANAGER.name(),needToWaringProject.getRegionCode()); + List users = roleManage.getUsersByRoleType(RoleEnum.REGION_MANAGER.name()); String employeesStr = users.stream().map(UserInfo::getEmployeeCode) .collect(Collectors.joining(StrPool.COMMA)); - for(UserInfo user : users){ - if(noticeTypeMap.containsKey(needToWaringProject.getProjectCode())){ + for (UserInfo user : users) { + if (noticeTypeMap.containsKey(needToWaringProject.getProjectCode())) { List noticeTypes = noticeTypeMap.get(needToWaringProject.getProjectCode()); - for(Integer noticeType : noticeTypes){ - earlyWarningManage.doEarlyWarning(noticeMethod,Objects.nonNull(noticeType)&¬iceType.equals(1) ? noticeContent : adventContent, - adventTime,time,null, - needToWaringProject.getUpdateOn(),user.getEmployeeCode(),project, - WarningRuleTypeEnum.RENEWAL_FUND.getCode(),noticeType,path,employeesStr,needToWaringProject.getId().toString()); + for (Integer noticeType : noticeTypes) { + earlyWarningManage.doEarlyWarning(noticeMethod, Objects.nonNull(noticeType) && noticeType.equals(1) ? noticeContent : adventContent, + adventTime, time, null, + needToWaringProject.getUpdateOn(), Long.valueOf(user.getEmployeeCode()), project, + WarningRuleTypeEnum.RENEWAL_FUND.getCode(), noticeType, path, employeesStr, needToWaringProject.getId().toString()); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/SynProjectCollectionTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/SynProjectCollectionTask.java index 4092d37..3d41804 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/SynProjectCollectionTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/SynProjectCollectionTask.java @@ -37,8 +37,8 @@ import java.util.StringJoiner; * @author ZPF * @since 2023/08/31 18:16 */ -@Component @Slf4j +@Component @RequiredArgsConstructor public class SynProjectCollectionTask { @@ -48,35 +48,21 @@ public class SynProjectCollectionTask { @Value("${spring.profiles.active}") public String active; - @Autowired - private GovProjectCollectionManage collectionManage; - - @Autowired - private IGovBizProjectBaseinfoService baseinfoService; - @Autowired - private IGovBizProjectApplyService applyService; - @Autowired - private IGovBizProjectApproveService approveService; - - @Autowired - private IGovBizProjectCimplementService cimplementService; - - @Autowired - private IGovBizProjectMimplementService mimplementService; - - @Autowired - private IGovBizProjectProcureService procureService; - @Autowired - private IProjectService projectService; - @Autowired - private ProjectLibManage projectLibManage; + private final GovProjectCollectionManage collectionManage; + private final IGovBizProjectBaseinfoService baseinfoService; + private final IGovBizProjectApplyService applyService; + private final IGovBizProjectApproveService approveService; + private final IGovBizProjectCimplementService cimplementService; + private final IGovBizProjectMimplementService mimplementService; + private final IGovBizProjectProcureService procureService; + private final IProjectService projectService; + private final ProjectLibManage projectLibManage; + private final FileService fileService; - @Autowired - private FileService fileService; + private static final Integer PAGE_NUMBER = 1; - private final Integer PAGE_NUMBER = 1; /** * 前置机每天晚上10点自动清空,第二天早上6点获取数据 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/staging/contants/StagingContant.java b/hz-pm-api/src/main/java/com/hz/pm/api/staging/contants/StagingContant.java index 8591833..cd76638 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/staging/contants/StagingContant.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/staging/contants/StagingContant.java @@ -6,6 +6,10 @@ package com.hz.pm.api.staging.contants; public interface StagingContant { class Retry { + + private Retry() { + } + public static final Integer MAX_RETRY_TIMES = 10; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/staging/service/impl/NdWorkNoticeStagingServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/staging/service/impl/NdWorkNoticeStagingServiceImpl.java index 75fc836..33f7749 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/staging/service/impl/NdWorkNoticeStagingServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/staging/service/impl/NdWorkNoticeStagingServiceImpl.java @@ -1,11 +1,11 @@ package com.hz.pm.api.staging.service.impl; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hz.pm.api.staging.contants.StagingContant; import com.hz.pm.api.staging.enums.MsgTypeEnum; -import com.hz.pm.api.staging.model.entity.WorkNoticeStaging; import com.hz.pm.api.staging.mapper.NdWorkNoticeStagingMapper; +import com.hz.pm.api.staging.model.entity.WorkNoticeStaging; import com.hz.pm.api.staging.service.INdWorkNoticeStagingService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hz.pm.api.staging.utils.WorkNoticeFlowMapUtil; import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo; import lombok.RequiredArgsConstructor; @@ -31,7 +31,6 @@ public class NdWorkNoticeStagingServiceImpl extends ServiceImpl 0) { dead = Boolean.TRUE; @@ -69,6 +68,7 @@ public class NdWorkNoticeStagingServiceImpl extends ServiceImpl intervalTimeMap = Maps.newHashMap(); + private static final Map INTERVAL_TIME_MAP = Maps.newHashMap(); - /** - * 扫描的间隔越来越长 秒数 - */ - public WorkNoticeFlowMapUtil(){ - intervalTimeMap.put(0,60); - intervalTimeMap.put(1,60 * 2); - intervalTimeMap.put(2,60 * 6); - intervalTimeMap.put(3,60 * 15); - intervalTimeMap.put(4,60 * 30); - intervalTimeMap.put(5,60 * 60); - intervalTimeMap.put(6,60 * 60 * 2); - intervalTimeMap.put(7,60 * 60 * 5); - intervalTimeMap.put(8,60 * 60 * 12); - intervalTimeMap.put(9,60 * 60 * 24); - intervalTimeMap.put(10,60 * 60 * 72); - intervalTimeMap.put(11,60 * 60 * 216); + + static { + INTERVAL_TIME_MAP.put(0, 60); + INTERVAL_TIME_MAP.put(1, 60 * 2); + INTERVAL_TIME_MAP.put(2, 60 * 6); + INTERVAL_TIME_MAP.put(3, 60 * 15); + INTERVAL_TIME_MAP.put(4, 60 * 30); + INTERVAL_TIME_MAP.put(5, 60 * 60); + INTERVAL_TIME_MAP.put(6, 60 * 60 * 2); + INTERVAL_TIME_MAP.put(7, 60 * 60 * 5); + INTERVAL_TIME_MAP.put(8, 60 * 60 * 12); + INTERVAL_TIME_MAP.put(9, 60 * 60 * 24); + INTERVAL_TIME_MAP.put(10, 60 * 60 * 72); + INTERVAL_TIME_MAP.put(11, 60 * 60 * 216); } + + public static Integer get(Integer times) { + return INTERVAL_TIME_MAP.get(times); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/contants/UserGuidanceContant.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/contants/UserGuidanceContant.java index 9f51129..4cb5313 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/contants/UserGuidanceContant.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/contants/UserGuidanceContant.java @@ -11,6 +11,10 @@ public interface UserGuidanceContant { Integer ALL_FINISHED_NUM = 2; class OrgModel { + + private OrgModel() { + } + public static final String GUIDANCE_NAME = "配置单位流程"; public static final String GUIDANCE_REMARK = "用户项目审核,请先配置单位默认流程"; public static final String GUIDANCE_PATH1 = "unitSet/flowPathConfiguration"; @@ -20,12 +24,20 @@ public interface UserGuidanceContant { } class FiscalCode { + + private FiscalCode() { + } + public static final String GUIDANCE_NAME = "配置财政编码"; public static final String GUIDANCE_REMARK = "用于生成项目唯一编码"; public static final String GUIDANCE_PATH = "unitSet/fiscalCodeSet"; } class Signature { + + private Signature() { + } + public static final String GUIDANCE_NAME = "配置印章编码"; public static final String GUIDANCE_REMARK = "用于电子签章"; public static final String GUIDANCE_PATH = "unitSet/fiscalCodeSet"; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/convert/RegionConverter.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/convert/RegionConverter.java index a90aa59..e5f8b91 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/convert/RegionConverter.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/convert/RegionConverter.java @@ -23,6 +23,9 @@ import java.util.stream.Collectors; */ public class RegionConverter { + private RegionConverter() { + } + public static RegionDTO toRegionDTO(Region region) { RegionDTO dto = new RegionDTO(); dto.setRegionLevel(region.getRegionLevel()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java index bfda643..b36535f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/EarlyWarningManage.java @@ -3,19 +3,18 @@ package com.hz.pm.api.sys.manage; import com.hz.pm.api.common.enumeration.CommonEnum; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.meeting.helper.YxtCallOrSmsHelper; +import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.WarningFlowTypeEnum; import com.hz.pm.api.projectlib.model.enumeration.WarningOperationTypeEnum; -import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.staging.enums.MsgTypeEnum; import com.hz.pm.api.staging.service.INdWorkNoticeStagingService; import com.hz.pm.api.sys.model.entity.Notify; import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords; import com.hz.pm.api.sys.service.IEarlyWarningRecordsService; import com.hz.pm.api.sys.service.INotifyService; -import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo; import com.hz.pm.api.user.security.model.UserFullInfoDTO; -import com.ningdatech.yxt.model.cmd.SendSmsCmd; +import com.ningdatech.yxt.model.cmd.SendSmsCmd.SendSmsContext; import com.wflow.enums.WarningNoticeTypeEnum; import com.wflow.enums.WarningRuleTypeEnum; import lombok.AllArgsConstructor; @@ -55,15 +54,15 @@ public class EarlyWarningManage { * @param noticeMethod * @param noticeContent * @param adventTimeout - * @param employeeCode + * @param userId * @param project */ public void doEarlyWarning(String noticeMethod, String noticeContent, Integer adventTimeout, Integer overTimeout, - Integer biz, LocalDateTime startTime, String employeeCode, + Integer biz, LocalDateTime startTime, Long userId, Project project, Integer ruleType, Integer noticeType, String path, String batchEmployees, String nodeId) { //1.存入 预警记录 - UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId); WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); String content; @@ -134,13 +133,13 @@ public class EarlyWarningManage { records.setNoticeContent(content); records.setProjectName(project.getProjectName()); records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY); - records.setWarningEmployeecode(employeeCode); + records.setWarningUserId(String.valueOf(userId)); records.setProjectId(project.getId()); records.setProjectCode(project.getProjectCode()); records.setProjectStatus(project.getStatus()); records.setNoticeType(noticeType); records.setPath(path); - records.setBatchEmployees(batchEmployees); + records.setBatchUserIds(batchEmployees); records.setBiz(biz); records.setNodeId(nodeId); records.setOverTime(overTimeout); @@ -153,20 +152,20 @@ public class EarlyWarningManage { //3.发短信 if (noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode()))) { - SendSmsCmd.SendSmsContext context = new SendSmsCmd.SendSmsContext(); + SendSmsContext context = new SendSmsContext(); context.setReceiveNumber(user.getMobile()); context.setContent(content); yxtCallOrSmsHelper.sendSms(context); } //4.浙政钉 - if (noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))) { + /*if (noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))) { // 获取发送浙政钉工作通知必要信息 - WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(employeeCode); + WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(userId); passWorkNoticeInfo.setMsg(content); // 放入工作通知暂存表中,通过扫表异步发送 workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); - } + }*/ } /** @@ -175,15 +174,15 @@ public class EarlyWarningManage { * @param noticeMethod * @param noticeContent * @param adventTimeout - * @param employeeCode + * @param userId * @param project */ public void urging(String noticeMethod, String noticeContent, Integer adventTimeout, Integer overTimeout, - Integer biz, LocalDateTime startTime, String employeeCode, + Integer biz, LocalDateTime startTime, Long userId, Project project, Integer ruleType, Integer noticeType, String path, String batchEmployees, String nodeId) { //1.存入 预警记录 - UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId); WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); String content; @@ -254,13 +253,13 @@ public class EarlyWarningManage { records.setNoticeContent(content); records.setProjectName(project.getProjectName()); records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY); - records.setWarningEmployeecode(employeeCode); + records.setWarningUserId(String.valueOf(userId)); records.setProjectId(project.getId()); records.setProjectCode(project.getProjectCode()); records.setProjectStatus(project.getStatus()); records.setNoticeType(noticeType); records.setPath(path); - records.setBatchEmployees(batchEmployees); + records.setBatchUserIds(batchEmployees); records.setBiz(biz); records.setNodeId(nodeId); earlyWarningRecordsService.save(records); @@ -272,20 +271,20 @@ public class EarlyWarningManage { //3.发短信 if (noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode()))) { - SendSmsCmd.SendSmsContext context = new SendSmsCmd.SendSmsContext(); + SendSmsContext context = new SendSmsContext(); context.setReceiveNumber(user.getMobile()); context.setContent(content); yxtCallOrSmsHelper.sendSms(context); } - //4.浙政钉 + /*//4.浙政钉 if (noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))) { // 获取发送浙政钉工作通知必要信息 WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(employeeCode); passWorkNoticeInfo.setMsg(content); // 放入工作通知暂存表中,通过扫表异步发送 workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); - } + }*/ } /** diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/NoticeManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/NoticeManage.java index e147c0c..144f745 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/NoticeManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/NoticeManage.java @@ -7,12 +7,6 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.model.IdVo; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.basic.util.CollUtils; -import com.ningdatech.file.entity.vo.result.AttachFileVo; -import com.ningdatech.file.service.FileService; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.organization.model.entity.DingEmployeeInfo; @@ -41,6 +35,12 @@ import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.service.IUserInfoService; import com.hz.pm.api.user.util.LoginUserUtil; +import com.ningdatech.basic.exception.BizException; +import com.ningdatech.basic.model.IdVo; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.file.entity.vo.result.AttachFileVo; +import com.ningdatech.file.service.FileService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -90,7 +90,7 @@ public class NoticeManage { @Transactional(rollbackFor = Exception.class) public IdVo saveOrModify(NoticeSaveReq req) { Notice notice = BeanUtil.copyProperties(req, Notice.class); - permissionsSave(notice,LoginUserUtil.loginUserDetail()); + permissionsSave(notice, LoginUserUtil.loginUserDetail()); noticeService.saveOrUpdate(notice); return IdVo.of(notice.getId()); } @@ -135,7 +135,7 @@ public class NoticeManage { .eq(req.getType() != null, Notice::getType, req.getType()) .orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - permissionsWrapperByEdit(wrapper,user); + permissionsWrapperByEdit(wrapper, user); Page page = noticeService.page(req.page(), wrapper); if (page.getTotal() == 0) { return PageVo.empty(); @@ -159,7 +159,7 @@ public class NoticeManage { .eq(req.getType() != null, Notice::getType, req.getType()) .orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - permissionsWrapper(wrapper,user); + permissionsWrapper(wrapper, user); Page page = noticeService.page(req.page(), wrapper); if (page.getTotal() == 0) { return PageVo.empty(); @@ -176,13 +176,13 @@ public class NoticeManage { return PageVo.of(tempDataList, page.getTotal()); } - public Map> listToMapByManager(NoticeListReq req,UserFullInfoDTO user) { + public Map> listToMapByManager(NoticeListReq req, UserFullInfoDTO user) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Notice.class) .eq(req.getEnabled() != null, Notice::getEnabled, req.getEnabled()) .like(StrUtil.isNotBlank(req.getTitle()), Notice::getTitle, req.getTitle()) .eq(req.getType() != null, Notice::getType, req.getType()) .orderByDesc(Notice::getToppedTime, Notice::getUpdateOn); - permissionsWrapper(wrapper,user); + permissionsWrapper(wrapper, user); List records = noticeService.list(wrapper); return CollUtils.convert(records, w -> NoticeListItemVO .builder() @@ -202,15 +202,16 @@ public class NoticeManage { /** * 发送消息 - * @param employeeCode 员工号 - * @param userId 用户ID - * @param project 项目 + * + * @param employeeCode 员工号 + * @param userId 用户ID + * @param project 项目 * @param procDefinitionName 流程定义名 - * @param template 消息模板内容 - * @param msgTypeEnum 枚举 + * @param template 消息模板内容 + * @param msgTypeEnum 枚举 */ public void sendNotice(String employeeCode, Long userId, Project project, String procDefinitionName, - String template, MsgTypeEnum msgTypeEnum){ + String template, MsgTypeEnum msgTypeEnum) { // 获取发送浙政钉工作通知必要信息 WorkNoticeInfo passWorkNoticeInfo = getSendWorkNoticeInfo(employeeCode); String passMsg = String.format(template, project.getProjectName(), procDefinitionName); @@ -226,13 +227,13 @@ public class NoticeManage { /** * 获取发送浙政钉工作通知的信息 * - * @param currentEmployeeCode + * @param employeeCode \ * @return com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo * @author CMM * @since 2023/02/15 14:04 */ - public WorkNoticeInfo getSendWorkNoticeInfo(String currentEmployeeCode) { - UserInfo auditUserInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class).eq(UserInfo::getEmployeeCode,currentEmployeeCode).last("limit 1")); + public WorkNoticeInfo getSendWorkNoticeInfo(String employeeCode) { + UserInfo auditUserInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class).eq(UserInfo::getEmployeeCode, employeeCode).last("limit 1")); if (Objects.isNull(auditUserInfo)) { throw new BizException("该用户不存在!"); } @@ -245,7 +246,7 @@ public class NoticeManage { // 根据浙政钉用户ID获取部门code DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) .eq(DingEmployeeInfo::getAccountId, accountId) - .eq(DingEmployeeInfo::getMainJob,String.valueOf(Boolean.TRUE)) + .eq(DingEmployeeInfo::getMainJob, String.valueOf(Boolean.TRUE)) .last("limit 1")); String organizationCode = employeeInfo.getOrganizationCode(); workNoticeInfo.setOrganizationCode(organizationCode); @@ -265,6 +266,7 @@ public class NoticeManage { /** * 装配项目审核工作通知 + * * @param userId * @param project * @param msg @@ -286,12 +288,13 @@ public class NoticeManage { /** * 找寻第一个审核人 去发消息 + * * @param project * @param formName * @param template * @param msgTypeEnum */ - public void sendFirtUser(Project project, String formName,String instanceId, String template, MsgTypeEnum msgTypeEnum) { + public void sendFirtUser(Project project, String formName, String instanceId, String template, MsgTypeEnum msgTypeEnum) { try { List activityInstances = runtimeService.createActivityInstanceQuery() .processInstanceId(instanceId) @@ -301,13 +304,13 @@ public class NoticeManage { .list(); for (ActivityInstance activityInstance : activityInstances) { - if(StringUtils.isNotBlank(activityInstance.getAssignee())){ - UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(activityInstance.getAssignee()); + if (StringUtils.isNotBlank(activityInstance.getAssignee())) { + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(Long.valueOf(activityInstance.getAssignee())); sendNotice(activityInstance.getAssignee(), user.getUserId(), project, formName, template, msgTypeEnum); } } - }catch (Exception e){ + } catch (Exception e) { log.error("发送消息失败 :" + e); } @@ -315,57 +318,51 @@ public class NoticeManage { /** * 公告保存 权限控制 - * @param notice - * @param user + * + * @param notice \ + * @param user \ */ private void permissionsSave(Notice notice, UserInfoDetails user) { List userRoleList = user.getUserRoleList(); - if(CollUtil.isEmpty(userRoleList)){ + if (CollUtil.isEmpty(userRoleList)) { //默认 权限是单位 notice.setPermissions(NoticePermissionsEnum.ORG.getCode()); - notice.setPermissionsValue(user.getEmpPosUnitCode()); + notice.setPermissionsValue(user.getMhUnitIdStr()); return; } - if(user.getSuperAdmin()){ + if (user.getSuperAdmin()) { notice.setPermissions(NoticePermissionsEnum.SUPER.getCode()); return; - }else if(user.getRegionAdmin()){ - notice.setPermissions(NoticePermissionsEnum.REGION.getCode()); - notice.setPermissionsValue(user.getRegionCode()); - return; - }else if(user.getIsOrgAdmin()){ + } else if (user.getIsOrgAdmin()) { notice.setPermissions(NoticePermissionsEnum.ORG.getCode()); - notice.setPermissionsValue(user.getEmpPosUnitCode()); + notice.setPermissionsValue(user.getMhUnitIdStr()); return; } notice.setPermissions(NoticePermissionsEnum.ORG.getCode()); - notice.setPermissionsValue(user.getEmpPosUnitCode()); + notice.setPermissionsValue(user.getMhUnitIdStr()); } /** * 列表查询 权限体现 - * @param wrapper + * + * @param wrapper \ */ - private void permissionsWrapper(LambdaQueryWrapper wrapper,UserFullInfoDTO user) { - wrapper.and(q3 -> q3.eq(Notice::getPermissions,NoticePermissionsEnum.SUPER.getCode()) - .or(q1 -> q1.eq(Notice::getPermissions,NoticePermissionsEnum.REGION.getCode()) - .eq(Notice::getPermissionsValue,user.getRegionCode())) - .or(q2 -> q2.eq(Notice::getPermissions,NoticePermissionsEnum.ORG.getCode()) - .eq(Notice::getPermissionsValue,user.getEmpPosUnitCode()))); + private void permissionsWrapper(LambdaQueryWrapper wrapper, UserFullInfoDTO user) { + wrapper.and(q3 -> q3.eq(Notice::getPermissions, NoticePermissionsEnum.SUPER.getCode()) + .or(q1 -> q1.eq(Notice::getPermissions, NoticePermissionsEnum.REGION.getCode())) + .or(q2 -> q2.eq(Notice::getPermissions, NoticePermissionsEnum.ORG.getCode()) + .eq(Notice::getPermissionsValue, user.getMhUnitId()))); } - private void permissionsWrapperByEdit(LambdaQueryWrapper wrapper,UserFullInfoDTO user) { + private void permissionsWrapperByEdit(LambdaQueryWrapper wrapper, UserFullInfoDTO user) { //如果是超管 就能看所有 - if(user.getSuperAdmin()){ + if (user.getSuperAdmin() || user.getRegionAdmin()) { log.info(user.getUsername() + ",超管可以看所有"); - }else if(user.getRegionAdmin()){ - wrapper.eq(Notice::getPermissions,NoticePermissionsEnum.REGION.getCode()) - .eq(Notice::getPermissionsValue,user.getRegionCode()); - }else if(user.getIsOrgAdmin()){ - wrapper.eq(Notice::getPermissions,NoticePermissionsEnum.ORG.getCode()) - .eq(Notice::getPermissionsValue,user.getEmpPosUnitCode()); - }else{ - wrapper.eq(Notice::getCreateOn,user.getUserId()); + } else if (user.getIsOrgAdmin()) { + wrapper.eq(Notice::getPermissions, NoticePermissionsEnum.ORG.getCode()) + .eq(Notice::getPermissionsValue, user.getMhUnitId()); + } else { + wrapper.eq(Notice::getCreateOn, user.getUserId()); } } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/RoleManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/RoleManage.java index 686f59e..724f602 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/RoleManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/RoleManage.java @@ -41,9 +41,7 @@ public class RoleManage { private final IMenuService menuService; private final IRoleMenuService roleMenuService; private final IRoleMenuDatascopeService roleMenuDatascopeService; - - private final IUserRoleService iUserRoleService; - + private final IUserRoleService userRoleService; private final IUserInfoService userInfoService; public PageVo queryList(RolePageReq rolePageReq) { @@ -94,12 +92,12 @@ public class RoleManage { Role regionRole = roleService.getOne(Wrappers.lambdaQuery(Role.class) .eq(Role::getCode, roleType) .last(BizConst.LIMIT_1)); - if(Objects.isNull(regionRole)){ + if (Objects.isNull(regionRole)) { return Collections.emptyList(); } - List userRoles = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) + List userRoles = userRoleService.list(Wrappers.lambdaQuery(UserRole.class) .eq(UserRole::getRoleId, regionRole.getId())); - if(CollUtil.isEmpty(userRoles)){ + if (CollUtil.isEmpty(userRoles)) { return Collections.emptyList(); } List userIds = userRoles.stream().map(UserRole::getUserId) @@ -107,22 +105,4 @@ public class RoleManage { return userInfoService.listByIds(userIds); } - public List getUsersByRoleType(String roleType,String regionCode) { - Role regionRole = roleService.getOne(Wrappers.lambdaQuery(Role.class) - .eq(Role::getCode, roleType) - .last(BizConst.LIMIT_1)); - if(Objects.isNull(regionRole)){ - return Collections.emptyList(); - } - List userRoles = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) - .eq(UserRole::getRoleId, regionRole.getId())); - if(CollUtil.isEmpty(userRoles)){ - return Collections.emptyList(); - } - List userIds = userRoles.stream().map(UserRole::getUserId) - .collect(Collectors.toList()); - return userInfoService.list(Wrappers.lambdaQuery(UserInfo.class) - .in(UserInfo::getId,userIds) - .eq(UserInfo::getRegionCode,regionCode)); - } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/UserGuidanceManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/UserGuidanceManage.java index 15c1198..75fa8c4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/UserGuidanceManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/UserGuidanceManage.java @@ -1,6 +1,7 @@ package com.hz.pm.api.sys.manage; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.hz.pm.api.expert.entity.ExpertUserFullInfo; @@ -56,14 +57,13 @@ public class UserGuidanceManage { /** * 查询用户引导 详情 + * * @param user * @return */ public UserGuidanceVO detailUserGuidance(UserInfoDetails user) { UserGuidanceVO vo = new UserGuidanceVO(); - //单位code - String empPosUnitCode = user.getEmpPosUnitCode(); - vo.setEmpPosUnitCode(empPosUnitCode); + vo.setOrgCode(user.getMhUnitId()); //用户信息 String username = user.getUsername(); vo.setUsername(username); @@ -79,21 +79,21 @@ public class UserGuidanceManage { Integer finishedNum = 0; //1.去查询 用户所在单位 有没有单位默认流程配置 并且process 不能为空 WflowOrgModels orgModel = orgProcdefService.getOne(Wrappers.lambdaQuery(WflowOrgModels.class) - .eq(WflowOrgModels::getOrgCode, empPosUnitCode) + .eq(WflowOrgModels::getOrgCode, user.getMhUnitId()) .eq(WflowOrgModels::getType, ProcessDefTypeEnum.DEFAULT.name()) .eq(WflowOrgModels::getIsDelete, Boolean.FALSE) .last(BizConst.LIMIT_1)); - if(Objects.isNull(orgModel)){ + if (Objects.isNull(orgModel)) { orgModelGuidance.setPath(UserGuidanceContant.OrgModel.GUIDANCE_PATH1); orgModelGuidance.setIsFinish(Boolean.FALSE); - }else{ + } else { orgModelGuidance.setPath(UserGuidanceContant.OrgModel.GUIDANCE_PATH2 + orgModel.getProcessDefId()); //判断process是否为空 - if(StringUtils.isNotBlank(orgModel.getProcess()) && - !UserGuidanceContant.OrgModel.EMPTY_PROCESS.equals(orgModel.getProcess())){ + if (StringUtils.isNotBlank(orgModel.getProcess()) && + !UserGuidanceContant.OrgModel.EMPTY_PROCESS.equals(orgModel.getProcess())) { orgModelGuidance.setIsFinish(Boolean.TRUE); - finishedNum ++; - }else{ + finishedNum++; + } else { orgModelGuidance.setIsFinish(Boolean.FALSE); } } @@ -105,22 +105,22 @@ public class UserGuidanceManage { signatureGuidance.setRemark(UserGuidanceContant.Signature.GUIDANCE_REMARK); signatureGuidance.setPath(UserGuidanceContant.Signature.GUIDANCE_PATH); CompanySignature signature = signatureService.getOne(Wrappers.lambdaQuery(CompanySignature.class) - .eq(CompanySignature::getOrganizationCode, empPosUnitCode) + .eq(CompanySignature::getOrganizationCode, user.getMhUnitId()) .last(BizConst.LIMIT_1)); - if(Objects.isNull(signature)){ + if (Objects.isNull(signature)) { signatureGuidance.setIsFinish(Boolean.FALSE); - }else{ + } else { //判断印章编码是否为空 - if(StringUtils.isNotBlank(signature.getSealSn())){ + if (StringUtils.isNotBlank(signature.getSealSn())) { signatureGuidance.setIsFinish(Boolean.TRUE); - finishedNum ++; - }else{ + finishedNum++; + } else { signatureGuidance.setIsFinish(Boolean.FALSE); } } details.add(signatureGuidance); - if(UserGuidanceContant.ALL_FINISHED_NUM.equals(finishedNum)){ + if (UserGuidanceContant.ALL_FINISHED_NUM.equals(finishedNum)) { vo.setIsAllFinished(Boolean.TRUE); } vo.setDetails(details); @@ -129,24 +129,24 @@ public class UserGuidanceManage { /** * 删除重复用户 + * * @param userId * @return */ public String removeRepeat(Long userId) { UserInfo user = userInfoService.getById(userId); - VUtils.isTrue(Objects.isNull(user)).throwMessage("该用户不存在 删除重复失败"); + Assert.notNull(user, "该用户不存在 删除重复失败"); List repeatUsers = userInfoService.list(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getUsername, user.getUsername()) .ne(UserInfo::getId, userId) .isNull(UserInfo::getAccountId)); - if(CollUtil.isNotEmpty(repeatUsers)){ + if (CollUtil.isNotEmpty(repeatUsers)) { List repeatIds = repeatUsers.stream().map(UserInfo::getId).collect(Collectors.toList()); userInfoService.removeBatchByIds(repeatIds); userAuthService.remove(Wrappers.lambdaQuery(UserAuth.class) - .in(UserAuth::getUserId,repeatIds)); - userRoleService.remove(Wrappers.lambdaQuery(UserRole.class) - .in(UserRole::getUserId,repeatIds)); - for(Long repeatId : repeatIds){ + .in(UserAuth::getUserId, repeatIds)); + userRoleService.remove(Wrappers.lambdaQuery(UserRole.class).in(UserRole::getUserId, repeatIds)); + for (Long repeatId : repeatIds) { ExpertUserFullInfo expert = expertUserFullInfoService.getByUserId(repeatId); expert.setUserId(userId); expertUserFullInfoService.updateById(expert); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/dto/RoleUpdateDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/dto/RoleUpdateDTO.java index 15fecda..cc70cb0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/dto/RoleUpdateDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/dto/RoleUpdateDTO.java @@ -27,9 +27,7 @@ import java.util.List; @EqualsAndHashCode(callSuper = false) @Builder @ApiModel(value = "RoleUpdateDTO", description = "角色") -public class RoleUpdateDTO implements Serializable { - - private static final long serialVersionUID = 1L; +public class RoleUpdateDTO { @ApiModelProperty(value = "主键") @NotNull(message = "id不能为空", groups = Update.class) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/entity/WflowEarlyWarningRecords.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/entity/WflowEarlyWarningRecords.java index bea2507..551ade1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/entity/WflowEarlyWarningRecords.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/entity/WflowEarlyWarningRecords.java @@ -81,7 +81,7 @@ public class WflowEarlyWarningRecords implements Serializable { * 预警员工号 */ @ApiModelProperty(value = "预警员工号") - private String warningEmployeecode; + private String warningUserId; /** * 通知方式 @@ -120,7 +120,7 @@ public class WflowEarlyWarningRecords implements Serializable { private String nodeId; @ApiModelProperty(value = "这一批要通知的员工号") - private String batchEmployees; + private String batchUserIds; @ApiModelProperty(value = "临期时要记录下 超期的时间") private Integer overTime; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/vo/ProjectEarlyWarningVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/vo/ProjectEarlyWarningVO.java index c88de44..a5a76dc 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/vo/ProjectEarlyWarningVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/vo/ProjectEarlyWarningVO.java @@ -68,7 +68,7 @@ public class ProjectEarlyWarningVO implements Serializable { @ApiModelProperty(value = "预警ID") private Long recordId; @ApiModelProperty(value = "预警员工号") - private String warningEmployeecode; + private String warningUserId; @ApiModelProperty(value = "通知方式 0浙政钉 1短信 逗号分隔") private String noticeMethod; @ApiModelProperty(value = "通知内容") @@ -80,7 +80,7 @@ public class ProjectEarlyWarningVO implements Serializable { @ApiModelProperty(value = "路径") private String path; @ApiModelProperty(value = "这一批要通知的员工号") - private String batchEmployees; + private String batchUserIds; private LocalDateTime createOn; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/vo/UserGuidanceVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/vo/UserGuidanceVO.java index 974721f..302f86d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/vo/UserGuidanceVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/vo/UserGuidanceVO.java @@ -38,7 +38,7 @@ public class UserGuidanceVO { * 单位code */ @ApiModelProperty(value = "单位code") - private String empPosUnitCode; + private Long orgCode; /** * 是否全部完成 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IRoleService.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IRoleService.java index aa2dbf1..07278ef 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IRoleService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IRoleService.java @@ -65,7 +65,7 @@ public interface IRoleService extends IService { * @param name / * @return 存在返回真 */ - Boolean check(String name); + boolean check(String name); /** * 校验角色名 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IUserRoleService.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IUserRoleService.java index 6af1af9..fe2b362 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IUserRoleService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IUserRoleService.java @@ -7,7 +7,6 @@ import com.hz.pm.api.common.model.constant.BizConst; import com.hz.pm.api.sys.model.entity.UserRole; import java.util.Collection; -import java.util.Collections; import java.util.List; /** @@ -36,6 +35,7 @@ public interface IUserRoleService extends IService { * @author WendyYang **/ List listUserIdByRoleId(Long roleId); + List listUserIdByRoleIds(Collection roleId); default UserRole getOne(Long userId, Long roleId) { @@ -46,4 +46,10 @@ public interface IUserRoleService extends IService { return getOne(eq); } + default List listByUserId(Long userId) { + LambdaQueryWrapper eq = Wrappers.lambdaQuery(UserRole.class) + .eq(UserRole::getUserId, userId); + return list(eq); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/impl/RoleServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/impl/RoleServiceImpl.java index 530f815..d9fd252 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/impl/RoleServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/service/impl/RoleServiceImpl.java @@ -173,7 +173,7 @@ public class RoleServiceImpl extends ServiceImpl implements IR } @Override - public Boolean check(String name) { + public boolean check(String name) { return super.count(Wrappers.lambdaQuery(Role.class).eq(Role::getName, name)) > 0; } @@ -187,7 +187,6 @@ public class RoleServiceImpl extends ServiceImpl implements IR roleMenuService.remove(Wrappers.lambdaQuery(RoleMenu.class).eq(RoleMenu::getRoleId, roleId)); if (CollUtil.isNotEmpty(menuIds)) { Set toAddMenus = new HashSet<>(); - // Set addParentIds = new HashSet<>(); for (Long menuId : menuIds) { Menu menu = menuService.getById(menuId); if (Objects.isNull(menu)) { @@ -195,8 +194,6 @@ public class RoleServiceImpl extends ServiceImpl implements IR } RoleMenu roleMenu = new RoleMenu(null, menuId, roleId); toAddMenus.add(roleMenu); - // 父级菜单 - // addParent(toAddMenus, menu, roleId, addParentIds); } if (CollUtil.isNotEmpty(toAddMenus)) { roleMenuService.saveBatch(toAddMenus); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/utils/EarlyWarningUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/utils/EarlyWarningUtil.java index a30a6bc..bf440da 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/utils/EarlyWarningUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/utils/EarlyWarningUtil.java @@ -14,51 +14,46 @@ import com.hz.pm.api.user.security.model.UserInfoDetails; */ public class EarlyWarningUtil { - public static void buildPermissonWrapper(LambdaQueryWrapper wrapper, - UserInfoDetails user) { + private EarlyWarningUtil() { + } + + public static void buildPermissionWrapper(LambdaQueryWrapper wrapper, + UserInfoDetails user) { //如果是超管的话 - if(user.getSuperAdmin()){ - //可以看所有 - //如果是区管 - }else if(user.getRegionAdmin()){ - wrapper.eq(WflowEarlyWarningRecords::getAreaCode,user.getRegionCode()); - }else if(user.getIsOrgAdmin()){ - wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()); - }else{ + if (user.getSuperAdmin() || user.getRegionAdmin()) { + // 可以看所有 + } else if (user.getIsOrgAdmin()) { + wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode, user.getMhUnitId()); + } else { //否则都只能看自己单位的 - wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()); + wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode, user.getMhUnitId()); } } - public static void buildPermissonFullWrapper(LambdaQueryWrapper wrapper, - UserFullInfoDTO user) { + public static void buildPermissionFullWrapper(LambdaQueryWrapper wrapper, + UserFullInfoDTO user) { //如果是超管的话 - if(user.getSuperAdmin()){ - //可以看所有 - //如果是区管 - }else if(user.getRegionAdmin()){ - wrapper.eq(WflowEarlyWarningRecords::getAreaCode,user.getRegionCode()); - }else if(user.getIsOrgAdmin()){ - wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()); - }else{ + if (user.getSuperAdmin() || user.getRegionAdmin()) { + // 可以看所有 + } else if (user.getIsOrgAdmin()) { + wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode, user.getMhUnitId()); + } else { //否则都只能看自己单位的 - wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode,user.getEmpPosUnitCode()); + wrapper.eq(WflowEarlyWarningRecords::getBuildOrgCode, user.getMhUnitId()); } } - public static void buildPermissonProjectWrapper(LambdaQueryWrapper wrapper, - UserFullInfoDTO user) { + public static void buildPermissionProjectWrapper(LambdaQueryWrapper wrapper, + UserFullInfoDTO user) { //如果是超管的话 - if(user.getSuperAdmin()){ - //可以看所有 - //如果是区管 - }else if(user.getRegionAdmin()){ - wrapper.eq(Project::getAreaCode,user.getRegionCode()); - }else if(user.getIsOrgAdmin()){ - wrapper.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); - }else{ + if (user.getSuperAdmin()) { + // 看所有 + } else if (user.getIsOrgAdmin()) { + wrapper.eq(Project::getBuildOrgCode, user.getMhUnitId()); + } else { //否则都只能看自己单位的 - wrapper.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); + wrapper.eq(Project::getBuildOrgCode, user.getMhUnitId()); } } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/TodoCenterConstant.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/TodoCenterConst.java similarity index 85% rename from hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/TodoCenterConstant.java rename to hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/TodoCenterConst.java index 5a1792f..9c9a156 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/TodoCenterConstant.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/TodoCenterConst.java @@ -3,10 +3,13 @@ package com.hz.pm.api.todocenter.constant; * @author ZPF * @since 2023/04/02 14:56 */ -public interface TodoCenterConstant { +public interface TodoCenterConst { class Handler { + private Handler() { + } + public static final String ACTIVITY_APPROVAL = "userTask"; public static final String OR_SIGN_FLAG = "MI_END"; @@ -16,11 +19,18 @@ public interface TodoCenterConstant { class Declared { + private Declared() { + } + public static final String NULL_INST_CODE = "EMPTY"; } class SealTemplate{ + + private SealTemplate() { + } + public static final String CITY_TEMPLATE = "市级-预审申请单"; public static final String COUNTRY_TEMPLATE = "区县-预审申请单"; public static final String CONSTRUCT_TEMPLATE = "建设方案申请单"; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/WorkNoticeConstant.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/WorkNoticeConstant.java index 4026006..8b07769 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/WorkNoticeConstant.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/constant/WorkNoticeConstant.java @@ -4,23 +4,27 @@ package com.hz.pm.api.todocenter.constant; * @author CMM * @since 2023/02/01 14:56 */ -public interface WorkNoticeConstant { - public final String PASS_MSG_TEMPLATE = "【%s】的【%s】需要您审核。"; - public final String PASS_MSG_TEMPLATE2 = "【%s】已通过【%s】,请及时开始下一步操作。"; - public final String BACK_MSG_TEMPLATE = "【%s】的【%s】被退回,请及时处理。"; - public final String REJECT_MSG_TEMPLATE = "【%s】的【%s】被驳回,请及时处理。"; +public class WorkNoticeConstant { - public final String CC_MSG_TEMPLATE = "【%s】的【%s】有消息抄送您,请查看详情"; + private WorkNoticeConstant() { + } - public final String AUDIT_WORK_TITLE = "审核任务"; + public static final String PASS_MSG_TEMPLATE = "【%s】的【%s】需要您审核。"; + public static final String PASS_MSG_TEMPLATE2 = "【%s】已通过【%s】,请及时开始下一步操作。"; + public static final String BACK_MSG_TEMPLATE = "【%s】的【%s】被退回,请及时处理。"; + public static final String REJECT_MSG_TEMPLATE = "【%s】的【%s】被驳回,请及时处理。"; - public final String EXPERT_REVIEW_TEMPLATE = "【%s】的【%s】待您评审,请及时处理。"; - public final String REVIEW_MEETING_TEMPLATE = "【%s】已完成专家抽取,请及时处理。"; - public final String WARNING_ALERT_TEMPLATE = "【%s】的【%s】待您审核,已停留2小时,请及时处理。"; + public static final String CC_MSG_TEMPLATE = "【%s】的【%s】有消息抄送您,请查看详情"; - public final String PROJECT_ID = "projectId"; - public final String INSTANCE_ID = "instanceId"; - public final String MEETING_ID = "meetingId"; + public static final String AUDIT_WORK_TITLE = "审核任务"; + + public static final String EXPERT_REVIEW_TEMPLATE = "【%s】的【%s】待您评审,请及时处理。"; + public static final String REVIEW_MEETING_TEMPLATE = "【%s】已完成专家抽取,请及时处理。"; + public static final String WARNING_ALERT_TEMPLATE = "【%s】的【%s】待您审核,已停留2小时,请及时处理。"; + + public static final String PROJECT_ID = "projectId"; + public static final String INSTANCE_ID = "instanceId"; + public static final String MEETING_ID = "meetingId"; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java index a06e647..e652664 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/handle/WithDrawHandle.java @@ -3,10 +3,11 @@ package com.hz.pm.api.todocenter.handle; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.helper.UserInfoHelper; +import com.hz.pm.api.common.util.StrUtils; import com.hz.pm.api.projectlib.model.enumeration.InstTypeEnum; import com.hz.pm.api.projectlib.model.entity.ProjectInst; import com.hz.pm.api.projectlib.service.IProjectInstService; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; @@ -51,57 +52,58 @@ public class WithDrawHandle { /** * 判断 当前流程 可否被当前登录人 所撤回 + * * @param instanceId * @param progressInstanceDetail * @return */ - public Boolean checkCanWithdraw(String instanceId, ProcessProgressVo progressInstanceDetail,String taskId) { + public Boolean checkCanWithdraw(String instanceId, ProcessProgressVo progressInstanceDetail, String taskId) { HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(instanceId).singleResult(); UserInfoDetails userInfoDetails = LoginUserUtil.loginUserDetail(); String employeeCode = userInfoDetails.getEmployeeCode(); //如果不是审核中 - if(!ProcessStatusEnum.UNDER_REVIEW.getDesc() - .equals(progressInstanceDetail.getStatus())){ + if (!ProcessStatusEnum.UNDER_REVIEW.getDesc() + .equals(progressInstanceDetail.getStatus())) { return Boolean.FALSE; } // 如果当前登录用户是流程发起人,判断流程是否已经开始审批,如果开始审批,不能撤回 Boolean userIsRoot = checkUserIsRoot(instanceId, null); - if (Boolean.TRUE.equals(userIsRoot) && canRootWithDraw(historicProcessInstance, employeeCode)){ + if (Boolean.TRUE.equals(userIsRoot) && canRootWithDraw(historicProcessInstance, employeeCode)) { return Boolean.TRUE; } ReqProcessHandlerDTO dto = new ReqProcessHandlerDTO(); dto.setTaskId(taskId); dto.setInstanceId(instanceId); - return checkUserIsBefore(progressInstanceDetail.getProgressInfo(),dto); + return checkUserIsBefore(progressInstanceDetail.getProgressInfo(), dto); } // 判断当前操作人 是上一个节点的审批人 - public Boolean checkUserIsBefore(List currentProgressInfo, ReqProcessHandlerDTO param) { + public Boolean checkUserIsBefore(List currProgressInfo, ReqProcessHandlerDTO param) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); // 先排除掉抄送任务节点 - currentProgressInfo = currentProgressInfo.stream() + currProgressInfo = currProgressInfo.stream() .filter(c -> !NodeTypeEnum.CC.name().equals(c.getNodeType().name())) .collect(Collectors.toList()); - if (CollUtil.isEmpty(currentProgressInfo)){ + if (CollUtil.isEmpty(currProgressInfo)) { return Boolean.FALSE; } String taskId = param.getTaskId(); //1.判断出 当前审批人和上一个审批人 如果传了taskid - ProgressNode progressNode = StringUtils.isBlank(taskId) ? - currentProgressInfo.get(currentProgressInfo.size() - 1) - : findSubNodeByTaskId(taskId,currentProgressInfo); + ProgressNode progressNode = StrUtils.isBlank(taskId) ? + currProgressInfo.get(currProgressInfo.size() - 1) + : findSubNodeByTaskId(taskId, currProgressInfo); - if (Objects.isNull(progressNode)){ + if (Objects.isNull(progressNode)) { return Boolean.FALSE; } - ProgressNode beforeProgressNode = null; - ProgressNode currentProgressNode = null; + ProgressNode beforeProgressNode; + ProgressNode currProgressNode; // 说明当前节点是子流程节点 // 如果是会签 或签 当前和上个 @@ -113,64 +115,62 @@ public class WithDrawHandle { children = children.stream() .filter(c -> !NodeTypeEnum.CC.name().equals(c.getNodeType().name())) .collect(Collectors.toList()); - if (CollUtil.isEmpty(children)){ + if (CollUtil.isEmpty(children)) { return Boolean.FALSE; } - currentProgressNode = children.get(children.size() - 1); + currProgressNode = children.get(children.size() - 1); //把当前和上一个节点和 会签或签的情况 都check出来 - beforeProgressNode = checkBeforeNodeAndOr(children,currentProgressNode,thisAndOr,beforeAndOr); + beforeProgressNode = checkBeforeNodeAndOr(children, currProgressNode, thisAndOr, beforeAndOr); } else { - currentProgressNode = currentProgressInfo.get(currentProgressInfo.size() - 1); + currProgressNode = currProgressInfo.get(currProgressInfo.size() - 1); // 把当前和上一个节点和 会签或签的情况 都check出来 - beforeProgressNode = checkBeforeNodeAndOr(currentProgressInfo,currentProgressNode,thisAndOr,beforeAndOr); + beforeProgressNode = checkBeforeNodeAndOr(currProgressInfo, currProgressNode, thisAndOr, beforeAndOr); } // 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 // 获取当前当前工作流任务当前审核人信息 - UserFullInfoDTO currentUserInfo = userInfoHelper.getUserFullInfoByEmployeeCode(currentProgressNode.getUserId()); - if(Objects.isNull(currentUserInfo) || !currentUserInfo.getEmpPosUnitCode().equals(user.getEmpPosUnitCode())){ + UserFullInfoDTO currUser = userInfoHelper.getUserFullInfo(Long.valueOf(currProgressNode.getUserId())); + if (Objects.isNull(currUser) || !currUser.getMhUnitId().equals(user.getMhUnitId())) { return Boolean.FALSE; } - Boolean isAndOr = Boolean.FALSE; + boolean isAndOr = Boolean.FALSE; - //判断当前子流程是否结束 如果结束了 必不能撤回 - Boolean thisSubNodeOver = Boolean.FALSE; //当前节点是 会签|或签的情况 - if(CollUtil.isNotEmpty(thisAndOr)){ + if (CollUtil.isNotEmpty(thisAndOr)) { Integer finishNodes = 0; - for(ProgressNode n : thisAndOr){ - if(Objects.nonNull(n.getFinishTime())){ + for (ProgressNode n : thisAndOr) { + if (Objects.nonNull(n.getFinishTime())) { //当前会签 有审批过的 那么上个会签|或签 无论如何 就不可能可以撤回了 beforeAndOr = Collections.emptyList(); - finishNodes ++; + finishNodes++; } //找到了 当前的操作人 在当前的 会签|或签 中 并且已经审批了 - if(n.getUserId().equals(user.getEmployeeCode()) && - Objects.nonNull(n.getFinishTime())){ + if (n.getUserId().equals(user.getUserIdStr()) && + Objects.nonNull(n.getFinishTime())) { beforeProgressNode = n; //说明当前操作人 在上个会签或者或签节点 isAndOr = Boolean.TRUE; } } //如果都审批过了 结束了 那说明此子流程已经结束了 不能再撤回了 - if(finishNodes.equals(thisAndOr.size())){ + if (finishNodes.equals(thisAndOr.size())) { return Boolean.FALSE; } - }else{ + } else { //如果当前不是会签|或签 就判断 当前最后一个节点 结束了没 //如果结束了 也同样 直接不能撤回 - if(Objects.nonNull(currentProgressNode.getFinishTime())){ + if (Objects.nonNull(currProgressNode.getFinishTime())) { return Boolean.FALSE; } } //如果上个会签没取到 还有种情况是 会签 或签 并且在上个节点 - if(!isAndOr && CollUtil.isNotEmpty(beforeAndOr)) { + if (!isAndOr && CollUtil.isNotEmpty(beforeAndOr)) { for (ProgressNode n : beforeAndOr) { - if (n.getUserId().equals(user.getEmployeeCode()) - && !TodoCenterConstant.Handler.OR_SIGN_FLAG.equals(n.getWithdrawFlag())) { + if (n.getUserId().equals(user.getUserIdStr()) + && !TodoCenterConst.Handler.OR_SIGN_FLAG.equals(n.getWithdrawFlag())) { beforeProgressNode = n; //说明当前操作人 在上个会签或者或签节点 isAndOr = Boolean.TRUE; @@ -179,47 +179,46 @@ public class WithDrawHandle { } } - if(!isAndOr && (Objects.isNull(beforeProgressNode) - || !user.getEmployeeCode().equals(beforeProgressNode.getUserId()))){ + if (!isAndOr && (Objects.isNull(beforeProgressNode) + || !user.getUserIdStr().equals(beforeProgressNode.getUserId()))) { return Boolean.FALSE; } //如果是true 把对应操作人 在上个审批节点的task 也传入 - if(Objects.nonNull(param)){ - // 获取bpmn文件中节点的连线关系,如果前一个节点的下一个节点是抄送节点, - // 获取抄送节点传入param中,在执行撤回操作时,将抄送信息从抄送表中删除 - HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery() - .processInstanceId(param.getInstanceId()) - .singleResult(); - BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()); - // 传节点定义key 获取撤回操作人在流程配置中所在的节点 - FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(beforeProgressNode.getNodeId()); - List outgoingFlows = flowNode.getOutgoingFlows(); - for (SequenceFlow outgoingFlow : outgoingFlows) { - //获取输出节点元素 - FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement(); - // 获取下一个抄送任务的节点 - if(targetFlowElement instanceof ServiceTask){ - param.setCcNodeId(targetFlowElement.getId()); - break; - } + // 获取bpmn文件中节点的连线关系,如果前一个节点的下一个节点是抄送节点, + // 获取抄送节点传入param中,在执行撤回操作时,将抄送信息从抄送表中删除 + HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery() + .processInstanceId(param.getInstanceId()) + .singleResult(); + BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()); + // 传节点定义key 获取撤回操作人在流程配置中所在的节点 + FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(beforeProgressNode.getNodeId()); + List outgoingFlows = flowNode.getOutgoingFlows(); + for (SequenceFlow outgoingFlow : outgoingFlows) { + //获取输出节点元素 + FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement(); + // 获取下一个抄送任务的节点 + if (targetFlowElement instanceof ServiceTask) { + param.setCcNodeId(targetFlowElement.getId()); + break; } - param.setTaskId(beforeProgressNode.getTaskId()); } + param.setTaskId(beforeProgressNode.getTaskId()); return Boolean.TRUE; } /** * 找到其 所在的子流程父节点 + * * @param taskId * @return */ - private ProgressNode findSubNodeByTaskId(String taskId,List currentProgressInfos) { - for(ProgressNode progressNode : currentProgressInfos){ - if(progressNode.getNodeType().equals(NodeTypeEnum.SUB)){ + private ProgressNode findSubNodeByTaskId(String taskId, List currentProgressInfos) { + for (ProgressNode progressNode : currentProgressInfos) { + if (progressNode.getNodeType().equals(NodeTypeEnum.SUB)) { List children = progressNode.getChildren(); - for(ProgressNode c : children){ - if(taskId.equals(c.getTaskId())){ + for (ProgressNode c : children) { + if (taskId.equals(c.getTaskId())) { //如果任务ID对得上 返回其 所在的子流程 return progressNode; } @@ -231,18 +230,20 @@ public class WithDrawHandle { /** * 判断撤回用户 是不是发起人 + * * @param processInstanceId * @param task * @return */ - public Boolean checkUserIsRoot(String processInstanceId,String task){ + public Boolean checkUserIsRoot(String processInstanceId, String task) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); // 获取当前要处理的流程实例 HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstanceId) .singleResult(); - if (user.getEmployeeCode().equals(instance.getStartUserId()) && - (Objects.isNull(task) || user.getEmployeeCode().equals(instance.getStartUserId()))) { + String userId = user.getUserIdStr(); + if (userId.equals(instance.getStartUserId()) && + (Objects.isNull(task) || userId.equals(instance.getStartUserId()))) { return Boolean.TRUE; } return Boolean.FALSE; @@ -251,14 +252,15 @@ public class WithDrawHandle { /** * 把上一个节点 和 或签 会签情况都check出来 + * * @param progressNodes andOr - * @param thisAndOr beforeAndOr + * @param thisAndOr beforeAndOr * @return */ - public ProgressNode checkBeforeNodeAndOr(List progressNodes,ProgressNode curr, - List thisAndOr,List beforeAndOr) { + public ProgressNode checkBeforeNodeAndOr(List progressNodes, ProgressNode curr, + List thisAndOr, List beforeAndOr) { ProgressNode beforeNode = null; - if(progressNodes.size() == 1){ + if (progressNodes.size() == 1) { return null; } //进入上一个节点的标识 @@ -267,20 +269,20 @@ public class WithDrawHandle { String thisAndOrNodeId = curr.getNodeId(); //假设 作为上一个会签/或签的第一个点 ProgressNode beforeAndOrNode = null; - for(int i = progressNodes.size() - 2;i >= 0;i--){ + for (int i = progressNodes.size() - 2; i >= 0; i--) { //说明有会签 或签 - if(progressNodes.get(i).getNodeId().equals(thisAndOrNodeId)){ + if (progressNodes.get(i).getNodeId().equals(thisAndOrNodeId)) { //还在当前节点 - if(!enterBefore){ - if(thisAndOr.isEmpty()){ + if (!enterBefore) { + if (thisAndOr.isEmpty()) { //放入当前的那个点 thisAndOr.add(curr); } thisAndOr.add(progressNodes.get(i)); } //如果在上个节点了 - else{ - if(beforeAndOr.isEmpty()){ + else { + if (beforeAndOr.isEmpty()) { //放入假设的那个点 beforeAndOr.add(beforeAndOrNode); //如果 上个节点也是 会签|或签 那么就置为null @@ -288,11 +290,11 @@ public class WithDrawHandle { } beforeAndOr.add(progressNodes.get(i)); } - }else{ + } else { thisAndOrNodeId = progressNodes.get(i).getNodeId(); //存在假设可能 beforeAndOrNode = progressNodes.get(i); - if(!enterBefore){ + if (!enterBefore) { beforeNode = progressNodes.get(i); enterBefore = Boolean.TRUE; continue; @@ -306,9 +308,10 @@ public class WithDrawHandle { /** * 1.判断 当前 撤回人 是否是 发起人 * 2.并且流程 尚未开始审批 + * * @return */ - public boolean canRootWithDraw(HistoricProcessInstance instance,String employeeCode) { + public boolean canRootWithDraw(HistoricProcessInstance instance, String employeeCode) { String startUserId = instance.getStartUserId(); // 如果是申请延期或者申请借阅审批流程,流程发起人不能撤回,直接返回false String instanceId = instance.getId(); @@ -317,24 +320,24 @@ public class WithDrawHandle { Integer instType = projectInst.getInstType(); if (InstTypeEnum.APPLY_DELAY.getCode().equals(instType) || - InstTypeEnum.APPLY_BORROW.getCode().equals(instType)){ + InstTypeEnum.APPLY_BORROW.getCode().equals(instType)) { return Boolean.FALSE; } //如果流程发起人 不是 当前登录人 直接返回false - if(StringUtils.isBlank(employeeCode) || StringUtils.isBlank(startUserId) - || !employeeCode.equals(startUserId)){ + if (StringUtils.isBlank(employeeCode) || StringUtils.isBlank(startUserId) + || !employeeCode.equals(startUserId)) { return Boolean.FALSE; } List finished = historyService.createHistoricActivityInstanceQuery() .processInstanceId(instance.getId()).finished() - .activityType(TodoCenterConstant.Handler.ACTIVITY_APPROVAL) + .activityType(TodoCenterConst.Handler.ACTIVITY_APPROVAL) .orderByHistoricActivityInstanceEndTime().asc().list(); List instances = finished.stream() .filter(a -> !HisProInsEndActId.WITHDRAW.equals(a.getDeleteReason())) .collect(Collectors.toList()); //如果有已经被审核过的 节点 返回false - if(CollUtil.isNotEmpty(instances)){ + if (CollUtil.isNotEmpty(instances)) { return Boolean.FALSE; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/HandlerManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/HandlerManage.java index 2eadbac..3a8bd21 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/HandlerManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/HandlerManage.java @@ -53,7 +53,7 @@ import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.staging.enums.MsgTypeEnum; import com.hz.pm.api.staging.service.IProjectStagingService; import com.hz.pm.api.sys.manage.NoticeManage; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.user.util.LoginUserUtil; import com.wflow.contants.HisProInsEndActId; import com.wflow.workflow.bean.process.ProgressNode; @@ -489,7 +489,7 @@ public class HandlerManage { stateMachineUtil.withDraw(declaredProject); declaredProject.setUpdateOn(LocalDateTime.now()); declaredProject.setUpdateBy(userId); - declaredProject.setInstCode(TodoCenterConstant.Declared.NULL_INST_CODE); + declaredProject.setInstCode(TodoCenterConst.Declared.NULL_INST_CODE); projectService.updateById(declaredProject); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java index d9e9e35..cc3d74e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java @@ -9,15 +9,16 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import com.hz.pm.api.common.enumeration.CommonEnum; +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.CommonConst; import com.hz.pm.api.common.model.constant.RegionConst; -import com.hz.pm.api.common.enumeration.CommonEnum; -import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.model.entity.ExcelExportWriter; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.ExcelDownUtil; @@ -38,7 +39,7 @@ import com.hz.pm.api.signature.entity.CompanySignature; import com.hz.pm.api.signature.service.ICompanySignatureService; import com.hz.pm.api.sys.model.entity.Region; import com.hz.pm.api.sys.service.IRegionService; -import com.hz.pm.api.todocenter.constant.TodoCenterConstant; +import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.todocenter.enumeration.IsAppendProjectEnum; import com.hz.pm.api.todocenter.enumeration.IsOrNotEnum; import com.hz.pm.api.todocenter.handle.PassHandle; @@ -153,19 +154,11 @@ public class TodoCenterManage { * @since 2023/02/18 */ public PageVo todoProjectList(ToBeProcessedReq param) { - String employeeCode = param.getEmployeeCode(); - if (StringUtils.isBlank(employeeCode)) { + String userIdStr = String.valueOf(param.getUserId()); + if (StringUtils.isBlank(userIdStr)) { // 获取登录用户ID Long userId = Optional.ofNullable(param.getLoginUserId()).orElseGet(LoginUserUtil::getUserId); - // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - // 获取员工浙政钉code - if (Objects.nonNull(userFullInfo)) { - employeeCode = userFullInfo.getEmployeeCode(); - } - if (StringUtils.isBlank(employeeCode)) { - return PageVo.empty(); - } + userIdStr = String.valueOf(userId); } // 查出项目库项目 @@ -184,7 +177,7 @@ public class TodoCenterManage { .orderByDesc(ProjectInst::getProjectId)); Map projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && - !TodoCenterConstant.Declared.NULL_INST_CODE.equals(p.getInstCode())) + !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); @@ -197,7 +190,7 @@ public class TodoCenterManage { Integer pageNumber = param.getPageNumber(); Integer pageSize = param.getPageSize(); req.setProcessDefId(param.getProcessDefId()); - req.setEmployeeCode(employeeCode); + req.setEmployeeCode(userIdStr); //有待办节点的(不包含退回) List todoList = processTaskService.getUserTodoList(req); //有退回待办的 @@ -274,10 +267,8 @@ public class TodoCenterManage { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - // 获取用户全量用户信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); // 获取登录用户浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); + String userIdStr = String.valueOf(userId); List userTodoList = Lists.newArrayList(); Map projectInfoMap = MapUtil.newHashMap(); @@ -285,9 +276,6 @@ public class TodoCenterManage { ProjectListReq projectListReq = new ProjectListReq(); BeanUtils.copyProperties(param, projectListReq); List projects = projectLibManage.projectList(projectListReq); - if (StringUtils.isBlank(employeeCode)) { - projects = Collections.emptyList(); - } if (CollUtil.isNotEmpty(projects)) { Map projectsMap = CollUtils.listToMap(projects, Project::getId); // 再查出项目关联的流程实例ID @@ -301,7 +289,7 @@ public class TodoCenterManage { TodoCenterListReqDTO req = new TodoCenterListReqDTO(); req.setInstCodes(instCodes); req.setProcessDefId(param.getProcessDefId()); - req.setEmployeeCode(employeeCode); + req.setEmployeeCode(userIdStr); // 有待办节点的(不包含退回) List todoList = processTaskService.getUserTodoList(req); @@ -347,7 +335,7 @@ public class TodoCenterManage { // 获取登录用户ID UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); // 获取登录用户浙政钉code - String employeeCode = user.getEmployeeCode(); + String userIdStr = user.getUserIdStr(); // 获取入参 String processInstanceId = param.getInstanceId(); Long projectId = param.getProjectId(); @@ -380,26 +368,26 @@ public class TodoCenterManage { //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); if (ObjectUtil.isNull(task)) { - return TodoCenterConstant.Handler.TASKID_ERROR; + return TodoCenterConst.Handler.TASKID_ERROR; } String nodeId = task.getTaskDefinitionKey(); // 通过该任务,流程到下一审核人处 - processTaskService.handleTask(param, employeeCode); + processTaskService.handleTask(param, userIdStr); //通过审核后 所处理的逻辑 handlerManage.afterPassTodo(declaredProject, instance); - return findNextTaskId(instance, employeeCode, nodeId, param.getTaskId()); + return findNextTaskId(instance, userIdStr, nodeId, param.getTaskId()); } // 驳回 case REJECT: { //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); if (ObjectUtil.isNull(task)) { - return TodoCenterConstant.Handler.TASKID_ERROR; + return TodoCenterConst.Handler.TASKID_ERROR; } // 驳回该任务,中止流程并使项目进入对应状态,给项目创建人、流程发起人发送浙政钉工作通知: // 【项目名称】的【流程名称】被驳回,请及时处理。 - processTaskService.handleTask(param, employeeCode); + processTaskService.handleTask(param, userIdStr); //驳回审核后 所处理的逻辑 handlerManage.afterRejectTodo(declaredProject, instance); } @@ -409,10 +397,10 @@ public class TodoCenterManage { //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); if (ObjectUtil.isNull(task)) { - return TodoCenterConstant.Handler.TASKID_ERROR; + return TodoCenterConst.Handler.TASKID_ERROR; } // 退回该任务 - processTaskService.handleTaskLs(param, employeeCode); + processTaskService.handleTaskLs(param, userIdStr); //退回审核后 所处理的逻辑 handlerManage.afterBackTodo(declaredProject, instance); } @@ -424,9 +412,9 @@ public class TodoCenterManage { * 不判断前端传的taskId * 1.先判断 用户是否是ROOT 发起人 并且流程没有开始审批 */ - if (withDrawHandle.canRootWithDraw(instance, employeeCode)) { + if (withDrawHandle.canRootWithDraw(instance, userIdStr)) { // 登录用户是流程发起人,且是流程发起人撤回 - processTaskService.rootWithdrawTask(param, employeeCode); + processTaskService.rootWithdrawTask(param, userIdStr); //发起人撤回 handlerManage.rootWithDraw(declaredProject); } else { @@ -438,13 +426,13 @@ public class TodoCenterManage { //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 HistoricTaskInstance taskInst = historyService.createHistoricTaskInstanceQuery().taskId(param.getTaskId()).finished().singleResult(); if (ObjectUtil.isNull(taskInst)) { - return TodoCenterConstant.Handler.TASKID_ERROR; + return TodoCenterConst.Handler.TASKID_ERROR; } String nodeId = taskInst.getTaskDefinitionKey(); //上个审批人处理逻辑 processTaskService.lastWithdrawTask(param); - return findNextTaskId(instance, employeeCode, nodeId, param.getTaskId()); + return findNextTaskId(instance, userIdStr, nodeId, param.getTaskId()); } } break; @@ -463,10 +451,10 @@ public class TodoCenterManage { /** * 调用IRS接口,获取盖章后的pdf文件,上传到OSS,并保存文件ID到项目库中 * - * @param req - * @param declaredProject - * @param templateName - * @param notSealedFileId + * @param req \ + * @param declaredProject \ + * @param templateName \ + * @param notSealedFileId \ * @return void * @author CMM * @since 2023/03/16 21:34 @@ -492,7 +480,7 @@ public class TodoCenterManage { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); // 获取印章编号 CompanySignature companySignature = companySignatureService.getOne(Wrappers.lambdaQuery(CompanySignature.class) - .eq(CompanySignature::getOrganizationCode, userFullInfo.getEmpPosUnitCode())); + .eq(CompanySignature::getOrganizationCode, userFullInfo.getMhUnitId())); sealSn = companySignature.getSealSn(); } else { // 区县预审时,对有上级条线主管单位并进行了盖章的情况,需要根据上次的印章编号再次盖章 @@ -532,12 +520,12 @@ public class TodoCenterManage { FileResultVO resultVo = fileService.upload(multipartFile, "default"); // 将返回的文件ID更新到项目库中对应的项目下 // 根据模版名称判断是预审申请单还是建设方案申请单 - if (TodoCenterConstant.SealTemplate.CITY_TEMPLATE.equals(templateName) || - TodoCenterConstant.SealTemplate.COUNTRY_TEMPLATE.equals(templateName)) { + if (TodoCenterConst.SealTemplate.CITY_TEMPLATE.equals(templateName) || + TodoCenterConst.SealTemplate.COUNTRY_TEMPLATE.equals(templateName)) { //放到项目申报书字段 declaredProject.setProjectApplicationForm(BizUtils.buildFileJson(resultVo)); declaredProject.setUpdateOn(LocalDateTime.now()); - } else if (TodoCenterConstant.SealTemplate.CONSTRUCT_TEMPLATE.equals(templateName)) { + } else if (TodoCenterConst.SealTemplate.CONSTRUCT_TEMPLATE.equals(templateName)) { declaredProject.setConstructFileId(resultVo.getId()); declaredProject.setConstructFileName(resultVo.getOriginalFileName()); declaredProject.setUpdateOn(LocalDateTime.now()); @@ -625,21 +613,20 @@ public class TodoCenterManage { //如果是 子流程 if (Objects.nonNull(p.getNodeType()) && NodeTypeEnum.SUB.name().equals(p.getNodeType().name())) { //如果不是上级条线单位 根本不用理 - if (!p.getIsHighLine()) { + if (Boolean.FALSE.equals(p.getIsHighLine())) { return; } List children = p.getChildren(); ProgressNode progressNode = children.get(0); String userId = progressNode.getUserId(); - if (StringUtils.isBlank(userId)) { + if (StrUtil.isBlank(userId)) { return; } - UserFullInfoDTO userFullInfoDTO = userInfoHelper.getUserFullInfoByEmployeeCode(userId); - if (Objects.nonNull(userFullInfoDTO) && user.getEmpPosUnitCode() - .equals(userFullInfoDTO.getEmpPosUnitCode())) { + UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(Long.valueOf(userId)); + if (userFullInfo != null && user.getMhUnitId().equals(userFullInfo.getMhUnitId())) { //说明是此单位的人 //那么要去看 taskId 是不是 在这个单位内的任务 - Boolean isContainsTask = HandlerManage.checkIsContainsTask(children, taskId); + boolean isContainsTask = HandlerManage.checkIsContainsTask(children, taskId); if (isContainsTask) { res[0] = Boolean.TRUE; } @@ -661,10 +648,8 @@ public class TodoCenterManage { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); // 获取登录用户浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); + String userIdStr = String.valueOf(userId); // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); @@ -681,7 +666,7 @@ public class TodoCenterManage { .orderByDesc(ProjectInst::getProjectId)); Map projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && - !TodoCenterConstant.Declared.NULL_INST_CODE.equals(p.getInstCode())) + !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); @@ -690,8 +675,8 @@ public class TodoCenterManage { Integer pageNumber = param.getPageNumber(); Integer pageSize = param.getPageSize(); req.setProcessDefId(param.getProcessDefId()); - req.setUserId(String.valueOf(userId)); - req.setEmployeeCode(employeeCode); + req.setUserId(userIdStr); + req.setEmployeeCode(userIdStr); req.setInstCodes(instCodes); List iDoList = processTaskService.getUserIdoList(req); if (CollUtil.isEmpty(iDoList)) { @@ -732,10 +717,8 @@ public class TodoCenterManage { public void idoExport(HttpServletResponse response, ToBeProcessedExportReq param) { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); // 获取登录用户浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); + String userIdStr = String.valueOf(userId); //因为要解耦 不能把项目和工作流一起查 // 查出项目库项目 @@ -754,15 +737,15 @@ public class TodoCenterManage { .orderByDesc(ProjectInst::getProjectId)); projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && - !TodoCenterConstant.Declared.NULL_INST_CODE.equals(p.getInstCode())) + !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 查出用户工作流 TodoCenterListReqDTO req = new TodoCenterListReqDTO(); req.setProcessDefId(param.getProcessDefId()); - req.setUserId(String.valueOf(userId)); - req.setEmployeeCode(employeeCode); + req.setUserId(userIdStr); + req.setEmployeeCode(userIdStr); req.setInstCodes(instCodes); userIdoList = processTaskService.getUserIdoList(req); } @@ -804,14 +787,8 @@ public class TodoCenterManage { public PageVo mySubmittedList(ToBeProcessedReq param) { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); // 获取登录用户浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); - - if (StringUtils.isBlank(employeeCode)) { - return PageVo.empty(); - } + String userIdStr = String.valueOf(userId); // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); @@ -830,7 +807,7 @@ public class TodoCenterManage { .orderByDesc(ProjectInst::getProjectId)); Map projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && - !TodoCenterConstant.Declared.NULL_INST_CODE.equals(p.getInstCode())) + !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); @@ -839,8 +816,8 @@ public class TodoCenterManage { Integer pageNumber = param.getPageNumber(); Integer pageSize = param.getPageSize(); req.setProcessDefId(param.getProcessDefId()); - req.setUserId(String.valueOf(userId)); - req.setEmployeeCode(employeeCode); + req.setUserId(userIdStr); + req.setEmployeeCode(userIdStr); req.setInstCodes(instCodes); List submittedList = processInstanceService.getUserSubmittedList(req); @@ -881,10 +858,8 @@ public class TodoCenterManage { // 获取登录用户ID long userId = LoginUserUtil.getUserId(); - // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); // 获取登录用户浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); + String userIdStr = String.valueOf(userId); // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); @@ -894,28 +869,24 @@ public class TodoCenterManage { List userSubmittedList = Lists.newArrayList(); Map projectInfoMap = Maps.newHashMap(); - if (StringUtils.isBlank(employeeCode)) { - projects = Collections.emptyList(); - } - if (CollUtil.isNotEmpty(projects)) { - Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + Map projectsMap = CollUtils.listToMap(projects, Project::getId); // 再查出项目关联的流程实例ID - List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + List projectIdList = CollUtils.fieldList(projects, Project::getId); List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList) .orderByDesc(ProjectInst::getProjectId)); projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && - !TodoCenterConstant.Declared.NULL_INST_CODE.equals(p.getInstCode())) + !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 查出用户工作流 TodoCenterListReqDTO req = new TodoCenterListReqDTO(); req.setProcessDefId(param.getProcessDefId()); - req.setUserId(String.valueOf(userId)); - req.setEmployeeCode(employeeCode); + req.setUserId(userIdStr); + req.setEmployeeCode(userIdStr); req.setInstCodes(instCodes); userSubmittedList = processInstanceService.getUserSubmittedList(req); } @@ -959,15 +930,11 @@ public class TodoCenterManage { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - // 获取登录用户浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); - + String userIdStr = String.valueOf(userId); // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); BeanUtils.copyProperties(param, projectListReq); List projects = projectLibManage.projectList(projectListReq); - if (CollUtil.isEmpty(projects)) { return PageVo.empty(); } @@ -980,7 +947,7 @@ public class TodoCenterManage { .orderByDesc(ProjectInst::getProjectId)); Map projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && - !TodoCenterConstant.Declared.NULL_INST_CODE.equals(p.getInstCode())) + !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); @@ -989,8 +956,8 @@ public class TodoCenterManage { Integer pageNumber = param.getPageNumber(); Integer pageSize = param.getPageSize(); req.setProcessDefId(param.getProcessDefId()); - req.setUserId(String.valueOf(userId)); - req.setEmployeeCode(employeeCode); + req.setUserId(userIdStr); + req.setEmployeeCode(userIdStr); req.setInstCodes(instCodes); List ccMeList = processInstanceService.getCcMeList(req); @@ -1032,11 +999,7 @@ public class TodoCenterManage { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); - // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - // 获取登录用户浙政钉code - String employeeCode = userFullInfo.getEmployeeCode(); - + String userIdStr = String.valueOf(userId); // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); BeanUtils.copyProperties(param, projectListReq); @@ -1053,15 +1016,15 @@ public class TodoCenterManage { .orderByDesc(ProjectInst::getProjectId)); projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && - !TodoCenterConstant.Declared.NULL_INST_CODE.equals(p.getInstCode())) + !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 分页查出用户工作流 TodoCenterListReqDTO req = new TodoCenterListReqDTO(); req.setProcessDefId(param.getProcessDefId()); - req.setUserId(String.valueOf(userId)); - req.setEmployeeCode(employeeCode); + req.setUserId(userIdStr); + req.setEmployeeCode(userIdStr); req.setInstCodes(instCodes); ccMeList = processInstanceService.getCcMeList(req); } @@ -1103,7 +1066,7 @@ public class TodoCenterManage { ProjectDTO projectDto = dto.getProjectInfo(); Project projectInfo = projectService.getById(projectDto.getId()); - VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("调整失败 此项目不存在!"); + Assert.notNull(projectInfo, "调整失败 此项目不存在!"); //项目名称去重 //项目名称去重 @@ -1142,8 +1105,7 @@ public class TodoCenterManage { private Boolean modifyProject(ProjectDTO projectDto, Project oldProject) { //先修改项目信息 Project project = new Project(); - VUtils.isTrue(Objects.isNull(oldProject)) - .throwMessage("项目不存在!"); + Assert.notNull(oldProject, "项目不存在!"); BeanUtil.copyProperties(oldProject, project, CopyOptions.create() .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); BeanUtil.copyProperties(projectDto, project, CopyOptions.create() @@ -1221,11 +1183,11 @@ public class TodoCenterManage { */ public NotSealedInfoVO getNotSealedPdf(SealInfoDTO req) { UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - String empPosUnitCode = user.getEmpPosUnitCode(); Long projectId = req.getProjectId(); String auditOpinion = req.getAuditOpinion(); String auditDate = NdDateUtils.format(LocalDateTime.now(), NdDateUtils.DEFAULT_DATE_TIME_FORMAT); NotSealedInfoVO notSealedInfoVo = new NotSealedInfoVO(); + String mhUnitId = user.getMhUnitId().toString(); // 判断项目盖章审批类型 Project project = projectService.getById(projectId); String buildOrgCode = project.getBuildOrgCode(); @@ -1236,154 +1198,31 @@ public class TodoCenterManage { // 如果为预审申报审批 if (InstTypeEnum.PRELIMINARY_PREVIEW.getCode().equals(instType)) { // 再根据项目所属区域判断是市级预审还是区县预审 - String areaCode = project.getAreaCode(); - String areaName = project.getArea(); Long pretrialFileId = project.getPretrialFileId(); - Region region = regionService.getOne(Wrappers.lambdaQuery(Region.class) - .eq(Region::getRegionCode, areaCode) - .eq(Region::getRegionName, areaName)); - VUtils.isTrue(Objects.isNull(region)).throwMessage("项目所属区域不存在!"); - Integer regionLevel = region.getRegionLevel(); - if (CommonEnum.LS_SBJ.getDesc().equals(areaName)) { - regionLevel = RegionConst.RL_CITY; - } // 获取项目申报时是否选择了主管单位和上级条线主管单位 // 主管单位信息 Integer isSuperOrg = project.getIsSuperOrg(); String superOrgCode = project.getSuperOrgCode(); // 上级条线主管单位信息 - Integer isHigherSuperOrg = project.getIsHigherSuperOrg(); - String higherSuperOrgCode = project.getHigherSuperOrgCode(); - switch (regionLevel) { - // 市级预审(市本级) - case RegionConst.RL_CITY: - // 如果项目关联的预审文件ID不为空,说明已经提交过审核意见,直接返回文件ID - if (Boolean.TRUE.equals(getCityNotSealedInfoVO(pretrialFileId, notSealedInfoVo))) { - return notSealedInfoVo; - } - String cityTemplateName = TodoCenterConstant.SealTemplate.CITY_TEMPLATE; - // 设置pdf模板参数 - JSONObject cityParamsMap = assemblyPdfParams(project, cityTemplateName); - // 盖章审核为主管单位审核 - if (CommonEnum.YES.getCode().equals(isSuperOrg)) { - // 有主管单位信息且登录用户所在单位是主管单位 - checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, superOrgCode, cityParamsMap); - } else if (CommonEnum.NO.getCode().equals(isSuperOrg)) { - // 没有选主管单位,默认为项目建设单位且登录用户所在单位为项目建设单位 - checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, buildOrgCode, cityParamsMap); - } - Long cityPdfId = generateNotSealedPdf(projectId, cityTemplateName, cityParamsMap); - notSealedInfoVo.setFileId(cityPdfId); - checkAuditOpinion(auditOpinion, notSealedInfoVo); - return notSealedInfoVo; - // 区县预审 - case RegionConst.RL_COUNTY: - String countryTemplateName = TodoCenterConstant.SealTemplate.COUNTRY_TEMPLATE; - String sealNo = null; - Long notSealedId = null; - // 设置pdf模板参数 - JSONObject countryParamsMap = assemblyPdfParams(project, countryTemplateName); - // 以是否有上级主管单位的维度判断(有上级条线主管单位,才有可能需要盖两次章) - if (CommonEnum.YES.getCode().equals(isHigherSuperOrg)) { - // 盖章审核登录用户所在单位为上级条线主管单位,此时为区县预审盖章流程第一个章 - if (empPosUnitCode.equals(higherSuperOrgCode)) { - // 有上级条线主管单位信息且登录用户所在单位是上级条线主管单位, - // 如果项目关联的预审文件ID和上级条线审核意见不为空,说明已经提交过审核意见,直接返回文件ID - if (Boolean.TRUE.equals(getCountryHigherNotSealedInfoVO(pretrialFileId, notSealedInfoVo, - project.getCountryHigherSealAuditOpinion()))) { - return notSealedInfoVo; - } - countryParamsMap.put("higherOrgOpinion", auditOpinion); - countryParamsMap.put("higherOrgAuditDate", auditDate); - // 获取上级条线主管单位印章编号 - CompanySignature companySignature = - companySignatureService.getOne(Wrappers.lambdaQuery(CompanySignature.class) - .eq(CompanySignature::getOrganizationCode, higherSuperOrgCode)); - if (Objects.nonNull(companySignature)) { - sealNo = companySignature.getSealSn(); - } - // 保存区县预审上级条线主管单位盖章审核意见、审核日期和盖章编号 - project.setCountryHigherSealNo(sealNo); - project.setCountryHigherSealAuditOpinion(auditOpinion); - project.setCountryHigherSealAuditDate(auditDate); - projectService.updateById(project); - countryParamsMap.put("superOrgOpinion", null); - countryParamsMap.put("superOrgAuditDate", null); - // 直接返回装填了上级条线主管单位意见的未盖章文件 - notSealedId = generateNotSealedPdf(projectId, countryTemplateName, countryParamsMap); - } - // 盖章审核登录用户所在单位不为上级条线主管单位(可能为选择的主管单位、项目建设单位、其他单位), - // 此时为区县预审盖章流程第二个章 - else if (CommonEnum.YES.getCode().equals(isSuperOrg)) { - // 有上级条线主管单位信息且有本级主管单位信息 - // 有主管单位信息且登录用户所在单位是主管单位 - // 装配本级主管单位审核意见 - // 如果项目关联的预审文件ID和上级条线审核意见以及区县审核意见不为空,说明已经提交过审核意见,直接返回文件ID - if (Boolean.TRUE.equals(getCountryNotSealedInfoVO(pretrialFileId, notSealedInfoVo, - project.getCountryHigherSealAuditOpinion(), project.getCountrySealAuditOpinion()))) { - return notSealedInfoVo; - } - // 保存区县本级主管单位盖章审核意见、审核日期 - project.setCountrySealAuditOpinion(auditOpinion); - project.setCountrySealAuditDate(auditDate); - projectService.updateById(project); - checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, superOrgCode, countryParamsMap); - // 装配上级条线主管单位意见,调用盖章接口, - // 重新生成上级条线主管单位盖章而本级主管单位未盖章的pdf文件 - SealInfoDTO sealInfoDTO = getHigherSealInfoDTO(project, countryParamsMap); - Long notSealedPdfId = generateNotSealedPdf(projectId, countryTemplateName, countryParamsMap); - notSealedId = generateSealedPdf(sealInfoDTO, project, countryTemplateName, notSealedPdfId); - } else if (CommonEnum.NO.getCode().equals(isSuperOrg)) { - // 有上级条线主管单位信息,没有本级主管单位信息 - // 没有选主管单位,默认为项目建设单位且登录用户所在单位为项目建设单位 - // 如果项目关联的预审文件ID和上级条线审核意见以及区县审核意见不为空,说明已经提交过审核意见,直接返回文件ID - if (Boolean.TRUE.equals(getCountryNotSealedInfoVO(pretrialFileId, notSealedInfoVo, - project.getCountryHigherSealAuditOpinion(), project.getCountrySealAuditOpinion()))) { - return notSealedInfoVo; - } - // 保存区县本级主管单位盖章审核意见、审核日期 - project.setCountrySealAuditOpinion(auditOpinion); - project.setCountrySealAuditDate(auditDate); - projectService.updateById(project); - checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, buildOrgCode, countryParamsMap); - // 装配上级条线主管单位意见,调用盖章接口, - // 重新生成上级条线主管单位盖章而本级主管单位未盖章的pdf文件 - SealInfoDTO sealInfoDTO = getHigherSealInfoDTO(project, countryParamsMap); - Long notSealedPdfId = generateNotSealedPdf(projectId, countryTemplateName, countryParamsMap); - notSealedId = generateSealedPdf(sealInfoDTO, project, countryTemplateName, notSealedPdfId); - } - } - // 没有上级主管条线单位 - else if (CommonEnum.NO.getCode().equals(isHigherSuperOrg)) { - // 如果项目关联的预审文件ID不为空,说明已经提交过审核意见,直接返回文件ID - if (Boolean.TRUE.equals(getCityNotSealedInfoVO(pretrialFileId, notSealedInfoVo))) { - return notSealedInfoVo; - } - // 有本级主管单位信息 - if (CommonEnum.YES.getCode().equals(isSuperOrg)) { - // 登录用户所在单位是本级主管单位,装配本级主管单位审核意见 - checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, superOrgCode, countryParamsMap); - // 直接返回装配了本级主管单位审核意见的未盖章文件 - countryParamsMap.put("higherOrgOpinion", null); - countryParamsMap.put("higherOrgAuditDate", null); - notSealedId = generateNotSealedPdf(projectId, countryTemplateName, countryParamsMap); - } - // 没有选主管单位,默认为项目建设单位 - else if (CommonEnum.NO.getCode().equals(isSuperOrg)) { - // 登录用户所在单位为项目建设单位 - checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, buildOrgCode, countryParamsMap); - // 直接返回装配了项目建设单位审核意见的未盖章文件 - countryParamsMap.put("higherOrgOpinion", null); - countryParamsMap.put("higherOrgAuditDate", null); - notSealedId = generateNotSealedPdf(projectId, countryTemplateName, countryParamsMap); - } - } - notSealedInfoVo.setFileId(notSealedId); - checkAuditOpinion(auditOpinion, notSealedInfoVo); - return notSealedInfoVo; - default: - throw new IllegalStateException("Unexpected value: " + regionLevel); + // 如果项目关联的预审文件ID不为空,说明已经提交过审核意见,直接返回文件ID + if (Boolean.TRUE.equals(getCityNotSealedInfoVO(pretrialFileId, notSealedInfoVo))) { + return notSealedInfoVo; } + String cityTemplateName = TodoCenterConst.SealTemplate.CITY_TEMPLATE; + // 设置pdf模板参数 + JSONObject cityParamsMap = assemblyPdfParams(project, cityTemplateName); + // 盖章审核为主管单位审核 + if (CommonEnum.YES.getCode().equals(isSuperOrg)) { + // 有主管单位信息且登录用户所在单位是主管单位 + checkEmpPosUnitCode(mhUnitId, auditOpinion, auditDate, superOrgCode, cityParamsMap); + } else if (CommonEnum.NO.getCode().equals(isSuperOrg)) { + // 没有选主管单位,默认为项目建设单位且登录用户所在单位为项目建设单位 + checkEmpPosUnitCode(mhUnitId, auditOpinion, auditDate, buildOrgCode, cityParamsMap); + } + Long cityPdfId = generateNotSealedPdf(projectId, cityTemplateName, cityParamsMap); + notSealedInfoVo.setFileId(cityPdfId); + checkAuditOpinion(auditOpinion, notSealedInfoVo); + return notSealedInfoVo; } // 如果为建设方案申报审批 else if (InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode().equals(instType)) { @@ -1393,7 +1232,7 @@ public class TodoCenterManage { return notSealedInfoVo; } // 设置pdf模板参数 - String constructTemplateName = TodoCenterConstant.SealTemplate.CONSTRUCT_TEMPLATE; + String constructTemplateName = TodoCenterConst.SealTemplate.CONSTRUCT_TEMPLATE; JSONObject constructParamsMap = assemblyPdfParams(project, constructTemplateName); // 审核为指定大数据局盖章 // 获取流程配置的指定单位信息 @@ -1422,41 +1261,6 @@ public class TodoCenterManage { return false; } - private Boolean getCountryHigherNotSealedInfoVO(Long fileId, NotSealedInfoVO notSealedInfoVo, String auditOpinion) { - if (Objects.nonNull(fileId) && StringUtils.isNotBlank(auditOpinion)) { - notSealedInfoVo.setFileId(fileId); - notSealedInfoVo.setIsCommit(Boolean.TRUE); - return true; - } - return false; - } - - private Boolean getCountryNotSealedInfoVO(Long fileId, NotSealedInfoVO notSealedInfoVo, String higherAuditOpinion, - String auditOpinion) { - if (Objects.nonNull(fileId) && StringUtils.isNotBlank(higherAuditOpinion) - && StringUtils.isNotBlank(auditOpinion)) { - notSealedInfoVo.setFileId(fileId); - notSealedInfoVo.setIsCommit(Boolean.TRUE); - return true; - } - return false; - } - - private SealInfoDTO getHigherSealInfoDTO(Project project, JSONObject countryParamsMap) { - String countrySealAuditOpinion = project.getCountryHigherSealAuditOpinion(); - String countrySealAuditDate = project.getCountryHigherSealAuditDate(); - countryParamsMap.put("higherOrgOpinion", countrySealAuditOpinion); - countryParamsMap.put("higherOrgAuditDate", countrySealAuditDate); - SealInfoDTO sealInfoDTO = new SealInfoDTO(); - sealInfoDTO.setPosPage(TodoCenterConstant.SealTemplate.COUNTRY_SEAL_POS_PAGE); - sealInfoDTO.setProjectId(project.getId()); - sealInfoDTO.setPosX(TodoCenterConstant.SealTemplate.COUNTRY_SEAL_POS_X); - sealInfoDTO.setPosY(TodoCenterConstant.SealTemplate.COUNTRY_SEAL_POS_Y); - sealInfoDTO.setSignType(TodoCenterConstant.SealTemplate.COUNTRY_SEAL_SIGN_TYPE); - sealInfoDTO.setSealSn(project.getCountryHigherSealNo()); - return sealInfoDTO; - } - private void checkEmpPosUnitCode(String empPosUnitCode, String auditOpinion, String auditDate, String orgCode, JSONObject cityParamsMap) { if (empPosUnitCode.equals(orgCode)) { cityParamsMap.put("superOrgOpinion", auditOpinion); @@ -1493,12 +1297,12 @@ public class TodoCenterManage { String superOrgOpinion = paramsMap.getString("superOrgOpinion"); String higherOrgOpinion = paramsMap.getString("higherOrgOpinion"); if (StringUtils.isNotBlank(superOrgOpinion) || StringUtils.isNotBlank(higherOrgOpinion)) { - if (TodoCenterConstant.SealTemplate.CITY_TEMPLATE.equals(templateName) || - TodoCenterConstant.SealTemplate.COUNTRY_TEMPLATE.equals(templateName)) { + if (TodoCenterConst.SealTemplate.CITY_TEMPLATE.equals(templateName) || + TodoCenterConst.SealTemplate.COUNTRY_TEMPLATE.equals(templateName)) { //放到项目申报书字段 declaredProject.setProjectApplicationForm(BizUtils.buildFileJson(resultVo)); declaredProject.setUpdateOn(LocalDateTime.now()); - } else if (TodoCenterConstant.SealTemplate.CONSTRUCT_TEMPLATE.equals(templateName)) { + } else if (TodoCenterConst.SealTemplate.CONSTRUCT_TEMPLATE.equals(templateName)) { declaredProject.setConstructFileId(resultVo.getId()); declaredProject.setConstructFileName(resultVo.getOriginalFileName()); declaredProject.setUpdateOn(LocalDateTime.now()); @@ -1676,11 +1480,11 @@ public class TodoCenterManage { switch (regionLevel) { // 市级预审(市本级) case RegionConst.RL_CITY: - String cityTemplateName = TodoCenterConstant.SealTemplate.CITY_TEMPLATE; + String cityTemplateName = TodoCenterConst.SealTemplate.CITY_TEMPLATE; return generateSealedPdf(req, declaredProject, cityTemplateName, notSealedFileId); // 区县预审 case RegionConst.RL_COUNTY: - String countryTemplateName = TodoCenterConstant.SealTemplate.COUNTRY_TEMPLATE; + String countryTemplateName = TodoCenterConst.SealTemplate.COUNTRY_TEMPLATE; return generateSealedPdf(req, declaredProject, countryTemplateName, notSealedFileId); default: throw new IllegalStateException("Unexpected value: " + regionLevel); @@ -1689,30 +1493,26 @@ public class TodoCenterManage { // 如果为建设方案申报审批 else if (InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode().equals(instType)) { // 设置pdf模板参数 - String constructTemplateName = TodoCenterConstant.SealTemplate.CONSTRUCT_TEMPLATE; + String constructTemplateName = TodoCenterConst.SealTemplate.CONSTRUCT_TEMPLATE; return generateSealedPdf(req, declaredProject, constructTemplateName, notSealedFileId); } return null; } //获取当前登录人的 待办中心统计数据 - public TodoCenterStatisticsVO todoCenterStatistics(String employeeCode) { + public TodoCenterStatisticsVO todoCenterStatistics(Long userId) { //为了查询效率 还是自己去写统计接口 - TodoCenterStatisticsPO statistics = statisticsService.getStatistics(employeeCode); + TodoCenterStatisticsPO statistics = statisticsService.getStatistics(userId); return BeanUtil.copyProperties(statistics, TodoCenterStatisticsVO.class); } public TodoNumVO getTodoNums(ToBeProcessedReq param) { // 获取登录用户ID Long userId = LoginUserUtil.getUserId(); + String userIdStr = String.valueOf(userId); // 获取登录用户全量信息 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); // 获取员工浙政钉code TodoNumVO todoNumVo = new TodoNumVO(); - String employeeCode = userFullInfo.getEmployeeCode(); - if (StringUtils.isBlank(employeeCode)) { - return todoNumVo; - } // 查出项目库项目 ProjectListReq projectListReq = new ProjectListReq(); @@ -1732,8 +1532,8 @@ public class TodoCenterManage { TodoCenterListReqDTO req = new TodoCenterListReqDTO(); req.setInstCodes(instCodes); req.setProcessDefId(param.getProcessDefId()); - req.setUserId(String.valueOf(userId)); - req.setEmployeeCode(employeeCode); + req.setUserId(userIdStr); + req.setEmployeeCode(userIdStr); //有待办节点的(不包含退回) List todoList = processTaskService.getUserTodoList(req); //有退回待办的 @@ -1751,7 +1551,7 @@ public class TodoCenterManage { Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); Map projectInfoMap = projectInstList.stream() .filter(p -> StringUtils.isNotBlank(p.getInstCode()) && - !TodoCenterConstant.Declared.NULL_INST_CODE.equals(p.getInstCode())) + !TodoCenterConst.Declared.NULL_INST_CODE.equals(p.getInstCode())) .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); // 关联项目信息 List projectList = list.stream() @@ -1835,14 +1635,11 @@ public class TodoCenterManage { public Object saveAuditOpinion(ReqAuditOpinionSaveDTO param) { // 获取登录用户ID UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); - // 获取登录用户浙政钉code - String employeeCode = user.getEmployeeCode(); - //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); if (ObjectUtil.isNull(task)) { - return TodoCenterConstant.Handler.TASKID_ERROR; + return TodoCenterConst.Handler.TASKID_ERROR; } - return processTaskService.saveAuditOpinion(param, employeeCode); + return processTaskService.saveAuditOpinion(param, user.getUserIdStr()); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/model/dto/AdjustHandleDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/model/dto/AdjustHandleDTO.java index 353fc50..b1704ce 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/model/dto/AdjustHandleDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/model/dto/AdjustHandleDTO.java @@ -1,19 +1,16 @@ package com.hz.pm.api.todocenter.model.dto; -import java.io.Serializable; -import java.util.Map; - -import javax.validation.constraints.NotNull; - +import cn.hutool.core.collection.CollUtil; import com.google.common.collect.Maps; import com.hz.pm.api.projectlib.model.dto.ProjectDTO; - -import cn.hutool.core.collection.CollUtil; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.constraints.NotNull; +import java.util.Map; + /** * @Classname DefaultDeclaredDTO * @Description @@ -23,24 +20,23 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor -public class AdjustHandleDTO implements Serializable { - - private static final long serialVersionUID = 1L; +public class AdjustHandleDTO { @NotNull @ApiModelProperty("项目信息") private ProjectDTO projectInfo; @ApiModelProperty("表单信息 新增模块") - private Map formData; + private Map formData; - public Map getFormData(){ - if(CollUtil.isEmpty(this.formData)){ + public Map getFormData() { + if (CollUtil.isEmpty(this.formData)) { this.formData = Maps.newHashMap(); return this.formData; } return this.formData; } + @ApiModelProperty("项目ID") @NotNull(message = "要处理的项目ID不能为空!") private Long projectId; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/model/req/ToBeProcessedReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/model/req/ToBeProcessedReq.java index fb379d5..bbbf202 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/model/req/ToBeProcessedReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/model/req/ToBeProcessedReq.java @@ -8,6 +8,7 @@ import com.ningdatech.basic.model.PagePo; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; @@ -20,12 +21,15 @@ import org.springframework.format.annotation.DateTimeFormat; @Data @NoArgsConstructor @AllArgsConstructor +@EqualsAndHashCode(callSuper = true) public class ToBeProcessedReq extends PagePo implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("项目名称") private String projectName; + private Long userId; + @ApiModelProperty("申报单位名称") private String buildOrgName; @@ -46,9 +50,6 @@ public class ToBeProcessedReq extends PagePo implements Serializable { @ApiModelProperty("流程配置ID") private String processDefId; - @ApiModelProperty("登录人员工号") - private String employeeCode; - private Long loginUserId; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/StatisticsService.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/StatisticsService.java index 99726e6..f11680f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/StatisticsService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/StatisticsService.java @@ -11,5 +11,5 @@ import com.hz.pm.api.todocenter.model.po.TodoCenterStatisticsPO; public interface StatisticsService { //根据用户id 去查询 一些统计数据 - TodoCenterStatisticsPO getStatistics(String employeeCode); + TodoCenterStatisticsPO getStatistics(Long userId); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/impl/StatisticsServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/impl/StatisticsServiceImpl.java index b4e6189..1dd5bf2 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/impl/StatisticsServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/impl/StatisticsServiceImpl.java @@ -28,23 +28,23 @@ public class StatisticsServiceImpl implements StatisticsService { private final TaskService taskService; @Override - public TodoCenterStatisticsPO getStatistics(String employeeCode) { + public TodoCenterStatisticsPO getStatistics(Long userId) { TodoCenterStatisticsPO res = new TodoCenterStatisticsPO(); - + String userIdStr = String.valueOf(userId); TodoCenterListReqDTO req = new TodoCenterListReqDTO(); - req.setEmployeeCode(employeeCode); + req.setEmployeeCode(userIdStr); Integer todoCount = processTaskService.getTodoCount(req); res.setTodoNum(todoCount); Integer idoCount = processTaskService.getUserIdoCount(req); res.setIdoNum(idoCount); - TodoCenterStatisticsPO submit = mapper.mysubmitNum(employeeCode); + TodoCenterStatisticsPO submit = mapper.mysubmitNum(userIdStr); if(Objects.nonNull(submit)){ res.setMysubmitNum(submit.getMysubmitNum()); } - TodoCenterStatisticsPO ccMe = mapper.ccNums(employeeCode); + TodoCenterStatisticsPO ccMe = mapper.ccNums(userIdStr); if(Objects.nonNull(ccMe)){ res.setCcmeNum(ccMe.getCcmeNum()); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/impl/TodoServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/impl/TodoServiceImpl.java index 768111f..665df6a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/impl/TodoServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/service/impl/TodoServiceImpl.java @@ -117,15 +117,14 @@ public class TodoServiceImpl implements ITodoService { if(StringUtils.isBlank(userId)){ return; } - UserFullInfoDTO userFullInfoDTO = userInfoHelper.getUserFullInfoByEmployeeCode(userId); - if(Objects.nonNull(userFullInfoDTO) && user.getEmpPosUnitCode() - .equals(userFullInfoDTO.getEmpPosUnitCode())){ + UserFullInfoDTO userFullInfoDTO = userInfoHelper.getUserFullInfo(Long.valueOf(userId)); + if(Objects.nonNull(userFullInfoDTO) && user.getMhUnitId() + .equals(userFullInfoDTO.getMhUnitId())){ //说明是此单位的人 //那么要去看 taskId 是不是 在这个单位内的任务 boolean isContainsTask = HandlerManage.checkIsContainsTask(children,taskId); if(isContainsTask){ res[0] = Boolean.TRUE; - return; } } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/utils/BuildUserUtils.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/utils/BuildUserUtils.java index d696ed4..ac2784b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/utils/BuildUserUtils.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/utils/BuildUserUtils.java @@ -3,6 +3,7 @@ package com.hz.pm.api.todocenter.utils; import cn.hutool.core.collection.CollUtil; import com.google.common.collect.Sets; import com.hz.pm.api.user.manage.UserInfoManage; +import com.ningdatech.basic.util.CollUtils; import com.wflow.workflow.bean.dto.ProcessInstanceUserDto; import com.wflow.workflow.bean.process.ProgressNode; import lombok.RequiredArgsConstructor; @@ -37,9 +38,11 @@ public class BuildUserUtils { userSet.add(node.getUserId()); } }); - Map userMap = userInfoManage.getUserMapByEmployeeCode(userSet); - buildUser(progressInfo,userMap); + List tmpUserIds = CollUtils.convert(userSet, Long::parseLong); + Map userMap = userInfoManage.getUserMapByUserIds(tmpUserIds); + buildUser(progressInfo, userMap); } + private void buildUser(List progressInfo, Map userMap) { for (ProgressNode progressNode : progressInfo) { progressNode.setUser(userMap.get(progressNode.getUserId())); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/UserAuthController.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/UserAuthController.java index b57aeef..b88db3d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/UserAuthController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/UserAuthController.java @@ -10,7 +10,7 @@ import com.hz.pm.api.user.util.LoginUserUtil; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.util.StrPool; import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.user.security.auth.constants.SessionTimeConstant; +import com.hz.pm.api.user.security.auth.constants.SessionTimeConst; import com.ningdatech.log.annotation.WebLog; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -86,7 +86,7 @@ public class UserAuthController { response.setContentType(StrPool.CONTENT_TYPE); Cookie cookie = new Cookie(BizConst.COOKIE_KEY, null); cookie.setPath(request.getContextPath() + "/"); - cookie.setMaxAge(SessionTimeConstant.SESSION_EXPIRED); + cookie.setMaxAge(SessionTimeConst.SESSION_EXPIRED); response.addCookie(cookie); response.setStatus(HttpStatus.UNAUTHORIZED.value()); response.getWriter().write(objectMapper.writeValueAsString(BizConst.UNAUTHENTICATED)); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/UserInfoController.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/UserInfoController.java index 17dfa6f..31b309d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/UserInfoController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/UserInfoController.java @@ -1,16 +1,16 @@ package com.hz.pm.api.user.controller; -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.log.annotation.WebLog; import com.hz.pm.api.user.manage.UserInfoManage; import com.hz.pm.api.user.model.po.ReqUserDetailEditPO; -import com.hz.pm.api.user.model.po.ReqUserDetailPO; import com.hz.pm.api.user.model.po.ReqUserDisableOrEnablePO; -import com.hz.pm.api.user.model.po.ReqUserInfoListPO; +import com.hz.pm.api.user.model.po.UserDetailReq; +import com.hz.pm.api.user.model.po.UserInfoListReq; import com.hz.pm.api.user.model.vo.ResUserDetailVO; -import com.hz.pm.api.user.model.vo.ResUserInfoListVO; +import com.hz.pm.api.user.model.vo.UserInfoListVO; import com.hz.pm.api.user.model.vo.UserRoleVO; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.log.annotation.WebLog; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -36,7 +36,7 @@ public class UserInfoController { @ApiOperation(value = "用户列表搜索", notes = "用户列表搜索") @PostMapping("/list") - public PageVo userInfoList(@Valid @RequestBody ReqUserInfoListPO req) { + public PageVo userInfoList(@Valid @RequestBody UserInfoListReq req) { return userInfoManage.list(req); } @@ -48,7 +48,7 @@ public class UserInfoController { @ApiOperation(value = "用户详情", notes = "用户详情") @PostMapping("/detail") - public ResUserDetailVO userInfoDetail(@Valid @RequestBody ReqUserDetailPO req) { + public ResUserDetailVO userInfoDetail(@Valid @RequestBody UserDetailReq req) { return userInfoManage.userInfoDetail(req); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java index d2ece63..c0b27bf 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/convert/UserInfoConvertor.java @@ -23,19 +23,13 @@ public class UserInfoConvertor { userInfoDetails.setUsername(userFullInfo.getUsername()); userInfoDetails.setRealName(userFullInfo.getRealName()); userInfoDetails.setUserRoleList(userFullInfo.getUserRoleList()); - userInfoDetails.setRegionCode(userFullInfo.getRegionCode()); - userInfoDetails.setRegionLevel(userFullInfo.getRegionLevel()); userInfoDetails.setIdentifier(userFullInfo.getIdentifier()); userInfoDetails.setPassword(userFullInfo.getCredential()); - userInfoDetails.setEmployeeCode(userFullInfo.getEmployeeCode()); - userInfoDetails.setOrganizationCode(userFullInfo.getOrganizationCode()); - userInfoDetails.setOrganizationName(userFullInfo.getOrganizationName()); - userInfoDetails.setEmpPosUnitCode(userFullInfo.getEmpPosUnitCode()); - userInfoDetails.setEmpPosUnitName(userFullInfo.getEmpPosUnitName()); + userInfoDetails.setMhUnitId(userFullInfo.getMhUnitId()); + userInfoDetails.setMhUnitName(userFullInfo.getMhUnitName()); userInfoDetails.setMobile(userFullInfo.getMobile()); + userInfoDetails.setMhUserId(userFullInfo.getMhUserId()); return userInfoDetails; } - - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java index 0678e6a..e1bb6b9 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java @@ -3,6 +3,8 @@ package com.hz.pm.api.user.manage; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hz.pm.api.user.helper.MhUnitCache; +import com.hz.pm.api.user.model.dto.MhUnitDTO; import com.hz.pm.api.user.model.dto.MhUnitTreeDTO; import com.hz.pm.api.user.model.entity.MhUnit; import com.hz.pm.api.user.service.IMhUnitService; @@ -25,12 +27,11 @@ import java.util.List; public class MhUnitManage { private final IMhUnitService mhUnitService; + private final MhUnitCache mhUnitCache; public List getMhUnitTree() { - LambdaQueryWrapper query = Wrappers.lambdaQuery(MhUnit.class) - .select(MhUnit::getId, MhUnit::getName, MhUnit::getParentId, MhUnit::getSort); - List units = mhUnitService.list(query); - List nodes = BeanUtil.copyToList(units, MhUnitTreeDTO.class); + List allUnits = mhUnitCache.all(); + List nodes = BeanUtil.copyToList(allUnits, MhUnitTreeDTO.class); return TreeUtil.convertToTree(nodes, 0L); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java index adb95ff..27a2d5f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java @@ -92,10 +92,9 @@ public class SyncMhUserOrgManage { userInfo.setRealName(mhUser.getUserName()); userInfo.setUsername(mhUser.getAccount()); userInfo.setId(userIdMap.get(mhUser.getUserId())); - userInfo.setRegionCode("330100"); MhUnit unit = unitMap.get(mhUser.getMhUnitId()); if (unit != null) { - userInfo.setEmpPosUnitName(unit.getName()); + userInfo.setMhUnitName(unit.getName()); } if (PhoneUtil.isMobile(mhUser.getAccount())) { userInfo.setMobile(mhUser.getAccount()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java index d6d6e10..baec1c8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java @@ -7,12 +7,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.helper.RegionCacheHelper; import com.hz.pm.api.common.helper.UserInfoHelper; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.StrUtils; -import com.hz.pm.api.ding.constants.DingOrganizationContant; import com.hz.pm.api.organization.model.entity.DingEmployeeInfo; -import com.hz.pm.api.organization.model.entity.DingOrganization; import com.hz.pm.api.organization.service.IDingEmployeeInfoService; import com.hz.pm.api.organization.service.IDingOrganizationService; import com.hz.pm.api.sys.model.entity.Role; @@ -22,17 +19,16 @@ import com.hz.pm.api.sys.service.IUserRoleService; import com.hz.pm.api.user.model.entity.UserInfo; import com.hz.pm.api.user.model.enumeration.UserAvailableEnum; import com.hz.pm.api.user.model.po.ReqUserDetailEditPO; -import com.hz.pm.api.user.model.po.ReqUserDetailPO; +import com.hz.pm.api.user.model.po.UserDetailReq; import com.hz.pm.api.user.model.po.ReqUserDisableOrEnablePO; -import com.hz.pm.api.user.model.po.ReqUserInfoListPO; +import com.hz.pm.api.user.model.po.UserInfoListReq; import com.hz.pm.api.user.model.vo.ResUserDetailVO; -import com.hz.pm.api.user.model.vo.ResUserInfoListVO; +import com.hz.pm.api.user.model.vo.UserInfoListVO; import com.hz.pm.api.user.model.vo.UserRoleVO; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.service.IUserInfoService; import com.hz.pm.api.user.util.LoginUserUtil; import com.ningdatech.basic.exception.BizException; -import com.ningdatech.basic.model.GenericResult; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.zwdd.ZwddIntegrationProperties; @@ -49,31 +45,27 @@ import java.util.stream.Collectors; /** * @author liuxinxin - * @date 2023/2/13 上午9:09 + * @since 2023/2/13 上午9:09 */ @Component @RequiredArgsConstructor public class UserInfoManage { private final UserAuthManage userAuthManage; - private final IUserInfoService iUserInfoService; - private final IRoleService iRoleService; - private final IDingOrganizationService iDingOrganizationService; - private final IDingEmployeeInfoService iDingEmployeeInfoService; - private final IUserRoleService iUserRoleService; + private final IUserInfoService userInfoService; + private final IRoleService roleService; + private final IDingOrganizationService dingOrganizationService; + private final IDingEmployeeInfoService dingEmployeeInfoService; + private final IUserRoleService userRoleService; private final UserInfoHelper userInfoHelper; private final RegionCacheHelper regionCacheHelper; - private final ZwddIntegrationProperties zwddIntegrationProperties; - private final ZwddClient zwddClient; - public PageVo list(ReqUserInfoListPO req) { + public PageVo list(UserInfoListReq req) { String phoneNo = req.getPhoneNo(); - String orgCode = req.getOrgCode(); String name = req.getName(); - String orgName = req.getOrgName(); - Long regionId = req.getRegionId(); + String mhUnitName = req.getMhUnitName(); List userIdList = getRoleCompliantUserIdList(req.getUserRoleList()); if (userIdList != null && userIdList.isEmpty()) { @@ -81,155 +73,82 @@ public class UserInfoManage { } LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(UserInfo.class) - .like(StringUtils.isNotBlank(phoneNo), UserInfo::getMobile, phoneNo) - .like(StringUtils.isNotBlank(name), UserInfo::getRealName, name) + .like(StrUtils.isNotBlank(phoneNo), UserInfo::getMobile, phoneNo) + .like(StrUtils.isNotBlank(name), UserInfo::getRealName, name) .in(Objects.nonNull(userIdList), UserInfo::getId, userIdList) - .eq(Objects.nonNull(regionId), UserInfo::getRegionCode, regionId) - .like(StringUtils.isNotBlank(orgName), UserInfo::getEmpPosUnitName, orgName) - .eq(StringUtils.isNotBlank(orgCode), UserInfo::getEmpPosUnitCode, orgCode) + .like(StrUtils.isNotBlank(mhUnitName), UserInfo::getMhUnitName, mhUnitName) .orderByDesc(UserInfo::getUpdateOn); - Page page = iUserInfoService.page(req.page(), wrapper); - List records = page.getRecords(); - long total = page.getTotal(); - List result = new ArrayList<>(); - if (records != null && !records.isEmpty()) { - List employeeCodeList = records.stream().map(UserInfo::getEmployeeCode) - .distinct().collect(Collectors.toList()); - - List employeeInfoList = iDingEmployeeInfoService.getEmployeeList(employeeCodeList); - Map empCodeOrgMap = iDingOrganizationService.getEmpCodeOrgMap(employeeInfoList); - - records.forEach(r -> { - ResUserInfoListVO item = new ResUserInfoListVO(); - item.setName(r.getRealName()); - String employeeCode = r.getEmployeeCode(); - if (StringUtils.isNotBlank(employeeCode)) { - DingOrganization dingOrganization = empCodeOrgMap.get(employeeCode); - if (Objects.nonNull(dingOrganization)) { - item.setOrgName(dingOrganization.getOrganizationName()); - item.setOrgCode(dingOrganization.getOrganizationCode()); - String regionCode = dingOrganization.getDivisionCode(); - item.setRegionCode(regionCode); - if (Objects.nonNull(regionCode)) { - item.setRegionName(regionCacheHelper.getDisplayName(regionCode, RegionConst.RL_COUNTY)); - } - } - - } - userStatusAssembler(item, r); - item.setUpdateTime(r.getUpdateOn()); - item.setEmployeeCode(r.getEmployeeCode()); - item.setUserRoleList(getUserRoleVOList(item.getUserId())); - result.add(item); - }); - } - return PageVo.of(result, total); - } - - private List getCompliantOrgEmpCodeList(String orgName, String orgCode) { - if (StringUtils.isBlank(orgName) && StringUtils.isBlank(orgCode)) { - return Collections.emptyList(); - } - List compliantOrgCodeList = new ArrayList<>(); - - // 查重符合筛选条件的组织列表 - if (StringUtils.isNotBlank(orgName)) { - List dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) - .like(DingOrganization::getOrganizationName, orgName) - .eq(DingOrganization::getTypeCode, DingOrganizationContant.UNIT_TYPE) - ); - - List compliantOrgNameCodeList = dingOrganizationList.stream() - .map(DingOrganization::getOrganizationCode) - .collect(Collectors.toList()); - if (CollUtil.isEmpty(compliantOrgNameCodeList)) { - return new ArrayList<>(); - } - - // 取交集 - List tempCompliantOrgCodeList = new ArrayList<>(); - for (String compliantOrgNameCode : compliantOrgNameCodeList) { - if (compliantOrgCodeList.contains(compliantOrgNameCode)) { - tempCompliantOrgCodeList.add(compliantOrgNameCode); - } - } - compliantOrgCodeList = tempCompliantOrgCodeList; - if (CollUtil.isEmpty(compliantOrgCodeList)) { - return new ArrayList<>(); - } - } - - if (StringUtils.isNotBlank(orgCode)) { - compliantOrgCodeList.add(orgCode); - } - if (CollUtil.isEmpty(compliantOrgCodeList)) { - return new ArrayList<>(); + Page page = userInfoService.page(req.page(), wrapper); + if (page.getTotal() == 0) { + return PageVo.empty(); } - - // 查重符合筛选条件的用户code列表 - List dingEmployeeInfoList = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) - .in(DingEmployeeInfo::getEmpPosUnitCode, compliantOrgCodeList)); - - return dingEmployeeInfoList.stream() - .map(DingEmployeeInfo::getEmployeeCode).distinct().collect(Collectors.toList()); + List result = new ArrayList<>(); + page.getRecords().forEach(r -> { + UserInfoListVO item = new UserInfoListVO(); + item.setName(r.getRealName()); + userStatusBuilder(item, r); + item.setUpdateTime(r.getUpdateOn()); + item.setEmployeeCode(r.getEmployeeCode()); + item.setUserRoleList(getUserRole(item.getUserId())); + item.setUserId(r.getId()); + item.setPhoneNo(r.getMobile()); + item.setMhUnitId(r.getMhUnitId()); + item.setMhUnitName(r.getMhUnitName()); + result.add(item); + }); + return PageVo.of(result, page.getTotal()); } /** * 获取符合查询条件的 用户 userId * - * @param userRoleList + * @param user */ - private List getRoleCompliantUserIdList(List userRoleList) { - if (CollUtil.isNotEmpty(userRoleList)) { - userRoleList.removeIf(r -> Objects.isNull(r.getId())); + @SuppressWarnings("all") + private List getRoleCompliantUserIdList(List userRoles) { + if (CollUtil.isNotEmpty(userRoles)) { + userRoles.removeIf(r -> Objects.isNull(r.getId())); } - if (CollUtil.isEmpty(userRoleList)) { + if (CollUtil.isEmpty(userRoles)) { return null; } - List roleIdList = CollUtils.fieldList(userRoleList, UserRoleVO::getId); - List compliantUserIdList = iUserRoleService.listUserIdByRoleIds(roleIdList); - if (CollUtil.isEmpty(compliantUserIdList)) { - return new ArrayList<>(); - } - return iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) - .in(UserInfo::getId, compliantUserIdList)) - .stream().map(UserInfo::getId).collect(Collectors.toList()); - + List roleIds = CollUtils.fieldList(userRoles, UserRoleVO::getId); + return userRoleService.listUserIdByRoleIds(roleIds); } /** * 装配用户状态 及 userId * - * @param resListVO - * @param userInfo + * @param resUser \ + * @param userInfo \ */ - private void userStatusAssembler(ResUserInfoListVO resListVO, UserInfo userInfo) { + private static void userStatusBuilder(UserInfoListVO resUser, UserInfo userInfo) { if (Objects.nonNull(userInfo)) { - resListVO.setPhoneNo(userInfo.getMobile()); + resUser.setPhoneNo(userInfo.getMobile()); if (StringUtils.isNotBlank(userInfo.getAvailable()) && UserAvailableEnum.ENABLE.name().equals(userInfo.getAvailable())) { - resListVO.setStatus(UserAvailableEnum.ENABLE.name()); + resUser.setStatus(UserAvailableEnum.ENABLE.name()); } else { - resListVO.setStatus(UserAvailableEnum.DISABLE.name()); + resUser.setStatus(UserAvailableEnum.DISABLE.name()); } - resListVO.setUserId(userInfo.getId()); + resUser.setUserId(userInfo.getId()); } else { - resListVO.setStatus(UserAvailableEnum.DISABLE.name()); + resUser.setStatus(UserAvailableEnum.DISABLE.name()); } } - private List getUserRoleVOList(Long userId) { + private List getUserRole(Long userId) { List userRoleInfoList = new ArrayList<>(); if (Objects.isNull(userId)) { return userRoleInfoList; } - List userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) + List userRoleList = userRoleService.list(Wrappers.lambdaQuery(UserRole.class) .eq(UserRole::getUserId, userId).orderByAsc(UserRole::getCreateOn)); if (CollUtil.isNotEmpty(userRoleList)) { List roleIdList = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList()); - List roleList = iRoleService.listByIds(roleIdList); + List roleList = roleService.listByIds(roleIdList); roleList.forEach(r -> { UserRoleVO userRoleVO = new UserRoleVO(); userRoleVO.setId(r.getId()); @@ -252,51 +171,45 @@ public class UserInfoManage { } else { throw BizException.wrap("用户参数缺失"); } - UserInfo userInfo = iUserInfoService.getById(userId); + UserInfo userInfo = userInfoService.getById(userId); userInfo.setAvailable(req.getOperation()); - iUserInfoService.updateById(userInfo); + userInfoService.updateById(userInfo); if ("DISABLE".equals(userInfo.getAvailable())) { userAuthManage.kickOff(userId); } } - public ResUserDetailVO userInfoDetail(ReqUserDetailPO reqUserDetailPO) { - Long userId = reqUserDetailPO.getUserId(); - String employeeCode = reqUserDetailPO.getEmployeeCode(); - if (StringUtils.isBlank(employeeCode) && Objects.isNull(userId)) { - throw new BizException("employeeCode and userId can't not be null"); - } - if (Objects.isNull(userId)) { - userId = generateUserId(reqUserDetailPO.getEmployeeCode()); + public ResUserDetailVO userInfoDetail(UserDetailReq req) { + Long userId = req.getUserId(); + String employeeCode = req.getEmployeeCode(); + if (StrUtils.isBlank(employeeCode) && Objects.isNull(userId)) { + throw new IllegalArgumentException("参数缺失"); } - - UserInfo userInfo = iUserInfoService.getById(userId); + UserInfo userInfo = userInfoService.getById(userId); if (Objects.isNull(userInfo)) { return null; } - ResUserDetailVO resUserDetailVO = new ResUserDetailVO(); - resUserDetailVO.setRealName(userInfo.getRealName()); - resUserDetailVO.setUserId(userInfo.getId()); - resUserDetailVO.setPhoneNo(userInfo.getMobile()); - resUserDetailVO.setStatus(userInfo.getAvailable()); + ResUserDetailVO resUserDetail = new ResUserDetailVO(); + resUserDetail.setRealName(userInfo.getRealName()); + resUserDetail.setUserId(userInfo.getId()); + resUserDetail.setPhoneNo(userInfo.getMobile()); + resUserDetail.setStatus(userInfo.getAvailable()); // 装配用户角色信息列表 - List userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) - .eq(UserRole::getUserId, userId)); - List userRoleInfoList = new ArrayList<>(); + List userRoleList = userRoleService.listByUserId(userId); if (CollUtil.isNotEmpty(userRoleList)) { - List roleIdList = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList()); - List roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList)); - userRoleInfoList = roleList.stream().map(r -> { + List roleIdList = CollUtils.fieldList(userRoleList, UserRole::getRoleId); + List roleList = roleService.listByIds(roleIdList); + List userRoles = roleList.stream().map(r -> { UserRoleVO userRoleVO = new UserRoleVO(); userRoleVO.setId(r.getId()); userRoleVO.setName(r.getName()); return userRoleVO; }).collect(Collectors.toList()); + resUserDetail.setUserRoleInfoList(userRoles); } - resUserDetailVO.setUserRoleInfoList(userRoleInfoList); - return resUserDetailVO; + return resUserDetail; } @Transactional(rollbackFor = Exception.class) @@ -309,7 +222,7 @@ public class UserInfoManage { } userId = generateUserId(employeeCode); } - UserInfo userInfo = iUserInfoService.getById(userId); + UserInfo userInfo = userInfoService.getById(userId); String oldUserStatus = userInfo.getAvailable(); // 绑定用户手机号 bandUserMobile(userInfo, reqUserDetailEditPO); @@ -317,10 +230,10 @@ public class UserInfoManage { userInfo.setAvailable(reqUserDetailEditPO.getStatus()); userInfo.setUpdateOn(LocalDateTime.now()); userInfo.setUpdateBy(LoginUserUtil.getUserId()); - iUserInfoService.updateById(userInfo); + userInfoService.updateById(userInfo); List userRoleInfoList = reqUserDetailEditPO.getUserRoleInfoList(); - iUserRoleService.remove(Wrappers.lambdaQuery(UserRole.class).eq(UserRole::getUserId, userId)); + userRoleService.remove(Wrappers.lambdaQuery(UserRole.class).eq(UserRole::getUserId, userId)); if (CollUtil.isNotEmpty(userRoleInfoList)) { Long finalUserId = userId; List userRoleList = userRoleInfoList.stream().map(r -> { @@ -329,7 +242,7 @@ public class UserInfoManage { saveRecord.setUserId(finalUserId); return saveRecord; }).collect(Collectors.toList()); - iUserRoleService.saveBatch(userRoleList); + userRoleService.saveBatch(userRoleList); } // 刷新用户权限 仅原状态为正常才需要刷新session if ("ENABLE".equals(oldUserStatus)) { @@ -352,7 +265,7 @@ public class UserInfoManage { String employeeCode = reqUserDetailEditPO.getEmployeeCode(); Long userId = userInfo.getId(); // 校验手机号是否重复 - UserInfo repeatMobileUserInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + UserInfo repeatMobileUserInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getMobile, reqUserDetailEditPO.getPhoneNo()).ne(UserInfo::getId, userId)); if (Objects.nonNull(repeatMobileUserInfo)) { throw new BizException("该手机号码已被绑定,请问重复绑定"); @@ -362,21 +275,21 @@ public class UserInfoManage { userInfo.setMobile(phoneNo); // 更新浙政钉相关数据 if (StringUtils.isNotBlank(phoneNo)) { - iDingEmployeeInfoService + dingEmployeeInfoService .update(Wrappers.lambdaUpdate(DingEmployeeInfo.class) .eq(DingEmployeeInfo::getMainJob, "true") .eq(DingEmployeeInfo::getEmployeeCode, employeeCode) .set(DingEmployeeInfo::getBindUserMobile, phoneNo)); - iUserInfoService.updateById(userInfo); + userInfoService.updateById(userInfo); } } @Transactional(rollbackFor = Exception.class) public Long generateUserId(String employeeCode) { - UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + UserInfo userInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getEmployeeCode, employeeCode)); if (Objects.isNull(userInfo)) { - List dingEmployeeInfoList = iDingEmployeeInfoService + List dingEmployeeInfoList = dingEmployeeInfoService .list(Wrappers.lambdaQuery(DingEmployeeInfo.class) .eq(DingEmployeeInfo::getEmployeeCode, employeeCode) .eq(DingEmployeeInfo::getMainJob, "true")); @@ -395,7 +308,7 @@ public class UserInfoManage { .createOn(LocalDateTime.now()) .updateOn(LocalDateTime.now()) .build(); - iUserInfoService.save(userInfo); + userInfoService.save(userInfo); } return userInfo.getId(); } @@ -403,114 +316,54 @@ public class UserInfoManage { public ResUserDetailVO currentUserInfo() { Long userId = LoginUserUtil.getUserId(); - UserInfo userInfo = iUserInfoService.getById(userId); + UserInfo userInfo = userInfoService.getById(userId); if (Objects.isNull(userInfo)) { return null; } - ResUserDetailVO resUserDetailVO = new ResUserDetailVO(); - resUserDetailVO.setRealName(userInfo.getRealName()); - resUserDetailVO.setUserId(userInfo.getId()); - resUserDetailVO.setPhoneNo(userInfo.getMobile()); - resUserDetailVO.setStatus(userInfo.getAvailable()); - resUserDetailVO.setEmployeeCode(userInfo.getEmployeeCode()); - resUserDetailVO.setAvatar(makeAvatar(userInfo.getAvatar())); + ResUserDetailVO resUserDetail = new ResUserDetailVO(); + resUserDetail.setRealName(userInfo.getRealName()); + resUserDetail.setUserId(userInfo.getId()); + resUserDetail.setPhoneNo(userInfo.getMobile()); + resUserDetail.setStatus(userInfo.getAvailable()); + resUserDetail.setEmployeeCode(userInfo.getEmployeeCode()); + resUserDetail.setMhUnitId(userInfo.getMhUnitId()); + resUserDetail.setMhUnitName(userInfo.getMhUnitName()); // 装配用户角色信息列表 - List userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) - .eq(UserRole::getUserId, userId)); - List userRoleInfoList = new ArrayList<>(); + List userRoleList = userRoleService.listByUserId(userId); if (CollUtil.isNotEmpty(userRoleList)) { - List roleIdList = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList()); - List roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList)); - roleList.forEach(r -> { - UserRoleVO userRoleVO = new UserRoleVO(); - userRoleVO.setId(r.getId()); - userRoleVO.setName(r.getName()); - userRoleVO.setCode(r.getCode()); - userRoleInfoList.add(userRoleVO); - }); - } - resUserDetailVO.setUserRoleInfoList(userRoleInfoList); - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - if (Objects.nonNull(userFullInfo)) { - resUserDetailVO.setOrgCode(userFullInfo.getOrganizationCode()); - resUserDetailVO.setOrgName(userFullInfo.getOrganizationName()); - resUserDetailVO.setRegionCode(userFullInfo.getRegionCode()); - resUserDetailVO.setRegionLevel(userFullInfo.getRegionLevel()); - resUserDetailVO.setRegionName(regionCacheHelper.getRegionName(userFullInfo.getRegionCode() - , RegionConst.RL_COUNTY)); - resUserDetailVO.setEmpPosUnitCode(userFullInfo.getEmpPosUnitCode()); - resUserDetailVO.setEmpPosUnitName(userFullInfo.getEmpPosUnitName()); - } - return resUserDetailVO; - } - - //生成头像 链接 - private String makeAvatar(String avatar) { - try { - GenericResult accessToken = zwddClient.getAccessToken(); - String token = accessToken.getData(); - String res = "https://" + zwddIntegrationProperties.getDomain() + "/media/download?" + - "access_token=" + token + "&media_id=" + avatar; - return res; - } catch (Exception e) { + List roleIdList = CollUtils.fieldList(userRoleList,UserRole::getRoleId); + List roleList = roleService.listByIds(roleIdList); + List userRoles = roleList.stream().map(r -> { + UserRoleVO userRole = new UserRoleVO(); + userRole.setId(r.getId()); + userRole.setName(r.getName()); + userRole.setCode(r.getCode()); + return userRole; + }).collect(Collectors.toList()); + resUserDetail.setUserRoleInfoList(userRoles); } - return org.apache.commons.lang3.StringUtils.EMPTY; - } - - public Map getUserMapByIds(Set staterUsers) { - List userInfos = iUserInfoService.listByIds(staterUsers); - return userInfos.stream().map(u -> { - ProcessInstanceUserDto userInfo = new ProcessInstanceUserDto(); - userInfo.setUserId(u.getEmployeeCode()); - userInfo.setUserName(u.getRealName()); - // 根据 单位code获取单位名称 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(u.getId()); - if (Objects.nonNull(userFullInfo)) { - userInfo.setOrgCode(userFullInfo.getEmpPosUnitCode()); - userInfo.setOrgName(userFullInfo.getEmpPosUnitName()); - } - return userInfo; - }).collect(Collectors.toMap((ProcessInstanceUserDto::getUserId), v -> v)); + return resUserDetail; } - public Map getUserMapByEmployeeCode(Set staterUsers) { + public Map getUserMapByUserIds(Collection staterUsers) { if (CollUtil.isEmpty(staterUsers)) { return Collections.emptyMap(); } - List userInfos = iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) - .in(UserInfo::getEmployeeCode, staterUsers)); + List userInfos = userInfoService.listByIds(staterUsers); if (CollUtil.isEmpty(userInfos)) { return Collections.emptyMap(); } return userInfos.stream().map(u -> { ProcessInstanceUserDto userInfo = new ProcessInstanceUserDto(); - userInfo.setUserId(u.getEmployeeCode()); + userInfo.setUserId(String.valueOf(u.getId())); userInfo.setUserName(u.getRealName()); - // 根据 单位code获取单位名称 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(u.getId()); - if (Objects.nonNull(userFullInfo)) { - userInfo.setOrgCode(userFullInfo.getEmpPosUnitCode()); - userInfo.setOrgName(userFullInfo.getEmpPosUnitName()); - } + userInfo.setOrgCode(String.valueOf(u.getMhUnitId())); + userInfo.setOrgName(u.getMhUnitName()); return userInfo; }).collect(Collectors.toMap((ProcessInstanceUserDto::getUserId), v -> v)); } - public ProcessInstanceUserDto getUserInfo(String userId) { - UserInfo userInfo = iUserInfoService.getById(userId); - ProcessInstanceUserDto processInstanceUserDto = new ProcessInstanceUserDto(); - processInstanceUserDto.setUserId(String.valueOf(userInfo.getId())); - processInstanceUserDto.setUserName(userInfo.getRealName()); - // 根据 单位code获取单位名称 - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userInfo.getId()); - if (Objects.nonNull(userFullInfo)) { - processInstanceUserDto.setOrgCode(userFullInfo.getEmpPosUnitCode()); - processInstanceUserDto.setOrgName(userFullInfo.getEmpPosUnitName()); - } - return processInstanceUserDto; - } - /** * 获取当前用户可控角色列表 * @@ -519,7 +372,7 @@ public class UserInfoManage { public List getControlledRoleList() { Long userId = LoginUserUtil.getUserId(); // 装配用户角色信息列表 - List userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) + List userRoleList = userRoleService.list(Wrappers.lambdaQuery(UserRole.class) .eq(UserRole::getUserId, userId)); List controlledRoleVOList = new ArrayList<>(); @@ -527,7 +380,7 @@ public class UserInfoManage { if (CollUtil.isNotEmpty(userRoleList)) { List roleIdList = userRoleList.stream().map(UserRole::getRoleId).distinct().collect(Collectors.toList()); - List roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList)); + List roleList = roleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList)); for (Role role : roleList) { List manageRoleIdList = BizUtils.splitToLong(role.getManageRoleIds()); @@ -536,7 +389,7 @@ public class UserInfoManage { } } controlledRoleIdList = controlledRoleIdList.stream().distinct().collect(Collectors.toList()); - List controlledRoleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, controlledRoleIdList)); + List controlledRoleList = roleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, controlledRoleIdList)); controlledRoleVOList = controlledRoleList.stream().map(r -> { UserRoleVO userRoleVO = new UserRoleVO(); @@ -557,7 +410,7 @@ public class UserInfoManage { */ public UserFullInfoDTO queryUserInfoInPasswordAuth(String username) { // TODO 目前账号密码登陆测试使用 强制用户登录 userId 1L - UserInfo userInfo = iUserInfoService.getById(username); + UserInfo userInfo = userInfoService.getById(username); if (Objects.isNull(userInfo)) { return null; } @@ -572,7 +425,7 @@ public class UserInfoManage { * @return / */ public UserFullInfoDTO queryUserInfoInPhoneNoAuth(String phoneNo) { - UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + UserInfo userInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getMobile, phoneNo)); if (Objects.isNull(userInfo)) { return null; @@ -590,7 +443,7 @@ public class UserInfoManage { public UserFullInfoDTO queryUserInfoInAccountIdAuth(String accountId) { // 获取用户信息 - UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + UserInfo userInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getAccountId, accountId)); if (Objects.isNull(userInfo)) { return null; @@ -600,7 +453,7 @@ public class UserInfoManage { } public UserFullInfoDTO getUserFullInfoByEmployeeCode(String employeeCode) { - UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + UserInfo userInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) .eq(UserInfo::getEmployeeCode, employeeCode).last("limit 1")); if (Objects.isNull(userInfo)) { return null; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/entity/UserInfo.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/entity/UserInfo.java index 7080ba1..21c36c3 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/entity/UserInfo.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/entity/UserInfo.java @@ -12,8 +12,6 @@ import java.io.Serializable; import java.time.LocalDateTime; - - /** *

* @@ -57,12 +55,9 @@ public class UserInfo implements Serializable { private String employeeCode; - private String regionCode; - private Long mhUnitId; - private String empPosUnitCode; - private String empPosUnitName; + private String mhUnitName; @ApiModelProperty("头像") private String avatar; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/ReqUserDetailPO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/UserDetailReq.java similarity index 92% rename from hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/ReqUserDetailPO.java rename to hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/UserDetailReq.java index 4608f2f..11cf48e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/ReqUserDetailPO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/UserDetailReq.java @@ -10,7 +10,7 @@ import lombok.Data; */ @Data @ApiModel("获取用户详情请求") -public class ReqUserDetailPO { +public class UserDetailReq { @ApiModelProperty("用户id") private Long userId; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/ReqUserInfoListPO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/UserInfoListReq.java similarity index 64% rename from hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/ReqUserInfoListPO.java rename to hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/UserInfoListReq.java index 1764949..07775bd 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/ReqUserInfoListPO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/po/UserInfoListReq.java @@ -5,6 +5,7 @@ import com.hz.pm.api.user.model.vo.UserRoleVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; @@ -13,8 +14,9 @@ import java.util.List; * @date 2023/2/13 上午9:10 */ @Data +@EqualsAndHashCode(callSuper = true) @ApiModel("用户管理查询 请求入参") -public class ReqUserInfoListPO extends PagePo { +public class UserInfoListReq extends PagePo { @ApiModelProperty("姓名") private String name; @@ -22,17 +24,11 @@ public class ReqUserInfoListPO extends PagePo { @ApiModelProperty("手机号码") private String phoneNo; - @ApiModelProperty("所在单位(主职)") - private String orgName; + @ApiModelProperty("所在单位") + private String mhUnitName; - @ApiModelProperty("所在单位Code(主职)") - private String orgCode; - - @ApiModelProperty("所属区域") - private Long regionId; - - @ApiModelProperty("所属区域名称") - private Long regionName; + @ApiModelProperty("所在单位Code") + private Long mhUnitId; @ApiModelProperty("用户角色") private List userRoleList; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java index fea6e63..63aa5ce 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserDetailVO.java @@ -1,6 +1,5 @@ package com.hz.pm.api.user.model.vo; -import com.hz.pm.api.common.model.constant.RegionConst; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -10,7 +9,7 @@ import java.util.List; /** * @author liuxinxin - * @date 2023/2/15 上午8:43 + * @since 2023/2/15 上午8:43 */ @Data @ApiModel("获取用户详情请求") @@ -31,23 +30,11 @@ public class ResUserDetailVO { @ApiModelProperty("浙政钉 用户编码") private String employeeCode; - @ApiModelProperty("所在单位(主职)") - private String orgName; + @ApiModelProperty("所在单位") + private String mhUnitName; - @ApiModelProperty("所在单位(主职)code") - private String orgCode; - - @ApiModelProperty("所属区域") - private Long regionId; - private String regionCode; - private Integer regionLevel; - private String regionName; - - @ApiModelProperty("用户任职所在单位code") - private String empPosUnitCode; - - @ApiModelProperty("用户任职所在单位") - private String empPosUnitName; + @ApiModelProperty("所在单位code") + private Long mhUnitId; @ApiModelProperty("用户角色") private List userRoleList; @@ -61,12 +48,4 @@ public class ResUserDetailVO { @ApiModelProperty("头像") private String avatar; - //是否是市级单位 - public Boolean getIsMunicipalOrg(){ - //如果是丽水市本级的code 就是 - if(RegionConst.RC_HZ.equals(this.regionCode)){ - return Boolean.TRUE; - } - return Boolean.FALSE; - } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserInfoListVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/UserInfoListVO.java similarity index 70% rename from hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserInfoListVO.java rename to hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/UserInfoListVO.java index bf066df..799fc78 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/ResUserInfoListVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/model/vo/UserInfoListVO.java @@ -17,7 +17,7 @@ import java.util.List; */ @Data @ApiModel("用户管理查询 请求response") -public class ResUserInfoListVO { +public class UserInfoListVO { @ApiModelProperty("用户id") private Long userId; @@ -31,17 +31,11 @@ public class ResUserInfoListVO { @ApiModelProperty("手机号码") private String phoneNo; - @ApiModelProperty("所在单位(主职)") - private String orgName; + @ApiModelProperty("所在单位") + private String mhUnitName; - @ApiModelProperty("所在单位(主职)code") - private String orgCode; - - @ApiModelProperty("所属区域") - private Long regionId; - private Integer regionLevel; - private String regionCode; - private String regionName; + @ApiModelProperty("所在单位code") + private Long mhUnitId; @ApiModelProperty("用户角色") private List userRoleList; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/constants/SessionTimeConstant.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/constants/SessionTimeConst.java similarity index 81% rename from hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/constants/SessionTimeConstant.java rename to hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/constants/SessionTimeConst.java index 33f6971..ea0b22b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/constants/SessionTimeConstant.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/constants/SessionTimeConst.java @@ -5,10 +5,14 @@ package com.hz.pm.api.user.security.auth.constants; * @Date 2022/2/17 12:59 上午 * @Version 1.0 **/ -public class SessionTimeConstant { +public class SessionTimeConst { + + private SessionTimeConst() { + } public static final Integer SESSION_TIME_SECONDS = 24 * 60 * 60 * 10; public static final Integer SESSION_EXPIRED = 0; public static final String UNIVERSAL_VERIFICATION_CODE = "9527"; + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/credential/CredentialAuthProvider.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/credential/CredentialAuthProvider.java index a9d836d..7370024 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/credential/CredentialAuthProvider.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/credential/CredentialAuthProvider.java @@ -3,7 +3,7 @@ package com.hz.pm.api.user.security.auth.credential; import com.hz.pm.api.sms.constant.VerificationCodeType; import com.hz.pm.api.sms.helper.VerifyCodeCheckHelper; import com.hz.pm.api.user.model.enumeration.LoginTypeEnum; -import com.hz.pm.api.user.security.auth.constants.SessionTimeConstant; +import com.hz.pm.api.user.security.auth.constants.SessionTimeConst; import com.hz.pm.api.user.security.auth.constants.UserDetailsServiceConstant; import com.hz.pm.api.user.security.validate.CommonLoginException; import com.ningdatech.basic.exception.BizException; @@ -79,7 +79,7 @@ public class CredentialAuthProvider implements AuthenticationProvider { if (Boolean.FALSE.equals(phoneVerifyCodeSkip)) { // 校验短信验证码 boolean verificationResult = verifyCodeCheckHelper.verification(VerificationCodeType.LOGIN, principal, credentials); - if (!verificationResult && !SessionTimeConstant.UNIVERSAL_VERIFICATION_CODE.equals(credentials)) { + if (!verificationResult && !SessionTimeConst.UNIVERSAL_VERIFICATION_CODE.equals(credentials)) { throw new CommonLoginException("验证码错误"); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/config/RedisSessionConfig.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/config/RedisSessionConfig.java index 5866b66..2d55c5b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/config/RedisSessionConfig.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/config/RedisSessionConfig.java @@ -1,7 +1,7 @@ package com.hz.pm.api.user.security.config;//package com.hz.pm.api.user.security.auth.config; import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.user.security.auth.constants.SessionTimeConstant; +import com.hz.pm.api.user.security.auth.constants.SessionTimeConst; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; @@ -30,7 +30,7 @@ public class RedisSessionConfig { sessionIdResolver.setCookieSerializer(cookieSerializer); // 设置到 sessionIdResolver 中 cookieSerializer.setCookieName(BizConst.COOKIE_KEY); - cookieSerializer.setCookieMaxAge(SessionTimeConstant.SESSION_TIME_SECONDS); + cookieSerializer.setCookieMaxAge(SessionTimeConst.SESSION_TIME_SECONDS); return sessionIdResolver; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java index 0fa9956..6307cfb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserFullInfoDTO.java @@ -12,7 +12,7 @@ import java.util.stream.Collectors; /** * @author liuxinxin - * @date 2023/1/4 下午5:07 + * @since 2023/1/4 下午5:07 */ @Data @@ -20,6 +20,12 @@ public class UserFullInfoDTO { private Long userId; + private String mhUnitName; + + private Long mhUnitId; + + private String mhUserId; + private String realName; private String username; @@ -29,45 +35,11 @@ public class UserFullInfoDTO { private String credential; /** - * 所属区域编码 - */ - private String regionCode; - /** - * 所属区域编码 - */ - private Integer regionLevel; - - /** - * 浙政钉扫码 员工code - */ - private String employeeCode; - - /** - * 浙政钉组织code - */ - private String organizationCode; - - /** * 手机号码 */ private String mobile; /** - * 浙政钉组织名称 - */ - private String organizationName; - - /** - * 任职所在单位code - */ - private String empPosUnitCode; - - /** - * 任职所在单位 - */ - private String empPosUnitName; - - /** * 用户角色 */ private List userRoleList; @@ -83,7 +55,7 @@ public class UserFullInfoDTO { /** * 取最高的权限 * - * @return + * @return \ */ public RoleEnum getRoleCode() { if (CollUtil.isNotEmpty(this.userRoleList)) { @@ -93,35 +65,35 @@ public class UserFullInfoDTO { return null; } - public Boolean getIsOrgAdmin() { - if (CollUtil.isNotEmpty(this.userRoleList)) { - for (Role role : this.userRoleList) { - RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); - if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.COMPANY_MANAGER.name())) { - return Boolean.TRUE; - } - } - } - return Boolean.FALSE; + public boolean getIsOrgAdmin() { + return containsRole(RoleEnum.COMPANY_MANAGER); } - public Boolean getSuperAdmin() { - if (CollUtil.isNotEmpty(this.userRoleList)) { - for (Role role : this.userRoleList) { - RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); - if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.SUPER_ADMIN.name())) { - return Boolean.TRUE; - } - } - } - return Boolean.FALSE; + public boolean getSuperAdmin() { + return containsRole(RoleEnum.SUPER_ADMIN); } - public Boolean getRegionAdmin() { + public boolean getRegionAdmin() { + return containsRole(RoleEnum.REGION_MANAGER); + } + + public Boolean notAdmin() { + return !getSuperAdmin() && !getRegionAdmin() && !getIsOrgAdmin(); + } + + public String getMhUnitIdStr() { + return String.valueOf(getMhUnitId()); + } + + public String getUserIdStr() { + return String.valueOf(getUserId()); + } + + private boolean containsRole(RoleEnum targetRole) { if (CollUtil.isNotEmpty(this.userRoleList)) { for (Role role : this.userRoleList) { RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); - if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.REGION_MANAGER.name())) { + if (Objects.nonNull(roleEnum) && roleEnum.eq(targetRole.name())) { return Boolean.TRUE; } } @@ -129,10 +101,4 @@ public class UserFullInfoDTO { return Boolean.FALSE; } - public Boolean notAdmin() { - if(!getSuperAdmin() && !getRegionAdmin() && !getIsOrgAdmin()){ - return Boolean.TRUE; - } - return Boolean.FALSE; - } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java index a89b4e7..7dd62a9 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/security/model/UserInfoDetails.java @@ -2,25 +2,21 @@ package com.hz.pm.api.user.security.model; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; -import com.ningdatech.basic.auth.AbstractLoginUser; -import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.sys.model.entity.Role; import com.hz.pm.api.user.model.enumeration.RoleEnum; +import com.ningdatech.basic.auth.AbstractLoginUser; import lombok.Data; import lombok.EqualsAndHashCode; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** * @author LiuXinXin - * @date 2022/8/1 下午3:32 + * @since 2022/8/1 下午3:32 */ @Data @EqualsAndHashCode(callSuper = true) @@ -28,16 +24,9 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { private static final long serialVersionUID = -8219907690673456440L; - private String realName; - private String password; /** - * 所属区域编码 - */ - private String regionCode; - - /** * 所属区域层级 */ private Integer regionLevel; @@ -48,38 +37,38 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { private String employeeCode; /** - * 浙政钉组织code + * 用户所属单位 */ - private String organizationCode; + private String mhUnitName; /** - * 浙政钉组织名称 + * 用户所属单位ID */ - private String organizationName; + private Long mhUnitId; + + private String mhUserId; /** * 用户角色 */ private List userRoleList; - /** - * 任职所在单位code - */ - private String empPosUnitCode; - /** - * 任职所在单位 - */ - private String empPosUnitName; + private String mobile; + public String getUserIdStr() { + return String.valueOf(getUserId()); + } - private String mobile; + public String getMhUnitIdStr() { + return String.valueOf(getMhUnitId()); + } /** * 获取用户权限 * - * @return + * @return \ */ @Override public Collection getAuthorities() { @@ -90,7 +79,7 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { } return authorities; } - return new ArrayList<>(); + return Collections.emptyList(); } @Override @@ -126,7 +115,7 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { /** * 取最高的权限 * - * @return + * @return \ */ public RoleEnum getRoleCode() { if (CollUtil.isNotEmpty(this.userRoleList)) { @@ -136,35 +125,23 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { return null; } - public Boolean getIsOrgAdmin() { - if (CollUtil.isNotEmpty(this.userRoleList)) { - for (Role role : this.userRoleList) { - RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); - if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.COMPANY_MANAGER.name())) { - return Boolean.TRUE; - } - } - } - return Boolean.FALSE; + public boolean getIsOrgAdmin() { + return containsRole(RoleEnum.COMPANY_MANAGER); } - public Boolean getSuperAdmin() { - if (CollUtil.isNotEmpty(this.userRoleList)) { - for (Role role : this.userRoleList) { - RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); - if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.SUPER_ADMIN.name())) { - return Boolean.TRUE; - } - } - } - return Boolean.FALSE; + public boolean getSuperAdmin() { + return containsRole(RoleEnum.SUPER_ADMIN); } - public Boolean getRegionAdmin() { + public boolean getRegionAdmin() { + return containsRole(RoleEnum.REGION_MANAGER); + } + + private boolean containsRole(RoleEnum targetRole) { if (CollUtil.isNotEmpty(this.userRoleList)) { for (Role role : this.userRoleList) { RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); - if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.REGION_MANAGER.name())) { + if (Objects.nonNull(roleEnum) && roleEnum.eq(targetRole.name())) { return Boolean.TRUE; } } @@ -172,11 +149,4 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { return Boolean.FALSE; } - public Boolean getIsMunicipalOrg() { - //如果是丽水市本级的code 就是 - if (RegionConst.RC_HZ.equals(this.regionCode)) { - return Boolean.TRUE; - } - return Boolean.FALSE; - } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/util/LoginUserUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/util/LoginUserUtil.java index 25243f1..023dcb4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/util/LoginUserUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/util/LoginUserUtil.java @@ -10,10 +10,13 @@ import java.util.stream.Collectors; /** - * @Author liuxinxin - * @Date 2022/9/30 12:26 下午 - * @Version 1.0 - **/ + *

+ * LoginUserUtil + *

+ * + * @author WendyYang + * @since 15:42 2024/1/12 + */ public class LoginUserUtil extends AbstractLoginUserUtil { public static UserInfoDetails loginUserDetail() { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java index 07f47ec..4185ad0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/workbench/manage/WorkbenchManage.java @@ -90,11 +90,11 @@ public class WorkbenchManage { StopWatch stopWatch = new StopWatch(); stopWatch.start(); //1.待办中心数据 - TodoCenterStatisticsVO statisticsVO = todoCenterManage.todoCenterStatistics(user.getEmployeeCode()); + TodoCenterStatisticsVO statisticsVO = todoCenterManage.todoCenterStatistics(user.getUserId()); ToBeProcessedReq toBeProcessedReq = new ToBeProcessedReq(); toBeProcessedReq.page(1, 5); toBeProcessedReq.setLoginUserId(userId); - toBeProcessedReq.setEmployeeCode(user.getEmployeeCode()); + toBeProcessedReq.setUserId(user.getUserId()); statisticsVO.setTodoList(todoCenterManage.todoProjectList(toBeProcessedReq).getRecords() .stream().map(WorkbenchConverter::convert).collect(Collectors.toList())); res.setTodoCerter(statisticsVO); @@ -156,7 +156,7 @@ public class WorkbenchManage { WorkbenchVO.ProjectEarlyWarning projectEarlyWarning = new WorkbenchVO.ProjectEarlyWarning(); LambdaQueryWrapper projectWrapper = Wrappers.lambdaQuery(Project.class) .eq(Project::getNewest, Boolean.TRUE); - EarlyWarningUtil.buildPermissonProjectWrapper(projectWrapper, user); + EarlyWarningUtil.buildPermissionProjectWrapper(projectWrapper, user); List projects = projectService.list(projectWrapper); Set projectCodeS = Sets.newHashSet(); Map projectNameMap = projects.stream() @@ -169,12 +169,12 @@ public class WorkbenchManage { LambdaQueryWrapper overWrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) .eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.OVER.getCode()) .or(q2 -> q2.isNull(WflowEarlyWarningRecords::getNoticeType)); - EarlyWarningUtil.buildPermissonFullWrapper(overWrapper, user); + EarlyWarningUtil.buildPermissionFullWrapper(overWrapper, user); long overCount = earlyWarningRecordsService.count(overWrapper); accumulate.setOver((int) overCount); LambdaQueryWrapper adventWrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) .eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.ADVENT.getCode()); - EarlyWarningUtil.buildPermissonFullWrapper(adventWrapper, user); + EarlyWarningUtil.buildPermissionFullWrapper(adventWrapper, user); long adventCount = earlyWarningRecordsService.count(adventWrapper); accumulate.setAdvent((int) adventCount); projectEarlyWarning.setAccumulate(accumulate); @@ -187,18 +187,15 @@ public class WorkbenchManage { Page normalPage = Page.of(1, 1000); LambdaQueryWrapper overPewWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class) .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.OVER_TIME.name()) - .eq(user.getRegionAdmin() && !user.getSuperAdmin(), ProjectEarlyWarning::getAreaCode, user.getRegionCode()) - .eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getEmpPosUnitCode()); + .eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getMhUnitId()); projectEarlyWarningService.page(overPage, overPewWrapper); LambdaQueryWrapper adventPewWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class) .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.ADVENT_TIME.name()) - .eq(user.getRegionAdmin() && !user.getSuperAdmin(), ProjectEarlyWarning::getAreaCode, user.getRegionCode()) - .eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getEmpPosUnitCode()); + .eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getMhUnitId()); projectEarlyWarningService.page(adventPage, adventPewWrapper); LambdaQueryWrapper normalWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class) .eq(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.NORMAL.name()) - .eq(user.getRegionAdmin() && !user.getSuperAdmin(), ProjectEarlyWarning::getAreaCode, user.getRegionCode()) - .eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getEmpPosUnitCode()); + .eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), ProjectEarlyWarning::getBuildOrgCode, user.getMhUnitId()); projectEarlyWarningService.page(normalPage, normalWrapper); WorkbenchVO.WarningStatistics cuurent = new WorkbenchVO.WarningStatistics(); @@ -211,8 +208,7 @@ public class WorkbenchManage { projectEarlyWarning.setCurrent(cuurent); List warningRecords = earlyWarningRecordsService.list(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) - .eq(user.getRegionAdmin() && !user.getSuperAdmin(), WflowEarlyWarningRecords::getAreaCode, user.getRegionCode()) - .eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), WflowEarlyWarningRecords::getBuildOrgCode, user.getEmpPosUnitCode()) + .eq((user.getIsOrgAdmin() && !user.getSuperAdmin()) || user.notAdmin(), WflowEarlyWarningRecords::getBuildOrgCode, user.getMhUnitId()) .orderByDesc(WflowEarlyWarningRecords::getWarningTime)); Set projectCodeSet = Sets.newHashSet(); Map warningMap = warningRecords.stream() @@ -228,11 +224,11 @@ public class WorkbenchManage { WflowEarlyWarningRecords record = warningMap.get(vo.getProjectCode()); vo.setWarningTime(record.getWarningTime()); vo.setInstStart(record.getInstStart()); - vo.setWarningEmployeecode(record.getWarningEmployeecode()); + vo.setWarningUserId(record.getWarningUserId()); vo.setNoticeMethod(record.getNoticeMethod()); vo.setNoticeContent(record.getNoticeContent()); vo.setPath(record.getPath()); - vo.setBatchEmployees(record.getBatchEmployees()); + vo.setBatchUserIds(record.getBatchUserIds()); vo.setRecordId(record.getId()); } else { vo.setWarningTime(now); @@ -255,11 +251,11 @@ public class WorkbenchManage { WflowEarlyWarningRecords record = warningMap.get(vo.getProjectCode()); vo.setWarningTime(record.getWarningTime()); vo.setInstStart(record.getInstStart()); - vo.setWarningEmployeecode(record.getWarningEmployeecode()); + vo.setWarningUserId(record.getWarningUserId()); vo.setNoticeMethod(record.getNoticeMethod()); vo.setNoticeContent(record.getNoticeContent()); vo.setPath(record.getPath()); - vo.setBatchEmployees(record.getBatchEmployees()); + vo.setBatchUserIds(record.getBatchUserIds()); vo.setRecordId(record.getId()); } else { vo.setWarningTime(now); @@ -281,11 +277,11 @@ public class WorkbenchManage { WflowEarlyWarningRecords record = warningMap.get(vo.getProjectCode()); vo.setWarningTime(record.getWarningTime()); vo.setInstStart(record.getInstStart()); - vo.setWarningEmployeecode(record.getWarningEmployeecode()); + vo.setWarningUserId(record.getWarningUserId()); vo.setNoticeMethod(record.getNoticeMethod()); vo.setNoticeContent(record.getNoticeContent()); vo.setPath(record.getPath()); - vo.setBatchEmployees(record.getBatchEmployees()); + vo.setBatchUserIds(record.getBatchUserIds()); vo.setRecordId(record.getId()); } vo.setProjectName(projectNameMap.get(o.getProjectCode())); @@ -314,7 +310,7 @@ public class WorkbenchManage { Integer noticeType = record.getNoticeType(); String projectCode = record.getProjectCode(); Project project = projectService.getProjectByCode(projectCode); - String batchEmployees = record.getBatchEmployees(); + String batchEmployees = record.getBatchUserIds(); Integer ruleType = record.getRuleType(); String areaCode = record.getAreaCode(); //如果是临期 可以取到 超期的小时数 @@ -324,7 +320,7 @@ public class WorkbenchManage { VUtils.isTrue(Objects.isNull(project)).throwMessage("催办失败,项目不存在!"); if (StringUtils.isBlank(batchEmployees)) { //如果批次员工号不存在 就取当前 - batchEmployees = record.getWarningEmployeecode(); + batchEmployees = record.getWarningUserId(); } String noticeContent = record.getNoticeContent(); //查出配置的模板 @@ -343,8 +339,11 @@ public class WorkbenchManage { //算出 当前和他的 小时差 临期 long adventBetween = ChronoUnit.HOURS.between(instStart, LocalDateTime.now()); for (String employee : employees) { - earlyWarningManage.urging(noticeMethod, noticeContent, (int) adventBetween, (int) adventBetween, - biz, instStart, employee, project, ruleType, noticeType, path, batchEmployees, record.getNodeId()); + earlyWarningManage.urging(noticeMethod, noticeContent, + (int) adventBetween, (int) adventBetween, + biz, instStart, Long.valueOf(employee), + project, ruleType, noticeType, path, + batchEmployees, record.getNodeId()); } return "催办成功了" + employees.length + "个人"; } diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/irs/EmployeeTest.java b/hz-pm-api/src/test/java/com/hz/pm/api/irs/EmployeeTest.java deleted file mode 100644 index 2058bff..0000000 --- a/hz-pm-api/src/test/java/com/hz/pm/api/irs/EmployeeTest.java +++ /dev/null @@ -1,224 +0,0 @@ -package com.hz.pm.api.irs; - -import cn.hutool.core.collection.CollUtil; -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.basic.function.VUtils; -import com.ningdatech.basic.model.GenericResult; -import com.hz.pm.api.AppTests; -import com.hz.pm.api.common.model.constant.BizConst; -import com.hz.pm.api.organization.model.entity.DingEmployeeInfo; -import com.hz.pm.api.organization.model.entity.DingOrganization; -import com.hz.pm.api.organization.service.IDingEmployeeInfoService; -import com.hz.pm.api.organization.service.IDingOrganizationService; -import com.hz.pm.api.user.model.enumeration.UserAvailableEnum; -import com.hz.pm.api.user.model.entity.UserInfo; -import com.hz.pm.api.user.service.IUserInfoService; -import com.ningdatech.zwdd.ZwddIntegrationProperties; -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 org.junit.Test; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; - -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @Classname EmployeeTest - * @Description - * @Date 2023/9/11 10:59 - * @Author PoffyZhang - */ -public class EmployeeTest extends AppTests { - - @Autowired - private IDingOrganizationService iDingOrganizationService; - - @Autowired - private ZwddIntegrationProperties zwddIntegrationProperties; - - @Autowired - private IDingEmployeeInfoService iDingEmployeeInfoService; - - @Autowired - private ZwddClient zwddClient; - - @Autowired - private IUserInfoService iUserInfoService; - - @Test - public void test(){ - String orgCode = "GO_3663776dcc2c414db2ed947e225bfc5b"; - DingOrganization org = iDingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) - .eq(DingOrganization::getOrganizationCode, orgCode) - .last(BizConst.LIMIT_1)); - VUtils.isTrue(Objects.isNull(org)).throwMessage("单位不存在"); - System.out.println("所属单位 {} 要更新员工信息了:" + org.getOrganizationName()); - - List allOrganizationEmployeePositionList = new ArrayList<>(); - String organizationCode = orgCode; - PageOrganizationEmployeePositionsQuery query = new PageOrganizationEmployeePositionsQuery(); - query.setEmployeeStatus("A"); - query.setOrganizationCode(organizationCode); - query.setReturnTotalSize(true); - query.setTenantId(zwddIntegrationProperties.getTenantId()); - int pageNo = 1; - query.setPageNo(pageNo); - query.setPageSize(100); - - // 查询组织下 用户信息 - GenericResult> firstPageGenericResult = zwddClient.pageOrganizationEmployeePositions(query); - Page data = firstPageGenericResult.getData(); - if (Objects.isNull(data)){ - System.out.println("响应为空:{}" + organizationCode); - return; - } - System.out.println(JSON.toJSONString(data.getData())); - if (CollUtil.isNotEmpty(data.getData())) { - allOrganizationEmployeePositionList.addAll(data.getData()); - } - Long totalSize = data.getTotalSize(); - - System.out.println("dingOrganization :{}" + JSON.toJSONString(org)); - - System.out.println("totalSize :{},{}" + totalSize + "," + org.getOrganizationName()); - - List dingEmployeeInfoSaveRecordList = new ArrayList<>(); - assemblerAccountId(allOrganizationEmployeePositionList, dingEmployeeInfoSaveRecordList); - System.out.println("dingEmployeeInfoSaveRecordList :{}" + JSON.toJSONString(dingEmployeeInfoSaveRecordList)); - // 批量保存用户信息 - saveBatch(dingEmployeeInfoSaveRecordList); - } - - private void saveBatch(List dingEmployeeInfoSaveRecordList) { - dingEmployeeInfoSaveRecordList = dingEmployeeInfoSaveRecordList.stream() - .filter(r -> ("true".equals(r.getMainJob()) - && "A".equals(r.getEmpStatus()) - && StringUtils.isNotBlank(r.getEmpPosUnitCode()) - && StringUtils.isNotBlank(r.getEmployeeCode())) - || "GE_48606ed7c10d4d15b0f931a9a4b89f21".equals(r.getEmployeeCode()) - ).collect(Collectors.toList()); - - Set uniqueKeySet = new HashSet(); - - List saveList = new ArrayList<>(); - - for (DingEmployeeInfo dingEmployeeInfo : dingEmployeeInfoSaveRecordList) { - if (uniqueKeySet.add(dingEmployeeInfo.getEmployeeCode() + dingEmployeeInfo.getEmpPosUnitCode())) { - saveList.add(dingEmployeeInfo); - } - } - - List organizations = iDingOrganizationService.list(); - Map organizationMap = organizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode, o -> o)); - - System.out.println("saveList:" + JSON.toJSONString(saveList)); - for (DingEmployeeInfo dingEmployeeInfo : saveList) { - String employeeCode = dingEmployeeInfo.getEmployeeCode(); - - DingEmployeeInfo employeeInfo = iDingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) - .eq(DingEmployeeInfo::getEmployeeCode, employeeCode) - .last(BizConst.LIMIT_1)); - if (Objects.isNull(employeeInfo)) { - iDingEmployeeInfoService.save(dingEmployeeInfo); - } else { - dingEmployeeInfo.setId(employeeInfo.getId()); - iDingEmployeeInfoService.saveOrUpdate(dingEmployeeInfo); - } - generateOrUpdateUserInfo(dingEmployeeInfo,organizationMap); - } - } - - private void assemblerAccountId(List segment, List dingEmployeeInfoSaveRecordList) { - List employeeCodes = segment.stream().map(OrganizationEmployeePosition::getEmployeeCode).distinct().collect(Collectors.toList()); - GenericResult> listGenericResult = zwddClient.listEmployeeAccountIds(employeeCodes); - List employeeAccountIdDTOList = listGenericResult.getData(); - if (CollUtil.isNotEmpty(employeeAccountIdDTOList)) { - Map employeeCodeAccountIdMap = employeeAccountIdDTOList.stream().filter(Objects::nonNull) - .collect(Collectors.toMap(EmployeeAccountIdDTO::getEmployeeCode, EmployeeAccountIdDTO::getAccountId)); - - List dingEmployeeInfos = buildDingEmployeeInfoRecordList(segment); - - dingEmployeeInfos = dingEmployeeInfos.stream().map(r -> { - r.setAccountId(employeeCodeAccountIdMap.get(r.getEmployeeCode())); - return r; - }).collect(Collectors.toList()); - dingEmployeeInfoSaveRecordList.addAll(dingEmployeeInfos); - } - } - private List buildDingEmployeeInfoRecordList(List allOrganizationEmployeePositionList) { - List saveRecordList = new ArrayList<>(); - for (OrganizationEmployeePosition organizationEmployeePosition : allOrganizationEmployeePositionList) { - List govEmployeePositions = organizationEmployeePosition.getGovEmployeePositions(); - if (CollUtil.isNotEmpty(govEmployeePositions)) { - List segmentSaveRecordList = new ArrayList<>(); - for (OrganizationEmployeePosition.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()); - dingEmployeeInfo.setCreateOn(LocalDateTime.now()); - dingEmployeeInfo.setUpdateOn(LocalDateTime.now()); - dingEmployeeInfo.setCreateBy(-1L); - dingEmployeeInfo.setUpdateBy(-1L); - segmentSaveRecordList.add(dingEmployeeInfo); - } - saveRecordList.addAll(segmentSaveRecordList); - } else { - DingEmployeeInfo dingEmployeeInfo = new DingEmployeeInfo(); - BeanUtils.copyProperties(organizationEmployeePosition, dingEmployeeInfo); - saveRecordList.add(dingEmployeeInfo); - } - } - return saveRecordList; - } - - public void generateOrUpdateUserInfo(DingEmployeeInfo dingEmployeeInfo,Map organizationMap) { - String employeeCode = dingEmployeeInfo.getEmployeeCode(); - UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) - .eq(UserInfo::getEmployeeCode, employeeCode)); - if (Objects.isNull(userInfo)) { - userInfo = UserInfo.builder() - .accountId(dingEmployeeInfo.getAccountId()) - .username(dingEmployeeInfo.getEmployeeName()) - .realName(dingEmployeeInfo.getEmployeeName()) - .employeeCode(dingEmployeeInfo.getEmployeeCode()) - .available(UserAvailableEnum.DISABLE.name()) - .createBy(-1L) - .updateBy(-1L) - .createOn(LocalDateTime.now()) - .updateOn(LocalDateTime.now()) - .empPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode()) - .avatar(dingEmployeeInfo.getAvatar()) - .build(); - if(StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())){ - DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode()); - userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); - userInfo.setRegionCode(dingOrganization.getDivisionCode()); - } - iUserInfoService.save(userInfo); - }else{ - userInfo.setAvatar(dingEmployeeInfo.getAvatar()); - userInfo.setEmpPosUnitCode(dingEmployeeInfo.getEmpPosUnitCode()); - if(StringUtils.isNotBlank(userInfo.getEmpPosUnitCode()) && organizationMap.containsKey(userInfo.getEmpPosUnitCode())){ - DingOrganization dingOrganization = organizationMap.get(userInfo.getEmpPosUnitCode()); - userInfo.setEmpPosUnitName(dingOrganization.getOrganizationName()); - userInfo.setRegionCode(dingOrganization.getDivisionCode()); - } - iUserInfoService.updateById(userInfo); - } - } -} diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/provincial/Test.java b/hz-pm-api/src/test/java/com/hz/pm/api/provincial/Test.java index c4fcb7f..50250ac 100644 --- a/hz-pm-api/src/test/java/com/hz/pm/api/provincial/Test.java +++ b/hz-pm-api/src/test/java/com/hz/pm/api/provincial/Test.java @@ -3,21 +3,21 @@ package com.hz.pm.api.provincial; import cn.hutool.crypto.SecureUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.file.service.FileService; import com.hz.pm.api.AppTests; import com.hz.pm.api.common.model.constant.ProjectDeclareConst; import com.hz.pm.api.common.model.constant.RegionConst; import com.hz.pm.api.projectdeclared.converter.ApplicationConverter; import com.hz.pm.api.projectdeclared.manage.PrequalificationDeclaredProjectManage; -import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.entity.ProjectApplication; +import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum; import com.hz.pm.api.projectlib.service.IProjectApplicationService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.provincial.service.IJoinReviewProvincialBureauService; import com.hz.pm.api.staging.contants.StagingContant; import com.hz.pm.api.staging.model.entity.ProjectStaging; import com.hz.pm.api.staging.service.IProjectStagingService; +import com.ningdatech.file.service.FileService; import com.wflow.exception.BusinessException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -37,7 +37,7 @@ import java.util.List; * @Author PoffyZhang */ @Slf4j -public class Test extends AppTests{// +public class Test extends AppTests {// @Autowired private PrequalificationDeclaredProjectManage prequalificationDeclaredProjectManage; @@ -68,19 +68,13 @@ public class Test extends AppTests{// log.info("" + bytesToSign); - String secret = "75152a97f20e4c4c854dc6301cf72ad4"; - String str = SecureUtil.hmacSha256(secret).digestBase64(bytesToSign,false); + String secret = "75152a97f20e4c4c854dc6301cf72ad4"; + String str = SecureUtil.hmacSha256(secret).digestBase64(bytesToSign, false); log.info("" + str); } @org.junit.Test - public void Test222(){ - Project project = projectService.getById(340); - prequalificationDeclaredProjectManage.directStartProcess(project,project.getPreStartUserId(),Boolean.FALSE); - } - - @org.junit.Test - public void Test3333(){ + public void Test3333() { String url = "http://devplat.oss-cn-hangzhou.aliyuncs.com/2023/04/13/5b2e1ef734e14437ba350ef97202c5b7.pdf?Expires=1681367401&OSSAccessKeyId=LTAI4GL7uypycnBjiRn55rMG&Signature=5PbIhpHNZvA2o8xYy8Ujw9Ibhl8%3D"; String s = "Expires"; System.out.println(url.replaceAll("&?" + s + "=[^&]*&", StringUtils.EMPTY)); @@ -90,33 +84,33 @@ public class Test extends AppTests{// private String active; @org.junit.Test - public void Test4444(){ + public void Test4444() { // 对接省级联审的接口 Project p = projectService.getById(448); List applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) .eq(ProjectApplication::getProjectId, p.getId())); - if(!joinReviewProvincialBureauService.pushImportProject( - ApplicationConverter.convertProject(p,applications,fileService,active))){ + if (!joinReviewProvincialBureauService.pushImportProject( + ApplicationConverter.convertProject(p, applications, fileService, active))) { throw new BusinessException("提交省级部门联审失败"); } System.out.println("成功"); } @org.junit.Test - public void test5(){ + public void test5() { //1. 定时取 项目暂存表的数据 去进行状态继续流转 List stagingList = projectStagingService.list(Wrappers.lambdaQuery(ProjectStaging.class) - .eq(ProjectStaging::getDead,Boolean.FALSE) + .eq(ProjectStaging::getDead, Boolean.FALSE) .le(ProjectStaging::getNextTime, LocalDateTime.now()) .le(ProjectStaging::getRetryTimes, StagingContant.Retry.MAX_RETRY_TIMES) .orderByAsc(ProjectStaging::getProjectId)); - log.info("需要状态流转的项目 size:{} :{}",stagingList.size(), JSON.toJSONString(stagingList)); + log.info("需要状态流转的项目 size:{} :{}", stagingList.size(), JSON.toJSONString(stagingList)); } @org.junit.Test - public void test6(){ + public void test6() { List projectList = projectService.list(Wrappers.lambdaQuery(Project.class) .eq(Project::getStage, ProjectStatusEnum.NOT_APPROVED.getCode()) .eq(Project::getStatus, ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS.getCode()) @@ -124,6 +118,6 @@ public class Test extends AppTests{// .eq(Project::getAreaCode, RegionConst.RC_HZ) .orderByAsc(Project::getCreateOn)); - log.info("需要去查询省级联审结果的项目 size:{}",projectList.size()); + log.info("需要去查询省级联审结果的项目 size:{}", projectList.size()); } }