👍 修改为本地数据库。

This commit is contained in:
2023-01-11 14:10:41 +08:00
parent c8ca54f026
commit eb76349932
5 changed files with 144 additions and 172 deletions
+1 -1
View File
@@ -1 +1 @@
rsync yudao-server/target/yudao-server.jar root@39.105.46.0:/root/project/zen/yudao.jar rsync -v ../yudao-server/target/yudao-server.jar root@47.108.56.75:/www/wwwroot/yudao/yudao-server.jar
@@ -41,7 +41,6 @@ import java.util.Map;
@MapperScans({ @MapperScans({
@MapperScan(basePackages ={"co.yixiang.**.service.mapper", "co.yixiang.config"},sqlSessionFactoryRef = "shangcheng"), @MapperScan(basePackages ={"co.yixiang.**.service.mapper", "co.yixiang.config"},sqlSessionFactoryRef = "shangcheng"),
@MapperScan(basePackages = {"com.zsw.erp.datasource.mappers"},sqlSessionFactoryRef = "erp"),
@MapperScan(basePackages = {"${yudao.info.base-package}", "cn.iocoder.yudao"}, annotationClass = Mapper.class, @MapperScan(basePackages = {"${yudao.info.base-package}", "cn.iocoder.yudao"}, annotationClass = Mapper.class,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试 lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试
}) })
@@ -89,23 +88,6 @@ public class YudaoMybatisAutoConfiguration {
return getSqlSessionFactory(factory); return getSqlSessionFactory(factory);
} }
@Bean("erpDataSource")
@ConfigurationProperties("spring.datasource.dynamic.datasource.erp")
public DataSource erpDataSource(){
return new DruidDataSource();
}
@Bean("erp")
public SqlSessionFactory erpSqlSessionFactory(@Qualifier("erpDataSource") DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean();
Resource[] resources = new PathMatchingResourcePatternResolver().getResources("classpath*:/erp_mapper/*.xml");
Arrays.stream(resources).forEach(resource -> {
log.info("erp mapper:{}",resource.getFilename());
});
factory.setMapperLocations(resources);
factory.setDataSource(dataSource);
return getSqlSessionFactory(factory);
}
private SqlSessionFactory getSqlSessionFactory(MybatisSqlSessionFactoryBean factory) throws Exception { private SqlSessionFactory getSqlSessionFactory(MybatisSqlSessionFactoryBean factory) throws Exception {
GlobalConfig globalConfig = new GlobalConfig(); GlobalConfig globalConfig = new GlobalConfig();
@@ -1,3 +1,11 @@
# 自定义数据库
mysql:
url: 47.108.56.75
port: 3306
vue-username: vue_pro
vue-password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#-
bxg_username: vue_pro_bxg
bxg_password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#-
server: server:
port: 48080 port: 48080
@@ -42,56 +50,23 @@ spring:
test-on-return: false test-on-return: false
datasource: datasource:
master: master:
url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai name: vue_pro
driver-class-name: com.p6spy.engine.spy.P6SpyDriver url: jdbc:mysql://${mysql.url}:${mysql.port}/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
username: root driver-class-name: com.mysql.cj.jdbc.Driver
password: root username: ${mysql.vue-username}
password: ${mysql.vue-password}
slave: # 模拟从库,可根据自己需要修改 slave: # 模拟从库,可根据自己需要修改
url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai name: vue_pro
driver-class-name: com.p6spy.engine.spy.P6SpyDriver url: jdbc:mysql://${mysql.url}:${mysql.port}/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
username: root driver-class-name: com.mysql.cj.jdbc.Driver
password: root username: ${mysql.vue-username}
password: ${mysql.vue-password}
bxg: # 农场数据源 bxg: # 农场数据源
url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro_bxg?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai name: vue_pro_bxg
driver-class-name: com.p6spy.engine.spy.P6SpyDriver url: jdbc:mysql://${mysql.url}:${mysql.port}/${spring.datasource.dynamic.datasource.bxg.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
username: root driver-class-name: com.mysql.cj.jdbc.Driver
password: root username: ${mysql.bxg-username}
erp: # 进销存 password: ${mysql.bxg-password}
url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro_erp?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
username: root
password: root
farm: # 农场数据源
url: jdbc:p6spy:mysql://192.168.10.250:3306/zsw-farm?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
username: root
password: root
# datasource:
# master:
# url: jdbc:p6spy:mysql://localhost:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# username: root
# password: 123456
# slave: # 模拟从库,可根据自己需要修改
# url: jdbc:p6spy:mysql://localhost:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# username: root
# password: 123456
# bxg: # 农场数据源
# url: jdbc:p6spy:mysql://localhost:3306/vue_pro_bxg?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# username: root
# password: 123456
# erp: # 进销存
# url: jdbc:p6spy:mysql://localhost/vue_pro_erp?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# username: root
# password: 123456
# farm: # 农场数据源
# url: jdbc:p6spy:mysql://localhost/zsw-farm?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
# driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# username: root
# password: 123456
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis: redis:
@@ -1,3 +1,11 @@
# 自定义数据库
mysql:
url: 127.0.0.1
port: 3306
vue-username: vue_pro
vue-password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#-
bxg_username: vue_pro_bxg
bxg_password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#-
server: server:
port: 48080 port: 48080
@@ -47,28 +55,22 @@ spring:
# ip: rm-2zey92ofhilzm3p4j0o.mysql.rds.aliyuncs.com:3306 # ip: rm-2zey92ofhilzm3p4j0o.mysql.rds.aliyuncs.com:3306
master: master:
name: vue_pro name: vue_pro
url: jdbc:mysql://rm-2zey92ofhilzm3p4j0o.mysql.rds.aliyuncs.com:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true url: jdbc:mysql://${mysql.url}:${mysql.port}/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
username: vue_pro username: ${mysql.vue-username}
password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#- password: ${mysql.vue-password}
slave: # 模拟从库,可根据自己需要修改 slave: # 模拟从库,可根据自己需要修改
name: vue_pro name: vue_pro
url: jdbc:mysql://rm-2zey92ofhilzm3p4j0o.mysql.rds.aliyuncs.com:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true url: jdbc:mysql://${mysql.url}:${mysql.port}/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
username: vue_pro username: ${mysql.vue-username}
password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#- password: ${mysql.vue-password}
bxg: # 农场数据源 bxg: # 农场数据源
name: vue_pro_bxg name: vue_pro_bxg
url: jdbc:mysql://rm-2zey92ofhilzm3p4j0o.mysql.rds.aliyuncs.com:3306/${spring.datasource.dynamic.datasource.bxg.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true url: jdbc:mysql://${mysql.url}:${mysql.port}/${spring.datasource.dynamic.datasource.bxg.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
username: vue_pro username: ${mysql.bxg-username}
password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#- password: ${mysql.bxg-password}
erp: # 农场数据源
name: vue_pro_erp
url: jdbc:mysql://rm-2zey92ofhilzm3p4j0o.mysql.rds.aliyuncs.com:3306/${spring.datasource.dynamic.datasource.erp.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
driver-class-name: com.mysql.cj.jdbc.Driver
username: vue_pro
password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#-
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis: redis:
@@ -76,6 +78,9 @@ spring:
port: 6379 # 端口 port: 6379 # 端口
database: 15 # 数据库索引 database: 15 # 数据库索引
flowable:
database-schema-update: false
--- #################### 定时任务相关配置 #################### --- #################### 定时任务相关配置 ####################
# Quartz 配置项,对应 QuartzProperties 配置类 # Quartz 配置项,对应 QuartzProperties 配置类
@@ -83,6 +83,7 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
@Autowired @Autowired
private ApplicationEventPublisher publisher; private ApplicationEventPublisher publisher;
@SneakyThrows @SneakyThrows
@Override @Override
//@Cacheable //@Cacheable
@@ -204,7 +205,10 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
//当前月份所有的商品分类 //当前月份所有的商品分类
}); });
return map; return map;
}; }
;
/*** /***
*根据榜单,分类,时间等获取商品信息 *根据榜单,分类,时间等获取商品信息
* ***/ * ***/
@@ -249,7 +253,9 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
}); });
return list; return list;
} }
; ;
@Override @Override
public List<HotListDTO> getList() { public List<HotListDTO> getList() {
LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>();
@@ -266,6 +272,7 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
String mouth = Collections.max(mouthList);//设定月份为最近的月份 String mouth = Collections.max(mouthList);//设定月份为最近的月份
//获取当前月份的榜单记录 //获取当前月份的榜单记录
List<YxStoreHotListRecord> recordList = yxStoreHotListRecordMapper.selectList(wrapper.eq(YxStoreHotListRecord::getMouth, mouth)); List<YxStoreHotListRecord> recordList = yxStoreHotListRecordMapper.selectList(wrapper.eq(YxStoreHotListRecord::getMouth, mouth));
// ???
LinkedHashSet<Integer> hotIdList = new LinkedHashSet<>(); LinkedHashSet<Integer> hotIdList = new LinkedHashSet<>();
//获得不重复的榜单id //获得不重复的榜单id
recordList.forEach(cate -> { recordList.forEach(cate -> {
@@ -276,8 +283,11 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
//批量查询榜单信息,并进行排序 //批量查询榜单信息,并进行排序
LambdaQueryWrapper<YxStoreHotList> wrapperList = new LambdaQueryWrapper<>(); LambdaQueryWrapper<YxStoreHotList> wrapperList = new LambdaQueryWrapper<>();
wrapperList.in(YxStoreHotList::getId, hotIdList).orderByAsc(YxStoreHotList::getSort); wrapperList.in(YxStoreHotList::getId, hotIdList).orderByAsc(YxStoreHotList::getSort);
// 榜单ID
ArrayList<Integer> list1 = new ArrayList<>(); ArrayList<Integer> list1 = new ArrayList<>();
yxStoreHotListMapper.selectList(wrapperList).forEach(yxHotList->list1.add(yxHotList.getId())); yxStoreHotListMapper.selectList(wrapperList).forEach(
yxHotList -> list1.add(yxHotList.getId())
);
ArrayList<HotListDTO> hotListDTOS = new ArrayList<>(); ArrayList<HotListDTO> hotListDTOS = new ArrayList<>();
//已经排序过的榜单 //已经排序过的榜单
list1.forEach(hotId -> { list1.forEach(hotId -> {