fix: 优化水质锚点数据获取
This commit is contained in:
parent
b1bdb4cf66
commit
693408a59a
@ -15,7 +15,11 @@
|
||||
*/
|
||||
package com.yfd.platform.config;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.service.EnvWqDataService;
|
||||
import com.yfd.platform.system.domain.QuartzJob;
|
||||
import com.yfd.platform.system.mapper.QuartzJobMapper;
|
||||
import com.yfd.platform.utils.QuartzManage;
|
||||
@ -42,6 +46,7 @@ public class JobRunner implements ApplicationRunner {
|
||||
private static final Logger log = LoggerFactory.getLogger(JobRunner.class);
|
||||
private final QuartzJobMapper quartzJobMapper;
|
||||
private final QuartzManage quartzManage;
|
||||
private final EnvWqDataService envWqDataService;
|
||||
|
||||
/**
|
||||
* 项目启动时重新激活启用的定时任务
|
||||
@ -55,5 +60,15 @@ public class JobRunner implements ApplicationRunner {
|
||||
quartzJobMapper.selectList(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getStatus, "1"));
|
||||
quartzJobs.forEach(quartzManage::addJob);
|
||||
log.info("--------------------定时任务注入完成---------------------");
|
||||
JobBaseAo ao = new JobBaseAo();
|
||||
//如果没有传递时间,则默认为上个月的开始到现在
|
||||
if (null == ao.getEndTime()){
|
||||
ao.setEndTime(DateUtil.date());
|
||||
}
|
||||
if (null == ao.getStartTime()){
|
||||
ao.setStartTime(DateUtil.beginOfYear(DateUtil.offset(ao.getEndTime(), DateField.YEAR,-1)));
|
||||
}
|
||||
envWqDataService.wqLastData(ao);
|
||||
log.info("--------------------wq最新一条数据---------------------");
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,310 @@
|
||||
package com.yfd.platform.qgc_env.wq.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("SD_WQ_R")
|
||||
@Schema(description = "水质监测数据表实体")
|
||||
public class SdWqR {
|
||||
|
||||
@TableId(value = "ID", type = IdType.ASSIGN_UUID)
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@TableField("STCD")
|
||||
@Schema(description = "站码")
|
||||
private String stcd;
|
||||
|
||||
@TableField("TM")
|
||||
@Schema(description = "采样时间")
|
||||
private Date tm;
|
||||
|
||||
@TableField("WQGRD")
|
||||
@Schema(description = "水质类别")
|
||||
private String wqgrd;
|
||||
|
||||
|
||||
@Schema(description = "水质类别")
|
||||
@TableField(exist = false)
|
||||
private String wqgrdName;
|
||||
|
||||
@TableField("PERIOD")
|
||||
@Schema(description = "丰平枯时期")
|
||||
private String period;
|
||||
|
||||
@TableField("SPSTLC")
|
||||
@Schema(description = "水平位置")
|
||||
private Long spstlc;
|
||||
|
||||
@TableField("WTMP")
|
||||
@Schema(description = "水温")
|
||||
private BigDecimal wtmp;
|
||||
|
||||
@TableField("PH")
|
||||
@Schema(description = "PH")
|
||||
private BigDecimal ph;
|
||||
|
||||
@TableField("DOX")
|
||||
@Schema(description = "溶解氧")
|
||||
private BigDecimal dox;
|
||||
|
||||
@TableField("CODMN")
|
||||
@Schema(description = "高锰酸盐指数")
|
||||
private BigDecimal codmn;
|
||||
|
||||
@TableField("CODCR")
|
||||
@Schema(description = "化学需氧量")
|
||||
private BigDecimal codcr;
|
||||
|
||||
@TableField("BOD5")
|
||||
@Schema(description = "五日生化需氧量")
|
||||
private BigDecimal bod5;
|
||||
|
||||
@TableField("NH3N")
|
||||
@Schema(description = "氨氮")
|
||||
private BigDecimal nh3n;
|
||||
|
||||
@TableField("TP")
|
||||
@Schema(description = "总磷")
|
||||
private BigDecimal tp;
|
||||
|
||||
@TableField("TN")
|
||||
@Schema(description = "总氮")
|
||||
private BigDecimal tn;
|
||||
|
||||
@TableField("CU")
|
||||
@Schema(description = "铜")
|
||||
private BigDecimal cu;
|
||||
|
||||
@TableField("ZN")
|
||||
@Schema(description = "锌")
|
||||
private BigDecimal zn;
|
||||
|
||||
@TableField("F")
|
||||
@Schema(description = "氟化物")
|
||||
private BigDecimal f;
|
||||
|
||||
@TableField("SE")
|
||||
@Schema(description = "硒")
|
||||
private BigDecimal se;
|
||||
|
||||
@TableField("ARS")
|
||||
@Schema(description = "砷")
|
||||
private BigDecimal ars;
|
||||
|
||||
@TableField("HG")
|
||||
@Schema(description = "汞")
|
||||
private BigDecimal hg;
|
||||
|
||||
@TableField("CD")
|
||||
@Schema(description = "镉")
|
||||
private BigDecimal cd;
|
||||
|
||||
@TableField("CR6")
|
||||
@Schema(description = "铬(六价)")
|
||||
private BigDecimal cr6;
|
||||
|
||||
@TableField("PB")
|
||||
@Schema(description = "铅")
|
||||
private BigDecimal pb;
|
||||
|
||||
@TableField("CN")
|
||||
@Schema(description = "氰化物")
|
||||
private BigDecimal cn;
|
||||
|
||||
@TableField("VLPH")
|
||||
@Schema(description = "挥发酚")
|
||||
private BigDecimal vlph;
|
||||
|
||||
@TableField("OIL")
|
||||
@Schema(description = "石油类")
|
||||
private BigDecimal oil;
|
||||
|
||||
@TableField("LAS")
|
||||
@Schema(description = "阴离子表面活性剂")
|
||||
private BigDecimal las;
|
||||
|
||||
@TableField("S2")
|
||||
@Schema(description = "硫化物")
|
||||
private BigDecimal s2;
|
||||
|
||||
@TableField("FCG")
|
||||
@Schema(description = "粪大肠菌群")
|
||||
private BigDecimal fcg;
|
||||
|
||||
@TableField("CL")
|
||||
@Schema(description = "氯化物")
|
||||
private BigDecimal cl;
|
||||
|
||||
@TableField("SO4")
|
||||
@Schema(description = "硫酸盐")
|
||||
private BigDecimal so4;
|
||||
|
||||
@TableField("NO3")
|
||||
@Schema(description = "硝氮/硝酸盐氮")
|
||||
private BigDecimal no3;
|
||||
|
||||
@TableField("THRD")
|
||||
@Schema(description = "总硬度")
|
||||
private BigDecimal thrd;
|
||||
|
||||
@TableField("COND")
|
||||
@Schema(description = "电导率")
|
||||
private BigDecimal cond;
|
||||
|
||||
@TableField("FE")
|
||||
@Schema(description = "铁")
|
||||
private BigDecimal fe;
|
||||
|
||||
@TableField("MN")
|
||||
@Schema(description = "锰")
|
||||
private BigDecimal mn;
|
||||
|
||||
@TableField("AL")
|
||||
@Schema(description = "铝")
|
||||
private BigDecimal al;
|
||||
|
||||
@TableField("CHLA")
|
||||
@Schema(description = "叶绿素a")
|
||||
private BigDecimal chla;
|
||||
|
||||
@TableField("CLARITY")
|
||||
@Schema(description = "透明度")
|
||||
private BigDecimal clarity;
|
||||
|
||||
@TableField("TU")
|
||||
@Schema(description = "浊度")
|
||||
private BigDecimal tu;
|
||||
|
||||
@TableField("CYANO")
|
||||
@Schema(description = "蓝绿藻")
|
||||
private BigDecimal cyano;
|
||||
|
||||
@TableField("NI")
|
||||
@Schema(description = "镍")
|
||||
private BigDecimal ni;
|
||||
|
||||
@TableField("TOD")
|
||||
@Schema(description = "总氧/总需氧量")
|
||||
private BigDecimal tod;
|
||||
|
||||
@TableField("SFDB")
|
||||
@Schema(description = "是否达标")
|
||||
private Integer sfdb;
|
||||
|
||||
@TableField("FID")
|
||||
@Schema(description = "文件ID")
|
||||
private String fid;
|
||||
|
||||
@TableField("VLSR")
|
||||
@Schema(description = "数据来源")
|
||||
private String vlsr;
|
||||
|
||||
@TableField("WQ_SFDBHN_YS")
|
||||
@Schema(description = "水质不达标的要素")
|
||||
private String wqSfdbhnYs;
|
||||
|
||||
@TableField("REMARK")
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@TableField("TLI_SUM")
|
||||
@Schema(description = "综合营养状态指数")
|
||||
private BigDecimal tliSum;
|
||||
|
||||
@TableField("TLI_SUM_LEVEL")
|
||||
@Schema(description = "综合营养状态指数分级")
|
||||
private String tliSumLevel;
|
||||
|
||||
@TableField("CA")
|
||||
@Schema(description = "钙")
|
||||
private BigDecimal ca;
|
||||
|
||||
@TableField("PO4")
|
||||
@Schema(description = "磷酸盐")
|
||||
private BigDecimal po4;
|
||||
|
||||
@TableField("N_NO2")
|
||||
@Schema(description = "亚硝酸盐氮(弃用)")
|
||||
private BigDecimal nNo2;
|
||||
|
||||
@TableField("NA")
|
||||
@Schema(description = "钠")
|
||||
private BigDecimal na;
|
||||
|
||||
@TableField("K")
|
||||
@Schema(description = "钾")
|
||||
private BigDecimal k;
|
||||
|
||||
@TableField("TOC")
|
||||
@Schema(description = "总有机碳")
|
||||
private BigDecimal toc;
|
||||
|
||||
@TableField("OPOR")
|
||||
@Schema(description = "有机磷农药")
|
||||
private BigDecimal opor;
|
||||
|
||||
@TableField("SS")
|
||||
@Schema(description = "悬浮物")
|
||||
private BigDecimal ss;
|
||||
|
||||
@TableField("NO2")
|
||||
@Schema(description = "亚硝酸盐氮")
|
||||
private BigDecimal no2;
|
||||
|
||||
@TableField("ORP")
|
||||
@Schema(description = "氧化还原电位")
|
||||
private BigDecimal orp;
|
||||
|
||||
@TableField("FWGHTEMP")
|
||||
@Schema(description = "FWGHTEMP")
|
||||
private BigDecimal fwghtemp;
|
||||
|
||||
@TableField("RECORD_USER")
|
||||
@Schema(description = "创建人")
|
||||
private String recordUser;
|
||||
|
||||
@TableField("RECORD_TIME")
|
||||
@Schema(description = "创建时间")
|
||||
private Date recordTime;
|
||||
|
||||
@TableField("MODIFY_USER")
|
||||
@Schema(description = "更新人")
|
||||
private String modifyUser;
|
||||
|
||||
@TableField("MODIFY_TIME")
|
||||
@Schema(description = "更新时间")
|
||||
private Date modifyTime;
|
||||
|
||||
@TableField("IS_DELETED")
|
||||
@Schema(description = "是否已删除")
|
||||
private Integer isDeleted;
|
||||
|
||||
@TableField("DELETE_USER")
|
||||
@Schema(description = "删除人")
|
||||
private String deleteUser;
|
||||
|
||||
@TableField("DELETE_TIME")
|
||||
@Schema(description = "删除时间")
|
||||
private Date deleteTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer sfdbNew;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String tmNew;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String baseId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer dtinType;
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
package com.yfd.platform.qgc_env.wq.entity.ao;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Schema(description = "定时任务基础参数")
|
||||
public class JobBaseAo {
|
||||
|
||||
public static final String JOB_TYPE_DAY = "day";
|
||||
public static final String JOB_TYPE_HOUR = "hour";
|
||||
|
||||
@Schema(description = "job类型 day=天 hour=小时", example = "hour", allowableValues = "day,hour")
|
||||
private String jobType;
|
||||
|
||||
@Schema(description = "只能是数字或特定字符串,为空=1。job类型为天即单位为天,类型为小时即单位小时 today=当天 am15=跨月15天取开始月份1号", example = "2")
|
||||
private String jobStep;
|
||||
|
||||
@Schema(description = "开始时间", example = "2022-08-01 00:00:00")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
|
||||
@Schema(description = "结束时间", example = "2022-08-31 23:59:59")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
|
||||
@Schema(description = "设施类型")
|
||||
private String sttpCode;
|
||||
|
||||
@Schema(description = "测站编码集合")
|
||||
private Set<String> stcds;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
|
||||
public void initTime() {
|
||||
Date startTime = this.getStartTime();
|
||||
Date endTime = this.getEndTime();
|
||||
if (startTime == null || endTime == null) {
|
||||
Date now = new Date();
|
||||
String num = this.getJobStep() != null && !"".equals(this.getJobStep().trim()) ? this.getJobStep() : "1";
|
||||
if ("hour".equals(this.getJobType())) {
|
||||
if ("today".equalsIgnoreCase(num)) {
|
||||
startTime = getDayStartTime(now);
|
||||
endTime = parseWholeMinuteEnd(now);
|
||||
} else {
|
||||
startTime = parseWholeMinuteStart(DateUtils.addHours(now, -Integer.parseInt(num)));
|
||||
endTime = parseWholeMinuteEnd(now);
|
||||
}
|
||||
} else if ("day".equals(this.getJobType())) {
|
||||
if ("today".equalsIgnoreCase(num)) {
|
||||
startTime = getDayStartTime(now);
|
||||
endTime = parseWholeMinuteEnd(now);
|
||||
} else if (num.toLowerCase().startsWith("am")) {
|
||||
num = num.replace("am", "");
|
||||
startTime = getMonthFirstDayStartTime(DateUtils.addDays(now, -Integer.parseInt(num)));
|
||||
endTime = parseWholeMinuteEnd(now);
|
||||
} else {
|
||||
startTime = getDayStartTime(DateUtils.addDays(now, -Integer.parseInt(num)));
|
||||
endTime = parseWholeMinuteEnd(now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (startTime != null && endTime != null) {
|
||||
if (startTime.getTime() > endTime.getTime()) {
|
||||
throw new RuntimeException("开始时间不能大于结束时间");
|
||||
} else {
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("开始时间和结束时间不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
private Date getMonthFirstDayStartTime(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
private static Date getDayStartTime(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
private static Date parseWholeMinuteEnd(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.MINUTE, 59);
|
||||
calendar.set(Calendar.SECOND, 59);
|
||||
calendar.set(Calendar.MILLISECOND, 999);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
private static Date parseWholeMinuteStart(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
private static class DateUtils {
|
||||
public static Date addHours(Date date, int hours) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.HOUR_OF_DAY, hours);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static Date addDays(Date date, int days) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, days);
|
||||
return calendar.getTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.yfd.platform.qgc_env.wq.entity.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@ -11,6 +12,8 @@ import java.util.Map;
|
||||
@Data
|
||||
@Schema(description = "水质实时数据")
|
||||
public class EnvWqDataVo {
|
||||
@Schema(description = "id")
|
||||
private String id;
|
||||
@Schema(description = "测站编码")
|
||||
private String stcd;
|
||||
@Schema(description = "电站编码")
|
||||
@ -137,6 +140,34 @@ public class EnvWqDataVo {
|
||||
private Integer rstcdStepSort;
|
||||
@Schema(description = "测站排序")
|
||||
private Integer siteStepSort;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String recordUser;
|
||||
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date recordTime;
|
||||
|
||||
|
||||
@Schema(description = "更新人")
|
||||
private String modifyUser;
|
||||
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private Date modifyTime;
|
||||
|
||||
|
||||
@Schema(description = "是否已删除")
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
@Schema(description = "删除人")
|
||||
private String deleteUser;
|
||||
|
||||
|
||||
@Schema(description = "删除时间")
|
||||
private Date deleteTime;
|
||||
|
||||
@Schema(description = "水质要素最小限值集合")
|
||||
private List<Map<String, Object>> min;
|
||||
@Schema(description = "水质要素最大限值集合")
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.yfd.platform.qgc_env.wq.mapper;
|
||||
|
||||
import com.yfd.platform.qgc_env.wq.entity.SdWqR;
|
||||
import com.yfd.platform.qgc_env.wq.entity.ao.JobBaseAo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WqJobMapper {
|
||||
|
||||
List<SdWqR> getWqLastData(@Param("ao") JobBaseAo ao);
|
||||
|
||||
List<SdWqR> getWqYsLastData(@Param("startTimeStr") String startTimeStr, @Param("endTimeStr") String endTimeStr);
|
||||
|
||||
void mergeWqR(@Param("wqRs") List<SdWqR> wqRs);
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.yfd.platform.qgc_env.wq.service;
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.common.DataSourceResult;
|
||||
import com.yfd.platform.qgc_base.entity.vo.BatchDeleteAo;
|
||||
import com.yfd.platform.qgc_env.wq.entity.ao.JobBaseAo;
|
||||
import com.yfd.platform.qgc_env.wq.entity.vo.WqBaseInfoVo;
|
||||
import com.yfd.platform.qgc_env.wq.entity.vo.EnvWqAnchorPointVo;
|
||||
|
||||
@ -45,4 +46,6 @@ public interface EnvWqDataService {
|
||||
boolean removeKendoByIds(BatchDeleteAo batchDeleteAo);
|
||||
|
||||
DataSourceResult<EnvWqAnchorPointVo> getAnchorPointKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
|
||||
void wqLastData(JobBaseAo ao);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yfd.platform.common.*;
|
||||
import com.yfd.platform.common.exception.BizException;
|
||||
@ -15,14 +16,14 @@ import com.yfd.platform.qgc_base.entity.vo.DataParam;
|
||||
import com.yfd.platform.qgc_base.mapper.MsOperationLogDetailMapper;
|
||||
import com.yfd.platform.qgc_base.mapper.MsOperationLogMapper;
|
||||
import com.yfd.platform.qgc_base.service.IDataScopeFilterService;
|
||||
import com.yfd.platform.qgc_env.wq.entity.SdWqR;
|
||||
import com.yfd.platform.qgc_env.wq.entity.ao.JobBaseAo;
|
||||
import com.yfd.platform.qgc_env.wq.entity.vo.*;
|
||||
import com.yfd.platform.qgc_env.wq.mapper.WqJobMapper;
|
||||
import com.yfd.platform.qgc_env.wq.service.EnvWqDataService;
|
||||
import com.yfd.platform.qgc_env.wt.entity.vo.WbsbVo;
|
||||
import com.yfd.platform.qgc_env.wt.utils.SiteAvoidanceUtils;
|
||||
import com.yfd.platform.utils.KendoUtil;
|
||||
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||
import com.yfd.platform.utils.RequestHolder;
|
||||
import com.yfd.platform.utils.SecurityUtils;
|
||||
import com.yfd.platform.utils.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -51,6 +52,9 @@ public class EnvWqDataServiceImpl implements EnvWqDataService {
|
||||
@Resource
|
||||
private IDataScopeFilterService dataScopeFilterService;
|
||||
|
||||
@Resource
|
||||
private RedisCacheUtil redisCacheUtil;
|
||||
|
||||
private static final String WQ_HOUR_TABLE_NAME = "SD_WQ_R";
|
||||
private static final String WQ_DAY_TABLE_NAME = "SD_WQDAY_S";
|
||||
private static final String WQ_MONTH_TABLE_NAME = "SD_WQDRTP_S";
|
||||
@ -159,6 +163,9 @@ public class EnvWqDataServiceImpl implements EnvWqDataService {
|
||||
@Resource
|
||||
private MsOperationLogDetailMapper msOperationLogDetailMapper;
|
||||
|
||||
@Resource
|
||||
private WqJobMapper wqJobMapper;
|
||||
|
||||
@Override
|
||||
public DataSourceResult processKendoList(DataSourceRequest dataSourceRequest) {
|
||||
boolean calculated = CommonConstant.CALCULATE_SUCCESS.equals(
|
||||
@ -4550,7 +4557,7 @@ public class EnvWqDataServiceImpl implements EnvWqDataService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(cacheNames = "weCache#3600", keyGenerator = "cacheKeyGenerator")
|
||||
// @Cacheable(cacheNames = "weCache#3600", keyGenerator = "cacheKeyGenerator")
|
||||
public DataSourceResult<EnvWqAnchorPointVo> getAnchorPointKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceResult<EnvWqAnchorPointVo> dataSourceResult = new DataSourceResult<>();
|
||||
dataSourceResult.setAggregates(new HashMap<>());
|
||||
@ -4651,12 +4658,12 @@ public class EnvWqDataServiceImpl implements EnvWqDataService {
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<EnvWqDataVo> wqDataList = queryWqDataByStcdBatch(stcdList);
|
||||
Map<String, EnvWqDataVo> wqDataMap = wqDataList.stream()
|
||||
.collect(Collectors.toMap(EnvWqDataVo::getStcd, Function.identity(), (oldValue, newValue) -> newValue));
|
||||
// List<EnvWqDataVo> wqDataList = queryWqDataByStcdBatch(stcdList);
|
||||
// Map<String, EnvWqDataVo> wqDataMap = wqDataList.stream()
|
||||
// .collect(Collectors.toMap(EnvWqDataVo::getStcd, Function.identity(), (oldValue, newValue) -> newValue));
|
||||
|
||||
for (EnvWqAnchorPointVo anchorPointVo : wqVoList) {
|
||||
EnvWqDataVo wqData = wqDataMap.get(anchorPointVo.getStcd());
|
||||
EnvWqDataVo wqData = redisCacheUtil.fromJson(redisCacheUtil.getString("wqLastDate:" + anchorPointVo.getStcd()), EnvWqDataVo.class);
|
||||
if (wqData != null) {
|
||||
anchorPointVo.setTm(wqData.getTm());
|
||||
anchorPointVo.setWqGrd(wqData.getWqgrd());
|
||||
@ -4964,4 +4971,29 @@ public class EnvWqDataServiceImpl implements EnvWqDataService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wqLastData(JobBaseAo ao) {
|
||||
List<SdWqR> wqDataVos = wqJobMapper.getWqLastData(ao);
|
||||
String startTimeStr = DateUtil.format(ao.getStartTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
String endTimeStr = DateUtil.format(ao.getEndTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
List<SdWqR> wqYsDataVos = wqJobMapper.getWqYsLastData(startTimeStr, endTimeStr);
|
||||
if (CollectionUtils.isNotEmpty(wqYsDataVos)) {
|
||||
for (SdWqR wqDataVo : wqYsDataVos) {
|
||||
redisCacheUtil.setString("wqYsLastDate:" + wqDataVo.getStcd(), JSONUtil.toJsonStr(wqDataVo));
|
||||
}
|
||||
}
|
||||
if (CollUtil.isEmpty(wqDataVos)) {
|
||||
return;
|
||||
}
|
||||
if (!wqDataVos.isEmpty()) {
|
||||
List<List<SdWqR>> newWqrListPartition = CollUtil.split(wqDataVos, 300);
|
||||
for (List<SdWqR> t : newWqrListPartition) {
|
||||
wqJobMapper.mergeWqR(t);
|
||||
}
|
||||
}
|
||||
for (SdWqR wqDataVo : wqDataVos) {
|
||||
redisCacheUtil.setString("wqLastDate:" + wqDataVo.getStcd(), JSONUtil.toJsonStr(wqDataVo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.yfd.platform.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -12,8 +15,9 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RedisCacheUtil {
|
||||
|
||||
static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@ -41,6 +45,21 @@ public class RedisCacheUtil {
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
public <T> T fromJson(String json, Class<T> clazz) {
|
||||
if (!StringUtils.isBlank(json) && clazz != null) {
|
||||
try {
|
||||
return (T)objectMapper.readValue(json, clazz);
|
||||
} catch (Exception var4) {
|
||||
if (log.isErrorEnabled()) {
|
||||
log.error(var4.getMessage(), var4);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object get(String key) {
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
56
backend/src/main/resources/mapper/qgc_env/wq/WqJobMapper.xml
Normal file
56
backend/src/main/resources/mapper/qgc_env/wq/WqJobMapper.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yfd.platform.qgc_env.wq.mapper.WqJobMapper">
|
||||
|
||||
<select id="getWqLastData" resultType="com.yfd.platform.qgc_env.wq.entity.SdWqR">
|
||||
SELECT SHR.*,CASE SHR.WQGRD
|
||||
WHEN '1' THEN 'Ⅰ'
|
||||
WHEN '2' THEN 'Ⅱ'
|
||||
WHEN '3' THEN 'Ⅲ'
|
||||
WHEN '4' THEN 'Ⅳ'
|
||||
WHEN '5' THEN 'Ⅴ'
|
||||
WHEN '6' THEN 'V'
|
||||
ELSE '未知'
|
||||
END AS wqgrdName FROM (
|
||||
SELECT STCD, MAX(TM) TM FROM SD_WQ_R WHERE NVL(IS_DELETED, 0) = 0 GROUP BY STCD
|
||||
) T LEFT JOIN SD_WQ_R SHR ON T.STCD = SHR.STCD AND SHR.TM = T.TM
|
||||
</select>
|
||||
|
||||
<select id="getWqYsLastData" resultType="com.yfd.platform.qgc_env.wq.entity.SdWqR">
|
||||
SELECT * FROM (
|
||||
SELECT SD_WQ_R.*,CASE SD_WQ_R.WQGRD
|
||||
WHEN '1' THEN 'Ⅰ'
|
||||
WHEN '2' THEN 'Ⅱ'
|
||||
WHEN '3' THEN 'Ⅲ'
|
||||
WHEN '4' THEN 'Ⅳ'
|
||||
WHEN '5' THEN 'Ⅴ'
|
||||
WHEN '6' THEN 'V'
|
||||
ELSE '未知'
|
||||
END AS wqgrdName,
|
||||
RANK() OVER (PARTITION BY STCD ORDER BY TM DESC) AS RANK
|
||||
FROM SD_WQ_R
|
||||
WHERE NVL(IS_DELETED, 0) = 0
|
||||
AND <![CDATA[ TM >= TO_DATE(#{startTimeStr}, 'yyyy-MM-dd HH24:mi:ss') ]]>
|
||||
AND <![CDATA[ TM <= TO_DATE(#{endTimeStr}, 'yyyy-MM-dd HH24:mi:ss') ]]>
|
||||
AND (NH3N IS NOT NULL OR TP IS NOT NULL OR TN IS NOT NULL)
|
||||
) WHERE RANK = 1
|
||||
</select>
|
||||
|
||||
<update id="mergeWqR">
|
||||
MERGE INTO SD_WQ_R T
|
||||
USING (
|
||||
<foreach collection="wqRs" index="index" item="wqR" open="" close="" separator="union all">
|
||||
SELECT #{wqR.id,jdbcType=VARCHAR} AS ID
|
||||
, #{wqR.wqgrd,jdbcType=VARCHAR} AS WQGRD
|
||||
, #{wqR.sfdb,jdbcType=NUMERIC} AS SFDB
|
||||
, #{wqR.wqSfdbhnYs,jdbcType=VARCHAR} AS WQ_SFDBHN_YS
|
||||
, SYSDATE AS MODIFY_TIME
|
||||
FROM DUAL
|
||||
</foreach>
|
||||
) S
|
||||
ON (T.ID = S.ID)
|
||||
WHEN MATCHED THEN
|
||||
UPDATE SET T.WQGRD = S.WQGRD, T.SFDB = S.SFDB, T.WQ_SFDBHN_YS = S.WQ_SFDBHN_YS, T.MODIFY_TIME = S.MODIFY_TIME
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user