From 41c03b27ad469eb98a100eaf2f676647944b6b96 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Thu, 25 Apr 2024 04:21:56 +0800 Subject: [PATCH] TASK:mixi; --- .../common/tasks/MiTuExportScheduledTask.java | 43 ++++++++++++++++--- .../com/mixi/service/TAppProductService.java | 2 +- .../service/impl/MiTuExportServiceImpl.java | 23 +++++++++- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/mixi/common/tasks/MiTuExportScheduledTask.java b/src/main/java/com/mixi/common/tasks/MiTuExportScheduledTask.java index 4b65a26..c1127c5 100644 --- a/src/main/java/com/mixi/common/tasks/MiTuExportScheduledTask.java +++ b/src/main/java/com/mixi/common/tasks/MiTuExportScheduledTask.java @@ -58,7 +58,7 @@ public class MiTuExportScheduledTask { // weeklySellThrReport(); // WeeklyHeavyStockReport(); // QuarterlyProductGroupingReport(); - customerTypeAnalysis(); +// customerTypeAnalysis(); // getBestSell(); } @@ -1831,14 +1831,43 @@ public class MiTuExportScheduledTask { member.setMbrName(rs.getString("mbr_name")); member.setMbrMobile(rs.getString("mbr_mobile")); member.setMbrGroup(rs.getString("mbr_group")); - member.setMbrStatus(rs.getString("mbr_status").charAt(0)); - member.setJoinDate(rs.getDate("join_date").toLocalDate()); + + // Check if "mbr_status" is not NULL + String mbrStatus = rs.getString("mbr_status"); + if (mbrStatus != null) { + member.setMbrStatus(mbrStatus.charAt(0)); + } else { + // Handle NULL value for "mbr_status" + } + + // Check if "join_date" is not NULL + Date joinDate = rs.getDate("join_date"); + if (joinDate != null) { + member.setJoinDate(joinDate.toLocalDate()); + } else { + // Handle NULL value for "join_date" + } + member.setMbrIssue(rs.getString("mbr_issue")); member.setBirthMonth(rs.getInt("birth_m")); - member.setMbrSex(rs.getString("mbr_sex").charAt(0)); - member.setOffBonus(rs.getDouble("off_bonus")); - member.setEffBonus(rs.getDouble("eff_bonus")); - member.setSumBonus(rs.getDouble("sum_bonus")); + + // Check if "mbr_sex" is not NULL + String mbrSex = rs.getString("mbr_sex"); + if (mbrSex != null) { + member.setMbrSex(mbrSex.charAt(0)); + } else { + // Handle NULL value for "mbr_sex" + } + + // Check if "off_bonus" is not NULL + double offBonus = rs.getDouble("off_bonus"); + if (!rs.wasNull()) { + member.setOffBonus(offBonus); + } else { + // Handle NULL value for "off_bonus" + } + + // Repeat similar checks for other fields... } // 清理环境 diff --git a/src/main/java/com/mixi/service/TAppProductService.java b/src/main/java/com/mixi/service/TAppProductService.java index b46ef5f..5797eb1 100644 --- a/src/main/java/com/mixi/service/TAppProductService.java +++ b/src/main/java/com/mixi/service/TAppProductService.java @@ -344,7 +344,7 @@ public class TAppProductService extends ServiceImpl { return sortedList; } - private Map getProductIdListByQueryType(Integer type) { + public Map getProductIdListByQueryType(Integer type) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate today = LocalDate.now(); String startDate = ""; diff --git a/src/main/java/com/mixi/service/impl/MiTuExportServiceImpl.java b/src/main/java/com/mixi/service/impl/MiTuExportServiceImpl.java index 646f450..a134b1b 100644 --- a/src/main/java/com/mixi/service/impl/MiTuExportServiceImpl.java +++ b/src/main/java/com/mixi/service/impl/MiTuExportServiceImpl.java @@ -19,6 +19,7 @@ import com.mixi.mapper.entity.TProduct; import com.mixi.model.dto.QueryMiTuExportPageDTO; import com.mixi.model.vo.MiTuExportVO; import com.mixi.service.MiTuExportService; +import com.mixi.service.TAppProductService; import com.mixi.service.TProductService; import io.minio.errors.MinioException; import lombok.extern.slf4j.Slf4j; @@ -38,6 +39,7 @@ import java.net.URLEncoder; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -68,6 +70,8 @@ public class MiTuExportServiceImpl implements MiTuExportService { @Resource private TProductMapper productMapper; + @Resource + private TAppProductService appProductService; @Override public PageBaseResponse queryMiTuExportPage(QueryMiTuExportPageDTO query) { @@ -162,7 +166,17 @@ public class MiTuExportServiceImpl implements MiTuExportService { switch (memberType) { case "Type D" : { // 根据牌子、款式、颜色推荐 - return new ArrayList<>(); + QueryWrapper miTuProductQueryWrapper = new QueryWrapper<>(); + miTuProductQueryWrapper.lambda().like(MiTuProduct::getColor, miTuMembers.get(0).getMostFrequentColor()); + List miTuProductList = miTuProductMapper.selectList(miTuProductQueryWrapper); + if (CollectionUtils.isEmpty(miTuProductList)) { + return new ArrayList<>(); + } + Set collect = miTuProductList.stream().map(MiTuProduct::getProductId).collect(Collectors.toSet()); + if (CollectionUtils.isEmpty(collect)) { + return new ArrayList<>(); + } + return new ArrayList<>(collect); } case "Type i" : { QueryWrapper miTuProductQueryWrapper = new QueryWrapper<>(); @@ -194,7 +208,12 @@ public class MiTuExportServiceImpl implements MiTuExportService { } case "Type S" : { // Sell through 前20 - return new ArrayList<>(); + Map productIdNumMap = appProductService.getProductIdListByQueryType(3); + List collect = productIdNumMap.keySet().stream().collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)) { + return new ArrayList<>(); + } + return collect; } default : throw new BusinessException("Unknown memberType.");