TASK:mixi;
This commit is contained in:
@@ -70,6 +70,14 @@ public enum RolePermissionResourceEnum {
|
|||||||
* Mi-Tu 报表
|
* Mi-Tu 报表
|
||||||
*/
|
*/
|
||||||
REPORT_EXPORTING("Report Exporting","REPORT_EXPORTING",null,null,null,11),
|
REPORT_EXPORTING("Report Exporting","REPORT_EXPORTING",null,null,null,11),
|
||||||
|
/**
|
||||||
|
* 激励规则
|
||||||
|
*/
|
||||||
|
MOTIVATIONAL_TASKS("Motivational Tasks","MOTIVATIONAL_TASKS",null,null,null,12),
|
||||||
|
/**
|
||||||
|
* 激励排名
|
||||||
|
*/
|
||||||
|
MOTIVATIONAL_RANKING("Motivational Ranking","MOTIVATIONAL_RANKING",null,null,null,13),
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -37,6 +38,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -893,7 +895,7 @@ public class MiTuExportScheduledTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void linkImageToCell(Workbook workbook, Sheet sheet, int startRow, int endRow, int colNum, String imagePath) throws IOException {
|
private void linkImageToCell(Workbook workbook, Sheet sheet, int startRow, int endRow, int colNum, String imagePath) throws IOException {
|
||||||
try (InputStream inputStream = minioUtil.download("mi-tu/26/BOTTOM/PANTS/MKTS27000_0BLK.jpg")) {
|
try (InputStream inputStream = minioUtil.download("mi-tu/26/BOTTOM/PANTS/MKTS27000_0CMY_copy.jpg")) {
|
||||||
byte[] bytes = IOUtils.toByteArray(inputStream);
|
byte[] bytes = IOUtils.toByteArray(inputStream);
|
||||||
int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
|
int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
|
||||||
|
|
||||||
@@ -2766,4 +2768,44 @@ public class MiTuExportScheduledTask {
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 压缩图片
|
||||||
|
* @param inputImagePath 原始图片路径
|
||||||
|
* @param outputImagePath 压缩后图片保存路径
|
||||||
|
* @param scaledWidth 压缩后图片的宽度
|
||||||
|
* @param scaledHeight 压缩后图片的高度
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
// public static void compressImage(String inputImagePath, String outputImagePath, int scaledWidth, int scaledHeight) throws IOException {
|
||||||
|
// // 读取图片
|
||||||
|
// BufferedImage inputImage = ImageIO.read(new File(inputImagePath));
|
||||||
|
//
|
||||||
|
// // 创建输出图片
|
||||||
|
// BufferedImage outputImage = new BufferedImage(scaledWidth, scaledHeight, inputImage.getType());
|
||||||
|
//
|
||||||
|
// // 绘制缩放后的图片
|
||||||
|
// Graphics2D g2d = outputImage.createGraphics();
|
||||||
|
// g2d.drawImage(inputImage.getScaledInstance(scaledWidth, scaledHeight, Image.SCALE_SMOOTH), 0, 0, null);
|
||||||
|
// g2d.dispose();
|
||||||
|
//
|
||||||
|
// // 保存到文件
|
||||||
|
// ImageIO.write(outputImage, "jpg", new File(outputImagePath));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// String inputImagePath = "C:\\Users\\10233\\Desktop\\2024 SS\\MKTS27000_0CMY.jpg";
|
||||||
|
// String outputImagePath = "C:\\Users\\10233\\Desktop\\2024 SS\\MKTS27000_0CMY_copy.jpg";
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// // 压缩图片到指定大小
|
||||||
|
// int scaledWidth = 300;
|
||||||
|
// int scaledHeight = 300;
|
||||||
|
// compressImage(inputImagePath, outputImagePath, scaledWidth, scaledHeight);
|
||||||
|
//
|
||||||
|
// System.out.println("图片压缩完成。");
|
||||||
|
// } catch (IOException ex) {
|
||||||
|
// System.out.println("图片压缩出错: " + ex.getMessage());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
package com.mixi.service;
|
package com.mixi.service;
|
||||||
|
|
||||||
import com.mixi.common.response.PageBaseResponse;
|
import com.mixi.common.response.PageBaseResponse;
|
||||||
import com.mixi.common.response.Response;
|
|
||||||
import com.mixi.mapper.entity.MiTuExport;
|
|
||||||
import com.mixi.mapper.entity.MiTuMember;
|
import com.mixi.mapper.entity.MiTuMember;
|
||||||
import com.mixi.model.dto.QueryMiTuExportPageDTO;
|
import com.mixi.model.dto.QueryMiTuExportPageDTO;
|
||||||
import com.mixi.model.vo.MiTuExportVO;
|
import com.mixi.model.vo.MiTuExportVO;
|
||||||
import io.minio.errors.MinioException;
|
import io.minio.errors.MinioException;
|
||||||
import org.springframework.core.io.InputStreamResource;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -30,5 +25,5 @@ public interface MiTuExportService {
|
|||||||
|
|
||||||
List<MiTuMember> queryMiTuMemberList(String phone);
|
List<MiTuMember> queryMiTuMemberList(String phone);
|
||||||
|
|
||||||
List<Long> getProductIdsByMiTuMemberCode(String memberCode);
|
List<Long> getProductIdsByMiTuMemberCode(String memberCode, List<Long> productIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,10 +163,31 @@ public class TAppProductService extends ServiceImpl<TProductMapper, TProduct> {
|
|||||||
List<Long> productIds = new ArrayList<>();
|
List<Long> productIds = new ArrayList<>();
|
||||||
List<Long> productIdsByMemberCode = new ArrayList<>(); // 初始化 productIdsByMemberCode
|
List<Long> productIdsByMemberCode = new ArrayList<>(); // 初始化 productIdsByMemberCode
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(query.getLabelItem())) {
|
||||||
|
List<Long> byItemAndType = tProductAttributeService.findByItemAndType(query.getLabelItem(), null);
|
||||||
|
if (CollectionUtils.isEmpty(byItemAndType)) {
|
||||||
|
return PageBaseResponse.success(new Page<>());
|
||||||
|
}
|
||||||
|
productIds.addAll(byItemAndType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(query.getStoreId())) {
|
||||||
|
List<Long> stockProductIdList = tProductStockService.findByStoreIds(Collections.singletonList(query.getStoreId()));
|
||||||
|
if(CollectionUtils.isEmpty(stockProductIdList)){
|
||||||
|
return PageBaseResponse.success(new Page<>());
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(query.getLabelItem())) {
|
||||||
|
productIds.retainAll(stockProductIdList);
|
||||||
|
}else {
|
||||||
|
productIds.addAll(stockProductIdList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(query.getMemberCode())) {
|
if (!StringUtils.isEmpty(query.getMemberCode())) {
|
||||||
// 获取三页商品ID列表
|
// 获取三页商品ID列表
|
||||||
productIdsByMemberCode = miTuExportService.getProductIdsByMiTuMemberCode(query.getMemberCode());
|
productIdsByMemberCode = miTuExportService.getProductIdsByMiTuMemberCode(query.getMemberCode(), productIds);
|
||||||
productIds.addAll(productIdsByMemberCode);
|
// productIds.addAll(productIdsByMemberCode);
|
||||||
|
productIds = productIdsByMemberCode;
|
||||||
if (CollectionUtils.isEmpty(productIds)) {
|
if (CollectionUtils.isEmpty(productIds)) {
|
||||||
return PageBaseResponse.success(new Page<>());
|
return PageBaseResponse.success(new Page<>());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package com.mixi.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.mixi.mapper.TProductStockMapper;
|
import com.mixi.mapper.TProductStockMapper;
|
||||||
import com.mixi.mapper.entity.TProduct;
|
import com.mixi.mapper.entity.TProduct;
|
||||||
import com.mixi.mapper.entity.TProductLabel;
|
import com.mixi.mapper.entity.TProductLabel;
|
||||||
@@ -14,6 +17,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@@ -41,10 +45,35 @@ public class TProductStockService extends ServiceImpl<TProductStockMapper, TProd
|
|||||||
QueryWrapper<TProductStock> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<TProductStock> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.in("store_id", storeIds);
|
queryWrapper.in("store_id", storeIds);
|
||||||
List<TProductStock> result = tProductStockMapper.selectList(queryWrapper);
|
List<TProductStock> result = tProductStockMapper.selectList(queryWrapper);
|
||||||
return CollectionUtils.isEmpty(result)?null :
|
|
||||||
result.stream().map(TProductStock::getProductId).distinct().collect(Collectors.toList());
|
|
||||||
|
|
||||||
|
// 如果查询结果为空,返回 null
|
||||||
|
if (CollectionUtils.isEmpty(result)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 过滤并获取 productId
|
||||||
|
return result.stream()
|
||||||
|
.filter(this::hasPositiveStock) // 使用单独的方法来处理过滤逻辑
|
||||||
|
.map(TProductStock::getProductId)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断 stock_content 中是否有 num > 0
|
||||||
|
private boolean hasPositiveStock(TProductStock productStock) {
|
||||||
|
List<Map<String, Object>> stockContent;
|
||||||
|
try {
|
||||||
|
stockContent = new ObjectMapper().readValue(productStock.getStockContent(), new TypeReference<List<Map<String, Object>>>() {});
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false; // 解析失败的记录跳过
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有 num > 0 的情况
|
||||||
|
return stockContent.stream()
|
||||||
|
.anyMatch(entry -> (Integer) entry.get("num") > 0);
|
||||||
|
}
|
||||||
|
|
||||||
public List<TProductStock> findByProductIds(List<Long> productIds) {
|
public List<TProductStock> findByProductIds(List<Long> productIds) {
|
||||||
QueryWrapper<TProductStock> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<TProductStock> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.in("product_id", productIds);
|
queryWrapper.in("product_id", productIds);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.mixi.common.config.exception.BusinessException;
|
import com.mixi.common.config.exception.BusinessException;
|
||||||
import com.mixi.common.response.PageBaseResponse;
|
import com.mixi.common.response.PageBaseResponse;
|
||||||
import com.mixi.common.tasks.mituExportEntity.WeeklyHeavyStock;
|
|
||||||
import com.mixi.common.utils.CopyUtil;
|
import com.mixi.common.utils.CopyUtil;
|
||||||
import com.mixi.common.utils.MinioUtil;
|
import com.mixi.common.utils.MinioUtil;
|
||||||
import com.mixi.mapper.MiTuExportMapper;
|
import com.mixi.mapper.MiTuExportMapper;
|
||||||
@@ -34,7 +33,6 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
//import com.ai.da.common.utils.SendSmsUtil;
|
//import com.ai.da.common.utils.SendSmsUtil;
|
||||||
|
|
||||||
@@ -148,7 +146,7 @@ public class MiTuExportServiceImpl implements MiTuExportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Long> getProductIdsByMiTuMemberCode(String memberCode) {
|
public List<Long> getProductIdsByMiTuMemberCode(String memberCode, List<Long> productIds) {
|
||||||
// 顾客类型筛选
|
// 顾客类型筛选
|
||||||
QueryWrapper<MiTuMember> qw = new QueryWrapper<>();
|
QueryWrapper<MiTuMember> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(MiTuMember::getMbrCode, memberCode);
|
qw.lambda().eq(MiTuMember::getMbrCode, memberCode);
|
||||||
@@ -160,6 +158,7 @@ public class MiTuExportServiceImpl implements MiTuExportService {
|
|||||||
MiTuMember member = miTuMembers.get(0);
|
MiTuMember member = miTuMembers.get(0);
|
||||||
// 根据顾客代码获取筛选后的商品ID列表
|
// 根据顾客代码获取筛选后的商品ID列表
|
||||||
List<Long> productIdList = getProductIdListByMemberType(member);
|
List<Long> productIdList = getProductIdListByMemberType(member);
|
||||||
|
productIdList.retainAll(productIds);
|
||||||
if (CollectionUtils.isEmpty(productIdList)) {
|
if (CollectionUtils.isEmpty(productIdList)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,13 +135,22 @@
|
|||||||
<foreach item="item" index="index" collection="productIdList" open="(" separator="," close=")">
|
<foreach item="item" index="index" collection="productIdList" open="(" separator="," close=")">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
)
|
),
|
||||||
|
MaxScorePerGroup AS (
|
||||||
SELECT
|
SELECT
|
||||||
product_id,
|
product_id,
|
||||||
price_sales,
|
size,
|
||||||
sum(score) as score
|
MAX(score) AS max_score
|
||||||
FROM ProductScores
|
FROM ProductScores
|
||||||
GROUP BY product_id,price_sales
|
GROUP BY product_id, size
|
||||||
ORDER BY score DESC
|
)
|
||||||
|
SELECT
|
||||||
|
ps.product_id,
|
||||||
|
ps.price_sales,
|
||||||
|
MAX(ms.max_score) AS score
|
||||||
|
FROM ProductScores ps
|
||||||
|
JOIN MaxScorePerGroup ms ON ps.product_id = ms.product_id AND ps.size = ms.size AND ps.score = ms.max_score
|
||||||
|
GROUP BY ps.product_id, ps.price_sales
|
||||||
|
ORDER BY score DESC;
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user