From e1d8a1248cd2b14f96cd5117bb494a801d188e3d Mon Sep 17 00:00:00 2001 From: CMM <2198256324@qq.com> Date: Thu, 3 Aug 2023 11:11:38 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E8=AE=A1=E5=88=92-?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E8=87=AA=E8=AF=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/manage/OrgSelfAppraisalManage.java | 48 +++++++++++++++++----- .../model/vo/PerformanceAppraisalProjectVO.java | 16 ++++++++ 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java index bcb8322..30f3c57 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; 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.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.IPerformanceAppraisalProjectService; 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.service.IProjectApplicationService; 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.util.LoginUserUtil; import lombok.AllArgsConstructor; @@ -49,6 +55,7 @@ public class OrgSelfAppraisalManage { private final IProjectService projectService; private final IProjectApplicationService applicationService; + private final IRoleService roleService; /** * 绩效列表 @@ -60,23 +67,37 @@ public class OrgSelfAppraisalManage { //当前登录用户 单位code String empPosUnitCode = user.getEmpPosUnitCode(); + // 获取当前登录用户的角色列表,只有单位管理员才能查看该列表 + 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)){ + throw new BizException("系统没有单位管理员角色!"); + } + + // 登录用户不是单位管理员,不能查看本单位的自评计划列表 + 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)); 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)){ 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) @@ -86,10 +107,9 @@ public class OrgSelfAppraisalManage { return PageVo.empty(); } - List res = page.getRecords().stream().map(p -> { - PerformanceAppraisalVO vo = BeanUtil.copyProperties(p,PerformanceAppraisalVO.class); - return vo; - }).collect(Collectors.toList()); + List res = page.getRecords().stream() + .map(p -> BeanUtil.copyProperties(p, PerformanceAppraisalVO.class)) + .collect(Collectors.toList()); return PageVo.of(res,page.getTotal()); } @@ -97,8 +117,9 @@ public class OrgSelfAppraisalManage { UserInfoDetails user = LoginUserUtil.loginUserDetail(); PerformanceAppraisal plan = performanceAppraisalService.getById(planId); - VUtils.isTrue(Objects.isNull(plan)).throwMessage("该计划不存在!"); + VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!"); + // 获取评价计划内已添加的待评价项目信息 List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())); Map papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); @@ -106,11 +127,12 @@ public class OrgSelfAppraisalManage { if(CollUtil.isEmpty(paps)){ return PageVo.empty(); } - Set projectIds = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); + // 获取本单位在当前评价计划内的项目 + Set projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); Page page = req.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) - .in(Project::getProjectCode, projectIds) + .in(Project::getProjectCode, projectCodes) .eq(Project::getNewest, Boolean.TRUE) .eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); @@ -124,6 +146,10 @@ public class OrgSelfAppraisalManage { .map(p -> { PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); 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)); return vo; }) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java index af24f9a..c96768b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.performance.model.vo; +import com.alibaba.fastjson.annotation.JSONField; import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -51,4 +52,19 @@ public class PerformanceAppraisalProjectVO implements Serializable { @ApiModelProperty("是否可自评") 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; + + } From bbb399e9813794c5aa23c75a166140073a7635b3 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 3 Aug 2023 15:12:27 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/listener/EarlyWarningListener.java | 142 +++++++++++++++++++++ .../sys/mapper/EarlyWarningRecordsMapper.java | 17 +++ .../sys/model/entity/WflowEarlyWarningRecords.java | 108 ++++++++++++++++ .../sys/model/vo/WflowEarlyWarningRecordsVO.java | 106 +++++++++++++++ .../sys/service/IEarlyWarningRecordsService.java | 11 ++ .../impl/EarlyWarningRecordsServiceImpl.java | 26 ++++ 6 files changed, 410 insertions(+) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/EarlyWarningRecordsMapper.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IEarlyWarningRecordsService.java create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java new file mode 100644 index 0000000..9217caa --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java @@ -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 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 byCode + * @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; + } +} \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/EarlyWarningRecordsMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/EarlyWarningRecordsMapper.java new file mode 100644 index 0000000..5c3174f --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/mapper/EarlyWarningRecordsMapper.java @@ -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; + +/** + *

+ * Mapper 接口 + *

+ * + * @author PoffyZhang + */ +@Repository +public interface EarlyWarningRecordsMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java new file mode 100644 index 0000000..c130f7f --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java @@ -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; + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java new file mode 100644 index 0000000..6b8675b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java @@ -0,0 +1,106 @@ +package com.ningdatech.pmapi.sys.model.vo; + +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) +@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; + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IEarlyWarningRecordsService.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IEarlyWarningRecordsService.java new file mode 100644 index 0000000..34339ed --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IEarlyWarningRecordsService.java @@ -0,0 +1,11 @@ +package com.ningdatech.pmapi.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; + +/** + * @author PoffyZhang + */ +public interface IEarlyWarningRecordsService extends IService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java new file mode 100644 index 0000000..d952a55 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java @@ -0,0 +1,26 @@ +package com.ningdatech.pmapi.sys.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.pmapi.sys.mapper.EarlyWarningRecordsMapper; +import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; +import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + + +/** + *

+ * 业务实现类 + * 菜单 + *

+ * + * @author ZPF + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class EarlyWarningRecordsServiceImpl extends ServiceImpl + implements IEarlyWarningRecordsService { + +} From 4a18a6f39ee02e2038f81e7468f9d5c3be8d9096 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 3 Aug 2023 15:31:49 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=A0=87=E7=AD=BE=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=88=A0=E9=99=A4=20=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/portrait/manage/TagManage.java | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java index dbb16e5..75a7998 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java @@ -28,6 +28,7 @@ import org.springframework.stereotype.Component; import java.time.LocalDateTime; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * @Classname TagManage @@ -130,32 +131,29 @@ public class TagManage { if(CollUtil.isEmpty(dtos)){ return "参入的标签为空"; } - 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){ - String projectCode = dto.getProjectCode(); - Project project = projectService.getProjectByCode(projectCode); - VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); Long tagId = dto.getTagId(); Tag tag = tagService.getById(tagId); VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!"); - VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode())) .throwMessage("项目和标签不是一个区域的!"); - ProjectTag projectTag = new ProjectTag(); projectTag.setProjectCode(projectCode); projectTag.setTagId(tagId); projectTag.setCreateOn(LocalDateTime.now()); projectTag.setCreateBy(user.getUsername()); - if(projectTagService.save(projectTag)){ - successNum ++; - } + projectTagService.save(projectTag); } - return "保存成功" + successNum + "条"; + return "保存成功"; } public String removeTagToProject(TagToProjectDTO dto) { From ac5e10d26b47f7f7d449d1b4001b9d44fe34b511 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 3 Aug 2023 15:38:46 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java index 9217caa..56aa2e6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java @@ -128,7 +128,7 @@ public class EarlyWarningListener { * 转换出 通知的内容 * @param noticeContent * @param projectName - * @param byCode + * @param instTypeEnum * @param timeout * @return */ From c80c7a3e7caec73e3a99f2002f6b7cca8033726e Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 3 Aug 2023 16:15:09 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/controller/EarlyWarningController.java | 12 ++++++++ .../pmapi/sys/model/req/WarningListReq.java | 35 ++++++++++++++++++++++ .../sys/model/vo/WflowEarlyWarningRecordsVO.java | 24 ++++++++++++++- .../sys/service/IEarlyWarningRecordsService.java | 4 +++ .../impl/EarlyWarningRecordsServiceImpl.java | 34 +++++++++++++++++++++ 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/EarlyWarningController.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/EarlyWarningController.java index a4dd3d8..84c9d30 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/EarlyWarningController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/EarlyWarningController.java @@ -1,6 +1,10 @@ package com.ningdatech.pmapi.sys.controller; +import com.ningdatech.basic.model.PageVo; 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.vo.WflowEarlyWarningVO; import com.wflow.service.IEarlyWarningService; @@ -29,6 +33,8 @@ public class EarlyWarningController { private final IEarlyWarningService earlyWarningService; + private final IEarlyWarningRecordsService earlyWarningRecordsService; + @ApiOperation(value = "预警规则获取", notes = "预警规则获取") @GetMapping("/detail/{areaCode}") public List detail(@PathVariable String areaCode) { @@ -41,4 +47,10 @@ public class EarlyWarningController { public String save(@Validated @RequestBody WflowEarlyWarningDTO dto) { return earlyWarningService.saveByDto(dto); } + + @ApiOperation(value = "预警记录查询", notes = "预警记录查询") + @GetMapping("/records/{ruleType}") + public PageVo records(@PathVariable Integer ruleType, WarningListReq req) { + return earlyWarningRecordsService.records(ruleType,req); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java new file mode 100644 index 0000000..1e8e3a6 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java @@ -0,0 +1,35 @@ +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; + +/** + *

+ * WarningListReq + *

+ * + * @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; +} \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java index 6b8675b..e6d8b64 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java @@ -1,14 +1,17 @@ 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; /** * 实体类 @@ -103,4 +106,23 @@ public class WflowEarlyWarningRecordsVO implements Serializable { 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; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IEarlyWarningRecordsService.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IEarlyWarningRecordsService.java index 34339ed..8ebc57c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IEarlyWarningRecordsService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/IEarlyWarningRecordsService.java @@ -1,11 +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 { + PageVo records(Integer ruleType, WarningListReq req); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java index d952a55..af2411e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java @@ -1,13 +1,25 @@ 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; + /** *

@@ -23,4 +35,26 @@ import org.springframework.stereotype.Service; public class EarlyWarningRecordsServiceImpl extends ServiceImpl implements IEarlyWarningRecordsService { + @Override + public PageVo records(Integer ruleType, WarningListReq req) { + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) + .eq(WflowEarlyWarningRecords::getRuleType, ruleType) + .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()); + + this.page(page,wrapper); + + if(0L == page.getTotal()){ + return PageVo.empty(); + } + + List res = page.getRecords().stream() + .map(p -> BeanUtil.copyProperties(p,WflowEarlyWarningRecordsVO.class)) + .collect(Collectors.toList()); + + return PageVo.of(res,page.getTotal()); + } } From 10f1e6fa351732baf301cbb6d5dc01ef0e032414 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 3 Aug 2023 16:26:53 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/sys/controller/EarlyWarningController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/EarlyWarningController.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/EarlyWarningController.java index 84c9d30..9c36213 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/EarlyWarningController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/EarlyWarningController.java @@ -27,7 +27,7 @@ import java.util.List; @Validated @RestController @RequestMapping("/api/v1/sys/early-warning") -@Api(value = "EarlyWarning", tags = "系统管理-预警规则") +@Api(value = "EarlyWarning", tags = "预警管理") @RequiredArgsConstructor public class EarlyWarningController { From 005bf0a700f78d6eb117898ef120850cedc41ef7 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 3 Aug 2023 16:44:05 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E8=AE=B0=E5=BD=95=20?= =?UTF-8?q?=E9=99=8D=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java index af2411e..99ab9a3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java @@ -43,7 +43,8 @@ public class EarlyWarningRecordsServiceImpl extends ServiceImpl Date: Fri, 4 Aug 2023 09:22:13 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E8=AE=B0=E5=BD=95=20?= =?UTF-8?q?=E6=8C=89=E5=8C=BA=E5=9F=9Fcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java | 3 +++ .../pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java | 1 + 2 files changed, 4 insertions(+) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java index 1e8e3a6..3373c84 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/req/WarningListReq.java @@ -32,4 +32,7 @@ public class WarningListReq extends PagePo { @ApiModelProperty("提醒结束时间") private LocalDateTime endTime; + + @ApiModelProperty("区域Code") + private String areaCode; } \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java index 99ab9a3..f3e6c03 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/service/impl/EarlyWarningRecordsServiceImpl.java @@ -40,6 +40,7 @@ public class EarlyWarningRecordsServiceImpl extends ServiceImpl page = req.page(); LambdaQueryWrapper 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())