dev
1iyc 3 weeks ago
parent 27bff7eae6
commit 245bddd298

@ -94,7 +94,6 @@
<version>${bitwalker.version}</version>
</dependency>
<!-- 获取系统信息 -->
<dependency>
<groupId>com.github.oshi</groupId>
@ -204,14 +203,12 @@
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.1-jre</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
@ -219,6 +216,11 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.15.2</version>
</dependency>
</dependencies>
</dependencyManagement>

@ -96,10 +96,10 @@
<artifactId>jaxb-api</artifactId>
</dependency>
<!-- redis 缓存操作 -->
<!-- redisson 缓存操作 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
</dependency>
<!-- pool 对象池 -->

@ -0,0 +1,45 @@
package com.lyr.common.core.redis;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.redisson.config.TransportMode;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* packageName com.ktg.mes.config
*
* @author liyc
* @date 2024/9/3
* @description TODO
**/
@Configuration
public class RedissonConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private String port;
@Value("${spring.redis.password}")
private String password;
@Bean
public RedissonClient redissonClient() {
Config config = new Config();
config.setTransportMode(TransportMode.NIO);
SingleServerConfig singleServerConfig = config.useSingleServer();
String address = String.format("redis://%s:%s", host, port);
singleServerConfig.setAddress(address);
if (StringUtils.isNotEmpty(password)) {
singleServerConfig.setPassword(password);
}
RedissonClient redisson = Redisson.create(config);
return redisson;
}
}

@ -1,22 +0,0 @@
package com.lyr.gather.kis.domain.strategy;
import org.springframework.stereotype.Component;
import java.lang.annotation.*;
/**
*
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Sync {
String value();
String tableName() default "";
}

@ -1,7 +1,7 @@
package com.lyr.gather.kis.domain.strategy;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lyr.common.annotation.DataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.annotation.AnnotationUtils;
@ -35,7 +35,7 @@ public class SyncServicesStrategyContext implements BeanPostProcessor {
*/
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws SecurityException {
Sync annotation = AnnotationUtils.findAnnotation(bean.getClass(), Sync.class);
TableName annotation = AnnotationUtils.findAnnotation(bean.getClass(), TableName.class);
if (ClassUtils.isAssignableValue(IService.class, bean) && annotation != null) {
handlerMap.put(annotation.value().toUpperCase().trim(), (IService) bean);
}

@ -1,11 +1,11 @@
package com.lyr.gather.kis.service.impl;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lyr.gather.kis.convert.TSupplierConvert;
import com.lyr.gather.kis.domain.model.TSupplier;
import com.lyr.gather.kis.domain.strategy.Sync;
import com.lyr.gather.kis.domain.vo.TSupplierVO;
import com.lyr.gather.kis.mapper.TSupplierMapper;
import com.lyr.gather.kis.service.TSupplierService;
@ -21,7 +21,7 @@ import java.util.Map;
* @description TODO
**/
@Service
@Sync("t_Supplier")
@TableName("t_Supplier")
public class TSupplierServiceImpl extends ServiceImpl<TSupplierMapper, TSupplier> implements TSupplierService {

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableMap;
import com.lyr.common.core.redis.RedisCache;
import com.lyr.gather.kis.domain.model.TSupplier;
import com.lyr.gather.kis.domain.strategy.SyncServicesStrategyContext;
import com.lyr.gather.local.convert.ConfigTaskConvert;
@ -30,9 +31,11 @@ public class ConfigTaskServiceImpl extends ServiceImpl<ConfigTaskMapper, ConfigT
@Resource
private ConfigTaskMapper configTaskMapper;
@Resource
private SyncServicesStrategyContext syncServicesStrategyContext;
@Resource
private RedisCache redisCache;
@Override
public IPage<ConfigTaskPageVO> page(ConfigTaskReq req) {
@ -71,6 +74,8 @@ public class ConfigTaskServiceImpl extends ServiceImpl<ConfigTaskMapper, ConfigT
public int sync(String dataSource, String tableName) {
IService<TSupplier> handler = syncServicesStrategyContext.getHandler(tableName);
List<TSupplier> tSuppliers = handler.listByMap(ImmutableMap.of(handler.getClass().getName(), dataSource));
long cacheList = redisCache.setCacheList(tableName, tSuppliers);
System.out.println("cacheList = " + cacheList);
return 0;
}

@ -6,7 +6,7 @@ import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-07T18:10:07+0800",
date = "2024-11-07T18:23:20+0800",
comments = "version: 1.6.2, compiler: javac, environment: Java 1.8.0_392 (Amazon.com Inc.)"
)
public class TSupplierConvertImpl implements TSupplierConvert {

@ -6,7 +6,7 @@ import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-06T10:37:36+0800",
date = "2024-11-07T18:23:20+0800",
comments = "version: 1.6.2, compiler: javac, environment: Java 1.8.0_392 (Amazon.com Inc.)"
)
public class ConfigTaskConvertImpl implements ConfigTaskConvert {

@ -8,7 +8,7 @@ import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-06T10:37:36+0800",
date = "2024-11-07T18:23:21+0800",
comments = "version: 1.6.2, compiler: javac, environment: Java 1.8.0_392 (Amazon.com Inc.)"
)
public class DataSourceConfigConvertImpl implements DataSourceConfigConvert {

Loading…
Cancel
Save