mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、报表接口入参检查完善;2、executor-api、report-api相互依赖移除;
This commit is contained in:
-26
@@ -1,26 +0,0 @@
|
||||
package com.cf.imes.module.report.api.template;
|
||||
|
||||
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
||||
import com.cf.imes.module.report.enums.ApiConstants;
|
||||
import feign.Response;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* 报表模板feign service
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/7/19 11:31
|
||||
*/
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 报表模板")
|
||||
public interface ReportTemplateApi {
|
||||
String PREFIX = ApiConstants.PREFIX + "/template";
|
||||
|
||||
@PostMapping(value = PREFIX + "/export")
|
||||
@Operation(summary = "下载模板excel")
|
||||
Response excel(@RequestBody ReportTemplateGenerateReqDTO reqDTO);
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.cf.imes.module.report.api.template.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/19 15:03
|
||||
*/
|
||||
@Schema(description = "RPC 服务 - 报表模板生成 Request DTO")
|
||||
@Data
|
||||
public class ReportTemplateGenerateReqDTO {
|
||||
@Schema(description = "模板id")
|
||||
@NotNull(message = "模板id不能为空")
|
||||
private Long templateId;
|
||||
|
||||
@Schema(description = "参数集合")
|
||||
private Map<String, Object> params;
|
||||
|
||||
@Schema(description = "生成文件类型,pdf/word/excel")
|
||||
@NotNull(message = "生成文件类型不能为空")
|
||||
private String producerType;
|
||||
}
|
||||
@@ -134,12 +134,6 @@
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>${commons-text.version}</version>
|
||||
</dependency>
|
||||
<!-- executor feign 远程调用-->
|
||||
<dependency>
|
||||
<groupId>com.cf.imes</groupId>
|
||||
<artifactId>cf-module-prod-executor-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!--ureport-core 相关start-->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
@@ -185,10 +179,6 @@
|
||||
<groupId>com.cf.imes</groupId>
|
||||
<artifactId>cf-module-infra-api</artifactId>
|
||||
</include>
|
||||
<include>
|
||||
<groupId>com.cf.imes</groupId>
|
||||
<artifactId>cf-module-prod-executor-api</artifactId>
|
||||
</include>
|
||||
<include>
|
||||
<groupId>com.cf.imes</groupId>
|
||||
<artifactId>cf-module-report-api</artifactId>
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class ReportDatasetController {
|
||||
}
|
||||
|
||||
@GetMapping("/dataset/{id}")
|
||||
@Operation(summary = "获得报表数据集")
|
||||
@Operation(summary = "获取报表数据集")
|
||||
@Parameter(name = "id", description = "数据集id", required = true, example = "1")
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public CommonResult<ReportDatasetRespVO> getDataset(@PathVariable("id") Long id) {
|
||||
|
||||
+2
@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -22,5 +23,6 @@ public class ReportDatasetFieldVO implements Serializable {
|
||||
* 字段名称
|
||||
*/
|
||||
@Schema(description = "字段名称")
|
||||
@NotBlank(message = "字段名称不能为空")
|
||||
private String name;
|
||||
}
|
||||
|
||||
+3
@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -22,12 +23,14 @@ public class ReportDatasetParameterVO implements Serializable {
|
||||
* 参数名称
|
||||
*/
|
||||
@Schema(description = "参数名称")
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "参数类型")
|
||||
@NotBlank(message = "参数类型不能为空")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
|
||||
+6
@@ -7,8 +7,10 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -47,8 +49,12 @@ public class ReportDatasetSaveReqVO implements Serializable {
|
||||
private String method;
|
||||
|
||||
@Schema(description = "参数列表")
|
||||
@Size(max = 30, message = "参数列表数量不能超过30个")
|
||||
@Valid
|
||||
private List<ReportDatasetParameterVO> parameters = new ArrayList<>();
|
||||
|
||||
@Schema(description = "字段列表")
|
||||
@Size(max = 30, message = "字段列表数量不能超过30个")
|
||||
@Valid
|
||||
private List<ReportDatasetFieldVO> fields = new ArrayList<>();
|
||||
}
|
||||
|
||||
+13
-10
@@ -8,8 +8,10 @@ import com.bstek.ureport.definition.dataset.Field;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportBeanDatasourceRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourcePreviewReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceSaveReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.datasource.vo.ReportDatasourceTestConnReqVO;
|
||||
import com.cf.imes.module.report.dal.dataobject.datasource.ReportDatasourceDO;
|
||||
import com.cf.imes.module.report.service.datasource.ReportDatasourceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -99,7 +102,7 @@ public class ReportDatasourceController {
|
||||
@Operation(summary = "获取springbean数据源返回对象")
|
||||
@Parameter(name = "clazz", description = "返回对象类路径全名不能为空", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public List<Field> springbeanFieldList(@RequestParam(value = "clazz") @NotEmpty(message = "类路径全名不能为空") String clazz) {
|
||||
public List<Field> springbeanFieldList(@RequestParam(value = "clazz") @NotEmpty(message = "类路径全名不能为空") @Size(max = 100, message = "类路径全名不能超过100个字符") String clazz) {
|
||||
return datasourceService.getSpringBeanResultFieldList(clazz);
|
||||
}
|
||||
|
||||
@@ -107,7 +110,7 @@ public class ReportDatasourceController {
|
||||
@Operation(summary = "获取springbean数据源方法类表")
|
||||
@Parameter(name = "beanId", description = "springbeanId", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public CommonResult<List<String>> getBeanDatasourceList(@RequestParam(value = "beanId") @NotEmpty(message = "beanId不能为空") String beanId) {
|
||||
public CommonResult<List<String>> getBeanDatasourceList(@RequestParam(value = "beanId") @NotEmpty(message = "beanId不能为空") @Size(max = 100, message = "beanId不能超过100个字符") String beanId) {
|
||||
return success(datasourceService.loadBeanMethods(beanId));
|
||||
}
|
||||
|
||||
@@ -115,29 +118,29 @@ public class ReportDatasourceController {
|
||||
@PostMapping("/datasource/connect")
|
||||
@Operation(summary = "测试数据源连接")
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public CommonResult<Boolean> testDatasourceConnect(@RequestBody DataSourceInfo info) {
|
||||
String success = MultipleJdbcTemplate.testConnection(info);
|
||||
public CommonResult<Boolean> testDatasourceConnect(@RequestBody @Valid ReportDatasourceTestConnReqVO reqVO) {
|
||||
String success = MultipleJdbcTemplate.testConnection(BeanUtils.toBean(reqVO, DataSourceInfo.class));
|
||||
return Objects.equals("success", success) ? success(true) : error(DATASOURCE_CONNECT_FAIL);
|
||||
}
|
||||
|
||||
@PostMapping("/datasource/tables")
|
||||
@Operation(summary = "获取数据库表列表")
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public CommonResult<List<Map<String, String>>> getDatasourceTables(@RequestBody DataSourceInfo info) {
|
||||
return success(ureportDataSourceService.selectTableList(info));
|
||||
public CommonResult<List<Map<String, String>>> getDatasourceTables(@RequestBody @Valid ReportDatasourceTestConnReqVO reqVO) {
|
||||
return success(ureportDataSourceService.selectTableList(BeanUtils.toBean(reqVO, DataSourceInfo.class)));
|
||||
}
|
||||
|
||||
@PostMapping("/datasource/table/fields")
|
||||
@Operation(summary = "获取数据源表字段")
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public CommonResult<List<Field>> getDatasourceTableFields(@RequestBody PreviewParams previewParams) {
|
||||
return success(datasourceService.getTableFields(previewParams));
|
||||
public CommonResult<List<Field>> getDatasourceTableFields(@RequestBody @Valid ReportDatasourcePreviewReqVO reqVO) {
|
||||
return success(datasourceService.getTableFields(BeanUtils.toBean(reqVO, PreviewParams.class)));
|
||||
}
|
||||
|
||||
@PostMapping("/datasource/preview")
|
||||
@Operation(summary = "数据源预览")
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public CommonResult<Map<String, Object>> previewData(@RequestBody PreviewParams previewParams) {
|
||||
return success(ureportDataSourceService.previewData(previewParams));
|
||||
public CommonResult<Map<String, Object>> previewData(@RequestBody @Valid ReportDatasourcePreviewReqVO reqVO) {
|
||||
return success(ureportDataSourceService.previewData(BeanUtils.toBean(reqVO, PreviewParams.class)));
|
||||
}
|
||||
}
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.cf.imes.module.report.controller.admin.datasource.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/8 11:36
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "管理后台 - 报表数据源查询参数 Request VO")
|
||||
public class ReportDatasourceParameterVO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 2752387952196201725L;
|
||||
/**
|
||||
* 参数名称
|
||||
*/
|
||||
@Schema(description = "参数名称")
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "参数类型")
|
||||
@NotBlank(message = "参数类型不能为空")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
@Schema(description = "参数默认值")
|
||||
private String defaultValue;
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.cf.imes.module.report.controller.admin.datasource.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/10/16 16:39
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表数据源预览 Request VO")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ReportDatasourcePreviewReqVO {
|
||||
@Schema(description = "数据源连接信息")
|
||||
@NotNull
|
||||
@Valid
|
||||
private ReportDatasourceTestConnReqVO info;
|
||||
|
||||
@Schema(description = "查询语句")
|
||||
@NotBlank(message = "查询语句不能为空")
|
||||
private String sql;
|
||||
|
||||
@Schema(description = "查询参数列表")
|
||||
@Size(max = 30, message = "查询参数列表数量不能超过30个")
|
||||
@Valid
|
||||
private List<ReportDatasourceParameterVO> parameters;
|
||||
}
|
||||
+3
@@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -65,8 +66,10 @@ public class ReportDatasourceSaveReqVO implements Serializable {
|
||||
private String password;
|
||||
|
||||
@Schema(description = "备注", example = "该模板仅供生产使用")
|
||||
@Length(max = 64, message = "备注长度不能超过64个字符")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "请求头参数")
|
||||
@Size(max = 30, message = "请求头参数数量不能超过30个")
|
||||
private List<Map<String, String>> headers;
|
||||
}
|
||||
|
||||
+7
-14
@@ -1,14 +1,12 @@
|
||||
package com.cf.imes.module.report.controller.admin.datasource.vo;
|
||||
|
||||
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetParameterVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
@@ -21,24 +19,19 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class ReportDatasourceTestConnReqVO {
|
||||
|
||||
@Schema(description = "数据源驱动类",example = "com.mysql.cj.jdbc.Driver")
|
||||
private String driver;
|
||||
@Schema(description = "数据源驱动类", example = "com.mysql.cj.jdbc.Driver")
|
||||
@NotBlank(message = "数据源驱动类不能为空")
|
||||
private String driverClassName;
|
||||
|
||||
@Schema(description = "数据源地址", example = "https://www.cf.com")
|
||||
@NotBlank(message = "数据源地址不能为空")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "数据源用户名", example = "晨丰")
|
||||
@NotBlank(message = "数据源用户名不能为空")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "数据源密码", example = "晨丰")
|
||||
@NotBlank(message = "数据源密码不能为空")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "数据源id", example = "1")
|
||||
private Long datasourceId;
|
||||
|
||||
@Schema(description = "数据库语句")
|
||||
private String sql;
|
||||
|
||||
@Schema(description = "参数列表")
|
||||
private List<ReportDatasetParameterVO> parameters = new ArrayList<>();
|
||||
}
|
||||
|
||||
+8
-33
@@ -1,23 +1,18 @@
|
||||
package com.cf.imes.module.report.controller.admin.template;
|
||||
|
||||
import com.bstek.designer.bean.PreviewParameters;
|
||||
import com.bstek.designer.bean.ReportDefinitionWrapper;
|
||||
import com.bstek.designer.excel.ExcelParserUtils;
|
||||
import com.bstek.ureport.definition.ReportDefinition;
|
||||
import com.bstek.ureport.dsl.ReportParserLexer;
|
||||
import com.bstek.ureport.dsl.ReportParserParser;
|
||||
import com.bstek.ureport.exception.ReportException;
|
||||
import com.bstek.ureport.export.ExportUtils;
|
||||
import com.bstek.ureport.export.ProducerEnum;
|
||||
import com.bstek.ureport.export.html.HtmlReport;
|
||||
import com.bstek.ureport.expression.ErrorInfo;
|
||||
import com.bstek.ureport.expression.ScriptErrorListener;
|
||||
import com.bstek.ureport.model.Report;
|
||||
import com.bstek.ureport.utils.StringUtils;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplatePreviewReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||
@@ -30,7 +25,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -41,10 +35,10 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -115,41 +109,22 @@ public class ReportTemplateController {
|
||||
@PostMapping("/template/preview")
|
||||
@Operation(summary = "模板预览")
|
||||
@PreAuthorize("@ss.hasPermission('report:preview')")
|
||||
public CommonResult<HtmlReport> preview(@RequestBody PreviewParameters params) {
|
||||
return success(templateService.preview(params));
|
||||
public CommonResult<HtmlReport> preview(@RequestBody ReportTemplatePreviewReqVO reqVO) {
|
||||
return success(templateService.preview(reqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/template/print")
|
||||
@Operation(summary = "模板预览打印")
|
||||
@PreAuthorize("@ss.hasPermission('report:preview')")
|
||||
public void print(@RequestBody PreviewParameters reportParameters, HttpServletResponse response) {
|
||||
templateService.print(reportParameters, response);
|
||||
public void print(@RequestBody ReportTemplatePreviewReqVO reqVO, HttpServletResponse response) {
|
||||
templateService.print(reqVO, response);
|
||||
}
|
||||
|
||||
@PostMapping("/template/download/{type}")
|
||||
@Operation(summary = "模板预览下载")
|
||||
@PreAuthorize("@ss.hasPermission('report:preview')")
|
||||
public void print(@PathVariable @Valid @ReportTemplateProducerTypeInEnum String type, @RequestBody PreviewParameters reportParameters, HttpServletResponse response) {
|
||||
templateService.download(type, reportParameters, response);
|
||||
}
|
||||
|
||||
@PostMapping("/template/export")
|
||||
@Operation(summary = "模板导出")
|
||||
@PreAuthorize("@ss.hasPermission('report:design')")
|
||||
public void generateTemplate(@Valid @RequestBody ReportTemplateGenerateReqDTO reqDTO, HttpServletResponse response) {
|
||||
OutputStream out = null;
|
||||
try {
|
||||
Report report = templateService.generateReport(reqDTO);
|
||||
out = response.getOutputStream();
|
||||
ProducerEnum p = ProducerEnum.valueOf(reqDTO.getProducerType().toUpperCase());
|
||||
ExportUtils.export(out, report, p);
|
||||
} catch (ReportException rex) {
|
||||
throw rex;
|
||||
} catch (Exception ex) {
|
||||
log.error("[generateExcel] 报表模板生成excel异常", ex);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(out);
|
||||
}
|
||||
public void print(@PathVariable @ReportTemplateProducerTypeInEnum @NotBlank(message = "模板下载类型不能为空") String type, @RequestBody ReportTemplatePreviewReqVO reqVO, HttpServletResponse response) {
|
||||
templateService.download(type, reqVO, response);
|
||||
}
|
||||
|
||||
@PostMapping("/template/excel/import")
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/19 9:22
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "管理后台 - 报表模板预览分页参数 Request VO")
|
||||
public class ReportTemplatePreviewPageParametersVO {
|
||||
@Schema(description = "页码",example = "1")
|
||||
private int pageIndex;
|
||||
|
||||
@Schema(description = "预览参数")
|
||||
private ReportTemplatePreviewParametersVO params;
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/19 9:22
|
||||
*/
|
||||
@Schema(description = "管理后台 - 报表模板预览参数 Request VO")
|
||||
@Data
|
||||
public class ReportTemplatePreviewParametersVO {
|
||||
/**
|
||||
* 报表内容
|
||||
*/
|
||||
@Schema(description = "报表内容")
|
||||
@NotNull(message = "预览报表内容不能为空")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 报表名称
|
||||
*/
|
||||
@Schema(description = "报表名称")
|
||||
private String reportName;
|
||||
|
||||
/**
|
||||
* 表单参数
|
||||
*/
|
||||
@Schema(description = "表单参数")
|
||||
private Map<String, Object> query = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 表单对应组件唯一标识
|
||||
*/
|
||||
@Schema(description = "表单对应组件唯一标识")
|
||||
private Map<String, String> component = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 图表图片目前用于PDF导出
|
||||
*/
|
||||
@Schema(description = "图表图片目前用于PDF导出")
|
||||
private Map<String, String> chartImages = new HashMap<>();
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.cf.imes.module.report.controller.admin.template.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/19 9:22
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "管理后台 - 报表模板预览请求参数 Request VO")
|
||||
public class ReportTemplatePreviewReqVO {
|
||||
@Schema(description = "页码",example = "1")
|
||||
@Min(value = 1, message = "页码最小值为 1")
|
||||
private int pageIndex;
|
||||
|
||||
@Schema(description = "报表内容")
|
||||
@NotNull(message = "预览报表内容不能为空")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 表单参数
|
||||
*/
|
||||
@Schema(description = "表单参数")
|
||||
@Size(max = 30, message = "表单参数数量不能超过30个")
|
||||
private Map<String, Object> query;
|
||||
|
||||
/**
|
||||
* 表单对应组件唯一标识
|
||||
*/
|
||||
@Schema(description = "表单对应组件唯一标识")
|
||||
@Size(max = 30, message = "表单对应组件唯一标识数量不能超过30个")
|
||||
private Map<String, String> component;
|
||||
|
||||
/**
|
||||
* 图表图片目前用于PDF导出
|
||||
*/
|
||||
@Schema(description = "图表图片")
|
||||
@Size(max = 30, message = "图表图片数量不能超过30个")
|
||||
private Map<String, String> chartImages;
|
||||
|
||||
}
|
||||
+2
-2
@@ -38,10 +38,10 @@ public class ReportTemplateSaveReqVO {
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "数据源id列表")
|
||||
@Size(max = 20, message = "数据源数量不能超过20个")
|
||||
@Size(max = 30, message = "数据源数量不能超过30个")
|
||||
private Set<Long> datasourceIds;
|
||||
|
||||
@Schema(description = "数据集id列表")
|
||||
@Size(max = 20, message = "数据集数量不能超过20个")
|
||||
@Size(max = 30, message = "数据集数量不能超过30个")
|
||||
private Set<Long> datasetIds;
|
||||
}
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package com.cf.imes.module.report.framework.rpc.config;
|
||||
|
||||
import com.cf.imes.module.executor.api.datasource.OrderDatasourceApi;
|
||||
import com.cf.imes.module.executor.api.datasource.OrderPartDatasourceApi;
|
||||
import com.cf.imes.module.executor.api.datasource.OrderPlateDatasourceApi;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {OrderPlateDatasourceApi.class, OrderDatasourceApi.class, OrderPartDatasourceApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
-278
@@ -1,278 +0,0 @@
|
||||
package com.cf.imes.module.report.framework.ureport.bean;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.executor.api.datasource.OrderDatasourceApi;
|
||||
import com.cf.imes.module.executor.api.datasource.OrderPartDatasourceApi;
|
||||
import com.cf.imes.module.executor.api.datasource.OrderPlateDatasourceApi;
|
||||
import com.cf.imes.module.executor.api.datasource.dto.OrderDTO;
|
||||
import com.cf.imes.module.executor.api.datasource.dto.PartGoodsRespDTO;
|
||||
import com.cf.imes.module.executor.api.datasource.dto.PlateGoodsRespDTO;
|
||||
import com.cf.imes.module.executor.enums.OrderPlateOpenDoorTypeEnum;
|
||||
import com.cf.imes.module.report.framework.ureport.annotation.CfReportSpringbeanDatasource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/7/19 14:41
|
||||
*/
|
||||
@CfReportSpringbeanDatasource(value = "OrderSummaryBeanDatasource", name = "生产单导出统计数据源")
|
||||
@Slf4j
|
||||
public class OrderSummaryBeanDatasource {
|
||||
|
||||
@Resource
|
||||
private OrderPlateDatasourceApi orderPlateDatasourceApi;
|
||||
|
||||
@Resource
|
||||
private OrderDatasourceApi orderDatasourceApi;
|
||||
|
||||
@Resource
|
||||
private OrderPartDatasourceApi orderPartDatasourceApi;
|
||||
|
||||
// 常用的字段key
|
||||
private static final String ORDER_ID_FIELD_NAME = "orderId";
|
||||
private static final String BODY_NAME_FIELD_NAME = "bodyName";
|
||||
private static final String ROOM_NAME_FIELD_NAME = "roomName";
|
||||
private static final String REMARK_FIELD_NAME = "remark";
|
||||
|
||||
/**
|
||||
* 生产单信息
|
||||
*
|
||||
* @param dsName
|
||||
* @param datasetName
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> orderInfo(String dsName, String datasetName, Map<String, Object> parameters) {
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderInfo][{}][{}]调用开始", dsName, datasetName);
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
|
||||
Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
|
||||
if (ObjectUtil.isNull(orderId)) {
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
CommonResult<OrderDTO> commonResult = orderDatasourceApi.getOrderInfo(Long.parseLong(orderId.toString()));
|
||||
OrderDTO orderDTO = commonResult.getData();
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
if (orderDTO != null) {
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
// 构造报表所需结构
|
||||
resultMap.put(ORDER_ID_FIELD_NAME, orderDTO.getId());
|
||||
resultMap.put("customOrderNo", orderDTO.getCustomOrderNo());
|
||||
resultMap.put("dealer", orderDTO.getDealer());
|
||||
LocalDateTime orderDate = orderDTO.getOrderDate();
|
||||
resultMap.put("orderDate", ObjectUtil.isNotNull(orderDate) ? formatter.format(orderDate) : null);
|
||||
LocalDateTime deliveryDate = orderDTO.getDeliveryDate();
|
||||
resultMap.put("deliveryDate", ObjectUtil.isNotNull(deliveryDate) ? formatter.format(deliveryDate) : null);
|
||||
resultMap.put("customer", orderDTO.getCustomer());
|
||||
resultMap.put("phoneNumber", orderDTO.getPhoneNumber());
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderInfo][{}][{}]调用结束", dsName, datasetName);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 板材汇总
|
||||
*
|
||||
* @param dsName
|
||||
* @param datasetName
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> orderPlateGoodsSummary(String dsName, String datasetName, Map<String, Object> parameters) {
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateGoodsSummary][{}][{}]调用开始", dsName, datasetName);
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
|
||||
Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
|
||||
// 查询统计信息
|
||||
CommonResult<List<PlateGoodsRespDTO>> commonResult = orderPlateDatasourceApi.selectPlateGoodsListSummary(Long.parseLong(orderId.toString()));
|
||||
List<PlateGoodsRespDTO> plateGoodsRespDTOS = commonResult.getData();
|
||||
|
||||
if (CollUtil.isNotEmpty(plateGoodsRespDTOS)) {
|
||||
plateGoodsRespDTOS.forEach(p -> {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
BigDecimal area = p.getArea();
|
||||
Integer count = p.getCount();
|
||||
// 构造报表所需结构
|
||||
resultMap.put(ROOM_NAME_FIELD_NAME, p.getRoomName());
|
||||
resultMap.put(BODY_NAME_FIELD_NAME, p.getBodyName());
|
||||
resultMap.put("thickness", stripTrailingZeros(p.getThickness()));
|
||||
resultMap.put("name", p.getName());
|
||||
resultMap.put("height", stripTrailingZeros(p.getHeight()));
|
||||
resultMap.put("width", stripTrailingZeros(p.getWidth()));
|
||||
resultMap.put("count", count);
|
||||
resultMap.put("area", stripTrailingZeros(area));
|
||||
resultMap.put("openDoorType", OrderPlateOpenDoorTypeEnum.getDescFromCode(p.getOpenDoorType()));
|
||||
resultMap.put("material", p.getMaterial());
|
||||
resultMap.put("color", p.getColor());
|
||||
resultMap.put(REMARK_FIELD_NAME, p.getRemark());
|
||||
resultMap.put("areaAll", stripTrailingZeros(area.multiply(BigDecimal.valueOf(count))));
|
||||
resultList.add(resultMap);
|
||||
});
|
||||
}
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateGoodsSummary][{}][{}]调用结束", dsName, datasetName);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 板材明细
|
||||
*
|
||||
* @param dsName
|
||||
* @param datasetName
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> orderPlateGoodsList(String dsName, String datasetName, Map<String, Object> parameters) {
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateGoodsList][{}][{}]调用开始", dsName, datasetName);
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
|
||||
Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
|
||||
// 查询统计信息
|
||||
CommonResult<List<PlateGoodsRespDTO>> commonResult = orderPlateDatasourceApi.selectPlateGoodsList(Long.parseLong(orderId.toString()));
|
||||
List<PlateGoodsRespDTO> plateGoodsRespDTOS = commonResult.getData();
|
||||
|
||||
if (CollUtil.isNotEmpty(plateGoodsRespDTOS)) {
|
||||
plateGoodsRespDTOS.forEach(p -> {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
BigDecimal area = p.getArea();
|
||||
Integer count = p.getCount();
|
||||
// 构造报表所需结构
|
||||
resultMap.put("goodsName", p.getGoodsName());
|
||||
resultMap.put("name", p.getName());
|
||||
resultMap.put("material", p.getMaterial());
|
||||
resultMap.put("color", p.getColor());
|
||||
resultMap.put("goodsThickness", p.getGoodsThickness());
|
||||
resultMap.put("count", p.getCount());
|
||||
resultMap.put(ROOM_NAME_FIELD_NAME, p.getRoomName());
|
||||
resultMap.put(BODY_NAME_FIELD_NAME, p.getBodyName());
|
||||
resultMap.put("plateNo", p.getPlateNo());
|
||||
resultMap.put("height", stripTrailingZeros(p.getHeight()));
|
||||
resultMap.put("width", stripTrailingZeros(p.getWidth()));
|
||||
resultMap.put("thickness", stripTrailingZeros(p.getThickness()));
|
||||
resultMap.put("area", stripTrailingZeros(area));
|
||||
resultMap.put(REMARK_FIELD_NAME, p.getRemark());
|
||||
resultMap.put("isSpecialShaped", getBooleanString(p.getIsSpecialShaped()));
|
||||
resultMap.put("isSculpt", getBooleanString(p.getIsSculpt()));
|
||||
resultMap.put("openDoorType", OrderPlateOpenDoorTypeEnum.getDescFromCode(p.getOpenDoorType()));
|
||||
resultMap.put("seal", String.join(",", stripTrailingZeros(p.getSealLeft()), stripTrailingZeros(p.getSealRight()), stripTrailingZeros(p.getSealUp()), stripTrailingZeros(p.getSealDown())));
|
||||
resultMap.put("areaAll", stripTrailingZeros(area.multiply(BigDecimal.valueOf(count))));
|
||||
resultList.add(resultMap);
|
||||
});
|
||||
}
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateGoodsList][{}][{}]调用结束", dsName, datasetName);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配件明细
|
||||
*
|
||||
* @param dsName
|
||||
* @param datasetName
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> orderPartDetailList(String dsName, String datasetName, Map<String, Object> parameters) {
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderPartDetailList][{}][{}]调用开始", dsName, datasetName);
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
|
||||
Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
|
||||
CommonResult<List<PartGoodsRespDTO>> commonResult = orderPartDatasourceApi.selectPartDetail(Long.parseLong(orderId.toString()));
|
||||
List<PartGoodsRespDTO> partGoodsRespDTOS = commonResult.getData();
|
||||
|
||||
if (CollUtil.isNotEmpty(partGoodsRespDTOS)) {
|
||||
partGoodsRespDTOS.forEach(p -> {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
// 构造报表所需结构
|
||||
resultMap.put(ROOM_NAME_FIELD_NAME, p.getRoomName());
|
||||
resultMap.put(BODY_NAME_FIELD_NAME, p.getBodyName());
|
||||
resultMap.put("name", p.getName());
|
||||
resultMap.put("brand", p.getBrand());
|
||||
resultMap.put("factory", p.getFactory());
|
||||
resultMap.put("model", p.getModel());
|
||||
resultMap.put("spec", p.getSpec());
|
||||
resultMap.put("num", p.getNum());
|
||||
resultMap.put("unit", p.getUnit());
|
||||
resultMap.put("price", p.getPrice());
|
||||
resultMap.put("totalPrice", p.getTotalPrice());
|
||||
resultMap.put(REMARK_FIELD_NAME, p.getRemark());
|
||||
resultList.add(resultMap);
|
||||
});
|
||||
}
|
||||
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderPartDetailList][{}][{}]调用结束", dsName, datasetName);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配件汇总
|
||||
*
|
||||
* @param dsName
|
||||
* @param datasetName
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> orderPartSummary(String dsName, String datasetName, Map<String, Object> parameters) {
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderPartSummary][{}][{}]调用开始", dsName, datasetName);
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
|
||||
Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
|
||||
CommonResult<List<PartGoodsRespDTO>> commonResult = orderPartDatasourceApi.selectPartAll(Long.parseLong(orderId.toString()));
|
||||
List<PartGoodsRespDTO> partGoodsRespDTOS = commonResult.getData();
|
||||
|
||||
if (CollUtil.isNotEmpty(partGoodsRespDTOS)) {
|
||||
partGoodsRespDTOS.forEach(p -> {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
// 构造报表所需结构
|
||||
resultMap.put("name", p.getName());
|
||||
resultMap.put("model", p.getModel());
|
||||
resultMap.put("spec", p.getSpec());
|
||||
resultMap.put("num", p.getNum());
|
||||
resultMap.put("unit", p.getUnit());
|
||||
resultMap.put("brand", p.getBrand());
|
||||
resultMap.put(REMARK_FIELD_NAME, p.getRemark());
|
||||
resultList.add(resultMap);
|
||||
});
|
||||
}
|
||||
|
||||
log.info("报表数据源[OrderSummaryBeanDatasource][orderPartSummary][{}][{}]调用结束", dsName, datasetName);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除尾数的0,600.000 -> 600
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private String stripTrailingZeros(BigDecimal data) {
|
||||
if (ObjectUtil.isNotNull(data)) {
|
||||
return data.stripTrailingZeros().toPlainString();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 布尔值转是否
|
||||
*
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
private String getBooleanString(Boolean b) {
|
||||
return b ? "是" : "否";
|
||||
}
|
||||
}
|
||||
+4
-15
@@ -1,10 +1,8 @@
|
||||
package com.cf.imes.module.report.service.template;
|
||||
|
||||
import com.bstek.designer.bean.PreviewParameters;
|
||||
import com.bstek.designer.bean.ReportDefinitionWrapper;
|
||||
import com.bstek.ureport.export.html.HtmlReport;
|
||||
import com.bstek.ureport.model.Report;
|
||||
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplatePreviewReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||
@@ -80,21 +78,12 @@ public interface ReportTemplateService {
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
HtmlReport preview(PreviewParameters params);
|
||||
|
||||
|
||||
/**
|
||||
* 构造生成报表report对象
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Report generateReport(ReportTemplateGenerateReqDTO dto);
|
||||
HtmlReport preview(ReportTemplatePreviewReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 模版预览打印
|
||||
*/
|
||||
void print(PreviewParameters params, HttpServletResponse response);
|
||||
void print(ReportTemplatePreviewReqVO reqVO, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 模版预览下载
|
||||
@@ -103,5 +92,5 @@ public interface ReportTemplateService {
|
||||
* @param params
|
||||
* @param response
|
||||
*/
|
||||
void download(String type, PreviewParameters params, HttpServletResponse response);
|
||||
void download(String type, ReportTemplatePreviewReqVO reqVO, HttpServletResponse response);
|
||||
}
|
||||
|
||||
+12
-25
@@ -34,8 +34,8 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
||||
import com.cf.imes.module.report.config.CfReportProperties;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplatePreviewReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||
@@ -353,7 +353,9 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HtmlReport preview(PreviewParameters params) {
|
||||
public HtmlReport preview(ReportTemplatePreviewReqVO reqVO) {
|
||||
// 自定义请求vo转ureport对象
|
||||
PreviewParameters params = BeanUtils.toBean(reqVO, PreviewParameters.class);
|
||||
Long userOrganId = SecurityFrameworkUtils.getUserOrganId();
|
||||
|
||||
HtmlProducer htmlProducer = new HtmlProducer();
|
||||
@@ -391,7 +393,10 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(PreviewParameters params, HttpServletResponse response) {
|
||||
public void print(ReportTemplatePreviewReqVO reqVO, HttpServletResponse response) {
|
||||
// 自定义请求vo转ureport对象
|
||||
PreviewParameters params = BeanUtils.toBean(reqVO, PreviewParameters.class);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
ReportRender reportRender = new ReportRender();
|
||||
ReportDefinition reportDefinition = getReportDefinition(reportRender, params);
|
||||
@@ -416,7 +421,10 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(String type, PreviewParameters params, HttpServletResponse response) {
|
||||
public void download(String type, ReportTemplatePreviewReqVO reqVO, HttpServletResponse response) {
|
||||
// 自定义请求vo转ureport对象
|
||||
PreviewParameters params = BeanUtils.toBean(reqVO, PreviewParameters.class);
|
||||
|
||||
ReportRender reportRender = new ReportRender();
|
||||
ReportDefinition reportDefinition = getReportDefinition(reportRender, params);
|
||||
Report report = reportRender.render(reportDefinition, params.getQuery());
|
||||
@@ -469,27 +477,6 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
return reportDefinition;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Report generateReport(ReportTemplateGenerateReqDTO reqDTO) {
|
||||
// 校验生成文件类型
|
||||
validateProducerType(reqDTO.getProducerType());
|
||||
Long templateId = reqDTO.getTemplateId();
|
||||
// 校验模板
|
||||
ReportTemplateDO template = validateTemplateExists(templateId);
|
||||
String xmlContent = template.getContent();
|
||||
ReportRender reportRender = new ReportRender();
|
||||
// 解析xml
|
||||
ReportDefinition reportDefinition = reportRender.getReportDefinition(xmlContent, CharsetUtil.UTF_8);
|
||||
// 查询数据源
|
||||
queryDatasource(template, reportDefinition);
|
||||
// 设置参数
|
||||
PreviewParameters previewParameters = new PreviewParameters();
|
||||
previewParameters.setQuery(reqDTO.getParams());
|
||||
|
||||
return reportRender.render(reportDefinition, previewParameters.getQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板生成文件类型校验
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user