# Conflicts: # pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.javamaster
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
import com.ningdatech.basic.exception.BizException; | |||||
import com.ningdatech.basic.function.VUtils; | import com.ningdatech.basic.function.VUtils; | ||||
import com.ningdatech.basic.model.PageVo; | import com.ningdatech.basic.model.PageVo; | ||||
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisal; | import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisal; | ||||
@@ -15,9 +16,14 @@ import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; | |||||
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalApplicationService; | import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalApplicationService; | ||||
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectService; | import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectService; | ||||
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalService; | import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalService; | ||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | import com.ningdatech.pmapi.projectlib.model.entity.Project; | ||||
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; | import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; | ||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | import com.ningdatech.pmapi.projectlib.service.IProjectService; | ||||
import com.ningdatech.pmapi.sys.model.entity.Role; | |||||
import com.ningdatech.pmapi.sys.service.IRoleService; | |||||
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | |||||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | ||||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | import com.ningdatech.pmapi.user.util.LoginUserUtil; | ||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
@@ -49,6 +55,7 @@ public class OrgSelfAppraisalManage { | |||||
private final IProjectService projectService; | private final IProjectService projectService; | ||||
private final IProjectApplicationService applicationService; | private final IProjectApplicationService applicationService; | ||||
private final IRoleService roleService; | |||||
/** | /** | ||||
* 绩效列表 | * 绩效列表 | ||||
@@ -60,23 +67,37 @@ public class OrgSelfAppraisalManage { | |||||
//当前登录用户 单位code | //当前登录用户 单位code | ||||
String empPosUnitCode = user.getEmpPosUnitCode(); | String empPosUnitCode = user.getEmpPosUnitCode(); | ||||
// 获取当前登录用户的角色列表,只有单位管理员才能查看该列表 | |||||
List<Role> userRoleList = user.getUserRoleList(); | |||||
List<Long> 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)){ | |||||
throw new BizException("系统没有单位管理员角色!"); | |||||
} | |||||
// 登录用户不是单位管理员,不能查看本单位的自评计划列表 | |||||
if (!roleIdList.contains(role.getId())){ | |||||
return PageVo.empty(); | |||||
} | |||||
// 获取登录用户所在单位的所有已终验项目信息 | |||||
List<Project> projectLists = projectService.list(Wrappers.lambdaQuery(Project.class) | List<Project> projectLists = projectService.list(Wrappers.lambdaQuery(Project.class) | ||||
.eq(Project::getStatus, ProjectStatusEnum.ACCEPTED.getCode()) | |||||
.eq(Project::getBuildOrgCode, empPosUnitCode)); | .eq(Project::getBuildOrgCode, empPosUnitCode)); | ||||
if(CollUtil.isEmpty(projectLists)){ | if(CollUtil.isEmpty(projectLists)){ | ||||
return PageVo.empty(); | return PageVo.empty(); | ||||
} | } | ||||
List<Long> projectIds = projectLists.stream().map(Project::getId).collect(Collectors.toList()); | List<Long> projectIds = projectLists.stream().map(Project::getId).collect(Collectors.toList()); | ||||
// 获取添加过该单位项目的所有评价计划信息 | |||||
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) | List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) | ||||
.in(PerformanceAppraisalProject::getProjectId, projectIds)); | .in(PerformanceAppraisalProject::getProjectId, projectIds)); | ||||
if(CollUtil.isEmpty(paps)){ | if(CollUtil.isEmpty(paps)){ | ||||
return PageVo.empty(); | return PageVo.empty(); | ||||
} | } | ||||
Set<Long> paIds = paps.stream().map(PerformanceAppraisalProject::getAppraisalId).collect(Collectors.toSet()); | Set<Long> paIds = paps.stream().map(PerformanceAppraisalProject::getAppraisalId).collect(Collectors.toSet()); | ||||
// 获取评价计划列表 | |||||
Page<PerformanceAppraisal> page = req.page(); | Page<PerformanceAppraisal> page = req.page(); | ||||
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) | LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) | ||||
.in(PerformanceAppraisal::getId,paIds) | .in(PerformanceAppraisal::getId,paIds) | ||||
@@ -86,10 +107,9 @@ public class OrgSelfAppraisalManage { | |||||
return PageVo.empty(); | return PageVo.empty(); | ||||
} | } | ||||
List<PerformanceAppraisalVO> res = page.getRecords().stream().map(p -> { | |||||
PerformanceAppraisalVO vo = BeanUtil.copyProperties(p,PerformanceAppraisalVO.class); | |||||
return vo; | |||||
}).collect(Collectors.toList()); | |||||
List<PerformanceAppraisalVO> 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()); | ||||
} | } | ||||
@@ -97,8 +117,9 @@ public class OrgSelfAppraisalManage { | |||||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | UserInfoDetails user = LoginUserUtil.loginUserDetail(); | ||||
PerformanceAppraisal plan = performanceAppraisalService.getById(planId); | PerformanceAppraisal plan = performanceAppraisalService.getById(planId); | ||||
VUtils.isTrue(Objects.isNull(plan)).throwMessage("该计划不存在!"); | |||||
VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!"); | |||||
// 获取评价计划内已添加的待评价项目信息 | |||||
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) | List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) | ||||
.eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())); | .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())); | ||||
Map<Long, PerformanceAppraisalProject> papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); | Map<Long, PerformanceAppraisalProject> papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); | ||||
@@ -106,11 +127,12 @@ public class OrgSelfAppraisalManage { | |||||
if(CollUtil.isEmpty(paps)){ | if(CollUtil.isEmpty(paps)){ | ||||
return PageVo.empty(); | return PageVo.empty(); | ||||
} | } | ||||
Set<String> projectIds = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); | |||||
// 获取本单位在当前评价计划内的项目 | |||||
Set<String> projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); | |||||
Page<Project> page = req.page(); | Page<Project> page = req.page(); | ||||
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class) | LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class) | ||||
.in(Project::getProjectCode, projectIds) | |||||
.in(Project::getProjectCode, projectCodes) | |||||
.eq(Project::getNewest, Boolean.TRUE) | .eq(Project::getNewest, Boolean.TRUE) | ||||
.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) | .eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) | ||||
.like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); | .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); | ||||
@@ -124,6 +146,10 @@ public class OrgSelfAppraisalManage { | |||||
.map(p -> { | .map(p -> { | ||||
PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); | PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); | ||||
PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); | PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); | ||||
vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType())); | |||||
vo.setIsReAppraisal(appraisalProject.getIsReAppraisal()); | |||||
vo.setSelfAppraisalStart(appraisalProject.getSelfAppraisalStart()); | |||||
vo.setSelfAppraisalEnd(appraisalProject.getSelfAppraisalEnd()); | |||||
vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject)); | vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject)); | ||||
return vo; | return vo; | ||||
}) | }) | ||||
@@ -1,5 +1,6 @@ | |||||
package com.ningdatech.pmapi.performance.model.vo; | package com.ningdatech.pmapi.performance.model.vo; | ||||
import com.alibaba.fastjson.annotation.JSONField; | |||||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; | import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; | ||||
import io.swagger.annotations.ApiModel; | import io.swagger.annotations.ApiModel; | ||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
@@ -51,4 +52,19 @@ public class PerformanceAppraisalProjectVO implements Serializable { | |||||
@ApiModelProperty("是否可自评") | @ApiModelProperty("是否可自评") | ||||
private Boolean canSelfAppraisal = Boolean.FALSE; | private Boolean canSelfAppraisal = Boolean.FALSE; | ||||
@ApiModelProperty("自评开始时间") | |||||
private LocalDateTime selfAppraisalStart; | |||||
@ApiModelProperty("自评结束时间") | |||||
private LocalDateTime selfAppraisalEnd; | |||||
@ApiModelProperty("自评总分") | |||||
private BigDecimal selfAppraisalScore; | |||||
@ApiModelProperty("打分时间") | |||||
@JSONField(format = "yyyy-MM-dd HH:mm") | |||||
private LocalDateTime scoreTime; | |||||
} | } |
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Component; | |||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Objects; | import java.util.Objects; | ||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* @Classname TagManage | * @Classname TagManage | ||||
@@ -130,32 +131,29 @@ public class TagManage { | |||||
if(CollUtil.isEmpty(dtos)){ | if(CollUtil.isEmpty(dtos)){ | ||||
return "参入的标签为空"; | return "参入的标签为空"; | ||||
} | } | ||||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | UserInfoDetails user = LoginUserUtil.loginUserDetail(); | ||||
Integer successNum = 0; | |||||
String projectCode = dtos.get(0).getProjectCode(); | |||||
Project project = projectService.getProjectByCode(projectCode); | |||||
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); | |||||
projectTagService.remove(Wrappers.lambdaQuery(ProjectTag.class) | |||||
.eq(ProjectTag::getProjectCode,projectCode)); | |||||
//去重 | |||||
dtos = dtos.stream().distinct().collect(Collectors.toList()); | |||||
for(TagToProjectDTO dto : dtos){ | for(TagToProjectDTO dto : dtos){ | ||||
String projectCode = dto.getProjectCode(); | |||||
Project project = projectService.getProjectByCode(projectCode); | |||||
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); | |||||
Long tagId = dto.getTagId(); | Long tagId = dto.getTagId(); | ||||
Tag tag = tagService.getById(tagId); | Tag tag = tagService.getById(tagId); | ||||
VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!"); | VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!"); | ||||
VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode())) | VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode())) | ||||
.throwMessage("项目和标签不是一个区域的!"); | .throwMessage("项目和标签不是一个区域的!"); | ||||
ProjectTag projectTag = new ProjectTag(); | ProjectTag projectTag = new ProjectTag(); | ||||
projectTag.setProjectCode(projectCode); | projectTag.setProjectCode(projectCode); | ||||
projectTag.setTagId(tagId); | projectTag.setTagId(tagId); | ||||
projectTag.setCreateOn(LocalDateTime.now()); | projectTag.setCreateOn(LocalDateTime.now()); | ||||
projectTag.setCreateBy(user.getUsername()); | projectTag.setCreateBy(user.getUsername()); | ||||
if(projectTagService.save(projectTag)){ | |||||
successNum ++; | |||||
} | |||||
projectTagService.save(projectTag); | |||||
} | } | ||||
return "保存成功" + successNum + "条"; | |||||
return "保存成功"; | |||||
} | } | ||||
public String removeTagToProject(TagToProjectDTO dto) { | public String removeTagToProject(TagToProjectDTO dto) { | ||||
@@ -399,12 +399,12 @@ public class ProjectDetailVO { | |||||
@ApiModelProperty("审批详情") | @ApiModelProperty("审批详情") | ||||
private ProcessProgressDetailVo process; | private ProcessProgressDetailVo process; | ||||
@ApiModelProperty("是否退回|驳回的项目版本") | |||||
private Boolean isBackReject; | |||||
@ApiModelProperty("标签") | @ApiModelProperty("标签") | ||||
private List<TagVO> tags; | private List<TagVO> tags; | ||||
@ApiModelProperty("是否退回|驳回的项目版本") | |||||
private Boolean isBackReject; | |||||
public String getVersionStr() { | public String getVersionStr() { | ||||
if (Objects.nonNull(this.newest) && this.newest) { | if (Objects.nonNull(this.newest) && this.newest) { | ||||
this.versionStr = "当前版本"; | this.versionStr = "当前版本"; | ||||
@@ -431,8 +431,9 @@ public class ProjectDetailVO { | |||||
@ApiModelProperty("项目阶段中文") | @ApiModelProperty("项目阶段中文") | ||||
private String stageName; | private String stageName; | ||||
public String getStageName(){ | |||||
if(Objects.nonNull(this.stage)){ | |||||
public String getStageName() { | |||||
if (Objects.nonNull(this.stage)) { | |||||
return ProjectStatusEnum.getDesc(this.stage); | return ProjectStatusEnum.getDesc(this.stage); | ||||
} | } | ||||
return StringUtils.EMPTY; | return StringUtils.EMPTY; | ||||
@@ -440,8 +441,9 @@ public class ProjectDetailVO { | |||||
@ApiModelProperty("项目状态中文") | @ApiModelProperty("项目状态中文") | ||||
private String statusName; | private String statusName; | ||||
public String getStatusName(){ | |||||
if(Objects.nonNull(this.status)){ | |||||
public String getStatusName() { | |||||
if (Objects.nonNull(this.status)) { | |||||
return ProjectStatusEnum.getDesc(this.status); | return ProjectStatusEnum.getDesc(this.status); | ||||
} | } | ||||
return StringUtils.EMPTY; | return StringUtils.EMPTY; | ||||
@@ -0,0 +1,142 @@ | |||||
package com.ningdatech.pmapi.scheduler.listener; | |||||
import cn.hutool.core.collection.CollUtil; | |||||
import com.alibaba.fastjson.JSON; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.ningdatech.pmapi.common.constant.BizConst; | |||||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||||
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; | |||||
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService; | |||||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | |||||
import com.wflow.workflow.notify.event.EarlyWarningEvent; | |||||
import lombok.RequiredArgsConstructor; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.flowable.engine.HistoryService; | |||||
import org.flowable.engine.history.HistoricActivityInstance; | |||||
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.LocalDateTime; | |||||
import java.time.ZoneId; | |||||
import java.util.List; | |||||
import java.util.Objects; | |||||
/** | |||||
* 预警规则触发 | |||||
* | |||||
* @author ZPF | |||||
* @return | |||||
* @since 2023/08/03 14:19 | |||||
*/ | |||||
@Slf4j | |||||
@Component | |||||
@RequiredArgsConstructor | |||||
public class EarlyWarningListener { | |||||
private final HistoryService historyService; | |||||
private final IProjectInstService projectInstService; | |||||
private final IProjectService projectService; | |||||
private final IEarlyWarningRecordsService earlyWarningRecordsService; | |||||
private final UserInfoHelper userInfoHelper; | |||||
@Async | |||||
@EventListener | |||||
public void onApplicationEvent(EarlyWarningEvent event) { | |||||
log.info("进入预警规则触发的 事件监听!"); | |||||
log.info("event:{}", JSON.toJSONString(event)); | |||||
String nodeId = event.getNodeId(); | |||||
Integer timeout = event.getTimeout(); | |||||
String noticeMethod = event.getNoticeMethod(); | |||||
String noticeContent = event.getNoticeContent(); | |||||
//1.根据nodeId 查询到 node 去查找 未完成 项目实例关系表 找到实例 | |||||
List<HistoricActivityInstance> hais = historyService.createHistoricActivityInstanceQuery() | |||||
.activityId(nodeId) | |||||
.unfinished() | |||||
.orderByHistoricActivityInstanceStartTime() | |||||
.asc() | |||||
.list(); | |||||
if (CollUtil.isEmpty(hais)) { | |||||
log.info("没有查到 历史实例"); | |||||
return; | |||||
} | |||||
String instanceId = hais.get(0).getProcessInstanceId(); | |||||
//查询当前未完成的此实例 | |||||
HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery() | |||||
.processInstanceId(instanceId) | |||||
.unfinished() | |||||
.singleResult(); | |||||
if (Objects.isNull(instance)) { | |||||
log.info("没有查到实例 或者 实例已经结束"); | |||||
return; | |||||
} | |||||
//2.查到 此流程实例的 项目 | |||||
ProjectInst pi = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) | |||||
.eq(ProjectInst::getInstCode, instanceId) | |||||
.last(BizConst.LIMIT_1)); | |||||
if (Objects.isNull(pi)) { | |||||
log.info("没有查到实例项目关联信息"); | |||||
return; | |||||
} | |||||
Long projectId = pi.getProjectId(); | |||||
Project project = projectService.getById(projectId); | |||||
if (Objects.isNull(project)) { | |||||
log.info("没有查到该项目信息"); | |||||
return; | |||||
} | |||||
for(HistoricActivityInstance hai : hais){ | |||||
String assignee = hai.getAssignee(); | |||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(assignee); | |||||
WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); | |||||
records.setAreaCode(project.getAreaCode()); | |||||
records.setBuildOrgCode(project.getBuildOrgCode()); | |||||
records.setBuildOrgName(project.getBuildOrgName()); | |||||
records.setCreateOn(LocalDateTime.now()); | |||||
records.setWarningTime(LocalDateTime.now()); | |||||
records.setInstStart(hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); | |||||
records.setInstType(pi.getInstType()); | |||||
records.setNoticeMethod(noticeMethod); | |||||
records.setNoticeContent(convertContent(noticeContent,project.getProjectName(),InstTypeEnum.getByCode(pi.getInstType()),timeout)); | |||||
records.setProjectName(project.getProjectName()); | |||||
records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode()); | |||||
records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY); | |||||
records.setWarningEmployeecode(assignee); | |||||
earlyWarningRecordsService.save(records); | |||||
} | |||||
} | |||||
/** | |||||
* 转换出 通知的内容 | |||||
* @param noticeContent | |||||
* @param projectName | |||||
* @param instTypeEnum | |||||
* @param timeout | |||||
* @return | |||||
*/ | |||||
private String convertContent(String noticeContent, String projectName, InstTypeEnum instTypeEnum, Integer timeout) { | |||||
noticeContent = noticeContent.replace("{projectName}",projectName) | |||||
.replace("{flowType}",Objects.nonNull(instTypeEnum) ? instTypeEnum.getDesc() : "{flowType}") | |||||
.replace("{time}",String.valueOf(timeout)); | |||||
log.info("通知内容 :{}",noticeContent); | |||||
return noticeContent; | |||||
} | |||||
} |
@@ -1,6 +1,10 @@ | |||||
package com.ningdatech.pmapi.sys.controller; | package com.ningdatech.pmapi.sys.controller; | ||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.log.annotation.WebLog; | import com.ningdatech.log.annotation.WebLog; | ||||
import com.ningdatech.pmapi.sys.model.req.WarningListReq; | |||||
import com.ningdatech.pmapi.sys.model.vo.WflowEarlyWarningRecordsVO; | |||||
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService; | |||||
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; | ||||
@@ -23,12 +27,14 @@ import java.util.List; | |||||
@Validated | @Validated | ||||
@RestController | @RestController | ||||
@RequestMapping("/api/v1/sys/early-warning") | @RequestMapping("/api/v1/sys/early-warning") | ||||
@Api(value = "EarlyWarning", tags = "系统管理-预警规则") | |||||
@Api(value = "EarlyWarning", tags = "预警管理") | |||||
@RequiredArgsConstructor | @RequiredArgsConstructor | ||||
public class EarlyWarningController { | public class EarlyWarningController { | ||||
private final IEarlyWarningService earlyWarningService; | private final IEarlyWarningService earlyWarningService; | ||||
private final IEarlyWarningRecordsService earlyWarningRecordsService; | |||||
@ApiOperation(value = "预警规则获取", notes = "预警规则获取") | @ApiOperation(value = "预警规则获取", notes = "预警规则获取") | ||||
@GetMapping("/detail/{areaCode}") | @GetMapping("/detail/{areaCode}") | ||||
public List<WflowEarlyWarningVO> detail(@PathVariable String areaCode) { | public List<WflowEarlyWarningVO> detail(@PathVariable String areaCode) { | ||||
@@ -41,4 +47,10 @@ public class EarlyWarningController { | |||||
public String save(@Validated @RequestBody WflowEarlyWarningDTO dto) { | public String save(@Validated @RequestBody WflowEarlyWarningDTO dto) { | ||||
return earlyWarningService.saveByDto(dto); | return earlyWarningService.saveByDto(dto); | ||||
} | } | ||||
@ApiOperation(value = "预警记录查询", notes = "预警记录查询") | |||||
@GetMapping("/records/{ruleType}") | |||||
public PageVo<WflowEarlyWarningRecordsVO> records(@PathVariable Integer ruleType, WarningListReq req) { | |||||
return earlyWarningRecordsService.records(ruleType,req); | |||||
} | |||||
} | } |
@@ -0,0 +1,17 @@ | |||||
package com.ningdatech.pmapi.sys.mapper; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; | |||||
import org.springframework.stereotype.Repository; | |||||
/** | |||||
* <p> | |||||
* Mapper 接口 | |||||
* </p> | |||||
* | |||||
* @author PoffyZhang | |||||
*/ | |||||
@Repository | |||||
public interface EarlyWarningRecordsMapper extends BaseMapper<WflowEarlyWarningRecords> { | |||||
} |
@@ -0,0 +1,108 @@ | |||||
package com.ningdatech.pmapi.sys.model.entity; | |||||
import com.baomidou.mybatisplus.annotation.IdType; | |||||
import com.baomidou.mybatisplus.annotation.TableId; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import lombok.NoArgsConstructor; | |||||
import lombok.ToString; | |||||
import lombok.experimental.Accessors; | |||||
import java.io.Serializable; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* 实体类 | |||||
* 角色分配 | |||||
* 预警触发通知记录 | |||||
* @author PoffyZhang | |||||
*/ | |||||
@Data | |||||
@NoArgsConstructor | |||||
@ToString(callSuper = true) | |||||
@Accessors(chain = true) | |||||
@TableName("wflow_early_warning_records") | |||||
@ApiModel(value = "WflowEarlyWarningRecords", description = "预警触发通知记录") | |||||
public class WflowEarlyWarningRecords implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty(value = "id") | |||||
@TableId(value = "id", type = IdType.AUTO) | |||||
private Long id; | |||||
/** | |||||
* 区域CODE | |||||
*/ | |||||
@ApiModelProperty(value = "区域CODE") | |||||
private String areaCode; | |||||
/** | |||||
* 项目名称 | |||||
*/ | |||||
@ApiModelProperty(value = "项目名称") | |||||
private String projectName; | |||||
/** | |||||
* 流程类型 | |||||
*/ | |||||
@ApiModelProperty(value = "流程类型") | |||||
private Integer instType; | |||||
/** | |||||
* 任务开始时间 | |||||
*/ | |||||
@ApiModelProperty(value = "任务开始时间") | |||||
private LocalDateTime instStart; | |||||
/** | |||||
* 预警时间 | |||||
*/ | |||||
@ApiModelProperty(value = "预警时间") | |||||
private LocalDateTime warningTime; | |||||
/** | |||||
* 通知人名 | |||||
*/ | |||||
@ApiModelProperty(value = "通知人名") | |||||
private String warningUsername; | |||||
/** | |||||
* 预警员工号 | |||||
*/ | |||||
@ApiModelProperty(value = "预警员工号") | |||||
private String warningEmployeecode; | |||||
/** | |||||
* 通知方式 | |||||
*/ | |||||
@ApiModelProperty(value = "通知方式 0浙政钉 1短信 逗号分隔") | |||||
private String noticeMethod; | |||||
/** | |||||
* 通知内容 | |||||
*/ | |||||
@ApiModelProperty(value = "通知内容") | |||||
private String noticeContent; | |||||
/** | |||||
* 申报单位 | |||||
*/ | |||||
@ApiModelProperty(value = "申报单位CODE") | |||||
private String buildOrgCode; | |||||
@ApiModelProperty(value = "申报单位") | |||||
private String buildOrgName; | |||||
/** | |||||
* 规则 | |||||
*/ | |||||
@ApiModelProperty(value = "规则类型 1.流程预警规则 2.填报预警规则 3.实施监督") | |||||
private Integer ruleType; | |||||
private LocalDateTime createOn; | |||||
} |
@@ -0,0 +1,38 @@ | |||||
package com.ningdatech.pmapi.sys.model.req; | |||||
import com.ningdatech.basic.model.PagePo; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* <p> | |||||
* WarningListReq | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 00:32 2022/7/23 | |||||
*/ | |||||
@Data | |||||
@ApiModel("预警记录查询参数类") | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class WarningListReq extends PagePo { | |||||
@ApiModelProperty("项目名称") | |||||
private String projectName; | |||||
@ApiModelProperty("申报单位") | |||||
private String buildOrgName; | |||||
@ApiModelProperty("提醒开始时间") | |||||
private LocalDateTime startTime; | |||||
@ApiModelProperty("提醒结束时间") | |||||
private LocalDateTime endTime; | |||||
@ApiModelProperty("区域Code") | |||||
private String areaCode; | |||||
} |
@@ -0,0 +1,128 @@ | |||||
package com.ningdatech.pmapi.sys.model.vo; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import lombok.NoArgsConstructor; | |||||
import lombok.ToString; | |||||
import lombok.experimental.Accessors; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.io.Serializable; | |||||
import java.time.LocalDateTime; | |||||
import java.util.Objects; | |||||
/** | |||||
* 实体类 | |||||
* 角色分配 | |||||
* 预警触发通知记录 | |||||
* @author PoffyZhang | |||||
*/ | |||||
@Data | |||||
@NoArgsConstructor | |||||
@ToString(callSuper = true) | |||||
@Accessors(chain = true) | |||||
@ApiModel(value = "WflowEarlyWarningRecords", description = "预警触发通知记录") | |||||
public class WflowEarlyWarningRecordsVO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty(value = "id") | |||||
private Long id; | |||||
/** | |||||
* 区域CODE | |||||
*/ | |||||
@ApiModelProperty(value = "区域CODE") | |||||
private String areaCode; | |||||
/** | |||||
* 项目名称 | |||||
*/ | |||||
@ApiModelProperty(value = "项目名称") | |||||
private String projectName; | |||||
/** | |||||
* 流程类型 | |||||
*/ | |||||
@ApiModelProperty(value = "流程类型") | |||||
private Integer instType; | |||||
/** | |||||
* 任务开始时间 | |||||
*/ | |||||
@ApiModelProperty(value = "任务开始时间") | |||||
private LocalDateTime instStart; | |||||
/** | |||||
* 预警时间 | |||||
*/ | |||||
@ApiModelProperty(value = "预警时间") | |||||
private LocalDateTime warningTime; | |||||
/** | |||||
* 通知人名 | |||||
*/ | |||||
@ApiModelProperty(value = "通知人名") | |||||
private String warningUsername; | |||||
/** | |||||
* 预警员工号 | |||||
*/ | |||||
@ApiModelProperty(value = "预警员工号") | |||||
private String warningEmployeecode; | |||||
/** | |||||
* 通知方式 | |||||
*/ | |||||
@ApiModelProperty(value = "通知方式 0浙政钉 1短信 逗号分隔") | |||||
private String noticeMethod; | |||||
/** | |||||
* 通知内容 | |||||
*/ | |||||
@ApiModelProperty(value = "通知内容") | |||||
private String noticeContent; | |||||
/** | |||||
* 申报单位 | |||||
*/ | |||||
@ApiModelProperty(value = "申报单位CODE") | |||||
private String buildOrgCode; | |||||
@ApiModelProperty(value = "申报单位") | |||||
private String buildOrgName; | |||||
/** | |||||
* 规则 | |||||
*/ | |||||
@ApiModelProperty(value = "规则类型 1.流程预警规则 2.填报预警规则 3.实施监督") | |||||
private Integer ruleType; | |||||
private LocalDateTime createOn; | |||||
private String createBy; | |||||
private LocalDateTime updateOn; | |||||
private String updateBy; | |||||
public String getInstTypeName(){ | |||||
if(Objects.nonNull(this.instType)){ | |||||
InstTypeEnum instEnum = InstTypeEnum.getByCode(this.instType); | |||||
if(Objects.nonNull(instEnum)){ | |||||
return instEnum.getDesc(); | |||||
} | |||||
} | |||||
return StringUtils.EMPTY; | |||||
} | |||||
public String getRuleTypeName(){ | |||||
if(Objects.nonNull(this.ruleType)){ | |||||
WarningRuleTypeEnum warningEnum = WarningRuleTypeEnum.checkByCode(this.instType); | |||||
if(Objects.nonNull(warningEnum)){ | |||||
return warningEnum.getDesc(); | |||||
} | |||||
} | |||||
return StringUtils.EMPTY; | |||||
} | |||||
} |
@@ -0,0 +1,15 @@ | |||||
package com.ningdatech.pmapi.sys.service; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; | |||||
import com.ningdatech.pmapi.sys.model.req.WarningListReq; | |||||
import com.ningdatech.pmapi.sys.model.vo.WflowEarlyWarningRecordsVO; | |||||
/** | |||||
* @author PoffyZhang | |||||
*/ | |||||
public interface IEarlyWarningRecordsService extends IService<WflowEarlyWarningRecords> { | |||||
PageVo<WflowEarlyWarningRecordsVO> records(Integer ruleType, WarningListReq req); | |||||
} |
@@ -0,0 +1,62 @@ | |||||
package com.ningdatech.pmapi.sys.service.impl; | |||||
import cn.hutool.core.bean.BeanUtil; | |||||
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.pmapi.sys.mapper.EarlyWarningRecordsMapper; | |||||
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; | |||||
import com.ningdatech.pmapi.sys.model.req.WarningListReq; | |||||
import com.ningdatech.pmapi.sys.model.vo.WflowEarlyWarningRecordsVO; | |||||
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService; | |||||
import lombok.RequiredArgsConstructor; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.List; | |||||
import java.util.Objects; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* <p> | |||||
* 业务实现类 | |||||
* 菜单 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
*/ | |||||
@Slf4j | |||||
@Service | |||||
@RequiredArgsConstructor | |||||
public class EarlyWarningRecordsServiceImpl extends ServiceImpl<EarlyWarningRecordsMapper, WflowEarlyWarningRecords> | |||||
implements IEarlyWarningRecordsService { | |||||
@Override | |||||
public PageVo<WflowEarlyWarningRecordsVO> records(Integer ruleType, WarningListReq req) { | |||||
Page<WflowEarlyWarningRecords> page = req.page(); | |||||
LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) | |||||
.eq(WflowEarlyWarningRecords::getRuleType, ruleType) | |||||
.eq(StringUtils.isNotBlank(req.getAreaCode()),WflowEarlyWarningRecords::getAreaCode,req.getAreaCode()) | |||||
.like(StringUtils.isNotBlank(req.getProjectName()), WflowEarlyWarningRecords::getProjectName, req.getProjectName()) | |||||
.like(StringUtils.isNotBlank(req.getBuildOrgName()), WflowEarlyWarningRecords::getBuildOrgName, req.getBuildOrgName()) | |||||
.ge(Objects.nonNull(req.getStartTime()),WflowEarlyWarningRecords::getWarningTime,req.getStartTime()) | |||||
.le(Objects.nonNull(req.getEndTime()),WflowEarlyWarningRecords::getWarningTime,req.getEndTime()) | |||||
.orderByDesc(WflowEarlyWarningRecords::getCreateOn); | |||||
this.page(page,wrapper); | |||||
if(0L == page.getTotal()){ | |||||
return PageVo.empty(); | |||||
} | |||||
List<WflowEarlyWarningRecordsVO> res = page.getRecords().stream() | |||||
.map(p -> BeanUtil.copyProperties(p,WflowEarlyWarningRecordsVO.class)) | |||||
.collect(Collectors.toList()); | |||||
return PageVo.of(res,page.getTotal()); | |||||
} | |||||
} |