1.oracle同步mysql代码,监测点运行状态
This commit is contained in:
@@ -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() {
|
||||
// 获取当前时间
|
||||
String date = DateUtil.format(LocalDateTime.now().minusDays(1), DatePattern.NORM_DATE_PATTERN);
|
||||
System.out.println("-----------------------------------------------------------------------");
|
||||
System.out.println("-----------------------------day表同步------------------------------------------");
|
||||
oracleToMysqlService.insertDayHarmRateV(date,date);
|
||||
oracleToMysqlService.insertPqsIntegrity(date,date);
|
||||
oracleToMysqlService.insertDayV(date,date);
|
||||
@@ -46,7 +46,14 @@ public class OracleToMysqlDBJob {
|
||||
oracleToMysqlService.insertPlt(date,date);
|
||||
oracleToMysqlService.insertFlicker(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
|
||||
*/
|
||||
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.util.ObjUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.njcn.mysql.bo.enums.TargetEnum;
|
||||
import com.njcn.mysql.bo.po.*;
|
||||
import com.njcn.mysql.service.*;
|
||||
@@ -37,6 +38,7 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
||||
private final IRStatDataPltDService statDataPltDService;
|
||||
private final IRStatDataFlickerDService statDataFlickerDService;
|
||||
private final IRStatDataInharmVDService statDataInharmVDService;
|
||||
private final IPqLineDetailService pqLineDetailService;
|
||||
|
||||
|
||||
@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) {
|
||||
ZoneId zoneId = ZoneId.systemDefault();
|
||||
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 {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user