需求-----大屏复制

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 com.anjiplus.template.gaea.business.modules.report.service.ReportService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* TODO * TODO
@ -46,11 +43,11 @@ public class ReportController extends GaeaBaseController<ReportParam, Report, Re
return new ReportDto(); return new ReportDto();
} }
@DeleteMapping("/delReport") @GetMapping("/copy")
@Permission(code = "delete", name = "删除") @Permission(code = "copy", name = "复制")
@GaeaAuditLog(pageTitle = "删除") @GaeaAuditLog(pageTitle = "复制")
public ResponseBean delReport(@RequestBody ReportDto reportDto) { public ResponseBean copy(@RequestParam("reportId") Long reportId) {
reportService.delReport(reportDto); reportService.copy(reportId);
return ResponseBean.builder().build(); 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> { public interface ReportService extends GaeaBaseService<ReportParam, Report> {
void delReport(ReportDto reportDto);
/** /**
* +1 * +1
* @param reportCode * @param reportCode
*/ */
void downloadStatistics(String 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.constant.BaseOperationEnum;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anji.plus.gaea.exception.BusinessException; 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.controller.dto.ReportDto;
import com.anjiplus.template.gaea.business.modules.report.dao.ReportMapper; 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.dao.entity.Report;
import com.anjiplus.template.gaea.business.modules.report.service.ReportService; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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 @Autowired
private ReportMapper reportMapper; private ReportMapper reportMapper;
@Autowired
private ReportDashboardService reportDashboardService;
@Autowired
private ReportDashboardWidgetService reportDashboardWidgetService;
@Autowired
private ReportExcelService reportExcelService;
@Override @Override
public GaeaBaseMapper<Report> getMapper() { public GaeaBaseMapper<Report> getMapper() {
@ -28,10 +48,41 @@ public class ReportServiceImpl implements ReportService {
@Override @Override
public void delReport(ReportDto reportDto) { public void processBatchBeforeOperation(List<Report> entities, BaseOperationEnum operationEnum) throws BusinessException {
deleteById(reportDto.getId()); ReportService.super.processBatchAfterOperation(entities, operationEnum);
//删除gaea_report_excel、gaea_report_dashboard、gaea_report_dashboard_widget 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 @Override
public void processBeforeOperation(Report entity, BaseOperationEnum operationEnum) throws BusinessException { 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 } export default { reportList, reportAdd, reportDeleteBatch, reportUpdate, reportDetail }

@ -24,10 +24,12 @@ import {
reportAdd, reportAdd,
reportDeleteBatch, reportDeleteBatch,
reportUpdate, reportUpdate,
reportDetail reportDetail,
reportCopy
} from "@/api/reportmanage"; } from "@/api/reportmanage";
import Share from "./components/share"; import Share from "./components/share";
import { validateEngOrNum } from "@/utils/validate"; import { validateEngOrNum } from "@/utils/validate";
import {verificationSet} from "@/api/report";
export default { export default {
name: "Report", name: "Report",
components: { components: {
@ -118,6 +120,11 @@ export default {
permission: "bigScreenManage:share", permission: "bigScreenManage:share",
click: this.shareReport click: this.shareReport
}, },
{
label: "复制",
permission: "bigScreenManage:copy",
click: this.copyReport
},
{ {
label: "删除", label: "删除",
permission: "reportManage:delete", permission: "reportManage:delete",
@ -339,6 +346,15 @@ export default {
this.reportCodeForShareDialog = val.reportCode; this.reportCodeForShareDialog = val.reportCode;
this.reportNameForShareDialog = val.reportName; this.reportNameForShareDialog = val.reportName;
this.visibleForShareDialog = true; 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