暂态文件同步二次开发

This commit is contained in:
hzj
2026-01-06 09:53:36 +08:00
parent b9fb336cac
commit f33b657bae
19 changed files with 838 additions and 75 deletions

View File

@@ -87,6 +87,12 @@
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
</project>

View File

@@ -17,5 +17,5 @@ import java.util.List;
* @version V1.0.0
*/
public interface PqDeviceMapper extends BaseMapper<PqDevice> {
PqDevice selectByLineId(@Param("lineId") String lineId);
}

View File

@@ -0,0 +1,32 @@
package com.njcn.device.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.pojo.po.RmpEventDetailPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 暂态事件明细
*
* @author yzh
* @date 2022/10/12
*/
@Mapper
public interface RmpEventDetailMapper extends BaseMapper<RmpEventDetailPO> {
/**
* 获取暂态事件明细
*
* @param startTime 开始时间
* @param endTime 结束时间
* @return 暂态事件明细
*/
List<RmpEventDetailPO> getDetailsOfTransientEvents(
@Param("startTime") String startTime,
@Param("endTime") String endTime);
}

View File

@@ -0,0 +1,10 @@
<?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.njcn.device.mapper.PqDeviceMapper">
<select id="selectByLineId" resultType="com.njcn.device.pojo.po.PqDevice">
select a.* FROM pq_device a , pq_line pl where a.Id = SUBSTRING_INDEX(SUBSTRING_INDEX(pl.Pids, ',', 5), ',', -1) and pl.id =#{lineId};
</select>
</mapper>

View File

@@ -0,0 +1,29 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.device.mapper.RmpEventDetailMapper">
<select id="getDetailsOfTransientEvents" resultType="com.njcn.device.pojo.po.RmpEventDetailPO">
SELECT
event_id as eventId,
measurement_point_id as measurementPointId,
Event_Type as eventType,
start_time as startTime,
Duration as duration,
feature_amplitude as featureAmplitude,
phase as phase,
event_describe as eventDescribe,
wave_path as wavePath
FROM
r_mp_event_detail
WHERE
1=1
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') &gt;= DATE_FORMAT(#{startTime}, '%Y-%m-%d %H:%i:%s')
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d %H:%i:%s')
</if>
order by start_time desc
</select>
</mapper>

View File

@@ -0,0 +1,127 @@
package com.njcn.device.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 暂降明细实体类
*
* @author yzh
* @since 2022-10-12 18:34:55
*/
@Data
@TableName("r_mp_event_detail")
@ApiModel(value="RmpEventDetail对象")
public class RmpEventDetailPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "暂时事件ID")
@TableId(value = "event_id", type = IdType.ASSIGN_ID)
private String eventId;
@ApiModelProperty(value = "监测点ID")
private String measurementPointId;
@ApiModelProperty(value = "监测点ID(复制)")
@TableField("measurement_point_id")
private String lineId;
@ApiModelProperty(value = "统计类型")
private String eventType;
@ApiModelProperty(value = "暂降原因Event_Reason")
@TableField("advance_reason")
private String advanceReason;
@ApiModelProperty(value = "暂降类型Event_Type")
@TableField("advance_type")
private String advanceType;
@ApiModelProperty(value = "事件关联分析表Guid")
private String eventassIndex;
@ApiModelProperty(value = "dq计算持续时间 ")
private Double dqTime;
@ApiModelProperty(value = "特征值计算更新时间外键PQS_Relevance的Time字段")
private LocalDateTime dealTime;
@ApiModelProperty(value = "默认事件个数为0")
private Integer num;
@ApiModelProperty(value = "波形文件是否从装置招到本地(0未招1已招)默认值为0")
private Integer fileFlag;
@ApiModelProperty(value = "特征值计算标志0未处理1已处理; 2已处理无结果;3计算失败默认值为0")
private Integer dealFlag;
@ApiModelProperty(value = "处理结果第一条事件发生时间(读comtra文件获取)")
private LocalDateTime firstTime;
@ApiModelProperty(value = "处理结果第一条事件暂降类型字典表PQS_Dicdata")
private String firstType;
@ApiModelProperty(value = "处理结果第一条事件发生时间毫秒(读comtra文件获取)")
private Double firstMs;
@ApiModelProperty(value = "暂降能量")
private Double energy;
@ApiModelProperty(value = "暂降严重度")
private Double severity;
@ApiModelProperty(value = "暂降源与监测位置关系 Upper:上游Lower :下游Unknown :未知;为空则是未计算")
private String sagsource;
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime startTime;
@ApiModelProperty(value = "格式化开始时间")
@TableField(exist = false)
private String formatTime;
@ApiModelProperty(value = "持续时间,单位秒")
private Double duration;
@ApiModelProperty(value = "特征幅值")
private Double featureAmplitude;
@ApiModelProperty(value = "相别")
private String phase;
@ApiModelProperty(value = "事件描述")
private String eventDescribe;
@ApiModelProperty(value = "波形路径")
private String wavePath;
@ApiModelProperty(value = "暂降核实原因")
@TableField("verify_reason")
private String verifyReason;
@ApiModelProperty(value = "暂降核实原因详情")
@TableField("verify_reason_detail")
private String verifyReasonDetail;
private Double transientValue;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "用于计算数量")
@TableField(exist = false)
private Integer count;
}

View File

@@ -13,10 +13,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@@ -48,4 +45,15 @@ public class FileSyncController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,flag , methodDescribe);
}
@GetMapping("/EventWavePathSYnc")
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@ApiOperation("暂态文件同步手动触发")
public HttpResult<Boolean> EventWavePathSYnc(@RequestParam("startDateTime") String startDateTime, @RequestParam("endDateTime") String endDateTime) {
String methodDescribe = getMethodDescribe("triggerCrossSync");
fileSyncService.EventWavePathSYnc(startDateTime,endDateTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,true , methodDescribe);
}
}

View File

@@ -9,4 +9,6 @@ package com.njcn.filesync.service;
*/
public interface FileSyncService {
boolean triggerCrossSync();
void EventWavePathSYnc(String startTime,String endTime);
}

View File

@@ -1,6 +1,12 @@
package com.njcn.filesync.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.device.mapper.PqDeviceMapper;
import com.njcn.device.mapper.RmpEventDetailMapper;
import com.njcn.device.pojo.po.PqDevice;
import com.njcn.device.pojo.po.RmpEventDetailPO;
import com.njcn.device.service.PqDeviceService;
import com.njcn.filesync.config.ServerConfig;
import com.njcn.filesync.config.SourceConfig;
@@ -9,11 +15,16 @@ import com.njcn.filesync.service.FileSyncService;
import com.njcn.filesync.sftp.IncrementalFileSync;
import jdk.nashorn.internal.ir.annotations.Reference;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -25,26 +36,64 @@ import java.util.stream.Collectors;
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class FileSyncServiceImpl implements FileSyncService {
private final SourceConfig sourceConfig;
private final TargetConfig targetConfig;
private final PqDeviceService pqDeviceService;
private final PqDeviceMapper pqDeviceMapper;
private final RmpEventDetailMapper rmpEventDetailMapper;
@Override
public boolean triggerCrossSync() {
log.info("begintriggerCrossSync"+ LocalDateTime.now());
ServerConfig source = new ServerConfig();
ServerConfig target = new ServerConfig();
BeanUtils.copyProperties(sourceConfig,source);
BeanUtils.copyProperties(targetConfig,target);
List<PqDevice> list = pqDeviceService.lambdaQuery().list();
List<PqDevice> list =pqDeviceMapper.selectList(null);
if(!CollectionUtils.isEmpty(list)){
List<String> ipList = list.stream().map(PqDevice::getIp).collect(Collectors.toList());
List<String> ipList = list.stream().map(PqDevice::getIp).collect(Collectors.toList());
System.out.println("ipList"+ipList);
IncrementalFileSync fileSync = new IncrementalFileSync(
source, target, "sync-state.json",ipList);
source, target, "sync-state.json",ipList,new ArrayList<>());
// 同步文件
fileSync.syncOnce();
}
log.info("endtriggerCrossSync"+ LocalDateTime.now());
return true;
}
@Override
public void EventWavePathSYnc(String startTime,String endTime ) {
List<RmpEventDetailPO> detailsOfTransientEvents = rmpEventDetailMapper.selectList(new LambdaQueryWrapper<RmpEventDetailPO>().between(RmpEventDetailPO::getStartTime,startTime,endTime));
List<String> pathList = new ArrayList<>();
for (RmpEventDetailPO detailsOfTransientEvent : detailsOfTransientEvents) {
String lineId = detailsOfTransientEvent.getLineId();
PqDevice pqDevice = pqDeviceMapper.selectByLineId(lineId);
if(Objects.nonNull(detailsOfTransientEvent.getWavePath())){
String path = pqDevice.getIp()+"/"+detailsOfTransientEvent.getWavePath()+".CFG";
pathList.add(path);
String path2 = pqDevice.getIp()+"/"+detailsOfTransientEvent.getWavePath()+".DAT";
pathList.add(path2);
String path3 = pqDevice.getIp()+"/"+detailsOfTransientEvent.getWavePath()+".cfg";
pathList.add(path3);
String path4= pqDevice.getIp()+"/"+detailsOfTransientEvent.getWavePath()+".dat";
pathList.add(path4);
}
}
ServerConfig source = new ServerConfig();
ServerConfig target = new ServerConfig();
BeanUtils.copyProperties(sourceConfig,source);
BeanUtils.copyProperties(targetConfig,target);
IncrementalFileSync fileSync = new IncrementalFileSync(
source, target, "sync-state.json",new ArrayList<>(),pathList);
// 同步文件
fileSync.syncOnceByPathList();
}
}

View File

@@ -14,6 +14,7 @@ import java.io.InputStream;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.Objects;
import java.util.Vector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -35,28 +36,32 @@ public class IncrementalFileSync {
// private ScheduledExecutorService scheduler;
private WatchService watchService;
private List<String> ipList;
private List<String> pathList;
private boolean isMonitoring = false;
public IncrementalFileSync(ServerConfig sourceConfig, ServerConfig targetConfig, String stateFilePath,List<String> ipList) {
public IncrementalFileSync(ServerConfig sourceConfig, ServerConfig targetConfig, String stateFilePath,List<String> ipList,List<String> pathList) {
this.sourceConfig = sourceConfig;
this.targetConfig = targetConfig;
this.syncState = new FileSyncState(stateFilePath);
// this.scheduler = Executors.newScheduledThreadPool(2);
this.ipList = ipList;
this.pathList = pathList;
}
/**
* 执行一次增量同步
*/
public void syncOnce() {
logger.info("Starting incremental synchronization...");
logger.info("Starting incremental synchronization...");
try (SftpClient sourceClient = new SftpClient();
SftpClient targetClient = new SftpClient()) {
// 连接到源服务器和目标服务器
sourceClient.connect(sourceConfig);
logger.info("sourceClient concet succss");
targetClient.connect(targetConfig);
logger.info("targetClient concet succss");
// 同步文件
syncDirectory("", sourceClient, targetClient);
@@ -70,6 +75,105 @@ public class IncrementalFileSync {
}
}
public void syncOnceByPathList() {
logger.info("Starting incremental synchronization...");
try (SftpClient sourceClient = new SftpClient();
SftpClient targetClient = new SftpClient()) {
// 连接到源服务器和目标服务器
sourceClient.connect(sourceConfig);
logger.info("sourceClient concet succss");
targetClient.connect(targetConfig);
logger.info("targetClient concet succss");
// 同步文件
syncPathList( sourceClient, targetClient,pathList);
logger.info("Incremental synchronization completed successfully");
} catch (Exception e) {
logger.error("Synchronization failed", e);
} finally {
syncState.saveState();
}
}
private void syncPathList(SftpClient sourceClient, SftpClient targetClient, List<String> pathList) throws SftpException {
ChannelSftp destSftp = targetClient.getChannel();
ChannelSftp sourceSftp = sourceClient.getChannel();
logger.info("-----------------------------------------------beginsyncByPathList----------------------");
for (String path : pathList) {
String sourceFilePath="";
if(sourceConfig.getBasePath().endsWith("/")){
sourceFilePath = sourceConfig.getBasePath() + path;
}else {
sourceFilePath = sourceConfig.getBasePath() + "/" + path;
}
String destFilePath = targetConfig.getBasePath() + "/" + path;
boolean flag = safeFileExists(sourceSftp, sourceFilePath);
if(flag){
boolean needSync = safeFileExists(destSftp, destFilePath);
if(!needSync){
logger.info(sourceFilePath+"同步成功");
// 上传文件
try (InputStream inputStream = sourceSftp.get(sourceFilePath)) {
int lastSlashIndex = destFilePath.lastIndexOf('/');
String directoryPath = destFilePath.substring(0, lastSlashIndex);
targetClient.createRemoteDirectory(directoryPath);
destSftp.put(inputStream, destFilePath);
// System.out.println("Synced: " + sourceFilePath);
} catch (Exception e) {
e.printStackTrace();
}
}
}else {
continue;
}
}
}
public boolean safeFileExists(ChannelSftp sftpChannel, String remotePath) {
// 1. 基础检查
if (remotePath == null || remotePath.trim().isEmpty()) {
return false;
}
// 2. 检查连接 (根据你的JSch版本和封装方式)
if (sftpChannel == null || !sftpChannel.isConnected()) {
logger.warn("SFTP channel is not connected.");
return false;
}
// 3. 尝试获取属性判断存在性
try {
sftpChannel.lstat(remotePath);
return true;
} catch (SftpException e) {
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
return false;
} else {
// 记录非“文件不存在”的其他异常(如权限问题)
logger.error("SFTP error while checking file existence: " + remotePath, e);
// 根据业务逻辑决定返回false或抛出异常
return false;
}
} catch (Exception e) {
// 处理其他意外异常,如网络中断
logger.error("Unexpected error checking file existence: " + remotePath, e);
return false;
}
}
/**
* 开始定时同步
*/
@@ -209,6 +313,7 @@ public class IncrementalFileSync {
private void syncRemoteDirectory(SftpClient sourceClient, SftpClient destClient, String sourceDir, String destDir) throws SftpException {
ChannelSftp destSftp = destClient.getChannel();
ChannelSftp sourceSftp = sourceClient.getChannel();
logger.info("-----------------------------------------------beginsyncRemoteDirectory----------------------");
// 获取源目录下的文件列表
Vector<ChannelSftp.LsEntry> files = sourceSftp.ls(sourceDir);
@@ -238,13 +343,11 @@ public class IncrementalFileSync {
// 传输文件
try (InputStream inputStream = sourceSftp.get(sourceFilePath)) {
destSftp.put(inputStream, destFilePath);
System.out.println("Synced: " + sourceFilePath);
// System.out.println("Synced: " + sourceFilePath);
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.out.println("Skipped: " + sourceFilePath);
}
}
}
@@ -256,6 +359,12 @@ public class IncrementalFileSync {
private boolean needSync(ChannelSftp sourceSftp, ChannelSftp destSftp, String sourcePath, String destPath, ChannelSftp.LsEntry sourceEntry) throws SftpException {
// 判断目标文件是否存在
SftpATTRS destAttrs;
long sourceMTime = sourceEntry.getAttrs().getMTime();
long currentTimeSeconds = System.currentTimeMillis() / 1000;
long halfYearSeconds = 100L * 24 * 60 * 60; // 假设半年为180天
if (sourceMTime < currentTimeSeconds - halfYearSeconds) {
return false;
}
try {
destAttrs = destSftp.lstat(destPath);
} catch (SftpException e) {
@@ -264,7 +373,6 @@ public class IncrementalFileSync {
}
// 比较文件的修改时间
long sourceMTime = sourceEntry.getAttrs().getMTime();
long destMTime = destAttrs.getMTime();
// 如果源文件的修改时间晚于目标文件,则需要同步

View File

@@ -0,0 +1,41 @@
package com.njcn.job;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.njcn.filesync.service.FileSyncService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* Description:
* Date: 2025/12/08 上午 10:47【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Component
@EnableScheduling
@RequiredArgsConstructor
@Slf4j
public class EventWavePathJob {
private final FileSyncService fileSyncService;
// 每10分钟执行
@Scheduled(cron = "0 0/10 * * * ? ")
public void UpHarmonicJob(){
String endTime = LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.NORM_DATETIME_PATTERN);
String startTime =LocalDateTimeUtil.format(LocalDateTime.now().minusMinutes(30), DatePattern.NORM_DATETIME_PATTERN);
log.info("begin sync------------------" +
startTime+"---"+endTime+"eventFile");
fileSyncService.EventWavePathSYnc(startTime,endTime);
log.info("end sync------------------" +
startTime+"---"+endTime+"eventFile");
}
}

View File

@@ -1,47 +1,48 @@
package com.njcn.job;
import com.njcn.device.pojo.po.PqDevice;
import com.njcn.device.service.PqDeviceService;
import com.njcn.filesync.config.*;
import com.njcn.filesync.service.FileSyncService;
import com.njcn.filesync.sftp.IncrementalFileSync;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Author: cdf
* @CreateTime: 2025-09-19
* @Description: 定时任务
*/
@Component
@EnableScheduling
@RequiredArgsConstructor
@Slf4j
public class FileSyncJob {
private final SourceConfig sourceConfig;
private final TargetConfig targetConfig;
private final PqDeviceService pqDeviceService;
private final FileSyncService fileSyncService;
// 每10分钟执行
@Scheduled(cron = "0 0/10 * * * ? ")
public void UpHarmonicJob(){
fileSyncService.triggerCrossSync();
}
}
//package com.njcn.job;
//
//import com.njcn.device.pojo.po.PqDevice;
//import com.njcn.device.service.PqDeviceService;
//import com.njcn.filesync.config.*;
//import com.njcn.filesync.service.FileSyncService;
//import com.njcn.filesync.sftp.IncrementalFileSync;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.BeanUtils;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.util.CollectionUtils;
//
//import java.time.LocalDateTime;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
///**
// * @Author: cdf
// * @CreateTime: 2025-09-19
// * @Description: 定时任务
// */
//@Component
//@EnableScheduling
//@RequiredArgsConstructor
//@Slf4j
//public class FileSyncJob {
//
// private final SourceConfig sourceConfig;
// private final TargetConfig targetConfig;
// private final PqDeviceService pqDeviceService;
//
// private final FileSyncService fileSyncService;
// // 每10分钟执行
// @Scheduled(cron = "0 0/10 * * * ? ")
// public void UpHarmonicJob(){
//
// fileSyncService.triggerCrossSync();
//
//
// }
//
//
//}

View File

@@ -0,0 +1,104 @@
#当前服务的基本信息
spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.95.53.49:13306/pqsinfo_hn?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
username: root
password: njcnpqs
# url: jdbc:mysql://localhost:3306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
# username: root
# password: root
#初始化建立物理连接的个数、最小、最大连接数
initial-size: 5
min-idle: 5
max-active: 50
#获取连接最大等待时间,单位毫秒
max-wait: 60000
#链接保持空间而不被驱逐的最长时间,单位毫秒
min-evictable-idle-time-millis: 300000
validation-query: select 1
test-while-idle: true
test-on-borrow: false
test-on-return: false
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
#influxDB内容配置
influx:
url: http://192.168.1.103:18086
user: admin
password: 123456
database: pqsbase_wx
mapper-location: com.njcn.**.imapper
#mybatis配置信息
mybatis-plus:
mapper-locations: classpath*:com/njcn/**/mapping/*.xml
#别名扫描
type-aliases-package: com.njcn.product.**.pojo
configuration:
#驼峰命名
map-underscore-to-camel-case: true
#配置sql日志输出
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# #关闭日志输出
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
global-config:
db-config:
#指定主键生成策略
id-type: assign_uuid
db:
type: mysql
#文件位置配置
business:
#处理波形数据位置
# wavePath: D://comtrade
wavePath: /usr/local/comtrade
#处理临时数据
#tempPath: D://file
tempPath: /usr/local/file
#文件存储的方式 1.本地
file:
storage: 1
#localStoragePath: /usr/local/localStoragePath
localStoragePath: D://localStoragePath
#oss服务器配置
min:
io:
endpoint: http://192.168.1.22:9009
accessKey: minio
secretKey: minio@123
bucket: excelreport
#华为obs服务器配置
huawei:
access-key: J9GS9EA79PZ60OK23LWP
security-key: BirGrAFDSLxU8ow5fffyXgZRAmMRb1R1AdqCI60d
obs:
bucket: test-8601
endpoint: https://obs.cn-east-3.myhuaweicloud.com
# 单位为秒
expire: 3600
server:
source:
host: 10.95.53.20
port: 9388
username: test
password: njcnpqs
basePath: /
privateKeyPath:
target:
host: 10.95.53.49
port: 9389
username: hndnzl
password: '@#001njcnPQS'
basePath: /home/hndnzl
privateKeyPath:

View File

@@ -3,7 +3,7 @@ spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.24:13306/pqsinfo_wuxi?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://127.0.0.1:3306/pqsinfo_jb?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
username: root
password: njcnpqs
# url: jdbc:mysql://localhost:3306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
@@ -47,7 +47,7 @@ mybatis-plus:
#配置sql日志输出
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# #关闭日志输出
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
global-config:
db-config:
#指定主键生成策略
@@ -86,18 +86,18 @@ huawei:
server:
source:
host: 192.168.1.63
host: 127.0.0.1
port: 22
username: root
password: dnzl@#001
basePath: /
username: test
password: 123456
basePath: /D:/comtrade
privateKeyPath:
target:
host: 192.168.1.103
host: 127.0.0.1
port: 22
username: root
password: dnzl@#001
basePath: /usr/local/wuxi
username: test
password: 123456
basePath: /D:/comtrade2
privateKeyPath:

View File

@@ -0,0 +1,104 @@
#当前服务的基本信息
spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.103:13306/pqsinfo_wuxi?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
username: root
password: njcnpqs
# url: jdbc:mysql://localhost:3306/pqs91001?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
# username: root
# password: root
#初始化建立物理连接的个数、最小、最大连接数
initial-size: 5
min-idle: 5
max-active: 50
#获取连接最大等待时间,单位毫秒
max-wait: 60000
#链接保持空间而不被驱逐的最长时间,单位毫秒
min-evictable-idle-time-millis: 300000
validation-query: select 1
test-while-idle: true
test-on-borrow: false
test-on-return: false
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
#influxDB内容配置
influx:
url: http://192.168.1.103:18086
user: admin
password: 123456
database: pqsbase_wx
mapper-location: com.njcn.**.imapper
#mybatis配置信息
mybatis-plus:
mapper-locations: classpath*:com/njcn/**/mapping/*.xml
#别名扫描
type-aliases-package: com.njcn.product.**.pojo
configuration:
#驼峰命名
map-underscore-to-camel-case: true
#配置sql日志输出
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# #关闭日志输出
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
global-config:
db-config:
#指定主键生成策略
id-type: assign_uuid
db:
type: mysql
#文件位置配置
business:
#处理波形数据位置
# wavePath: D://comtrade
wavePath: /usr/local/comtrade
#处理临时数据
#tempPath: D://file
tempPath: /usr/local/file
#文件存储的方式 1.本地
file:
storage: 1
#localStoragePath: /usr/local/localStoragePath
localStoragePath: D://localStoragePath
#oss服务器配置
min:
io:
endpoint: http://192.168.1.22:9009
accessKey: minio
secretKey: minio@123
bucket: excelreport
#华为obs服务器配置
huawei:
access-key: J9GS9EA79PZ60OK23LWP
security-key: BirGrAFDSLxU8ow5fffyXgZRAmMRb1R1AdqCI60d
obs:
bucket: test-8601
endpoint: https://obs.cn-east-3.myhuaweicloud.com
# 单位为秒
expire: 3600
server:
source:
host: 192.168.1.82
port: 22
username: root
password: dnzl@#001
basePath: /
privateKeyPath:
target:
host: 192.168.1.103
port: 22
username: root
password: dnzl@#001
basePath: /usr/local/comtrade
privateKeyPath:

View File

@@ -9,7 +9,7 @@ spring:
name: file-sync
profiles:
active: wuxi_dev
active: hn_prod
jackson:

View File

@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="20 seconds" debug="false">
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<!-- 直接使用固定配置避免Spring配置解析时机问题 -->
<property name="log.projectName" value="file-sync"/>
<property name="logCommonLevel" value="info"/>
<property name="logHomeDir" value="F:\logs"/>
<!-- <property name="logHomeDir" value="usr/local/logs"/>-->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="ec"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!--日志输出格式-->
<property name="log.pattern"
value="|-%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%level} ${log.projectName} -- %t %logger{100}.%M ==> %m%n${Log_EXCEPTION_CONVERSION_WORD:-%ec}}}"/>
<property name="log.maxHistory" value="30"/>
<!--客户端输出日志-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- 自动高亮日志级别ERROR=红色, WARN=黄色, INFO=绿色等) -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %logger{36} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!--系统中常规的debug日志-->
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender -->
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>
${logHomeDir}/${log.projectName}/debug/debug.log
</file>
<!-- 如果日志级别等于配置级别过滤器会根据onMath 和 onMismatch接收或拒绝日志。 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 设置过滤级别 -->
<level>DEBUG</level>
<!-- 用于配置符合过滤条件的操作 -->
<onMatch>ACCEPT</onMatch>
<!-- 用于配置不符合过滤条件的操作 -->
<onMismatch>DENY</onMismatch>
</filter>
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责触发滚动 SizeAndTimeBasedRollingPolicy-->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志输出位置 可相对、和绝对路径 -->
<fileNamePattern>
${logHomeDir}/${log.projectName}/debug/debug.log.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件,假设设置每个月滚动,且<maxHistory>是6
则只保存最近6个月的文件删除之前的旧文件。注意删除旧文件是那些为了归档而创建的目录也会被删除 -->
<maxHistory>${log.maxHistory:-30}</maxHistory>
<!--重启清理日志文件-->
<!-- <cleanHistoryOnStart>true</cleanHistoryOnStart>-->
<!--每个文件最多100MB保留N天的历史记录但最多20GB-->
<!--<totalSizeCap>20GB</totalSizeCap>-->
<!--日志文件最大的大小-->
<!--<MaxFileSize>${log.maxSize}</MaxFileSize>-->
</rollingPolicy>
<encoder>
<pattern>
${log.pattern}
</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!--系统中常规的info日志-->
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>
${logHomeDir}/${log.projectName}/info/info.log
</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${logHomeDir}/${log.projectName}/info/info.log.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>${log.maxHistory:-30}</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
${log.pattern}
</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!--系统中常规的error日志-->
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>
${logHomeDir}/${log.projectName}/error/error.log
</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${logHomeDir}/${log.projectName}/error/error.log.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>${log.maxHistory:-30}</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>
${log.pattern}
</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR"/>
<logger name="org.apache.catalina.util.LifecycleBase" level="ERROR"/>
<logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN"/>
<logger name="com.njcn" level="INFO" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="DEBUG"/>
<appender-ref ref="INFO"/>
<appender-ref ref="ERROR"/>
</logger>
<root level="${logCommonLevel}">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="DEBUG"/>
<appender-ref ref="INFO"/>
<appender-ref ref="ERROR"/>
</root>
</configuration>

View File

@@ -29,7 +29,7 @@ public enum TableEnum {
DATAI("DataI","谐波电流幅值数据表", 4),
DATAPLT("DataPlt","长时闪变数据表", 1),
DATAV("DataV","谐波电压幅值数据表", 4),
// COMINFORMATION("ComInfoRmation","监测点状态监测数据", 4),
COMINFORMATION("ComInfoRmation","监测点状态监测数据", 4),
;

View File

@@ -305,7 +305,7 @@ public class InfluxDBDataV {
influxDBDataV.setFreq(dataV.getFreq());
influxDBDataV.setFreqDev(dataV.getFreqDev());
influxDBDataV.setRms(dataV.getRms());
influxDBDataV.setRmsLvr(dataV.getRmsab());
// influxDBDataV.setRmsLvr(dataV.getRmsab());
influxDBDataV.setVlDev(dataV.getVlDev());
influxDBDataV.setVuDev(dataV.getVuDev());