master
commit
dd87fe12b8
|
@ -28,6 +28,7 @@ public class ManyJob {
|
||||||
@Autowired
|
@Autowired
|
||||||
private EntinfoServiceImpl entinfoService;
|
private EntinfoServiceImpl entinfoService;
|
||||||
|
|
||||||
|
|
||||||
// @Scheduled(cron = "*/10 * * * * *") // 每10分钟执行一次
|
// @Scheduled(cron = "*/10 * * * * *") // 每10分钟执行一次
|
||||||
public void manyJob(){
|
public void manyJob(){
|
||||||
redisService.deleteObject("entinfo");
|
redisService.deleteObject("entinfo");
|
||||||
|
|
|
@ -160,6 +160,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
||||||
@Autowired
|
@Autowired
|
||||||
private RabbitTemplate rabbitTemplate;
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http URL 链接
|
* http URL 链接
|
||||||
* @param business
|
* @param business
|
||||||
|
@ -196,12 +197,12 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
||||||
new InputStreamReader(httpConn.getInputStream()));
|
new InputStreamReader(httpConn.getInputStream()));
|
||||||
String resultData = br.readLine();
|
String resultData = br.readLine();
|
||||||
System.out.println("从服务端返回结果: " + resultData);
|
System.out.println("从服务端返回结果: " + resultData);
|
||||||
|
|
||||||
// 7.关闭HttpURLConnection连接
|
// 7.关闭HttpURLConnection连接
|
||||||
httpConn.disconnect();
|
httpConn.disconnect();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entinfo build = Entinfo.builder()
|
Entinfo build = Entinfo.builder()
|
||||||
.entCode("test_" + business.getId())
|
.entCode("test_" + business.getId())
|
||||||
.ip("192.168.120.128")
|
.ip("192.168.120.128")
|
||||||
|
|
|
@ -73,7 +73,6 @@ public class GenController extends BaseController {
|
||||||
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据表字段列表
|
* 查询数据表字段列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -67,13 +67,6 @@ public class ManyDataSource {
|
||||||
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
||||||
public void smsConfig(String msg, Message message, Channel channel){
|
public void smsConfig(String msg, Message message, Channel channel){
|
||||||
//获取消息的ID
|
//获取消息的ID
|
||||||
// new Thread(() -> {
|
|
||||||
// try {
|
|
||||||
// Thread.sleep(10000);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// }).start();
|
|
||||||
String messageId = message.getMessageProperties().getMessageId();
|
String messageId = message.getMessageProperties().getMessageId();
|
||||||
try {
|
try {
|
||||||
//添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费
|
//添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费
|
||||||
|
@ -103,7 +96,6 @@ public class ManyDataSource {
|
||||||
private void druidData(String msg) {
|
private void druidData(String msg) {
|
||||||
Entinfo entinfo1 = JSON.parseObject(msg, Entinfo.class);
|
Entinfo entinfo1 = JSON.parseObject(msg, Entinfo.class);
|
||||||
log.info("消息为:{}",entinfo1);
|
log.info("消息为:{}",entinfo1);
|
||||||
|
|
||||||
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
||||||
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||||
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entinfo1.getEntCode(), entinfo1.getIp(), entinfo1.getPort());
|
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entinfo1.getEntCode(), entinfo1.getIp(), entinfo1.getPort());
|
||||||
|
@ -123,7 +115,6 @@ public class ManyDataSource {
|
||||||
// List<com.zhiLian.common.core.domain.Entinfo> entinfos = remoteFileService.listAll();
|
// List<com.zhiLian.common.core.domain.Entinfo> entinfos = remoteFileService.listAll();
|
||||||
// databaseNameList.a(entinfos)
|
// databaseNameList.a(entinfos)
|
||||||
List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
|
List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
|
||||||
|
|
||||||
entinfo.forEach(string -> {
|
entinfo.forEach(string -> {
|
||||||
Entinfo entInfo = JSON.parseObject(string, Entinfo.class);
|
Entinfo entInfo = JSON.parseObject(string, Entinfo.class);
|
||||||
databaseNameList.add(entInfo);
|
databaseNameList.add(entInfo);
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||||
*/
|
*/
|
||||||
private Map<Object, Object> defineTargetDataSources;
|
private Map<Object, Object> defineTargetDataSources;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 决定当前线程使用哪个数据源
|
* 决定当前线程使用哪个数据源
|
||||||
*/
|
*/
|
||||||
|
@ -35,6 +36,7 @@ public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||||
return DynamicDataSourceHolder.getDynamicDataSourceKey();
|
return DynamicDataSourceHolder.getDynamicDataSourceKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加数据库
|
* 添加数据库
|
||||||
* @param key 键
|
* @param key 键
|
||||||
|
|
Loading…
Reference in New Issue