fix: 优化电站锚点数据获取
This commit is contained in:
parent
693408a59a
commit
f2e6b406fa
@ -20,6 +20,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.yfd.platform.qgc_env.wq.entity.ao.JobBaseAo;
|
import com.yfd.platform.qgc_env.wq.entity.ao.JobBaseAo;
|
||||||
import com.yfd.platform.qgc_env.wq.service.EnvWqDataService;
|
import com.yfd.platform.qgc_env.wq.service.EnvWqDataService;
|
||||||
|
import com.yfd.platform.qgc_job.service.IEqJobService;
|
||||||
import com.yfd.platform.system.domain.QuartzJob;
|
import com.yfd.platform.system.domain.QuartzJob;
|
||||||
import com.yfd.platform.system.mapper.QuartzJobMapper;
|
import com.yfd.platform.system.mapper.QuartzJobMapper;
|
||||||
import com.yfd.platform.utils.QuartzManage;
|
import com.yfd.platform.utils.QuartzManage;
|
||||||
@ -47,6 +48,7 @@ public class JobRunner implements ApplicationRunner {
|
|||||||
private final QuartzJobMapper quartzJobMapper;
|
private final QuartzJobMapper quartzJobMapper;
|
||||||
private final QuartzManage quartzManage;
|
private final QuartzManage quartzManage;
|
||||||
private final EnvWqDataService envWqDataService;
|
private final EnvWqDataService envWqDataService;
|
||||||
|
private final IEqJobService iEqJobService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目启动时重新激活启用的定时任务
|
* 项目启动时重新激活启用的定时任务
|
||||||
@ -69,6 +71,8 @@ public class JobRunner implements ApplicationRunner {
|
|||||||
ao.setStartTime(DateUtil.beginOfYear(DateUtil.offset(ao.getEndTime(), DateField.YEAR,-1)));
|
ao.setStartTime(DateUtil.beginOfYear(DateUtil.offset(ao.getEndTime(), DateField.YEAR,-1)));
|
||||||
}
|
}
|
||||||
envWqDataService.wqLastData(ao);
|
envWqDataService.wqLastData(ao);
|
||||||
|
|
||||||
|
iEqJobService.eqAnchorPointLastDate( ao);
|
||||||
log.info("--------------------wq最新一条数据---------------------");
|
log.info("--------------------wq最新一条数据---------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.yfd.platform.qgc_base.domain.vo;
|
package com.yfd.platform.qgc_base.domain.vo;
|
||||||
|
|
||||||
|
import com.yfd.platform.qgc_eng.eq.entity.vo.LastTmEngEqDataVo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -99,4 +100,7 @@ public class EngPointVo {
|
|||||||
|
|
||||||
@Schema(description = "基地排序")
|
@Schema(description = "基地排序")
|
||||||
private Integer baseStepSort;
|
private Integer baseStepSort;
|
||||||
|
|
||||||
|
@Schema(description="电站最新数据:入库流量和出库流量")
|
||||||
|
private LastTmEngEqDataVo lastTmEngEqDataVo;
|
||||||
}
|
}
|
||||||
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@ -42,8 +43,10 @@ import com.yfd.platform.qgc_base.mapper.SdEngInfoBHMapper;
|
|||||||
import com.yfd.platform.qgc_base.service.IDataScopeFilterService;
|
import com.yfd.platform.qgc_base.service.IDataScopeFilterService;
|
||||||
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
|
import com.yfd.platform.qgc_base.service.IMsOperationLogService;
|
||||||
import com.yfd.platform.qgc_base.service.ISdEngInfoBHService;
|
import com.yfd.platform.qgc_base.service.ISdEngInfoBHService;
|
||||||
|
import com.yfd.platform.qgc_eng.eq.entity.vo.LastTmEngEqDataVo;
|
||||||
import com.yfd.platform.system.service.IAdminAuthService;
|
import com.yfd.platform.system.service.IAdminAuthService;
|
||||||
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||||
|
import com.yfd.platform.utils.RedisCacheUtil;
|
||||||
import com.yfd.platform.utils.SecurityUtils;
|
import com.yfd.platform.utils.SecurityUtils;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
@ -65,7 +68,8 @@ import java.util.stream.Collectors;
|
|||||||
public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEngInfoBH> implements ISdEngInfoBHService {
|
public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEngInfoBH> implements ISdEngInfoBHService {
|
||||||
|
|
||||||
private static final Map<String, String> ENG_CODE_NAME_FIELD_MAP = new LinkedHashMap<>();
|
private static final Map<String, String> ENG_CODE_NAME_FIELD_MAP = new LinkedHashMap<>();
|
||||||
|
@Resource
|
||||||
|
private RedisCacheUtil redisCacheUtil;
|
||||||
@Resource
|
@Resource
|
||||||
private IDataScopeFilterService dataScopeFilterService;
|
private IDataScopeFilterService dataScopeFilterService;
|
||||||
|
|
||||||
@ -2924,7 +2928,24 @@ public class SdEngInfoBHServiceImpl extends ServiceImpl<SdEngInfoBHMapper, SdEng
|
|||||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
||||||
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||||
List<EngPointVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, EngPointVo.class);
|
List<EngPointVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(page, sql.toString(), paramMap, EngPointVo.class);
|
||||||
|
if(CollUtil.isNotEmpty(list)){
|
||||||
|
for( EngPointVo engPointVo: list ){
|
||||||
|
String stcd = engPointVo.getStcd();
|
||||||
|
//查询最新一条数据的缓存
|
||||||
|
LastTmEngEqDataVo lastTmEngEqDataVo = redisCacheUtil.fromJson(redisCacheUtil.getString("eqAnchorPointLastDate:"+stcd),LastTmEngEqDataVo.class);
|
||||||
|
if (ObjectUtil.isEmpty(lastTmEngEqDataVo)){
|
||||||
|
lastTmEngEqDataVo = new LastTmEngEqDataVo();
|
||||||
|
lastTmEngEqDataVo.setStcd(engPointVo.getStcd());
|
||||||
|
}else{
|
||||||
|
lastTmEngEqDataVo.setStcd(engPointVo.getStcd());
|
||||||
|
}
|
||||||
|
// 设置电站名称、装机容量、正常蓄水位
|
||||||
|
lastTmEngEqDataVo.setStnm(engPointVo.getEnnm());
|
||||||
|
lastTmEngEqDataVo.setTtpwr(engPointVo.getTtpwr());
|
||||||
|
lastTmEngEqDataVo.setNormz(engPointVo.getNormz());
|
||||||
|
engPointVo.setLastTmEngEqDataVo(lastTmEngEqDataVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
result.setData(list);
|
result.setData(list);
|
||||||
result.setTotal(page == null ? list.size() : page.getTotal());
|
result.setTotal(page == null ? list.size() : page.getTotal());
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.yfd.platform.qgc_job.service;
|
||||||
|
|
||||||
|
import com.yfd.platform.qgc_env.wq.entity.ao.JobBaseAo;
|
||||||
|
|
||||||
|
public interface IEqJobService {
|
||||||
|
|
||||||
|
void eqAnchorPointLastDate(JobBaseAo ao);
|
||||||
|
}
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
package com.yfd.platform.qgc_job.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||||
|
import com.yfd.platform.qgc_env.wq.entity.ao.JobBaseAo;
|
||||||
|
import com.yfd.platform.qgc_job.service.IEqJobService;
|
||||||
|
import com.yfd.platform.qgc_job.vo.EqAnchorPointLastDateVo;
|
||||||
|
import com.yfd.platform.utils.RedisCacheUtil;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EqJobServiceImpl implements IEqJobService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MicroservicDynamicSQLMapper<?> microservicDynamicSQLMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisCacheUtil redisCacheUtil;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void eqAnchorPointLastDate(JobBaseAo ao) {
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
// 旧逻辑只按当前时间截取最新一条工程运行数据,ao 在此方法中不参与过滤
|
||||||
|
paramMap.put("currentTime", new Date());
|
||||||
|
|
||||||
|
List<EqAnchorPointLastDateVo> eqDataVos = microservicDynamicSQLMapper.getAllListWithResultType(
|
||||||
|
buildEqAnchorPointLastDateSql(),
|
||||||
|
paramMap,
|
||||||
|
EqAnchorPointLastDateVo.class
|
||||||
|
);
|
||||||
|
for (EqAnchorPointLastDateVo eqDataVo : eqDataVos) {
|
||||||
|
redisCacheUtil.setString("eqAnchorPointLastDate:" + eqDataVo.getStcd(), JSONUtil.toJsonStr(eqDataVo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildEqAnchorPointLastDateSql() {
|
||||||
|
return "SELECT " +
|
||||||
|
"run.STCD AS stcd, " +
|
||||||
|
"run.TM AS tm, " +
|
||||||
|
"run.QI AS qi, " +
|
||||||
|
"run.QO AS qo, " +
|
||||||
|
"run.RZ AS rz, " +
|
||||||
|
"run.DZ AS dz, " +
|
||||||
|
"qec.QEC_LIMIT AS qecLimit, " +
|
||||||
|
"qec.QEC_C AS qecC, " +
|
||||||
|
"qec.MWR_LIMIT AS mwrLimit, " +
|
||||||
|
"qec.MWR_C AS mwrC, " +
|
||||||
|
"NVL(qec.AVQ_LIMIT, eng.AVQ) AS avqLimit, " +
|
||||||
|
"qec.AVQ_C AS avqC, " +
|
||||||
|
"qecDetail.VLSR AS vlsr, " +
|
||||||
|
"qecDetail.VLSR_TM AS vlsrTm, " +
|
||||||
|
"mwrDetail.VLSR AS mwrVlsr, " +
|
||||||
|
"mwrDetail.VLSR_TM AS mwrVlsrTm " +
|
||||||
|
"FROM ( " +
|
||||||
|
" SELECT STCD, MAX(TM) AS TM " +
|
||||||
|
" FROM SD_HYDROPW_R " +
|
||||||
|
" WHERE NVL(IS_DELETED, 0) = 0 " +
|
||||||
|
" AND TM <= #{map.currentTime} " +
|
||||||
|
" GROUP BY STCD " +
|
||||||
|
") lastRun " +
|
||||||
|
"INNER JOIN SD_HYDROPW_R run " +
|
||||||
|
" ON lastRun.STCD = run.STCD " +
|
||||||
|
" AND lastRun.TM = run.TM " +
|
||||||
|
" AND NVL(run.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN SD_QEC_R qec " +
|
||||||
|
" ON qec.STCD = run.STCD " +
|
||||||
|
" AND qec.TM = run.TM " +
|
||||||
|
" AND NVL(qec.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN SD_ENGINFO_B_H eng " +
|
||||||
|
" ON eng.STCD = run.STCD " +
|
||||||
|
" AND NVL(eng.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN MS_WARN_RULE_DETAIL_B qecDetail " +
|
||||||
|
" ON qecDetail.ID = qec.QEC_RULE_DID " +
|
||||||
|
" AND NVL(qecDetail.IS_DELETED, 0) = 0 " +
|
||||||
|
"LEFT JOIN MS_WARN_RULE_DETAIL_B mwrDetail " +
|
||||||
|
" ON mwrDetail.ID = qec.QEC_MWRRULE_DID " +
|
||||||
|
" AND NVL(mwrDetail.IS_DELETED, 0) = 0";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
package com.yfd.platform.qgc_job.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "电站锚点最新缓存数据")
|
||||||
|
public class EqAnchorPointLastDateVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "电站编码")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
@Schema(description = "电站名称")
|
||||||
|
private String stnm;
|
||||||
|
|
||||||
|
@Schema(description = "数据时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date tm;
|
||||||
|
|
||||||
|
@Schema(description = "装机容量")
|
||||||
|
private BigDecimal ttpwr;
|
||||||
|
|
||||||
|
@Schema(description = "生态流量限值(环保部)")
|
||||||
|
private BigDecimal qecLimit;
|
||||||
|
|
||||||
|
@Schema(description = "生态流量限值(水利部)")
|
||||||
|
private BigDecimal mwrLimit;
|
||||||
|
|
||||||
|
@Schema(description = "生态流量限值(多年平均)")
|
||||||
|
private BigDecimal avqLimit;
|
||||||
|
|
||||||
|
@Schema(description = "生态流量系数(环保部)")
|
||||||
|
private BigDecimal qecC;
|
||||||
|
|
||||||
|
@Schema(description = "生态流量系数(水利部)")
|
||||||
|
private BigDecimal mwrC;
|
||||||
|
|
||||||
|
@Schema(description = "生态流量系数(多年平均)")
|
||||||
|
private BigDecimal avqC;
|
||||||
|
|
||||||
|
@Schema(description = "正常蓄水位")
|
||||||
|
private BigDecimal normz;
|
||||||
|
|
||||||
|
@Schema(description = "死水位")
|
||||||
|
private BigDecimal ddz;
|
||||||
|
|
||||||
|
@Schema(description = "入库流量")
|
||||||
|
private BigDecimal qi;
|
||||||
|
|
||||||
|
@Schema(description = "出库流量")
|
||||||
|
private BigDecimal qo;
|
||||||
|
|
||||||
|
@Schema(description = "坝上水位")
|
||||||
|
private BigDecimal rz;
|
||||||
|
|
||||||
|
@Schema(description = "坝下水位")
|
||||||
|
private BigDecimal dz;
|
||||||
|
|
||||||
|
@Schema(description = "规则来源")
|
||||||
|
private String vlsr;
|
||||||
|
|
||||||
|
@Schema(description = "规则来源时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private Date vlsrTm;
|
||||||
|
|
||||||
|
@Schema(description = "规则来源(水利部)")
|
||||||
|
private String mwrVlsr;
|
||||||
|
|
||||||
|
@Schema(description = "规则来源时间(水利部)")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
|
private Date mwrVlsrTm;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user