From 345c885daca9ce4a7d5bc6c76b43ee9eb0c237d2 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 8 Aug 2022 13:59:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feigns/JiMuReportOpenFeignClient.java | 14 +++++++ .../JiMuReportOpenFeignClientFallback.java | 11 ++++++ .../tools/constant/ServiceConstant.java | 5 +++ .../tools/dto/form/DictListFormDTO.java | 4 ++ .../com/epmet/dto/result/ReportResultDTO.java | 2 +- .../constant/CustomerFunctionConstant.java | 2 + .../impl/IcCustomerReportServiceImpl.java | 38 ++++++++++++++++++- 7 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java create mode 100644 epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java diff --git a/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java new file mode 100644 index 0000000000..69f1f84c70 --- /dev/null +++ b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java @@ -0,0 +1,14 @@ +package com.epmet.commons.feignclient.feigns; + +import com.epmet.commons.feignclient.feigns.fallback.JiMuReportOpenFeignClientFallback; +import com.epmet.commons.tools.constant.ServiceConstant; +import org.springframework.cloud.openfeign.FeignClient; + +/** + * @Author zxc + * @DateTime 2022/8/8 13:52 + * @DESC + */ +@FeignClient(name = ServiceConstant.JM_REPORT, fallbackFactory = JiMuReportOpenFeignClientFallback.class) +public interface JiMuReportOpenFeignClient { +} diff --git a/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java new file mode 100644 index 0000000000..f1ca95d23d --- /dev/null +++ b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java @@ -0,0 +1,11 @@ +package com.epmet.commons.feignclient.feigns.fallback; + +import com.epmet.commons.feignclient.feigns.JiMuReportOpenFeignClient; + +/** + * @Author zxc + * @DateTime 2022/8/8 13:53 + * @DESC + */ +public class JiMuReportOpenFeignClientFallback implements JiMuReportOpenFeignClient { +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java index 221d7d3f69..b753a7d65b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java @@ -143,4 +143,9 @@ public interface ServiceConstant { * 聚合查询服务 */ String DATA_AGGREGATOR_SERVER = "data-aggregator-server"; + + /** + * + */ + String JM_REPORT = ""; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DictListFormDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DictListFormDTO.java index 1880debe42..88adefbd17 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DictListFormDTO.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/DictListFormDTO.java @@ -1,6 +1,8 @@ package com.epmet.commons.tools.dto.form; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import javax.validation.constraints.NotBlank; @@ -9,6 +11,8 @@ import javax.validation.constraints.NotBlank; * @Author sun */ @Data +@AllArgsConstructor +@NoArgsConstructor public class DictListFormDTO { /** diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/ReportResultDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/ReportResultDTO.java index cbbc75acca..0667a0c226 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/ReportResultDTO.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/ReportResultDTO.java @@ -57,7 +57,7 @@ public class ReportResultDTO implements Serializable { @Data - static class CustomerList implements Serializable{ + public static class CustomerList implements Serializable{ private static final long serialVersionUID = 7146198312265513418L; diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/constant/CustomerFunctionConstant.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/constant/CustomerFunctionConstant.java index dc347a7c53..5d41b4453c 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/constant/CustomerFunctionConstant.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/constant/CustomerFunctionConstant.java @@ -23,5 +23,7 @@ public interface CustomerFunctionConstant { */ String PARAMETER_EXCEPTION = "请至少勾选一条默认功能或定制功能数据"; + String REPORT_CATEGORY = "jmreport_category"; + } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java index 206e9c2d74..5e8e770abe 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java @@ -4,13 +4,21 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.form.DictListFormDTO; +import com.epmet.commons.tools.dto.result.DictListResultDTO; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.CustomerFunctionConstant; import com.epmet.dao.IcCustomerReportDao; +import com.epmet.dto.CustomerDTO; import com.epmet.dto.IcCustomerReportDTO; import com.epmet.dto.result.ReportResultDTO; import com.epmet.entity.IcCustomerReportEntity; import com.epmet.feign.EpmetAdminOpenFeignClient; +import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.service.IcCustomerReportService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -22,6 +30,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 客户报表关系表 @@ -34,6 +43,8 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl page(Map params) { @@ -99,8 +110,31 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl(); } - - return null; + Result> dictList = adminOpenFeignClient.dictList(new DictListFormDTO(CustomerFunctionConstant.REPORT_CATEGORY)); + if (!dictList.success()){ + throw new EpmetException("查询字典信息失败:" + CustomerFunctionConstant.REPORT_CATEGORY); + } + if (CollectionUtils.isNotEmpty(dictList.getData())){ + dictList.getData().forEach(d -> reportList.stream().filter(r -> d.getValue().equals(r.getCategoryKey())).forEach(r -> r.setCategoryName(d.getLabel()))); + } + Result> allCustomerList = operCrmOpenFeignClient.getAllCustomerList(); + if (!allCustomerList.success()){ + throw new EpmetException("获取客户信息失败..."); + } + if (CollectionUtils.isNotEmpty(allCustomerList.getData())){ + allCustomerList.getData().forEach(c -> reportList.stream().filter(r -> c.getId().equals(r.getCustomerId())).forEach(r -> r.setCustomerName(c.getCustomerName()))); + } + // todo 报表 + List result = new ArrayList<>(); + Map> groupByReport = reportList.stream().collect(Collectors.groupingBy(ReportResultDTO::getReportId)); + groupByReport.forEach((reportId,l) -> { + ReportResultDTO dto = new ReportResultDTO(); + dto.setReportId(reportId); + dto.setReportName(l.get(NumConstant.ZERO).getReportName()); + dto.setCustomerList(ConvertUtils.sourceToTarget(l, ReportResultDTO.CustomerList.class)); + result.add(dto); + }); + return result; } } \ No newline at end of file