Browse Source

👍 修改为本地数据库。

sj
占永辉 2 years ago
parent
commit
eb76349932
  1. 2
      bin/sync.sh
  2. 18
      yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
  3. 71
      yudao-server/src/main/resources/application-local.yaml
  4. 35
      yudao-server/src/main/resources/application-prod.yaml
  5. 190
      zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java

2
bin/sync.sh

@ -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

18
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java

@ -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();

71
yudao-server/src/main/resources/application-local.yaml

@ -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:

35
yudao-server/src/main/resources/application-prod.yaml

@ -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 配置类

190
zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java

@ -1,11 +1,11 @@
/** /**
* Copyright (C) 2018-2020 * Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co * All rights reserved, Designed By www.yixiang.co
* 注意 * 注意
* 本软件为www.yixiang.co开发研制未经购买不得使用 * 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台 * 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台
* 一经发现盗用分享等行为将追究法律责任后果自负 * 一经发现盗用分享等行为将追究法律责任后果自负
*/ */
package co.yixiang.modules.hotList.service.impl; package co.yixiang.modules.hotList.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
@ -61,9 +61,9 @@ import java.util.*;
/** /**
* @author ssj * @author ssj
* @date 2022-10-08 * @date 2022-10-08
*/ */
@Service @Service
@AllArgsConstructor @AllArgsConstructor
//@CacheConfig(cacheNames = "yxStoreHotList") //@CacheConfig(cacheNames = "yxStoreHotList")
@ -83,24 +83,25 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
@Autowired @Autowired
private ApplicationEventPublisher publisher; private ApplicationEventPublisher publisher;
@SneakyThrows @SneakyThrows
@Override @Override
//@Cacheable //@Cacheable
public PageResult<YxStoreHotListVo> queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable) { public PageResult<YxStoreHotListVo> queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable) {
getPage(pageable); getPage(pageable);
PageInfo<YxStoreHotList> page = new PageInfo<>(queryAll(criteria)); PageInfo<YxStoreHotList> page = new PageInfo<>(queryAll(criteria));
PageResult<YxStoreHotListVo> result=generator.convertPageInfo(page, YxStoreHotListVo.class); PageResult<YxStoreHotListVo> result = generator.convertPageInfo(page, YxStoreHotListVo.class);
result.getContent().forEach(hotListVo->{ result.getContent().forEach(hotListVo -> {
List<Integer> productArr = JSONUtil.toList(hotListVo.getProductList(), Integer.class); List<Integer> productArr = JSONUtil.toList(hotListVo.getProductList(), Integer.class);
ArrayList<YxStoreProduct> list1 =new ArrayList<>(); ArrayList<YxStoreProduct> list1 = new ArrayList<>();
productArr.forEach(productId->{ productArr.forEach(productId -> {
LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue())
.eq(YxStoreProduct::getId, productId); .eq(YxStoreProduct::getId, productId);
//这里需要有一个非空判断 //这里需要有一个非空判断
YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper); YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper);
// YxStoreProduct storeProduct=storeProductMapper.selectById(productId); // YxStoreProduct storeProduct=storeProductMapper.selectById(productId);
if (ObjectUtil.isNotNull(storeProduct)){ if (ObjectUtil.isNotNull(storeProduct)) {
list1.add(storeProduct); list1.add(storeProduct);
} }
}); });
@ -112,12 +113,12 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
@Override @Override
//@Cacheable //@Cacheable
public List<YxStoreHotList> queryAll(YxStoreHotListQueryCriteria criteria){ public List<YxStoreHotList> queryAll(YxStoreHotListQueryCriteria criteria) {
//查出所有用户拥有的券使用时间小于24小时且未使用的券 //查出所有用户拥有的券使用时间小于24小时且未使用的券
Date now=new Date(); Date now = new Date();
Date endTime = DateUtil.offsetDay(now,1); Date endTime = DateUtil.offsetDay(now, 1);
List<YxStoreCouponUser> storeCouponUsers=yxStoreCouponUserMapper.selectUserCouponList(endTime); List<YxStoreCouponUser> storeCouponUsers = yxStoreCouponUserMapper.selectUserCouponList(endTime);
storeCouponUsers.forEach(storeCouponUser->{ storeCouponUsers.forEach(storeCouponUser -> {
//这里调用微信订阅模板发送消息 //这里调用微信订阅模板发送消息
TemplateBean templateBean = TemplateBean.builder() TemplateBean templateBean = TemplateBean.builder()
.couponId(storeCouponUser.getCid()) .couponId(storeCouponUser.getCid())
@ -135,15 +136,15 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
public void download(List<YxStoreHotListDto> all, HttpServletResponse response) throws IOException { public void download(List<YxStoreHotListDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
for (YxStoreHotListDto yxStoreHotList : all) { for (YxStoreHotListDto yxStoreHotList : all) {
Map<String,Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("榜单名称", yxStoreHotList.getListName()); map.put("榜单名称", yxStoreHotList.getListName());
map.put("排序", yxStoreHotList.getSort()); map.put("排序", yxStoreHotList.getSort());
map.put("商品列表", yxStoreHotList.getProductList()); map.put("商品列表", yxStoreHotList.getProductList());
map.put("是否显示", yxStoreHotList.getIsShow()); map.put("是否显示", yxStoreHotList.getIsShow());
map.put("添加时间", yxStoreHotList.getCreateTime()); map.put("添加时间", yxStoreHotList.getCreateTime());
map.put(" updateTime", yxStoreHotList.getUpdateTime()); map.put(" updateTime", yxStoreHotList.getUpdateTime());
map.put("删除状态", yxStoreHotList.getIsDel()); map.put("删除状态", yxStoreHotList.getIsDel());
map.put(" tenantId", yxStoreHotList.getTenantId()); map.put(" tenantId", yxStoreHotList.getTenantId());
list.add(map); list.add(map);
} }
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
@ -152,59 +153,62 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
/*** /***
*获取所有拥有榜单的月份,并获取对应榜单 *获取所有拥有榜单的月份,并获取对应榜单
* ***/ * ***/
public Map<String,Object>getHotListDataList(){ public Map<String, Object> getHotListDataList() {
Map<String, Object> map=new HashMap<>(); Map<String, Object> map = new HashMap<>();
LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()); wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue());
wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue());
//获取所有榜单记录列表(后期限制一年?) //获取所有榜单记录列表(后期限制一年?)
List<YxStoreHotListRecord> list=yxStoreHotListRecordMapper.selectList(wrapper); List<YxStoreHotListRecord> list = yxStoreHotListRecordMapper.selectList(wrapper);
if(list.isEmpty()){ if (list.isEmpty()) {
return null; return null;
} }
//获取月份 //获取月份
LinkedHashSet<String> mouthList=new LinkedHashSet<>(); LinkedHashSet<String> mouthList = new LinkedHashSet<>();
list.forEach(yxStoreHotListRecord -> mouthList.add(yxStoreHotListRecord.getMouth())); list.forEach(yxStoreHotListRecord -> mouthList.add(yxStoreHotListRecord.getMouth()));
map.put("mouthList",mouthList); map.put("mouthList", mouthList);
mouthList.forEach(mouth->{ mouthList.forEach(mouth -> {
LambdaQueryWrapper<YxStoreHotListRecord> wrapper2= SerializationUtils.clone(wrapper); LambdaQueryWrapper<YxStoreHotListRecord> wrapper2 = SerializationUtils.clone(wrapper);
//当前月份的所有榜单记录信息 //当前月份的所有榜单记录信息
List<YxStoreHotListRecord> recordList=yxStoreHotListRecordMapper.selectList(wrapper2.eq(YxStoreHotListRecord::getMouth,mouth)); List<YxStoreHotListRecord> recordList = yxStoreHotListRecordMapper.selectList(wrapper2.eq(YxStoreHotListRecord::getMouth, mouth));
LinkedHashSet<Integer> hotIdList=new LinkedHashSet<>(); LinkedHashSet<Integer> hotIdList = new LinkedHashSet<>();
//获得不重复的榜单信息 //获得不重复的榜单信息
recordList.forEach(cate->{ recordList.forEach(cate -> {
if(ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))){ if (ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))) {
hotIdList.add(cate.getHotListId()); hotIdList.add(cate.getHotListId());
} }
}); });
//批量查询榜单信息,并进行排序 //批量查询榜单信息,并进行排序
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);
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 -> {
LambdaQueryWrapper<YxStoreHotListRecord> wrapper1= SerializationUtils.clone(wrapper); LambdaQueryWrapper<YxStoreHotListRecord> wrapper1 = SerializationUtils.clone(wrapper);
//查出当前月份当前榜单的记录 //查出当前月份当前榜单的记录
List<YxStoreHotListRecord> recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth)); List<YxStoreHotListRecord> recordCateList = yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId, hotId).eq(YxStoreHotListRecord::getMouth, mouth));
LinkedHashSet<String> cateIdList=new LinkedHashSet<>(); LinkedHashSet<String> cateIdList = new LinkedHashSet<>();
//获得不重复的商品分类id //获得不重复的商品分类id
recordCateList.forEach(cate->{ recordCateList.forEach(cate -> {
if(ObjectUtil.isNotNull(storeCategoryMapper.selectById(cate.getCateId()))) if (ObjectUtil.isNotNull(storeCategoryMapper.selectById(cate.getCateId())))
cateIdList.add(cate.getCateId()); cateIdList.add(cate.getCateId());
}); });
ArrayList<CateDto> cateDtos=new ArrayList<>(); ArrayList<CateDto> cateDtos = new ArrayList<>();
//把该榜单下的分类封为一个数组 //把该榜单下的分类封为一个数组
cateIdList.forEach(cateId->cateDtos.add(new CateDto().setCateId(Long.valueOf(cateId)).setCateName(storeCategoryMapper.selectById(cateId).getCateName()))); cateIdList.forEach(cateId -> cateDtos.add(new CateDto().setCateId(Long.valueOf(cateId)).setCateName(storeCategoryMapper.selectById(cateId).getCateName())));
hotListDTOS.add(new HotListDTO().setId(Math.toIntExact(hotId)).setListName(yxStoreHotListMapper.selectById(hotId).getListName()) hotListDTOS.add(new HotListDTO().setId(Math.toIntExact(hotId)).setListName(yxStoreHotListMapper.selectById(hotId).getListName())
.setCateDtos(cateDtos) .setCateDtos(cateDtos)
.setListImage(yxStoreHotListMapper.selectById(hotId).getListImage())); .setListImage(yxStoreHotListMapper.selectById(hotId).getListImage()));
}); });
map.put(mouth,new HotListDataDto().setHotListDTOS(hotListDTOS)); map.put(mouth, new HotListDataDto().setHotListDTOS(hotListDTOS));
//当前月份所有的商品分类 //当前月份所有的商品分类
}); });
return map; return map;
}; }
;
/*** /***
*根据榜单,分类,时间等获取商品信息 *根据榜单,分类,时间等获取商品信息
* ***/ * ***/
@ -214,15 +218,15 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()); wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue());
wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue());
//按照商品分类id //按照商品分类id
if (queryParam.getCateId()!=null){ if (queryParam.getCateId() != null) {
wrapper.eq(YxStoreHotListRecord::getCateId,queryParam.getCateId()); wrapper.eq(YxStoreHotListRecord::getCateId, queryParam.getCateId());
} }
//评测id //评测id
if (queryParam.getHotListId()!=null){ if (queryParam.getHotListId() != null) {
wrapper.eq(YxStoreHotListRecord::getHotListId,queryParam.getHotListId()); wrapper.eq(YxStoreHotListRecord::getHotListId, queryParam.getHotListId());
} }
if (StringUtils.isNotBlank(queryParam.getMouth())){ if (StringUtils.isNotBlank(queryParam.getMouth())) {
wrapper.eq(YxStoreHotListRecord::getMouth,queryParam.getMouth()); wrapper.eq(YxStoreHotListRecord::getMouth, queryParam.getMouth());
} }
//默认销量降序排序 //默认销量降序排序
if (SortEnum.DESC.getValue().equals(queryParam.getSalesOrder())) { if (SortEnum.DESC.getValue().equals(queryParam.getSalesOrder())) {
@ -239,65 +243,71 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
Page<YxStoreHotListRecord> pageModel = new Page<>(queryParam.getPage(), queryParam.getLimit()); Page<YxStoreHotListRecord> pageModel = new Page<>(queryParam.getPage(), queryParam.getLimit());
IPage<YxStoreHotListRecord> pageList = yxStoreHotListRecordMapper.selectPage(pageModel, wrapper); IPage<YxStoreHotListRecord> pageList = yxStoreHotListRecordMapper.selectPage(pageModel, wrapper);
List<YxStoreProduct> list =new ArrayList<>(); List<YxStoreProduct> list = new ArrayList<>();
pageList.getRecords().forEach(yxStoreHotListRecord -> { pageList.getRecords().forEach(yxStoreHotListRecord -> {
YxStoreProduct yxStoreProduct=storeProductMapper.selectById(yxStoreHotListRecord.getProductId()); YxStoreProduct yxStoreProduct = storeProductMapper.selectById(yxStoreHotListRecord.getProductId());
if (ObjectUtil.isNotNull(yxStoreProduct)){ if (ObjectUtil.isNotNull(yxStoreProduct)) {
yxStoreProduct.setHotSales(yxStoreHotListRecord.getHotSales()); yxStoreProduct.setHotSales(yxStoreHotListRecord.getHotSales());
list.add(yxStoreProduct); list.add(yxStoreProduct);
} }
}); });
return list; return list;
} }
; ;
@Override @Override
public List<HotListDTO> getList() { public List<HotListDTO> getList() {
LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<YxStoreHotListRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue()); wrapper.eq(YxStoreHotListRecord::getIsShow, ShopCommonEnum.SHOW_1.getValue());
wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); wrapper.eq(YxStoreHotListRecord::getIsDel, CommonEnum.DEL_STATUS_0.getValue());
//获取所有榜单记录列表(后期限制一年?) //获取所有榜单记录列表(后期限制一年?)
List<YxStoreHotListRecord> list=yxStoreHotListRecordMapper.selectList(wrapper); List<YxStoreHotListRecord> list = yxStoreHotListRecordMapper.selectList(wrapper);
if(list.isEmpty()){ if (list.isEmpty()) {
return null; return null;
} }
//获取月份 //获取月份
LinkedHashSet<String> mouthList=new LinkedHashSet<>(); LinkedHashSet<String> mouthList = new LinkedHashSet<>();
list.forEach(yxStoreHotListRecord -> mouthList.add(yxStoreHotListRecord.getMouth())); list.forEach(yxStoreHotListRecord -> mouthList.add(yxStoreHotListRecord.getMouth()));
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 -> {
if(ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))){ if (ObjectUtil.isNotNull(yxStoreHotListMapper.selectById(cate.getHotListId()))) {
hotIdList.add(cate.getHotListId()); hotIdList.add(cate.getHotListId());
} }
}); });
//批量查询榜单信息,并进行排序 //批量查询榜单信息,并进行排序
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);
ArrayList <Integer> list1=new ArrayList<>(); // 榜单ID
yxStoreHotListMapper.selectList(wrapperList).forEach(yxHotList->list1.add(yxHotList.getId())); ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<HotListDTO> hotListDTOS=new ArrayList<>(); yxStoreHotListMapper.selectList(wrapperList).forEach(
yxHotList -> list1.add(yxHotList.getId())
);
ArrayList<HotListDTO> hotListDTOS = new ArrayList<>();
//已经排序过的榜单 //已经排序过的榜单
list1.forEach(hotId->{ list1.forEach(hotId -> {
LambdaQueryWrapper<YxStoreHotListRecord> wrapper1= SerializationUtils.clone(wrapper); LambdaQueryWrapper<YxStoreHotListRecord> wrapper1 = SerializationUtils.clone(wrapper);
//查出当前月份当前榜单的记录 //查出当前月份当前榜单的记录
List<YxStoreHotListRecord> recordCateList=yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId,hotId).eq(YxStoreHotListRecord::getMouth,mouth)); List<YxStoreHotListRecord> recordCateList = yxStoreHotListRecordMapper.selectList(wrapper1.eq(YxStoreHotListRecord::getHotListId, hotId).eq(YxStoreHotListRecord::getMouth, mouth));
//获得不重复的商品分类id //获得不重复的商品分类id
LinkedHashSet<String> cateIdList=new LinkedHashSet<>(); LinkedHashSet<String> cateIdList = new LinkedHashSet<>();
//当前榜单下的商品信息 //当前榜单下的商品信息
List<YxStoreProduct> productInfo=new ArrayList<>(); List<YxStoreProduct> productInfo = new ArrayList<>();
//获得不重复的商品分类id //获得不重复的商品分类id
recordCateList.forEach(cate->{ recordCateList.forEach(cate -> {
if(ObjectUtil.isNotNull(storeCategoryMapper.selectById(cate.getCateId()))){ if (ObjectUtil.isNotNull(storeCategoryMapper.selectById(cate.getCateId()))) {
cateIdList.add(cate.getCateId()); cateIdList.add(cate.getCateId());
} }
productInfo.add(storeProductMapper.selectById(cate.getProductId()).setHotSales(cate.getHotSales())); productInfo.add(storeProductMapper.selectById(cate.getProductId()).setHotSales(cate.getHotSales()));
}); });
ArrayList<CateDto> cateDtos=new ArrayList<>(); ArrayList<CateDto> cateDtos = new ArrayList<>();
//把该榜单下的分类封为一个数组 //把该榜单下的分类封为一个数组
cateIdList.forEach(cateId->cateDtos.add(new CateDto().setCateId(Long.valueOf(cateId)).setCateName(storeCategoryMapper.selectById(cateId).getCateName()))); cateIdList.forEach(cateId -> cateDtos.add(new CateDto().setCateId(Long.valueOf(cateId)).setCateName(storeCategoryMapper.selectById(cateId).getCateName())));
hotListDTOS.add(new HotListDTO().setId(Math.toIntExact(hotId)).setListName(yxStoreHotListMapper.selectById(hotId).getListName()) hotListDTOS.add(new HotListDTO().setId(Math.toIntExact(hotId)).setListName(yxStoreHotListMapper.selectById(hotId).getListName())
.setCateDtos(cateDtos) .setCateDtos(cateDtos)
.setProductInfo(productInfo) .setProductInfo(productInfo)
@ -307,7 +317,7 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
} }
private List<HotListDTO> getHotListDTOS(LambdaQueryWrapper<YxStoreHotList> wrapper) { private List<HotListDTO> getHotListDTOS(LambdaQueryWrapper<YxStoreHotList> wrapper) {
List<HotListDTO> list = generator.convert(baseMapper.selectList(wrapper),HotListDTO.class); List<HotListDTO> list = generator.convert(baseMapper.selectList(wrapper), HotListDTO.class);
// list.forEach(hotListDto->{ // list.forEach(hotListDto->{
// List<Integer> productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class); // List<Integer> productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class);
// List<YxStoreProduct> list1 =new ArrayList<>(); // List<YxStoreProduct> list1 =new ArrayList<>();

Loading…
Cancel
Save