refactor: 重构

master
李一帆 2025-11-06 11:35:41 +08:00
parent 50b09e4b65
commit 80285b1864
57 changed files with 161 additions and 416 deletions

View File

@ -1,7 +1,7 @@
package com.gunshi.project.hsz.mapper;
package com.gunshi.project.hsz.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.hsz.model.StRiverR;
import com.gunshi.project.hsz.common.model.StRiverR;
import org.apache.ibatis.annotations.Mapper;
/**

View File

@ -1,7 +1,7 @@
package com.gunshi.project.hsz.mapper;
package com.gunshi.project.hsz.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.hsz.model.StRiverRReal;
import com.gunshi.project.hsz.common.model.StRiverRReal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

View File

@ -1,7 +1,7 @@
package com.gunshi.project.hsz.mapper;
package com.gunshi.project.hsz.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.hsz.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StRsvrR;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

View File

@ -1,7 +1,7 @@
package com.gunshi.project.hsz.mapper;
package com.gunshi.project.hsz.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.hsz.model.StRsvrRReal;
import com.gunshi.project.hsz.common.model.StRsvrRReal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.model;
package com.gunshi.project.hsz.common.model;
import com.baomidou.mybatisplus.annotation.IdType;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.model;
package com.gunshi.project.hsz.common.model;
import com.baomidou.mybatisplus.annotation.IdType;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.model;
package com.gunshi.project.hsz.common.model;
import com.baomidou.mybatisplus.annotation.IdType;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.model;
package com.gunshi.project.hsz.common.model;
import com.baomidou.mybatisplus.annotation.IdType;
@ -15,6 +15,7 @@ import jakarta.validation.constraints.Size;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -63,7 +64,7 @@ public class StRsvrRReal implements Serializable {
@TableField(value="rz")
@Schema(description="rz")
// @Size(max = 0,message = "rz最大长度要小于 0")
private String rz;
private BigDecimal rz;
/**
* inq

View File

@ -0,0 +1,19 @@
package com.gunshi.project.hsz.common.util;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
/**
* @author lyf
* @since 2025-11-06
*/
public class LocalDateTimeConverter {
public static Date toDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
public static LocalDateTime fromDate(Date date) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
}

View File

@ -1,8 +1,8 @@
<?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.gunshi.project.hsz.mapper.StRsvrRMapper">
<mapper namespace="com.gunshi.project.hsz.common.mapper.StRsvrRMapper">
<select id="getStcdLastRsvrData" resultType="com.gunshi.project.hsz.model.StRsvrR">
<select id="getStcdLastRsvrData" resultType="com.gunshi.project.hsz.common.model.StRsvrR">
SELECT stb.stcd,
case UPPER(stb.sttp) when 'RR' then r.tm when 'ZZ' then r2.tm end stm,
stb.source,
@ -16,7 +16,7 @@
WHERE subquery2.rn = 1) r2 ON stb.stcd = r2.stcd
WHERE stb.source in ('SW', 'SH', 'SHYLRES')
</select>
<select id="getStcdFirstRsvrData" resultType="com.gunshi.project.hsz.model.StRsvrR">
<select id="getStcdFirstRsvrData" resultType="com.gunshi.project.hsz.common.model.StRsvrR">
SELECT stb.stcd,
case UPPER(stb.sttp) when 'RR' then r.tm when 'ZZ' then r2.tm end etm,
stb.source,

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.service;
package com.gunshi.project.hsz.datasync;
import org.springframework.lang.NonNull;

View File

@ -1,8 +1,8 @@
package com.gunshi.project.hsz.datasync.config;
import com.gunshi.project.hsz.datasync.service.impl.SyncGnssRService;
import com.gunshi.project.hsz.datasync.service.impl.SyncSlRService;
import com.gunshi.project.hsz.datasync.service.impl.SyncSyRService;
import com.gunshi.project.hsz.datasync.gnss.SyncGnssRService;
import com.gunshi.project.hsz.datasync.seepage.SyncSlRService;
import com.gunshi.project.hsz.datasync.seepage.SyncSyRService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;

View File

@ -7,7 +7,7 @@ import com.gunshi.project.hsz.common.model.StStbprpBElem;
import com.gunshi.project.hsz.datasync.flow.datasource.JcskStFlowR;
import com.gunshi.project.hsz.common.mapper.StStbprpBElemMapper;
import com.gunshi.project.hsz.datasync.flow.datasource.JcskStFlowRMapper;
import com.gunshi.project.hsz.datasync.service.SyncTableRService;
import com.gunshi.project.hsz.datasync.SyncTableRService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.service.impl;
package com.gunshi.project.hsz.datasync.gnss;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gunshi.project.hsz.common.model.JcskGnssB;
@ -6,8 +6,8 @@ import com.gunshi.project.hsz.common.model.JcskGnssR;
import com.gunshi.project.hsz.datasync.entity.jcsk.AttMqttCalcData;
import com.gunshi.project.hsz.common.mapper.JcskGnssBMapper;
import com.gunshi.project.hsz.common.mapper.JcskGnssRMapper;
import com.gunshi.project.hsz.datasync.mapper.jcsk.AttMqttCalcDataNormalMapper;
import com.gunshi.project.hsz.datasync.service.SyncTableRService;
import com.gunshi.project.hsz.datasync.gnss.datasource.AttMqttCalcDataNormalMapper;
import com.gunshi.project.hsz.datasync.SyncTableRService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.mapper.jcsk;
package com.gunshi.project.hsz.datasync.gnss.datasource;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.mapper.jcsk;
package com.gunshi.project.hsz.datasync.gnss.datasource;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@ -1,15 +0,0 @@
package com.gunshi.project.hsz.datasync.mapper.jcsk;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.hsz.datasync.entity.jcsk.WaterDataTermites;
import org.apache.ibatis.annotations.Mapper;
/**
* WaterDataTermitesMapper
*/
@DS("jcsk")
@Mapper
public interface WaterDataTermitesMapper extends BaseMapper<WaterDataTermites> {
}

View File

@ -1,17 +0,0 @@
package com.gunshi.project.hsz.datasync.mapper.jcsk;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.hsz.datasync.entity.jcsk.WaterDevice;
import org.apache.ibatis.annotations.Mapper;
/**
* WaterDeviceMapper
*/
@DS("jcsk")
@Mapper
public interface WaterDeviceMapper extends BaseMapper<WaterDevice> {
// 可以在这里添加自定义的SQL方法
}

View File

@ -6,9 +6,10 @@ import com.gunshi.project.hsz.common.mapper.StPptnRRealMapper;
import com.gunshi.project.hsz.common.mapper.StStbprpBElemMapper;
import com.gunshi.project.hsz.common.model.StPptnR;
import com.gunshi.project.hsz.common.model.StStbprpBElem;
import com.gunshi.project.hsz.common.util.LocalDateTimeConverter;
import com.gunshi.project.hsz.datasync.rainfall.datasource.JcskStPptnR;
import com.gunshi.project.hsz.datasync.rainfall.datasource.JcskStPptnRMapper;
import com.gunshi.project.hsz.datasync.service.SyncTableRService;
import com.gunshi.project.hsz.datasync.SyncTableRService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
@ -16,6 +17,9 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.List;
/**
@ -69,7 +73,9 @@ public class SyncRainfallService implements SyncTableRService<JcskStPptnR, StPpt
if (target == null) {
target = new StPptnR();
target.setStcd(stcd);
target.setTm(LocalDateTime.of(2025, 10, 20, 15, 0, 0));
Date date = LocalDateTimeConverter.toDate(LocalDateTime.of(2025, 10, 20, 15, 0, 0));
target.setTm(date);
}
return target;
@ -78,7 +84,7 @@ public class SyncRainfallService implements SyncTableRService<JcskStPptnR, StPpt
@Override
public List<JcskStPptnR> getSourceEntityListByLatestTargetEntity(@NonNull StPptnR targetEntity) {
String stcd = targetEntity.getStcd();
LocalDateTime tm = targetEntity.getTm();
LocalDateTime tm = LocalDateTimeConverter.fromDate(targetEntity.getTm());
return sourceMapper.selectList(
new LambdaQueryWrapper<JcskStPptnR>()
.gt(JcskStPptnR::getTm, tm)
@ -101,6 +107,7 @@ public class SyncRainfallService implements SyncTableRService<JcskStPptnR, StPpt
if (existingTarget == null) {
StPptnR targetEntity = new StPptnR();
BeanUtils.copyProperties(sourceEntity, targetEntity);
targetEntity.setChtm(new Date());
targetMapper.insert(targetEntity);
}
count++;

View File

@ -1,40 +0,0 @@
package com.gunshi.project.hsz.datasync.riverWaterLevel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author lyf
* @since 2025-10-30
*/
@Data
@TableName("st_river_r")
public class RiverWaterLevel {
/**
*
*/
@TableField("stcd")
private String stcd;
/**
*
*/
@TableField("tm")
private LocalDateTime tm;
/**
*
*/
@TableField("z")
private BigDecimal z;
/**
*
*/
@TableField("wptn")
private String wptn;
}

View File

@ -1,14 +0,0 @@
package com.gunshi.project.hsz.datasync.riverWaterLevel;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lyf
* @since 2025-10-20
*/
@DS("tsg")
@Mapper
public interface RiverWaterLevelMapper extends BaseMapper<RiverWaterLevel> {
}

View File

@ -1,49 +0,0 @@
package com.gunshi.project.hsz.datasync.riverWaterLevel;
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 lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@TableName("st_river_r_real")
public class RiverWaterLevelReal {
/**
* stcd
*/
@TableId(value = "stcd", type = IdType.AUTO)
private String stcd;
/**
* tm
*/
@TableField(value = "tm")
private LocalDateTime tm;
/**
* z
*/
@TableField(value = "")
private BigDecimal z;
/**
* rwptn
*/
@TableField(value = "wptn")
private String wptn;
/**
* chtm
*/
@TableField(value = "chtm")
private LocalDateTime chtm;
}

View File

@ -1,14 +0,0 @@
package com.gunshi.project.hsz.datasync.riverWaterLevel;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lyf
* @since 2025-10-20
*/
@DS("tsg")
@Mapper
public interface RiverWaterLevelRealMapper extends BaseMapper<RiverWaterLevelReal> {
}

View File

@ -1,65 +0,0 @@
package com.gunshi.project.hsz.datasync.rsvrWaterLevel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author lyf
* @since 2025-10-20
*/
@Data
@TableName("st_rsvr_r")
public class RsvrWaterLevel {
/**
*
*/
@TableField("stcd")
private String stcd;
/**
*
*/
@TableField("tm")
private LocalDateTime tm;
/**
*
*/
@TableField("rz")
private BigDecimal rz;
/**
*
*/
@TableField("inq")
private BigDecimal inq;
/**
*
*/
@TableField("w")
private BigDecimal w;
/**
*
*/
@TableField("blrz")
private BigDecimal blrz;
/**
*
*/
@TableField("otq")
private BigDecimal otq;
/**
*
*/
@TableField("rwptn")
private String rwptn;
}

View File

@ -1,14 +0,0 @@
package com.gunshi.project.hsz.datasync.rsvrWaterLevel;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lyf
* @since 2025-10-20
*/
@DS("tsg")
@Mapper
public interface RsvrWaterLevelMapper extends BaseMapper<RsvrWaterLevel> {
}

View File

@ -1,49 +0,0 @@
package com.gunshi.project.hsz.datasync.rsvrWaterLevel;
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 lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@TableName("st_rsvr_r_real")
public class RsvrWaterLevelReal {
/**
* stcd
*/
@TableId(value = "stcd", type = IdType.AUTO)
private String stcd;
/**
* tm
*/
@TableField(value = "tm")
private LocalDateTime tm;
/**
* rz
*/
@TableField(value = "rz")
private BigDecimal rz;
/**
* rwptn
*/
@TableField(value = "rwptn")
private String rwptn;
/**
* chtm
*/
@TableField(value = "chtm")
private LocalDateTime chtm;
}

View File

@ -1,14 +0,0 @@
package com.gunshi.project.hsz.datasync.rsvrWaterLevel;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lyf
* @since 2025-10-20
*/
@DS("tsg")
@Mapper
public interface RsvrWaterLevelRealMapper extends BaseMapper<RsvrWaterLevelReal> {
}

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.service.impl;
package com.gunshi.project.hsz.datasync.seepage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gunshi.project.hsz.common.model.JcskSlB;
@ -6,8 +6,8 @@ import com.gunshi.project.hsz.common.model.JcskSlR;
import com.gunshi.project.hsz.datasync.entity.jcsk.DsmSpgSpqn;
import com.gunshi.project.hsz.common.mapper.JcskSlBMapper;
import com.gunshi.project.hsz.common.mapper.JcskSlRMapper;
import com.gunshi.project.hsz.datasync.mapper.jcsk.DsmSpgSpqnMapper;
import com.gunshi.project.hsz.datasync.service.SyncTableRService;
import com.gunshi.project.hsz.datasync.seepage.datasource.DsmSpgSpqnMapper;
import com.gunshi.project.hsz.datasync.SyncTableRService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.service.impl;
package com.gunshi.project.hsz.datasync.seepage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gunshi.project.hsz.common.model.JcskSyB;
@ -6,8 +6,8 @@ import com.gunshi.project.hsz.common.model.JcskSyR;
import com.gunshi.project.hsz.datasync.entity.jcsk.DsmSpgSppr;
import com.gunshi.project.hsz.common.mapper.JcskSyBMapper;
import com.gunshi.project.hsz.common.mapper.JcskSyRMapper;
import com.gunshi.project.hsz.datasync.mapper.jcsk.DsmSpgSpprMapper;
import com.gunshi.project.hsz.datasync.service.SyncTableRService;
import com.gunshi.project.hsz.datasync.seepage.datasource.DsmSpgSpprMapper;
import com.gunshi.project.hsz.datasync.SyncTableRService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.mapper.jcsk;
package com.gunshi.project.hsz.datasync.seepage.datasource;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.mapper.jcsk;
package com.gunshi.project.hsz.datasync.seepage.datasource;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.mapper.jcsk;
package com.gunshi.project.hsz.datasync.seepage.datasource;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.mapper.jcsk;
package com.gunshi.project.hsz.datasync.seepage.datasource;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@ -1,11 +1,16 @@
package com.gunshi.project.hsz.datasync.riverWaterLevel;
package com.gunshi.project.hsz.datasync.waterLevel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gunshi.project.hsz.common.mapper.StRiverRMapper;
import com.gunshi.project.hsz.common.mapper.StRiverRRealMapper;
import com.gunshi.project.hsz.common.model.StRiverR;
import com.gunshi.project.hsz.common.model.StRiverRReal;
import com.gunshi.project.hsz.common.model.StStbprpBElem;
import com.gunshi.project.hsz.common.mapper.StStbprpBElemMapper;
import com.gunshi.project.hsz.datasync.rsvrWaterLevel.datasource.JcskStRsvrR;
import com.gunshi.project.hsz.datasync.rsvrWaterLevel.datasource.JcskStRsvrRMapper;
import com.gunshi.project.hsz.datasync.service.SyncTableRService;
import com.gunshi.project.hsz.common.util.LocalDateTimeConverter;
import com.gunshi.project.hsz.datasync.waterLevel.datasource.JcskStRsvrR;
import com.gunshi.project.hsz.datasync.waterLevel.datasource.JcskStRsvrRMapper;
import com.gunshi.project.hsz.datasync.SyncTableRService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
@ -13,6 +18,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
@ -21,15 +27,15 @@ import java.util.List;
*
*/
@Service
public class SyncRiverWaterLevelService implements SyncTableRService<JcskStRsvrR, RiverWaterLevel> {
public class SyncRiverWaterLevelService implements SyncTableRService<JcskStRsvrR, StRiverR> {
@Autowired
private JcskStRsvrRMapper sourceMapper;
@Autowired
private RiverWaterLevelRealMapper targetRealMapper;
private StRiverRRealMapper targetRealMapper;
@Autowired
private RiverWaterLevelMapper targetMapper;
private StRiverRMapper targetMapper;
@Autowired
private StStbprpBElemMapper stbprpMapper;
@ -42,10 +48,10 @@ public class SyncRiverWaterLevelService implements SyncTableRService<JcskStRsvrR
int cnt = 0;
for (StStbprpBElem StStbprpBElem : stbprps) {
RiverWaterLevel targetParams = new RiverWaterLevel();
StRiverR targetParams = new StRiverR();
targetParams.setStcd(StStbprpBElem.getStcd());
//获取该站点在水库表中最新的那一条数据
RiverWaterLevel latestTarget = getLatestTargetEntity(targetParams);
StRiverR latestTarget = getLatestTargetEntity(targetParams);
List<JcskStRsvrR> sourceEntityList = getSourceEntityListByLatestTargetEntity(latestTarget);
cnt += saveToTarget(sourceEntityList);
}
@ -54,30 +60,32 @@ public class SyncRiverWaterLevelService implements SyncTableRService<JcskStRsvrR
@NonNull
@Override
public RiverWaterLevel getLatestTargetEntity(RiverWaterLevel targetParams) {
public StRiverR getLatestTargetEntity(StRiverR targetParams) {
String stcd = targetParams.getStcd();
RiverWaterLevel target = targetMapper.selectOne(
new LambdaQueryWrapper<RiverWaterLevel>()
.eq(RiverWaterLevel::getStcd, stcd)
.orderByDesc(RiverWaterLevel::getTm)
StRiverR target = targetMapper.selectOne(
new LambdaQueryWrapper<StRiverR>()
.eq(StRiverR::getStcd, stcd)
.orderByDesc(StRiverR::getTm)
.last("limit 1")
);
if (target == null) {
target = new RiverWaterLevel();
target = new StRiverR();
target.setStcd(stcd);
target.setTm(LocalDateTime.of(2025, 10, 20, 15, 0, 0));
Date date = LocalDateTimeConverter.toDate(LocalDateTime.of(2025, 10, 20, 15, 0, 0));
target.setTm(date);
}
return target;
}
@Override
public List<JcskStRsvrR> getSourceEntityListByLatestTargetEntity(@NonNull RiverWaterLevel targetEntity) {
public List<JcskStRsvrR> getSourceEntityListByLatestTargetEntity(@NonNull StRiverR targetEntity) {
//去荆楚水库中查询出,时间大于水库中最新那一条时间的记录
String stcd = targetEntity.getStcd();
LocalDateTime tm = targetEntity.getTm();
LocalDateTime tm = LocalDateTimeConverter.fromDate(targetEntity.getTm());
return sourceMapper.selectList(
new LambdaQueryWrapper<JcskStRsvrR>()
.gt(JcskStRsvrR::getTm, tm)
@ -92,14 +100,14 @@ public class SyncRiverWaterLevelService implements SyncTableRService<JcskStRsvrR
for (JcskStRsvrR sourceEntity : sourceEntityList) {
String stcd = sourceEntity.getStcd();
LocalDateTime tm = sourceEntity.getTm();
RiverWaterLevel existingTarget = targetMapper.selectOne(
new LambdaQueryWrapper<RiverWaterLevel>()
.eq(RiverWaterLevel::getStcd, stcd)
.eq(RiverWaterLevel::getTm, tm)
StRiverR existingTarget = targetMapper.selectOne(
new LambdaQueryWrapper<StRiverR>()
.eq(StRiverR::getStcd, stcd)
.eq(StRiverR::getTm, tm)
);
if (existingTarget == null) {
RiverWaterLevel targetEntity = new RiverWaterLevel();
StRiverR targetEntity = new StRiverR();
BeanUtils.copyProperties(sourceEntity, targetEntity);
targetEntity.setZ(sourceEntity.getRz());
targetEntity.setWptn(sourceEntity.getRwptn());
@ -112,15 +120,15 @@ public class SyncRiverWaterLevelService implements SyncTableRService<JcskStRsvrR
sourceEntityList.sort((o1, o2) -> o2.getTm().compareTo(o1.getTm()));
JcskStRsvrR sourceEntity = sourceEntityList.getFirst();
String stcd = sourceEntity.getStcd();
RiverWaterLevelReal real = targetRealMapper.selectById(stcd);
StRiverRReal real = targetRealMapper.selectById(stcd);
if (real == null) {
real = new RiverWaterLevelReal();
real = new StRiverRReal();
}
real.setTm(sourceEntity.getTm());
real.setTm(LocalDateTimeConverter.toDate(sourceEntity.getTm()));
real.setStcd(stcd);
real.setZ(sourceEntity.getRz());
real.setWptn(sourceEntity.getRwptn());
real.setChtm(LocalDateTime.now());
real.setChtm(new Date());
targetRealMapper.insertOrUpdate(real);
}
return count;

View File

@ -1,11 +1,16 @@
package com.gunshi.project.hsz.datasync.rsvrWaterLevel;
package com.gunshi.project.hsz.datasync.waterLevel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gunshi.project.hsz.common.mapper.StRsvrRMapper;
import com.gunshi.project.hsz.common.mapper.StRsvrRRealMapper;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StRsvrRReal;
import com.gunshi.project.hsz.common.model.StStbprpBElem;
import com.gunshi.project.hsz.common.mapper.StStbprpBElemMapper;
import com.gunshi.project.hsz.datasync.rsvrWaterLevel.datasource.JcskStRsvrR;
import com.gunshi.project.hsz.datasync.rsvrWaterLevel.datasource.JcskStRsvrRMapper;
import com.gunshi.project.hsz.datasync.service.SyncTableRService;
import com.gunshi.project.hsz.common.util.LocalDateTimeConverter;
import com.gunshi.project.hsz.datasync.waterLevel.datasource.JcskStRsvrR;
import com.gunshi.project.hsz.datasync.waterLevel.datasource.JcskStRsvrRMapper;
import com.gunshi.project.hsz.datasync.SyncTableRService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
@ -13,6 +18,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
@ -20,15 +26,15 @@ import java.util.List;
* @since 2025-10-20
*/
@Service
public class SyncRsvrWaterLevelService implements SyncTableRService<JcskStRsvrR, RsvrWaterLevel> {
public class SyncRsvrWaterLevelService implements SyncTableRService<JcskStRsvrR, StRsvrR> {
@Autowired
private JcskStRsvrRMapper sourceMapper;
@Autowired
private RsvrWaterLevelRealMapper targetRealMapper;
private StRsvrRRealMapper targetRealMapper;
@Autowired
private RsvrWaterLevelMapper targetMapper;
private StRsvrRMapper targetMapper;
@Autowired
private StStbprpBElemMapper stbprpMapper;
@ -41,10 +47,10 @@ public class SyncRsvrWaterLevelService implements SyncTableRService<JcskStRsvrR,
int cnt = 0;
for (StStbprpBElem StStbprpBElem : stbprps) {
RsvrWaterLevel targetParams = new RsvrWaterLevel();
StRsvrR targetParams = new StRsvrR();
targetParams.setStcd(StStbprpBElem.getStcd());
RsvrWaterLevel latestTarget = getLatestTargetEntity(targetParams);
StRsvrR latestTarget = getLatestTargetEntity(targetParams);
List<JcskStRsvrR> sourceEntityList = getSourceEntityListByLatestTargetEntity(latestTarget);
cnt += saveToTarget(sourceEntityList);
}
@ -53,29 +59,29 @@ public class SyncRsvrWaterLevelService implements SyncTableRService<JcskStRsvrR,
@NonNull
@Override
public RsvrWaterLevel getLatestTargetEntity(RsvrWaterLevel targetParams) {
public StRsvrR getLatestTargetEntity(StRsvrR targetParams) {
String stcd = targetParams.getStcd();
RsvrWaterLevel target = targetMapper.selectOne(
new LambdaQueryWrapper<RsvrWaterLevel>()
.eq(RsvrWaterLevel::getStcd, stcd)
.orderByDesc(RsvrWaterLevel::getTm)
StRsvrR target = targetMapper.selectOne(
new LambdaQueryWrapper<StRsvrR>()
.eq(StRsvrR::getStcd, stcd)
.orderByDesc(StRsvrR::getTm)
.last("limit 1")
);
if (target == null) {
target = new RsvrWaterLevel();
target = new StRsvrR();
target.setStcd(stcd);
target.setTm(LocalDateTime.of(2025,10,20,15,0,0));
target.setTm(LocalDateTimeConverter.toDate(LocalDateTime.of(2025, 10, 20, 15, 0, 0)));
}
return target;
}
@Override
public List<JcskStRsvrR> getSourceEntityListByLatestTargetEntity(@NonNull RsvrWaterLevel targetEntity) {
public List<JcskStRsvrR> getSourceEntityListByLatestTargetEntity(@NonNull StRsvrR targetEntity) {
String stcd = targetEntity.getStcd();
LocalDateTime tm = targetEntity.getTm();
LocalDateTime tm = LocalDateTimeConverter.fromDate(targetEntity.getTm());
return sourceMapper.selectList(
new LambdaQueryWrapper<JcskStRsvrR>()
.gt(JcskStRsvrR::getTm, tm)
@ -89,14 +95,14 @@ public class SyncRsvrWaterLevelService implements SyncTableRService<JcskStRsvrR,
for (JcskStRsvrR sourceEntity : sourceEntityList) {
String stcd = sourceEntity.getStcd();
LocalDateTime tm = sourceEntity.getTm();
RsvrWaterLevel existingTarget = targetMapper.selectOne(
new LambdaQueryWrapper<RsvrWaterLevel>()
.eq(RsvrWaterLevel::getStcd, stcd)
.eq(RsvrWaterLevel::getTm, tm)
StRsvrR existingTarget = targetMapper.selectOne(
new LambdaQueryWrapper<StRsvrR>()
.eq(StRsvrR::getStcd, stcd)
.eq(StRsvrR::getTm, tm)
);
if (existingTarget == null) {
RsvrWaterLevel targetEntity = new RsvrWaterLevel();
StRsvrR targetEntity = new StRsvrR();
BeanUtils.copyProperties(sourceEntity, targetEntity);
targetMapper.insert(targetEntity);
}
@ -107,15 +113,15 @@ public class SyncRsvrWaterLevelService implements SyncTableRService<JcskStRsvrR,
sourceEntityList.sort((o1, o2) -> o2.getTm().compareTo(o1.getTm()));
JcskStRsvrR sourceEntity = sourceEntityList.getFirst();
String stcd = sourceEntity.getStcd();
RsvrWaterLevelReal real = targetRealMapper.selectById(stcd);
StRsvrRReal real = targetRealMapper.selectById(stcd);
if (real == null) {
real = new RsvrWaterLevelReal();
real = new StRsvrRReal();
}
real.setTm(sourceEntity.getTm());
real.setTm(LocalDateTimeConverter.toDate(sourceEntity.getTm()));
real.setStcd(stcd);
real.setRz(sourceEntity.getRz());
real.setRwptn(sourceEntity.getRwptn());
real.setChtm(LocalDateTime.now());
real.setChtm(new Date());
targetRealMapper.insertOrUpdate(real);
}
return count;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.rsvrWaterLevel.datasource;
package com.gunshi.project.hsz.datasync.waterLevel.datasource;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;

View File

@ -1,4 +1,4 @@
package com.gunshi.project.hsz.datasync.rsvrWaterLevel.datasource;
package com.gunshi.project.hsz.datasync.waterLevel.datasource;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@ -9,6 +9,7 @@ import com.gunshi.core.annotation.Get;
import com.gunshi.core.annotation.Post;
import com.gunshi.core.result.R;
import com.gunshi.project.hsz.common.model.StPptnR;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StStbprpB;
import com.gunshi.project.hsz.entity.so.DataQueryCommonSo;
import com.gunshi.project.hsz.entity.so.PicQuerySo;

View File

@ -2,7 +2,7 @@ package com.gunshi.project.hsz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R;
import com.gunshi.project.hsz.model.StRiverR;
import com.gunshi.project.hsz.common.model.StRiverR;
import com.gunshi.project.hsz.service.StRiverRService;
import com.gunshi.project.hsz.common.validate.markers.Insert;
import com.gunshi.project.hsz.common.validate.markers.Update;

View File

@ -2,7 +2,7 @@ package com.gunshi.project.hsz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R;
import com.gunshi.project.hsz.model.StRiverRReal;
import com.gunshi.project.hsz.common.model.StRiverRReal;
import com.gunshi.project.hsz.service.StRiverRRealService;
import com.gunshi.project.hsz.common.validate.markers.Insert;
import com.gunshi.project.hsz.common.validate.markers.Update;

View File

@ -1,7 +1,7 @@
package com.gunshi.project.hsz.controller;
import com.gunshi.core.result.R;
import com.gunshi.project.hsz.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.service.StRsvrRService;
import com.gunshi.project.hsz.common.validate.markers.Insert;
import com.gunshi.project.hsz.common.validate.markers.Update;

View File

@ -1,7 +1,7 @@
package com.gunshi.project.hsz.controller;
import com.gunshi.core.result.R;
import com.gunshi.project.hsz.model.StRsvrRReal;
import com.gunshi.project.hsz.common.model.StRsvrRReal;
import com.gunshi.project.hsz.service.StRsvrRRealService;
import com.gunshi.project.hsz.common.validate.markers.Insert;
import com.gunshi.project.hsz.common.validate.markers.Update;

View File

@ -1,6 +1,6 @@
package com.gunshi.project.hsz.entity.vo;
import com.gunshi.project.hsz.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StRsvrR;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -2,6 +2,7 @@ package com.gunshi.project.hsz.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StStbprpB;
import com.gunshi.project.hsz.entity.so.DataQueryCommonSo;
import com.gunshi.project.hsz.entity.so.PicQuerySo;

View File

@ -9,6 +9,7 @@ import com.gunshi.algorithm.RrainfallForecast;
import com.gunshi.algorithm.RunoffService;
import com.gunshi.model.vo.FloodAlgorithemVo;
import com.gunshi.project.hsz.common.model.StPptnR;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StStbprpB;
import com.gunshi.project.hsz.entity.vo.ForeRainStatVo;
import com.gunshi.project.hsz.entity.vo.ForeRainTimeVo;

View File

@ -14,7 +14,7 @@ import com.gunshi.project.hsz.mapper.MessageCenterMapper;
import com.gunshi.project.hsz.model.AttResBase;
import com.gunshi.project.hsz.model.MessageCenter;
import com.gunshi.project.hsz.model.OsmoticWarnR;
import com.gunshi.project.hsz.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.util.DateUtil;
import com.ruoyi.common.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gunshi.project.hsz.common.model.StPptnRReal;
import com.gunshi.project.hsz.common.model.StRiverRReal;
import com.gunshi.project.hsz.entity.so.DataQueryCommonSo;
import com.gunshi.project.hsz.entity.vo.*;
import com.gunshi.project.hsz.mapper.AttResBaseMapper;

View File

@ -6,6 +6,7 @@ import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gunshi.db.dto.DateTimeRangeSo;
import com.gunshi.project.hsz.common.model.StRiverRReal;
import com.gunshi.project.hsz.entity.vo.*;
import com.gunshi.project.hsz.mapper.AttResBaseMapper;
import com.gunshi.project.hsz.mapper.StQxWarnRMapper;

View File

@ -1,8 +1,8 @@
package com.gunshi.project.hsz.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.mapper.StRiverRRealMapper;
import com.gunshi.project.hsz.model.StRiverRReal;
import com.gunshi.project.hsz.common.mapper.StRiverRRealMapper;
import com.gunshi.project.hsz.common.model.StRiverRReal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View File

@ -1,8 +1,8 @@
package com.gunshi.project.hsz.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.mapper.StRiverRMapper;
import com.gunshi.project.hsz.model.StRiverR;
import com.gunshi.project.hsz.common.mapper.StRiverRMapper;
import com.gunshi.project.hsz.common.model.StRiverR;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View File

@ -1,8 +1,8 @@
package com.gunshi.project.hsz.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.mapper.StRsvrRRealMapper;
import com.gunshi.project.hsz.model.StRsvrRReal;
import com.gunshi.project.hsz.common.mapper.StRsvrRRealMapper;
import com.gunshi.project.hsz.common.model.StRsvrRReal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View File

@ -7,8 +7,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.mapper.StRsvrRMapper;
import com.gunshi.project.hsz.model.StRsvrR;
import com.gunshi.project.hsz.common.mapper.StRsvrRMapper;
import com.gunshi.project.hsz.common.model.StRsvrR;
import lombok.extern.slf4j.Slf4j;

View File

@ -12,7 +12,7 @@ import com.gunshi.project.hsz.entity.vo.*;
import com.gunshi.project.hsz.mapper.OsmoticPressRMapper;
import com.gunshi.project.hsz.mapper.OsmoticShiftRMapper;
import com.gunshi.project.hsz.mapper.StbprpBVoMapper;
import com.gunshi.project.hsz.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.model.StZqrlB;
import com.gunshi.project.hsz.model.StZvarlB;
import com.gunshi.project.hsz.util.DateUtil;

View File

@ -3,7 +3,7 @@ package com.gunshi.project.hsz.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.entity.vo.RsvrComplexVo;
import com.gunshi.project.hsz.mapper.StZqrlBMapper;
import com.gunshi.project.hsz.model.StRsvrR;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.model.StZqrlB;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

View File

@ -3,6 +3,7 @@ package com.gunshi.project.hsz.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gunshi.db.dto.DateRangeSo;
import com.gunshi.project.hsz.common.model.StRsvrR;
import com.gunshi.project.hsz.entity.vo.WaterAnalysisVo;
import com.gunshi.project.hsz.entity.vo.WaterCapacityAnalysisVo;
import com.gunshi.project.hsz.model.*;

View File

@ -1,15 +1,12 @@
package com.gunshi.project.hsz.timetask;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.gunshi.project.hsz.entity.enums.AlarmTypeEnum;
import com.gunshi.project.hsz.entity.vo.AttResBaseVo;
import com.gunshi.project.hsz.mapper.AlarmSetMapper;
import com.gunshi.project.hsz.mapper.AttResBaseMapper;
import com.gunshi.project.hsz.mapper.StRsvrRRealMapper;
import com.gunshi.project.hsz.model.AlarmSet;
import com.gunshi.project.hsz.model.StRiverRReal;
import com.gunshi.project.hsz.model.StRsvrRReal;
import com.gunshi.project.hsz.common.model.StRiverRReal;
import com.gunshi.project.hsz.model.WaterAlarm;
import com.gunshi.project.hsz.service.StRiverRRealService;
import com.gunshi.project.hsz.service.WaterAlarmService;
@ -19,19 +16,11 @@ import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**

View File

@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.gunshi.project.hsz.common.model.StPptnR;
import com.gunshi.project.hsz.common.model.*;
import com.gunshi.project.hsz.model.*;
import com.gunshi.project.hsz.service.*;
import com.gunshi.project.hsz.util.OkHttpUtil;