1061 changed files with 104002 additions and 0 deletions
@ -0,0 +1,47 @@ |
|||||||
|
###################################################################### |
||||||
|
# Build Tools |
||||||
|
|
||||||
|
.gradle |
||||||
|
/build/ |
||||||
|
!gradle/wrapper/gradle-wrapper.jar |
||||||
|
|
||||||
|
target/ |
||||||
|
!.mvn/wrapper/maven-wrapper.jar |
||||||
|
|
||||||
|
###################################################################### |
||||||
|
# IDE |
||||||
|
|
||||||
|
### STS ### |
||||||
|
.apt_generated |
||||||
|
.classpath |
||||||
|
.factorypath |
||||||
|
.project |
||||||
|
.settings |
||||||
|
.springBeans |
||||||
|
|
||||||
|
### IntelliJ IDEA ### |
||||||
|
.idea |
||||||
|
*.iws |
||||||
|
*.iml |
||||||
|
*.ipr |
||||||
|
|
||||||
|
### JRebel ### |
||||||
|
rebel.xml |
||||||
|
|
||||||
|
### NetBeans ### |
||||||
|
nbproject/private/ |
||||||
|
build/* |
||||||
|
nbbuild/ |
||||||
|
dist/ |
||||||
|
nbdist/ |
||||||
|
.nb-gradle/ |
||||||
|
|
||||||
|
###################################################################### |
||||||
|
# Others |
||||||
|
*.log |
||||||
|
*.xml.versionsBackup |
||||||
|
*.swp |
||||||
|
|
||||||
|
!*/build/*.java |
||||||
|
!*/build/*.html |
||||||
|
!*/build/*.xml |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
The MIT License (MIT) |
||||||
|
|
||||||
|
Copyright (c) 2018 RuoYi |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of |
||||||
|
this software and associated documentation files (the "Software"), to deal in |
||||||
|
the Software without restriction, including without limitation the rights to |
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so, |
||||||
|
subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
@echo off |
||||||
|
echo. |
||||||
|
echo [信息] 清理工程target生成路径。 |
||||||
|
echo. |
||||||
|
|
||||||
|
%~d0 |
||||||
|
cd %~dp0 |
||||||
|
|
||||||
|
cd .. |
||||||
|
call mvn clean |
||||||
|
|
||||||
|
pause |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
@echo off |
||||||
|
echo. |
||||||
|
echo [信息] 打包Web工程,生成war/jar包文件。 |
||||||
|
echo. |
||||||
|
|
||||||
|
%~d0 |
||||||
|
cd %~dp0 |
||||||
|
|
||||||
|
cd .. |
||||||
|
call mvn clean package -Dmaven.test.skip=true |
||||||
|
|
||||||
|
pause |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
@echo off |
||||||
|
echo. |
||||||
|
echo [信息] 使用Jar命令运行Web工程。 |
||||||
|
echo. |
||||||
|
|
||||||
|
cd %~dp0 |
||||||
|
cd ../ruoyi-admin/target |
||||||
|
|
||||||
|
set JAVA_OPTS=-Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m |
||||||
|
|
||||||
|
java -jar %JAVA_OPTS% ruoyi-admin.jar |
||||||
|
|
||||||
|
cd bin |
||||||
|
pause |
||||||
Binary file not shown.
@ -0,0 +1,62 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<parent> |
||||||
|
<artifactId>ruoyi</artifactId> |
||||||
|
<groupId>com.ruoyi</groupId> |
||||||
|
<version>3.8.1</version> |
||||||
|
</parent> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<artifactId>hs_license</artifactId> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework.boot</groupId> |
||||||
|
<artifactId>spring-boot-starter-web</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>com.alibaba</groupId> |
||||||
|
<artifactId>fastjson</artifactId> |
||||||
|
<version>1.2.47</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>de.schlichtherle.truelicense</groupId> |
||||||
|
<artifactId>truelicense-core</artifactId> |
||||||
|
<version>1.33</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.6</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<!-- 获取系统信息 --> |
||||||
|
<dependency> |
||||||
|
<groupId>com.github.oshi</groupId> |
||||||
|
<artifactId>oshi-core</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<!-- 系统模块--> |
||||||
|
<dependency> |
||||||
|
<groupId>com.ruoyi</groupId> |
||||||
|
<artifactId>ruoyi-system</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
|
||||||
|
<!-- SpringBoot 拦截器 --> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework.boot</groupId> |
||||||
|
<artifactId>spring-boot-starter-aop</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
</dependencies> |
||||||
|
<properties> |
||||||
|
<maven.compiler.source>8</maven.compiler.source> |
||||||
|
<maven.compiler.target>8</maven.compiler.target> |
||||||
|
</properties> |
||||||
|
|
||||||
|
</project> |
||||||
@ -0,0 +1,80 @@ |
|||||||
|
package com.modules.entity; |
||||||
|
|
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 自定义需要校验的License参数 |
||||||
|
*/ |
||||||
|
//@Data
|
||||||
|
@AllArgsConstructor |
||||||
|
@NoArgsConstructor |
||||||
|
public class LicenseCheckModel implements Serializable{ |
||||||
|
|
||||||
|
private static final long serialVersionUID = 8600137500316662317L; |
||||||
|
/** |
||||||
|
* 可被允许的IP地址 |
||||||
|
*/ |
||||||
|
private List<String> ipAddress; |
||||||
|
|
||||||
|
/** |
||||||
|
* 可被允许的MAC地址 |
||||||
|
*/ |
||||||
|
private List<String> macAddress; |
||||||
|
|
||||||
|
/** |
||||||
|
* 可被允许的CPU序列号 |
||||||
|
*/ |
||||||
|
private String cpuSerial; |
||||||
|
|
||||||
|
/** |
||||||
|
* 可被允许的主板序列号 |
||||||
|
*/ |
||||||
|
private String mainBoardSerial; |
||||||
|
|
||||||
|
public List<String> getIpAddress() { |
||||||
|
return ipAddress; |
||||||
|
} |
||||||
|
|
||||||
|
public void setIpAddress(List<String> ipAddress) { |
||||||
|
this.ipAddress = ipAddress; |
||||||
|
} |
||||||
|
|
||||||
|
public List<String> getMacAddress() { |
||||||
|
return macAddress; |
||||||
|
} |
||||||
|
|
||||||
|
public void setMacAddress(List<String> macAddress) { |
||||||
|
this.macAddress = macAddress; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCpuSerial() { |
||||||
|
return cpuSerial; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCpuSerial(String cpuSerial) { |
||||||
|
this.cpuSerial = cpuSerial; |
||||||
|
} |
||||||
|
|
||||||
|
public String getMainBoardSerial() { |
||||||
|
return mainBoardSerial; |
||||||
|
} |
||||||
|
|
||||||
|
public void setMainBoardSerial(String mainBoardSerial) { |
||||||
|
this.mainBoardSerial = mainBoardSerial; |
||||||
|
} |
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String toString() {
|
||||||
|
// return "LicenseCheckModel{" +
|
||||||
|
// "ipAddress=" + ipAddress +
|
||||||
|
// ", macAddress=" + macAddress +
|
||||||
|
// ", cpuSerial='" + cpuSerial + '\'' +
|
||||||
|
// ", mainBoardSerial='" + mainBoardSerial + '\'' +
|
||||||
|
// '}';
|
||||||
|
// }
|
||||||
|
} |
||||||
@ -0,0 +1,95 @@ |
|||||||
|
package com.modules.entity; |
||||||
|
|
||||||
|
/** |
||||||
|
* License校验类需要的参数 |
||||||
|
*/ |
||||||
|
public class LicenseVerifyParam { |
||||||
|
|
||||||
|
/** |
||||||
|
* 证书subject |
||||||
|
*/ |
||||||
|
private String subject; |
||||||
|
|
||||||
|
/** |
||||||
|
* 公钥别称 |
||||||
|
*/ |
||||||
|
private String publicAlias; |
||||||
|
|
||||||
|
/** |
||||||
|
* 访问公钥库的密码 |
||||||
|
*/ |
||||||
|
private String storePass; |
||||||
|
|
||||||
|
/** |
||||||
|
* 证书生成路径 |
||||||
|
*/ |
||||||
|
private String licensePath; |
||||||
|
|
||||||
|
/** |
||||||
|
* 密钥库存储路径 |
||||||
|
*/ |
||||||
|
private String publicKeysStorePath; |
||||||
|
|
||||||
|
public LicenseVerifyParam() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public LicenseVerifyParam(String subject, String publicAlias, String storePass, String licensePath, String publicKeysStorePath) { |
||||||
|
this.subject = subject; |
||||||
|
this.publicAlias = publicAlias; |
||||||
|
this.storePass = storePass; |
||||||
|
this.licensePath = licensePath; |
||||||
|
this.publicKeysStorePath = publicKeysStorePath; |
||||||
|
} |
||||||
|
|
||||||
|
public String getSubject() { |
||||||
|
return subject; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSubject(String subject) { |
||||||
|
this.subject = subject; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPublicAlias() { |
||||||
|
return publicAlias; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPublicAlias(String publicAlias) { |
||||||
|
this.publicAlias = publicAlias; |
||||||
|
} |
||||||
|
|
||||||
|
public String getStorePass() { |
||||||
|
return storePass; |
||||||
|
} |
||||||
|
|
||||||
|
public void setStorePass(String storePass) { |
||||||
|
this.storePass = storePass; |
||||||
|
} |
||||||
|
|
||||||
|
public String getLicensePath() { |
||||||
|
return licensePath; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLicensePath(String licensePath) { |
||||||
|
this.licensePath = licensePath; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPublicKeysStorePath() { |
||||||
|
return publicKeysStorePath; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPublicKeysStorePath(String publicKeysStorePath) { |
||||||
|
this.publicKeysStorePath = publicKeysStorePath; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "LicenseVerifyParam{" + |
||||||
|
"subject='" + subject + '\'' + |
||||||
|
", publicAlias='" + publicAlias + '\'' + |
||||||
|
", storePass='" + storePass + '\'' + |
||||||
|
", licensePath='" + licensePath + '\'' + |
||||||
|
", publicKeysStorePath='" + publicKeysStorePath + '\'' + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,32 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<parent> |
||||||
|
<artifactId>ruoyi</artifactId> |
||||||
|
<groupId>com.ruoyi</groupId> |
||||||
|
<version>3.8.1</version> |
||||||
|
</parent> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<artifactId>job</artifactId> |
||||||
|
|
||||||
|
<description> |
||||||
|
任务 |
||||||
|
</description> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
|
||||||
|
<!-- 通用工具--> |
||||||
|
<dependency> |
||||||
|
<groupId>com.ruoyi</groupId> |
||||||
|
<artifactId>ruoyi-common</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>com.ruoyi</groupId> |
||||||
|
<artifactId>zxzb</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
</dependencies> |
||||||
|
</project> |
||||||
@ -0,0 +1,38 @@ |
|||||||
|
package com.ruoyi.job.config; |
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.apache.kafka.clients.producer.ProducerRecord; |
||||||
|
import org.apache.kafka.clients.producer.RecordMetadata; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.kafka.annotation.KafkaListener; |
||||||
|
import org.springframework.kafka.core.KafkaTemplate; |
||||||
|
import org.springframework.kafka.support.ProducerListener; |
||||||
|
|
||||||
|
import javax.annotation.PostConstruct; |
||||||
|
import javax.annotation.Resource; |
||||||
|
|
||||||
|
@Slf4j |
||||||
|
//@Configuration
|
||||||
|
public class ProSendYBLen { |
||||||
|
|
||||||
|
@Resource |
||||||
|
KafkaTemplate kafkaTemplate; |
||||||
|
|
||||||
|
//配置监听
|
||||||
|
@PostConstruct |
||||||
|
private void listener() { |
||||||
|
kafkaTemplate.setProducerListener(new ProducerListener() { |
||||||
|
@Override |
||||||
|
public void onSuccess(ProducerRecord producerRecord, RecordMetadata recordMetadata) { |
||||||
|
log.info("我已经接收到消息-----message={}", producerRecord.value()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onError(ProducerRecord producerRecord, RecordMetadata recordMetadata, Exception exception) { |
||||||
|
log.error("接收失败--------message={}", producerRecord.value()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,84 @@ |
|||||||
|
package com.ruoyi.job.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.ruoyi.common.core.page.R; |
||||||
|
import com.ruoyi.job.dto.MessageData; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.service.ProducerService; |
||||||
|
import com.ruoyi.zxzb.basic.domain.YcStation; |
||||||
|
import org.springframework.kafka.core.KafkaTemplate; |
||||||
|
import org.springframework.scheduling.annotation.Async; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("/kfk") |
||||||
|
public class ProducerController { |
||||||
|
@Resource |
||||||
|
private KafkaTemplate<String, String> kafkaTemplate; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private ProducerService producerService; |
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/complementMeData") |
||||||
|
public R complementMeData(@RequestParam Map<String,Object> params){ |
||||||
|
String startDate = (String)params.get("startDate"); |
||||||
|
String endDate = (String)params.get("endDate"); |
||||||
|
producerService.complementMeData(startDate,endDate); |
||||||
|
return R.ok(); |
||||||
|
} |
||||||
|
|
||||||
|
// @RequestMapping("/send")
|
||||||
|
// public R sendTest(){
|
||||||
|
// YcStation ys = new YcStation();
|
||||||
|
// ys.setStnm("测试站点");
|
||||||
|
// ys.setStnmId(111L);
|
||||||
|
// kafkaTemplate.send("test", JSON.toJSONString(ys));
|
||||||
|
// return R.ok("发送完成");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @RequestMapping("/sendData")
|
||||||
|
// public R sendData(){
|
||||||
|
// MessageData data = new MessageData();
|
||||||
|
// data.setTableName("yc_pd_rain");
|
||||||
|
// data.setStnmId(1L);
|
||||||
|
// data.setTm("2022-07-25 10:00:00");
|
||||||
|
// data.setValue(new BigDecimal(9.2));
|
||||||
|
// kafkaTemplate.send("ycdata", JSON.toJSONString(data));
|
||||||
|
// return R.ok("发送完成");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @RequestMapping("/pptn")
|
||||||
|
// public R pptn(){
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setStcd("1818");
|
||||||
|
// data.setValue(new BigDecimal(1.3));
|
||||||
|
// data.setTm("2022-07-25 10:10:00");
|
||||||
|
// kafkaTemplate.send("pptn", JSON.toJSONString(data));
|
||||||
|
// return R.ok("发送完成");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @RequestMapping("/pptn2")
|
||||||
|
// public R pptn2(){
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setStcd("15208");
|
||||||
|
// data.setValue(new BigDecimal(5.9));
|
||||||
|
// data.setTm("2022-07-25 10:05:00");
|
||||||
|
// kafkaTemplate.send("pptn", JSON.toJSONString(data));
|
||||||
|
// return R.ok("发送完成");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @RequestMapping("/rsvrtest")
|
||||||
|
// public R rsvrtest(){
|
||||||
|
// kafkaTemplate.send("ywpt_mysql.ywpt.st_rsvr_r", "{\"payload\":{\"op\":\"123\",\"before\":\"bbb\",\"after\":\"aaaaa\"}}");
|
||||||
|
// return R.ok("发送完成");
|
||||||
|
// }
|
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("me_rain") |
||||||
|
public class MeRain implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_pptn_hour") |
||||||
|
public class StPptnHour implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal drp; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_pptn_r") |
||||||
|
public class StPptrR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal drp; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_q_qflow") |
||||||
|
public class StQflowR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal q; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_rh_r") |
||||||
|
public class StRhR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_river_r") |
||||||
|
public class StRiverR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal z; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_rsvr_r") |
||||||
|
public class StRsvrR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal rz; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_temp_r") |
||||||
|
public class StTempR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_tide_r") |
||||||
|
public class StTideR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal tdz; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_wdr_r") |
||||||
|
public class StWdrR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("st_ws_r") |
||||||
|
public class StWsR implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("voltage_s") |
||||||
|
public class VoltageS implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private Date tm; |
||||||
|
|
||||||
|
private BigDecimal voltage; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class MeData { |
||||||
|
private Object source; |
||||||
|
|
||||||
|
private Object before; |
||||||
|
|
||||||
|
private MeDataAfter after; |
||||||
|
|
||||||
|
private String op; |
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class MeDataAfter { |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private Integer sid; |
||||||
|
|
||||||
|
private String item; |
||||||
|
|
||||||
|
private String val; |
||||||
|
|
||||||
|
private String unit; |
||||||
|
|
||||||
|
private String dt; |
||||||
|
|
||||||
|
private String index; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class MeStData implements Serializable |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private Long sid; |
||||||
|
|
||||||
|
private String item; |
||||||
|
|
||||||
|
private String val; |
||||||
|
|
||||||
|
private String unit; |
||||||
|
|
||||||
|
private String dt; |
||||||
|
|
||||||
|
private String index; |
||||||
|
} |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class MessageData implements Serializable |
||||||
|
{ |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
private String tableName; |
||||||
|
|
||||||
|
private Long stnmId; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class OrigionDataDto { |
||||||
|
|
||||||
|
private String dt; |
||||||
|
|
||||||
|
private String item; |
||||||
|
|
||||||
|
private String itemCode; |
||||||
|
|
||||||
|
private String sid; |
||||||
|
|
||||||
|
private String type; |
||||||
|
|
||||||
|
private String unit; |
||||||
|
|
||||||
|
private String updDt; |
||||||
|
|
||||||
|
private String val; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class PushCurrDataDto { |
||||||
|
private String stationCode; |
||||||
|
|
||||||
|
private String stationName; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private List<PushStcdDataDto> data; |
||||||
|
} |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class PushStcdDataDto { |
||||||
|
private String item; |
||||||
|
|
||||||
|
private String value; |
||||||
|
} |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StData implements Serializable |
||||||
|
{ |
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String type; |
||||||
|
|
||||||
|
private String unit; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StPptnHourDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal drp; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StPptrRDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal drp; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StQflowDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal q; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StRhRDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StRiverRDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal z; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StRsvrRDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal rz; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StTempRDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StTideRDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal tdz; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StWdrRDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class StWsRDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal value; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class VoltageSDto |
||||||
|
{ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String stcd; |
||||||
|
|
||||||
|
private String tm; |
||||||
|
|
||||||
|
private BigDecimal voltage; |
||||||
|
|
||||||
|
private String err; |
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.MeRain; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface MeRainMapper extends BaseMapper<MeRain> { |
||||||
|
List<MeRain> selectData(@Param("stcd")String stcd, @Param("startTime")String startTime, @Param("endTime")String endTime); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.dto.MessageData; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface MessageDataMapper extends BaseMapper<MessageData> { |
||||||
|
MessageData selectData(@Param("params")Map<String,Object> params); |
||||||
|
|
||||||
|
void insertData(@Param("data")MessageData data); |
||||||
|
|
||||||
|
void updateData(@Param("data")MessageData data); |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StPptnHour; |
||||||
|
import com.ruoyi.job.dto.StPptnHourDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StPptnHourMapper extends BaseMapper<StPptnHour> { |
||||||
|
void insertData(@Param("data") StPptnHourDto data); |
||||||
|
|
||||||
|
void insertDataIgnore(@Param("data") StPptnHourDto data); |
||||||
|
|
||||||
|
void updateData(@Param("data") StPptnHourDto data); |
||||||
|
|
||||||
|
StPptnHourDto getDataByTmAndStcd(@Param("tm")String tm,@Param("stcd")String stcd); |
||||||
|
|
||||||
|
String getMaxTmData(@Param("stcd")String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StPptrR; |
||||||
|
import com.ruoyi.job.dto.MessageData; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StPptrRMapper extends BaseMapper<StPptrR> { |
||||||
|
void insertData(@Param("data") StPptrRDto data); |
||||||
|
|
||||||
|
void insertDataIgnore(@Param("data") StPptrRDto data); |
||||||
|
|
||||||
|
void updateData(@Param("data") StPptrRDto data); |
||||||
|
|
||||||
|
StPptrRDto getDataByTmAndStcd(@Param("tm")String tm,@Param("stcd")String stcd); |
||||||
|
|
||||||
|
String getMaxTmData(@Param("stcd")String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StQflowR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StQflowDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StQflowMapper extends BaseMapper<StQflowR> { |
||||||
|
void insertData(@Param("data") StQflowDto data); |
||||||
|
|
||||||
|
void insertDataIgnore(@Param("data") StQflowDto data); |
||||||
|
|
||||||
|
void updateData(@Param("data") StQflowDto data); |
||||||
|
|
||||||
|
StQflowDto getDataByTmAndStcd(@Param("tm")String tm, @Param("stcd")String stcd); |
||||||
|
|
||||||
|
String getMaxTmData(@Param("stcd")String stcd); |
||||||
|
|
||||||
|
StData getMinTmData(@Param("tm")String tm,@Param("stcd")String stcd); |
||||||
|
|
||||||
|
StQflowDto getSpeedDataByTmAndStcd(@Param("tm")String tm, @Param("stcd")String stcd); |
||||||
|
|
||||||
|
void insertSpeedData(@Param("data") StQflowDto data); |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StRhR; |
||||||
|
import com.ruoyi.job.domain.StWsR; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
import com.ruoyi.job.dto.StRhRDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StRhRMapper extends BaseMapper<StRhR> { |
||||||
|
void insertData(@Param("data") StRhRDto data); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StPptrR; |
||||||
|
import com.ruoyi.job.domain.StRiverR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
import com.ruoyi.job.dto.StRiverRDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StRiverRMapper extends BaseMapper<StRiverR> { |
||||||
|
void insertData(@Param("data") StRiverRDto data); |
||||||
|
|
||||||
|
void insertDataIgnore(@Param("data") StRiverRDto data); |
||||||
|
|
||||||
|
void updateData(@Param("data") StRiverRDto data); |
||||||
|
|
||||||
|
StRiverRDto getDataByTmAndStcd(@Param("tm")String tm, @Param("stcd")String stcd); |
||||||
|
|
||||||
|
String getMaxTmData(@Param("stcd")String stcd); |
||||||
|
|
||||||
|
StData getMinTmData(@Param("tm")String tm,@Param("stcd")String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StRsvrR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
import com.ruoyi.job.dto.StRsvrRDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StRsvrRMapper extends BaseMapper<StRsvrR> { |
||||||
|
void insertData(@Param("data") StRsvrRDto data); |
||||||
|
|
||||||
|
void insertDataIgnore(@Param("data") StRsvrRDto data); |
||||||
|
|
||||||
|
void updateData(@Param("data") StRsvrRDto data); |
||||||
|
|
||||||
|
StRsvrRDto getDataByTmAndStcd(@Param("tm")String tm, @Param("stcd")String stcd); |
||||||
|
|
||||||
|
String getMaxTmData(@Param("stcd")String stcd); |
||||||
|
|
||||||
|
StData getMinTmData(@Param("tm")String tm,@Param("stcd")String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StTempR; |
||||||
|
import com.ruoyi.job.dto.StRiverRDto; |
||||||
|
import com.ruoyi.job.dto.StTempRDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StTempRMapper extends BaseMapper<StTempR> { |
||||||
|
void insertData(@Param("data") StTempRDto data); |
||||||
|
|
||||||
|
StTempRDto getDataByTmAndStcd(@Param("tm")String tm, @Param("stcd")String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StTideR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
import com.ruoyi.job.dto.StTideRDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StTideRMapper extends BaseMapper<StTideR> { |
||||||
|
void insertData(@Param("data") StTideRDto data); |
||||||
|
|
||||||
|
void insertDataIgnore(@Param("data") StTideRDto data); |
||||||
|
|
||||||
|
void updateData(@Param("data") StTideRDto data); |
||||||
|
|
||||||
|
StTideRDto getDataByTmAndStcd(@Param("tm")String tm, @Param("stcd")String stcd); |
||||||
|
|
||||||
|
String getMaxTmData(@Param("stcd")String stcd); |
||||||
|
|
||||||
|
StData getMinTmData(@Param("tm")String tm,@Param("stcd")String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StWdrR; |
||||||
|
import com.ruoyi.job.dto.StWdrRDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StWdrRMapper extends BaseMapper<StWdrR> { |
||||||
|
void insertData(@Param("data") StWdrRDto data); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.StWsR; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
import com.ruoyi.job.dto.StWsRDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface StWsRMapper extends BaseMapper<StWsR> { |
||||||
|
void insertData(@Param("data") StWsRDto data); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
package com.ruoyi.job.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.ruoyi.job.domain.VoltageS; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
import com.ruoyi.job.dto.StTideRDto; |
||||||
|
import com.ruoyi.job.dto.VoltageSDto; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
/** |
||||||
|
* Mapper接口 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface VoltageSMapper extends BaseMapper<VoltageS> { |
||||||
|
void insertData(@Param("data") VoltageSDto data); |
||||||
|
|
||||||
|
void insertDataIgnore(@Param("data") VoltageSDto data); |
||||||
|
|
||||||
|
void updateData(@Param("data") VoltageSDto data); |
||||||
|
|
||||||
|
VoltageSDto getDataByTmAndStcd(@Param("tm")String tm, @Param("stcd")String stcd); |
||||||
|
|
||||||
|
String getMaxTmData(@Param("stcd")String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,473 @@ |
|||||||
|
//package com.ruoyi.job.program;
|
||||||
|
//
|
||||||
|
//import com.alibaba.fastjson.JSON;
|
||||||
|
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
//import com.ruoyi.common.enums.OrigionDataItemEnum;
|
||||||
|
//import com.ruoyi.common.enums.StationTypeEnum;
|
||||||
|
//import com.ruoyi.common.utils.DateUtils;
|
||||||
|
//import com.ruoyi.job.domain.MeRain;
|
||||||
|
//import com.ruoyi.job.dto.*;
|
||||||
|
//import com.ruoyi.job.service.*;
|
||||||
|
//import com.ruoyi.job.service.impl.StPptnHourServiceImpl;
|
||||||
|
//import com.ruoyi.zxzb.basic.domain.YcStcdInfo;
|
||||||
|
//import com.ruoyi.zxzb.basic.service.IYcStationService;
|
||||||
|
//import com.ruoyi.zxzb.basic.service.IYcStcdInfoService;
|
||||||
|
//import com.ruoyi.zxzb.data.service.IYcStcdCurrValService;
|
||||||
|
//import com.ruoyi.zxzb.report.utils.DateUtil;
|
||||||
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||||
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.kafka.annotation.KafkaListener;
|
||||||
|
//import org.springframework.kafka.support.Acknowledgment;
|
||||||
|
//
|
||||||
|
//import javax.annotation.Resource;
|
||||||
|
//import java.math.BigDecimal;
|
||||||
|
//import java.math.RoundingMode;
|
||||||
|
//import java.util.List;
|
||||||
|
//import java.util.Optional;
|
||||||
|
//import java.util.regex.Pattern;
|
||||||
|
//
|
||||||
|
//@Slf4j
|
||||||
|
//@Configuration
|
||||||
|
//public class ConsumerConfig {
|
||||||
|
// @Resource
|
||||||
|
// private StPptrRService stPptrRService;
|
||||||
|
// @Resource
|
||||||
|
// private StRiverRService stRiverRService;
|
||||||
|
// @Resource
|
||||||
|
// private StRsvrRService stRsvrRService;
|
||||||
|
// @Resource
|
||||||
|
// private StTideRService stTideRService;
|
||||||
|
// @Resource
|
||||||
|
// private VoltageSService voltageSService;
|
||||||
|
// @Resource
|
||||||
|
// private StQflowService stQflowService;
|
||||||
|
// @Resource
|
||||||
|
// private StTempRService stTempRService;
|
||||||
|
// @Resource
|
||||||
|
// private StWsRService stWsRService;
|
||||||
|
// @Resource
|
||||||
|
// private StWdrRService stWdrRService;
|
||||||
|
// @Resource
|
||||||
|
// private StRhRService stRhRService;
|
||||||
|
// @Resource
|
||||||
|
// private StPptnHourService stPptnHourService;
|
||||||
|
// @Resource
|
||||||
|
// private IYcStcdInfoService ycStcdInfoService;
|
||||||
|
// @Resource
|
||||||
|
// private IYcStationService ycStationService;
|
||||||
|
// @Resource
|
||||||
|
// private IYcStcdCurrValService ycStcdCurrValService;
|
||||||
|
// @Resource
|
||||||
|
// private ConsumerService consumerService;
|
||||||
|
// @Resource
|
||||||
|
// private MeRainService meRainService;
|
||||||
|
//
|
||||||
|
// @KafkaListener(topics = {"parse_data"},groupId = "report_parse_data")
|
||||||
|
// public void parse_data(ConsumerRecord<?, ?> consumerRecord, Acknowledgment ack){
|
||||||
|
// Optional<?> optional = Optional.ofNullable(consumerRecord.value());
|
||||||
|
// if (optional.isPresent()) {
|
||||||
|
// String msg = optional.get().toString();
|
||||||
|
// OrigionDataDto data = JSON.parseObject(msg,OrigionDataDto.class);
|
||||||
|
// String itemCode = data.getItemCode();
|
||||||
|
// OrigionDataItemEnum code = OrigionDataItemEnum.fromCode(itemCode);
|
||||||
|
//
|
||||||
|
// if(code == null){
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// switch (code) {
|
||||||
|
// case RAIN:
|
||||||
|
// //累计降雨
|
||||||
|
// deal_rain(data);
|
||||||
|
// break;
|
||||||
|
// case WATER:
|
||||||
|
// //水位
|
||||||
|
// deal_water(data);
|
||||||
|
// break;
|
||||||
|
// case VOL:
|
||||||
|
// //电压
|
||||||
|
// deal_vol(data);
|
||||||
|
// break;
|
||||||
|
// case WIND_SPEED:
|
||||||
|
// //风速
|
||||||
|
// deal_ws(data);
|
||||||
|
// break;
|
||||||
|
// case WIND_TREND:
|
||||||
|
// //风向
|
||||||
|
// deal_wdr(data);
|
||||||
|
// break;
|
||||||
|
// case HUMIDITY:
|
||||||
|
// //湿度
|
||||||
|
// deal_rh(data);
|
||||||
|
// break;
|
||||||
|
// case TEMP:
|
||||||
|
// //瞬时气温
|
||||||
|
// deal_temp(data);
|
||||||
|
// break;
|
||||||
|
// case HOUR_RAIN:
|
||||||
|
// //小时时段雨量
|
||||||
|
// deal_hourRain(data);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ack.acknowledge();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private void deal_rain(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(new BigDecimal(origionData.getVal()));
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(origionData.getSid());
|
||||||
|
//
|
||||||
|
// YcStcdInfo stcd = ycStcdInfoService.selectStcd(data.getStcd(),"A");
|
||||||
|
// if (stcd == null) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// List<MeRain> localMeRains = meRainService.list(
|
||||||
|
// new QueryWrapper<MeRain>().eq("stcd",data.getStcd()).eq("tm",DateUtil.parseDate(data.getTm(),"yyyy-MM-dd HH:mm:ss")));
|
||||||
|
// if(!localMeRains.isEmpty()){
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// //原始数据入库
|
||||||
|
// MeRain meRain = new MeRain();
|
||||||
|
// meRain.setStcd(data.getStcd());
|
||||||
|
// meRain.setValue(data.getValue());
|
||||||
|
// meRain.setTm(DateUtil.parseDate(data.getTm(),"yyyy-MM-dd HH:mm:ss"));
|
||||||
|
// meRainService.save(meRain);
|
||||||
|
//
|
||||||
|
// //查询上一个时刻数据,差值作为当前时刻雨量数据
|
||||||
|
// String beforeTm = DateUtil.formatDate(DateUtils.addMinutes(meRain.getTm(),-5),"yyyy-MM-dd HH:mm:ss");
|
||||||
|
// String afterTm = DateUtil.formatDate(DateUtils.addMinutes(meRain.getTm(),5),"yyyy-MM-dd HH:mm:ss");
|
||||||
|
//
|
||||||
|
//// if(stcd.getProp() == 1){
|
||||||
|
//// beforeTm = DateUtil.formatDate(DateUtils.addHours(meRain.getTm(),-1),"yyyy-MM-dd HH:mm:ss");
|
||||||
|
//// afterTm = DateUtil.formatDate(DateUtils.addHours(meRain.getTm(),1),"yyyy-MM-dd HH:mm:ss");
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// List<MeRain> rainList = meRainService.selectData(data.getStcd(),beforeTm,afterTm);
|
||||||
|
// if(!rainList.isEmpty()){
|
||||||
|
// String firstTm = DateUtil.formatDate(rainList.get(0).getTm(),"yyyy-MM-dd HH:mm:ss");
|
||||||
|
// if(firstTm.equals(beforeTm)){
|
||||||
|
// BigDecimal rainValue = meRain.getValue().subtract(rainList.get(0).getValue());
|
||||||
|
// if(rainValue.abs().intValue()<30) {
|
||||||
|
// StData rainData = new StData();
|
||||||
|
// rainData.setStcd(data.getStcd());
|
||||||
|
// rainData.setTm(data.getTm());
|
||||||
|
// rainData.setValue(rainValue);
|
||||||
|
// st_pptn(rainData, stcd);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// MeRain lastData = rainList.get(rainList.size() - 1);
|
||||||
|
// String lastTm = DateUtil.formatDate(lastData.getTm(),"yyyy-MM-dd HH:mm:ss");
|
||||||
|
// if(lastTm.equals(afterTm)){
|
||||||
|
// BigDecimal rainValue = lastData.getValue().subtract(meRain.getValue());
|
||||||
|
// if(rainValue.abs().intValue()<30){
|
||||||
|
// StData rainData = new StData();
|
||||||
|
// rainData.setStcd(data.getStcd());
|
||||||
|
// rainData.setTm(afterTm);
|
||||||
|
// rainData.setValue(rainValue);
|
||||||
|
// st_pptn(rainData,stcd);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void deal_water(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// String stcd = String.valueOf(origionData.getSid());
|
||||||
|
// YcStcdInfo stcdInfo = ycStcdInfoService.selectWaterStcd(stcd);
|
||||||
|
// if(stcdInfo != null){
|
||||||
|
// BigDecimal value = new BigDecimal(origionData.getVal());
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(value);
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(stcd);
|
||||||
|
// if(StationTypeEnum.RIVER.getCode().equals(stcdInfo.getParentStnmType())){
|
||||||
|
// //河道
|
||||||
|
// st_river(data,stcdInfo);
|
||||||
|
// }else if(StationTypeEnum.RSVR.getCode().equals(stcdInfo.getParentStnmType())){
|
||||||
|
// //水库
|
||||||
|
// st_rsvr(data,stcdInfo);
|
||||||
|
// }else if(StationTypeEnum.TIDE.getCode().equals(stcdInfo.getParentStnmType())){
|
||||||
|
// //潮位
|
||||||
|
// st_tide(data,stcdInfo);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //电压
|
||||||
|
// private void deal_vol(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// String type = "V";
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(new BigDecimal(origionData.getVal()));
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(String.valueOf(origionData.getSid()));
|
||||||
|
// List<YcStcdInfo> stcd = ycStcdInfoService.list(new QueryWrapper<YcStcdInfo>().eq("stcd",data.getStcd()));
|
||||||
|
// if (!stcd.isEmpty()) {
|
||||||
|
// BigDecimal before5MinData = consumerService.get5beforeData(data,type);
|
||||||
|
// //和上一个时刻数据对比,超过50%,判断异常,取上一个时刻数据填入
|
||||||
|
//
|
||||||
|
// if(before5MinData != null){
|
||||||
|
// BigDecimal subData = data.getValue().subtract(before5MinData);
|
||||||
|
// BigDecimal per = subData.multiply(new BigDecimal(100)).divide(before5MinData, 2, RoundingMode.HALF_UP).abs();
|
||||||
|
// if(per.compareTo(new BigDecimal(50)) > -1){
|
||||||
|
// data.setValue(before5MinData);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// st_vol(data);
|
||||||
|
// for (YcStcdInfo ycStcdInfo : stcd) {
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(ycStcdInfo, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void deal_qflow(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(new BigDecimal(origionData.getVal()));
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(String.valueOf(origionData.getSid()));
|
||||||
|
// YcStcdInfo stcd = ycStcdInfoService.selectStcd(data.getStcd(),"E");
|
||||||
|
// if (stcd != null) {
|
||||||
|
// qflow(data,stcd);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //没有
|
||||||
|
// private void deal_hourRain(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// String type = "Y";
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(new BigDecimal(origionData.getVal()));
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(String.valueOf(origionData.getSid()));
|
||||||
|
// YcStcdInfo stcd = ycStcdInfoService.selectStcd(data.getStcd(),type);
|
||||||
|
// if (stcd != null) {
|
||||||
|
// StPptnHourDto pp = new StPptnHourDto();
|
||||||
|
// pp.setDrp(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
// stPptnHourService.saveData(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //风速
|
||||||
|
// private void deal_ws(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// String type = "S";
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(new BigDecimal(origionData.getVal()));
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(String.valueOf(origionData.getSid()));
|
||||||
|
// YcStcdInfo stcd = ycStcdInfoService.selectStcd(data.getStcd(),type);
|
||||||
|
// if (stcd != null) {
|
||||||
|
// BigDecimal before5MinData = consumerService.get5beforeData(data,type);
|
||||||
|
// //者和上一个时刻数据差值大于50 ,判断异常,取上一个时刻数据填入
|
||||||
|
// if(before5MinData != null){
|
||||||
|
// BigDecimal subData = data.getValue().subtract(before5MinData);
|
||||||
|
// //者和上一个时刻数据差值大于50 ,判断异常,取上一个时刻数据填入
|
||||||
|
// if(subData.abs().compareTo(new BigDecimal(50)) > -1){
|
||||||
|
// data.setValue(before5MinData);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// StWsRDto pp = new StWsRDto();
|
||||||
|
// pp.setValue(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
// stWsRService.saveData(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 风向
|
||||||
|
// private void deal_wdr(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// String type = "U";
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(new BigDecimal(origionData.getVal()));
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(String.valueOf(origionData.getSid()));
|
||||||
|
// YcStcdInfo stcd = ycStcdInfoService.selectStcd(data.getStcd(),type);
|
||||||
|
// if (stcd != null) {
|
||||||
|
// StWdrRDto pp = new StWdrRDto();
|
||||||
|
// pp.setValue(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
// stWdrRService.saveData(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 湿度
|
||||||
|
// private void deal_rh(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// String type = "R";
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(new BigDecimal(origionData.getVal()));
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(String.valueOf(origionData.getSid()));
|
||||||
|
// YcStcdInfo stcd = ycStcdInfoService.selectStcd(data.getStcd(),type);
|
||||||
|
// if (stcd != null) {
|
||||||
|
// BigDecimal before5MinData = consumerService.get5beforeData(data,type);
|
||||||
|
// //和上一个时刻数据对比,超过50%,或者和上一个时刻数据差值大于100 ,判断异常,取上一个时刻数据填入
|
||||||
|
// if(before5MinData != null){
|
||||||
|
// BigDecimal subData = data.getValue().subtract(before5MinData);
|
||||||
|
// BigDecimal per = subData.multiply(new BigDecimal(100)).divide(before5MinData, 2, RoundingMode.HALF_UP).abs();
|
||||||
|
// //和上一个时刻数据对比,超过50%,或者和上一个时刻数据差值大于100 ,判断异常,取上一个时刻数据填入
|
||||||
|
// if(per.compareTo(new BigDecimal(50)) > -1 || subData.abs().compareTo(new BigDecimal(100)) > -1){
|
||||||
|
// data.setValue(before5MinData);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// StRhRDto pp = new StRhRDto();
|
||||||
|
// pp.setValue(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
// stRhRService.saveData(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 湿度 大于100
|
||||||
|
// private void deal_temp(OrigionDataDto origionData){
|
||||||
|
// if(origionData != null && origionData.getSid() != null && origionData.getDt() != null){
|
||||||
|
// String type = "T";
|
||||||
|
// StData data = new StData();
|
||||||
|
// data.setValue(new BigDecimal(origionData.getVal()));
|
||||||
|
// data.setTm(origionData.getDt());
|
||||||
|
// data.setStcd(String.valueOf(origionData.getSid()));
|
||||||
|
// YcStcdInfo stcd = ycStcdInfoService.selectStcd(data.getStcd(),type);
|
||||||
|
// if (stcd != null) {
|
||||||
|
// BigDecimal before5MinData = consumerService.get5beforeData(data,type);
|
||||||
|
// //和上一个时刻数据对比,超过50%,或者和上一个时刻数据差值大于100 ,判断异常,取上一个时刻数据填入
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if(before5MinData != null){
|
||||||
|
// BigDecimal subData = data.getValue().subtract(before5MinData);
|
||||||
|
// BigDecimal per = subData.multiply(new BigDecimal(100)).divide(before5MinData, 2, RoundingMode.HALF_UP).abs();
|
||||||
|
// //和上一个时刻数据对比,超过50%,或者和上一个时刻数据差值大于100 ,判断异常,取上一个时刻数据填入
|
||||||
|
//// if(per.compareTo(new BigDecimal(50)) > -1) {
|
||||||
|
//// data.setValue(before5MinData);
|
||||||
|
//// }
|
||||||
|
// if(per.compareTo(new BigDecimal(50)) > -1 || subData.abs().compareTo(new BigDecimal(100)) > -1) {
|
||||||
|
// data.setValue(before5MinData);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// StTempRDto pp = new StTempRDto();
|
||||||
|
// pp.setValue(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
// stTempRService.saveData(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void st_pptn(StData data,YcStcdInfo stcd){
|
||||||
|
// String type = "A";
|
||||||
|
// StPptrRDto pp = new StPptrRDto();
|
||||||
|
// pp.setDrp(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
// String errId = consumerService.DataErrorDeal(stcd, data, type, "毫米");
|
||||||
|
//// pp.setErr(errId);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// stPptrRService.saveOrUpdate(pp);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private void st_river(StData data,YcStcdInfo stcd){
|
||||||
|
// String type = "B";
|
||||||
|
// StRiverRDto pp = new StRiverRDto();
|
||||||
|
// pp.setZ(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
// String errId = consumerService.DataErrorDeal(stcd, data, type, "米");
|
||||||
|
//// pp.setErr(errId);
|
||||||
|
// stRiverRService.saveOrUpdate(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private void st_rsvr(StData data,YcStcdInfo stcd){
|
||||||
|
// String type = "C";
|
||||||
|
// StRsvrRDto pp = new StRsvrRDto();
|
||||||
|
// pp.setRz(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
//
|
||||||
|
// String errId = consumerService.DataErrorDeal(stcd, data, type, "米");
|
||||||
|
//// pp.setErr(errId);
|
||||||
|
// stRsvrRService.saveOrUpdate(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void st_tide(StData data,YcStcdInfo stcd){
|
||||||
|
// String type = "D";
|
||||||
|
// StTideRDto pp = new StTideRDto();
|
||||||
|
// pp.setTdz(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
// String errId = consumerService.DataErrorDeal(stcd, data, type, "米");
|
||||||
|
//// pp.setErr(errId);
|
||||||
|
// stTideRService.saveOrUpdate(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private void qflow(StData data,YcStcdInfo stcd){
|
||||||
|
// //log.error("||||EEEEEEEEEE||||");
|
||||||
|
// String type = "E";
|
||||||
|
// StQflowDto pp = new StQflowDto();
|
||||||
|
// pp.setQ(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
//// String errId = consumerService.DataErrorDeal(stcd, data, type, "毫米");
|
||||||
|
//// pp.setErr(errId);
|
||||||
|
// stQflowService.saveOrUpdate(pp);
|
||||||
|
// ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private void st_vol(StData data){
|
||||||
|
// //log.error("||||VVVVVVVV||||");
|
||||||
|
// String type = "V";
|
||||||
|
// VoltageSDto pp = new VoltageSDto();
|
||||||
|
// pp.setVoltage(data.getValue());
|
||||||
|
// pp.setTm(data.getTm());
|
||||||
|
// pp.setStcd(data.getStcd());
|
||||||
|
//// String errId = consumerService.volErrorDeal(data, type, "V");
|
||||||
|
// String errId = "0";
|
||||||
|
// pp.setErr(errId);
|
||||||
|
// voltageSService.saveOrUpdate(pp);
|
||||||
|
// //log.error("||||VVVVVVVV结束||||");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
//// Date dd = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,"2022-12-08 18:10:20");
|
||||||
|
//// System.out.println((new Date().getTime() - dd.getTime()) / 1000);
|
||||||
|
//
|
||||||
|
// String a = "2022-12-08 18:14:20".substring(15,16);
|
||||||
|
// System.out.println(a);
|
||||||
|
// System.out.println(Pattern.matches("^-?\\d+(\\.\\d+)?$",""));
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
@ -0,0 +1,139 @@ |
|||||||
|
package com.ruoyi.job.program; |
||||||
|
|
||||||
|
|
||||||
|
import com.google.gson.*; |
||||||
|
import com.google.gson.reflect.TypeToken; |
||||||
|
|
||||||
|
import java.time.LocalDate; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
import java.time.ZoneId; |
||||||
|
import java.time.format.DateTimeFormatter; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
/** |
||||||
|
* gson工具类 |
||||||
|
* |
||||||
|
* @author baiyan |
||||||
|
* @date 2022/01/19 |
||||||
|
*/ |
||||||
|
public class GsonUtil { |
||||||
|
|
||||||
|
private static Gson gson = null; |
||||||
|
|
||||||
|
static { |
||||||
|
if (Objects.isNull(gson)) { |
||||||
|
gson = new GsonBuilder() |
||||||
|
.registerTypeAdapter(LocalDateTime.class, (JsonDeserializer<LocalDateTime>) (json, type, jsonDeserializationContext) -> { |
||||||
|
String datetime = json.getAsJsonPrimitive().getAsString(); |
||||||
|
return LocalDateTime.parse(datetime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||||
|
}) |
||||||
|
.registerTypeAdapter(LocalDate.class, (JsonDeserializer<LocalDate>) (json, type, jsonDeserializationContext) -> { |
||||||
|
String datetime = json.getAsJsonPrimitive().getAsString(); |
||||||
|
return LocalDate.parse(datetime, DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
||||||
|
}) |
||||||
|
.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, type, jsonDeserializationContext) -> { |
||||||
|
String datetime = json.getAsJsonPrimitive().getAsString(); |
||||||
|
LocalDateTime localDateTime = LocalDateTime.parse(datetime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||||
|
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); |
||||||
|
}) |
||||||
|
.registerTypeAdapter(LocalDateTime.class, (JsonSerializer<LocalDateTime>) (src, typeOfSrc, context) -> new JsonPrimitive(src.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))) |
||||||
|
.registerTypeAdapter(LocalDate.class, (JsonSerializer<LocalDate>) (src, typeOfSrc, context) -> new JsonPrimitive(src.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))) |
||||||
|
.registerTypeAdapter(Date.class, (JsonSerializer<Date>) (src, typeOfSrc, context) -> { |
||||||
|
LocalDateTime localDateTime = LocalDateTime.ofInstant(src.toInstant(), ZoneId.systemDefault()); |
||||||
|
return new JsonPrimitive(localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
||||||
|
}) |
||||||
|
.create(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public GsonUtil() { |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 将object对象转成json字符串 |
||||||
|
* |
||||||
|
* @param object |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static String gsonToString(Object object) { |
||||||
|
String gsonString = null; |
||||||
|
if (gson != null) { |
||||||
|
gsonString = gson.toJson(object); |
||||||
|
} |
||||||
|
return gsonString; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 将gsonString转成泛型bean |
||||||
|
* |
||||||
|
* @param gsonString |
||||||
|
* @param cls |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static <T> T gsonToBean(String gsonString, Class<T> cls) { |
||||||
|
T t = null; |
||||||
|
if (gson != null) { |
||||||
|
t = gson.fromJson(gsonString, cls); |
||||||
|
} |
||||||
|
return t; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 转成list |
||||||
|
* 泛型在编译期类型被擦除导致报错 |
||||||
|
* @param gsonString |
||||||
|
* @param cls |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static <T> List<T> gsonToList(String gsonString, Class<T> cls) { |
||||||
|
List<T> list = null; |
||||||
|
if (gson != null) { |
||||||
|
list = gson.fromJson(gsonString, TypeToken.getParameterized(List.class,cls).getType()); |
||||||
|
} |
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 转成list中有map的 |
||||||
|
* |
||||||
|
* @param gsonString |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static <T> List<Map<String, T>> gsonToListMaps(String gsonString) { |
||||||
|
List<Map<String, T>> list = null; |
||||||
|
if (gson != null) { |
||||||
|
list = gson.fromJson(gsonString, |
||||||
|
new TypeToken<List<Map<String, T>>>() { |
||||||
|
}.getType()); |
||||||
|
} |
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 转成map的 |
||||||
|
* |
||||||
|
* @param gsonString |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static <T> Map<String, T> gsonToMaps(String gsonString) { |
||||||
|
Map<String, T> map = null; |
||||||
|
if (gson != null) { |
||||||
|
map = gson.fromJson(gsonString, new TypeToken<Map<String, T>>() { |
||||||
|
}.getType()); |
||||||
|
} |
||||||
|
return map; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 把一个bean(或者其他的字符串什么的)转成json |
||||||
|
* @param object |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static String beanToJson(Object object){ |
||||||
|
return gson.toJson(object); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,84 @@ |
|||||||
|
//package com.ruoyi.job.program;
|
||||||
|
//import lombok.Data;
|
||||||
|
//import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||||
|
//import org.apache.kafka.clients.producer.ProducerConfig;
|
||||||
|
//import org.apache.kafka.common.serialization.StringDeserializer;
|
||||||
|
//import org.apache.kafka.common.serialization.StringSerializer;
|
||||||
|
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
//import org.springframework.context.annotation.Bean;
|
||||||
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.kafka.annotation.EnableKafka;
|
||||||
|
//import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
||||||
|
//import org.springframework.kafka.core.*;
|
||||||
|
//import org.springframework.kafka.listener.ContainerProperties;
|
||||||
|
//
|
||||||
|
//import java.util.HashMap;
|
||||||
|
//import java.util.Map;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//@Configuration
|
||||||
|
//@EnableKafka
|
||||||
|
//@ConfigurationProperties(prefix = "spring.kafka")
|
||||||
|
//@Data
|
||||||
|
//public class KafkaConfig {
|
||||||
|
// /**
|
||||||
|
// * kafka地址
|
||||||
|
// */
|
||||||
|
// private String bootstrapServers;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 单次最大拉取记录数
|
||||||
|
// */
|
||||||
|
// private Integer maxPollRecords = 20;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 消费者groupId
|
||||||
|
// */
|
||||||
|
// private String groupId = "test";
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
|
// ConcurrentKafkaListenerContainerFactory<Integer, String> baiyanCommonListenerContainerFactory() {
|
||||||
|
// ConcurrentKafkaListenerContainerFactory<Integer, String> factory = new ConcurrentKafkaListenerContainerFactory<>();
|
||||||
|
// factory.setConsumerFactory(consumerFactory());
|
||||||
|
// factory.setBatchListener(true);
|
||||||
|
// factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL);
|
||||||
|
// return factory;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
|
// public ConsumerFactory<Integer, String> consumerFactory() {
|
||||||
|
// return new DefaultKafkaConsumerFactory<>(consumerConfigs());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
|
// public Map<String, Object> consumerConfigs() {
|
||||||
|
// Map<String, Object> props = new HashMap<>(8);
|
||||||
|
// props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
|
||||||
|
// props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
|
||||||
|
// props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
|
||||||
|
//// props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
|
||||||
|
// props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, maxPollRecords);
|
||||||
|
// props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
|
||||||
|
// props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
|
||||||
|
// return props;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
|
// public Map<String, Object> producerConfigs() {
|
||||||
|
// Map<String, Object> props = new HashMap<>(8);
|
||||||
|
// props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
|
||||||
|
// props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
|
||||||
|
// props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
|
||||||
|
// return props;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
|
// public KafkaTemplate<String, String> kafkaTemplate() {
|
||||||
|
// return new KafkaTemplate<>(producerFactory());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
|
// public ProducerFactory<String, String> producerFactory() {
|
||||||
|
// return new DefaultKafkaProducerFactory<>(producerConfigs());
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,137 @@ |
|||||||
|
//package com.ruoyi.job.program;
|
||||||
|
//
|
||||||
|
//import com.ruoyi.job.dto.StData;
|
||||||
|
//import lombok.Data;
|
||||||
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//
|
||||||
|
//import javax.annotation.Resource;
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
|
//import java.util.Objects;
|
||||||
|
//import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
//import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
//import java.util.function.Consumer;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * kafka顺序消费工具类线程池1.0
|
||||||
|
// *
|
||||||
|
// * 平滑扩容缩容待设计,stopped的钩子可以支持
|
||||||
|
// *
|
||||||
|
// * @author baiyan
|
||||||
|
// * @date 2022/01/19
|
||||||
|
// */
|
||||||
|
//@Slf4j
|
||||||
|
//@Data
|
||||||
|
//public class KafkaConsumerPool<E> {
|
||||||
|
// /**
|
||||||
|
// * 线程并发级别
|
||||||
|
// */
|
||||||
|
// private Integer concurrentSize;
|
||||||
|
// /**
|
||||||
|
// * 工作线程线程
|
||||||
|
// */
|
||||||
|
// private List<Thread> workThreads;
|
||||||
|
// /**
|
||||||
|
// * 任务处理队列
|
||||||
|
// */
|
||||||
|
// private List<ConcurrentLinkedQueue<E>> queues;
|
||||||
|
// /**
|
||||||
|
// * 是否全量停止任务,留个钩子,以便后续动态扩容
|
||||||
|
// */
|
||||||
|
// private volatile boolean stopped;
|
||||||
|
// /**
|
||||||
|
// * 待提交的记录数
|
||||||
|
// */
|
||||||
|
// private AtomicLong pendingOffsets;
|
||||||
|
// /**
|
||||||
|
// * kafka线程名前缀
|
||||||
|
// */
|
||||||
|
// private final static String KAFKA_CONSUMER_WORK_THREAD_PREFIX = "kafka-sort-consumer-thread-";
|
||||||
|
// /**
|
||||||
|
// * 顺序消费任务池初始化
|
||||||
|
// *
|
||||||
|
// * @param config 业务配置
|
||||||
|
// */
|
||||||
|
// public KafkaConsumerPool(KafkaSortConsumerConfig<E> config){
|
||||||
|
// this.concurrentSize = config.getConcurrentSize();
|
||||||
|
// //初始化任务队列
|
||||||
|
// this.initQueue();
|
||||||
|
// this.workThreads = new ArrayList<>();
|
||||||
|
// this.stopped = false;
|
||||||
|
// this.pendingOffsets = new AtomicLong(0L);
|
||||||
|
// //初始化线程
|
||||||
|
// this.initWorkThread(config.getBizName(),config.getBizService());
|
||||||
|
// }
|
||||||
|
// /**
|
||||||
|
// * 初始化队列
|
||||||
|
// */
|
||||||
|
// private void initQueue(){
|
||||||
|
// this.queues = new ArrayList<>();
|
||||||
|
// for (int i = 0; i < this.concurrentSize; i++) {
|
||||||
|
// this.queues.add(new ConcurrentLinkedQueue<>());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 初始化工作线程
|
||||||
|
// */
|
||||||
|
// private void initWorkThread(String bizName, Consumer<E> bizService){
|
||||||
|
// //创建规定的线程
|
||||||
|
// for (int i = 0; i < this.concurrentSize; i++) {
|
||||||
|
// String threadName = KAFKA_CONSUMER_WORK_THREAD_PREFIX + bizName + i;
|
||||||
|
// int num = i;
|
||||||
|
// Thread workThread = new Thread(()->{
|
||||||
|
// //如果队列不为空 或者 线程标识为false则进入循环
|
||||||
|
// while (!queues.get(num).isEmpty() || !stopped){
|
||||||
|
// try{
|
||||||
|
// E task = pollTask(threadName,bizName);
|
||||||
|
// if(Objects.nonNull(task)){
|
||||||
|
// //业务处理逻辑
|
||||||
|
// StData stData = (StData) task;
|
||||||
|
// System.out.println(stData);
|
||||||
|
// if("A".equals(stData.getType())){
|
||||||
|
// log.error("AAAAAAAA");
|
||||||
|
// bizService.accept(task);
|
||||||
|
// }else{
|
||||||
|
// log.error("**********");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// log.info("线程:{},执行任务:{},成功",threadName, GsonUtil.beanToJson(task));
|
||||||
|
// //执行完成的任务加1
|
||||||
|
// pendingOffsets.incrementAndGet();
|
||||||
|
// }
|
||||||
|
// }catch (Exception e){
|
||||||
|
// log.error("线程:{},执行任务:{},失败",threadName,e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// log.info("线程:{}退出",threadName);
|
||||||
|
// },threadName);
|
||||||
|
// //加入线程管理
|
||||||
|
// workThreads.add(workThread);
|
||||||
|
// //开启线程
|
||||||
|
// workThread.start();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// /**
|
||||||
|
// * 根据id取模,将需要保证顺序的任务添加至同一队列
|
||||||
|
// *
|
||||||
|
// * @param id 能够取模的键
|
||||||
|
// * @param task 需要提交处理的任务
|
||||||
|
// */
|
||||||
|
// public void submitTask(Long id, E task){
|
||||||
|
// ConcurrentLinkedQueue<E> taskQueue = queues.get((int) (id % this.concurrentSize));
|
||||||
|
// taskQueue.offer(task);
|
||||||
|
// }
|
||||||
|
// /**
|
||||||
|
// * 根据线程名获取对应的待执行的任务
|
||||||
|
// *
|
||||||
|
// * @param threadName 线程名称
|
||||||
|
// * @return 队列内的任务
|
||||||
|
// */
|
||||||
|
// private E pollTask(String threadName,String bizName){
|
||||||
|
// int threadNum = Integer.valueOf(threadName.replace(KAFKA_CONSUMER_WORK_THREAD_PREFIX+bizName, ""));
|
||||||
|
// ConcurrentLinkedQueue<E> taskQueue = queues.get(threadNum);
|
||||||
|
// return taskQueue.poll();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,32 @@ |
|||||||
|
package com.ruoyi.job.program; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.function.Consumer; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* kafka顺序消费线程池配置参数 |
||||||
|
* |
||||||
|
* @author baiyan |
||||||
|
* @date 2022-01-19 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class KafkaSortConsumerConfig<E> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 业务名称 |
||||||
|
*/ |
||||||
|
String bizName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 并发级别,多少的队列与线程处理任务 |
||||||
|
*/ |
||||||
|
Integer concurrentSize; |
||||||
|
|
||||||
|
/** |
||||||
|
* 业务处理服务 |
||||||
|
*/ |
||||||
|
Consumer<E> bizService; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,4 @@ |
|||||||
|
package com.ruoyi.job.program; |
||||||
|
|
||||||
|
public class KfkTest { |
||||||
|
} |
||||||
@ -0,0 +1,104 @@ |
|||||||
|
//package com.ruoyi.job.program;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//import com.alibaba.fastjson.JSON;
|
||||||
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
|
//import com.ruoyi.job.dto.StData;
|
||||||
|
//import com.ruoyi.job.service.ConsumerService;
|
||||||
|
//import lombok.Data;
|
||||||
|
//import lombok.EqualsAndHashCode;
|
||||||
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.kafka.annotation.KafkaListener;
|
||||||
|
//import org.springframework.kafka.listener.AbstractConsumerSeekAware;
|
||||||
|
//import org.springframework.kafka.support.Acknowledgment;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
|
//import javax.annotation.PostConstruct;
|
||||||
|
//import javax.annotation.Resource;
|
||||||
|
//import java.math.BigDecimal;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * 订单消费者
|
||||||
|
// *
|
||||||
|
// * @author baiyan
|
||||||
|
// * @date 2022/01/19
|
||||||
|
// */
|
||||||
|
//@Configuration
|
||||||
|
//@Slf4j
|
||||||
|
//@Data
|
||||||
|
////@EqualsAndHashCode(callSuper = false)
|
||||||
|
//public class OrderKafkaListener extends AbstractConsumerSeekAware {
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 顺序消费并发级别
|
||||||
|
// */
|
||||||
|
// private final Integer concurrent = 10;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * order业务顺序消费池
|
||||||
|
// */
|
||||||
|
// private KafkaConsumerPool<StData> kafkaConsumerPool;
|
||||||
|
//
|
||||||
|
// @Resource
|
||||||
|
// private ConsumerService consumerService;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 初始化顺序消费池
|
||||||
|
// */
|
||||||
|
// @PostConstruct
|
||||||
|
// public void init(){
|
||||||
|
// KafkaSortConsumerConfig<StData> config = new KafkaSortConsumerConfig<>();
|
||||||
|
// config.setBizName("data");
|
||||||
|
// config.setBizService(consumerService::pptnOpen);
|
||||||
|
// config.setConcurrentSize(concurrent);
|
||||||
|
// kafkaConsumerPool = new KafkaConsumerPool<>(config);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// @KafkaListener(topics = {"swzh_mysql.swzh.st_pptn_r_origin"},groupId = "test666",containerFactory = "baiyanCommonListenerContainerFactory")
|
||||||
|
// public void consumerMsg(List<ConsumerRecord<?, ?>> records, Acknowledgment ack){
|
||||||
|
// if(records.isEmpty()){
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// records.forEach(consumerRecord->{
|
||||||
|
// StData data = new StData();
|
||||||
|
// String msg = consumerRecord.value().toString();
|
||||||
|
// JSONObject jb = JSON.parseObject(msg).getJSONObject("payload");
|
||||||
|
// if(!"d".equals(jb.getString("op"))) {
|
||||||
|
// log.error("11111111111111111111111");
|
||||||
|
// log.error(jb.toString());
|
||||||
|
// JSONObject obj = jb.getJSONObject("after");
|
||||||
|
// data.setValue(obj.getObject("drp", BigDecimal.class));
|
||||||
|
// data.setTm(obj.getString("tm"));
|
||||||
|
// data.setStcd(obj.getString("stcd"));
|
||||||
|
// data.setType("A");
|
||||||
|
// data.setUnit("毫米");
|
||||||
|
// kafkaConsumerPool.submitTask(Long.valueOf(data.getStcd()),data);
|
||||||
|
// }else{
|
||||||
|
// data.setStcd("0");
|
||||||
|
// kafkaConsumerPool.submitTask(Long.valueOf(data.getStcd()),data);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// StData order = GsonUtil.gsonToBean(consumerRecord.value().toString(), StData.class);
|
||||||
|
//// kafkaConsumerPool.submitTask(order.getId(),order);
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// // 当线程池中任务处理完成的计数达到拉取到的记录数时提交
|
||||||
|
// // 注意这里如果存在部分业务阻塞时间很长,会导致位移提交不上去,务必做好一些熔断措施
|
||||||
|
// while (true){
|
||||||
|
// if(records.size() == kafkaConsumerPool.getPendingOffsets().get()){
|
||||||
|
// ack.acknowledge();
|
||||||
|
// log.info("offset提交:{}",records.get(records.size()-1).offset());
|
||||||
|
// kafkaConsumerPool.getPendingOffsets().set(0L);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@ -0,0 +1,151 @@ |
|||||||
|
//package com.ruoyi.job.scheduled;
|
||||||
|
//
|
||||||
|
//import com.ruoyi.common.core.redis.RedisCache;
|
||||||
|
//import com.ruoyi.zxzb.basic.service.IYcFlowFormulaService;
|
||||||
|
//import com.ruoyi.zxzb.basic.service.IYcThresholdService;
|
||||||
|
//import com.ruoyi.zxzb.data.service.IYcRainLevelInfoService;
|
||||||
|
//import com.ruoyi.zxzb.data.service.IYcStcdCurrValService;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.core.env.Environment;
|
||||||
|
//import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
//import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
|
//import javax.annotation.PostConstruct;
|
||||||
|
//
|
||||||
|
//@Component
|
||||||
|
//@Configuration
|
||||||
|
//@EnableScheduling
|
||||||
|
//public class GxDataUploadAlarmTask {
|
||||||
|
//
|
||||||
|
// private static String errAlarm = "";
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private Environment env;
|
||||||
|
//
|
||||||
|
// @PostConstruct
|
||||||
|
// public void config() {
|
||||||
|
// errAlarm = env.getProperty("gxErrAlarm");
|
||||||
|
// }
|
||||||
|
// @Autowired
|
||||||
|
// private IYcStcdCurrValService ycStcdCurrValService;
|
||||||
|
// @Autowired
|
||||||
|
// private IYcThresholdService ycThresholdService;
|
||||||
|
// @Autowired
|
||||||
|
// private IYcFlowFormulaService ycFlowFormulaService;
|
||||||
|
// @Autowired
|
||||||
|
// private IYcRainLevelInfoService ycRainLevelInfoService;
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private RedisCache redisCache;
|
||||||
|
//
|
||||||
|
// @Scheduled(cron = "0 0/2 * * * ?")
|
||||||
|
// public void rtspScreenshot(){
|
||||||
|
// if("1".equals(errAlarm)){
|
||||||
|
// ycStcdCurrValService.dataUploadAlarm("A");
|
||||||
|
//// ycStcdCurrValService.dataUploadAlarm("B");
|
||||||
|
//// ycStcdCurrValService.dataUploadAlarm("C");
|
||||||
|
//// ycStcdCurrValService.dataUploadAlarm("D");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// List<YcSmsInfo> alarmList = ycStcdCurrValService.alarmErr1Sms(1L,null);
|
||||||
|
//// if(alarmList.isEmpty()){
|
||||||
|
//// return;
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// List<String> mobiles = new ArrayList<>();
|
||||||
|
//// for (YcSmsInfo d : alarmList) {
|
||||||
|
//// String[] phones = d.getPhones().split(",");
|
||||||
|
//// for (String phone : phones) {
|
||||||
|
//// if(!mobiles.contains(phone)){
|
||||||
|
//// mobiles.add(phone);
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// for (String mobile : mobiles) {
|
||||||
|
//// List<YcSmsInfo> smsInfos = alarmList.stream().filter(d -> d.getPhones().contains(mobile)).collect(Collectors.toList());
|
||||||
|
//// List<String> stnms = smsInfos.stream().map(YcSmsInfo::getStnm).distinct().collect(Collectors.toList());
|
||||||
|
//// String smsContent = "包含"+StringUtils.join(stnms,"、");
|
||||||
|
//// if(smsContent.length() >19){
|
||||||
|
//// smsContent = smsContent.substring(0,16)+"等";
|
||||||
|
//// }
|
||||||
|
//// String title = "自动测报系统";
|
||||||
|
//// String alarmTitle = "数据上传";
|
||||||
|
//String params = "[\""+alarmTitle+"\",\""+smsContent+"\"]";
|
||||||
|
//// try {
|
||||||
|
//// YySMSUtils.sendTemplatMsg("bee3733c90c8467c89894e958b5b2cc4",mobile,params);
|
||||||
|
//// } catch (IOException e) {
|
||||||
|
//// e.printStackTrace();
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// ycStcdCurrValService.alarmSms(1L,null);
|
||||||
|
//// ycStcdCurrValService.alarmSms(2L,null);
|
||||||
|
//// ycStcdCurrValService.alarmSms(3L,null);
|
||||||
|
//// ycStcdCurrValService.alarmErr4Sms(4L,null);
|
||||||
|
//// ycStcdCurrValService.alarmSms(5L,null);
|
||||||
|
//
|
||||||
|
// //水位超限预警
|
||||||
|
//// ycStcdCurrValService.alarmWaterErr4(4L,null);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 降雨预警等级机制
|
||||||
|
// */
|
||||||
|
// @Scheduled(cron = "0 0/2 * * * ?")
|
||||||
|
// public void rainLevelAlarmTask(){
|
||||||
|
// if("1".equals(errAlarm)) {
|
||||||
|
// ycStcdCurrValService.gxRainLevelAlarm2();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 降雨提醒
|
||||||
|
// */
|
||||||
|
// @Scheduled(cron = "0 0/2 * * * ?")
|
||||||
|
// public void rainReportTask(){
|
||||||
|
// if("1".equals(errAlarm)) {
|
||||||
|
// ycStcdCurrValService.rainReport();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// /**
|
||||||
|
//// * 每天早上8点发送预警汇总短信
|
||||||
|
//// */
|
||||||
|
//// @Scheduled(cron = "0 0 8 * * ?")
|
||||||
|
//// public void smsReSend(){
|
||||||
|
//// if("1".equals(errAlarm)) {
|
||||||
|
//// ycStcdCurrValService.dailyReport();
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 每天定时刷新缓存
|
||||||
|
// */
|
||||||
|
// @Scheduled(cron = "0 0 23 * * ?")
|
||||||
|
// public void reloadRedis(){
|
||||||
|
// if("1".equals(errAlarm)) {
|
||||||
|
// ycThresholdService.dataToRedis();
|
||||||
|
// ycRainLevelInfoService.setYcRainLevelInfoTORedis();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 启动刷新缓存
|
||||||
|
// */
|
||||||
|
// @PostConstruct
|
||||||
|
// public void dataToRedis(){
|
||||||
|
// System.out.println("============data to redis=============");
|
||||||
|
// ycThresholdService.dataToRedis();
|
||||||
|
// ycRainLevelInfoService.setYcRainLevelInfoTORedis();
|
||||||
|
//// ycStcdCurrValService.dailyReport();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,154 @@ |
|||||||
|
//package com.ruoyi.job.scheduled;
|
||||||
|
//
|
||||||
|
//import com.ruoyi.common.core.redis.RedisCache;
|
||||||
|
//import com.ruoyi.zxzb.basic.service.IYcFlowFormulaService;
|
||||||
|
//import com.ruoyi.zxzb.basic.service.IYcThresholdService;
|
||||||
|
//import com.ruoyi.zxzb.data.service.IYcRainLevelInfoService;
|
||||||
|
//import com.ruoyi.zxzb.data.service.IYcStcdCurrValService;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.core.env.Environment;
|
||||||
|
//import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
//import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
|
//import javax.annotation.PostConstruct;
|
||||||
|
//
|
||||||
|
//@Component
|
||||||
|
//@Configuration
|
||||||
|
//@EnableScheduling
|
||||||
|
//public class JdDataUploadAlarmTask {
|
||||||
|
//
|
||||||
|
// private static String errAlarm = "";
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private Environment env;
|
||||||
|
//
|
||||||
|
// @PostConstruct
|
||||||
|
// public void config() {
|
||||||
|
// errAlarm = env.getProperty("errAlarm");
|
||||||
|
// }
|
||||||
|
// @Autowired
|
||||||
|
// private IYcStcdCurrValService ycStcdCurrValService;
|
||||||
|
// @Autowired
|
||||||
|
// private IYcThresholdService ycThresholdService;
|
||||||
|
// @Autowired
|
||||||
|
// private IYcFlowFormulaService ycFlowFormulaService;
|
||||||
|
// @Autowired
|
||||||
|
// private IYcRainLevelInfoService ycRainLevelInfoService;
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private RedisCache redisCache;
|
||||||
|
//
|
||||||
|
//// @Scheduled(fixedDelay = 50000000)
|
||||||
|
// @Scheduled(cron = "0 0/2 * * * ?")
|
||||||
|
// public void rtspScreenshot(){
|
||||||
|
// if("1".equals(errAlarm)){
|
||||||
|
// ycStcdCurrValService.dataUploadAlarm("A");
|
||||||
|
//// ycStcdCurrValService.dataUploadAlarm("B");
|
||||||
|
// ycStcdCurrValService.dataUploadAlarm("C");
|
||||||
|
//// ycStcdCurrValService.dataUploadAlarm("D");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// List<YcSmsInfo> alarmList = ycStcdCurrValService.alarmErr1Sms(1L,null);
|
||||||
|
//// if(alarmList.isEmpty()){
|
||||||
|
//// return;
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// List<String> mobiles = new ArrayList<>();
|
||||||
|
//// for (YcSmsInfo d : alarmList) {
|
||||||
|
//// String[] phones = d.getPhones().split(",");
|
||||||
|
//// for (String phone : phones) {
|
||||||
|
//// if(!mobiles.contains(phone)){
|
||||||
|
//// mobiles.add(phone);
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// for (String mobile : mobiles) {
|
||||||
|
//// List<YcSmsInfo> smsInfos = alarmList.stream().filter(d -> d.getPhones().contains(mobile)).collect(Collectors.toList());
|
||||||
|
//// List<String> stnms = smsInfos.stream().map(YcSmsInfo::getStnm).distinct().collect(Collectors.toList());
|
||||||
|
//// String smsContent = "包含"+StringUtils.join(stnms,"、");
|
||||||
|
//// if(smsContent.length() >19){
|
||||||
|
//// smsContent = smsContent.substring(0,16)+"等";
|
||||||
|
//// }
|
||||||
|
//// String title = "自动测报系统";
|
||||||
|
//// String alarmTitle = "数据上传";
|
||||||
|
//// String params = "[\""+alarmTitle+"\",\""+smsContent+"\"]";
|
||||||
|
//// try {
|
||||||
|
//// YySMSUtils.sendTemplatMsg("bee3733c90c8467c89894e958b5b2cc4",mobile,params);
|
||||||
|
//// } catch (IOException e) {
|
||||||
|
//// e.printStackTrace();
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// ycStcdCurrValService.alarmSms(1L,null);
|
||||||
|
//// ycStcdCurrValService.alarmSms(2L,null);
|
||||||
|
//// ycStcdCurrValService.alarmSms(3L,null);
|
||||||
|
//// ycStcdCurrValService.alarmErr4Sms(4L,null);
|
||||||
|
//// ycStcdCurrValService.alarmSms(5L,null);
|
||||||
|
//
|
||||||
|
// //水位超限预警
|
||||||
|
// ycStcdCurrValService.alarmWaterErr4(4L,null);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 降雨预警等级机制
|
||||||
|
// */
|
||||||
|
// @Scheduled(cron = "0 0/2 * * * ?")
|
||||||
|
// public void rainLevelAlarmTask(){
|
||||||
|
//
|
||||||
|
// if("1".equals(errAlarm)) {
|
||||||
|
// ycStcdCurrValService.rainLevelAlarm2();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 降雨提醒
|
||||||
|
// */
|
||||||
|
// @Scheduled(cron = "0 0/2 * * * ?")
|
||||||
|
// public void rainReportTask(){
|
||||||
|
// if("1".equals(errAlarm)) {
|
||||||
|
// ycStcdCurrValService.rainReport();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 每天早上8点发送预警汇总短信
|
||||||
|
// */
|
||||||
|
// @Scheduled(cron = "0 0 8 * * ?")
|
||||||
|
//// @Scheduled(fixedDelay = 50000000)
|
||||||
|
// public void smsReSend(){
|
||||||
|
// if("1".equals(errAlarm)) {
|
||||||
|
// ycStcdCurrValService.dailyReport();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 每天定时刷新缓存
|
||||||
|
// */
|
||||||
|
// @Scheduled(cron = "0 0 23 * * ?")
|
||||||
|
// public void reloadRedis(){
|
||||||
|
// if("1".equals(errAlarm)) {
|
||||||
|
// ycThresholdService.dataToRedis();
|
||||||
|
// ycRainLevelInfoService.setYcRainLevelInfoTORedis();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 启动刷新缓存
|
||||||
|
// */
|
||||||
|
// @PostConstruct
|
||||||
|
// public void dataToRedis(){
|
||||||
|
// System.out.println("============data to redis=============");
|
||||||
|
// ycThresholdService.dataToRedis();
|
||||||
|
// ycRainLevelInfoService.setYcRainLevelInfoTORedis();
|
||||||
|
//// ycStcdCurrValService.dailyReport();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,35 @@ |
|||||||
|
package com.ruoyi.job.scheduled; |
||||||
|
|
||||||
|
import com.ruoyi.zxzb.api.service.IYcServeApiService; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import javax.annotation.PostConstruct; |
||||||
|
|
||||||
|
@Component |
||||||
|
@EnableScheduling |
||||||
|
public class ServeApiTask { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IYcServeApiService ycServeApiService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 每天定时刷新缓存 |
||||||
|
*/ |
||||||
|
@Scheduled(cron = "0 0 23 * * ?") |
||||||
|
public void smsReSend(){ |
||||||
|
ycServeApiService.addRedis(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 启动刷新缓存 |
||||||
|
*/ |
||||||
|
@PostConstruct |
||||||
|
public void dataToRedis(){ |
||||||
|
System.out.println("============api data to redis============="); |
||||||
|
ycServeApiService.addRedis(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,99 @@ |
|||||||
|
package com.ruoyi.job.scheduled; |
||||||
|
|
||||||
|
import cn.hutool.http.HttpRequest; |
||||||
|
import cn.hutool.http.HttpResponse; |
||||||
|
import cn.hutool.http.HttpUtil; |
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.ruoyi.common.enums.WdrEnum; |
||||||
|
import com.ruoyi.common.utils.StringUtils; |
||||||
|
import com.ruoyi.job.dto.PushCurrDataDto; |
||||||
|
import com.ruoyi.job.dto.PushStcdDataDto; |
||||||
|
import com.ruoyi.zxzb.api.service.IYcServeApiService; |
||||||
|
import com.ruoyi.zxzb.basic.domain.YcStation; |
||||||
|
import com.ruoyi.zxzb.basic.service.IYcStationService; |
||||||
|
import com.ruoyi.zxzb.data.domain.YcStcdCurrVal; |
||||||
|
import com.ruoyi.zxzb.data.service.IYcStcdCurrValService; |
||||||
|
import com.ruoyi.zxzb.report.utils.DateCalcUtil; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.core.env.Environment; |
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import javax.annotation.PostConstruct; |
||||||
|
import java.text.DecimalFormat; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
@Component |
||||||
|
@EnableScheduling |
||||||
|
public class ServeDataPushTask { |
||||||
|
|
||||||
|
private static String pushAddr = ""; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private Environment env; |
||||||
|
@Autowired |
||||||
|
private IYcStcdCurrValService ycStcdCurrValService; |
||||||
|
@Autowired |
||||||
|
private IYcStationService ycStationService; |
||||||
|
|
||||||
|
@PostConstruct |
||||||
|
public void config() { |
||||||
|
pushAddr = env.getProperty("pushAddr"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 每天定时刷新缓存 |
||||||
|
*/ |
||||||
|
@Scheduled(cron = "0 3/5 * * * ?") |
||||||
|
public void smsReSend(){ |
||||||
|
if(StringUtils.isNotBlank(pushAddr)){ |
||||||
|
System.out.println("pushAddr="+pushAddr); |
||||||
|
List<YcStation> stationList = ycStationService.list(new QueryWrapper<YcStation>().eq("deleted","n")); |
||||||
|
List<YcStcdCurrVal> dataList = ycStcdCurrValService.getCurrData(); |
||||||
|
List<PushCurrDataDto> list = new ArrayList<>(); |
||||||
|
|
||||||
|
DecimalFormat df1 = new DecimalFormat("0.0"); |
||||||
|
DecimalFormat df2 = new DecimalFormat("0.00"); |
||||||
|
for (YcStation s : stationList) { |
||||||
|
PushCurrDataDto dto = new PushCurrDataDto(); |
||||||
|
dto.setStationName(s.getStnm()); |
||||||
|
dto.setStationCode(s.getStaid()); |
||||||
|
List<YcStcdCurrVal> _thisDataList = dataList.stream().filter(t -> t.getStnmId().equals(s.getStnmId()) && t.getStcd().equals(s.getStaid())).collect(Collectors.toList()); |
||||||
|
List<PushStcdDataDto> _data = new ArrayList<>(); |
||||||
|
if(_thisDataList.isEmpty()){ |
||||||
|
continue; |
||||||
|
} |
||||||
|
dto.setTm(DateCalcUtil.dateToString(_thisDataList.get(0).getLatestTm(),"yyyy-MM-dd HH:mm:ss")); |
||||||
|
for (YcStcdCurrVal dd : _thisDataList) { |
||||||
|
PushStcdDataDto _stcdData = new PushStcdDataDto(); |
||||||
|
_stcdData.setItem(dd.getMainType()); |
||||||
|
if("U".equals(dd.getMainType())){ |
||||||
|
_stcdData.setValue(WdrEnum.getName(dd.getLatestValue().intValue())); |
||||||
|
}else{ |
||||||
|
if("C".equals(dd.getMainType())){ |
||||||
|
_stcdData.setValue(df2.format(dd.getLatestValue())); |
||||||
|
}else{ |
||||||
|
_stcdData.setValue(df1.format(dd.getLatestValue())); |
||||||
|
} |
||||||
|
} |
||||||
|
_data.add(_stcdData); |
||||||
|
} |
||||||
|
dto.setData(_data); |
||||||
|
|
||||||
|
list.add(dto); |
||||||
|
} |
||||||
|
HttpResponse response = HttpRequest.post(pushAddr) |
||||||
|
.body(JSON.toJSONString(list)) |
||||||
|
.header("Content-Type", "application/json") // 设置请求头,指定 JSON 内容类型
|
||||||
|
.execute(); |
||||||
|
|
||||||
|
System.out.println(response.body()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
//package com.ruoyi.job.scheduled;
|
||||||
|
//
|
||||||
|
//import com.ruoyi.zxzb.api.service.IYcServeApiService;
|
||||||
|
//import com.ruoyi.zxzb.data.service.IYcDataService;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
//import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
|
//import javax.annotation.PostConstruct;
|
||||||
|
//import java.util.HashMap;
|
||||||
|
//import java.util.Map;
|
||||||
|
//
|
||||||
|
//@Component
|
||||||
|
//@EnableScheduling
|
||||||
|
//public class TestTask {
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private IYcDataService ycDataService;
|
||||||
|
//
|
||||||
|
// @PostConstruct
|
||||||
|
// public void startTest(){
|
||||||
|
// Map<String,Object> params = new HashMap<>();
|
||||||
|
// params.put("startDate","2025-06-13");
|
||||||
|
// params.put("endDate","2025-06-19");
|
||||||
|
// ycDataService.getWeekReport(params);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@ -0,0 +1,16 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.zxzb.basic.domain.YcStcdInfo; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
public interface ConsumerService{ |
||||||
|
String DataErrorDeal(YcStcdInfo stcd, StData data, String type, String dataUnit); |
||||||
|
|
||||||
|
String volErrorDeal(StData data,String type,String dataUnit); |
||||||
|
|
||||||
|
void pptnOpen(StData data); |
||||||
|
|
||||||
|
BigDecimal get5beforeData(StData data, String type); |
||||||
|
} |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.MeRain; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface MeRainService extends IService<MeRain> { |
||||||
|
|
||||||
|
List<MeRain> selectData(String stcd, String startTime, String endTime); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.dto.MessageData; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface MessageDataService extends IService<MessageData> { |
||||||
|
|
||||||
|
MessageData selectData(Map<String,Object> params); |
||||||
|
|
||||||
|
void insertData(MessageData data); |
||||||
|
|
||||||
|
void updateData(MessageData data); |
||||||
|
} |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
public interface ProducerService { |
||||||
|
|
||||||
|
void complementMeData(String startDate,String endDate); |
||||||
|
} |
||||||
@ -0,0 +1,4 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
public interface ServeApiService { |
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StPptnHour; |
||||||
|
import com.ruoyi.job.dto.StPptnHourDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StPptnHourService extends IService<StPptnHour> { |
||||||
|
void updateData(StPptnHourDto data); |
||||||
|
|
||||||
|
void saveData(StPptnHourDto data); |
||||||
|
|
||||||
|
StPptnHourDto getDataByTmAndStcd(String beforeTm,String stcd); |
||||||
|
|
||||||
|
void saveOrUpdate(StPptnHourDto data); |
||||||
|
|
||||||
|
String getMaxTmData(String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StPptrR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StPptrRService extends IService<StPptrR> { |
||||||
|
void updateData(StPptrRDto data); |
||||||
|
|
||||||
|
void saveData(StPptrRDto data); |
||||||
|
|
||||||
|
StPptrRDto getDataByTmAndStcd(String beforeTm,String stcd); |
||||||
|
|
||||||
|
void saveOrUpdate(StPptrRDto data); |
||||||
|
|
||||||
|
String getMaxTmData(String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StQflowR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StQflowDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StQflowService extends IService<StQflowR> { |
||||||
|
void updateData(StQflowDto data); |
||||||
|
|
||||||
|
void saveData(StQflowDto data); |
||||||
|
|
||||||
|
StQflowDto getDataByTmAndStcd(String beforeTm, String stcd); |
||||||
|
|
||||||
|
StQflowDto getSpeedDataByTmAndStcd(String beforeTm, String stcd); |
||||||
|
|
||||||
|
void saveOrUpdate(StQflowDto data); |
||||||
|
|
||||||
|
void insertSpeedData(StQflowDto data); |
||||||
|
|
||||||
|
String getMaxTmData(String stcd); |
||||||
|
|
||||||
|
StData getMinTmData(String tm,String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StRhR; |
||||||
|
import com.ruoyi.job.dto.StRhRDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StRhRService extends IService<StRhR> { |
||||||
|
void saveData(StRhRDto data); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StRiverR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StRiverRDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StRiverRService extends IService<StRiverR> { |
||||||
|
void updateData(StRiverRDto data); |
||||||
|
|
||||||
|
void saveData(StRiverRDto data); |
||||||
|
|
||||||
|
StRiverRDto getDataByTmAndStcd(String beforeTm, String stcd); |
||||||
|
|
||||||
|
void saveOrUpdate(StRiverRDto data); |
||||||
|
|
||||||
|
String getMaxTmData(String stcd); |
||||||
|
|
||||||
|
StData getMinTmData(String tm,String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StRsvrR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StRsvrRDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StRsvrRService extends IService<StRsvrR> { |
||||||
|
void updateData(StRsvrRDto data); |
||||||
|
|
||||||
|
void saveData(StRsvrRDto data); |
||||||
|
|
||||||
|
StRsvrRDto getDataByTmAndStcd(String beforeTm, String stcd); |
||||||
|
|
||||||
|
void saveOrUpdate(StRsvrRDto data); |
||||||
|
|
||||||
|
String getMaxTmData(String stcd); |
||||||
|
|
||||||
|
StData getMinTmData(String tm,String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,15 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StTempR; |
||||||
|
import com.ruoyi.job.dto.StTempRDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StTempRService extends IService<StTempR> { |
||||||
|
void saveData(StTempRDto data); |
||||||
|
|
||||||
|
StTempRDto getDataByTmAndStcd(String beforeTm,String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StTideR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StTideRDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StTideRService extends IService<StTideR> { |
||||||
|
void updateData(StTideRDto data); |
||||||
|
|
||||||
|
void saveData(StTideRDto data); |
||||||
|
|
||||||
|
StTideRDto getDataByTmAndStcd(String beforeTm, String stcd); |
||||||
|
|
||||||
|
void saveOrUpdate(StTideRDto data); |
||||||
|
|
||||||
|
String getMaxTmData(String stcd); |
||||||
|
|
||||||
|
StData getMinTmData(String tm,String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StWdrR; |
||||||
|
import com.ruoyi.job.dto.StWdrRDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StWdrRService extends IService<StWdrR> { |
||||||
|
void saveData(StWdrRDto data); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.StWsR; |
||||||
|
import com.ruoyi.job.dto.StWsRDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface StWsRService extends IService<StWsR> { |
||||||
|
void saveData(StWsRDto data); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
package com.ruoyi.job.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.ruoyi.job.domain.VoltageS; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.VoltageSDto; |
||||||
|
|
||||||
|
/** |
||||||
|
* 统计数据公共类 |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface VoltageSService extends IService<VoltageS> { |
||||||
|
void updateData(VoltageSDto data); |
||||||
|
|
||||||
|
void saveData(VoltageSDto data); |
||||||
|
|
||||||
|
VoltageSDto getDataByTmAndStcd(String beforeTm, String stcd); |
||||||
|
|
||||||
|
void saveOrUpdate(VoltageSDto data); |
||||||
|
|
||||||
|
String getMaxTmData(String stcd); |
||||||
|
} |
||||||
@ -0,0 +1,645 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.common.utils.ClassReflection; |
||||||
|
import com.ruoyi.common.utils.DateUtils; |
||||||
|
import com.ruoyi.common.utils.StringUtils; |
||||||
|
import com.ruoyi.job.domain.StTideR; |
||||||
|
import com.ruoyi.job.dto.*; |
||||||
|
import com.ruoyi.job.mapper.StTideRMapper; |
||||||
|
import com.ruoyi.job.service.*; |
||||||
|
import com.ruoyi.zxzb.alarm.domain.YcAlarmInfo; |
||||||
|
import com.ruoyi.zxzb.alarm.service.IYcAlarmInfoService; |
||||||
|
import com.ruoyi.zxzb.basic.domain.YcStation; |
||||||
|
import com.ruoyi.zxzb.basic.domain.YcStcdInfo; |
||||||
|
import com.ruoyi.zxzb.basic.service.IYcStationService; |
||||||
|
import com.ruoyi.zxzb.basic.service.IYcStcdAbnormalStatusService; |
||||||
|
import com.ruoyi.zxzb.basic.service.IYcStcdInfoService; |
||||||
|
import com.ruoyi.zxzb.basic.service.IYcThresholdService; |
||||||
|
import com.ruoyi.zxzb.data.service.IYcStcdCurrValService; |
||||||
|
import com.ruoyi.zxzb.message.service.IFloodSeasonService; |
||||||
|
import com.ruoyi.zxzb.mobile.WebSocketServer; |
||||||
|
import com.ruoyi.zxzb.report.utils.DateUtil; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@Service("consumerService") |
||||||
|
public class ConsumerServiceImpl implements ConsumerService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private MessageDataService messageDataService; |
||||||
|
@Resource |
||||||
|
private StPptrRService stPptrRService; |
||||||
|
@Resource |
||||||
|
private StRiverRService stRiverRService; |
||||||
|
@Resource |
||||||
|
private StRsvrRService stRsvrRService; |
||||||
|
@Resource |
||||||
|
private StTideRService stTideRService; |
||||||
|
@Resource |
||||||
|
private StQflowService stQflowService; |
||||||
|
@Resource |
||||||
|
private StTempRService stTempRService; |
||||||
|
@Resource |
||||||
|
private VoltageSService voltageSService; |
||||||
|
@Resource |
||||||
|
private IYcStcdInfoService ycStcdInfoService; |
||||||
|
@Resource |
||||||
|
private IYcThresholdService ycThresholdService; |
||||||
|
@Resource |
||||||
|
private IFloodSeasonService floodSeasonService; |
||||||
|
@Resource |
||||||
|
private IYcStationService ycStationService; |
||||||
|
@Resource |
||||||
|
private IYcAlarmInfoService ycAlarmInfoService; |
||||||
|
@Resource |
||||||
|
private IYcStcdCurrValService ycStcdCurrValService; |
||||||
|
@Resource |
||||||
|
private IYcStcdAbnormalStatusService ycStcdAbnormalStatusService; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void pptnOpen(StData data){ |
||||||
|
if(data.getStcd() != null && data.getValue() != null && data.getTm() != null ) { |
||||||
|
String type = data.getType(); |
||||||
|
StPptrRDto pp = new StPptrRDto(); |
||||||
|
pp.setDrp(data.getValue()); |
||||||
|
pp.setTm(data.getTm()); |
||||||
|
pp.setStcd(data.getStcd()); |
||||||
|
YcStcdInfo stcd = ycStcdInfoService.selectStcd(data.getStcd(),type); |
||||||
|
//log.error("||||"+type+"查询stcd:"+System.currentTimeMillis());
|
||||||
|
if(stcd != null) { |
||||||
|
String errId = DataErrorDeal(stcd, data, type, data.getUnit()); |
||||||
|
pp.setErr(errId); |
||||||
|
stPptrRService.saveOrUpdate(pp); |
||||||
|
ycStcdCurrValService.saveOrUpdate(stcd, type, data.getTm(), data.getValue()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public String DataErrorDeal(YcStcdInfo stcd, StData data, String type, String dataUnit){ |
||||||
|
//log.error("||||"+type+"开始处理异常:"+System.currentTimeMillis());
|
||||||
|
// System.out.println("==============================");
|
||||||
|
// System.out.println(data.getTm()+","+data.getStcd());
|
||||||
|
// System.out.println("==============================");
|
||||||
|
String errId = "0"; |
||||||
|
|
||||||
|
String dataDesc = ""; |
||||||
|
String maxTmData = ""; |
||||||
|
if("D".equals(type)){ |
||||||
|
dataDesc = "潮位"; |
||||||
|
maxTmData = stTideRService.getMaxTmData(stcd.getStcd()); |
||||||
|
}else if("A".equals(type)){ |
||||||
|
dataDesc = "雨量"; |
||||||
|
// maxTmData = stPptrRService.getMaxTmData(stcd.getStcd());
|
||||||
|
}else if("B".equals(type)){ |
||||||
|
dataDesc = "河道水位"; |
||||||
|
maxTmData = stRiverRService.getMaxTmData(stcd.getStcd()); |
||||||
|
// }else if("C".equals(type)){
|
||||||
|
}else if("E".equals(type)){ |
||||||
|
dataDesc = "流量"; |
||||||
|
maxTmData = stQflowService.getMaxTmData(stcd.getStcd()); |
||||||
|
}else{ |
||||||
|
dataDesc = "水库水位"; |
||||||
|
maxTmData = stRsvrRService.getMaxTmData(stcd.getStcd()); |
||||||
|
} |
||||||
|
|
||||||
|
YcStation station = ycStationService.getById(stcd.getStnmId()); |
||||||
|
|
||||||
|
//log.error("||||"+type+"查询站点:"+System.currentTimeMillis());
|
||||||
|
//5分钟数据差
|
||||||
|
if(!"A".equals(type) && !"E".equals(type)){ |
||||||
|
|
||||||
|
String dataErrId = "3"; |
||||||
|
BigDecimal threshold = getThresholdData(stcd.getStnmId(),type,dataErrId); |
||||||
|
//log.error("||||"+type+"查询5分钟数据差阈值:"+System.currentTimeMillis());
|
||||||
|
if(threshold != null){ |
||||||
|
if(maxTmData == null || StringUtils.isBlank(maxTmData)){ |
||||||
|
BigDecimal beforeData = get5beforeData(data, type); |
||||||
|
//log.error("||||" + type + "查询5分钟之前数据:" + System.currentTimeMillis());
|
||||||
|
if (beforeData != null) { |
||||||
|
BigDecimal subValue = beforeData.subtract(data.getValue()).abs(); |
||||||
|
if (subValue.compareTo(threshold) > 0) { |
||||||
|
//超出阈值范围,告警
|
||||||
|
errId = "1"; |
||||||
|
String alarmContent = data.getTm() + " " + station.getStnm() + "【设备SID编码:" + stcd.getStcd() + "】5分钟" + dataDesc + "数据差" + subValue + dataUnit + ",超过故障阈值(" + threshold + dataUnit + ")。"; |
||||||
|
addAlarm(data, station, type, "数据异常", alarmContent, Long.valueOf(dataErrId)); |
||||||
|
ycStcdAbnormalStatusService.setStcdErr(stcd.getId(), Long.valueOf(dataErrId)); |
||||||
|
} else { |
||||||
|
//判断是否要恢复告警
|
||||||
|
recoveryAlarm(data, stcd.getStnmId(), type, Long.valueOf(dataErrId)); |
||||||
|
ycStcdAbnormalStatusService.resetStcdErr(stcd.getId(), Long.valueOf(dataErrId)); |
||||||
|
} |
||||||
|
} |
||||||
|
}else{ |
||||||
|
//log.error("|||||判断是否为延迟数据");
|
||||||
|
Date maxTm = DateUtil.parseDate(maxTmData,"yyyy-MM-dd HH:mm:ss"); |
||||||
|
Date newTm = DateUtil.parseDate(data.getTm(),"yyyy-MM-dd HH:mm:ss"); |
||||||
|
//查询数据最新时刻,判断是否延迟上传的数据,正常数据无需做任何处理
|
||||||
|
assert maxTm != null; |
||||||
|
if(maxTm.after(newTm)){ |
||||||
|
//log.error("|||||是延迟数据");
|
||||||
|
//异常数据:记录右段数据最小时刻数据
|
||||||
|
StData minTmData = getMinTmData(type,data.getTm(),stcd.getStcd()); |
||||||
|
Date minTm = DateUtil.parseDate(minTmData.getTm(),"yyyy-MM-dd HH:mm:ss"); |
||||||
|
//log.error("minTm = "+ minTmData.getTm());
|
||||||
|
YcAlarmInfo alarm = ycAlarmInfoService.getOne( |
||||||
|
new QueryWrapper<YcAlarmInfo>() |
||||||
|
.eq("stcd",data.getStcd()) |
||||||
|
.eq("stnm_id",station.getStnmId()) |
||||||
|
.eq("deleted","n") |
||||||
|
.eq("type", type) |
||||||
|
.eq("err_id",Long.valueOf(dataErrId) ) |
||||||
|
.lt("alarm_time",newTm) |
||||||
|
.gt("update_time",newTm) |
||||||
|
); |
||||||
|
if(alarm != null){ |
||||||
|
//log.error("|||||在告警时间段内");
|
||||||
|
//在告警时间段内,出现正常数据,分割告警
|
||||||
|
//log.error(JSON.toJSONString(data));
|
||||||
|
BigDecimal beforeData = get5beforeData(data, type); |
||||||
|
//log.error("||||" + type + "查询5分钟之前数据:" + System.currentTimeMillis());
|
||||||
|
if (beforeData != null) { |
||||||
|
BigDecimal subValue = beforeData.subtract(data.getValue()).abs(); |
||||||
|
//数据正常
|
||||||
|
if (subValue.compareTo(threshold) < 1) { |
||||||
|
//切割告警 , 恢复告警
|
||||||
|
YcAlarmInfo newAlarm = new YcAlarmInfo(); |
||||||
|
try { |
||||||
|
ClassReflection.reflectionAttr(alarm,newAlarm); |
||||||
|
} catch (Exception e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
|
||||||
|
Date newAlarmTm = DateUtils.addMinutes(minTm,5); |
||||||
|
//切割,创建新的告警
|
||||||
|
newAlarm.setId(null); |
||||||
|
String alarmContent = DateUtil.formatDate(newAlarmTm,"yyyy-MM-dd HH:mm:ss") + " " + station.getStnm() + "【设备SID编码:" + stcd.getStcd() + "】5分钟" + dataDesc + "数据差" + subValue + dataUnit + ",超过故障阈值(" + threshold + dataUnit + ")。"; |
||||||
|
newAlarm.setAlarmContent(alarmContent); |
||||||
|
int newTotalLength = (int) ((alarm.getUpdateTime().getTime() - newAlarmTm.getTime()) / 1000); |
||||||
|
newAlarm.setAlarmTime(newAlarmTm); |
||||||
|
newAlarm.setUpdateTime(alarm.getUpdateTime()); |
||||||
|
newAlarm.setAlarmTotalLength((long)newTotalLength); |
||||||
|
// ycAlarmInfoService.save(newAlarm);
|
||||||
|
alarm(newAlarm); |
||||||
|
|
||||||
|
//更新已有告警
|
||||||
|
int interval = (int) ((newTm.getTime() - alarm.getAlarmTime().getTime()) / 1000); |
||||||
|
alarm.setAlarmTotalLength((long) interval); |
||||||
|
alarm.setUpdateTime(newTm); |
||||||
|
alarm.setFlag("1"); |
||||||
|
newAlarm.setStnm(station.getStnm()); |
||||||
|
ycAlarmInfoService.updateById(alarm); |
||||||
|
} |
||||||
|
} |
||||||
|
}else{ |
||||||
|
//log.error("|||||非告警时间段内");
|
||||||
|
BigDecimal beforeData = get5beforeData(data, type); |
||||||
|
//判断是否有update_time 为newTime - 5分钟的数据,若有则告警时长加300,没有则不管
|
||||||
|
if (beforeData != null) { |
||||||
|
BigDecimal subValue = beforeData.subtract(data.getValue()).abs(); |
||||||
|
//告警
|
||||||
|
if (subValue.compareTo(threshold) > 0) { |
||||||
|
YcAlarmInfo newAlarm = getAlarm("2",Long.valueOf(dataErrId),station.getStnmId(),data.getStcd(),type,null,DateUtils.addMinutes(newTm,-5)); |
||||||
|
|
||||||
|
if(newAlarm == null){ |
||||||
|
newAlarm = new YcAlarmInfo(); |
||||||
|
newAlarm.setStnmId(station.getStnmId()); |
||||||
|
newAlarm.setStnm(station.getStnm()); |
||||||
|
newAlarm.setStcd(data.getStcd()); |
||||||
|
newAlarm.setType(type); |
||||||
|
newAlarm.setAlarmType("数据异常"); |
||||||
|
newAlarm.setAlarmLevel("1"); |
||||||
|
String alarmContent = data.getTm() + " " + station.getStnm() + "【设备SID编码:" + stcd.getStcd() + "】5分钟" + dataDesc + "数据差" + subValue + dataUnit + ",超过故障阈值(" + threshold + dataUnit + ")。"; |
||||||
|
newAlarm.setAlarmContent(alarmContent); |
||||||
|
newAlarm.setAlarmTime(newTm); |
||||||
|
newAlarm.setUpdateTime(newTm); |
||||||
|
newAlarm.setAlarmTotalLength(0L); |
||||||
|
newAlarm.setErrId(Long.valueOf(dataErrId)); |
||||||
|
//延迟告警临时设为2
|
||||||
|
newAlarm.setFlag("2"); |
||||||
|
// ycAlarmInfoService.save(newAlarm);
|
||||||
|
alarm(newAlarm); |
||||||
|
errId = "1"; |
||||||
|
}else{ |
||||||
|
newAlarm.setStnm(station.getStnm()); |
||||||
|
newAlarm.setAlarmTotalLength(newAlarm.getAlarmTotalLength() + 300); |
||||||
|
newAlarm.setUpdateTime(newTm); |
||||||
|
ycAlarmInfoService.updateById(newAlarm); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//minTmData 与 最后一个值的比较, 根据告警的情况判断合并告警/更新时间
|
||||||
|
if(DateUtils.addMinutes(newTm,5).getTime() == minTm.getTime()){ |
||||||
|
//log.error("|||||延迟数据与最后一个值比较");
|
||||||
|
BigDecimal subValue = minTmData.getValue().subtract(data.getValue()).abs(); |
||||||
|
YcAlarmInfo beforeAlarm = getAlarm("2",Long.valueOf(dataErrId),station.getStnmId(),data.getStcd(),type,null,newTm); |
||||||
|
|
||||||
|
//before有告警,持续时长+300,不修改告警状态
|
||||||
|
if(beforeAlarm != null){ |
||||||
|
beforeAlarm.setAlarmTotalLength(beforeAlarm.getAlarmTotalLength() + 300L); |
||||||
|
beforeAlarm.setUpdateTime(newTm); |
||||||
|
beforeAlarm.setStnm(station.getStnm()); |
||||||
|
ycAlarmInfoService.updateById(beforeAlarm); |
||||||
|
} |
||||||
|
//minTmData异常
|
||||||
|
if (subValue.compareTo(threshold) > 0 && alarm == null){ |
||||||
|
Date newAlarmTm = DateUtils.addMinutes(minTm,5); |
||||||
|
YcAlarmInfo afterAlarm = getAlarm("",Long.valueOf(dataErrId),station.getStnmId(),data.getStcd(),type,newAlarmTm,null); |
||||||
|
|
||||||
|
//后有告警
|
||||||
|
if(afterAlarm != null){ |
||||||
|
if(beforeAlarm != null){ |
||||||
|
//前后都有告警
|
||||||
|
afterAlarm.setAlarmTotalLength(afterAlarm.getAlarmTotalLength() + beforeAlarm.getAlarmTotalLength()+ 300L); |
||||||
|
afterAlarm.setAlarmTime(beforeAlarm.getAlarmTime()); |
||||||
|
afterAlarm.setStnm(station.getStnm()); |
||||||
|
ycAlarmInfoService.updateById(afterAlarm); |
||||||
|
ycAlarmInfoService.removeById(beforeAlarm); |
||||||
|
}else{ |
||||||
|
//前无告警,后有告警,更新告警时长、告警时间
|
||||||
|
int newTotalLength = (int) ((afterAlarm.getUpdateTime().getTime() - minTm.getTime()) / 1000); |
||||||
|
afterAlarm.setAlarmTotalLength((long) newTotalLength); |
||||||
|
afterAlarm.setAlarmTime(minTm); |
||||||
|
afterAlarm.setStnm(station.getStnm()); |
||||||
|
ycAlarmInfoService.updateById(afterAlarm); |
||||||
|
//存在一个问题:st_river_r表的minData的err未更新
|
||||||
|
} |
||||||
|
}else{ |
||||||
|
//后无告警、前有告警,更新告警时长、告警时间、flag
|
||||||
|
if (beforeAlarm != null) { |
||||||
|
beforeAlarm.setAlarmTotalLength(beforeAlarm.getAlarmTotalLength() + 300L); |
||||||
|
beforeAlarm.setUpdateTime(newAlarmTm); |
||||||
|
beforeAlarm.setFlag("1"); |
||||||
|
beforeAlarm.setStnm(station.getStnm()); |
||||||
|
ycAlarmInfoService.updateById(beforeAlarm); |
||||||
|
}else{ |
||||||
|
//前后都无告警、创建一个时长为0的相应时刻的告警
|
||||||
|
YcAlarmInfo newAlarm = new YcAlarmInfo(); |
||||||
|
newAlarm.setStnmId(station.getStnmId()); |
||||||
|
newAlarm.setStnm(station.getStnm()); |
||||||
|
newAlarm.setStcd(data.getStcd()); |
||||||
|
newAlarm.setType(type); |
||||||
|
newAlarm.setAlarmType("数据异常"); |
||||||
|
newAlarm.setAlarmLevel("1"); |
||||||
|
String alarmContent = minTmData.getTm() + " " + station.getStnm() + "【设备SID编码:" + stcd.getStcd() + "】5分钟" + dataDesc + "数据差" + subValue + dataUnit + ",超过故障阈值(" + threshold + dataUnit + ")。"; |
||||||
|
newAlarm.setAlarmContent(alarmContent); |
||||||
|
newAlarm.setAlarmTime(minTm); |
||||||
|
newAlarm.setUpdateTime(minTm); |
||||||
|
newAlarm.setAlarmTotalLength(0L); |
||||||
|
newAlarm.setErrId(Long.valueOf(dataErrId)); |
||||||
|
newAlarm.setFlag("1"); |
||||||
|
// ycAlarmInfoService.save(newAlarm);
|
||||||
|
alarm(newAlarm); |
||||||
|
errId = "1"; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}else { |
||||||
|
//log.error("|||||非延迟数据");
|
||||||
|
BigDecimal beforeData = get5beforeData(data, type); |
||||||
|
//log.error("||||" + type + "查询5分钟之前数据:" + System.currentTimeMillis());
|
||||||
|
if (beforeData != null) { |
||||||
|
BigDecimal subValue = beforeData.subtract(data.getValue()).abs(); |
||||||
|
if (subValue.compareTo(threshold) > 0) { |
||||||
|
//超出阈值范围,告警
|
||||||
|
errId = "1"; |
||||||
|
String alarmContent = data.getTm() + " " + station.getStnm() + "【设备SID编码:" + stcd.getStcd() + "】5分钟" + dataDesc + "数据差" + subValue + dataUnit + ",超过故障阈值(" + threshold + dataUnit + ")。"; |
||||||
|
addAlarm(data, station, type, "数据异常", alarmContent, Long.valueOf(dataErrId)); |
||||||
|
ycStcdAbnormalStatusService.setStcdErr(stcd.getId(), Long.valueOf(dataErrId)); |
||||||
|
} else { |
||||||
|
//判断是否要恢复告警
|
||||||
|
recoveryAlarm(data, stcd.getStnmId(), type, Long.valueOf(dataErrId)); |
||||||
|
ycStcdAbnormalStatusService.resetStcdErr(stcd.getId(), Long.valueOf(dataErrId)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
//log.error("||||"+type+"5分钟数据差执行结束:"+System.currentTimeMillis());
|
||||||
|
} |
||||||
|
|
||||||
|
//雨量故障阈值
|
||||||
|
if(Arrays.asList("A","B","C","D").contains(type) ){ |
||||||
|
String dataErrId = "4"; |
||||||
|
BigDecimal threshold = getThresholdData(stcd.getStnmId(),type,dataErrId); |
||||||
|
//log.error("||||"+type+"查询雨量故障阈值:"+System.currentTimeMillis());
|
||||||
|
if(threshold != null){ |
||||||
|
if(data.getValue().compareTo(threshold) > 0){ |
||||||
|
//超出阈值范围,告警
|
||||||
|
errId = "1"; |
||||||
|
String alarmContent = data.getTm() + " " + station.getStnm() + "【设备SID编码:"+stcd.getStcd()+"】"+dataDesc+data.getValue() + dataUnit+",超过故障阈值("+ threshold + dataUnit+")。"; |
||||||
|
addAlarm(data,station,type,"数据异常",alarmContent,Long.valueOf(dataErrId)); |
||||||
|
ycStcdAbnormalStatusService.setStcdErr(stcd.getId(),Long.valueOf(dataErrId)); |
||||||
|
}else{ |
||||||
|
//判断是否要恢复告警
|
||||||
|
recoveryAlarm(data,stcd.getStnmId(),type,Long.valueOf(dataErrId)); |
||||||
|
ycStcdAbnormalStatusService.resetStcdErr(stcd.getId(),Long.valueOf(dataErrId)); |
||||||
|
} |
||||||
|
} |
||||||
|
//log.error("||||"+type+"雨量故障阈值执行结束:"+System.currentTimeMillis());
|
||||||
|
} |
||||||
|
|
||||||
|
// 主副设备差
|
||||||
|
if(stcd.getStcdTypeId() < 3){ |
||||||
|
int stcdTypeId = stcd.getStcdTypeId() == 1L ? 2 : 1; |
||||||
|
//主站
|
||||||
|
YcStcdInfo otherStcd = ycStcdInfoService.getOne( |
||||||
|
new QueryWrapper<YcStcdInfo>().eq("stcd_type_id",stcdTypeId). |
||||||
|
eq("stnm_id",stcd.getStnmId()).eq("parent_stnm_type",type).last(" limit 1 ") |
||||||
|
); |
||||||
|
//log.error("||||"+type+"查询副设备:"+System.currentTimeMillis());
|
||||||
|
if(otherStcd != null){ |
||||||
|
String mainSid = stcd.getStcdTypeId()==1L ? data.getStcd() : otherStcd.getStcd(); |
||||||
|
String fuSid = stcd.getStcdTypeId()==2L ? data.getStcd() : otherStcd.getStcd(); |
||||||
|
String dataErrId2 = "2"; |
||||||
|
BigDecimal threshold2 = getThresholdData(stcd.getStnmId(),type,dataErrId2); |
||||||
|
//log.error("||||"+type+"查询主副设备阈值:"+System.currentTimeMillis());
|
||||||
|
if(threshold2 != null) { |
||||||
|
BigDecimal f1Data = getOtherData(otherStcd.getStcd(), data.getTm(), type); |
||||||
|
//log.error("||||"+type+"查询副设备数据:"+System.currentTimeMillis());
|
||||||
|
BigDecimal mainData = stcd.getStcdTypeId()==1L ? data.getValue() : f1Data; |
||||||
|
BigDecimal fuData = stcd.getStcdTypeId()==2L ? data.getValue() : f1Data; |
||||||
|
if(f1Data != null) { |
||||||
|
BigDecimal subValue = f1Data.subtract(data.getValue()).abs(); |
||||||
|
if (subValue.compareTo(threshold2) > 0) { |
||||||
|
//超出阈值范围,告警
|
||||||
|
errId = "1"; |
||||||
|
String alarmContent = data.getTm() + " " + station.getStnm() |
||||||
|
+"主设备【设备SID编码:"+mainSid+"】"+dataDesc+mainData + dataUnit |
||||||
|
+",副设备【设备SID码:"+fuSid+"】"+dataDesc+fuData + dataUnit |
||||||
|
+",主副设备"+dataDesc+"差"+subValue+dataUnit+"超过故障阈值(" + threshold2 + dataUnit+")。"; |
||||||
|
addAlarm(data, station, type, "数据异常", alarmContent,Long.valueOf(dataErrId2)); |
||||||
|
ycStcdAbnormalStatusService.setStcdErr(stcd.getId(),Long.valueOf(dataErrId2)); |
||||||
|
}else{ |
||||||
|
//判断是否要恢复告警
|
||||||
|
recoveryAlarm(data,stcd.getStnmId(),type,Long.valueOf(dataErrId2)); |
||||||
|
ycStcdAbnormalStatusService.resetStcdErr2(stcd.getStnmId(),type,Long.valueOf(dataErrId2)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//log.error("||||"+type+"主副设备执行结束:"+System.currentTimeMillis());
|
||||||
|
} |
||||||
|
|
||||||
|
// ycStcdCurrValService.stationStatusUpdate(stcd.getStnmId());
|
||||||
|
return errId; |
||||||
|
} |
||||||
|
|
||||||
|
public YcAlarmInfo getAlarm(String flag,Long dataErrId,Long stnmId,String stcd,String type,Date alarmTime,Date updateTime){ |
||||||
|
return ycAlarmInfoService.getOne( |
||||||
|
new QueryWrapper<YcAlarmInfo>() |
||||||
|
.eq(StringUtils.isNotBlank(flag),"flag",flag) |
||||||
|
.eq("deleted","n") |
||||||
|
.eq("err_id",dataErrId) |
||||||
|
.eq("stnm_id",stnmId) |
||||||
|
.eq("stcd",stcd) |
||||||
|
.eq("type",type) |
||||||
|
.eq(alarmTime != null,"alarm_time",alarmTime) |
||||||
|
.eq(updateTime != null,"update_time",updateTime) |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
// 5分钟前数据
|
||||||
|
@Override |
||||||
|
public BigDecimal get5beforeData(StData data,String type){ |
||||||
|
String before = get5minBeforeTime(data.getTm()); |
||||||
|
if("A".equals(type)){ |
||||||
|
StPptrRDto beforeData = stPptrRService.getDataByTmAndStcd(before,data.getStcd()); |
||||||
|
if(beforeData != null){ |
||||||
|
return beforeData.getDrp(); |
||||||
|
} |
||||||
|
}else if("B".equals(type)){ |
||||||
|
StRiverRDto beforeData = stRiverRService.getDataByTmAndStcd(before,data.getStcd()); |
||||||
|
if(beforeData != null){ |
||||||
|
return beforeData.getZ(); |
||||||
|
} |
||||||
|
}else if("C".equals(type)){ |
||||||
|
StRsvrRDto beforeData = stRsvrRService.getDataByTmAndStcd(before,data.getStcd()); |
||||||
|
if(beforeData != null){ |
||||||
|
return beforeData.getRz(); |
||||||
|
} |
||||||
|
}else if("D".equals(type)){ |
||||||
|
StTideRDto beforeData = stTideRService.getDataByTmAndStcd(before,data.getStcd()); |
||||||
|
if(beforeData != null){ |
||||||
|
return beforeData.getTdz(); |
||||||
|
} |
||||||
|
}else if("T".equals(type)){ |
||||||
|
StTempRDto beforeData = stTempRService.getDataByTmAndStcd(before,data.getStcd()); |
||||||
|
if(beforeData != null){ |
||||||
|
return beforeData.getValue(); |
||||||
|
} |
||||||
|
}else if("V".equals(type)){ |
||||||
|
VoltageSDto beforeData = voltageSService.getDataByTmAndStcd(before,data.getStcd()); |
||||||
|
if(beforeData != null){ |
||||||
|
return beforeData.getVoltage(); |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
// 5分钟前数据
|
||||||
|
public StData getMinTmData(String type,String tm,String stcd){ |
||||||
|
if("B".equals(type)){ |
||||||
|
return stRiverRService.getMinTmData(tm,stcd); |
||||||
|
}else if("C".equals(type)){ |
||||||
|
return stRsvrRService.getMinTmData(tm,stcd); |
||||||
|
}else if("D".equals(type)){ |
||||||
|
return stTideRService.getMinTmData(tm,stcd); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
//主/副设备数据
|
||||||
|
public BigDecimal getOtherData(String f1Stcd,String tm,String type){ |
||||||
|
if("A".equals(type)){ |
||||||
|
StPptrRDto data = stPptrRService.getDataByTmAndStcd(tm,f1Stcd); |
||||||
|
if(data != null){ |
||||||
|
return data.getDrp(); |
||||||
|
} |
||||||
|
}else if("B".equals(type)){ |
||||||
|
StRiverRDto data = stRiverRService.getDataByTmAndStcd(tm,f1Stcd); |
||||||
|
if(data != null){ |
||||||
|
return data.getZ(); |
||||||
|
} |
||||||
|
}else if("C".equals(type)){ |
||||||
|
StRsvrRDto data = stRsvrRService.getDataByTmAndStcd(tm,f1Stcd); |
||||||
|
if(data != null){ |
||||||
|
return data.getRz(); |
||||||
|
} |
||||||
|
}else if("D".equals(type)){ |
||||||
|
StTideRDto data = stTideRService.getDataByTmAndStcd(tm,f1Stcd); |
||||||
|
if(data != null){ |
||||||
|
return data.getTdz(); |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
//获取阈值
|
||||||
|
public BigDecimal getThresholdData(Long stnmId,String type,String errId){ |
||||||
|
return ycThresholdService.getRedisData(stnmId,type,Long.valueOf(errId)); |
||||||
|
} |
||||||
|
|
||||||
|
//恢复告警
|
||||||
|
public void recoveryAlarm(StData data,Long stnmId,String type,Long errId){ |
||||||
|
YcAlarmInfo alarm = ycAlarmInfoService.getOne( |
||||||
|
new QueryWrapper<YcAlarmInfo>() |
||||||
|
.eq("is_deal","n") |
||||||
|
.eq("flag","0") |
||||||
|
.eq("deleted","n") |
||||||
|
.eq("err_id",errId) |
||||||
|
.eq("stnm_id",stnmId) |
||||||
|
.eq(errId != 2L,"stcd",data.getStcd()) |
||||||
|
.eq("type",type)); |
||||||
|
if(alarm != null){ |
||||||
|
// Date now = new Date();
|
||||||
|
Date now = DateUtil.parseDate(data.getTm(),"yyyy-MM-dd HH:mm:ss"); |
||||||
|
int interval = (int) ((now.getTime() - alarm.getAlarmTime().getTime()) / 1000); |
||||||
|
if(alarm.getUpdateTime().before(now)) { |
||||||
|
alarm.setAlarmTotalLength((long) interval); |
||||||
|
} |
||||||
|
alarm.setUpdateTime(now); |
||||||
|
alarm.setFlag("1"); |
||||||
|
ycAlarmInfoService.updateById(alarm); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//添加/更新告警
|
||||||
|
private void addAlarm(StData data,YcStation station,String type,String alarmType,String content,Long errId){ |
||||||
|
YcAlarmInfo alarm = ycAlarmInfoService.getOne( |
||||||
|
new QueryWrapper<YcAlarmInfo>() |
||||||
|
.eq("is_deal","n") |
||||||
|
.eq("flag","0") |
||||||
|
.eq("deleted","n") |
||||||
|
.eq("err_id",errId) |
||||||
|
.eq("stnm_id",station.getStnmId()) |
||||||
|
.eq(errId != 2L,"stcd",data.getStcd()) |
||||||
|
.eq("type",type) |
||||||
|
); |
||||||
|
Date alarmTm = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,data.getTm()); |
||||||
|
// Date now = new Date();
|
||||||
|
if(alarm == null){ |
||||||
|
alarm = new YcAlarmInfo(); |
||||||
|
alarm.setStnmId(station.getStnmId()); |
||||||
|
alarm.setStnm(station.getStnm()); |
||||||
|
alarm.setStcd(data.getStcd()); |
||||||
|
alarm.setType(type); |
||||||
|
alarm.setAlarmType(alarmType); |
||||||
|
alarm.setAlarmLevel("1"); |
||||||
|
alarm.setAlarmContent(content); |
||||||
|
alarm.setAlarmTime(alarmTm); |
||||||
|
alarm.setAlarmTotalLength(0L); |
||||||
|
alarm.setUpdateTime(alarmTm); |
||||||
|
alarm.setErrId(errId); |
||||||
|
alarm.setFlag("0"); |
||||||
|
// ycAlarmInfoService.save(alarm);
|
||||||
|
alarm(alarm); |
||||||
|
}else{ |
||||||
|
//最新更新时间比告警时间早,正常计算持续时长
|
||||||
|
if(alarm.getUpdateTime().before(alarmTm)){ |
||||||
|
int interval = (int) ((alarmTm.getTime() - alarm.getAlarmTime().getTime())/1000); |
||||||
|
alarm.setUpdateTime(alarmTm); |
||||||
|
alarm.setAlarmTotalLength((long) interval); |
||||||
|
alarm.setStnm(station.getStnm()); |
||||||
|
ycAlarmInfoService.updateById(alarm); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
//5分钟前时间
|
||||||
|
public String get5minBeforeTime(String time){ |
||||||
|
if(StringUtils.isNotBlank(time)){ |
||||||
|
Date date = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,time); |
||||||
|
Date before = DateUtils.addMinutes(date,-5); |
||||||
|
return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,before); |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String volErrorDeal(StData data,String type,String dataUnit){ |
||||||
|
String errId = "0"; |
||||||
|
Date now = new Date(); |
||||||
|
//判断stcd是否存在
|
||||||
|
List<YcStcdInfo> list = ycStcdInfoService.selectStcdList(data.getStcd()); |
||||||
|
if(!list.isEmpty()){ |
||||||
|
YcStcdInfo stcd = list.get(0); |
||||||
|
YcStation station = ycStationService.getById(stcd.getStnmId()); |
||||||
|
BigDecimal threshold = getThresholdData(stcd.getStnmId(),"ALL","5"); |
||||||
|
if(threshold != null) { |
||||||
|
//查询告警
|
||||||
|
YcAlarmInfo alarmData = ycAlarmInfoService.getOne( |
||||||
|
new QueryWrapper<YcAlarmInfo>().eq("err_id",5L).eq("flag","0").eq("type",type).eq("stcd",data.getStcd()) |
||||||
|
); |
||||||
|
if (data.getValue().compareTo(threshold) < 0) { |
||||||
|
errId = "1"; |
||||||
|
//低电量
|
||||||
|
String alarmContent = station.getStnm() + "【设备SID编码:" + stcd.getStcd() + "】电压"+data.getValue() + dataUnit+"低于阈值(" + threshold + dataUnit+")。"; |
||||||
|
if(alarmData != null){ |
||||||
|
alarmData.setAlarmTotalLength(alarmData.getAlarmTotalLength() + (now.getTime() - alarmData.getUpdateTime().getTime()) / 1000); |
||||||
|
alarmData.setUpdateTime(now); |
||||||
|
alarmData.setAlarmTime(now); |
||||||
|
ycAlarmInfoService.updateById(alarmData); |
||||||
|
}else{ |
||||||
|
alarmData = new YcAlarmInfo(); |
||||||
|
alarmData.setStnmId(station.getStnmId()); |
||||||
|
alarmData.setStnm(station.getStnm()); |
||||||
|
alarmData.setStcd(data.getStcd()); |
||||||
|
alarmData.setType(type); |
||||||
|
alarmData.setAlarmType("设备故障"); |
||||||
|
alarmData.setAlarmLevel("2"); |
||||||
|
alarmData.setAlarmContent(alarmContent); |
||||||
|
alarmData.setAlarmTime(new Date()); |
||||||
|
alarmData.setAlarmTotalLength(0L); |
||||||
|
alarmData.setErrId(5L); |
||||||
|
alarmData.setFlag("0"); |
||||||
|
// ycAlarmInfoService.save(alarmData);
|
||||||
|
alarm(alarmData); |
||||||
|
|
||||||
|
ycStcdAbnormalStatusService.setStcdErr(stcd.getId(),5L); |
||||||
|
} |
||||||
|
}else{ |
||||||
|
if(alarmData != null){ |
||||||
|
alarmData.setFlag("1"); |
||||||
|
ycAlarmInfoService.updateById(alarmData); |
||||||
|
} |
||||||
|
|
||||||
|
ycStcdAbnormalStatusService.resetStcdErr(stcd.getId(),5L); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return errId; |
||||||
|
} |
||||||
|
|
||||||
|
private void alarm(YcAlarmInfo alarmInfo){ |
||||||
|
ycAlarmInfoService.save(alarmInfo); |
||||||
|
// sendToWeb(alarmInfo.getAlarmContent());
|
||||||
|
sendToWeb(JSON.toJSONString(alarmInfo)); |
||||||
|
} |
||||||
|
|
||||||
|
private void sendToWeb(String msg){ |
||||||
|
WebSocketServer.sendAll(msg); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.job.domain.MeRain; |
||||||
|
import com.ruoyi.job.mapper.MeRainMapper; |
||||||
|
import com.ruoyi.job.service.MeRainService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("meRainService") |
||||||
|
public class MeRainServiceImpl extends ServiceImpl<MeRainMapper, MeRain> implements MeRainService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<MeRain> selectData(String stcd,String startTime,String endTime){ |
||||||
|
return baseMapper.selectData(stcd,startTime,endTime); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.common.annotation.DataSource; |
||||||
|
import com.ruoyi.common.enums.DataSourceType; |
||||||
|
import com.ruoyi.job.dto.MessageData; |
||||||
|
import com.ruoyi.job.mapper.MessageDataMapper; |
||||||
|
import com.ruoyi.job.service.MessageDataService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("messageDataService") |
||||||
|
public class MessageDataServiceImpl extends ServiceImpl<MessageDataMapper, MessageData> implements MessageDataService { |
||||||
|
|
||||||
|
@Override |
||||||
|
@DataSource(DataSourceType.SHARDING) |
||||||
|
public MessageData selectData(Map<String,Object> params){ |
||||||
|
return baseMapper.selectData(params); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@DataSource(DataSourceType.SHARDING) |
||||||
|
public void insertData(MessageData data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
@DataSource(DataSourceType.SHARDING) |
||||||
|
public void updateData(MessageData data){ |
||||||
|
baseMapper.updateData(data); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,222 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.ruoyi.common.config.RuoYiConfig; |
||||||
|
import com.ruoyi.common.enums.TableNameEnum; |
||||||
|
import com.ruoyi.job.dto.MeData; |
||||||
|
import com.ruoyi.job.dto.MeDataAfter; |
||||||
|
import com.ruoyi.job.service.ProducerService; |
||||||
|
import com.ruoyi.zxzb.basic.domain.YcStation; |
||||||
|
import com.ruoyi.zxzb.report.domain.YcZbcgTask; |
||||||
|
import com.ruoyi.zxzb.report.utils.DateUtil; |
||||||
|
import org.apache.poi.ss.formula.functions.T; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
import org.springframework.jdbc.core.BeanPropertyRowMapper; |
||||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||||
|
import org.springframework.kafka.core.KafkaTemplate; |
||||||
|
import org.springframework.scheduling.annotation.Async; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.io.File; |
||||||
|
import java.sql.*; |
||||||
|
import java.time.LocalDate; |
||||||
|
import java.time.format.DateTimeFormatter; |
||||||
|
import java.util.*; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.regex.Pattern; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("producerService") |
||||||
|
public class ProducerServiceImpl implements ProducerService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private KafkaTemplate<String, String> kafkaTemplate; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void complementMeData(String startDate,String endDate){ |
||||||
|
//t_real20250102
|
||||||
|
DealTask dealTask = new DealTask(startDate,endDate); |
||||||
|
dealTask.start(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DealTask extends Thread{ |
||||||
|
private final String startDate; |
||||||
|
private final String endDate; |
||||||
|
|
||||||
|
public DealTask(String startDate,String endDate) { |
||||||
|
this.startDate = startDate; |
||||||
|
this.endDate = endDate; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
String nameHeader = "t_real"; |
||||||
|
|
||||||
|
List<String> dateList = generateDateRange(startDate,endDate); |
||||||
|
List<String> tableNames = dateList.stream() |
||||||
|
.map(date -> nameHeader + date.replace("-", "")) |
||||||
|
.collect(Collectors.toList()); |
||||||
|
|
||||||
|
//1.1是电量,补数据不需要
|
||||||
|
List<String> indexList = Arrays.asList("2.2","2.6","2.10","1000.54","-1.2","-1.1","-1.4","-1.3","-1.5","100.1","100.2","-1.6","-1.7","-1.13","2.9","2.12","2.13","2.2","1000.48","100.4","-1.17","-1.8","-1.10"); |
||||||
|
|
||||||
|
List<MeData> trueDatas = new ArrayList<>(); |
||||||
|
MeData meData; |
||||||
|
for (String tableName : tableNames) { |
||||||
|
String sql = "SELECT id, sid, item, val, unit, dt, `index` FROM "+tableName+" order by id"; |
||||||
|
|
||||||
|
String countSql = "select count(1) from "+tableName; |
||||||
|
List<MeDataAfter> tableDatas = selectMeData(sql,countSql); |
||||||
|
System.out.println(tableName+" 共有数据:"+ tableDatas.size()+" 条"); |
||||||
|
for (MeDataAfter d : tableDatas) { |
||||||
|
//过滤非整时刻数据
|
||||||
|
String mint = d.getDt().substring(15,16); |
||||||
|
if(!"0".equals(mint) && !"5".equals(mint)){ |
||||||
|
continue; |
||||||
|
} |
||||||
|
//过滤非数值数据
|
||||||
|
if(!Pattern.matches("^-?\\d+(\\.\\d+)?$",d.getVal())){ |
||||||
|
continue; |
||||||
|
} |
||||||
|
//过滤index不在有效范围内的数据
|
||||||
|
if(!indexList.contains(d.getIndex())){ |
||||||
|
continue; |
||||||
|
} |
||||||
|
meData = new MeData(); |
||||||
|
|
||||||
|
meData.setOp("c"); |
||||||
|
meData.setAfter(d); |
||||||
|
trueDatas.add(meData); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
sendToKafka(trueDatas); |
||||||
|
} |
||||||
|
|
||||||
|
private void sendToKafka(List<MeData> data){ |
||||||
|
for (MeData d : data) { |
||||||
|
String index = d.getAfter().getIndex(); |
||||||
|
int sid = d.getAfter().getSid(); |
||||||
|
int yu = sid % 10; |
||||||
|
String topic = "st_flow_"; |
||||||
|
if("2.2".equals(index)){ |
||||||
|
topic = "st_rain_"; |
||||||
|
}else if("2.6".equals(index)){ |
||||||
|
topic = "st_water_"; |
||||||
|
} |
||||||
|
topic = topic + yu; |
||||||
|
System.out.println("发送"+index+": " + JSON.toJSONString(d)+" 至topic: "+ topic); |
||||||
|
kafkaTemplate.send(topic, JSON.toJSONString(d)); |
||||||
|
} |
||||||
|
System.out.println("数据总数:"+data.size()+" 条"); |
||||||
|
} |
||||||
|
|
||||||
|
public List<String> generateDateRange(String startDateStr, String endDateStr) { |
||||||
|
// 定义日期格式
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
||||||
|
|
||||||
|
// 解析日期字符串
|
||||||
|
LocalDate startDate = LocalDate.parse(startDateStr, formatter); |
||||||
|
LocalDate endDate = LocalDate.parse(endDateStr, formatter); |
||||||
|
|
||||||
|
// 验证日期范围
|
||||||
|
if (startDate.isAfter(endDate)) { |
||||||
|
throw new IllegalArgumentException("开始日期不能晚于结束日期"); |
||||||
|
} |
||||||
|
|
||||||
|
// 生成日期列表
|
||||||
|
List<String> dateList = new ArrayList<>(); |
||||||
|
LocalDate currentDate = startDate; |
||||||
|
|
||||||
|
while (!currentDate.isAfter(endDate)) { |
||||||
|
dateList.add(currentDate.format(formatter)); |
||||||
|
currentDate = currentDate.plusDays(1); |
||||||
|
} |
||||||
|
|
||||||
|
return dateList; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Value("${dbLink}") |
||||||
|
private String dbLink; |
||||||
|
|
||||||
|
public List<MeDataAfter> selectMeData(String sql,String countSql){ |
||||||
|
// JDBC驱动名称及URL
|
||||||
|
String driver = "com.mysql.cj.jdbc.Driver"; |
||||||
|
String url = "jdbc:mysql://61.164.75.62:60001/records"; |
||||||
|
// String url = "jdbc:mysql://"+dbLink+"/records";
|
||||||
|
// String url = "jdbc:mysql://192.168.16.232:13306/records";
|
||||||
|
|
||||||
|
List<MeDataAfter> list = new ArrayList<>(); |
||||||
|
|
||||||
|
Connection conn = null; |
||||||
|
Statement stmt = null; |
||||||
|
ResultSet rs = null; |
||||||
|
ResultSet rsCount = null; |
||||||
|
try{ |
||||||
|
Class.forName(driver); |
||||||
|
conn = DriverManager.getConnection(url,"dbz","dbZ_2022!"); |
||||||
|
|
||||||
|
stmt = conn.createStatement(); |
||||||
|
|
||||||
|
// stmt.setFetchSize(Integer.MIN_VALUE);
|
||||||
|
int limit = 0; |
||||||
|
rsCount = stmt.executeQuery(countSql); |
||||||
|
if(rsCount.next()){ |
||||||
|
limit = rsCount.getInt(1); |
||||||
|
} |
||||||
|
|
||||||
|
// limit = 1000000;
|
||||||
|
int pageSize = 10000; |
||||||
|
|
||||||
|
String addSql = ""; |
||||||
|
int page = limit / pageSize; |
||||||
|
if(limit > 0){ |
||||||
|
for (int i = 0; i < page; i++) { |
||||||
|
addSql = sql + " limit "+ (i*pageSize)+","+pageSize+" "; |
||||||
|
rs = stmt.executeQuery(addSql); |
||||||
|
System.out.println(addSql); |
||||||
|
MeDataAfter data; |
||||||
|
while (rs.next()) { |
||||||
|
data = new MeDataAfter(); |
||||||
|
data.setId(rs.getLong("id")); |
||||||
|
data.setSid(rs.getInt("sid")); |
||||||
|
data.setItem(rs.getString("item")); |
||||||
|
data.setVal(rs.getString("val")); |
||||||
|
data.setUnit(rs.getString("unit")); |
||||||
|
data.setDt(rs.getString("dt")); |
||||||
|
data.setIndex(rs.getString("index")); |
||||||
|
list.add(data); |
||||||
|
} |
||||||
|
System.out.println(i); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
}catch(Exception e){ |
||||||
|
e.printStackTrace(); |
||||||
|
}finally{ |
||||||
|
// 确保所有资源都被正确地关闭
|
||||||
|
try{ |
||||||
|
if(rs != null) rs.close(); |
||||||
|
if(rsCount != null) rsCount.close(); |
||||||
|
if(stmt != null) stmt.close(); |
||||||
|
if(conn != null) conn.close(); |
||||||
|
}catch(SQLException se2){ |
||||||
|
se2.printStackTrace(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return list; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,45 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.job.domain.StPptnHour; |
||||||
|
import com.ruoyi.job.dto.StPptnHourDto; |
||||||
|
import com.ruoyi.job.mapper.StPptnHourMapper; |
||||||
|
import com.ruoyi.job.service.StPptnHourService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stPptnHourService") |
||||||
|
public class StPptnHourServiceImpl extends ServiceImpl<StPptnHourMapper, StPptnHour> implements StPptnHourService { |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveData(StPptnHourDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void updateData(StPptnHourDto data){ |
||||||
|
baseMapper.updateData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public StPptnHourDto getDataByTmAndStcd(String beforeTm,String stcd){ |
||||||
|
return baseMapper.getDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMaxTmData(String stcd){ |
||||||
|
return baseMapper.getMaxTmData(stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveOrUpdate(StPptnHourDto data){ |
||||||
|
baseMapper.insertDataIgnore(data); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,49 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.common.annotation.DataSource; |
||||||
|
import com.ruoyi.common.enums.DataSourceType; |
||||||
|
import com.ruoyi.job.domain.StPptrR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StPptrRDto; |
||||||
|
import com.ruoyi.job.mapper.StPptrRMapper; |
||||||
|
import com.ruoyi.job.service.StPptrRService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stPptrRService") |
||||||
|
public class StPptrRServiceImpl extends ServiceImpl<StPptrRMapper, StPptrR> implements StPptrRService { |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveData(StPptrRDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void updateData(StPptrRDto data){ |
||||||
|
baseMapper.updateData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public StPptrRDto getDataByTmAndStcd(String beforeTm,String stcd){ |
||||||
|
return baseMapper.getDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMaxTmData(String stcd){ |
||||||
|
return baseMapper.getMaxTmData(stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveOrUpdate(StPptrRDto data){ |
||||||
|
baseMapper.insertDataIgnore(data); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,68 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.job.domain.StQflowR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StQflowDto; |
||||||
|
import com.ruoyi.job.mapper.StQflowMapper; |
||||||
|
import com.ruoyi.job.service.StQflowService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stQflowService") |
||||||
|
public class StQflowServiceImpl extends ServiceImpl<StQflowMapper, StQflowR> implements StQflowService { |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveData(StQflowDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void updateData(StQflowDto data){ |
||||||
|
baseMapper.updateData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public StQflowDto getDataByTmAndStcd(String beforeTm,String stcd){ |
||||||
|
return baseMapper.getDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public StQflowDto getSpeedDataByTmAndStcd(String beforeTm,String stcd){ |
||||||
|
return baseMapper.getSpeedDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMaxTmData(String stcd){ |
||||||
|
return baseMapper.getMaxTmData(stcd); |
||||||
|
} |
||||||
|
@Override |
||||||
|
public StData getMinTmData(String tm,String stcd){ |
||||||
|
return baseMapper.getMinTmData(tm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveOrUpdate(StQflowDto data){ |
||||||
|
// StQflowDto d = baseMapper.getDataByTmAndStcd(data.getTm() , data.getStcd());
|
||||||
|
// if(d != null){
|
||||||
|
// d.setTdz(data.getTdz());
|
||||||
|
// d.setErr(data.getErr());
|
||||||
|
// baseMapper.updateData(d);
|
||||||
|
// }else{
|
||||||
|
// baseMapper.insertData(data);
|
||||||
|
// }
|
||||||
|
baseMapper.insertDataIgnore(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void insertSpeedData(StQflowDto data){ |
||||||
|
baseMapper.insertSpeedData(data); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.job.domain.StRhR; |
||||||
|
import com.ruoyi.job.dto.StRhRDto; |
||||||
|
import com.ruoyi.job.mapper.StRhRMapper; |
||||||
|
import com.ruoyi.job.service.StRhRService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stRhRService") |
||||||
|
public class StRhRServiceImpl extends ServiceImpl<StRhRMapper, StRhR> implements StRhRService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void saveData(StRhRDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,59 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.common.annotation.DataSource; |
||||||
|
import com.ruoyi.common.enums.DataSourceType; |
||||||
|
import com.ruoyi.job.domain.StRiverR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StRiverRDto; |
||||||
|
import com.ruoyi.job.mapper.StRiverRMapper; |
||||||
|
import com.ruoyi.job.service.StRiverRService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stRiverRService") |
||||||
|
public class StRiverRServiceImpl extends ServiceImpl<StRiverRMapper, StRiverR> implements StRiverRService { |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveData(StRiverRDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void updateData(StRiverRDto data){ |
||||||
|
baseMapper.updateData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public StRiverRDto getDataByTmAndStcd(String beforeTm,String stcd){ |
||||||
|
return baseMapper.getDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
@Override |
||||||
|
public String getMaxTmData(String stcd){ |
||||||
|
return baseMapper.getMaxTmData(stcd); |
||||||
|
} |
||||||
|
@Override |
||||||
|
public StData getMinTmData(String tm,String stcd){ |
||||||
|
return baseMapper.getMinTmData(tm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveOrUpdate(StRiverRDto data){ |
||||||
|
// StRiverRDto d = baseMapper.getDataByTmAndStcd(data.getTm() , data.getStcd());
|
||||||
|
// if(d != null){
|
||||||
|
// d.setZ(data.getZ());
|
||||||
|
// d.setErr(data.getErr());
|
||||||
|
// baseMapper.updateData(d);
|
||||||
|
// }else{
|
||||||
|
// baseMapper.insertData(data);
|
||||||
|
// }
|
||||||
|
baseMapper.insertDataIgnore(data); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,60 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.common.annotation.DataSource; |
||||||
|
import com.ruoyi.common.enums.DataSourceType; |
||||||
|
import com.ruoyi.job.domain.StRsvrR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StRsvrRDto; |
||||||
|
import com.ruoyi.job.mapper.StRsvrRMapper; |
||||||
|
import com.ruoyi.job.service.StRsvrRService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stRsvrRService") |
||||||
|
public class StRsvrRServiceImpl extends ServiceImpl<StRsvrRMapper, StRsvrR> implements StRsvrRService { |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveData(StRsvrRDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void updateData(StRsvrRDto data){ |
||||||
|
baseMapper.updateData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public StRsvrRDto getDataByTmAndStcd(String beforeTm,String stcd){ |
||||||
|
return baseMapper.getDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMaxTmData(String stcd){ |
||||||
|
return baseMapper.getMaxTmData(stcd); |
||||||
|
} |
||||||
|
@Override |
||||||
|
public StData getMinTmData(String tm,String stcd){ |
||||||
|
return baseMapper.getMinTmData(tm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveOrUpdate(StRsvrRDto data){ |
||||||
|
// StRsvrRDto d = baseMapper.getDataByTmAndStcd(data.getTm() , data.getStcd());
|
||||||
|
// if(d != null){
|
||||||
|
// d.setRz(data.getRz());
|
||||||
|
// d.setErr(data.getErr());
|
||||||
|
// baseMapper.updateData(d);
|
||||||
|
// }else{
|
||||||
|
// baseMapper.insertData(data);
|
||||||
|
// }
|
||||||
|
baseMapper.insertDataIgnore(data); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.job.domain.StTempR; |
||||||
|
import com.ruoyi.job.dto.StTempRDto; |
||||||
|
import com.ruoyi.job.mapper.StTempRMapper; |
||||||
|
import com.ruoyi.job.service.StTempRService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stTempRService") |
||||||
|
public class StTempRServiceImpl extends ServiceImpl<StTempRMapper, StTempR> implements StTempRService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void saveData(StTempRDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public StTempRDto getDataByTmAndStcd(String beforeTm,String stcd){ |
||||||
|
return baseMapper.getDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,60 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.common.annotation.DataSource; |
||||||
|
import com.ruoyi.common.enums.DataSourceType; |
||||||
|
import com.ruoyi.job.domain.StTideR; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.StTideRDto; |
||||||
|
import com.ruoyi.job.mapper.StTideRMapper; |
||||||
|
import com.ruoyi.job.service.StTideRService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stTideRService") |
||||||
|
public class StTideRServiceImpl extends ServiceImpl<StTideRMapper, StTideR> implements StTideRService { |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveData(StTideRDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void updateData(StTideRDto data){ |
||||||
|
baseMapper.updateData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public StTideRDto getDataByTmAndStcd(String beforeTm,String stcd){ |
||||||
|
return baseMapper.getDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMaxTmData(String stcd){ |
||||||
|
return baseMapper.getMaxTmData(stcd); |
||||||
|
} |
||||||
|
@Override |
||||||
|
public StData getMinTmData(String tm,String stcd){ |
||||||
|
return baseMapper.getMinTmData(tm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveOrUpdate(StTideRDto data){ |
||||||
|
// StTideRDto d = baseMapper.getDataByTmAndStcd(data.getTm() , data.getStcd());
|
||||||
|
// if(d != null){
|
||||||
|
// d.setTdz(data.getTdz());
|
||||||
|
// d.setErr(data.getErr());
|
||||||
|
// baseMapper.updateData(d);
|
||||||
|
// }else{
|
||||||
|
// baseMapper.insertData(data);
|
||||||
|
// }
|
||||||
|
baseMapper.insertDataIgnore(data); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.job.domain.StWdrR; |
||||||
|
import com.ruoyi.job.dto.StWdrRDto; |
||||||
|
import com.ruoyi.job.mapper.StWdrRMapper; |
||||||
|
import com.ruoyi.job.service.StWdrRService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stWdrRService") |
||||||
|
public class StWdrRServiceImpl extends ServiceImpl<StWdrRMapper, StWdrR> implements StWdrRService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void saveData(StWdrRDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.job.domain.StWsR; |
||||||
|
import com.ruoyi.job.dto.StWsRDto; |
||||||
|
import com.ruoyi.job.mapper.StWsRMapper; |
||||||
|
import com.ruoyi.job.service.StWsRService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("stWsRService") |
||||||
|
public class StWsRServiceImpl extends ServiceImpl<StWsRMapper, StWsR> implements StWsRService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void saveData(StWsRDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,54 @@ |
|||||||
|
package com.ruoyi.job.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.ruoyi.job.domain.VoltageS; |
||||||
|
import com.ruoyi.job.dto.StData; |
||||||
|
import com.ruoyi.job.dto.VoltageSDto; |
||||||
|
import com.ruoyi.job.mapper.VoltageSMapper; |
||||||
|
import com.ruoyi.job.service.VoltageSService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* Service业务层处理 |
||||||
|
* |
||||||
|
*/ |
||||||
|
@Service("voltageSService") |
||||||
|
public class VoltageSServiceImpl extends ServiceImpl<VoltageSMapper, VoltageS> implements VoltageSService { |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveData(VoltageSDto data){ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void updateData(VoltageSDto data){ |
||||||
|
baseMapper.updateData(data); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public VoltageSDto getDataByTmAndStcd(String beforeTm, String stcd){ |
||||||
|
return baseMapper.getDataByTmAndStcd(beforeTm,stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getMaxTmData(String stcd){ |
||||||
|
return baseMapper.getMaxTmData(stcd); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
// @DataSource(DataSourceType.SHARDING)
|
||||||
|
public void saveOrUpdate(VoltageSDto data){ |
||||||
|
VoltageSDto d = baseMapper.getDataByTmAndStcd(data.getTm() , data.getStcd()); |
||||||
|
if(d != null){ |
||||||
|
d.setVoltage(data.getVoltage()); |
||||||
|
d.setErr(data.getErr()); |
||||||
|
baseMapper.updateData(d); |
||||||
|
}else{ |
||||||
|
baseMapper.insertData(data); |
||||||
|
} |
||||||
|
// baseMapper.insertDataIgnore(data);
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||||
|
<!DOCTYPE mapper |
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.ruoyi.job.mapper.MeRainMapper"> |
||||||
|
|
||||||
|
|
||||||
|
<select id="selectData" resultType="com.ruoyi.job.domain.MeRain"> |
||||||
|
select stcd , tm ,min(value) as value from me_rain |
||||||
|
where stcd = #{stcd} and tm>=to_date(#{startTime},'YYYY-MM-DD HH24:MI:SS') and tm<=to_date(#{endTime},'YYYY-MM-DD HH24:MI:SS') |
||||||
|
group by stcd , tm order by tm asc |
||||||
|
</select> |
||||||
|
|
||||||
|
</mapper> |
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue