Browse Source

添加生成报告实现方法

lixing 4 years ago
parent
commit
fcdf261a38
34 changed files with 1770 additions and 68 deletions
  1. 16 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/dao/ReportTypeFunctionRelMapper.java
  2. 74 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/ConvertReportTypeFunctionRelTool.java
  3. 38 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/ReportTypeFunctionRel.java
  4. 31 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/AddReportTypeFunctionRelDTO.java
  5. 20 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/DeleteReportTypeFunctionRelDTO.java
  6. 32 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/PageQueryReportTypeFunctionRelDTO.java
  7. 25 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/QueryReportTypeFunctionRelDTO.java
  8. 20 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/QueryReportTypeFunctionRelDetailDTO.java
  9. 35 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/UpdateReportTypeFunctionRelDTO.java
  10. 43 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/vo/ResponseReportTypeFunctionRelItemVO.java
  11. 43 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/vo/ResponseReportTypeFunctionRelListItemVO.java
  12. 77 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/service/IReportTypeFunctionRelService.java
  13. 209 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/service/impl/ReportTypeFunctionRelServiceImpl.java
  14. 16 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/dao/ReportTypeFunctionGroupRelMapper.java
  15. 74 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/ConvertReportTypeFunctionGroupRelTool.java
  16. 38 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/ReportTypeFunctionGroupRel.java
  17. 31 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/AddReportTypeFunctionGroupRelDTO.java
  18. 20 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/DeleteReportTypeFunctionGroupRelDTO.java
  19. 32 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/PageQueryReportTypeFunctionGroupRelDTO.java
  20. 25 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/QueryReportTypeFunctionGroupRelDTO.java
  21. 20 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/QueryReportTypeFunctionGroupRelDetailDTO.java
  22. 35 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/UpdateReportTypeFunctionGroupRelDTO.java
  23. 43 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/vo/ResponseReportTypeFunctionGroupRelItemVO.java
  24. 43 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/vo/ResponseReportTypeFunctionGroupRelListItemVO.java
  25. 77 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/service/IReportTypeFunctionGroupRelService.java
  26. 209 0
      src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/service/impl/ReportTypeFunctionGroupRelServiceImpl.java
  27. 30 0
      src/main/java/com/persagy/apm/energy/report/monthly/outline/constants/enums/BusinessReportParagraphs.java
  28. 7 35
      src/main/java/com/persagy/apm/energy/report/monthly/outline/controller/ReportOutlineController.java
  29. 5 5
      src/main/java/com/persagy/apm/energy/report/monthly/outline/model/dto/AddReportOutlineDTO.java
  30. 234 0
      src/main/java/com/persagy/apm/energy/report/monthly/outline/service/impl/GenerateReportThreadPool.java
  31. 37 1
      src/main/java/com/persagy/apm/energy/report/monthly/outline/service/impl/ReportOutlineServiceImpl.java
  32. 95 27
      src/main/java/com/persagy/apm/energy/report/saasweb/service/impl/SaasWebServiceImpl.java
  33. 18 0
      src/main/resources/mapper/ReportTypeFunctionGroupRelMapper.xml
  34. 18 0
      src/main/resources/mapper/ReportTypeFunctionRelMapper.xml

+ 16 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/dao/ReportTypeFunctionRelMapper.java

@@ -0,0 +1,16 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.dao;
+
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.ReportTypeFunctionRel;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 报告类型(ReportTypeFunctionRel)dao层
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:41
+ */
+@Mapper
+public interface ReportTypeFunctionRelMapper extends BaseMapper<ReportTypeFunctionRel> {
+
+}

+ 74 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/ConvertReportTypeFunctionRelTool.java

@@ -0,0 +1,74 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model;
+
+import org.mapstruct.*;
+import org.mapstruct.MappingTarget;
+import org.mapstruct.factory.Mappers;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.vo.*;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto.*;
+
+import java.util.List;
+
+/**
+ * 报告类型(ReportTypeFunctionRel) dto、vo、do转换工具类
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:45 2021-05-24 16:02:45
+ */
+@Mapper(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT,
+        nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
+public interface ConvertReportTypeFunctionRelTool {
+
+    ConvertReportTypeFunctionRelTool INSTANCE = Mappers.getMapper(ConvertReportTypeFunctionRelTool.class);
+
+    /**
+     * do转换为ResponseItemVO
+     *
+     * @param reportTypeFunctionRel do对象
+     * @return ResponseItemVO
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:45
+     */
+    ResponseReportTypeFunctionRelItemVO convert2ResponseItemDTO(ReportTypeFunctionRel reportTypeFunctionRel);
+
+    /**
+     * do转换为ResponseListItemVO
+     *
+     * @param reportTypeFunctionRel do对象
+     * @return ResponseListItemVO
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:45
+     */
+    ResponseReportTypeFunctionRelListItemVO convert2ResponseListItemDTO(ReportTypeFunctionRel reportTypeFunctionRel);
+
+    /**
+     * do列表转换为ResponseListItemVO列表
+     *
+     * @param reportTypeFunctionRelList do列表
+     * @return ResponseListItemVO列表
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:45
+     */
+    List<ResponseReportTypeFunctionRelListItemVO> convert2List(List<ReportTypeFunctionRel> reportTypeFunctionRelList);
+
+    /**
+     * addDTO转换为do
+     *
+     * @param addReportTypeFunctionRelDTO addDTO
+     * @return 要创建的do对象
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:45
+     */
+    ReportTypeFunctionRel convertAddDto2Entity(AddReportTypeFunctionRelDTO addReportTypeFunctionRelDTO);
+
+    /**
+     * updateDTO转换为实体
+     *
+     * @param reportTypeFunctionRel          更新前的do对象
+     * @param updateReportTypeFunctionRelDTO updateDTO
+     * @return 更新后的do对象
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:45
+     */
+    ReportTypeFunctionRel convertUpdateDto2Entity(@MappingTarget ReportTypeFunctionRel reportTypeFunctionRel, UpdateReportTypeFunctionRelDTO updateReportTypeFunctionRelDTO);
+}
+

+ 38 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/ReportTypeFunctionRel.java

@@ -0,0 +1,38 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import com.persagy.apm.common.model.entity.AuditableEntity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 报告类型(ReportTypeFunctionRel)实体类
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:42
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "报告类型")
+public class ReportTypeFunctionRel extends AuditableEntity<ReportTypeFunctionRel> implements Serializable {
+    private static final long serialVersionUID = 496688571929587378L;
+
+    @ApiModelProperty("报告类型id")
+    private String reportTypeId;
+
+    @ApiModelProperty("信息点id")
+    private String functionId;
+
+    @ApiModelProperty("所属段落")
+    private String belongParagraph;
+
+
+    public static String PROP_REPORT_TYPE_ID = "report_type_id";
+    public static String PROP_FUNCTION_ID = "function_id";
+    public static String PROP_BELONG_PARAGRAPH = "belong_paragraph";
+
+}

+ 31 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/AddReportTypeFunctionRelDTO.java

@@ -0,0 +1,31 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:42
+ */
+@Data
+@ApiModel(value = "创建报告类型入参")
+public class AddReportTypeFunctionRelDTO {
+    @ApiModelProperty(value = "报告类型id", required = true)
+    @NotNull(message = "报告类型id不能为空") // todo 更新校验规则
+    private String reportTypeId;
+
+    @ApiModelProperty(value = "信息点id", required = true)
+    @NotNull(message = "信息点id不能为空") // todo 更新校验规则
+    private String functionId;
+
+    @ApiModelProperty(value = "所属段落", required = true)
+    @NotNull(message = "所属段落不能为空") // todo 更新校验规则
+    private String belongParagraph;
+
+}

+ 20 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/DeleteReportTypeFunctionRelDTO.java

@@ -0,0 +1,20 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:44
+ */
+@Data
+@ApiModel(value = "删除报告类型入参")
+public class DeleteReportTypeFunctionRelDTO {
+    @NotNull(message = "id不能为空")
+    @ApiModelProperty(value = "主键", required = true)
+    private String id;
+
+}

+ 32 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/PageQueryReportTypeFunctionRelDTO.java

@@ -0,0 +1,32 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+import com.persagy.apm.common.model.dto.PageDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:45
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(value = "分页查询报告类型入参")
+public class PageQueryReportTypeFunctionRelDTO extends PageDTO {
+    @ApiModelProperty(value = "主键", required = true)
+    private String id;
+
+    @ApiModelProperty(value = "报告类型id", required = true)
+    private String reportTypeId;
+
+    @ApiModelProperty(value = "信息点id", required = true)
+    private String functionId;
+
+    @ApiModelProperty(value = "所属段落", required = true)
+    private String belongParagraph;
+
+}

+ 25 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/QueryReportTypeFunctionRelDTO.java

@@ -0,0 +1,25 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:44
+ */
+@Data
+@ApiModel(value = "查询报告类型入参")
+public class QueryReportTypeFunctionRelDTO {
+    @ApiModelProperty(value = "报告类型id", required = true)
+    private String reportTypeId;
+
+    @ApiModelProperty(value = "信息点id", required = true)
+    private String functionId;
+
+    @ApiModelProperty(value = "所属段落", required = true)
+    private String belongParagraph;
+
+}

+ 20 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/QueryReportTypeFunctionRelDetailDTO.java

@@ -0,0 +1,20 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:43
+ */
+@Data
+@ApiModel(value = "获取报告类型详情入参")
+public class QueryReportTypeFunctionRelDetailDTO {
+    @NotNull(message = "主键不能为空")
+    @ApiModelProperty(value = "主键", required = true)
+    private String id;
+
+}

+ 35 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/dto/UpdateReportTypeFunctionRelDTO.java

@@ -0,0 +1,35 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:43
+ */
+@Data
+@ApiModel(value = "更新报告类型入参")
+public class UpdateReportTypeFunctionRelDTO {
+    @ApiModelProperty(value = "主键", required = true)
+    @NotNull(message = "主键不能为空") // todo 更新校验规则
+    private String id;
+
+    @ApiModelProperty(value = "报告类型id", required = true)
+    @NotNull(message = "报告类型id不能为空") // todo 更新校验规则
+    private String reportTypeId;
+
+    @ApiModelProperty(value = "信息点id", required = true)
+    @NotNull(message = "信息点id不能为空") // todo 更新校验规则
+    private String functionId;
+
+    @ApiModelProperty(value = "所属段落", required = true)
+    @NotNull(message = "所属段落不能为空") // todo 更新校验规则
+    private String belongParagraph;
+
+}

+ 43 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/vo/ResponseReportTypeFunctionRelItemVO.java

@@ -0,0 +1,43 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:45
+ */
+@Data
+@ApiModel(value = "报告类型返回结果参数")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ResponseReportTypeFunctionRelItemVO {
+    @ApiModelProperty("主键")
+    private String id;
+
+    @ApiModelProperty("报告类型id")
+    private String reportTypeId;
+
+    @ApiModelProperty("信息点id")
+    private String functionId;
+
+    @ApiModelProperty("所属段落")
+    private String belongParagraph;
+
+    @ApiModelProperty("创建人")
+    private String creator;
+
+    @ApiModelProperty("创建时间")
+    private Date creationTime;
+
+    @ApiModelProperty("最后修改人")
+    private String modifier;
+
+    @ApiModelProperty("最后修改时间")
+    private Date modifiedTime;
+
+}

+ 43 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/model/vo/ResponseReportTypeFunctionRelListItemVO.java

@@ -0,0 +1,43 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:45
+ */
+@Data
+@ApiModel(value = "报告类型列表返回结果参数")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ResponseReportTypeFunctionRelListItemVO {
+    @ApiModelProperty("主键")
+    private String id;
+
+    @ApiModelProperty("报告类型id")
+    private String reportTypeId;
+
+    @ApiModelProperty("信息点id")
+    private String functionId;
+
+    @ApiModelProperty("所属段落")
+    private String belongParagraph;
+
+    @ApiModelProperty("创建人")
+    private String creator;
+
+    @ApiModelProperty("创建时间")
+    private Date creationTime;
+
+    @ApiModelProperty("最后修改人")
+    private String modifier;
+
+    @ApiModelProperty("最后修改时间")
+    private Date modifiedTime;
+
+}

+ 77 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/service/IReportTypeFunctionRelService.java

@@ -0,0 +1,77 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.service;
+
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.*;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto.*;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 报告类型(ReportTypeFunctionRel) service接口
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:40
+ */
+public interface IReportTypeFunctionRelService {
+
+    /**
+     * 创建报告类型
+     *
+     * @param addReportTypeFunctionRelDTO addDTO
+     * @return 报告类型主键
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:40
+     */
+    String createReportTypeFunctionRel(AddReportTypeFunctionRelDTO addReportTypeFunctionRelDTO);
+
+    /**
+     * 报告类型详情
+     *
+     * @param id 主键
+     * @return 报告类型do对象
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:40
+     */
+    ReportTypeFunctionRel queryReportTypeFunctionRelDetail(String id);
+
+    /**
+     * 更新报告类型
+     *
+     * @param updateReportTypeFunctionRelDTO updateDTO
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:40
+     */
+    void updateReportTypeFunctionRel(UpdateReportTypeFunctionRelDTO updateReportTypeFunctionRelDTO);
+
+    /**
+     * 删除报告类型
+     *
+     * @param id 主键
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:40
+     */
+    void deleteReportTypeFunctionRel(String id);
+
+    /**
+     * 查询报告类型
+     *
+     * @param queryReportTypeFunctionRelDTO queryDTO
+     * @return List<ReportTypeFunctionRel>
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:40
+     */
+    List<ReportTypeFunctionRel> queryReportTypeFunctionRelList(QueryReportTypeFunctionRelDTO queryReportTypeFunctionRelDTO);
+
+    /**
+     * 分页查询报告类型
+     *
+     * @param pageQueryReportTypeFunctionRelDTO pageQueryDTO
+     * @return IPage<ReportTypeFunctionRel>
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:40
+     */
+    IPage<ReportTypeFunctionRel> pageQueryReportTypeFunctionRel(PageQueryReportTypeFunctionRelDTO pageQueryReportTypeFunctionRelDTO);
+}

+ 209 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunction/service/impl/ReportTypeFunctionRelServiceImpl.java

@@ -0,0 +1,209 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunction.service.impl;
+
+import com.persagy.apm.common.context.AppContext;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.dao.ReportTypeFunctionRelMapper;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.service.IReportTypeFunctionRelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import org.apache.commons.lang.StringUtils;
+import com.persagy.apm.common.constant.enums.ValidEnum;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.*;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto.*;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.base.CaseFormat;
+import com.persagy.apm.common.model.dto.Sort;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * 报告类型(ReportTypeFunctionRel) service层
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:41
+ */
+@Service
+public class ReportTypeFunctionRelServiceImpl extends ServiceImpl<ReportTypeFunctionRelMapper, ReportTypeFunctionRel>
+        implements IReportTypeFunctionRelService {
+
+    /**
+     * 创建报告类型
+     *
+     * @return 报告类型主键
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:41
+     */
+    @Override
+    public String createReportTypeFunctionRel(AddReportTypeFunctionRelDTO addReportTypeFunctionRelDTO) {
+        ReportTypeFunctionRel reportTypeFunctionRel = ConvertReportTypeFunctionRelTool.INSTANCE.convertAddDto2Entity(addReportTypeFunctionRelDTO);
+        // 设置默认值
+        setDefaultValue(reportTypeFunctionRel);
+        save(reportTypeFunctionRel);
+        return reportTypeFunctionRel.getId();
+    }
+
+    /**
+     * 如果某些字段没有赋值,使用默认的值
+     *
+     * @param reportTypeFunctionRel 报告类型实体
+     * @author lixing
+     * @version V1.0 2021/3/12 12:29 下午
+     */
+    private void setDefaultValue(ReportTypeFunctionRel reportTypeFunctionRel) {
+        reportTypeFunctionRel.setCreator(AppContext.getContext().getAccountId());
+        // todo 其他默认的属性
+
+    }
+
+    /**
+     * 报告类型详情
+     *
+     * @param id 主键
+     * @return 部门do类
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:41
+     */
+    @Override
+    public ReportTypeFunctionRel queryReportTypeFunctionRelDetail(String id) {
+        ReportTypeFunctionRel reportTypeFunctionRel = getById(id);
+        if (reportTypeFunctionRel == null) {
+            throw new IllegalArgumentException("查看ReportTypeFunctionRel详情时发生异常,找不到要查看的记录,id=" + id);
+        }
+        return reportTypeFunctionRel;
+    }
+
+    /**
+     * 更新报告类型
+     *
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:41
+     */
+    @Override
+    public void updateReportTypeFunctionRel(UpdateReportTypeFunctionRelDTO updateReportTypeFunctionRelDTO) {
+        ReportTypeFunctionRel reportTypeFunctionRel = getById(updateReportTypeFunctionRelDTO.getId());
+        reportTypeFunctionRel = ConvertReportTypeFunctionRelTool.INSTANCE.convertUpdateDto2Entity(reportTypeFunctionRel, updateReportTypeFunctionRelDTO);
+        reportTypeFunctionRel.setModifier(AppContext.getContext().getAccountId());
+        updateById(reportTypeFunctionRel);
+    }
+
+    /**
+     * 校验报告类型是否可删除
+     *
+     * @param id 报告类型主键
+     * @return 报告类型do类
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:41
+     */
+    public ReportTypeFunctionRel checkDeletable(String id) {
+        if (id == null) {
+            throw new IllegalArgumentException("删除ReportTypeFunctionRel时发生异常,主键为空");
+        }
+
+        ReportTypeFunctionRel reportTypeFunctionRel = getById(id);
+
+        if (reportTypeFunctionRel == null) {
+            throw new IllegalArgumentException("删除ReportTypeFunctionRel时发生异常,找不到要删除的数据,id:" + id);
+        }
+
+        return reportTypeFunctionRel;
+    }
+
+    /**
+     * 删除报告类型
+     *
+     * @param id 主键
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:41
+     */
+    @Override
+    public void deleteReportTypeFunctionRel(String id) {
+        // 校验是否可删除
+        ReportTypeFunctionRel reportTypeFunctionRel = checkDeletable(id);
+
+        reportTypeFunctionRel.setValid(ValidEnum.FALSE.getType());
+        updateById(reportTypeFunctionRel);
+    }
+
+    /**
+     * 查询报告类型
+     *
+     * @return List<ReportTypeFunctionRel>
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:41
+     */
+    @Override
+    public List<ReportTypeFunctionRel> queryReportTypeFunctionRelList(QueryReportTypeFunctionRelDTO queryReportTypeFunctionRelDTO) {
+        QueryWrapper<ReportTypeFunctionRel> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq(ReportTypeFunctionRel.PROP_VALID, ValidEnum.TRUE.getType());
+        // 默认按创建时间倒序排序
+        queryWrapper.orderBy(true, false, ReportTypeFunctionRel.PROP_CREATIONTIME);
+
+        if (queryReportTypeFunctionRelDTO != null) {
+
+            // todo 需判断使用like还是eq
+            if (StringUtils.isNotEmpty(queryReportTypeFunctionRelDTO.getReportTypeId())) {
+                queryWrapper.like(ReportTypeFunctionRel.PROP_REPORT_TYPE_ID, queryReportTypeFunctionRelDTO.getReportTypeId());
+            }
+
+            // todo 需判断使用like还是eq
+            if (StringUtils.isNotEmpty(queryReportTypeFunctionRelDTO.getFunctionId())) {
+                queryWrapper.like(ReportTypeFunctionRel.PROP_FUNCTION_ID, queryReportTypeFunctionRelDTO.getFunctionId());
+            }
+
+            // todo 需判断使用like还是eq
+            if (StringUtils.isNotEmpty(queryReportTypeFunctionRelDTO.getBelongParagraph())) {
+                queryWrapper.like(ReportTypeFunctionRel.PROP_BELONG_PARAGRAPH, queryReportTypeFunctionRelDTO.getBelongParagraph());
+            }
+
+        }
+
+        return list(queryWrapper);
+    }
+
+    /**
+     * 分页查询报告类型
+     *
+     * @return IPage<ReportTypeFunctionRel>
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:41
+     */
+    @Override
+    public IPage<ReportTypeFunctionRel> pageQueryReportTypeFunctionRel(PageQueryReportTypeFunctionRelDTO pageQueryReportTypeFunctionRelDTO) {
+        QueryWrapper<ReportTypeFunctionRel> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq(ReportTypeFunctionRel.PROP_VALID, ValidEnum.TRUE.getType());
+        // 这里认为pageQueryDTO是经过校验的,肯定包含分页信息
+        IPage<ReportTypeFunctionRel> pageParam = new Page<>(pageQueryReportTypeFunctionRelDTO.getPage(), pageQueryReportTypeFunctionRelDTO.getSize(), true);
+        // 排序信息
+        if (CollectionUtils.isEmpty(pageQueryReportTypeFunctionRelDTO.getOrders())) {
+            // 默认按创建时间倒序排序
+            queryWrapper.orderBy(true, false, ReportTypeFunctionRel.PROP_CREATIONTIME);
+        } else {
+            List<Sort> orders = pageQueryReportTypeFunctionRelDTO.getOrders();
+            for (Sort sort : orders) {
+                // 将驼峰转换为下划线格式
+                sort.setColumn(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sort.getColumn()));
+                queryWrapper.orderBy(true, sort.isAsc(), sort.getColumn());
+            }
+        }
+
+        // todo 需判断使用like还是eq
+        if (StringUtils.isNotEmpty(pageQueryReportTypeFunctionRelDTO.getReportTypeId())) {
+            queryWrapper.like(ReportTypeFunctionRel.PROP_REPORT_TYPE_ID, pageQueryReportTypeFunctionRelDTO.getReportTypeId());
+        }
+
+        // todo 需判断使用like还是eq
+        if (StringUtils.isNotEmpty(pageQueryReportTypeFunctionRelDTO.getFunctionId())) {
+            queryWrapper.like(ReportTypeFunctionRel.PROP_FUNCTION_ID, pageQueryReportTypeFunctionRelDTO.getFunctionId());
+        }
+
+        // todo 需判断使用like还是eq
+        if (StringUtils.isNotEmpty(pageQueryReportTypeFunctionRelDTO.getBelongParagraph())) {
+            queryWrapper.like(ReportTypeFunctionRel.PROP_BELONG_PARAGRAPH, pageQueryReportTypeFunctionRelDTO.getBelongParagraph());
+        }
+
+        return getBaseMapper().selectPage(pageParam, queryWrapper);
+    }
+}

+ 16 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/dao/ReportTypeFunctionGroupRelMapper.java

@@ -0,0 +1,16 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.dao;
+
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.ReportTypeFunctionGroupRel;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 报告类型(ReportTypeFunctionGroupRel)dao层
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:15
+ */
+@Mapper
+public interface ReportTypeFunctionGroupRelMapper extends BaseMapper<ReportTypeFunctionGroupRel> {
+
+}

+ 74 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/ConvertReportTypeFunctionGroupRelTool.java

@@ -0,0 +1,74 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model;
+
+import org.mapstruct.*;
+import org.mapstruct.MappingTarget;
+import org.mapstruct.factory.Mappers;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.vo.*;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto.*;
+
+import java.util.List;
+
+/**
+ * 报告类型(ReportTypeFunctionGroupRel) dto、vo、do转换工具类
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:18 2021-05-24 16:02:18
+ */
+@Mapper(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT,
+        nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
+public interface ConvertReportTypeFunctionGroupRelTool {
+
+    ConvertReportTypeFunctionGroupRelTool INSTANCE = Mappers.getMapper(ConvertReportTypeFunctionGroupRelTool.class);
+
+    /**
+     * do转换为ResponseItemVO
+     *
+     * @param reportTypeFunctionGroupRel do对象
+     * @return ResponseItemVO
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:18
+     */
+    ResponseReportTypeFunctionGroupRelItemVO convert2ResponseItemDTO(ReportTypeFunctionGroupRel reportTypeFunctionGroupRel);
+
+    /**
+     * do转换为ResponseListItemVO
+     *
+     * @param reportTypeFunctionGroupRel do对象
+     * @return ResponseListItemVO
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:18
+     */
+    ResponseReportTypeFunctionGroupRelListItemVO convert2ResponseListItemDTO(ReportTypeFunctionGroupRel reportTypeFunctionGroupRel);
+
+    /**
+     * do列表转换为ResponseListItemVO列表
+     *
+     * @param reportTypeFunctionGroupRelList do列表
+     * @return ResponseListItemVO列表
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:18
+     */
+    List<ResponseReportTypeFunctionGroupRelListItemVO> convert2List(List<ReportTypeFunctionGroupRel> reportTypeFunctionGroupRelList);
+
+    /**
+     * addDTO转换为do
+     *
+     * @param addReportTypeFunctionGroupRelDTO addDTO
+     * @return 要创建的do对象
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:18
+     */
+    ReportTypeFunctionGroupRel convertAddDto2Entity(AddReportTypeFunctionGroupRelDTO addReportTypeFunctionGroupRelDTO);
+
+    /**
+     * updateDTO转换为实体
+     *
+     * @param reportTypeFunctionGroupRel          更新前的do对象
+     * @param updateReportTypeFunctionGroupRelDTO updateDTO
+     * @return 更新后的do对象
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:18
+     */
+    ReportTypeFunctionGroupRel convertUpdateDto2Entity(@MappingTarget ReportTypeFunctionGroupRel reportTypeFunctionGroupRel, UpdateReportTypeFunctionGroupRelDTO updateReportTypeFunctionGroupRelDTO);
+}
+

+ 38 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/ReportTypeFunctionGroupRel.java

@@ -0,0 +1,38 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import com.persagy.apm.common.model.entity.AuditableEntity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 报告类型(ReportTypeFunctionGroupRel)实体类
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:15
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "报告类型")
+public class ReportTypeFunctionGroupRel extends AuditableEntity<ReportTypeFunctionGroupRel> implements Serializable {
+    private static final long serialVersionUID = 279475542066816931L;
+
+    @ApiModelProperty("报告类型id")
+    private String reportTypeId;
+
+    @ApiModelProperty("信息点分组id")
+    private String functionGroupId;
+
+    @ApiModelProperty("所属段落")
+    private String belongParagraph;
+
+
+    public static String PROP_REPORT_TYPE_ID = "report_type_id";
+    public static String PROP_FUNCTION_GROUP_ID = "function_group_id";
+    public static String PROP_BELONG_PARAGRAPH = "belong_paragraph";
+
+}

+ 31 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/AddReportTypeFunctionGroupRelDTO.java

@@ -0,0 +1,31 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:16
+ */
+@Data
+@ApiModel(value = "创建报告类型入参")
+public class AddReportTypeFunctionGroupRelDTO {
+    @ApiModelProperty(value = "报告类型id", required = true)
+    @NotNull(message = "报告类型id不能为空") // todo 更新校验规则
+    private String reportTypeId;
+
+    @ApiModelProperty(value = "信息点分组id", required = true)
+    @NotNull(message = "信息点分组id不能为空") // todo 更新校验规则
+    private String functionGroupId;
+
+    @ApiModelProperty(value = "所属段落", required = true)
+    @NotNull(message = "所属段落不能为空") // todo 更新校验规则
+    private String belongParagraph;
+
+}

+ 20 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/DeleteReportTypeFunctionGroupRelDTO.java

@@ -0,0 +1,20 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:17
+ */
+@Data
+@ApiModel(value = "删除报告类型入参")
+public class DeleteReportTypeFunctionGroupRelDTO {
+    @NotNull(message = "id不能为空")
+    @ApiModelProperty(value = "主键", required = true)
+    private String id;
+
+}

+ 32 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/PageQueryReportTypeFunctionGroupRelDTO.java

@@ -0,0 +1,32 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+import com.persagy.apm.common.model.dto.PageDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:17
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(value = "分页查询报告类型入参")
+public class PageQueryReportTypeFunctionGroupRelDTO extends PageDTO {
+    @ApiModelProperty(value = "主键", required = true)
+    private String id;
+
+    @ApiModelProperty(value = "报告类型id", required = true)
+    private String reportTypeId;
+
+    @ApiModelProperty(value = "信息点分组id", required = true)
+    private String functionGroupId;
+
+    @ApiModelProperty(value = "所属段落", required = true)
+    private String belongParagraph;
+
+}

+ 25 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/QueryReportTypeFunctionGroupRelDTO.java

@@ -0,0 +1,25 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:17
+ */
+@Data
+@ApiModel(value = "查询报告类型入参")
+public class QueryReportTypeFunctionGroupRelDTO {
+    @ApiModelProperty(value = "报告类型id", required = true)
+    private String reportTypeId;
+
+    @ApiModelProperty(value = "信息点分组id", required = true)
+    private String functionGroupId;
+
+    @ApiModelProperty(value = "所属段落", required = true)
+    private String belongParagraph;
+
+}

+ 20 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/QueryReportTypeFunctionGroupRelDetailDTO.java

@@ -0,0 +1,20 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:16
+ */
+@Data
+@ApiModel(value = "获取报告类型详情入参")
+public class QueryReportTypeFunctionGroupRelDetailDTO {
+    @NotNull(message = "主键不能为空")
+    @ApiModelProperty(value = "主键", required = true)
+    private String id;
+
+}

+ 35 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/dto/UpdateReportTypeFunctionGroupRelDTO.java

@@ -0,0 +1,35 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:16
+ */
+@Data
+@ApiModel(value = "更新报告类型入参")
+public class UpdateReportTypeFunctionGroupRelDTO {
+    @ApiModelProperty(value = "主键", required = true)
+    @NotNull(message = "主键不能为空") // todo 更新校验规则
+    private String id;
+
+    @ApiModelProperty(value = "报告类型id", required = true)
+    @NotNull(message = "报告类型id不能为空") // todo 更新校验规则
+    private String reportTypeId;
+
+    @ApiModelProperty(value = "信息点分组id", required = true)
+    @NotNull(message = "信息点分组id不能为空") // todo 更新校验规则
+    private String functionGroupId;
+
+    @ApiModelProperty(value = "所属段落", required = true)
+    @NotNull(message = "所属段落不能为空") // todo 更新校验规则
+    private String belongParagraph;
+
+}

+ 43 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/vo/ResponseReportTypeFunctionGroupRelItemVO.java

@@ -0,0 +1,43 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:18
+ */
+@Data
+@ApiModel(value = "报告类型返回结果参数")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ResponseReportTypeFunctionGroupRelItemVO {
+    @ApiModelProperty("主键")
+    private String id;
+
+    @ApiModelProperty("报告类型id")
+    private String reportTypeId;
+
+    @ApiModelProperty("信息点分组id")
+    private String functionGroupId;
+
+    @ApiModelProperty("所属段落")
+    private String belongParagraph;
+
+    @ApiModelProperty("创建人")
+    private String creator;
+
+    @ApiModelProperty("创建时间")
+    private Date creationTime;
+
+    @ApiModelProperty("最后修改人")
+    private String modifier;
+
+    @ApiModelProperty("最后修改时间")
+    private Date modifiedTime;
+
+}

+ 43 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/model/vo/ResponseReportTypeFunctionGroupRelListItemVO.java

@@ -0,0 +1,43 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:18
+ */
+@Data
+@ApiModel(value = "报告类型列表返回结果参数")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ResponseReportTypeFunctionGroupRelListItemVO {
+    @ApiModelProperty("主键")
+    private String id;
+
+    @ApiModelProperty("报告类型id")
+    private String reportTypeId;
+
+    @ApiModelProperty("信息点分组id")
+    private String functionGroupId;
+
+    @ApiModelProperty("所属段落")
+    private String belongParagraph;
+
+    @ApiModelProperty("创建人")
+    private String creator;
+
+    @ApiModelProperty("创建时间")
+    private Date creationTime;
+
+    @ApiModelProperty("最后修改人")
+    private String modifier;
+
+    @ApiModelProperty("最后修改时间")
+    private Date modifiedTime;
+
+}

+ 77 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/service/IReportTypeFunctionGroupRelService.java

@@ -0,0 +1,77 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.service;
+
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.*;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto.*;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 报告类型(ReportTypeFunctionGroupRel) service接口
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:14
+ */
+public interface IReportTypeFunctionGroupRelService {
+
+    /**
+     * 创建报告类型
+     *
+     * @param addReportTypeFunctionGroupRelDTO addDTO
+     * @return 报告类型主键
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    String createReportTypeFunctionGroupRel(AddReportTypeFunctionGroupRelDTO addReportTypeFunctionGroupRelDTO);
+
+    /**
+     * 报告类型详情
+     *
+     * @param id 主键
+     * @return 报告类型do对象
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    ReportTypeFunctionGroupRel queryReportTypeFunctionGroupRelDetail(String id);
+
+    /**
+     * 更新报告类型
+     *
+     * @param updateReportTypeFunctionGroupRelDTO updateDTO
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    void updateReportTypeFunctionGroupRel(UpdateReportTypeFunctionGroupRelDTO updateReportTypeFunctionGroupRelDTO);
+
+    /**
+     * 删除报告类型
+     *
+     * @param id 主键
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    void deleteReportTypeFunctionGroupRel(String id);
+
+    /**
+     * 查询报告类型
+     *
+     * @param queryReportTypeFunctionGroupRelDTO queryDTO
+     * @return List<ReportTypeFunctionGroupRel>
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    List<ReportTypeFunctionGroupRel> queryReportTypeFunctionGroupRelList(QueryReportTypeFunctionGroupRelDTO queryReportTypeFunctionGroupRelDTO);
+
+    /**
+     * 分页查询报告类型
+     *
+     * @param pageQueryReportTypeFunctionGroupRelDTO pageQueryDTO
+     * @return IPage<ReportTypeFunctionGroupRel>
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    IPage<ReportTypeFunctionGroupRel> pageQueryReportTypeFunctionGroupRel(PageQueryReportTypeFunctionGroupRelDTO pageQueryReportTypeFunctionGroupRelDTO);
+}

+ 209 - 0
src/main/java/com/persagy/apm/energy/report/monthly/config/rel/typefunctiongroup/service/impl/ReportTypeFunctionGroupRelServiceImpl.java

@@ -0,0 +1,209 @@
+package com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.service.impl;
+
+import com.persagy.apm.common.context.AppContext;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.dao.ReportTypeFunctionGroupRelMapper;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.service.IReportTypeFunctionGroupRelService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import org.apache.commons.lang.StringUtils;
+import com.persagy.apm.common.constant.enums.ValidEnum;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.*;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto.*;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.base.CaseFormat;
+import com.persagy.apm.common.model.dto.Sort;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * 报告类型(ReportTypeFunctionGroupRel) service层
+ *
+ * @author lixing
+ * @version V1.0 2021-05-24 16:02:14
+ */
+@Service
+public class ReportTypeFunctionGroupRelServiceImpl extends ServiceImpl<ReportTypeFunctionGroupRelMapper, ReportTypeFunctionGroupRel>
+        implements IReportTypeFunctionGroupRelService {
+
+    /**
+     * 创建报告类型
+     *
+     * @return 报告类型主键
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    @Override
+    public String createReportTypeFunctionGroupRel(AddReportTypeFunctionGroupRelDTO addReportTypeFunctionGroupRelDTO) {
+        ReportTypeFunctionGroupRel reportTypeFunctionGroupRel = ConvertReportTypeFunctionGroupRelTool.INSTANCE.convertAddDto2Entity(addReportTypeFunctionGroupRelDTO);
+        // 设置默认值
+        setDefaultValue(reportTypeFunctionGroupRel);
+        save(reportTypeFunctionGroupRel);
+        return reportTypeFunctionGroupRel.getId();
+    }
+
+    /**
+     * 如果某些字段没有赋值,使用默认的值
+     *
+     * @param reportTypeFunctionGroupRel 报告类型实体
+     * @author lixing
+     * @version V1.0 2021/3/12 12:29 下午
+     */
+    private void setDefaultValue(ReportTypeFunctionGroupRel reportTypeFunctionGroupRel) {
+        reportTypeFunctionGroupRel.setCreator(AppContext.getContext().getAccountId());
+        // todo 其他默认的属性
+
+    }
+
+    /**
+     * 报告类型详情
+     *
+     * @param id 主键
+     * @return 部门do类
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    @Override
+    public ReportTypeFunctionGroupRel queryReportTypeFunctionGroupRelDetail(String id) {
+        ReportTypeFunctionGroupRel reportTypeFunctionGroupRel = getById(id);
+        if (reportTypeFunctionGroupRel == null) {
+            throw new IllegalArgumentException("查看ReportTypeFunctionGroupRel详情时发生异常,找不到要查看的记录,id=" + id);
+        }
+        return reportTypeFunctionGroupRel;
+    }
+
+    /**
+     * 更新报告类型
+     *
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    @Override
+    public void updateReportTypeFunctionGroupRel(UpdateReportTypeFunctionGroupRelDTO updateReportTypeFunctionGroupRelDTO) {
+        ReportTypeFunctionGroupRel reportTypeFunctionGroupRel = getById(updateReportTypeFunctionGroupRelDTO.getId());
+        reportTypeFunctionGroupRel = ConvertReportTypeFunctionGroupRelTool.INSTANCE.convertUpdateDto2Entity(reportTypeFunctionGroupRel, updateReportTypeFunctionGroupRelDTO);
+        reportTypeFunctionGroupRel.setModifier(AppContext.getContext().getAccountId());
+        updateById(reportTypeFunctionGroupRel);
+    }
+
+    /**
+     * 校验报告类型是否可删除
+     *
+     * @param id 报告类型主键
+     * @return 报告类型do类
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    public ReportTypeFunctionGroupRel checkDeletable(String id) {
+        if (id == null) {
+            throw new IllegalArgumentException("删除ReportTypeFunctionGroupRel时发生异常,主键为空");
+        }
+
+        ReportTypeFunctionGroupRel reportTypeFunctionGroupRel = getById(id);
+
+        if (reportTypeFunctionGroupRel == null) {
+            throw new IllegalArgumentException("删除ReportTypeFunctionGroupRel时发生异常,找不到要删除的数据,id:" + id);
+        }
+
+        return reportTypeFunctionGroupRel;
+    }
+
+    /**
+     * 删除报告类型
+     *
+     * @param id 主键
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    @Override
+    public void deleteReportTypeFunctionGroupRel(String id) {
+        // 校验是否可删除
+        ReportTypeFunctionGroupRel reportTypeFunctionGroupRel = checkDeletable(id);
+
+        reportTypeFunctionGroupRel.setValid(ValidEnum.FALSE.getType());
+        updateById(reportTypeFunctionGroupRel);
+    }
+
+    /**
+     * 查询报告类型
+     *
+     * @return List<ReportTypeFunctionGroupRel>
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    @Override
+    public List<ReportTypeFunctionGroupRel> queryReportTypeFunctionGroupRelList(QueryReportTypeFunctionGroupRelDTO queryReportTypeFunctionGroupRelDTO) {
+        QueryWrapper<ReportTypeFunctionGroupRel> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq(ReportTypeFunctionGroupRel.PROP_VALID, ValidEnum.TRUE.getType());
+        // 默认按创建时间倒序排序
+        queryWrapper.orderBy(true, false, ReportTypeFunctionGroupRel.PROP_CREATIONTIME);
+
+        if (queryReportTypeFunctionGroupRelDTO != null) {
+
+            // todo 需判断使用like还是eq
+            if (StringUtils.isNotEmpty(queryReportTypeFunctionGroupRelDTO.getReportTypeId())) {
+                queryWrapper.like(ReportTypeFunctionGroupRel.PROP_REPORT_TYPE_ID, queryReportTypeFunctionGroupRelDTO.getReportTypeId());
+            }
+
+            // todo 需判断使用like还是eq
+            if (StringUtils.isNotEmpty(queryReportTypeFunctionGroupRelDTO.getFunctionGroupId())) {
+                queryWrapper.like(ReportTypeFunctionGroupRel.PROP_FUNCTION_GROUP_ID, queryReportTypeFunctionGroupRelDTO.getFunctionGroupId());
+            }
+
+            // todo 需判断使用like还是eq
+            if (StringUtils.isNotEmpty(queryReportTypeFunctionGroupRelDTO.getBelongParagraph())) {
+                queryWrapper.like(ReportTypeFunctionGroupRel.PROP_BELONG_PARAGRAPH, queryReportTypeFunctionGroupRelDTO.getBelongParagraph());
+            }
+
+        }
+
+        return list(queryWrapper);
+    }
+
+    /**
+     * 分页查询报告类型
+     *
+     * @return IPage<ReportTypeFunctionGroupRel>
+     * @author lixing
+     * @version V1.0 2021-05-24 16:02:14
+     */
+    @Override
+    public IPage<ReportTypeFunctionGroupRel> pageQueryReportTypeFunctionGroupRel(PageQueryReportTypeFunctionGroupRelDTO pageQueryReportTypeFunctionGroupRelDTO) {
+        QueryWrapper<ReportTypeFunctionGroupRel> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq(ReportTypeFunctionGroupRel.PROP_VALID, ValidEnum.TRUE.getType());
+        // 这里认为pageQueryDTO是经过校验的,肯定包含分页信息
+        IPage<ReportTypeFunctionGroupRel> pageParam = new Page<>(pageQueryReportTypeFunctionGroupRelDTO.getPage(), pageQueryReportTypeFunctionGroupRelDTO.getSize(), true);
+        // 排序信息
+        if (CollectionUtils.isEmpty(pageQueryReportTypeFunctionGroupRelDTO.getOrders())) {
+            // 默认按创建时间倒序排序
+            queryWrapper.orderBy(true, false, ReportTypeFunctionGroupRel.PROP_CREATIONTIME);
+        } else {
+            List<Sort> orders = pageQueryReportTypeFunctionGroupRelDTO.getOrders();
+            for (Sort sort : orders) {
+                // 将驼峰转换为下划线格式
+                sort.setColumn(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, sort.getColumn()));
+                queryWrapper.orderBy(true, sort.isAsc(), sort.getColumn());
+            }
+        }
+
+        // todo 需判断使用like还是eq
+        if (StringUtils.isNotEmpty(pageQueryReportTypeFunctionGroupRelDTO.getReportTypeId())) {
+            queryWrapper.like(ReportTypeFunctionGroupRel.PROP_REPORT_TYPE_ID, pageQueryReportTypeFunctionGroupRelDTO.getReportTypeId());
+        }
+
+        // todo 需判断使用like还是eq
+        if (StringUtils.isNotEmpty(pageQueryReportTypeFunctionGroupRelDTO.getFunctionGroupId())) {
+            queryWrapper.like(ReportTypeFunctionGroupRel.PROP_FUNCTION_GROUP_ID, pageQueryReportTypeFunctionGroupRelDTO.getFunctionGroupId());
+        }
+
+        // todo 需判断使用like还是eq
+        if (StringUtils.isNotEmpty(pageQueryReportTypeFunctionGroupRelDTO.getBelongParagraph())) {
+            queryWrapper.like(ReportTypeFunctionGroupRel.PROP_BELONG_PARAGRAPH, pageQueryReportTypeFunctionGroupRelDTO.getBelongParagraph());
+        }
+
+        return getBaseMapper().selectPage(pageParam, queryWrapper);
+    }
+}

+ 30 - 0
src/main/java/com/persagy/apm/energy/report/monthly/outline/constants/enums/BusinessReportParagraphs.java

@@ -0,0 +1,30 @@
+package com.persagy.apm.energy.report.monthly.outline.constants.enums;
+
+/**
+ * 商业报告段落
+ *
+ * @author lixing
+ * @version V1.0 2021/5/24 4:17 下午
+ **/
+public class BusinessReportParagraphs {
+    /**
+     * 在营项目用电量
+     */
+    public static final String OPEN_POWER = "openPower";
+    /**
+     * 可同比项目用电量
+     */
+    public static final String COMPARE_POWER = "comparePower";
+    /**
+     * 在营项目能源费
+     */
+    public static final String OPEN_COST = "openCost";
+    /**
+     * 可同比项目能源费
+     */
+    public static final String COMPARE_COST = "compareCost";
+    /**
+     * 能耗管理平台运维
+     */
+    public static final String PLATFORM = "platform";
+}

+ 7 - 35
src/main/java/com/persagy/apm/energy/report/monthly/outline/controller/ReportOutlineController.java

@@ -57,42 +57,14 @@ public class ReportOutlineController {
         return ResultHelper.single(new ApmResponseUpsertVO(id));
     }
 
-    //    @ApiOperation(value = "报告概要详情")
-    //    @PostMapping("/get")
-    //    public CommonResult<ResponseReportOutlineItemVO> queryReportOutlineDetail(
-    //            @Valid @RequestBody QueryReportOutlineDetailDTO queryReportOutlineDetailDTO) {
-    //        ReportOutline reportOutline = reportOutlineService.queryReportOutlineDetail(queryReportOutlineDetailDTO.getId());
-    //        ResponseReportOutlineItemVO responseReportOutlineItemVO = ConvertReportOutlineTool.INSTANCE.convert2ResponseItemDTO(reportOutline);
-    //        return ResultHelper.single(responseReportOutlineItemVO);
-    //    }
-
-
-    //    @ApiOperation(value = "更新报告概要")
-    //    @PostMapping("/update")
-    //    public CommonResult<ApmResponseUpsertVO> updateReportOutline(
-    //            @Valid @RequestBody UpdateReportOutlineDTO updateReportOutlineDTO) {
-    //        reportOutlineService.updateReportOutline(updateReportOutlineDTO);
-    //        return ResultHelper.single(new ApmResponseUpsertVO(updateReportOutlineDTO.getId()));
-    //    }
-
-
-        @ApiOperation(value = "批量删除报告概要")
-        @PostMapping("/batch_delete")
-        public CommonResult deleteReportOutline(
-                @RequestBody @Valid DeleteReportOutlineDTO deleteReportOutlineDTO) {
-            reportOutlineService.batchDeleteReportOutline(deleteReportOutlineDTO.getIds());
-            return ResultHelper.success();
-        }
-
+    @ApiOperation(value = "批量删除报告概要")
+    @PostMapping("/batch_delete")
+    public CommonResult deleteReportOutline(
+            @RequestBody @Valid DeleteReportOutlineDTO deleteReportOutlineDTO) {
+        reportOutlineService.batchDeleteReportOutline(deleteReportOutlineDTO.getIds());
+        return ResultHelper.success();
+    }
 
-    //    @ApiOperation(value = "报告概要列表")
-    //    @PostMapping("/query")
-    //    public CommonResult<PageList<ResponseReportOutlineListItemVO>> queryReportOutline(
-    //            @Valid @RequestBody QueryReportOutlineDTO queryReportOutlineDTO) {
-    //        List<ReportOutline> reportOutlineList = reportOutlineService.queryReportOutlineList(queryReportOutlineDTO);
-    //        List<ResponseReportOutlineListItemVO> resultList = ConvertReportOutlineTool.INSTANCE.convert2List(reportOutlineList);
-    //        return ResultHelper.multi(resultList);
-    //    }
 
     @ApiOperation(value = "报告概要列表, 分页查询")
     @PostMapping("/query")

+ 5 - 5
src/main/java/com/persagy/apm/energy/report/monthly/outline/model/dto/AddReportOutlineDTO.java

@@ -19,15 +19,15 @@ import java.util.Date;
 public class AddReportOutlineDTO {
 
     @ApiModelProperty(value = "报告日期", required = true)
-    @NotNull(message = "报告日期不能为空") // todo 更新校验规则
-    private Date date;
+    @NotNull(message = "报告日期不能为空")
+    private Date reportMonth;
 
     @ApiModelProperty(value = "报告所属", required = true)
-    @NotNull(message = "报告所属不能为空") // todo 更新校验规则
+    @NotNull(message = "报告所属不能为空")
     private String belong;
 
     @ApiModelProperty(value = "报告类型id", required = true)
-    @NotNull(message = "报告类型id不能为空") // todo 更新校验规则
-    private String type;
+    @NotNull(message = "报告类型id不能为空")
+    private String reportTypeId;
 
 }

+ 234 - 0
src/main/java/com/persagy/apm/energy/report/monthly/outline/service/impl/GenerateReportThreadPool.java

@@ -0,0 +1,234 @@
+package com.persagy.apm.energy.report.monthly.outline.service.impl;
+
+import cn.hutool.core.thread.ExecutorBuilder;
+import com.persagy.apm.energy.report.monthly.config.function.model.Function;
+import com.persagy.apm.energy.report.monthly.config.function.service.IFunctionService;
+import com.persagy.apm.energy.report.monthly.config.functiongroup.model.FunctionGroup;
+import com.persagy.apm.energy.report.monthly.config.functiongroup.service.IFunctionGroupService;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.ReportTypeFunctionRel;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.dto.QueryReportTypeFunctionRelDTO;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunction.service.IReportTypeFunctionRelService;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.ReportTypeFunctionGroupRel;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.dto.QueryReportTypeFunctionGroupRelDTO;
+import com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.service.IReportTypeFunctionGroupRelService;
+import com.persagy.apm.energy.report.monthly.config.type.constant.enums.BuildingTypeEnum;
+import com.persagy.apm.energy.report.monthly.config.type.model.ReportType;
+import com.persagy.apm.energy.report.monthly.config.type.service.IReportTypeService;
+import com.persagy.apm.energy.report.monthly.detail.business.model.OpenPower;
+import com.persagy.apm.energy.report.monthly.detail.business.model.dto.AddReportBusinessDetailDTO;
+import com.persagy.apm.energy.report.monthly.detail.business.model.vo.GroupInfo;
+import com.persagy.apm.energy.report.monthly.detail.business.model.vo.PowerItemVO;
+import com.persagy.apm.energy.report.monthly.detail.business.service.IReportBusinessDetailService;
+import com.persagy.apm.energy.report.monthly.functionvalue.service.IFunctionValueService;
+import com.persagy.apm.energy.report.monthly.outline.constants.enums.BusinessReportParagraphs;
+import com.persagy.apm.energy.report.monthly.outline.constants.enums.ReportStateEnum;
+import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
+import lombok.extern.slf4j.Slf4j;
+import org.assertj.core.util.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.stream.Collectors;
+
+/**
+ * 消费消息线程池
+ *
+ * @author lixing
+ * @version V1.0 2021/5/12 2:53 下午
+ **/
+@Component
+@Slf4j
+public class GenerateReportThreadPool {
+    @Autowired
+    private IReportBusinessDetailService businessDetailService;
+    @Autowired
+    private IReportTypeService reportTypeService;
+    @Autowired
+    private IReportTypeFunctionGroupRelService reportTypeFunctionGroupRelService;
+    @Autowired
+    private IReportTypeFunctionRelService reportTypeFunctionRelService;
+    @Autowired
+    private IFunctionGroupService functionGroupService;
+    @Autowired
+    private IFunctionService functionService;
+    @Autowired
+    private IFunctionValueService functionValueService;
+
+    private final ExecutorService es;
+
+    public GenerateReportThreadPool() {
+        // 初始化线程池
+        es = ExecutorBuilder.create()
+                .setCorePoolSize(5)
+                .setMaxPoolSize(10)
+                .setWorkQueue(new LinkedBlockingQueue<>(100))
+                .setHandler(new ThreadPoolExecutor.CallerRunsPolicy())
+                .build();
+    }
+
+    /**
+     * 生成报告
+     *
+     * @param reportOutline 报告outline对象
+     * @author lixing
+     * @version V1.0 2021/5/24 4:09 下午
+     */
+    public void generateReport(ReportOutline reportOutline) {
+        es.execute(() -> {
+            try {
+                String reportTypeId = reportOutline.getReportTypeId();
+                ReportType reportType = reportTypeService.queryReportTypeDetail(reportTypeId);
+                if (BuildingTypeEnum.BUSINESS.getType().equals(reportType.getBuildingType())) {
+                    AddReportBusinessDetailDTO addReportBusinessDetailDTO = new AddReportBusinessDetailDTO();
+                    OpenPower openPower = getOpenPower(reportOutline);
+                    // TODO: 2021/5/24 给其他属性赋值
+                    addReportBusinessDetailDTO.setOpenPower(openPower);
+                    businessDetailService.createReportBusinessDetail(addReportBusinessDetailDTO);
+                }
+            } catch (Exception e) {
+                log.error("生成报告失败", e);
+                reportOutline.setStatus(ReportStateEnum.BUILD_FAILED.getType());
+            }
+        });
+    }
+
+    /**
+     * 获取在营项目用电量
+     *
+     * @param reportOutline 报告outline对象
+     * @return 在营项目用电量
+     * @author lixing
+     * @version V1.0 2021/5/24 4:14 下午
+     */
+    private OpenPower getOpenPower(ReportOutline reportOutline) {
+        OpenPower openPower = new OpenPower();
+        String reportTypeId = reportOutline.getReportTypeId();
+        Date reportMonth = reportOutline.getReportMonth();
+
+        // 获取在营项目用电量下拥有的信息点分组和信息点
+        List<String> groupIdList = getGroupsByParagraph(
+                reportTypeId, BusinessReportParagraphs.OPEN_POWER);
+
+        openPower.setGroups(getPowerGroupInfos(groupIdList, reportMonth));
+
+        List<String> functionIdList = getFunctionsByParagraph(
+                reportTypeId, BusinessReportParagraphs.OPEN_POWER);
+        openPower.setItems(getPowerItemInfos(functionIdList, reportMonth));
+        // TODO: 2021/5/24 计算统计值
+        // openPower.setSummary();
+        return openPower;
+    }
+
+    /**
+     * 获取用电量条目信息
+     *
+     * @param functionIdList 用电量条目列表
+     * @param reportMonth 报告月份
+     * @return 用电量条目列表
+     * @author lixing
+     * @version V1.0 2021/5/24 7:15 下午
+     */
+    private List<PowerItemVO> getPowerItemInfos(List<String> functionIdList, Date reportMonth) {
+        List<PowerItemVO> powerItemVOList = Lists.newArrayList();
+        if (CollectionUtils.isEmpty(functionIdList)) {
+            return powerItemVOList;
+        }
+        for (String functionId : functionIdList) {
+            Function function = functionService.queryFunctionDetail(functionId);
+            String itemId = function.getItemId();
+            // TODO: 2021/5/24 获取条目名称
+            String itemName = "";
+            PowerItemVO powerItemVO = new PowerItemVO();
+            powerItemVO.setName(itemName);
+            // TODO: 2021/5/24 调用functionValueService获取值
+            // powerItemVO.setCurrentMonth();
+            // ...
+            powerItemVOList.add(powerItemVO);
+        }
+        return powerItemVOList;
+    }
+
+    /**
+     * 获取用电量分组信息
+     *
+     * @param groupIdList 分组id列表
+     * @param reportMonth 报告月份
+     * @return 分组对象列表
+     * @author lixing
+     * @version V1.0 2021/5/24 7:12 下午
+     */
+    private List<GroupInfo<PowerItemVO>> getPowerGroupInfos(List<String> groupIdList, Date reportMonth) {
+        List<GroupInfo<PowerItemVO>> groupInfoList = Lists.newArrayList();
+        if (CollectionUtils.isEmpty(groupIdList)) {
+            return groupInfoList;
+        }
+        for (String groupId : groupIdList) {
+            GroupInfo<PowerItemVO> groupInfo = new GroupInfo<>();
+            FunctionGroup functionGroup = functionGroupService.queryFunctionGroupDetail(groupId);
+            groupInfo.setGroupName(functionGroup.getName());
+            // 获取组下的分组(本期不做)
+            // 获取组下的分项
+            String functionIdStr = functionGroup.getFunctionIds();
+            List<String> functionIds = Lists.newArrayList(functionIdStr.split(","));
+            List<PowerItemVO> powerItemInfos = getPowerItemInfos(functionIds, reportMonth);
+            groupInfo.setItems(powerItemInfos);
+            // TODO: 2021/5/24  计算统计值
+            // groupInfo.setSummary();
+        }
+        return groupInfoList;
+    }
+
+
+    /**
+     * 根据段落获取报告类型关联的分组
+     *
+     * @param reportTypeId    报告类型
+     * @param belongParagraph 报告段落
+     * @return 报告段落包含的分组id列表
+     * @author lixing
+     * @version V1.0 2021/5/24 4:31 下午
+     */
+    private List<String> getGroupsByParagraph(String reportTypeId, String belongParagraph) {
+        List<String> groupIdList = Lists.newArrayList();
+        QueryReportTypeFunctionGroupRelDTO queryReportTypeFunctionGroupRelDTO = new QueryReportTypeFunctionGroupRelDTO();
+        queryReportTypeFunctionGroupRelDTO.setReportTypeId(reportTypeId);
+        queryReportTypeFunctionGroupRelDTO.setBelongParagraph(belongParagraph);
+        List<ReportTypeFunctionGroupRel> reportTypeFunctionGroupRels = reportTypeFunctionGroupRelService.
+                queryReportTypeFunctionGroupRelList(queryReportTypeFunctionGroupRelDTO);
+        if (!CollectionUtils.isEmpty(reportTypeFunctionGroupRels)) {
+            groupIdList = reportTypeFunctionGroupRels.stream().
+                    map(ReportTypeFunctionGroupRel::getFunctionGroupId).collect(Collectors.toList());
+        }
+        return groupIdList;
+    }
+
+    /**
+     * 根据段落获取报告类型关联的信息点
+     *
+     * @param reportTypeId    报告类型
+     * @param belongParagraph 报告段落
+     * @return 报告段落包含的信息点id列表
+     * @author lixing
+     * @version V1.0 2021/5/24 4:31 下午
+     */
+    private List<String> getFunctionsByParagraph(String reportTypeId, String belongParagraph) {
+        List<String> functionIdList = Lists.newArrayList();
+        QueryReportTypeFunctionRelDTO queryReportTypeFunctionRelDTO = new QueryReportTypeFunctionRelDTO();
+        queryReportTypeFunctionRelDTO.setReportTypeId(reportTypeId);
+        queryReportTypeFunctionRelDTO.setBelongParagraph(belongParagraph);
+        List<ReportTypeFunctionRel> reportTypeFunctionRels = reportTypeFunctionRelService.queryReportTypeFunctionRelList(queryReportTypeFunctionRelDTO);
+        if (!CollectionUtils.isEmpty(reportTypeFunctionRels)) {
+            functionIdList = reportTypeFunctionRels.stream().
+                    map(ReportTypeFunctionRel::getFunctionId).collect(Collectors.toList());
+        }
+        return functionIdList;
+    }
+
+
+}

+ 37 - 1
src/main/java/com/persagy/apm/energy/report/monthly/outline/service/impl/ReportOutlineServiceImpl.java

@@ -8,6 +8,9 @@ import com.google.common.base.CaseFormat;
 import com.persagy.apm.common.constant.enums.ValidEnum;
 import com.persagy.apm.common.context.poems.PoemsContext;
 import com.persagy.apm.common.model.dto.Sort;
+import com.persagy.apm.energy.report.monthly.config.type.constant.enums.BelongTypeEnum;
+import com.persagy.apm.energy.report.monthly.config.type.model.ReportType;
+import com.persagy.apm.energy.report.monthly.config.type.service.IReportTypeService;
 import com.persagy.apm.energy.report.monthly.outline.constants.enums.ReportStateEnum;
 import com.persagy.apm.energy.report.monthly.outline.dao.ReportOutlineMapper;
 import com.persagy.apm.energy.report.monthly.outline.model.ConvertReportOutlineTool;
@@ -17,11 +20,16 @@ import com.persagy.apm.energy.report.monthly.outline.model.dto.PageQueryReportOu
 import com.persagy.apm.energy.report.monthly.outline.model.dto.QueryReportOutlineDTO;
 import com.persagy.apm.energy.report.monthly.outline.model.dto.UpdateReportOutlineDTO;
 import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
+import com.persagy.apm.energy.report.saasweb.model.vo.ReportAreaVO;
+import com.persagy.apm.energy.report.saasweb.model.vo.ReportProjectVO;
+import com.persagy.apm.energy.report.saasweb.service.ISaasWebService;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import java.util.Calendar;
 import java.util.List;
 
 /**
@@ -33,6 +41,13 @@ import java.util.List;
 @Service
 public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, ReportOutline>
         implements IReportOutlineService {
+    @Autowired
+    IReportTypeService reportTypeService;
+    @Autowired
+    ISaasWebService saasWebService;
+    @Autowired
+    GenerateReportThreadPool generateReportThreadPool;
+
 
     /**
      * 创建报告概要
@@ -47,6 +62,8 @@ public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, R
         // 设置默认值
         setDefaultValue(reportOutline);
         save(reportOutline);
+        // 后台生成报告
+        generateReportThreadPool.generateReport(reportOutline);
         return reportOutline.getId();
     }
 
@@ -60,8 +77,27 @@ public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, R
     private void setDefaultValue(ReportOutline reportOutline) {
         reportOutline.setCreator(PoemsContext.getContext().getUserId());
         reportOutline.setStatus(ReportStateEnum.BUILDING.getType());
-        // todo 其他默认的属性
 
+        /* 拼接报告的名称 */
+        // 根据报告类型判断报告所属是项目还是管理分区, 获取报告所属名称
+        String reportTypeId = reportOutline.getReportTypeId();
+        ReportType reportType = reportTypeService.queryReportTypeDetail(reportTypeId);
+        String belongName = "";
+        if (BelongTypeEnum.PROJECT.getType().equals(reportType.getBelongType())) {
+            ReportProjectVO reportProjectInfo = saasWebService.getReportProjectInfo(reportOutline.getBelong());
+            belongName = reportProjectInfo.getProjectName();
+        }
+        if (BelongTypeEnum.AREA.getType().equals(reportType.getBelongType())) {
+            ReportAreaVO reportAreaInfo = saasWebService.getReportAreaInfo(reportOutline.getBelong());
+            belongName = reportAreaInfo.getAreaName();
+        }
+
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(reportOutline.getReportMonth());
+        reportOutline.setName(calendar.get(Calendar.YEAR) + "年" +
+                calendar.get(Calendar.MONTH) + "月" +
+                belongName + reportType.getName());
     }
 
     /**

+ 95 - 27
src/main/java/com/persagy/apm/energy/report/saasweb/service/impl/SaasWebServiceImpl.java

@@ -103,11 +103,7 @@ public class SaasWebServiceImpl implements ISaasWebService {
             reportAreaVO.setAreaName(poemsPartitionVO.getManagePartitionName());
         }
 
-        // 获取管理分区下的项目
-        QueryProjectDTO queryProjectDTO = new QueryProjectDTO();
-        queryProjectDTO.setGroupManageZone(areaCode);
-        PoemsFeignResponse<PoemsProjectVO> projectsResponse = saasWebClient.queryProjects(queryProjectDTO);
-        List<PoemsProjectVO> projectVOList = projectsResponse.getContent();
+        List<PoemsProjectVO> projectVOList = getProjectsByArea(areaCode);
 
         // 统计分区下总的商业面积,地下停车场面积
         BigDecimal totalCommercialArea = new BigDecimal("0");
@@ -129,19 +125,53 @@ public class SaasWebServiceImpl implements ISaasWebService {
         return reportAreaVO;
     }
 
+    /**
+     * 获取分区下所有的项目
+     *
+     * @param areaCode 分区编码
+     * @return 项目列表
+     * @author lixing
+     * @version V1.0 2021/5/24 5:37 下午
+     */
+    private List<PoemsProjectVO> getProjectsByArea(String areaCode) {
+        // 获取管理分区下的项目
+        QueryProjectDTO queryProjectDTO = new QueryProjectDTO();
+        queryProjectDTO.setGroupManageZone(areaCode);
+        PoemsFeignResponse<PoemsProjectVO> projectsResponse = saasWebClient.queryProjects(queryProjectDTO);
+        return projectsResponse.getContent();
+    }
+
+    /**
+     * 根据区域和业态过滤项目
+     *
+     * @param areaCode 区域编码
+     * @param buildingType 业态
+     * @return 项目列表
+     * @author lixing
+     * @version V1.0 2021/5/24 6:01 下午
+     */
+    private List<SimpleProjectVO> getProjectsByAreaAndBuildingType(String areaCode, String buildingType) {
+        List<PoemsProjectVO> projectsByArea = getProjectsByArea(areaCode);
+        if (CollectionUtils.isEmpty(projectsByArea)) {
+            return Lists.newArrayList();
+        }
+        List<String> buildingTypes = getRelatedBuildingTypes(buildingType);
+        return projectsByArea.stream().filter(
+                poemsProjectVO -> StringUtils.isNotBlank(poemsProjectVO.getFunctionType()) &&
+                        buildingTypes.contains(poemsProjectVO.getFunctionType())).map(
+                ConvertSaasWebTool.INSTANCE::convert2SimpleProjectVO
+        ).collect(Collectors.toList());
+    }
+
     @Override
     public List<SimpleProjectVO> getAvailableProjects(String buildingType) {
         List<SimpleProjectVO> result = Lists.newArrayList();
-        // 获取业态下所有的子业态
-        PoemsFeignBaseDTO poemsFeignBaseDTO = new PoemsFeignBaseDTO();
-        poemsFeignBaseDTO.setDefaultValue();
-        PoemsFeignResponse<FunctionTypeVO> functionTypesResponse = saasWebClient.getAllProjectFunctionTypes(poemsFeignBaseDTO);
-        List<FunctionTypeVO> functionTypeVOList = functionTypesResponse.getContent();
-        List<FunctionTypeVO> sonBuildingTypes = findSonBuildingTypes(buildingType, functionTypeVOList);
-        List<String> buildingTypes = Lists.newArrayList(buildingType);
-        functionTypeTree2List(sonBuildingTypes, buildingTypes);
+        // 获取所有关联的业态
+        List<String> buildingTypes = getRelatedBuildingTypes(buildingType);
 
         // 获取用户可选的所有项目
+        PoemsFeignBaseDTO poemsFeignBaseDTO = new PoemsFeignBaseDTO();
+        poemsFeignBaseDTO.setDefaultValue();
         PoemsFeignResponse<UserProjectsInfoVO> currentUserProjectsInfosResponse = saasWebClient.getCurrentUserProjectsInfo(poemsFeignBaseDTO);
         List<UserProjectsInfoVO> currentUserProjectsInfos = currentUserProjectsInfosResponse.getContent();
         if (!CollectionUtils.isEmpty(currentUserProjectsInfos)) {
@@ -160,6 +190,20 @@ public class SaasWebServiceImpl implements ISaasWebService {
     }
 
     /**
+     * 级联获取所有关联的业态
+     *
+     * @return 所有关联的业态(包括自己)
+     * @author lixing
+     * @version V1.0 2021/5/24 6:04 下午
+     */
+    private List<String> getRelatedBuildingTypes(String buildingType) {
+        List<FunctionTypeVO> sonBuildingTypes = findSonBuildingTypes(buildingType);
+        List<String> buildingTypes = Lists.newArrayList(buildingType);
+        functionTypeTree2List(sonBuildingTypes, buildingTypes);
+        return buildingTypes;
+    }
+
+    /**
      * 项目功能类型树转换为项目功能编码列表
      *
      * @param functionTypeVOList 项目功能类型树
@@ -183,19 +227,36 @@ public class SaasWebServiceImpl implements ISaasWebService {
     /**
      * 获取项目功能类型的子类型
      *
+     * @param buildingType 要获取子类型的项目功能类型
+     * @return 子类型列表树
+     * @author lixing
+     * @version V1.0 2021/5/21 2:40 下午
+     */
+    private List<FunctionTypeVO> findSonBuildingTypes(String buildingType) {
+        // 获取业态下所有的子业态
+        PoemsFeignBaseDTO poemsFeignBaseDTO = new PoemsFeignBaseDTO();
+        poemsFeignBaseDTO.setDefaultValue();
+        PoemsFeignResponse<FunctionTypeVO> functionTypesResponse = saasWebClient.getAllProjectFunctionTypes(poemsFeignBaseDTO);
+        List<FunctionTypeVO> functionTypeVOList = functionTypesResponse.getContent();
+        return recursiveFindSonBuildingTypes(buildingType, functionTypeVOList);
+    }
+
+    /**
+     * 递归获取项目功能类型的子类型
+     *
      * @param buildingType       要获取子类型的项目功能类型
      * @param functionTypeVOList 所有的项目功能类型
      * @return 子类型列表树
      * @author lixing
      * @version V1.0 2021/5/21 2:40 下午
      */
-    private List<FunctionTypeVO> findSonBuildingTypes(String buildingType, List<FunctionTypeVO> functionTypeVOList) {
+    private List<FunctionTypeVO> recursiveFindSonBuildingTypes(String buildingType, List<FunctionTypeVO> functionTypeVOList) {
         if (!CollectionUtils.isEmpty(functionTypeVOList)) {
             for (FunctionTypeVO functionTypeVO : functionTypeVOList) {
                 if (functionTypeVO.getCode().equals(buildingType)) {
                     return functionTypeVO.getContents();
                 }
-                List<FunctionTypeVO> sonBuildingTypes = findSonBuildingTypes(buildingType, functionTypeVO.getContents());
+                List<FunctionTypeVO> sonBuildingTypes = recursiveFindSonBuildingTypes(buildingType, functionTypeVO.getContents());
                 if (!CollectionUtils.isEmpty(sonBuildingTypes)) {
                     return sonBuildingTypes;
                 }
@@ -386,19 +447,26 @@ public class SaasWebServiceImpl implements ISaasWebService {
 
         for (FilterPartitionVO partition : partitions) {
             List<SimpleProjectVO> projects = partition.getProjects();
-            if (!CollectionUtils.isEmpty(projects)) {
-                Set<String> projectIds = projects.stream().
-                        map(SimpleProjectVO::getProjectId).collect(Collectors.toSet());
-                // 取用户可选项目和分区下项目的交集,projectIds会被更新为两个集合的交集
-                availableProjectIds.retainAll(projectIds);
-                if (projectIds.size() > 0) {
-                    partition.setProjects(
-                            projects.stream().filter(
-                                    project -> projectIds.contains(project.getProjectId())).
-                                    collect(Collectors.toList()));
-                    result.put(partition.getAreaId(), partition);
-                }
+            if (CollectionUtils.isEmpty(projects)) {
+                continue;
+            }
+            Set<String> projectIds = projects.stream().
+                    map(SimpleProjectVO::getProjectId).collect(Collectors.toSet());
+            // 取用户可选项目和分区下项目的交集,projectIds会被更新为两个集合的交集
+            availableProjectIds.retainAll(projectIds);
+            // 根据业态和分区过滤项目
+            List<SimpleProjectVO> projectsByAreaAndBuildingType = getProjectsByAreaAndBuildingType(partition.getAreaId(), buildingType);
+            Set<String> projectIdsByAreaAndBuildingType = projectsByAreaAndBuildingType.stream().
+                    map(SimpleProjectVO::getProjectId).collect(Collectors.toSet());
+            availableProjectIds.retainAll(projectIdsByAreaAndBuildingType);
+            if (CollectionUtils.isEmpty(projectIds) || projectIdsByAreaAndBuildingType.size() != projectIds.size()) {
+                continue;
             }
+            partition.setProjects(
+                    projects.stream().filter(
+                            project -> projectIds.contains(project.getProjectId())).
+                            collect(Collectors.toList()));
+            result.put(partition.getAreaId(), partition);
         }
         return result;
     }

+ 18 - 0
src/main/resources/mapper/ReportTypeFunctionGroupRelMapper.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.dao.ReportTypeFunctionGroupRelMapper">
+    <resultMap id="ReportTypeFunctionGroupRelMap"
+               type="com.persagy.apm.energy.report.monthly.config.rel.typefunctiongroup.model.ReportTypeFunctionGroupRel">
+        <result column="id" property="id"/>
+        <result column="report_type_id" property="reportTypeId"/>
+        <result column="function_group_id" property="functionGroupId"/>
+        <result column="belong_paragraph" property="belongParagraph"/>
+        <result column="ts" property="ts"/>
+        <result column="creator" property="creator"/>
+        <result column="creation_time" property="creationTime"/>
+        <result column="modifier" property="modifier"/>
+        <result column="modified_time" property="modifiedTime"/>
+        <result column="valid" property="valid"/>
+    </resultMap>
+</mapper>
+

+ 18 - 0
src/main/resources/mapper/ReportTypeFunctionRelMapper.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.persagy.apm.energy.report.monthly.config.rel.typefunction.dao.ReportTypeFunctionRelMapper">
+    <resultMap id="ReportTypeFunctionRelMap"
+               type="com.persagy.apm.energy.report.monthly.config.rel.typefunction.model.ReportTypeFunctionRel">
+        <result column="id" property="id"/>
+        <result column="report_type_id" property="reportTypeId"/>
+        <result column="function_id" property="functionId"/>
+        <result column="belong_paragraph" property="belongParagraph"/>
+        <result column="ts" property="ts"/>
+        <result column="creator" property="creator"/>
+        <result column="creation_time" property="creationTime"/>
+        <result column="modifier" property="modifier"/>
+        <result column="modified_time" property="modifiedTime"/>
+        <result column="valid" property="valid"/>
+    </resultMap>
+</mapper>
+