辽宁二三区数据迁移

This commit is contained in:
cdf
2026-06-17 10:11:44 +08:00
parent 8b166031ec
commit d1ba92bd03
51 changed files with 1728 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package com.njcn.relational;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {"com.njcn.relational"} )
@MapperScan(value = "com.njcn.relational")
@EnableScheduling
public class RelationalTargetApplication {
public static void main(String[] args) {
SpringApplication.run(RelationalTargetApplication.class, args);
}
}

View File

@@ -0,0 +1,4 @@
package com.njcn.relational.mapper;
public interface DynamicInsertMapper {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataFlickerD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataFlickerRelationMapper extends MppBaseMapper<RStatDataFlickerD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataFlucD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataFlucRelationMapper extends MppBaseMapper<RStatDataFlucD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataHarmPhasicID;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataHarmPhasicIRelationMapper extends MppBaseMapper<RStatDataHarmPhasicID> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataHarmPhasicVD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataHarmPhasicVRelationMapper extends MppBaseMapper<RStatDataHarmPhasicVD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataHarmPowerPD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataHarmPowerPRelationMapper extends MppBaseMapper<RStatDataHarmPowerPD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataHarmPowerQD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataHarmPowerQRelationMapper extends MppBaseMapper<RStatDataHarmPowerQD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataHarmPowerSD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataHarmPowerSRelationMapper extends MppBaseMapper<RStatDataHarmPowerSD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataHarmRateID;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataHarmRateIRelationMapper extends MppBaseMapper<RStatDataHarmRateID> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataHarmRateVD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataHarmRateVRelationMapper extends MppBaseMapper<RStatDataHarmRateVD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataID;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataIRelationMapper extends MppBaseMapper<RStatDataID> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataInHarmID;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataInHarmIRelationMapper extends MppBaseMapper<RStatDataInHarmID> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataInHarmVD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataInHarmVRelationMapper extends MppBaseMapper<RStatDataInHarmVD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataPltD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataPltRelationMapper extends MppBaseMapper<RStatDataPltD> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.relational.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.relational.pojo.po.RStatDataVD;
/**
* <p>
* Mapper 接口
* </p>
*/
public interface RStatDataVRelationMapper extends MppBaseMapper<RStatDataVD> {
}

View File

@@ -0,0 +1,79 @@
//package com.njcn.relational.service;
//
//import com.njcn.relational.utils.PowerDataParser;
//import lombok.AllArgsConstructor;
//import lombok.Data;
//import lombok.RequiredArgsConstructor;
//import org.apache.ibatis.session.ExecutorType;
//import org.apache.ibatis.session.SqlSession;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.io.IOException;
//import java.util.List;
//import java.util.Map;
//import java.util.Set;
//import java.util.stream.Collectors;
//import java.util.stream.IntStream;
//
///**
// * @Author: cdf
// * @CreateTime: 2025-05-28
// * @Description:
// */
//@Service
//@RequiredArgsConstructor
//public class DynamicDataImportService {
// private final PowerDataParser powerDataParser;
// private final SqlSessionFactory sqlSessionFactory;
//
// @Transactional
// public void dynamicImportData(String filePath) throws IOException {
// Map<String, List<Map<String, Object>>> tableDataMap = powerDataParser.parseMultiTableFile(filePath);
//
// // 批量大小设置为1000可根据实际情况调整
// final int batchSize = 1000;
//
// try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH)) {
// for (Map.Entry<String, List<Map<String, Object>>> entry : tableDataMap.entrySet()) {
// String tableName = entry.getKey();
// List<Map<String, Object>> dataList = entry.getValue();
//
// if (dataList.isEmpty()) continue;
//
// // 获取列名
// Set<String> columns = dataList.get(0).keySet();
//
// // 分批处理
// for (int i = 0; i < dataList.size(); i += batchSize) {
// List<Map<String, Object>> batch = dataList.subList(i, Math.min(i + batchSize, dataList.size()));
//
// // 执行批量插入
// sqlSession.insert("dynamicBatchInsert", new DynamicInsertParam(
// tableName,
// columns,
// batch,
// batch.size()
// ));
//
// // 定期刷新并清空缓存
// sqlSession.flushStatements();
// sqlSession.clearCache();
// }
// System.out.println(tableName+"——表数据转移成功");
// }
// }
// }
//
//
//
// @Data
// @AllArgsConstructor
// public static class DynamicInsertParam {
// private String tableName;
// private Set<String> columns;
// private List<Map<String, Object>> batchData;
// private int batchSize;
// }
//}

View File

@@ -0,0 +1,17 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataFlicker {
}

View File

@@ -0,0 +1,17 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataFluc {
}

View File

@@ -0,0 +1,13 @@
package com.njcn.relational.service;
import java.util.List;
/**
* @author xy
*/
public interface InsertIDataHarmRateI {
}

View File

@@ -0,0 +1,14 @@
package com.njcn.relational.service;
import java.util.List;
/**
* @author xy
*/
public interface InsertIDataHarmRateV {
}

View File

@@ -0,0 +1,19 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataHarmphasicI {
}

View File

@@ -0,0 +1,17 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataHarmphasicV {
}

View File

@@ -0,0 +1,18 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataHarmpowerP {
}

View File

@@ -0,0 +1,18 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataHarmpowerQ {
}

View File

@@ -0,0 +1,17 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataHarmpowerS {
}

View File

@@ -0,0 +1,17 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataI {
}

View File

@@ -0,0 +1,17 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 13:27【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataInharmI {
}

View File

@@ -0,0 +1,17 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 13:27【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataInharmV {
}

View File

@@ -0,0 +1,15 @@
package com.njcn.relational.service;
import java.util.List;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface InsertIDataPlt {
}

View File

@@ -0,0 +1,19 @@
package com.njcn.relational.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.relational.pojo.po.RStatDataID;
import com.njcn.relational.pojo.po.RStatDataVD;
import java.util.List;
/**
* @author hongawen
* @version 1.0
* @data 2024/11/7 10:54
*/
public interface InsertIDataV extends IService<RStatDataID> {
}

View File

@@ -0,0 +1,21 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataFlicker;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataFlickerImpl implements InsertIDataFlicker {
}

View File

@@ -0,0 +1,21 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataFluc;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataFlucImpl implements InsertIDataFluc {
}

View File

@@ -0,0 +1,18 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataHarmRateI;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* @author xy
*/
@Service
@RequiredArgsConstructor
public class InsertDataHarmRateIImpl implements InsertIDataHarmRateI {
}

View File

@@ -0,0 +1,17 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataHarmRateV;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* @author xy
*/
@Service
@RequiredArgsConstructor
public class InsertDataHarmRateVImpl implements InsertIDataHarmRateV {
}

View File

@@ -0,0 +1,22 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataHarmphasicI;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataHarmphasicIImpl implements InsertIDataHarmphasicI {
}

View File

@@ -0,0 +1,21 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataHarmphasicV;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataHarmphasicVImpl implements InsertIDataHarmphasicV {
}

View File

@@ -0,0 +1,21 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataHarmpowerP;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataHarmpowerPImpl implements InsertIDataHarmpowerP {
}

View File

@@ -0,0 +1,21 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataHarmpowerQ;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataHarmpowerQImpl implements InsertIDataHarmpowerQ {
}

View File

@@ -0,0 +1,22 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataHarmpowerS;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataHarmpowerSImpl implements InsertIDataHarmpowerS {
}

View File

@@ -0,0 +1,26 @@
package com.njcn.relational.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.njcn.relational.service.InsertIDataI;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.time.ZoneId;
import java.util.ArrayList;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataIImpl implements InsertIDataI {
}

View File

@@ -0,0 +1,21 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataInharmI;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 13:27【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataInharmIImpl implements InsertIDataInharmI {
}

View File

@@ -0,0 +1,22 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataInharmV;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 13:27【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataInharmVImpl implements InsertIDataInharmV {
}

View File

@@ -0,0 +1,20 @@
package com.njcn.relational.service.impl;
import com.njcn.relational.service.InsertIDataPlt;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* Description:
* Date: 2024/11/18 11:17【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class InsertDataPltImpl implements InsertIDataPlt {
}

View File

@@ -0,0 +1,24 @@
package com.njcn.relational.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.relational.mapper.RStatDataVRelationMapper;
import com.njcn.relational.pojo.po.RStatDataVD;
import com.njcn.relational.service.InsertIDataI;
import com.njcn.relational.service.InsertIDataV;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* @author hongawen
* @version 1.0
* @data 2024/11/7 10:54
*/
@Service
@RequiredArgsConstructor
public class InsertDataVImpl extends ServiceImpl<RStatDataVRelationMapper, RStatDataVD> implements InsertIDataI {
}

View File

@@ -0,0 +1,41 @@
//package com.njcn.relational.utils;
//
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
//import com.baomidou.mybatisplus.extension.service.IService;
//
//import java.util.List;
//
///**
// * @Author: cdf
// * @CreateTime: 2025-05-21
// * @Description:
// */
//public class BatchInsertUtils {
//
// /**
// * 批量插入优化适用于MySQL
// * @param service IService实例
// * @param list 数据列表
// * @param batchSize 每批数量
// */
// public static <T> boolean batchInsert(IService<T> service, List<T> list, int batchSize) {
// if (CollectionUtils.isEmpty(list)) {
// return true;
// }
//
// int total = list.size();
// int batchCount = (total + batchSize - 1) / batchSize;
//
// for (int i = 0; i < batchCount; i++) {
// int from = i * batchSize;
// int to = Math.min((i + 1) * batchSize, total);
// List<T> subList = list.subList(from, to);
//
// if (!service.saveBatch(subList)) {
// return false;
// }
// }
// return true;
// }
//
//}

View File

@@ -0,0 +1,182 @@
//package com.njcn.relational.utils;
//
//import org.springframework.stereotype.Component;
//
//import java.io.BufferedReader;
//import java.io.FileReader;
//import java.io.IOException;
//
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.*;
//
//@Component
//public class PowerDataParser {
//
// private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
// private static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
// public List<Map<String, Object>> parseFile(String filePath) throws IOException {
// List<Map<String, Object>> result = new ArrayList<>();
//
// try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
// String line;
// boolean inDataBlock = false;
// String[] headers = null;
// String[] types = null;
//
// while ((line = reader.readLine()) != null) {
// line = line.trim();
//
// if (line.startsWith("@DATA_BLOCK")) {
// inDataBlock = true;
// continue;
// }
//
// if (line.startsWith("</r_stat_data_v_d>")) {
// break;
// }
//
// if (!inDataBlock) continue;
//
// if (line.startsWith("%")) {
// // 数据类型定义行
// types = line.substring(1).split(",");
// }else if(line.startsWith("/@")){
// headers = line.substring(2).split(",");
// } else if (line.startsWith("#")) {
// // 数据行
// String[] values = line.substring(1).split(",");
// Map<String, Object> data = parseDataLine(headers, types, values);
// if (data != null) {
// result.add(data);
// }
// }
// }
// }
//
// return result;
// }
//
//
// public Map<String, List<Map<String, Object>>> parseMultiTableFile(String filePath) throws IOException {
// Map<String, List<Map<String, Object>>> result = new LinkedHashMap<>();
// String currentTable = null;
// List<Map<String, Object>> currentData = null;
// String[] headers = null;
// String[] types = null;
//
// try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
// String line;
// while ((line = reader.readLine()) != null) {
// line = line.trim();
// // 识别表开始标记
// if (line.startsWith("<") && line.contains("::")) {
// currentTable = line.substring(line.indexOf("::") + 2, line.indexOf(">"));
// currentData = new ArrayList<>();
// result.put(currentTable, currentData);
// continue;
// }
//
// if (currentTable == null) continue;
//
// // 数据块开始
// if (line.startsWith("@DATA_BLOCK")) {
// headers = null;
// types = null;
// continue;
// }
//
// // 数据块结束
// if (line.startsWith("</")) {
// currentTable = null;
// currentData = null;
// continue;
// }
//
// if (line.startsWith("%")) {
// types = line.substring(1).split(",");
// } else if (line.startsWith("/@")) {
// headers = line.substring(2).split(",");
// } else if (line.startsWith("#")) {
// if (headers != null && types != null) {
// String[] values = line.substring(1).split(",");
// Map<String, Object> data = parseDataLine(headers, types, values);
// if (data != null && currentData != null) {
// currentData.add(data);
// }
// }
// }
// }
// }
// return result;
// }
//
//
//
// private Map<String, Object> parseDataLine(String[] headers, String[] types, String[] values) {
// if (headers == null || types == null || values == null ||
// headers.length != values.length || headers.length != types.length) {
// return null;
// }
//
// Map<String, Object> data = new HashMap<>();
//
// for (int i = 0; i < headers.length; i++) {
// String field = headers[i].trim();
// String type = types[i].trim();
// String value = values[i].trim();
//
// try {
// if("-".equals(value)){
// data.put(field, null);
// continue;
// }
// Object parsedValue = parseValue(value, type);
// data.put(field, parsedValue);
// } catch (ParseException e) {
// System.err.println("Error parsing value '" + value + "' for field '" + field + "' with type '" + type + "'");
// data.put(field, null);
// }
// }
//
// return data;
// }
//
// private Object parseValue(String value, String type) throws ParseException {
// if (value == null || value.isEmpty() || "0E-8".equals(value)) {
// return getDefaultValue(type);
// }
//
// switch (type.toUpperCase()) {
// case "DATE":
// return DATE_FORMAT.parse(value);
// case "DATETIME":
// return DATE_TIME_FORMAT.parse(value);
// case "INT":
// return Integer.parseInt(value);
// case "DECIMAL":
// return Double.parseDouble(value);
// case "VARCHAR":
// return value;
// default:
// return value;
// }
// }
//
// private Object getDefaultValue(String type) {
// switch (type.toUpperCase()) {
// case "DATE":
// case "DATETIME":
// return null;
// case "INT":
// return 0;
// case "DECIMAL":
// return 0.0;
// case "VARCHAR":
// return "";
// default:
// return null;
// }
// }
//}

View File

@@ -0,0 +1,38 @@
//package com.njcn.relational.utils;
//
//import com.njcn.relational.config.TableConfig;
//import com.njcn.relational.pojo.po.RStatDataID;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.PostConstruct;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @Author: cdf
// * @CreateTime: 2025-05-28
// * @Description:
// */
//@Component
//public class TableConfigManager {
// private Map<String, TableConfig> configMap = new HashMap<>();
//
// @PostConstruct
// public void init() {
// // 注册r_stat_data_i_d表
// registerRStatDataIDConfig();
// // 注册其他表...
// }
//
// private void registerRStatDataIDConfig() {
// TableConfig config = new TableConfig();
// config.setTableName("r_stat_data_i_d");
// config.setEntityClass(RStatDataID.class);
// // 设置表头和数据类型...
// configMap.put("r_stat_data_i_d", config);
// }
//
// public TableConfig getConfig(String tableName) {
// return configMap.get(tableName);
// }
//}

View File

@@ -0,0 +1,45 @@
server:
port: 10556
# 30分钟无操作就过期
servlet:
context-path:
session:
timeout: 600m
spring:
application:
name: dmTransport
profiles:
#active: query_up
active: query_up
security:
user:
name: data_njcn
password: dnzl@#002
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.relational.pojo
mapper-locations: classpath*:com/njcn/relational/mapper/mapping/*.xml
configuration:
call-setters-on-nulls: true
#驼峰命名
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
logging:
level:
root: info
sync:
export:
#path: /home/d5000/liaoning/file-send/7/
path: D:/data/export/
import:
path: /home/import/

View File

@@ -0,0 +1,553 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数据同步管理系统</title>
<!-- 引入 Element UI 样式 -->
<link rel="stylesheet" href="js/element-ui.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
background-color: #f5f7fa;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
border-radius: 8px;
margin-bottom: 30px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.header h1 {
font-size: 28px;
margin-bottom: 10px;
}
.header p {
font-size: 14px;
opacity: 0.9;
}
.card {
background: white;
border-radius: 8px;
padding: 25px;
margin-bottom: 20px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.card-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #e4e7ed;
color: #303133;
}
.button-group {
display: flex;
gap: 15px;
flex-wrap: wrap;
}
.button-item {
flex: 1;
min-width: 200px;
}
.date-input {
width: 200px;
margin-right: 15px;
}
.file-list {
max-height: 400px;
overflow-y: auto;
}
.log-area {
background: #f5f7fa;
border: 1px solid #dcdfe6;
border-radius: 4px;
padding: 15px;
max-height: 300px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 12px;
line-height: 1.6;
}
.log-item {
margin-bottom: 5px;
padding: 5px;
border-radius: 3px;
}
.log-success {
background: #f0f9ff;
color: #67c23a;
}
.log-error {
background: #fef0f0;
color: #f56c6c;
}
.log-info {
background: #f4f4f5;
color: #909399;
}
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.stat-item {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
border-radius: 8px;
text-align: center;
}
.stat-value {
font-size: 32px;
font-weight: bold;
margin-bottom: 5px;
}
.stat-label {
font-size: 14px;
opacity: 0.9;
}
.environment-badge {
display: inline-block;
padding: 5px 15px;
border-radius: 20px;
font-size: 12px;
font-weight: bold;
margin-left: 15px;
}
.badge-source {
background: #e6a23c;
color: white;
}
.badge-target {
background: #409eff;
color: white;
}
</style>
</head>
<body>
<div id="app">
<div class="container">
<!-- 头部 -->
<div class="header">
<h1>
🗄️ 数据同步管理系统
<span :class="['environment-badge', isSourceServer ? 'badge-source' : 'badge-target']">
{{ serverTypeName }}
</span>
</h1>
<p> relational_migration - 数据导入导出管理平台</p>
</div>
<!-- 统计信息 -->
<div class="stats">
<div class="stat-item">
<div class="stat-value">{{ fileCount }}</div>
<div class="stat-label">远程文件数量</div>
</div>
<div class="stat-item">
<div class="stat-value">{{ operationCount }}</div>
<div class="stat-label">操作次数</div>
</div>
<div class="stat-item">
<div class="stat-value">{{ lastOperationTime || '--' }}</div>
<div class="stat-label">最后操作时间</div>
</div>
</div>
<!-- 环境配置卡片(可选显示) -->
<div class="card" v-if="showEnvSwitch">
<div class="card-title">⚙️ 环境切换(调试用)</div>
<el-alert
title="当前环境由配置文件控制,如需切换请修改 application.yml 中的 app.server-type 配置"
type="warning"
:closable="false"
show-icon
style="margin-bottom: 15px;">
</el-alert>
<el-form :inline="true">
<el-form-item label="当前配置">
<el-tag :type="isSourceServer ? 'warning' : 'primary'" size="medium">
{{ serverTypeName }}
</el-tag>
</el-form-item>
</el-form>
</div>
<!-- 数据操作卡片 -->
<div class="card">
<div class="card-title">📊 数据操作</div>
<el-form :inline="true" class="demo-form-inline">
<el-form-item label="日期">
<el-date-picker
v-model="selectedDate"
type="date"
placeholder="选择日期"
format="yyyyMMdd"
value-format="yyyyMMdd"
class="date-input">
</el-date-picker>
</el-form-item>
<el-form-item>
<div class="button-group">
<el-button
v-if="isSourceServer"
type="primary"
icon="el-icon-download"
@click="handleExport"
:loading="loading.export">
从二区库导出数据并上传横向隔离设备
</el-button>
<el-button
v-if="isTargetServer"
type="success"
icon="el-icon-upload2"
@click="handleImport"
:loading="loading.import">
从横向隔离设备拉取数据并入三区库
</el-button>
<el-button v-if="isSourceServer" type="warning" icon="el-icon-refresh" @click="handleTest" :loading="loading.test">
测试二区发送数据至横向隔离设备
</el-button>
<el-button v-if="isTargetServer" type="info" icon="el-icon-refresh-right" @click="handleTestR" :loading="loading.testR">
测试三区从横向隔离设备消费数据
</el-button>
</div>
</el-form-item>
</el-form>
</div>
<!-- 文件管理卡片 -->
<div class="card">
<div class="card-title">📁 远程文件管理</div>
<el-button type="primary" icon="el-icon-search" @click="getRemoteFiles" :loading="loading.getRemoteAll" style="margin-bottom: 15px;">
获取横向隔离设备远程文件列表
</el-button>
<div class="file-list" v-if="remoteFiles.length > 0">
<el-table :data="remoteFiles" stripe style="width: 100%">
<el-table-column type="index" label="序号" width="60"></el-table-column>
<el-table-column prop="name" label="文件名"></el-table-column>
<el-table-column label="操作" width="200">
<template slot-scope="scope">
<!-- <el-button size="mini" type="danger" @click="removeFile(scope.row)">
删除
</el-button>-->
</template>
</el-table-column>
</el-table>
</div>
<el-empty v-else description="暂无远程文件" :image-size="100"></el-empty>
</div>
<!-- 清理文件卡片 -->
<div class="card">
<div class="card-title">🗑️ 本地文件清理</div>
<el-form :inline="true">
<el-form-item label="保留天数">
<el-input-number v-model="cleanDays" :min="1" :max="365" label="请输入保留天数"></el-input-number>
</el-form-item>
<el-form-item>
<el-button v-if="isSourceServer" type="danger" icon="el-icon-delete" @click="cleanTwo" :loading="loading.removeTwo">
清理二区服务器上生成的数据
</el-button>
<el-button v-if="isTargetServer" type="danger" icon="el-icon-delete" @click="cleanThree" :loading="loading.removeThree">
清理三区服务器保留的数据
</el-button>
</el-form-item>
</el-form>
</div>
<!-- 操作日志卡片 -->
<div class="card">
<div class="card-title">📋 操作日志</div>
<div class="log-area">
<div v-for="(log, index) in logs" :key="index" :class="['log-item', log.type]">
[{{ log.time }}] {{ log.message }}
</div>
<div v-if="logs.length === 0" class="log-info">
暂无操作日志
</div>
</div>
<el-button size="small" @click="clearLogs" style="margin-top: 10px;">
清空日志
</el-button>
</div>
</div>
</div>
<!-- 引入 Vue -->
<script src="js/vue.min.js"></script>
<!-- 引入 Element UI -->
<script src="js/element-ui-index.js"></script>
<!-- 引入 Axios -->
<script src="js/axios.min.js"></script>
<script>
new Vue({
el: '#app',
data() {
return {
selectedDate: '',
cleanDays: 7,
remoteFiles: [],
logs: [],
loading: {
export: false,
import: false,
test: false,
testR: false,
getRemoteAll: false,
removeTwo: false,
removeThree: false
},
fileCount: 0,
operationCount: 0,
lastOperationTime: '',
serverType: 'source',
serverTypeName: '源服务器',
showEnvSwitch: false,
// 默认选中 昨天
selectedDate: this.getYesterdayDate()
}
},
computed: {
isSourceServer() {
return this.serverType === 'source';
},
isTargetServer() {
return this.serverType === 'target';
}
},
mounted() {
this.loadServerConfig();
},
methods: {
// 获取昨天的日期,格式 yyyyMMdd
getYesterdayDate() {
const date = new Date();
date.setDate(date.getDate() - 1); // 减去一天 = 昨天
const y = date.getFullYear();
const m = (date.getMonth() + 1).toString().padStart(2, '0');
const d = date.getDate().toString().padStart(2, '0');
return `${y}${m}${d}`; // 输出 20250613 这种格式
},
// 加载服务器配置
async loadServerConfig() {
try {
const response = await axios.get('source/getConfig');
this.serverType = response.data.serverType;
this.serverTypeName = response.data.serverTypeName;
this.addLog(`系统初始化完成,当前环境:${this.serverTypeName}`, 'success');
this.getRemoteFiles();
} catch (error) {
console.error('加载配置失败:', error);
this.addLog('加载配置失败,使用默认配置', 'error');
this.getRemoteFiles();
}
},
// 添加日志
addLog(message, type = 'info') {
const now = new Date();
const timeStr = now.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
this.logs.unshift({
time: timeStr,
message: message,
type: type
});
// 保持最多100条日志
if (this.logs.length > 100) {
this.logs.pop();
}
},
// 清空日志
clearLogs() {
this.logs = [];
this.$message.info('日志已清空');
},
// 导出数据
async handleExport() {
this.loading.export = true;
try {
const params = this.selectedDate ? { date: this.selectedDate } : {};
await axios.get('source/export', { params });
this.$message.success('二区数据导出上传成功');
this.addLog('二区数据导出上传成功', 'success');
this.operationCount++;
this.lastOperationTime = new Date().toLocaleTimeString();
} catch (error) {
this.$message.error('数据导出失败: ' + (error.response?.data || error.message));
this.addLog('数据导出失败: ' + error.message, 'error');
} finally {
this.loading.export = false;
}
},
// 导入数据
async handleImport() {
this.loading.import = true;
try {
const params = this.selectedDate ? { date: this.selectedDate } : {};
await axios.get('source/import', { params });
this.$message.success('三区数据拉取导入成功');
this.addLog('三区数据拉取导入成功', 'success');
this.operationCount++;
this.lastOperationTime = new Date().toLocaleTimeString();
} catch (error) {
this.$message.error('数据导入失败: ' + (error.response?.data || error.message));
this.addLog('数据导入失败: ' + error.message, 'error');
} finally {
this.loading.import = false;
}
},
// 测试连接
async handleTest() {
this.loading.test = true;
try {
await axios.get('source/test');
this.$message.success('测试二区数据推送横向隔离设备成功');
this.addLog('测试二区数据推送横向隔离设备成功', 'success');
this.operationCount++;
this.lastOperationTime = new Date().toLocaleTimeString();
} catch (error) {
this.$message.error('测试二区数据推送横向隔离设备失败: ' + (error.response?.data || error.message));
this.addLog('测试二区数据推送横向隔离设备失败: ' + error.message, 'error');
} finally {
this.loading.test = false;
}
},
// 测试远程
async handleTestR() {
this.loading.testR = true;
try {
await axios.get('source/testR');
this.$message.success('三区拉取测试数据成功');
this.addLog('三区拉取测试数据成功', 'success');
this.operationCount++;
this.lastOperationTime = new Date().toLocaleTimeString();
} catch (error) {
this.$message.error('三区拉取测试数据失败: ' + (error.response?.data || error.message));
this.addLog('三区拉取测试数据失败: ' + error.message, 'error');
} finally {
this.loading.testR = false;
}
},
// 获取远程文件列表
async getRemoteFiles() {
this.loading.getRemoteAll = true;
try {
const response = await axios.get('source/getRemoteAll');
this.remoteFiles = response.data.map((name, index) => ({
id: index,
name: name
}));
this.fileCount = this.remoteFiles.length;
this.$message.success(`获取到 ${this.fileCount} 个远程文件`);
this.addLog(`获取远程文件列表成功,共 ${this.fileCount} 个文件`, 'success');
} catch (error) {
this.$message.error('获取远程文件失败: ' + (error.response?.data || error.message));
this.addLog('获取远程文件失败: ' + error.message, 'error');
} finally {
this.loading.getRemoteAll = false;
}
},
// 清理二区服务器历史导出数据
async cleanTwo() {
this.loading.removeTwo = true;
try {
const response = await axios.get('source/removeTwo', {
params: { a: this.cleanDays }
});
this.$message.success(response.data);
this.addLog(`清理二区服务器历史导出数据成功,保留${this.cleanDays}天内的文件`, 'success');
this.operationCount++;
this.lastOperationTime = new Date().toLocaleTimeString();
// 刷新文件列表
//this.getRemoteFiles();
} catch (error) {
this.$message.error('清理失败: ' + (error.response?.data || error.message));
this.addLog('清理二区服务器历史导出数据失败: ' + error.message, 'error');
} finally {
this.loading.removeTwo = false;
}
},
// 清理三区拉取数据
async cleanThree() {
this.loading.removeThree = true;
try {
const response = await axios.get('source/removeThree', {
params: { a: this.cleanDays }
});
this.$message.success(response.data);
this.addLog(`清理三区拉取数据成功,保留${this.cleanDays}天内的文件`, 'success');
this.operationCount++;
this.lastOperationTime = new Date().toLocaleTimeString();
// 刷新文件列表
//this.getRemoteFiles();
} catch (error) {
this.$message.error('清理失败: ' + (error.response?.data || error.message));
this.addLog('清理三区拉取数据失败: ' + error.message, 'error');
} finally {
this.loading.removeThree = false;
}
}
}
})
</script>
</body>
</html>

View File

@@ -0,0 +1,13 @@
//package com.njcn.relational;
//
//import org.junit.jupiter.api.Test;
//import org.springframework.boot.test.context.SpringBootTest;
//
//@SpringBootTest
//class RelationalTargetApplicationTests {
//
// @Test
// void contextLoads() {
// }
//
//}