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 1/2] =?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 2/2] =?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()); + } }