浏览代码

生成报告代码开发

lixing 3 年之前
父节点
当前提交
468b50ccf9

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

@@ -139,23 +139,20 @@ public class ReportTypeFunctionGroupRelServiceImpl extends ServiceImpl<ReportTyp
         QueryWrapper<ReportTypeFunctionGroupRel> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq(ReportTypeFunctionGroupRel.PROP_VALID, ValidEnum.TRUE.getType());
         // 默认按创建时间倒序排序
-        queryWrapper.orderBy(true, false, ReportTypeFunctionGroupRel.PROP_CREATIONTIME);
+        queryWrapper.orderBy(true, true, ReportTypeFunctionGroupRel.PROP_CREATIONTIME);
 
         if (queryReportTypeFunctionGroupRelDTO != null) {
 
-            // todo 需判断使用like还是eq
             if (StringUtils.isNotEmpty(queryReportTypeFunctionGroupRelDTO.getReportTypeId())) {
-                queryWrapper.like(ReportTypeFunctionGroupRel.PROP_REPORT_TYPE_ID, queryReportTypeFunctionGroupRelDTO.getReportTypeId());
+                queryWrapper.eq(ReportTypeFunctionGroupRel.PROP_REPORT_TYPE_ID, queryReportTypeFunctionGroupRelDTO.getReportTypeId());
             }
 
-            // todo 需判断使用like还是eq
             if (StringUtils.isNotEmpty(queryReportTypeFunctionGroupRelDTO.getFunctionGroupId())) {
-                queryWrapper.like(ReportTypeFunctionGroupRel.PROP_FUNCTION_GROUP_ID, queryReportTypeFunctionGroupRelDTO.getFunctionGroupId());
+                queryWrapper.eq(ReportTypeFunctionGroupRel.PROP_FUNCTION_GROUP_ID, queryReportTypeFunctionGroupRelDTO.getFunctionGroupId());
             }
 
-            // todo 需判断使用like还是eq
             if (StringUtils.isNotEmpty(queryReportTypeFunctionGroupRelDTO.getBelongParagraph())) {
-                queryWrapper.like(ReportTypeFunctionGroupRel.PROP_BELONG_PARAGRAPH, queryReportTypeFunctionGroupRelDTO.getBelongParagraph());
+                queryWrapper.eq(ReportTypeFunctionGroupRel.PROP_BELONG_PARAGRAPH, queryReportTypeFunctionGroupRelDTO.getBelongParagraph());
             }
 
         }

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

@@ -10,10 +10,7 @@ import com.persagy.apm.energy.report.monthly.config.type.model.vo.ResponseReport
 import com.persagy.apm.energy.report.monthly.config.type.service.IReportTypeService;
 import com.persagy.apm.energy.report.monthly.outline.model.ConvertReportOutlineTool;
 import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
-import com.persagy.apm.energy.report.monthly.outline.model.dto.AddReportOutlineDTO;
-import com.persagy.apm.energy.report.monthly.outline.model.dto.DeleteReportOutlineDTO;
-import com.persagy.apm.energy.report.monthly.outline.model.dto.PageQueryReportOutlineDTO;
-import com.persagy.apm.energy.report.monthly.outline.model.dto.QueryAvailableBelongsDTO;
+import com.persagy.apm.energy.report.monthly.outline.model.dto.*;
 import com.persagy.apm.energy.report.monthly.outline.model.vo.ResponseReportOutlineListItemVO;
 import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
 import com.persagy.apm.energy.report.saasweb.model.vo.PartitionVO;
@@ -49,7 +46,7 @@ public class ReportOutlineController {
     @Autowired
     private ISaasWebService saasWebService;
 
-    @ApiOperation(value = "创建报告概要")
+    @ApiOperation(value = "生成报告")
     @PostMapping("/create")
     public CommonResult<ApmResponseUpsertVO> createReportOutline(
             @Valid @RequestBody AddReportOutlineDTO addReportOutlineDTO) {
@@ -57,8 +54,16 @@ public class ReportOutlineController {
         return ResultHelper.single(new ApmResponseUpsertVO(id));
     }
 
+    @ApiOperation(value = "重新生成报告")
+    @PostMapping("/recreate")
+    public CommonResult<ApmResponseUpsertVO> recreateReportOutline(
+            @Valid @RequestBody RecreateReportOutlineDTO recreateReportOutlineDTO) {
+        String id = reportOutlineService.recreateReportOutline(recreateReportOutlineDTO);
+        return ResultHelper.single(new ApmResponseUpsertVO(id));
+    }
+
     @ApiOperation(value = "批量删除报告概要")
-    @PostMapping("/batch_delete")
+    @PostMapping("/batchDelete")
     public CommonResult deleteReportOutline(
             @RequestBody @Valid DeleteReportOutlineDTO deleteReportOutlineDTO) {
         reportOutlineService.batchDeleteReportOutline(deleteReportOutlineDTO.getIds());

+ 21 - 0
src/main/java/com/persagy/apm/energy/report/monthly/outline/model/dto/RecreateReportOutlineDTO.java

@@ -0,0 +1,21 @@
+package com.persagy.apm.energy.report.monthly.outline.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.List;
+
+/**
+ * @author lixing
+ * @version V1.0 2021-05-17 11:09:38
+ */
+@Data
+@ApiModel(value = "重新生成报告入参")
+public class RecreateReportOutlineDTO {
+    @NotEmpty(message = "报告id不能为空")
+    @ApiModelProperty(value = "报告id", required = true)
+    private String id;
+
+}

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

@@ -18,35 +18,35 @@ import java.util.Date;
 @ApiModel(value = "更新报告概要入参")
 public class UpdateReportOutlineDTO {
     @ApiModelProperty(value = "报告id", required = true)
-    @NotNull(message = "报告id不能为空") // todo 更新校验规则
+    @NotNull(message = "报告id不能为空")
     private String id;
 
     @ApiModelProperty(value = "报告名称", required = true)
-    @NotNull(message = "报告名称不能为空") // todo 更新校验规则
+    @NotNull(message = "报告名称不能为空")
     private String name;
 
     @ApiModelProperty(value = "报告日期", required = true)
-    @NotNull(message = "报告日期不能为空") // todo 更新校验规则
+    @NotNull(message = "报告日期不能为空")
     private Date date;
 
     @ApiModelProperty(value = "报告所属", required = true)
-    @NotNull(message = "报告所属不能为空") // todo 更新校验规则
+    @NotNull(message = "报告所属不能为空")
     private String belong;
 
     @ApiModelProperty(value = "报告类型", required = true)
-    @NotNull(message = "报告类型不能为空") // todo 更新校验规则
+    @NotNull(message = "报告类型不能为空")
     private String type;
 
     @ApiModelProperty(value = "报告详情id", required = true)
-    @NotNull(message = "报告详情id不能为空") // todo 更新校验规则
+    @NotNull(message = "报告详情id不能为空")
     private String detailId;
 
     @ApiModelProperty(value = "报告状态", required = true)
-    @NotNull(message = "报告状态不能为空") // todo 更新校验规则
+    @NotNull(message = "报告状态不能为空")
     private Integer status;
 
     @ApiModelProperty(value = "备注", required = true)
-    @NotNull(message = "备注不能为空") // todo 更新校验规则
+    @NotNull(message = "备注不能为空")
     private ReportOutlineRemark remark;
 
 }

+ 24 - 0
src/main/java/com/persagy/apm/energy/report/monthly/outline/service/IBusinessReportPlatformInfoService.java

@@ -0,0 +1,24 @@
+package com.persagy.apm.energy.report.monthly.outline.service;
+
+import com.persagy.apm.energy.report.monthly.detail.business.model.Platform;
+import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
+
+import java.util.List;
+
+/**
+ * 接口说明
+ *
+ * @author lixing
+ * @version V1.0 2021/5/31 10:25 上午
+ **/
+public interface IBusinessReportPlatformInfoService {
+    /**
+     * 获取报告平台运维信息
+     *
+     * @param reportOutline 报告概要
+     * @return 平台运维信息点信息列表
+     * @author lixing
+     * @version V1.0 2021/5/30 10:47 下午
+     */
+    List<Platform> getPlatforms(ReportOutline reportOutline);
+}

+ 10 - 0
src/main/java/com/persagy/apm/energy/report/monthly/outline/service/IReportOutlineService.java

@@ -93,4 +93,14 @@ public interface IReportOutlineService {
      * @version V1.0 2021-05-17 11:09:37
      */
     IPage<ReportOutline> pageQueryReportOutline(PageQueryReportOutlineDTO pageQueryReportOutlineDTO);
+
+    /**
+     * 重新生成报告
+     *
+     * @param recreateReportOutlineDTO 重新生成报告入参
+     * @return 报告id
+     * @author lixing
+     * @version V1.0 2021/5/31 9:47 上午
+     */
+    String recreateReportOutline(RecreateReportOutlineDTO recreateReportOutlineDTO);
 }

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

@@ -7,6 +7,7 @@ import com.persagy.apm.energy.report.monthly.outline.constants.BusinessReportPar
 import com.persagy.apm.energy.report.monthly.outline.constants.enums.ReportStateEnum;
 import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
 import com.persagy.apm.energy.report.monthly.outline.service.IBusinessReportCostInfoService;
+import com.persagy.apm.energy.report.monthly.outline.service.IBusinessReportPlatformInfoService;
 import com.persagy.apm.energy.report.monthly.outline.service.IBusinessReportPowerInfoService;
 import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
 import lombok.extern.slf4j.Slf4j;
@@ -31,7 +32,7 @@ public class BusinessAreaReportGenerator {
     @Autowired
     private IBusinessReportCostInfoService businessReportCostInfoService;
     @Autowired
-    private BusinessReportPlatformInfoServiceImpl businessReportPlatformInfoService;
+    private IBusinessReportPlatformInfoService businessReportPlatformInfoService;
     @Autowired
     private IReportOutlineService reportOutlineService;
 

+ 2 - 2
src/main/java/com/persagy/apm/energy/report/monthly/outline/service/impl/BusinessProjectReportGenerator.java

@@ -9,13 +9,13 @@ import com.persagy.apm.energy.report.monthly.outline.constants.BusinessReportPar
 import com.persagy.apm.energy.report.monthly.outline.constants.enums.ReportStateEnum;
 import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
 import com.persagy.apm.energy.report.monthly.outline.service.IBusinessReportCostInfoService;
+import com.persagy.apm.energy.report.monthly.outline.service.IBusinessReportPlatformInfoService;
 import com.persagy.apm.energy.report.monthly.outline.service.IBusinessReportPowerInfoService;
 import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -34,7 +34,7 @@ public class BusinessProjectReportGenerator {
     @Autowired
     private IBusinessReportCostInfoService businessReportCostInfoService;
     @Autowired
-    private BusinessReportPlatformInfoServiceImpl businessReportPlatformInfoService;
+    private IBusinessReportPlatformInfoService businessReportPlatformInfoService;
     @Autowired
     private IReportOutlineService reportOutlineService;
 

+ 26 - 16
src/main/java/com/persagy/apm/energy/report/monthly/outline/service/impl/BusinessReportPlatformInfoServiceImpl.java

@@ -1,7 +1,7 @@
 package com.persagy.apm.energy.report.monthly.outline.service.impl;
 
 import com.persagy.apm.common.context.poems.PoemsContext;
-import com.persagy.apm.energy.report.common.dto.QueryAreaPlatformParamDTO;
+import com.persagy.apm.energy.report.common.dto.QueryPlatformParamDTO;
 import com.persagy.apm.energy.report.common.service.CommonService;
 import com.persagy.apm.energy.report.monthly.config.rel.typestatisticsitem.model.ReportTypeStatisticsItemRel;
 import com.persagy.apm.energy.report.monthly.config.rel.typestatisticsitem.model.dto.QueryReportTypeStatisticsItemRelDTO;
@@ -9,11 +9,15 @@ import com.persagy.apm.energy.report.monthly.config.rel.typestatisticsitem.servi
 import com.persagy.apm.energy.report.monthly.config.statisticsitems.model.StatisticItems;
 import com.persagy.apm.energy.report.monthly.config.statisticsitems.model.dto.QueryStatisticItemsDTO;
 import com.persagy.apm.energy.report.monthly.config.statisticsitems.service.IStatisticItemsService;
+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.Platform;
 import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
 import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
 import org.assertj.core.util.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
@@ -26,7 +30,8 @@ import java.util.stream.Collectors;
  * @author lixing
  * @version V1.0 2021/5/30 10:22 下午
  **/
-public class BusinessReportPlatformInfoServiceImpl {
+@Service
+public class BusinessReportPlatformInfoServiceImpl implements com.persagy.apm.energy.report.monthly.outline.service.IBusinessReportPlatformInfoService {
     @Autowired
     private IReportTypeStatisticsItemRelService reportTypeStatisticsItemRelService;
     @Autowired
@@ -35,19 +40,18 @@ public class BusinessReportPlatformInfoServiceImpl {
     private CommonService commonService;
     @Autowired
     private IReportOutlineService reportOutlineService;
+    @Autowired
+    private IReportTypeService reportTypeService;
+
+    @Value("${group.code}")
+    private String groupCode;
 
-    /**
-     * 获取报告平台运维信息
-     *
-     * @param reportOutline 报告概要
-     * @return 平台运维信息点信息列表
-     * @author lixing
-     * @version V1.0 2021/5/30 10:47 下午
-     */
+    @Override
     public List<Platform> getPlatforms(ReportOutline reportOutline) {
         // 查询报告类型关联的统计条目
         QueryReportTypeStatisticsItemRelDTO queryReportTypeStatisticsItemRelDTO = new QueryReportTypeStatisticsItemRelDTO();
-        queryReportTypeStatisticsItemRelDTO.setReportTypeId(reportOutline.getReportTypeId());
+        String reportTypeId = reportOutline.getReportTypeId();
+        queryReportTypeStatisticsItemRelDTO.setReportTypeId(reportTypeId);
         List<ReportTypeStatisticsItemRel> reportTypeStatisticsItemRels = reportTypeStatisticsItemRelService.
                 queryReportTypeStatisticsItemRelList(queryReportTypeStatisticsItemRelDTO);
         if (CollectionUtils.isEmpty(reportTypeStatisticsItemRels)) {
@@ -68,15 +72,21 @@ public class BusinessReportPlatformInfoServiceImpl {
         // 获取报告关联的项目
         List<String> projectIds = reportOutlineService.queryRelatedProjects(reportOutline);
 
+        // 获取报告类型的所属类型
+        ReportType reportType = reportTypeService.queryReportTypeDetail(reportTypeId);
+        String belongType = reportType.getBelongType();
+
         // 拼装运维信息查询条件
-        QueryAreaPlatformParamDTO queryAreaPlatformParamDTO = new QueryAreaPlatformParamDTO();
-        queryAreaPlatformParamDTO.setReportDate(reportOutline.getReportMonth());
-        queryAreaPlatformParamDTO.setProjectIdList(projectIds);
-        queryAreaPlatformParamDTO.setUserId(PoemsContext.getContext().getUserId());
+        QueryPlatformParamDTO queryPlatformParamDTO = new QueryPlatformParamDTO();
+        queryPlatformParamDTO.setReportDate(reportOutline.getReportMonth());
+        queryPlatformParamDTO.setProjectIdList(projectIds);
+        queryPlatformParamDTO.setGroupCode(groupCode);
+        queryPlatformParamDTO.setUserId(PoemsContext.getContext().getUserId());
+        queryPlatformParamDTO.setBelongType(belongType);
 
         List<Platform> result = new ArrayList<>();
         for (StatisticItems statisticItems : statisticItemList) {
-            result.add(commonService.getPlatform(statisticItems, queryAreaPlatformParamDTO));
+            result.add(commonService.getPlatform(statisticItems, queryPlatformParamDTO));
         }
 
         return result;

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

@@ -59,6 +59,9 @@ public class BusinessReportPowerInfoServiceImpl implements com.persagy.apm.energ
         List<String> projectIds = reportOutlineService.queryRelatedProjects(reportOutline);
 
         // TODO: 2021/5/30 过滤出去年一月份之前创建的项目
+        if (CollectionUtils.isEmpty(projectIds)) {
+            return null;
+        }
         List<String> filteredProjectIds = new ArrayList<>();
 
         return getPowerInfoByProjectIds(groupIdList, functionIdList, reportMonth, filteredProjectIds);

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

@@ -15,10 +15,7 @@ import com.persagy.apm.energy.report.monthly.outline.constants.enums.ReportState
 import com.persagy.apm.energy.report.monthly.outline.dao.ReportOutlineMapper;
 import com.persagy.apm.energy.report.monthly.outline.model.ConvertReportOutlineTool;
 import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
-import com.persagy.apm.energy.report.monthly.outline.model.dto.AddReportOutlineDTO;
-import com.persagy.apm.energy.report.monthly.outline.model.dto.PageQueryReportOutlineDTO;
-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.model.dto.*;
 import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
 import com.persagy.apm.energy.report.saasweb.model.vo.PoemsProjectVO;
 import com.persagy.apm.energy.report.saasweb.model.vo.ReportAreaVO;
@@ -156,6 +153,28 @@ public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, R
         return reportOutline;
     }
 
+    /**
+     * 校验报告概要是否存在
+     *
+     * @param id 报告概要主键
+     * @return 报告概要对象
+     * @author lixing
+     * @version V1.0 2021-05-17 11:09:37
+     */
+    public ReportOutline checkExists(String id) {
+        if (id == null) {
+            throw new IllegalArgumentException("主键不能为空");
+        }
+
+        ReportOutline reportOutline = getById(id);
+
+        if (reportOutline == null) {
+            throw new IllegalArgumentException("找不到数据,id:" + id);
+        }
+
+        return reportOutline;
+    }
+
     @Override
     @Transactional
     public void batchDeleteReportOutline(List<String> ids) {
@@ -287,4 +306,13 @@ public class ReportOutlineServiceImpl extends ServiceImpl<ReportOutlineMapper, R
         }
         return projectIds;
     }
+
+    @Override
+    public String recreateReportOutline(RecreateReportOutlineDTO recreateReportOutlineDTO) {
+        String id = recreateReportOutlineDTO.getId();
+        ReportOutline reportOutline = checkExists(id);
+        // 后台生成报告
+        generateReportThreadPool.generateReport(reportOutline);
+        return reportOutline.getId();
+    }
 }

+ 2 - 0
src/main/java/com/persagy/apm/energy/report/saasweb/model/vo/SimpleProjectVO.java

@@ -19,4 +19,6 @@ public class SimpleProjectVO {
     private String functionType;
     @ApiModelProperty(value = "项目本地编码")
     private String projectLocalID;
+    @ApiModelProperty(value = "开业时间")
+    private String businessOpeningTime;
 }