From f33b657baede548cae520e4e2c23cc8278da3707 Mon Sep 17 00:00:00 2001 From: hzj <826100833@qq.com> Date: Tue, 6 Jan 2026 09:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=80=81=E6=96=87=E4=BB=B6=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E4=BA=8C=E6=AC=A1=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filesync/pom.xml | 6 + .../njcn/device/mapper/PqDeviceMapper.java | 2 +- .../device/mapper/RmpEventDetailMapper.java | 32 ++++ .../device/mapper/mapping/PqDeviceMapper.xml | 10 ++ .../mapper/mapping/RmpEventDetailMapper.xml | 29 ++++ .../njcn/device/pojo/po/RmpEventDetailPO.java | 127 ++++++++++++++++ .../controller/FileSyncController.java | 16 +- .../filesync/service/FileSyncService.java | 2 + .../service/impl/FileSyncServiceImpl.java | 57 ++++++- .../filesync/sftp/IncrementalFileSync.java | 120 ++++++++++++++- .../java/com/njcn/job/EventWavePathJob.java | 41 +++++ .../main/java/com/njcn/job/FileSyncJob.java | 95 ++++++------ .../main/resources/application-hn_prod.yml | 104 +++++++++++++ .../main/resources/application-wuxi_dev.yml | 20 +-- .../main/resources/application-wuxi_prod.yml | 104 +++++++++++++ filesync/src/main/resources/application.yml | 2 +- filesync/src/main/resources/logback.xml | 142 ++++++++++++++++++ .../com/njcn/influx/bo/param/TableEnum.java | 2 +- .../com/njcn/influx/bo/po/InfluxDBDataV.java | 2 +- 19 files changed, 838 insertions(+), 75 deletions(-) create mode 100644 filesync/src/main/java/com/njcn/device/mapper/RmpEventDetailMapper.java create mode 100644 filesync/src/main/java/com/njcn/device/mapper/mapping/PqDeviceMapper.xml create mode 100644 filesync/src/main/java/com/njcn/device/mapper/mapping/RmpEventDetailMapper.xml create mode 100644 filesync/src/main/java/com/njcn/device/pojo/po/RmpEventDetailPO.java create mode 100644 filesync/src/main/java/com/njcn/job/EventWavePathJob.java create mode 100644 filesync/src/main/resources/application-hn_prod.yml create mode 100644 filesync/src/main/resources/application-wuxi_prod.yml create mode 100644 filesync/src/main/resources/logback.xml diff --git a/filesync/pom.xml b/filesync/pom.xml index fd4c5a2..0af5418 100644 --- a/filesync/pom.xml +++ b/filesync/pom.xml @@ -87,6 +87,12 @@ **/* + + src/main/java + + **/*.xml + + diff --git a/filesync/src/main/java/com/njcn/device/mapper/PqDeviceMapper.java b/filesync/src/main/java/com/njcn/device/mapper/PqDeviceMapper.java index e940a66..40f6970 100644 --- a/filesync/src/main/java/com/njcn/device/mapper/PqDeviceMapper.java +++ b/filesync/src/main/java/com/njcn/device/mapper/PqDeviceMapper.java @@ -17,5 +17,5 @@ import java.util.List; * @version V1.0.0 */ public interface PqDeviceMapper extends BaseMapper { - + PqDevice selectByLineId(@Param("lineId") String lineId); } diff --git a/filesync/src/main/java/com/njcn/device/mapper/RmpEventDetailMapper.java b/filesync/src/main/java/com/njcn/device/mapper/RmpEventDetailMapper.java new file mode 100644 index 0000000..9f0ddd6 --- /dev/null +++ b/filesync/src/main/java/com/njcn/device/mapper/RmpEventDetailMapper.java @@ -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 { + + /** + * 获取暂态事件明细 + * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 暂态事件明细 + */ + List getDetailsOfTransientEvents( + @Param("startTime") String startTime, + @Param("endTime") String endTime); + + +} diff --git a/filesync/src/main/java/com/njcn/device/mapper/mapping/PqDeviceMapper.xml b/filesync/src/main/java/com/njcn/device/mapper/mapping/PqDeviceMapper.xml new file mode 100644 index 0000000..b17adee --- /dev/null +++ b/filesync/src/main/java/com/njcn/device/mapper/mapping/PqDeviceMapper.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/filesync/src/main/java/com/njcn/device/mapper/mapping/RmpEventDetailMapper.xml b/filesync/src/main/java/com/njcn/device/mapper/mapping/RmpEventDetailMapper.xml new file mode 100644 index 0000000..dad47b0 --- /dev/null +++ b/filesync/src/main/java/com/njcn/device/mapper/mapping/RmpEventDetailMapper.xml @@ -0,0 +1,29 @@ + + + + + + + diff --git a/filesync/src/main/java/com/njcn/device/pojo/po/RmpEventDetailPO.java b/filesync/src/main/java/com/njcn/device/pojo/po/RmpEventDetailPO.java new file mode 100644 index 0000000..95da47f --- /dev/null +++ b/filesync/src/main/java/com/njcn/device/pojo/po/RmpEventDetailPO.java @@ -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; + +} + diff --git a/filesync/src/main/java/com/njcn/filesync/controller/FileSyncController.java b/filesync/src/main/java/com/njcn/filesync/controller/FileSyncController.java index c6de136..b58c9a2 100644 --- a/filesync/src/main/java/com/njcn/filesync/controller/FileSyncController.java +++ b/filesync/src/main/java/com/njcn/filesync/controller/FileSyncController.java @@ -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 EventWavePathSYnc(@RequestParam("startDateTime") String startDateTime, @RequestParam("endDateTime") String endDateTime) { + String methodDescribe = getMethodDescribe("triggerCrossSync"); + + fileSyncService.EventWavePathSYnc(startDateTime,endDateTime); + + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,true , methodDescribe); + } } diff --git a/filesync/src/main/java/com/njcn/filesync/service/FileSyncService.java b/filesync/src/main/java/com/njcn/filesync/service/FileSyncService.java index feda2fb..0450b2b 100644 --- a/filesync/src/main/java/com/njcn/filesync/service/FileSyncService.java +++ b/filesync/src/main/java/com/njcn/filesync/service/FileSyncService.java @@ -9,4 +9,6 @@ package com.njcn.filesync.service; */ public interface FileSyncService { boolean triggerCrossSync(); + + void EventWavePathSYnc(String startTime,String endTime); } diff --git a/filesync/src/main/java/com/njcn/filesync/service/impl/FileSyncServiceImpl.java b/filesync/src/main/java/com/njcn/filesync/service/impl/FileSyncServiceImpl.java index 875d683..b753542 100644 --- a/filesync/src/main/java/com/njcn/filesync/service/impl/FileSyncServiceImpl.java +++ b/filesync/src/main/java/com/njcn/filesync/service/impl/FileSyncServiceImpl.java @@ -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 list = pqDeviceService.lambdaQuery().list(); + List list =pqDeviceMapper.selectList(null); if(!CollectionUtils.isEmpty(list)){ - List ipList = list.stream().map(PqDevice::getIp).collect(Collectors.toList()); + List 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 detailsOfTransientEvents = rmpEventDetailMapper.selectList(new LambdaQueryWrapper().between(RmpEventDetailPO::getStartTime,startTime,endTime)); + List 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(); } } diff --git a/filesync/src/main/java/com/njcn/filesync/sftp/IncrementalFileSync.java b/filesync/src/main/java/com/njcn/filesync/sftp/IncrementalFileSync.java index f823155..286c847 100644 --- a/filesync/src/main/java/com/njcn/filesync/sftp/IncrementalFileSync.java +++ b/filesync/src/main/java/com/njcn/filesync/sftp/IncrementalFileSync.java @@ -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 ipList; + private List pathList; private boolean isMonitoring = false; - public IncrementalFileSync(ServerConfig sourceConfig, ServerConfig targetConfig, String stateFilePath,List ipList) { + public IncrementalFileSync(ServerConfig sourceConfig, ServerConfig targetConfig, String stateFilePath,List ipList,List 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 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 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(); // 如果源文件的修改时间晚于目标文件,则需要同步 diff --git a/filesync/src/main/java/com/njcn/job/EventWavePathJob.java b/filesync/src/main/java/com/njcn/job/EventWavePathJob.java new file mode 100644 index 0000000..f2c4ec7 --- /dev/null +++ b/filesync/src/main/java/com/njcn/job/EventWavePathJob.java @@ -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"); + + + } +} diff --git a/filesync/src/main/java/com/njcn/job/FileSyncJob.java b/filesync/src/main/java/com/njcn/job/FileSyncJob.java index cdac6dd..6b6069b 100644 --- a/filesync/src/main/java/com/njcn/job/FileSyncJob.java +++ b/filesync/src/main/java/com/njcn/job/FileSyncJob.java @@ -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(); +// +// +// } +// +// +//} diff --git a/filesync/src/main/resources/application-hn_prod.yml b/filesync/src/main/resources/application-hn_prod.yml new file mode 100644 index 0000000..b90e76c --- /dev/null +++ b/filesync/src/main/resources/application-hn_prod.yml @@ -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: + + + diff --git a/filesync/src/main/resources/application-wuxi_dev.yml b/filesync/src/main/resources/application-wuxi_dev.yml index 0643017..22745e8 100644 --- a/filesync/src/main/resources/application-wuxi_dev.yml +++ b/filesync/src/main/resources/application-wuxi_dev.yml @@ -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: diff --git a/filesync/src/main/resources/application-wuxi_prod.yml b/filesync/src/main/resources/application-wuxi_prod.yml new file mode 100644 index 0000000..f25dbb9 --- /dev/null +++ b/filesync/src/main/resources/application-wuxi_prod.yml @@ -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: + + + diff --git a/filesync/src/main/resources/application.yml b/filesync/src/main/resources/application.yml index 5ca7e06..90b5c41 100644 --- a/filesync/src/main/resources/application.yml +++ b/filesync/src/main/resources/application.yml @@ -9,7 +9,7 @@ spring: name: file-sync profiles: - active: wuxi_dev + active: hn_prod jackson: diff --git a/filesync/src/main/resources/logback.xml b/filesync/src/main/resources/logback.xml new file mode 100644 index 0000000..bc83c7f --- /dev/null +++ b/filesync/src/main/resources/logback.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %logger{36} - %msg%n + UTF-8 + + + + + + + + ${logHomeDir}/${log.projectName}/debug/debug.log + + + + + DEBUG + + ACCEPT + + DENY + + + + + + ${logHomeDir}/${log.projectName}/debug/debug.log.%d{yyyy-MM-dd}.%i.log + + 10MB + + ${log.maxHistory:-30} + + + + + + + + + + ${log.pattern} + + UTF-8 + + + + + + + INFO + ACCEPT + DENY + + + ${logHomeDir}/${log.projectName}/info/info.log + + + + ${logHomeDir}/${log.projectName}/info/info.log.%d{yyyy-MM-dd}.%i.log + + 10MB + ${log.maxHistory:-30} + + + + ${log.pattern} + + UTF-8 + + + + + + + + ${logHomeDir}/${log.projectName}/error/error.log + + + ERROR + ACCEPT + DENY + + + + ${logHomeDir}/${log.projectName}/error/error.log.%d{yyyy-MM-dd}.%i.log + + 10MB + ${log.maxHistory:-30} + + + + ${log.pattern} + + UTF-8 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/influx-data/influx-source/src/main/java/com/njcn/influx/bo/param/TableEnum.java b/influx-data/influx-source/src/main/java/com/njcn/influx/bo/param/TableEnum.java index c618c33..ed2135e 100644 --- a/influx-data/influx-source/src/main/java/com/njcn/influx/bo/param/TableEnum.java +++ b/influx-data/influx-source/src/main/java/com/njcn/influx/bo/param/TableEnum.java @@ -29,7 +29,7 @@ public enum TableEnum { DATAI("DataI","谐波电流幅值数据表", 4), DATAPLT("DataPlt","长时闪变数据表", 1), DATAV("DataV","谐波电压幅值数据表", 4), -// COMINFORMATION("ComInfoRmation","监测点状态监测数据", 4), + COMINFORMATION("ComInfoRmation","监测点状态监测数据", 4), ; diff --git a/influx-data/influx-source/src/main/java/com/njcn/influx/bo/po/InfluxDBDataV.java b/influx-data/influx-source/src/main/java/com/njcn/influx/bo/po/InfluxDBDataV.java index 08eb75e..116b052 100644 --- a/influx-data/influx-source/src/main/java/com/njcn/influx/bo/po/InfluxDBDataV.java +++ b/influx-data/influx-source/src/main/java/com/njcn/influx/bo/po/InfluxDBDataV.java @@ -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());