|
@@ -1,6 +1,7 @@
|
|
|
package com.persagy.apm.energy.report.monthly.outline.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.persagy.apm.common.response.ApmResponseUpsertVO;
|
|
|
import com.persagy.apm.common.response.CommonResult;
|
|
|
import com.persagy.apm.common.response.PageList;
|
|
@@ -10,14 +11,16 @@ import com.persagy.apm.energy.report.monthly.config.type.service.IReportTypeServ
|
|
|
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.vo.ResponseReportOutlineListItemVO;
|
|
|
import com.persagy.apm.energy.report.monthly.outline.service.IReportOutlineService;
|
|
|
import com.persagy.apm.energy.report.saasweb.model.vo.PartitionVO;
|
|
|
import com.persagy.apm.energy.report.saasweb.model.vo.SimpleProjectVO;
|
|
|
+import com.persagy.apm.energy.report.saasweb.service.ISaasWebService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.assertj.core.util.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -26,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 报告概要控制层
|
|
@@ -42,6 +46,8 @@ public class ReportOutlineController {
|
|
|
private IReportOutlineService reportOutlineService;
|
|
|
@Autowired
|
|
|
private IReportTypeService reportTypeService;
|
|
|
+ @Autowired
|
|
|
+ private ISaasWebService saasWebService;
|
|
|
|
|
|
@ApiOperation(value = "创建报告概要")
|
|
|
@PostMapping("/create")
|
|
@@ -51,42 +57,42 @@ 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("/delete")
|
|
|
-// public CommonResult deleteReportOutline(
|
|
|
-// @RequestBody @Valid DeleteReportOutlineDTO deleteReportOutlineDTO) {
|
|
|
-// reportOutlineService.deleteReportOutline(deleteReportOutlineDTO.getId());
|
|
|
-// 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("/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("/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")
|
|
@@ -95,7 +101,7 @@ public class ReportOutlineController {
|
|
|
IPage<ReportOutline> pagedList = reportOutlineService.pageQueryReportOutline(pageQueryReportOutlineDTO);
|
|
|
IPage<ResponseReportOutlineListItemVO> pagedResultList = pagedList.convert(item -> {
|
|
|
try {
|
|
|
- return ConvertReportOutlineTool.INSTANCE.convert2ResponseListItemDTO(item);
|
|
|
+ return ConvertReportOutlineTool.INSTANCE.convert2ResponseListItemDTO(item);
|
|
|
} catch (Exception e) {
|
|
|
throw new IllegalArgumentException("分页查询,ReportOutline实体类转换为列表对象发生异常", e);
|
|
|
}
|
|
@@ -105,21 +111,29 @@ public class ReportOutlineController {
|
|
|
|
|
|
@ApiOperation(value = "查询用户可选项目范围")
|
|
|
@PostMapping("/queryAvailableProjects")
|
|
|
- public CommonResult<PageList<SimpleProjectVO>> queryAvailableProjects() {
|
|
|
- // TODO: 2021/5/17 查询用户可选项目范围
|
|
|
- return ResultHelper.multi(Lists.newArrayList());
|
|
|
+ public CommonResult<PageList<SimpleProjectVO>> queryAvailableProjects(
|
|
|
+ @Valid @RequestBody QueryAvailableBelongsDTO queryAvailableBelongsDTO) {
|
|
|
+ List<SimpleProjectVO> availableProjects = saasWebService.getAvailableProjects(queryAvailableBelongsDTO.getBuildingType());
|
|
|
+ IPage<SimpleProjectVO> resultList = new Page<>();
|
|
|
+ resultList.setRecords(availableProjects);
|
|
|
+ resultList.setTotal(availableProjects.size());
|
|
|
+ return ResultHelper.multi(resultList);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "查询用户可选分区范围")
|
|
|
@PostMapping("/queryAvailableAreas")
|
|
|
- public CommonResult<PageList<PartitionVO>> queryAvailableAreas() {
|
|
|
- // TODO: 2021/5/17 查询用户可选分区范围
|
|
|
- return ResultHelper.multi(Lists.newArrayList());
|
|
|
+ public CommonResult<PageList<PartitionVO>> queryAvailableAreas(
|
|
|
+ @Valid @RequestBody QueryAvailableBelongsDTO queryAvailableBelongsDTO) {
|
|
|
+ List<PartitionVO> availableAreas = saasWebService.getAvailableAreas(queryAvailableBelongsDTO.getBuildingType());
|
|
|
+ IPage<PartitionVO> resultList = new Page<>();
|
|
|
+ resultList.setRecords(availableAreas);
|
|
|
+ resultList.setTotal(availableAreas.size());
|
|
|
+ return ResultHelper.multi(resultList);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "当前用户可用的报告类型")
|
|
|
@PostMapping("/availableReportTypes")
|
|
|
- public CommonResult<PageList<ResponseReportTypeListItemVO>> queryAvaliableReportTypes() {
|
|
|
+ public CommonResult<PageList<ResponseReportTypeListItemVO>> queryAvailableReportTypes() {
|
|
|
IPage<ResponseReportTypeListItemVO> resultList = reportTypeService.queryAvailableReportTypes();
|
|
|
return ResultHelper.multi(resultList);
|
|
|
}
|