QueryWrapper<RiskResultsDO> wrapper = new QueryWrapper<>();
wrapper.select("count(1) as countNum,risk_level_code as riskLevelCode,whether_forecast as whetherForecast ");
LambdaQueryWrapper<RiskResultsDO> searchInfo = riskResultsRepository.dealSearchInfo(req, wrapper.lambda());
searchInfo.groupBy(RiskResultsDO::getWhetherForecast);
searchInfo.groupBy(RiskResultsDO::getRiskLevelCode);
List<Map<String, Object>> maps = riskResultsRepository.listMaps(searchInfo);
public LambdaQueryWrapper<RiskResultsDO> dealSearchInfo(RiskResultsPageReq req, LambdaQueryWrapper<RiskResultsDO> lambdaQueryWrapper, SFunction<RiskResultsDO, ?> sortFiled, boolean whetherAsc) {
lambdaQueryWrapper.eq(StringUtils.isNotBlank(req.getEvaluationTypeCode()), RiskResultsDO::getEvaluationTypeCode, req.getEvaluationTypeCode())
.ge(StringUtils.isNotBlank(req.getStartEvaluationTime()), RiskResultsDO::getEvaluationTime, req.getStartEvaluationTime() + DateUtilConstant.MIN_DAY_TIME)
.le(StringUtils.isNotBlank(req.getEndEvaluationTime()), RiskResultsDO::getEvaluationTime, req.getEndEvaluationTime() + DateUtilConstant.MAX_DAY_TIME)
.ge(StringUtils.isNotBlank(req.getStartForecastBelongTime()), RiskResultsDO::getForecastBelongTime, req.getStartForecastBelongTime() + DateUtilConstant.MIN_DAY_TIME)
.le(StringUtils.isNotBlank(req.getEndForecastBelongTime()), RiskResultsDO::getForecastBelongTime, req.getEndForecastBelongTime() + DateUtilConstant.MAX_DAY_TIME)
.apply(ObjectUtil.isNotNull(req.getAreaId()), " FIND_IN_SET (" + req.getAreaId() + ",area_ids) ")
.eq(ObjectUtil.isNotNull(req.getWhetherForecast()), RiskResultsDO::getWhetherForecast, req.getWhetherForecast())
.eq(ObjectUtil.isNotNull(req.getStationAreaId()), RiskResultsDO::getAreaId, req.getStationAreaId())
.eq(ObjectUtil.isNotNull(req.getRiskLevelCode()), RiskResultsDO::getRiskLevelCode, req.getRiskLevelCode())
.eq(ObjectUtil.isNotNull(req.getBelongTypeCode()), RiskResultsDO::getBelongTypeCode, req.getBelongTypeCode());
if (ObjectUtil.isNotEmpty(req.getWhetherTown()) && req.getWhetherTown().equals(1)) {
lambdaQueryWrapper.isNotNull(RiskResultsDO::getVillageTownId);
}
lambdaQueryWrapper.orderBy(true, whetherAsc, sortFiled);
return lambdaQueryWrapper;
}
这个主要是不想维护常量字段名使用~