|
@@ -2,20 +2,21 @@ package com.fire.admin.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fire.admin.mapper.ChannelInfoMapper;
|
|
|
+import com.fire.admin.mapper.FireProductMapper;
|
|
|
import com.fire.admin.request.ChannelPageParam;
|
|
|
import com.fire.admin.service.ChannelInfoService;
|
|
|
import com.fire.admin.service.ChannelProductService;
|
|
|
import com.fire.dto.ChannelInfo;
|
|
|
import com.fire.dto.ChannelProductInfo;
|
|
|
+import com.fire.dto.FireProductInfo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author: admin
|
|
@@ -29,6 +30,9 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
@Autowired
|
|
|
private ChannelProductService channelProductService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FireProductMapper fireProductMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<ChannelInfo> getChannelList(ChannelPageParam channelPageParam) {
|
|
|
LambdaQueryWrapper<ChannelInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -38,16 +42,9 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
.eq(ChannelInfo::getIsDelete, 0);
|
|
|
IPage<ChannelInfo> channelInfoList = baseMapper.selectPage(channelPageParam, lambdaQueryWrapper);
|
|
|
if (channelInfoList != null) {
|
|
|
- List<Long> channelInfoIds = new ArrayList<>();
|
|
|
- for (ChannelInfo channelInfo : channelInfoList.getRecords()) {
|
|
|
- channelInfoIds.add(channelInfo.getChannelId());
|
|
|
- }
|
|
|
-
|
|
|
- List<ChannelProductInfo> channelProductInfos = new ArrayList<>();
|
|
|
|
|
|
- Map<Long, List<ChannelProductInfo>> map = channelProductInfos.stream().collect(Collectors.groupingBy(ChannelProductInfo::getChannelId));
|
|
|
- for (ChannelInfo channelInfo : channelInfoList.getRecords()) {
|
|
|
- channelInfo.setChannelProductInfos(map.get(channelInfo.getChannelId()));
|
|
|
+ for (ChannelInfo info : channelInfoList.getRecords()) {
|
|
|
+ info.setChannelProductInfos(channelProductService.getChannelProductList(info.getChannelId()));
|
|
|
}
|
|
|
return channelInfoList;
|
|
|
} else {
|
|
@@ -56,7 +53,14 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ChannelProductInfo> updateChannelInfoById(ChannelInfo channelInfo) {
|
|
|
+ public List<FireProductInfo> getProductByProductName(Integer operator) {
|
|
|
+ return new LambdaQueryChainWrapper<>(fireProductMapper).eq(operator != null, FireProductInfo::getOperator, operator).list();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateChannelInfoById(ChannelInfo channelInfo) {
|
|
|
+ channelInfo.setUpdator("admin");
|
|
|
+ channelInfo.setUpdateTime(new Date());
|
|
|
int result = baseMapper.updateById(channelInfo);
|
|
|
if (result > 0) {
|
|
|
// TODO: 2021/5/24 向MQ推送消息
|
|
@@ -64,27 +68,32 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
if (channelInfo.getChannelProductInfos() != null) {
|
|
|
channelProductService.saveChannelProducts(channelInfo.getChannelProductInfos());
|
|
|
}
|
|
|
- List<ChannelProductInfo> channelProductList = channelProductService.getChannelProductList(channelInfo.getChannelId());
|
|
|
- if (channelProductList != null) {
|
|
|
- return channelProductList;
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void insertChannelInfo(ChannelInfo channelInfo) {
|
|
|
-
|
|
|
- int result = baseMapper.insert(channelInfo);
|
|
|
- if (result > 0) {
|
|
|
- // TODO: 2021/5/24 向MQ推送消息
|
|
|
+ channelInfo.setCreator("admin");
|
|
|
+ channelInfo.setCreateTime(new Date());
|
|
|
+ List<FireProductInfo> fireProductInfos = this.getProductByProductName(channelInfo.getOperator());
|
|
|
+ List<ChannelProductInfo> channelProductInfos = channelInfo.getChannelProductInfos();
|
|
|
+ for (FireProductInfo fireProductInfo : fireProductInfos) {
|
|
|
+ String fireProductName = fireProductInfo.getProductName();
|
|
|
+ for (ChannelProductInfo channelProductInfo : channelProductInfos) {
|
|
|
+ String channelProductName = channelProductInfo.getChannelProductName();
|
|
|
+ if (fireProductInfos != null && !fireProductName.equals(channelProductName)) {
|
|
|
+ int result = baseMapper.insert(channelInfo);
|
|
|
+ if (result > 0) {
|
|
|
+ // TODO: 2021/5/24 向MQ推送消息
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void deleteChannelById(Integer channelId) {
|
|
|
- int result = baseMapper.delChannelById(channelId);
|
|
|
+ int result = baseMapper.deleteById(channelId);
|
|
|
if (result > 0) {
|
|
|
// TODO: 2021/5/20 向MQ推送消息
|
|
|
}
|