@@ -101,7 +101,7 @@ public class ProjectManageUtil { | |||||
public static void projectBaseQuery(LambdaQueryWrapper<Project> query) { | public static void projectBaseQuery(LambdaQueryWrapper<Project> query) { | ||||
query.select(Project::getId, Project::getStage, Project::getStatus, Project::getProjectCode, | query.select(Project::getId, Project::getStage, Project::getStatus, Project::getProjectCode, | ||||
Project::getBuildOrgCode, Project::getBuildOrgName, Project::getApprovalAmount, Project::getApprovalDate, | Project::getBuildOrgCode, Project::getBuildOrgName, Project::getApprovalAmount, Project::getApprovalDate, | ||||
Project::getCreateOn, Project::getProjectName, Project::getProjectYear, | |||||
Project::getCreateOn, Project::getProjectName, Project::getProjectYear, Project::getIsMajorProject, | |||||
Project::getDeclareAmount, Project::getReviewAmount, Project::getUnitStrip); | Project::getDeclareAmount, Project::getReviewAmount, Project::getUnitStrip); | ||||
} | } | ||||
@@ -497,4 +497,7 @@ public class Project implements Serializable { | |||||
@ApiModelProperty("项目终止状态") | @ApiModelProperty("项目终止状态") | ||||
private Integer stoppedStatus; | private Integer stoppedStatus; | ||||
@ApiModelProperty("是否是重大项目") | |||||
private Boolean isMajorProject; | |||||
} | } |
@@ -0,0 +1,75 @@ | |||||
package com.hz.pm.api.scheduler.task; | |||||
import cn.hutool.json.JSONUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.hz.pm.api.projectlib.model.entity.Project; | |||||
import com.hz.pm.api.projectlib.service.IProjectService; | |||||
import com.hz.pm.api.user.helper.MhUnitCache; | |||||
import com.wflow.bean.dto.MajorProjectRuleDTO; | |||||
import com.wflow.bean.entity.WflowEarlyWarning; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | |||||
import com.wflow.service.IEarlyWarningService; | |||||
import lombok.RequiredArgsConstructor; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | |||||
import org.springframework.scheduling.annotation.Scheduled; | |||||
import org.springframework.stereotype.Component; | |||||
import java.util.ArrayList; | |||||
import java.util.Comparator; | |||||
import java.util.List; | |||||
import java.util.Optional; | |||||
/** | |||||
* <p> | |||||
* MajorProjectEvalTask | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 11:29 2024/9/10 | |||||
*/ | |||||
@Slf4j | |||||
@Component | |||||
@ConditionalOnExpression("${major-project-eval.open:true}") | |||||
@RequiredArgsConstructor | |||||
public class MajorProjectEvalTask { | |||||
private final IEarlyWarningService earlyWarningService; | |||||
private final IProjectService projectService; | |||||
private final MhUnitCache mhUnitCache; | |||||
@Scheduled(cron = "${major-project-eval.cron:0 0/3 * * * ?}") | |||||
public void doMajorProjectEval() { | |||||
Wrapper<WflowEarlyWarning> query = Wrappers.lambdaQuery(WflowEarlyWarning.class) | |||||
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.MAJOR_PROJECT.getCode()) | |||||
.eq(WflowEarlyWarning::getIsOpen, Boolean.TRUE); | |||||
List<WflowEarlyWarning> earlyWarnings = earlyWarningService.list(query); | |||||
if (earlyWarnings.isEmpty()) { | |||||
return; | |||||
} | |||||
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
.select(Project::getId, Project::getReviewAmount, Project::getBuildOrgCode) | |||||
.isNotNull(Project::getReviewAmount) | |||||
.gt(Project::getReviewAmount, 0) | |||||
.eq(Project::getNewest, Boolean.TRUE)); | |||||
List<Project> projectsUpdate = new ArrayList<>(); | |||||
if (!projects.isEmpty()) { | |||||
for (Project project : projects) { | |||||
long unitId = Long.parseLong(project.getBuildOrgCode()); | |||||
List<Long> unitIdPaths = mhUnitCache.getUnitIdPaths(unitId); | |||||
Optional<WflowEarlyWarning> earlyWarning = earlyWarnings.stream() | |||||
.filter(warning -> unitIdPaths.contains(warning.getMhUnitId())) | |||||
.max(Comparator.comparing(w -> unitIdPaths.indexOf(w.getMhUnitId()))); | |||||
earlyWarning.ifPresent(warning -> { | |||||
MajorProjectRuleDTO rule = JSONUtil.toBean(warning.getRule(), MajorProjectRuleDTO.class); | |||||
boolean isMajorProject = project.getReviewAmount().compareTo(rule.getMinimumReviewAmount()) >= 0; | |||||
project.setIsMajorProject(isMajorProject); | |||||
projectsUpdate.add(project); | |||||
}); | |||||
} | |||||
projectService.updateBatchById(projectsUpdate); | |||||
} | |||||
} | |||||
} |
@@ -1,11 +1,10 @@ | |||||
package com.hz.pm.api.sys.controller; | package com.hz.pm.api.sys.controller; | ||||
import com.hz.pm.api.user.helper.MhUnitCache; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.log.annotation.WebLog; | |||||
import com.hz.pm.api.sys.model.req.WarningListReq; | import com.hz.pm.api.sys.model.req.WarningListReq; | ||||
import com.hz.pm.api.sys.model.vo.WflowEarlyWarningRecordsVO; | import com.hz.pm.api.sys.model.vo.WflowEarlyWarningRecordsVO; | ||||
import com.hz.pm.api.sys.service.IEarlyWarningRecordsService; | import com.hz.pm.api.sys.service.IEarlyWarningRecordsService; | ||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.log.annotation.WebLog; | |||||
import com.wflow.bean.dto.WflowEarlyWarningDTO; | import com.wflow.bean.dto.WflowEarlyWarningDTO; | ||||
import com.wflow.bean.vo.WflowEarlyWarningVO; | import com.wflow.bean.vo.WflowEarlyWarningVO; | ||||
import com.wflow.service.IEarlyWarningService; | import com.wflow.service.IEarlyWarningService; | ||||
@@ -35,12 +34,11 @@ public class EarlyWarningController { | |||||
private final IEarlyWarningService earlyWarningService; | private final IEarlyWarningService earlyWarningService; | ||||
private final IEarlyWarningRecordsService earlyWarningRecordsService; | private final IEarlyWarningRecordsService earlyWarningRecordsService; | ||||
private final MhUnitCache mhUnitCache; | |||||
@ApiOperation(value = "预警规则获取", notes = "预警规则获取") | @ApiOperation(value = "预警规则获取", notes = "预警规则获取") | ||||
@GetMapping("/detail/{mhUnitId}") | |||||
public List<WflowEarlyWarningVO> detail(@PathVariable Long mhUnitId) { | |||||
return earlyWarningService.detailByMhUnitId(mhUnitId); | |||||
@GetMapping("/detail/{mhUnitId}/{ruleType}") | |||||
public List<WflowEarlyWarningVO> detail(@PathVariable Long mhUnitId, @PathVariable Integer ruleType) { | |||||
return earlyWarningService.detailByMhUnitId(mhUnitId, ruleType); | |||||
} | } | ||||
@ApiOperation(value = "预警规则保存", notes = "预警规则保存") | @ApiOperation(value = "预警规则保存", notes = "预警规则保存") | ||||
@@ -53,6 +51,6 @@ public class EarlyWarningController { | |||||
@ApiOperation(value = "预警记录查询", notes = "预警记录查询") | @ApiOperation(value = "预警记录查询", notes = "预警记录查询") | ||||
@GetMapping("/records/{ruleType}") | @GetMapping("/records/{ruleType}") | ||||
public PageVo<WflowEarlyWarningRecordsVO> records(@PathVariable Integer ruleType, WarningListReq req) { | public PageVo<WflowEarlyWarningRecordsVO> records(@PathVariable Integer ruleType, WarningListReq req) { | ||||
return earlyWarningRecordsService.records(ruleType,req); | |||||
return earlyWarningRecordsService.records(ruleType, req); | |||||
} | } | ||||
} | } |
@@ -95,4 +95,10 @@ public class WorkbenchController { | |||||
return workbenchManage.projectMonitorEarlyWarnings(req); | return workbenchManage.projectMonitorEarlyWarnings(req); | ||||
} | } | ||||
@GetMapping("/pageMajorProjects") | |||||
@ApiOperation("获取重大项目动态") | |||||
public PageVo<ProjectLibListItemVO> listMajorProjects(WorkbenchProjectLibReq req) { | |||||
return workbenchManage.pageMajorProjects(req); | |||||
} | |||||
} | } |
@@ -47,13 +47,14 @@ import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords; | |||||
import com.hz.pm.api.sys.model.vo.ProjectEarlyWarningVO; | import com.hz.pm.api.sys.model.vo.ProjectEarlyWarningVO; | ||||
import com.hz.pm.api.sys.service.IEarlyWarningRecordsService; | import com.hz.pm.api.sys.service.IEarlyWarningRecordsService; | ||||
import com.hz.pm.api.sys.service.IProjectEarlyWarningService; | import com.hz.pm.api.sys.service.IProjectEarlyWarningService; | ||||
import com.hz.pm.api.sys.utils.EarlyWarningUtil; | |||||
import com.hz.pm.api.todocenter.manage.TodoCenterManage; | import com.hz.pm.api.todocenter.manage.TodoCenterManage; | ||||
import com.hz.pm.api.todocenter.model.req.ToBeProcessedReq; | import com.hz.pm.api.todocenter.model.req.ToBeProcessedReq; | ||||
import com.hz.pm.api.todocenter.model.vo.ResToBeProcessedVO; | import com.hz.pm.api.todocenter.model.vo.ResToBeProcessedVO; | ||||
import com.hz.pm.api.todocenter.model.vo.TodoCenterStatisticsVO; | import com.hz.pm.api.todocenter.model.vo.TodoCenterStatisticsVO; | ||||
import com.hz.pm.api.todocenter.model.vo.TodoVO; | import com.hz.pm.api.todocenter.model.vo.TodoVO; | ||||
import com.hz.pm.api.user.helper.MhUnitCache; | import com.hz.pm.api.user.helper.MhUnitCache; | ||||
import com.hz.pm.api.user.helper.MhUnitQueryAuthHelper; | |||||
import com.hz.pm.api.user.helper.MhUnitQueryAuthHelper.UnitQueryState; | |||||
import com.hz.pm.api.user.security.model.UserFullInfoDTO; | import com.hz.pm.api.user.security.model.UserFullInfoDTO; | ||||
import com.hz.pm.api.user.security.model.UserInfoDetails; | import com.hz.pm.api.user.security.model.UserInfoDetails; | ||||
import com.hz.pm.api.user.util.LoginUserUtil; | import com.hz.pm.api.user.util.LoginUserUtil; | ||||
@@ -113,6 +114,7 @@ public class WorkbenchManage { | |||||
private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; | private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; | ||||
private final IPurchaseStatusChangeService purchaseStatusChangeService; | private final IPurchaseStatusChangeService purchaseStatusChangeService; | ||||
private final IProjectEarlyWarningService projectEarlyWarningService; | private final IProjectEarlyWarningService projectEarlyWarningService; | ||||
private final MhUnitQueryAuthHelper mhUnitQueryAuthHelper; | |||||
public WorkbenchVO getWorkbenchData(Integer year) { | public WorkbenchVO getWorkbenchData(Integer year) { | ||||
WorkbenchVO res = new WorkbenchVO(); | WorkbenchVO res = new WorkbenchVO(); | ||||
@@ -801,9 +803,9 @@ public class WorkbenchManage { | |||||
UserInfoDetails userInfoDetails = LoginUserUtil.loginUserDetail(); | UserInfoDetails userInfoDetails = LoginUserUtil.loginUserDetail(); | ||||
// 从预警表中查询当前登录用户所能查看的项目 | // 从预警表中查询当前登录用户所能查看的项目 | ||||
LambdaQueryWrapper<ProjectEarlyWarning> queryWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class); | LambdaQueryWrapper<ProjectEarlyWarning> queryWrapper = Wrappers.lambdaQuery(ProjectEarlyWarning.class); | ||||
buildPermissionWarningWrapper(queryWrapper,userInfoDetails); | |||||
buildPermissionWarningWrapper(queryWrapper, userInfoDetails); | |||||
// 查询状态非正常的预警信息 | // 查询状态非正常的预警信息 | ||||
queryWrapper.eq(ProjectEarlyWarning::getNormal,Boolean.FALSE); | |||||
queryWrapper.eq(ProjectEarlyWarning::getNormal, Boolean.FALSE); | |||||
queryWrapper.ne(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.NORMAL); | queryWrapper.ne(ProjectEarlyWarning::getStatus, ProjectEarlyWarningStatusEnum.NORMAL); | ||||
if (req.getUnitStrip() != null) { | if (req.getUnitStrip() != null) { | ||||
String unitStripSql = String.format("select 1 from nd_project np where " + | String unitStripSql = String.format("select 1 from nd_project np where " + | ||||
@@ -819,7 +821,7 @@ public class WorkbenchManage { | |||||
} | } | ||||
List<ProjectEarlyWarning> records = projectEarlyWarningService.list(queryWrapper); | List<ProjectEarlyWarning> records = projectEarlyWarningService.list(queryWrapper); | ||||
if (Objects.nonNull(req.getUnitId())){ | |||||
if (Objects.nonNull(req.getUnitId())) { | |||||
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(req.getUnitId()); | List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(req.getUnitId()); | ||||
List<String> queryMhUnitIdList = CollUtils.convert(viewUnitIds, String::valueOf); | List<String> queryMhUnitIdList = CollUtils.convert(viewUnitIds, String::valueOf); | ||||
records = records.stream().filter(record -> queryMhUnitIdList.contains(record.getBuildOrgCode())).collect(Collectors.toList()); | records = records.stream().filter(record -> queryMhUnitIdList.contains(record.getBuildOrgCode())).collect(Collectors.toList()); | ||||
@@ -860,18 +862,54 @@ public class WorkbenchManage { | |||||
} | } | ||||
private void buildPermissionWarningWrapper(LambdaQueryWrapper<ProjectEarlyWarning> wrapper, UserInfoDetails user) { | private void buildPermissionWarningWrapper(LambdaQueryWrapper<ProjectEarlyWarning> wrapper, UserInfoDetails user) { | ||||
//如果是超管的话 | |||||
if (user.hasSuperAdmin() || user.hasRegionAdmin()) { | |||||
// 可以看所有 | |||||
} | |||||
// 如果是单位管理员 查看本单位及下属单位 | |||||
else if (user.hasOrgAdmin()) { | |||||
List<String> viewChildIdsRecursion = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()) | |||||
.stream().map(String::valueOf).collect(Collectors.toList()); | |||||
wrapper.in(ProjectEarlyWarning::getBuildOrgCode, viewChildIdsRecursion); | |||||
} else { | |||||
// 否则都只能看自己单位的 | |||||
wrapper.eq(ProjectEarlyWarning::getBuildOrgCode, user.getMhUnitIdStr()); | |||||
} | |||||
//如果是超管的话 | |||||
if (user.hasSuperAdmin() || user.hasRegionAdmin()) { | |||||
// 可以看所有 | |||||
} | |||||
// 如果是单位管理员 查看本单位及下属单位 | |||||
else if (user.hasOrgAdmin()) { | |||||
List<String> viewChildIdsRecursion = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()) | |||||
.stream().map(String::valueOf).collect(Collectors.toList()); | |||||
wrapper.in(ProjectEarlyWarning::getBuildOrgCode, viewChildIdsRecursion); | |||||
} else { | |||||
// 否则都只能看自己单位的 | |||||
wrapper.eq(ProjectEarlyWarning::getBuildOrgCode, user.getMhUnitIdStr()); | |||||
} | |||||
} | |||||
public PageVo<ProjectLibListItemVO> pageMajorProjects(WorkbenchProjectLibReq req) { | |||||
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class) | |||||
.eq(Project::getNewest, Boolean.TRUE) | |||||
.eq(req.getProjectYear() != null, Project::getProjectYear, req.getProjectYear()) | |||||
.eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) | |||||
.eq(Project::getIsMajorProject, Boolean.TRUE) | |||||
.orderByDesc(Project::getUpdateOn); | |||||
UnitQueryState state = mhUnitQueryAuthHelper.listCanViewUnitIds(req.getUnitId()); | |||||
if (!state.isState()) { | |||||
return PageVo.empty(); | |||||
} | |||||
if (CollUtil.isNotEmpty(state.getUnitIds())) { | |||||
query.in(Project::getBuildOrgCode, state.getUnitIds()); | |||||
} | } | ||||
ProjectManageUtil.projectBaseQuery(query); | |||||
Page<Project> page = projectService.page(req.page(), query); | |||||
if (page.getTotal() == 0) { | |||||
return PageVo.empty(); | |||||
} | |||||
List<ProjectLibListItemVO> data = page.getRecords().stream().map(w -> { | |||||
ProjectLibListItemVO item = new ProjectLibListItemVO(); | |||||
item.setId(w.getId()); | |||||
item.setStage(w.getStage()); | |||||
item.setStatus(w.getStatus()); | |||||
item.setProjectCode(w.getProjectCode()); | |||||
item.setProjectName(w.getProjectName()); | |||||
item.setBuildOrgName(w.getBuildOrgName()); | |||||
item.setBuildOrgCode(w.getBuildOrgCode()); | |||||
item.setDeclaredAmount(w.getDeclareAmount()); | |||||
item.setReviewAmount(w.getReviewAmount()); | |||||
return item; | |||||
}).collect(Collectors.toList()); | |||||
return PageVo.of(data, page.getTotal()); | |||||
} | |||||
} | } |
@@ -231,4 +231,7 @@ random-invite: | |||||
core-pool-size: 2 | core-pool-size: 2 | ||||
thread-name-prefix: expert-invite-executor- | thread-name-prefix: expert-invite-executor- | ||||
early-warning-without-submit: | early-warning-without-submit: | ||||
open: true | |||||
open: false | |||||
major-project-eval: | |||||
open: true | |||||
cron: 0 0/2 8-20 * * ? |
@@ -254,4 +254,7 @@ random-invite: | |||||
core-pool-size: 3 | core-pool-size: 3 | ||||
thread-name-prefix: expert-invite-executor- | thread-name-prefix: expert-invite-executor- | ||||
early-warning-without-submit: | early-warning-without-submit: | ||||
open: true | |||||
open: true | |||||
major-project-eval: | |||||
open: true | |||||
cron: 0 0/5 6-22 * * ? |