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({
@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,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试
})
@ -89,23 +88,6 @@ public class YudaoMybatisAutoConfiguration {
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 {
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:
port: 48080
@ -42,56 +50,23 @@ spring:
test-on-return: false
datasource:
master:
url: jdbc:p6spy:mysql://192.168.10.250: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: root
name: vue_pro
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
username: ${mysql.vue-username}
password: ${mysql.vue-password}
slave: # 模拟从库,可根据自己需要修改
url: jdbc:p6spy:mysql://192.168.10.250: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: root
name: vue_pro
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
username: ${mysql.vue-username}
password: ${mysql.vue-password}
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
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
username: root
password: root
erp: # 进销存
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
name: vue_pro_bxg
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
username: ${mysql.bxg-username}
password: ${mysql.bxg-password}
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
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:
port: 48080
@ -47,28 +55,22 @@ spring:
# ip: rm-2zey92ofhilzm3p4j0o.mysql.rds.aliyuncs.com:3306
master:
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
username: vue_pro
password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#-
username: ${mysql.vue-username}
password: ${mysql.vue-password}
slave: # 模拟从库,可根据自己需要修改
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
username: vue_pro
password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#-
username: ${mysql.vue-username}
password: ${mysql.vue-password}
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
username: vue_pro
password: CrnPu&g8HqbBikrA&DH-llRgtvpIrG#-
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#-
username: ${mysql.bxg-username}
password: ${mysql.bxg-password}
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
@ -76,6 +78,9 @@ spring:
port: 6379 # 端口
database: 15 # 数据库索引
flowable:
database-schema-update: false
--- #################### 定时任务相关配置 ####################
# Quartz 配置项,对应 QuartzProperties 配置类

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

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

Loading…
Cancel
Save