1.oracle同步mysql代码,监测点运行状态
This commit is contained in:
@@ -47,7 +47,7 @@ public class OracleToInfluxDBJob {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
//每小时03分钟时执行上一个小时的数据同步
|
//每小时03分钟时执行上一个小时的数据同步
|
||||||
@Scheduled(cron="0 3 * * * ?")
|
@Scheduled(cron="0/10 0 * * * ?")
|
||||||
public void executeHours() {
|
public void executeHours() {
|
||||||
DataAsynParam dataAsynParam = new DataAsynParam();
|
DataAsynParam dataAsynParam = new DataAsynParam();
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
package com.njcn.mysql.bo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2024-06-05
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("pq_line_detail")
|
||||||
|
public class PqLineDetail {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点序号
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线路号(在同一台设备中的监测点号)
|
||||||
|
*/
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PT一次变比
|
||||||
|
*/
|
||||||
|
private Float pt1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PT二次变比
|
||||||
|
*/
|
||||||
|
private Float pt2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CT一次变比
|
||||||
|
*/
|
||||||
|
private Float ct1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CT二次变比
|
||||||
|
*/
|
||||||
|
private Float ct2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备容量
|
||||||
|
*/
|
||||||
|
private Float devCapacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短路容量
|
||||||
|
*/
|
||||||
|
private Float shortCapacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基准容量
|
||||||
|
*/
|
||||||
|
private Float standardCapacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 协议容量
|
||||||
|
*/
|
||||||
|
private Float dealCapacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接线类型(0:星型接法;1:三角型接法;2:开口三角型接法)
|
||||||
|
*/
|
||||||
|
private Boolean ptType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测量间隔(1-10分钟)
|
||||||
|
*/
|
||||||
|
private Integer timeInterval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 干扰源类型,字典表
|
||||||
|
*/
|
||||||
|
private String loadType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行业类型,字典表
|
||||||
|
*/
|
||||||
|
private String businessType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网公司谐波监测平台标志(0-否;1-是),默认否
|
||||||
|
*/
|
||||||
|
private Boolean monitorFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电网标志(0-电网侧;1-非电网侧)
|
||||||
|
*/
|
||||||
|
private Boolean powerFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国网谐波监测平台监测点号
|
||||||
|
*/
|
||||||
|
private String monitorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点对象名称
|
||||||
|
*/
|
||||||
|
private String objName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人为干预是否参与统计(0:不参与,1:参与)默认参与统计
|
||||||
|
*/
|
||||||
|
private Boolean statFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端等级,关联字典表
|
||||||
|
*/
|
||||||
|
private String lineGrade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电网侧变电站
|
||||||
|
*/
|
||||||
|
private String powerSubstationName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类等级
|
||||||
|
*/
|
||||||
|
private String calssificationGrade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上级变电站
|
||||||
|
*/
|
||||||
|
private String superiorsSubstation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂接线路
|
||||||
|
*/
|
||||||
|
private String hangLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户联系人
|
||||||
|
*/
|
||||||
|
private String owner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人职务
|
||||||
|
*/
|
||||||
|
private String ownerDuty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人号码
|
||||||
|
*/
|
||||||
|
private String ownerTel;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主接线图路径
|
||||||
|
*/
|
||||||
|
private String wiringDiagram;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点接线相别(0,单相,1,三相,默认三相)
|
||||||
|
*/
|
||||||
|
private Boolean ptPhaseType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点实际安装位置
|
||||||
|
*/
|
||||||
|
private String actualArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点运行状态(0:运行;1:检修;2:停运;3:调试;4:退运)
|
||||||
|
*/
|
||||||
|
private Boolean runFlag;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -81,4 +81,12 @@ public interface OracleDataService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DayInharmV> getDayInHarmV(String time);
|
List<DayInharmV> getDayInHarmV(String time);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询oracle中PQ_Line数据
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Line> getLineList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class OracleDataServiceImpl implements OracleDataService {
|
|||||||
private final DayPltMapper dayPltMapper;
|
private final DayPltMapper dayPltMapper;
|
||||||
private final DayFlickerMapper dayFlickerMapper;
|
private final DayFlickerMapper dayFlickerMapper;
|
||||||
private final DayInharmVMapper dayInharmVMapper;
|
private final DayInharmVMapper dayInharmVMapper;
|
||||||
|
private final LineMapper lineMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -108,4 +109,9 @@ public class OracleDataServiceImpl implements OracleDataService {
|
|||||||
lambdaQueryWrapper.apply("TIMEID = to_date({0},'yyyy-mm-dd')",time);
|
lambdaQueryWrapper.apply("TIMEID = to_date({0},'yyyy-mm-dd')",time);
|
||||||
return dayInharmVMapper.selectList(lambdaQueryWrapper);
|
return dayInharmVMapper.selectList(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Line> getLineList() {
|
||||||
|
return lineMapper.selectList(new LambdaQueryWrapper<>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,16 +139,4 @@ public class OracleToMysqlController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
RStatDataPltD user = new RStatDataPltD();
|
|
||||||
user.setPlt(1101111.0f);
|
|
||||||
try {
|
|
||||||
MaxValueProcessor.process(user);
|
|
||||||
System.out.println(user.getPlt());
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Validation failed: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class OracleToMysqlDBJob {
|
|||||||
public void executeEvent() {
|
public void executeEvent() {
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
String date = DateUtil.format(LocalDateTime.now().minusDays(1), DatePattern.NORM_DATE_PATTERN);
|
String date = DateUtil.format(LocalDateTime.now().minusDays(1), DatePattern.NORM_DATE_PATTERN);
|
||||||
System.out.println("-----------------------------------------------------------------------");
|
System.out.println("-----------------------------day表同步------------------------------------------");
|
||||||
oracleToMysqlService.insertDayHarmRateV(date,date);
|
oracleToMysqlService.insertDayHarmRateV(date,date);
|
||||||
oracleToMysqlService.insertPqsIntegrity(date,date);
|
oracleToMysqlService.insertPqsIntegrity(date,date);
|
||||||
oracleToMysqlService.insertDayV(date,date);
|
oracleToMysqlService.insertDayV(date,date);
|
||||||
@@ -46,7 +46,14 @@ public class OracleToMysqlDBJob {
|
|||||||
oracleToMysqlService.insertPlt(date,date);
|
oracleToMysqlService.insertPlt(date,date);
|
||||||
oracleToMysqlService.insertFlicker(date,date);
|
oracleToMysqlService.insertFlicker(date,date);
|
||||||
oracleToMysqlService.insertInHarmV(date,date);
|
oracleToMysqlService.insertInHarmV(date,date);
|
||||||
System.out.println("-----------------------------------------------------------------------\n");
|
System.out.println("--------------------------------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron="0 0/10 * * * ?")
|
||||||
|
public void executeLineRunFlag() {
|
||||||
|
// 获取当前时间
|
||||||
|
System.out.println("--------------------------------监测点运行状态同步------------------------------------");
|
||||||
|
oracleToMysqlService.LineRunFlag();
|
||||||
|
System.out.println("-----------------------------------------------------------------------------------\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.mysql.mapper;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
|
import com.njcn.mysql.bo.po.PqLineDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2024-06-05
|
||||||
|
*/
|
||||||
|
public interface PqLineDetailMapper extends MppBaseMapper<PqLineDetail> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?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.mysql.mapper.PqLineDetailMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.mysql.service;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||||
|
import com.njcn.mysql.bo.po.PqLineDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2024-06-05
|
||||||
|
*/
|
||||||
|
public interface IPqLineDetailService extends IMppService<PqLineDetail> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -77,4 +77,11 @@ public interface OracleToMysqlService {
|
|||||||
* @param endTime
|
* @param endTime
|
||||||
*/
|
*/
|
||||||
void insertInHarmV(String startTime, String endTime);
|
void insertInHarmV(String startTime, String endTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 监测团运行状态同步
|
||||||
|
* @param
|
||||||
|
* @Author: wr
|
||||||
|
*/
|
||||||
|
void LineRunFlag();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.mysql.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.njcn.mysql.bo.enums.TargetEnum;
|
import com.njcn.mysql.bo.enums.TargetEnum;
|
||||||
import com.njcn.mysql.bo.po.*;
|
import com.njcn.mysql.bo.po.*;
|
||||||
import com.njcn.mysql.service.*;
|
import com.njcn.mysql.service.*;
|
||||||
@@ -37,6 +38,7 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
|||||||
private final IRStatDataPltDService statDataPltDService;
|
private final IRStatDataPltDService statDataPltDService;
|
||||||
private final IRStatDataFlickerDService statDataFlickerDService;
|
private final IRStatDataFlickerDService statDataFlickerDService;
|
||||||
private final IRStatDataInharmVDService statDataInharmVDService;
|
private final IRStatDataInharmVDService statDataInharmVDService;
|
||||||
|
private final IPqLineDetailService pqLineDetailService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -521,6 +523,30 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void LineRunFlag() {
|
||||||
|
List<PqLineBak> bakList = pqLineBakService.list();
|
||||||
|
//lineId:Oracle监测点ID id:Mysql监测点ID
|
||||||
|
Map<String, String> oracleRelationMysql = bakList.stream().collect(Collectors.toMap(PqLineBak::getLineId, PqLineBak::getId));
|
||||||
|
//获取oracle监测点接口
|
||||||
|
List<Line> list = oracleDataService.getLineList();
|
||||||
|
if(CollUtil.isNotEmpty(list)){
|
||||||
|
list.forEach(data->{
|
||||||
|
if (ObjUtil.isNotNull(oracleRelationMysql.get(data.getLineIndex()))) {
|
||||||
|
if(ObjUtil.isNotNull(data.getStatus())){
|
||||||
|
//mysql监测id
|
||||||
|
pqLineDetailService.update(new LambdaUpdateWrapper<PqLineDetail>()
|
||||||
|
.set(PqLineDetail::getRunFlag, data.getStatus())
|
||||||
|
.eq(PqLineDetail::getId, oracleRelationMysql.get(data.getLineIndex()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public RStatDataHarmrateVD getData1(DayHarmrateV data, Map<String, String> oracleRelationMysql, String valueType) {
|
public RStatDataHarmrateVD getData1(DayHarmrateV data, Map<String, String> oracleRelationMysql, String valueType) {
|
||||||
ZoneId zoneId = ZoneId.systemDefault();
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
RStatDataHarmrateVD po1 = new RStatDataHarmrateVD();
|
RStatDataHarmrateVD po1 = new RStatDataHarmrateVD();
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.njcn.mysql.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||||
|
import com.njcn.mysql.bo.po.PqLineDetail;
|
||||||
|
import com.njcn.mysql.mapper.PqLineDetailMapper;
|
||||||
|
import com.njcn.mysql.service.IPqLineDetailService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author wr
|
||||||
|
* @since 2024-06-05
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@DS("target")
|
||||||
|
public class PqLineDetailServiceImpl extends MppServiceImpl<PqLineDetailMapper, PqLineDetail> implements IPqLineDetailService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.njcn.oracle.bo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线路信息表
|
||||||
|
* */
|
||||||
|
@Data
|
||||||
|
@TableName("PQ_LINE")
|
||||||
|
public class Line {
|
||||||
|
|
||||||
|
@TableField("LINE_INDEX")
|
||||||
|
private String lineIndex;
|
||||||
|
|
||||||
|
@TableField("SUB_INDEX")
|
||||||
|
private String subIndex;
|
||||||
|
|
||||||
|
@TableField("GD_INDEX")
|
||||||
|
private String gdIndex;
|
||||||
|
|
||||||
|
@TableField("SUBV_INDEX")
|
||||||
|
private String subvIndex;
|
||||||
|
|
||||||
|
@TableField( "DEV_INDEX")
|
||||||
|
private String devIndex;
|
||||||
|
|
||||||
|
@TableField( "NAME")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@TableField("PT1")
|
||||||
|
private Float pt1;
|
||||||
|
|
||||||
|
@TableField("PT2")
|
||||||
|
private Float pt2;
|
||||||
|
|
||||||
|
@TableField("CT1")
|
||||||
|
private Float ct1;
|
||||||
|
|
||||||
|
@TableField("ct2")
|
||||||
|
private Float ct2;
|
||||||
|
|
||||||
|
//设备容量
|
||||||
|
@TableField("DEVCMP")
|
||||||
|
private Float devcMp;
|
||||||
|
|
||||||
|
//短路容量
|
||||||
|
@TableField("DLCMP")
|
||||||
|
private Float dlcMp;
|
||||||
|
|
||||||
|
//基准容量
|
||||||
|
@TableField("JZCMP")
|
||||||
|
private Float jzcMp;
|
||||||
|
|
||||||
|
//协议容量
|
||||||
|
@TableField("XYCMP")
|
||||||
|
private Float xycMp;
|
||||||
|
|
||||||
|
@TableField("SUBV_NO")
|
||||||
|
private Integer subVNo;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField("SCALE")
|
||||||
|
private String scale;
|
||||||
|
|
||||||
|
@TableField("SUBV_NAME")
|
||||||
|
private String subvName;
|
||||||
|
|
||||||
|
//监测点状态(0:投运;1:退运)
|
||||||
|
@TableField("STATUS")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.oracle.mapper;
|
||||||
|
|
||||||
|
import com.njcn.oracle.bo.po.Line;
|
||||||
|
import com.njcn.oracle.mybatis.mapper.BatchBaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author hongawen
|
||||||
|
* @since 2023-12-28
|
||||||
|
*/
|
||||||
|
public interface LineMapper extends BatchBaseMapper<Line> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?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.oracle.mapper.LineMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user