需求-----大屏复制

raodeming 3 years ago
parent ec77e4aba5
commit 5f0e8783dc

@ -0,0 +1,33 @@
package com.anjiplus.template.gaea.business.enums;
/**
* Created by raodeming on 2022/5/8.
*/
public enum ReportTypeEnum {
/**report_screen*/
report_screen("report_screen", "大屏报表"),
/**report_excel*/
report_excel("report_excel", "excel报表"),
;
private String codeValue;
private String codeDesc;
ReportTypeEnum() {
}
private ReportTypeEnum(String codeValue, String codeDesc) {
this.codeValue = codeValue;
this.codeDesc = codeDesc;
}
public String getCodeValue() {
return this.codeValue;
}
public String getCodeDesc() {
return this.codeDesc;
}
}

@ -11,10 +11,7 @@ import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report;
import com.anjiplus.template.gaea.business.modules.report.service.ReportService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* TODO
@ -46,11 +43,11 @@ public class ReportController extends GaeaBaseController<ReportParam, Report, Re
return new ReportDto();
}
@DeleteMapping("/delReport")
@Permission(code = "delete", name = "删除")
@GaeaAuditLog(pageTitle = "删除")
public ResponseBean delReport(@RequestBody ReportDto reportDto) {
reportService.delReport(reportDto);
@GetMapping("/copy")
@Permission(code = "copy", name = "复制")
@GaeaAuditLog(pageTitle = "复制")
public ResponseBean copy(@RequestParam("reportId") Long reportId) {
reportService.copy(reportId);
return ResponseBean.builder().build();
}
}

@ -12,11 +12,16 @@ import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report;
*/
public interface ReportService extends GaeaBaseService<ReportParam, Report> {
void delReport(ReportDto reportDto);
/**
* +1
* @param reportCode
*/
void downloadStatistics(String reportCode);
/**
*
* @param reportId
*/
void copy(Long reportId);
}

@ -3,12 +3,26 @@ package com.anjiplus.template.gaea.business.modules.report.service.impl;
import com.anji.plus.gaea.constant.BaseOperationEnum;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anji.plus.gaea.exception.BusinessException;
import com.anji.plus.gaea.utils.GaeaBeanUtils;
import com.anjiplus.template.gaea.business.enums.ReportTypeEnum;
import com.anjiplus.template.gaea.business.modules.dashboard.dao.entity.ReportDashboard;
import com.anjiplus.template.gaea.business.modules.dashboard.service.ReportDashboardService;
import com.anjiplus.template.gaea.business.modules.dashboardwidget.dao.entity.ReportDashboardWidget;
import com.anjiplus.template.gaea.business.modules.dashboardwidget.service.ReportDashboardWidgetService;
import com.anjiplus.template.gaea.business.modules.report.controller.dto.ReportDto;
import com.anjiplus.template.gaea.business.modules.report.dao.ReportMapper;
import com.anjiplus.template.gaea.business.modules.report.dao.entity.Report;
import com.anjiplus.template.gaea.business.modules.report.service.ReportService;
import com.anjiplus.template.gaea.business.modules.reportexcel.dao.entity.ReportExcel;
import com.anjiplus.template.gaea.business.modules.reportexcel.service.ReportExcelService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.List;
/**
*
@ -20,6 +34,12 @@ public class ReportServiceImpl implements ReportService {
@Autowired
private ReportMapper reportMapper;
@Autowired
private ReportDashboardService reportDashboardService;
@Autowired
private ReportDashboardWidgetService reportDashboardWidgetService;
@Autowired
private ReportExcelService reportExcelService;
@Override
public GaeaBaseMapper<Report> getMapper() {
@ -28,10 +48,41 @@ public class ReportServiceImpl implements ReportService {
@Override
public void delReport(ReportDto reportDto) {
deleteById(reportDto.getId());
//删除gaea_report_excel、gaea_report_dashboard、gaea_report_dashboard_widget
//...
public void processBatchBeforeOperation(List<Report> entities, BaseOperationEnum operationEnum) throws BusinessException {
ReportService.super.processBatchAfterOperation(entities, operationEnum);
switch (operationEnum) {
case DELETE_BATCH:
entities.forEach(report -> {
Long id = report.getId();
Report delReport = selectOne(id);
if (null == delReport) {
return;
}
String reportCode = delReport.getReportCode();
String reportType = delReport.getReportType();
switch (ReportTypeEnum.valueOf(reportType)) {
case report_screen:
LambdaQueryWrapper<ReportDashboard> reportDashboardLambdaQueryWrapper = Wrappers.lambdaQuery();
reportDashboardLambdaQueryWrapper.eq(ReportDashboard::getReportCode, reportCode);
reportDashboardService.delete(reportDashboardLambdaQueryWrapper);
LambdaQueryWrapper<ReportDashboardWidget> reportDashboardWidgetLambdaQueryWrapper = Wrappers.lambdaQuery();
reportDashboardWidgetLambdaQueryWrapper.eq(ReportDashboardWidget::getReportCode, reportCode);
reportDashboardWidgetService.delete(reportDashboardWidgetLambdaQueryWrapper);
break;
case report_excel:
LambdaQueryWrapper<ReportExcel> reportExcelLambdaQueryWrapper = Wrappers.lambdaQuery();
reportExcelLambdaQueryWrapper.eq(ReportExcel::getReportCode, reportCode);
reportExcelService.delete(reportExcelLambdaQueryWrapper);
break;
default:
}
});
break;
default:
}
}
/**
@ -55,6 +106,64 @@ public class ReportServiceImpl implements ReportService {
}
@Override
public void copy(Long reportId) {
Report report = selectOne(reportId);
String reportCode = report.getReportCode();
Report copyReport = copyReport(report);
//复制主表数据
insert(copyReport);
String copyReportCode = copyReport.getReportCode();
String reportType = report.getReportType();
switch (ReportTypeEnum.valueOf(reportType)) {
case report_screen:
//查询看板
ReportDashboard reportDashboard = reportDashboardService.selectOne("report_code", reportCode);
if (null != reportDashboard) {
reportDashboard.setId(null);
reportDashboard.setReportCode(copyReportCode);
reportDashboardService.insert(reportDashboard);
}
//查询组件
List<ReportDashboardWidget> reportDashboardWidgetList = reportDashboardWidgetService.list("report_code", reportCode);
if (!CollectionUtils.isEmpty(reportDashboardWidgetList)) {
String finalCopyReportCode = copyReportCode;
reportDashboardWidgetList.forEach(reportDashboardWidget -> {
reportDashboardWidget.setId(null);
reportDashboardWidget.setReportCode(finalCopyReportCode);
});
reportDashboardWidgetService.insertBatch(reportDashboardWidgetList);
}
break;
case report_excel:
ReportExcel reportExcel = reportExcelService.selectOne("report_code", reportCode);
if (null != reportExcel) {
reportExcel.setId(null);
reportExcel.setReportCode(copyReportCode);
reportExcelService.insert(reportExcel);
}
break;
default:
}
}
private Report copyReport(Report report){
//复制主表数据
Report copyReport = new Report();
GaeaBeanUtils.copyAndFormatter(report, copyReport);
copyReport.setId(null);
String copyReportCode = copyReport.getReportCode().concat("_").concat(String.valueOf(System.currentTimeMillis()));
if (copyReportCode.length() >= 100) {
copyReportCode = copyReportCode.substring(0, 100);
}
copyReport.setReportCode(copyReportCode);
copyReport.setReportName(copyReport.getReportName().concat("_copy"));
return copyReport;
}
@Override
public void processBeforeOperation(Report entity, BaseOperationEnum operationEnum) throws BusinessException {

@ -39,4 +39,12 @@ export function reportDetail(data) {
})
}
export function reportCopy(data) {
return request({
url: '/report/copy',
method: 'get',
params: { reportId: data.id }
})
}
export default { reportList, reportAdd, reportDeleteBatch, reportUpdate, reportDetail }

@ -24,10 +24,12 @@ import {
reportAdd,
reportDeleteBatch,
reportUpdate,
reportDetail
reportDetail,
reportCopy
} from "@/api/reportmanage";
import Share from "./components/share";
import { validateEngOrNum } from "@/utils/validate";
import {verificationSet} from "@/api/report";
export default {
name: "Report",
components: {
@ -118,6 +120,11 @@ export default {
permission: "bigScreenManage:share",
click: this.shareReport
},
{
label: "复制",
permission: "bigScreenManage:copy",
click: this.copyReport
},
{
label: "删除",
permission: "reportManage:delete",
@ -339,6 +346,15 @@ export default {
this.reportCodeForShareDialog = val.reportCode;
this.reportNameForShareDialog = val.reportName;
this.visibleForShareDialog = true;
},
//
async copyReport(val) {
const { code } = await reportCopy(val);
if (code != '200') {
return
}
this.$message.success("复制成功");
this.$refs.listPage.handleQueryForm("query");
}
}
};

Loading…
Cancel
Save