增加redis测试 连接操作

master
lwj 2024-09-03 15:27:20 +08:00
parent 6669076034
commit 7ec90b2673
9 changed files with 2192 additions and 3336 deletions

View File

@ -18,13 +18,23 @@
<dependencies>
<!-- oracle 数据源连接-->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version> <!-- 请使用适合你的Oracle数据库版本的驱动 -->
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-core</artifactId>

View File

@ -14,7 +14,8 @@ public class DataValueController {
@Autowired
private DataValueService dataValueService;
//获取字段值
//获取字段值 供任务调用
@PostMapping("/findTableValue")
public Result findTableValue(@RequestParam("basicId") Long basicId,@RequestParam("sql") String sql) {
List<List<DataValue>> list= dataValueService.findTableValue(basicId,sql);
@ -29,4 +30,6 @@ public class DataValueController {
}
}

View File

@ -83,8 +83,15 @@ public class SourceController extends BaseController {
*/
@PostMapping("/connectionTest")
public Result connectionTest(@RequestBody Source source) throws ServletException {
if(source.getDatabaseType().equals("mysql")){
return toAjax(sourceService.connectionTest(source));
}
if(source.getDatabaseType().equals("redis")){
return toAjax(sourceService.connectionRedisTest(source));
}
return toAjax(0);
}
//同步资产结构

View File

@ -25,6 +25,6 @@ public interface AccreditMapper {
List<Integer> findDeptTableIds(@Param("deptId") Long deptId);
Accredit findAccreditBasic(@Param("tableId") Long tableId);
// Accredit findAccreditBasic(@Param("tableId") Long tableId);
}

View File

@ -22,4 +22,8 @@ public interface SourceService extends IService<Source> {
int structure(Source source);
int redis(Source source);
int connectionRedisTest(Source source);
}

View File

@ -3,6 +3,7 @@ package com.muyu.cloud.etl.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.muyu.cloud.etl.mapper.SourceMapper;
import com.muyu.cloud.etl.service.SourceService;
import com.muyu.cloud.etl.service.StructureService;
@ -20,9 +21,8 @@ import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -208,30 +208,67 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
return 1;
}
@Autowired
private ObjectMapper objectMapper;
@Override
public int redis(Source source) {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(100);
jedisPoolConfig.setMaxIdle(100);
jedisPoolConfig.setMaxWaitMillis(5);
jedisPoolConfig.setMaxTotal(Math.toIntExact(source.getMaxLinkNum()));
jedisPoolConfig.setMaxIdle(Math.toIntExact(source.getMaxLinkNum()));
jedisPoolConfig.setMaxWaitMillis(source.getMaxWaitTime());
JedisPool jedisPool = new JedisPool(jedisPoolConfig, "172.13.1.1", 6379, 3000, null);
JedisPool jedisPool = new JedisPool(jedisPoolConfig, source.getHost(), Integer.parseInt(source.getPort()), 3000, null);
Jedis jedis = jedisPool.getResource();
HashMap<String, String> stringStringHashMap = new HashMap<>();
Set<String> keys = jedis.keys("*");
for (String key : keys) {
String value = jedis.get(key);
if (value != null) {
System.out.println(value);
stringStringHashMap.put(key, value);
// 反序列化逻辑
// Map<String, String> data = null;
// data.put(key,value);
// processData(key,data);
}
}
String[] split = value.split(",");
for (String s : split) {
return 1;
}
@Override
public int connectionRedisTest(Source source) {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(Math.toIntExact(source.getMaxLinkNum()));
jedisPoolConfig.setMaxIdle(Math.toIntExact(source.getMaxLinkNum()));
jedisPoolConfig.setMaxWaitMillis(source.getMaxWaitTime());
JedisPool jedisPool = new JedisPool(jedisPoolConfig, source.getHost(), Integer.parseInt(source.getPort()), 3000, null);
Jedis jedis = jedisPool.getResource();
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
Set<String> keys = jedis.keys("*");
for (String key : keys) {
String s = jedis.get(key);
if(s!=null){
System.out.println(s);
objectObjectHashMap.put(key, s);
}
// System.out.println(value);
}
return 0;
}
private void processData(String key, Map<String, String> data) {
// 处理数据的逻辑
System.out.println("Key: " + key + ", Data: " + data);
}
public void syncData(Connection conn, String databaseName, TableInfo table) throws SQLException {
ExecutorService threadPool = Executors.newCachedThreadPool();

View File

@ -32,6 +32,7 @@
<result property="parentId" column="parent_id"/>
<result property="ancestors" column="ancestors"/>
</resultMap>
<resultMap id="AccreditUserRep" type="com.muyu.domain.rep.AccreditUserRep">
<result property="userId" column="user_id"/>
<result property="userName" column="user_name"/>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff