diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java index 0d45ec4..5452d28 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sz_gssyd") +@TableName("xfgd_sz_gssyd") @ApiModel(value = "SzGssyd对象", description = "水质监测数据") public class SzGssyd extends BaseSwjEntity { @@ -115,6 +115,14 @@ @TableField(value = "AD") @JSONField(name="nh4n") private BigDecimal ad; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java index 0d45ec4..5452d28 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sz_gssyd") +@TableName("xfgd_sz_gssyd") @ApiModel(value = "SzGssyd对象", description = "水质监测数据") public class SzGssyd extends BaseSwjEntity { @@ -115,6 +115,14 @@ @TableField(value = "AD") @JSONField(name="nh4n") private BigDecimal ad; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java index 1f906e1..5af26ea 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_szy_r") +@TableName("xfgd_szy_r") @ApiModel(value = "SzyR对象", description = "水资源监测数据") public class SzyR extends BaseSwjEntity{ @@ -43,6 +43,14 @@ @TableField(value = "ZX") @JSONField(name="z") private BigDecimal zx; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java index 0d45ec4..5452d28 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sz_gssyd") +@TableName("xfgd_sz_gssyd") @ApiModel(value = "SzGssyd对象", description = "水质监测数据") public class SzGssyd extends BaseSwjEntity { @@ -115,6 +115,14 @@ @TableField(value = "AD") @JSONField(name="nh4n") private BigDecimal ad; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java index 1f906e1..5af26ea 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_szy_r") +@TableName("xfgd_szy_r") @ApiModel(value = "SzyR对象", description = "水资源监测数据") public class SzyR extends BaseSwjEntity{ @@ -43,6 +43,14 @@ @TableField(value = "ZX") @JSONField(name="z") private BigDecimal zx; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java index 6e2f64e..b6f4d33 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java @@ -18,8 +18,8 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_trsq_tjhs_r") -@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据") +@TableName("xfgd_trsq_tjhs_r") +@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据")//todo 未接 public class TrsqTjhsR extends BaseSwjEntity { private static final long serialVersionUID = 1L; @@ -65,4 +65,13 @@ @JSONField(name = "sq_type")//todo 墒情类型???? private String bz; + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java index 0d45ec4..5452d28 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sz_gssyd") +@TableName("xfgd_sz_gssyd") @ApiModel(value = "SzGssyd对象", description = "水质监测数据") public class SzGssyd extends BaseSwjEntity { @@ -115,6 +115,14 @@ @TableField(value = "AD") @JSONField(name="nh4n") private BigDecimal ad; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java index 1f906e1..5af26ea 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_szy_r") +@TableName("xfgd_szy_r") @ApiModel(value = "SzyR对象", description = "水资源监测数据") public class SzyR extends BaseSwjEntity{ @@ -43,6 +43,14 @@ @TableField(value = "ZX") @JSONField(name="z") private BigDecimal zx; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java index 6e2f64e..b6f4d33 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java @@ -18,8 +18,8 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_trsq_tjhs_r") -@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据") +@TableName("xfgd_trsq_tjhs_r") +@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据")//todo 未接 public class TrsqTjhsR extends BaseSwjEntity { private static final long serialVersionUID = 1L; @@ -65,4 +65,13 @@ @JSONField(name = "sq_type")//todo 墒情类型???? private String bz; + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java index b81c74a..0be4843 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; +import java.util.Date; import java.util.Map; /** @@ -76,7 +77,7 @@ }); model.setSt(map.get(PtReceiveBaseModel.RealTimeConsstant.st).toString()); model.setTt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.tt).toString(), DatePattern.NORM_DATETIME_PATTERN)); - model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); + model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut)==null?DateUtil.format(new Date(),DatePattern.NORM_DATETIME_PATTERN):map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); model.setDataMap(dataMap); return model; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java index 0d45ec4..5452d28 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sz_gssyd") +@TableName("xfgd_sz_gssyd") @ApiModel(value = "SzGssyd对象", description = "水质监测数据") public class SzGssyd extends BaseSwjEntity { @@ -115,6 +115,14 @@ @TableField(value = "AD") @JSONField(name="nh4n") private BigDecimal ad; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java index 1f906e1..5af26ea 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_szy_r") +@TableName("xfgd_szy_r") @ApiModel(value = "SzyR对象", description = "水资源监测数据") public class SzyR extends BaseSwjEntity{ @@ -43,6 +43,14 @@ @TableField(value = "ZX") @JSONField(name="z") private BigDecimal zx; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java index 6e2f64e..b6f4d33 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java @@ -18,8 +18,8 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_trsq_tjhs_r") -@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据") +@TableName("xfgd_trsq_tjhs_r") +@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据")//todo 未接 public class TrsqTjhsR extends BaseSwjEntity { private static final long serialVersionUID = 1L; @@ -65,4 +65,13 @@ @JSONField(name = "sq_type")//todo 墒情类型???? private String bz; + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java index b81c74a..0be4843 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; +import java.util.Date; import java.util.Map; /** @@ -76,7 +77,7 @@ }); model.setSt(map.get(PtReceiveBaseModel.RealTimeConsstant.st).toString()); model.setTt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.tt).toString(), DatePattern.NORM_DATETIME_PATTERN)); - model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); + model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut)==null?DateUtil.format(new Date(),DatePattern.NORM_DATETIME_PATTERN):map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); model.setDataMap(dataMap); return model; } diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java index f3ff4a3..fa9bc5e 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java @@ -27,7 +27,7 @@ private final HpAction hpAction; private final YlAction ylAction; private final ZsAction zsAction; - @Scheduled(cron = "0 0/1 * * * ?") +// @Scheduled(cron = "0 0/1 * * * ?") public void synchronize() { bzAction.list(); gqAction.list(); diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java index 0d45ec4..5452d28 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sz_gssyd") +@TableName("xfgd_sz_gssyd") @ApiModel(value = "SzGssyd对象", description = "水质监测数据") public class SzGssyd extends BaseSwjEntity { @@ -115,6 +115,14 @@ @TableField(value = "AD") @JSONField(name="nh4n") private BigDecimal ad; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java index 1f906e1..5af26ea 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_szy_r") +@TableName("xfgd_szy_r") @ApiModel(value = "SzyR对象", description = "水资源监测数据") public class SzyR extends BaseSwjEntity{ @@ -43,6 +43,14 @@ @TableField(value = "ZX") @JSONField(name="z") private BigDecimal zx; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java index 6e2f64e..b6f4d33 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java @@ -18,8 +18,8 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_trsq_tjhs_r") -@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据") +@TableName("xfgd_trsq_tjhs_r") +@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据")//todo 未接 public class TrsqTjhsR extends BaseSwjEntity { private static final long serialVersionUID = 1L; @@ -65,4 +65,13 @@ @JSONField(name = "sq_type")//todo 墒情类型???? private String bz; + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java index b81c74a..0be4843 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; +import java.util.Date; import java.util.Map; /** @@ -76,7 +77,7 @@ }); model.setSt(map.get(PtReceiveBaseModel.RealTimeConsstant.st).toString()); model.setTt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.tt).toString(), DatePattern.NORM_DATETIME_PATTERN)); - model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); + model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut)==null?DateUtil.format(new Date(),DatePattern.NORM_DATETIME_PATTERN):map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); model.setDataMap(dataMap); return model; } diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java index f3ff4a3..fa9bc5e 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java @@ -27,7 +27,7 @@ private final HpAction hpAction; private final YlAction ylAction; private final ZsAction zsAction; - @Scheduled(cron = "0 0/1 * * * ?") +// @Scheduled(cron = "0 0/1 * * * ?") public void synchronize() { bzAction.list(); gqAction.list(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 3ff0737..f78c9fc 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -35,6 +35,9 @@ datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver +# url: jdbc:mysql://172.16.3.38:3306/swj?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong&rewriteBatchedStatements=true +# username: u_swj +# password: c5Uh5WQRtacH url: jdbc:mysql://192.168.30.92:3306/swj?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong&rewriteBatchedStatements=true username: root password: admin123!@# diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java index 0d45ec4..5452d28 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sz_gssyd") +@TableName("xfgd_sz_gssyd") @ApiModel(value = "SzGssyd对象", description = "水质监测数据") public class SzGssyd extends BaseSwjEntity { @@ -115,6 +115,14 @@ @TableField(value = "AD") @JSONField(name="nh4n") private BigDecimal ad; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java index 1f906e1..5af26ea 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_szy_r") +@TableName("xfgd_szy_r") @ApiModel(value = "SzyR对象", description = "水资源监测数据") public class SzyR extends BaseSwjEntity{ @@ -43,6 +43,14 @@ @TableField(value = "ZX") @JSONField(name="z") private BigDecimal zx; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java index 6e2f64e..b6f4d33 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java @@ -18,8 +18,8 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_trsq_tjhs_r") -@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据") +@TableName("xfgd_trsq_tjhs_r") +@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据")//todo 未接 public class TrsqTjhsR extends BaseSwjEntity { private static final long serialVersionUID = 1L; @@ -65,4 +65,13 @@ @JSONField(name = "sq_type")//todo 墒情类型???? private String bz; + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java index b81c74a..0be4843 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; +import java.util.Date; import java.util.Map; /** @@ -76,7 +77,7 @@ }); model.setSt(map.get(PtReceiveBaseModel.RealTimeConsstant.st).toString()); model.setTt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.tt).toString(), DatePattern.NORM_DATETIME_PATTERN)); - model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); + model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut)==null?DateUtil.format(new Date(),DatePattern.NORM_DATETIME_PATTERN):map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); model.setDataMap(dataMap); return model; } diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java index f3ff4a3..fa9bc5e 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java @@ -27,7 +27,7 @@ private final HpAction hpAction; private final YlAction ylAction; private final ZsAction zsAction; - @Scheduled(cron = "0 0/1 * * * ?") +// @Scheduled(cron = "0 0/1 * * * ?") public void synchronize() { bzAction.list(); gqAction.list(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 3ff0737..f78c9fc 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -35,6 +35,9 @@ datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver +# url: jdbc:mysql://172.16.3.38:3306/swj?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong&rewriteBatchedStatements=true +# username: u_swj +# password: c5Uh5WQRtacH url: jdbc:mysql://192.168.30.92:3306/swj?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong&rewriteBatchedStatements=true username: root password: admin123!@# diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml new file mode 100644 index 0000000..2ac6524 --- /dev/null +++ b/src/main/resources/application-pro.yml @@ -0,0 +1,89 @@ +server: + port: 8877 + +spring: + redis: + host: 172.16.3.111 + port: 6379 + password: redis!@# + # password: + database: 0 + ssl: false + rabbitmq: + virtual-host: pt_mq + # host: 139.155.49.237 + host: 172.16.3.111 + port: 5672 + username: pt + password: uXP578kav8SDcjCgy + publisher-confirm-type: correlated + publisher-returns: true + listener: + simple: + acknowledge-mode: manual + retry: + enabled: true + template: + routing-key: rtu_message_test + exchange: amq.topic + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://172.16.3.38:3306/swj?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong&rewriteBatchedStatements=true + username: u_swj + password: c5Uh5WQRtacH + cloud: + nacos: + discovery: + password: nacos + username: nacos + server-addr: 172.16.3.109 + namespace: public +logging: + level: + root: info + org: + springnewfiber: + dataadapter: info + +ziguang: + #渍水点 + zs: + listurl: http://58.49.51.33:8081/iwp/dynamic/zs/map_waterlglive/list + realurl: http://58.49.51.33:8081/iwp/dynamic/zs/zs_daylist/list + #雨量站 + yl: + listurl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_live/list + realurl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_daylistmi/list + #暂时未使用 + oneHourUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_daylisthour/list + threeHourUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_3hour/list + sixHourUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_6hour/list + dayUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_24hour/list + countUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_his/list + #泵站工情 + bz: + listurl: http://58.49.51.33:8081/iwp/dynamic/bz/map_pumplive/list + realurl: http://58.49.51.33:8081/iwp/dynamic/bz/map_pumpdaylist/list + #湖泊 + hp: + listurl: http://58.49.51.33:8081/iwp/dynamic/hp/map_lakelive/list + realurl: http://58.49.51.33:8081/iwp/dynamic/hp/hp_daylist/list + #港渠 + gq: + listurl: http://58.49.51.33:8081/iwp/dynamic/gq/map_canallive/list + realurl: http://58.49.51.33:8081/iwp/dynamic/gq/gq_daylist/list + #河道 + hd: + listurl: http://58.49.51.33:8081/iwp/dynamic/hd/map_riverlive/list + # realurl: http://58.49.51.33:8081/iwp/dynamic/hd/rvnm_order/list + realurl: http://58.49.51.33:8081/iwp/dynamic/hd/wh_daylive/list + login: +# username: data-service1 +# password: data-service11 + username: data-service2 + password: data-service212345678 + loginurl: http://58.49.51.33:8081/jkfc/user/login +#rabbitmq: +# exchange: amq.topic +# routingKey: rtu_message_test \ No newline at end of file diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java index 98c6030..4ddeda5 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/core/SswjCoreJob.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -42,22 +41,23 @@ private final SzyRServiceImpl szyRService; private final TrsqTjhsRServiceImpl trsqTjhsRService; -// @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/1 * * * ?") public void selectSwj() { - checkHasRealDate(BzLive.class, bzLiveService); - checkHasRealDate(SqGqR.class, sqGqRService); - checkHasRealDate(SqHdSr.class, sqHdSrService); - checkHasRealDate(SqHpR.class, sqHpRService); - checkHasRealDate(SqHzR.class, sqHzRService); - checkHasRealDate(SqSkR.class, sqSkRService); - checkHasRealDate(SqZsR.class, sqZsRService); - checkHasRealDate(SzGssyd.class, szGssydService); - checkHasRealDate(SzyR.class, szyRService); - checkHasRealDate(TrsqTjhsR.class, trsqTjhsRService); + checkHasRealDate(new BzLive(), bzLiveService); + checkHasRealDate(new SqGqR(), sqGqRService); + checkHasRealDate(new SqHdSr(), sqHdSrService); + checkHasRealDate(new SqHpR(), sqHpRService); + checkHasRealDate(new SqHzR(), sqHzRService); + checkHasRealDate(new SqSkR(), sqSkRService); + checkHasRealDate(new SqZsR(), sqZsRService); + checkHasRealDate(new SzGssyd(), szGssydService); + checkHasRealDate(new SzyR(), szyRService); + checkHasRealDate(new TrsqTjhsR(), trsqTjhsRService); } - private void checkHasRealDate(Class clazz, ServiceImpl service) { + private void checkHasRealDate(BaseSwjEntity baseSwjEntity, ServiceImpl service) { try { + Class clazz = baseSwjEntity.getClass(); String name = clazz.getSimpleName(); if (CollUtil.isNotEmpty(redis.keys(name.concat(StringPool.COLON).concat(StringPool.ASTERISK)))) { //已经有 @@ -69,12 +69,11 @@ list.forEach(i -> { String key = name.concat(StringPool.COLON).concat(i.getDataUpUuid()); BaseSwjEntity redisObject; - if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getDataUpTime() != null) { + if (redis.exists(key) && (redisObject = redis.get(key)) != null && redisObject.getTTDate() != null) { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByAsc("DATA_UP_TIME"); - selectQwId.eq("DATA_UP_UUID",redisObject.getDataUpUuid()); - selectQwId.gt("DATA_UP_TIME",redisObject.getDataUpTime()); -// List nowList = service.list(Wrappers.lambdaQuery().eq(BaseSwjEntity::getDataUpUuid, redisObject.getDataUpUuid()).gt(BaseSwjEntity::getDataUpTime, redisObject.getDataUpTime()).orderByAsc(BaseSwjEntity::getDataUpTime)); + selectQwId.orderByAsc(baseSwjEntity.getTTFileName()); + selectQwId.eq("DATA_UP_UUID", redisObject.getDataUpUuid()); + selectQwId.gt(baseSwjEntity.getTTFileName(), redisObject.getTTDate()); List nowList = service.list(selectQwId); if (CollUtil.isNotEmpty(nowList)) { nowList.forEach(now -> { @@ -82,7 +81,7 @@ redis.set(key, now); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, now.getDataUpUuid(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); }); } } @@ -95,9 +94,9 @@ List list = service.list(qw); list.forEach(i -> { QueryWrapper selectQwId = new QueryWrapper<>(); - selectQwId.orderByDesc("DATA_UP_TIME"); + selectQwId.orderByDesc(baseSwjEntity.getTTFileName()); selectQwId.last("limit 0,1"); - selectQwId.eq("DATA_UP_UUID",i.getDataUpUuid()); + selectQwId.eq("DATA_UP_UUID", i.getDataUpUuid()); List stRealDataList = service.list(selectQwId); if (CollUtil.isNotEmpty(stRealDataList)) { BaseSwjEntity entity = stRealDataList.get(0); @@ -108,13 +107,13 @@ redis.set(name.concat(StringPool.COLON).concat(model.getSt()), entity); //发送mq log.info("发送数据:{},点位:{},具体数据:{}", name, model.getSt(), JSONObject.toJSONString(model)); -// rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); + rabbitTemplate.convertAndSend(JSONObject.toJSONString(model)); } } }); } } catch (Exception e) { - log.error("发生错误:{},e:{}", clazz.getSimpleName(), e.getStackTrace()); + log.error("发生错误:{},e:{}", baseSwjEntity.getClass().getSimpleName(), e.getStackTrace()); } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java index 2423000..38ec3f9 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BaseSwjEntity.java @@ -2,11 +2,11 @@ import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; /** @@ -16,7 +16,7 @@ * @create: 2022-04-21 19:22 **/ @Data -public class BaseSwjEntity implements Serializable { +public abstract class BaseSwjEntity implements Serializable { /** * 站码 */ @@ -29,13 +29,31 @@ */ @ApiModelProperty(value = "数据状态") @TableField(value = "DATA_UP_STATUS") - @JSONField(serialize=false) + @JSONField(serialize = false) private String dataUpStatus; /** * 录入时间 */ @ApiModelProperty(value = "录入时间") @TableField(value = "DATA_UP_TIME") - @JSONField(name="ut",format = "yyyy-MM-dd HH:mm:ss") + @JSONField(name = "ut", format = "yyyy-MM-dd HH:mm:ss") private Date dataUpTime; + @JSONField(serialize = false) + @JsonIgnore + public abstract String getTTFileName(); + @JSONField(serialize = false) + @JsonIgnore + public abstract Date getTTDate(); + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String YMDHMBAK = "YMDHM"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String DATETIMEBAK = "DATETIME"; + @TableField(exist = false) + @JSONField(serialize = false) + @JsonIgnore + String TMBAK = "TM"; } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java index 4e0b238..616d0b0 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/BzLive.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_bz_live") +@TableName("xfgd_bz_live") @ApiModel(value = "BzLive对象", description = "泵站监测数据") public class BzLive extends BaseSwjEntity { @@ -70,4 +70,15 @@ @JSONField(name="ts") private BigDecimal ts; + @Override + @JSONField(serialize = false) + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + @JSONField(serialize = false) + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java index 77c2857..db5c2ff 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqGqR.java @@ -20,7 +20,7 @@ * @author admin */ @Data -@TableName("whsw_sq_gq_r") +@TableName("xfgd_sq_gq_r") @ApiModel(value = "SqGqR对象", description = "港渠监测数据") public class SqGqR extends BaseSwjEntity { @@ -50,6 +50,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java index f1a251b..209f700 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHdSr.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hd_sr") +@TableName("xfgd_sq_hd_sr") @ApiModel(value = "SqHdSr对象", description = "河道监测数据") public class SqHdSr extends BaseSwjEntity { @@ -58,6 +58,14 @@ @TableField(value = "ZRTEND") @JSONField(name="rate") private String zrtend; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java index 3db2c8b..c2e56aa 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHpR.java @@ -22,7 +22,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_hp_r") +@TableName("xfgd_sq_hp_r") @ApiModel(value = "SqHpR对象", description = "湖泊监测数据") public class SqHpR extends BaseSwjEntity{ @@ -52,6 +52,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return DATETIMEBAK; + } - + @Override + public Date getTTDate() { + return datetime; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java index 795304c..ae23725 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqHzR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_hz_r") +@TableName("xfgd_sq_hz_r") @ApiModel(value = "SqHzR对象", description = "涵闸监测数据") public class SqHzR extends BaseSwjEntity { @@ -51,6 +51,14 @@ @TableField(value = "PPTN") @JSONField(name="rate") private String pptn; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java index 36a21ba..8daa1de 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqSkR.java @@ -23,7 +23,7 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_sq_sk_r") +@TableName("xfgd_sq_sk_r") @ApiModel(value = "SqSkR对象", description = "水库监测数据") public class SqSkR extends BaseSwjEntity{ @@ -53,6 +53,13 @@ @JSONField(name="rate") private String pptn; + @Override + public String getTTFileName() { + return YMDHMBAK; + } - + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java index 671766c..1d98a4b 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SqZsR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sq_zs_r") +@TableName("xfgd_sq_zs_r") @ApiModel(value = "SqZsR对象", description = "渍水实时数据") public class SqZsR extends BaseSwjEntity { @@ -43,6 +43,14 @@ @TableField(value = "RZ") @JSONField(name="z") private BigDecimal rz; - + @Override + public String getTTFileName() { + return TMBAK; + } + + @Override + public Date getTTDate() { + return tm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java index 0d45ec4..5452d28 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzGssyd.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_sz_gssyd") +@TableName("xfgd_sz_gssyd") @ApiModel(value = "SzGssyd对象", description = "水质监测数据") public class SzGssyd extends BaseSwjEntity { @@ -115,6 +115,14 @@ @TableField(value = "AD") @JSONField(name="nh4n") private BigDecimal ad; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java index 1f906e1..5af26ea 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/SzyR.java @@ -22,7 +22,7 @@ * @author admin */ @Data -@TableName("whsw_szy_r") +@TableName("xfgd_szy_r") @ApiModel(value = "SzyR对象", description = "水资源监测数据") public class SzyR extends BaseSwjEntity{ @@ -43,6 +43,14 @@ @TableField(value = "ZX") @JSONField(name="z") private BigDecimal zx; - + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java index 6e2f64e..b6f4d33 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/entity/TrsqTjhsR.java @@ -18,8 +18,8 @@ * @since 2022-04-21 13:04:31 */ @Data -@TableName("whsw_trsq_tjhs_r") -@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据") +@TableName("xfgd_trsq_tjhs_r") +@ApiModel(value = "TrsqTjhsR对象", description = "土壤墒情监测数据")//todo 未接 public class TrsqTjhsR extends BaseSwjEntity { private static final long serialVersionUID = 1L; @@ -65,4 +65,13 @@ @JSONField(name = "sq_type")//todo 墒情类型???? private String bz; + @Override + public String getTTFileName() { + return YMDHMBAK; + } + + @Override + public Date getTTDate() { + return ymdhm; + } } diff --git a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java index b81c74a..0be4843 100644 --- a/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java +++ b/src/main/java/org/springnewfiber/dataadapter/sswj/util/RealTimeSerializer.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; +import java.util.Date; import java.util.Map; /** @@ -76,7 +77,7 @@ }); model.setSt(map.get(PtReceiveBaseModel.RealTimeConsstant.st).toString()); model.setTt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.tt).toString(), DatePattern.NORM_DATETIME_PATTERN)); - model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); + model.setUt(DateUtil.parse(map.get(PtReceiveBaseModel.RealTimeConsstant.ut)==null?DateUtil.format(new Date(),DatePattern.NORM_DATETIME_PATTERN):map.get(PtReceiveBaseModel.RealTimeConsstant.ut).toString(), DatePattern.NORM_DATETIME_PATTERN)); model.setDataMap(dataMap); return model; } diff --git a/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java b/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java index f3ff4a3..fa9bc5e 100644 --- a/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java +++ b/src/main/java/org/springnewfiber/dataadapter/ziguang/core/ZiGuangDataJob.java @@ -27,7 +27,7 @@ private final HpAction hpAction; private final YlAction ylAction; private final ZsAction zsAction; - @Scheduled(cron = "0 0/1 * * * ?") +// @Scheduled(cron = "0 0/1 * * * ?") public void synchronize() { bzAction.list(); gqAction.list(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 3ff0737..f78c9fc 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -35,6 +35,9 @@ datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver +# url: jdbc:mysql://172.16.3.38:3306/swj?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong&rewriteBatchedStatements=true +# username: u_swj +# password: c5Uh5WQRtacH url: jdbc:mysql://192.168.30.92:3306/swj?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong&rewriteBatchedStatements=true username: root password: admin123!@# diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml new file mode 100644 index 0000000..2ac6524 --- /dev/null +++ b/src/main/resources/application-pro.yml @@ -0,0 +1,89 @@ +server: + port: 8877 + +spring: + redis: + host: 172.16.3.111 + port: 6379 + password: redis!@# + # password: + database: 0 + ssl: false + rabbitmq: + virtual-host: pt_mq + # host: 139.155.49.237 + host: 172.16.3.111 + port: 5672 + username: pt + password: uXP578kav8SDcjCgy + publisher-confirm-type: correlated + publisher-returns: true + listener: + simple: + acknowledge-mode: manual + retry: + enabled: true + template: + routing-key: rtu_message_test + exchange: amq.topic + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://172.16.3.38:3306/swj?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Hongkong&rewriteBatchedStatements=true + username: u_swj + password: c5Uh5WQRtacH + cloud: + nacos: + discovery: + password: nacos + username: nacos + server-addr: 172.16.3.109 + namespace: public +logging: + level: + root: info + org: + springnewfiber: + dataadapter: info + +ziguang: + #渍水点 + zs: + listurl: http://58.49.51.33:8081/iwp/dynamic/zs/map_waterlglive/list + realurl: http://58.49.51.33:8081/iwp/dynamic/zs/zs_daylist/list + #雨量站 + yl: + listurl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_live/list + realurl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_daylistmi/list + #暂时未使用 + oneHourUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_daylisthour/list + threeHourUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_3hour/list + sixHourUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_6hour/list + dayUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_24hour/list + countUrl: http://58.49.51.33:8081/iwp/dynamic/yl/yl_his/list + #泵站工情 + bz: + listurl: http://58.49.51.33:8081/iwp/dynamic/bz/map_pumplive/list + realurl: http://58.49.51.33:8081/iwp/dynamic/bz/map_pumpdaylist/list + #湖泊 + hp: + listurl: http://58.49.51.33:8081/iwp/dynamic/hp/map_lakelive/list + realurl: http://58.49.51.33:8081/iwp/dynamic/hp/hp_daylist/list + #港渠 + gq: + listurl: http://58.49.51.33:8081/iwp/dynamic/gq/map_canallive/list + realurl: http://58.49.51.33:8081/iwp/dynamic/gq/gq_daylist/list + #河道 + hd: + listurl: http://58.49.51.33:8081/iwp/dynamic/hd/map_riverlive/list + # realurl: http://58.49.51.33:8081/iwp/dynamic/hd/rvnm_order/list + realurl: http://58.49.51.33:8081/iwp/dynamic/hd/wh_daylive/list + login: +# username: data-service1 +# password: data-service11 + username: data-service2 + password: data-service212345678 + loginurl: http://58.49.51.33:8081/jkfc/user/login +#rabbitmq: +# exchange: amq.topic +# routingKey: rtu_message_test \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 517d34e..e169996 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -29,3 +29,7 @@ username: nacos server-addr: 192.168.16.220:8848 namespace: public +mybatis-plus: + global-config: + db-config: + table-underline: false \ No newline at end of file