Browse Source

modify:

1. 预警记录增加查询方法;
tags/24091301
WendyYang 2 months ago
parent
commit
28a380e76f
3 changed files with 38 additions and 10 deletions
  1. +10
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/sys/mapper/EarlyWarningRecordsMapper.java
  2. +8
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IEarlyWarningRecordsService.java
  3. +20
    -9
      hz-pm-api/src/main/java/com/hz/pm/api/sys/service/impl/EarlyWarningRecordsServiceImpl.java

+ 10
- 0
hz-pm-api/src/main/java/com/hz/pm/api/sys/mapper/EarlyWarningRecordsMapper.java View File

@@ -1,9 +1,15 @@
package com.hz.pm.api.sys.mapper; package com.hz.pm.api.sys.mapper;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords; import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;


import java.util.List;

/** /**
* <p> * <p>
* Mapper 接口 * Mapper 接口
@@ -14,4 +20,8 @@ import org.springframework.stereotype.Repository;
@Repository @Repository
public interface EarlyWarningRecordsMapper extends BaseMapper<WflowEarlyWarningRecords> { public interface EarlyWarningRecordsMapper extends BaseMapper<WflowEarlyWarningRecords> {



@Select("SELECT * FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY PROJECT_CODE ORDER BY WARN_TIME DESC) AS row_no FROM WFLOW_EARLY_WARNING_RECORDS ${ew.customSqlSegment}) t WHERE row_no = 1")
List<WflowEarlyWarningRecords> selectProjectLastWarningRecords(@Param(Constants.WRAPPER) LambdaQueryWrapper<WflowEarlyWarningRecords> ew);

} }

+ 8
- 1
hz-pm-api/src/main/java/com/hz/pm/api/sys/service/IEarlyWarningRecordsService.java View File

@@ -1,10 +1,14 @@
package com.hz.pm.api.sys.service; package com.hz.pm.api.sys.service;


import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.basic.model.PageVo;
import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords; import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords;
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.ningdatech.basic.model.PageVo;
import com.wflow.enums.WarningRuleTypeEnum;

import java.util.Collection;
import java.util.List;


/** /**
* @author PoffyZhang * @author PoffyZhang
@@ -12,4 +16,7 @@ import com.hz.pm.api.sys.model.vo.WflowEarlyWarningRecordsVO;
public interface IEarlyWarningRecordsService extends IService<WflowEarlyWarningRecords> { public interface IEarlyWarningRecordsService extends IService<WflowEarlyWarningRecords> {


PageVo<WflowEarlyWarningRecordsVO> records(Integer ruleType, WarningListReq req); PageVo<WflowEarlyWarningRecordsVO> records(Integer ruleType, WarningListReq req);

List<WflowEarlyWarningRecords> listProjectLastWarningRecords(Collection<String> projectCodes, WarningRuleTypeEnum ruleType);

} }

+ 20
- 9
hz-pm-api/src/main/java/com/hz/pm/api/sys/service/impl/EarlyWarningRecordsServiceImpl.java View File

@@ -6,17 +6,19 @@ 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.basic.model.PageVo;
import com.hz.pm.api.sys.mapper.EarlyWarningRecordsMapper; import com.hz.pm.api.sys.mapper.EarlyWarningRecordsMapper;
import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords; import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords;
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.wflow.enums.WarningRuleTypeEnum;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -41,25 +43,34 @@ public class EarlyWarningRecordsServiceImpl extends ServiceImpl<EarlyWarningReco
Page<WflowEarlyWarningRecords> page = req.page(); Page<WflowEarlyWarningRecords> page = req.page();
LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.eq(WflowEarlyWarningRecords::getRuleType, ruleType) .eq(WflowEarlyWarningRecords::getRuleType, ruleType)
.eq(StringUtils.isNotBlank(req.getAreaCode()),WflowEarlyWarningRecords::getAreaCode,req.getAreaCode())
.eq(Objects.nonNull(req.getMhUnitId()),WflowEarlyWarningRecords::getMhUnitId,req.getMhUnitId())
.eq(StringUtils.isNotBlank(req.getAreaCode()), WflowEarlyWarningRecords::getAreaCode, req.getAreaCode())
.eq(Objects.nonNull(req.getMhUnitId()), WflowEarlyWarningRecords::getMhUnitId, req.getMhUnitId())
.like(StringUtils.isNotBlank(req.getProjectName()), WflowEarlyWarningRecords::getProjectName, req.getProjectName()) .like(StringUtils.isNotBlank(req.getProjectName()), WflowEarlyWarningRecords::getProjectName, req.getProjectName())
.like(StringUtils.isNotBlank(req.getBuildOrgName()), WflowEarlyWarningRecords::getBuildOrgName, req.getBuildOrgName()) .like(StringUtils.isNotBlank(req.getBuildOrgName()), WflowEarlyWarningRecords::getBuildOrgName, req.getBuildOrgName())
.eq(StringUtils.isNotBlank(req.getBuildOrgCode()), WflowEarlyWarningRecords::getBuildOrgCode, req.getBuildOrgCode()) .eq(StringUtils.isNotBlank(req.getBuildOrgCode()), WflowEarlyWarningRecords::getBuildOrgCode, req.getBuildOrgCode())
.ge(Objects.nonNull(req.getStartTime()),WflowEarlyWarningRecords::getWarningTime,req.getStartTime())
.le(Objects.nonNull(req.getEndTime()),WflowEarlyWarningRecords::getWarningTime,req.getEndTime())
.ge(Objects.nonNull(req.getStartTime()), WflowEarlyWarningRecords::getWarningTime, req.getStartTime())
.le(Objects.nonNull(req.getEndTime()), WflowEarlyWarningRecords::getWarningTime, req.getEndTime())
.orderByDesc(WflowEarlyWarningRecords::getCreateOn); .orderByDesc(WflowEarlyWarningRecords::getCreateOn);


this.page(page,wrapper);
this.page(page, wrapper);


if(CollUtil.isEmpty(page.getRecords())){
if (CollUtil.isEmpty(page.getRecords())) {
return PageVo.empty(); return PageVo.empty();
} }


List<WflowEarlyWarningRecordsVO> res = page.getRecords().stream() List<WflowEarlyWarningRecordsVO> res = page.getRecords().stream()
.map(p -> BeanUtil.copyProperties(p,WflowEarlyWarningRecordsVO.class))
.map(p -> BeanUtil.copyProperties(p, WflowEarlyWarningRecordsVO.class))
.collect(Collectors.toList()); .collect(Collectors.toList());


return PageVo.of(res,page.getTotal());
return PageVo.of(res, page.getTotal());
}

@Override
public List<WflowEarlyWarningRecords> listProjectLastWarningRecords(Collection<String> projectCodes, WarningRuleTypeEnum ruleType) {
LambdaQueryWrapper<WflowEarlyWarningRecords> query = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class)
.in(WflowEarlyWarningRecords::getProjectCode, projectCodes)
.eq(WflowEarlyWarningRecords::getRuleType, ruleType.getCode());
return baseMapper.selectProjectLastWarningRecords(query);
} }

} }

Loading…
Cancel
Save