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..0c5dfb97ef --- /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.EPMET_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..61a428a953 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 EPMET_JM_REPORT = "epmet-jmreport-server"; } 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 new file mode 100644 index 0000000000..0667a0c226 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/ReportResultDTO.java @@ -0,0 +1,84 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/8/8 10:29 + * @DESC + */ +@Data +public class ReportResultDTO implements Serializable { + + private static final long serialVersionUID = -5798816843431200300L; + + /** + * 报表名字 + */ + private String reportName; + + /** + * 报表ID + */ + private String reportId; + + /** + * 客户ID + */ + @JsonIgnore + private String customerId; + + /** + * 客户名字 + */ + @JsonIgnore + private String customerName; + + /** + * 分类名字 + */ + @JsonIgnore + private String categoryName; + + /** + * 分类key + */ + @JsonIgnore + private String categoryKey; + + /** + * 客户信息集合 + */ + private List customerList; + + + @Data + public static class CustomerList implements Serializable{ + + private static final long serialVersionUID = 7146198312265513418L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 客户名字 + */ + private String customerName; + + /** + * 分类名字 + */ + private String categoryName; + + /** + * 分类key + */ + private String categoryKey; + } +} 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/controller/IcCustomerReportController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcCustomerReportController.java index 7c8a317964..a00410f7a7 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcCustomerReportController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcCustomerReportController.java @@ -11,12 +11,14 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.IcCustomerReportDTO; +import com.epmet.dto.result.ReportResultDTO; import com.epmet.dto.form.PreviewReportFormDTO; import com.epmet.dto.result.PreviewReportResDTO; import com.epmet.service.IcCustomerReportService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; @@ -71,6 +73,17 @@ public class IcCustomerReportController { return new Result(); } + /** + * Desc: 报表集合 + * @param + * @author zxc + * @date 2022/8/8 10:38 + */ + @PostMapping("list") + public Result> reportList(){ + return new Result>().ok(icCustomerReportService.reportList()); + } + /** * 在居民信息或者房屋信息等页面点击填表,存储入参到redis,返给前端key diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcCustomerReportDao.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcCustomerReportDao.java index 32068db46a..52513402d2 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcCustomerReportDao.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcCustomerReportDao.java @@ -1,9 +1,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.ReportResultDTO; import com.epmet.entity.IcCustomerReportEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 客户报表关系表 * @@ -12,5 +15,13 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcCustomerReportDao extends BaseDao { - + + /** + * Desc: 报表集合 + * @param + * @author zxc + * @date 2022/8/8 10:38 + */ + List reportList(); + } \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcCustomerReportService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcCustomerReportService.java index b69e1d0e46..9219ef0382 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcCustomerReportService.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcCustomerReportService.java @@ -3,8 +3,6 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcCustomerReportDTO; -import com.epmet.dto.form.PreviewReportFormDTO; -import com.epmet.dto.result.PreviewReportResDTO; import com.epmet.entity.IcCustomerReportEntity; import java.util.List; @@ -78,6 +76,14 @@ public interface IcCustomerReportService extends BaseService reportList(); + /** * 在居民信息或者房屋信息等页面点击填表,存储入参到redis,返给前端key * @param formDTO 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 376ee940f9..313901118b 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,24 +4,37 @@ 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.constant.StrConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisUtils; 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.dto.form.PreviewReportFormDTO; import com.epmet.dto.result.PreviewReportResDTO; 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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 客户报表关系表 @@ -33,6 +46,12 @@ import java.util.Map; public class IcCustomerReportServiceImpl extends BaseServiceImpl implements IcCustomerReportService { @Autowired private RedisUtils redisUtils; + + @Autowired + private EpmetAdminOpenFeignClient adminOpenFeignClient; + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -85,6 +104,45 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl reportList() { + List reportList = baseDao.reportList(); + if (CollectionUtils.isEmpty(reportList)){ + return new ArrayList<>(); + } + 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; + } + /** * 在居民信息或者房屋信息等页面点击填表,存储入参到redis,返给前端key * diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcCustomerReportDao.xml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcCustomerReportDao.xml index 9e4b9347a2..2336b1dc3d 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcCustomerReportDao.xml +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcCustomerReportDao.xml @@ -3,4 +3,15 @@ + + \ No newline at end of file