Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -82,6 +82,16 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.seata</groupId>
|
||||||
|
<artifactId>seata-spring-boot-starter</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode TEMPLATE_INSTANCE_NOT_EXISTS = new ErrorCode(1_006_004_001, "模板实例不存在");
|
ErrorCode TEMPLATE_INSTANCE_NOT_EXISTS = new ErrorCode(1_006_004_001, "模板实例不存在");
|
||||||
ErrorCode TEMPLATE_INSTANCE_CODE_DUPLICATE = new ErrorCode(1_006_004_002, "实例编码已存在");
|
ErrorCode TEMPLATE_INSTANCE_CODE_DUPLICATE = new ErrorCode(1_006_004_002, "实例编码已存在");
|
||||||
|
|
||||||
|
// 模板导出 1-006-005-xxx
|
||||||
|
ErrorCode TEMPLATE_EXPORT_TYPE_ERROR = new ErrorCode(1_006_005_001, "不支持的导出类型");
|
||||||
|
ErrorCode TEMPLATE_EXPORT_FAILED = new ErrorCode(1_006_005_002, "模板导出失败");
|
||||||
|
|
||||||
// ========== 物料属性 ==========
|
// ========== 物料属性 ==========
|
||||||
ErrorCode MATERIAL_PROPERTIES_NOT_EXISTS = new ErrorCode(1_027_101_001, "物料属性不存在");
|
ErrorCode MATERIAL_PROPERTIES_NOT_EXISTS = new ErrorCode(1_027_101_001, "物料属性不存在");
|
||||||
ErrorCode MATERIAL_HAS_PROPERTIES_NOT_EXISTS = new ErrorCode(1_027_101_002, "物料持有属性不存在");
|
ErrorCode MATERIAL_HAS_PROPERTIES_NOT_EXISTS = new ErrorCode(1_027_101_002, "物料持有属性不存在");
|
||||||
|
|||||||
@@ -126,7 +126,20 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity-engine-core</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
<version>2.3</version>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- docx4j - Word文档处理 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.docx4j</groupId>
|
||||||
|
<artifactId>docx4j-core</artifactId>
|
||||||
|
<version>11.4.11</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- docx4j JAXB 运行时支持 (Java 17 兼容) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.docx4j</groupId>
|
||||||
|
<artifactId>docx4j-JAXB-ReferenceImpl</artifactId>
|
||||||
|
<version>11.4.11</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 监控相关 -->
|
<!-- 监控相关 -->
|
||||||
|
|||||||
@@ -35,4 +35,6 @@ public class ElementPageReqVO extends PageParam {
|
|||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime[] createTime;
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer sort;
|
||||||
}
|
}
|
||||||
@@ -44,4 +44,6 @@ public class ElementRespVO {
|
|||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer sort;
|
||||||
}
|
}
|
||||||
@@ -34,4 +34,7 @@ public class ElementSaveReqVO {
|
|||||||
@NotEmpty(message = "品位单位不能为空")
|
@NotEmpty(message = "品位单位不能为空")
|
||||||
private String gradeUnit;
|
private String gradeUnit;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,15 +7,19 @@ import com.zt.plat.module.base.controller.admin.doctemplate.vo.DocTemplateInstan
|
|||||||
import com.zt.plat.module.base.controller.admin.doctemplate.vo.DocTemplateInstanceSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.doctemplate.vo.DocTemplateInstanceSaveReqVO;
|
||||||
import com.zt.plat.module.base.service.doctemplate.DocTemplateInstanceService;
|
import com.zt.plat.module.base.service.doctemplate.DocTemplateInstanceService;
|
||||||
import com.zt.plat.module.base.service.doctemplate.DocTemplateRenderService;
|
import com.zt.plat.module.base.service.doctemplate.DocTemplateRenderService;
|
||||||
|
import com.zt.plat.module.base.service.doctemplate.DocumentRenderApiService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -38,6 +42,9 @@ public class DocTemplateInstanceController {
|
|||||||
@Resource
|
@Resource
|
||||||
private DocTemplateRenderService renderService;
|
private DocTemplateRenderService renderService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DocumentRenderApiService documentRenderApiService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建模板实例")
|
@Operation(summary = "创建模板实例")
|
||||||
@PreAuthorize("@ss.hasPermission('base:template-instance:create')")
|
@PreAuthorize("@ss.hasPermission('base:template-instance:create')")
|
||||||
@@ -104,4 +111,35 @@ public class DocTemplateInstanceController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/render-and-export-word")
|
||||||
|
@Operation(summary = "渲染实例并导出为Word")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:template-instance:query')")
|
||||||
|
public ResponseEntity<byte[]> renderAndExportToWord(
|
||||||
|
@Parameter(name = "instanceId", description = "实例ID", required = true) @RequestParam("instanceId") Long instanceId,
|
||||||
|
@Parameter(name = "fileName", description = "文件名") @RequestParam(value = "fileName", required = false) String fileName,
|
||||||
|
@Parameter(name = "dataMap", description = "数据Map") @RequestBody(required = false) Map<String, Object> dataMap) {
|
||||||
|
byte[] fileContent = documentRenderApiService.renderAndExportToWord(instanceId, dataMap, fileName);
|
||||||
|
String actualFileName = (fileName != null ? fileName : "document") + ".docx";
|
||||||
|
String encodedFileName = URLEncoder.encode(actualFileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.header("Content-Disposition", "attachment; filename=\"document.docx\"; filename*=UTF-8''" + encodedFileName)
|
||||||
|
.header("Content-Type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
||||||
|
.body(fileContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/export-html-to-word")
|
||||||
|
@Operation(summary = "导出HTML为Word文档")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:template-instance:query')")
|
||||||
|
public ResponseEntity<byte[]> exportHtmlToWord(
|
||||||
|
@Parameter(name = "html", description = "HTML内容", required = true) @RequestBody String html,
|
||||||
|
@Parameter(name = "fileName", description = "文件名") @RequestParam(value = "fileName", required = false) String fileName) {
|
||||||
|
byte[] fileContent = documentRenderApiService.exportToWord(html, fileName);
|
||||||
|
String actualFileName = (fileName != null ? fileName : "document") + ".docx";
|
||||||
|
String encodedFileName = URLEncoder.encode(actualFileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.header("Content-Disposition", "attachment; filename=\"document.docx\"; filename*=UTF-8''" + encodedFileName)
|
||||||
|
.header("Content-Type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
||||||
|
.body(fileContent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.doctemplate.render.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BusinessExportRequest {
|
||||||
|
private Long templateInstanceId;
|
||||||
|
private String businessType;
|
||||||
|
private Long businessId;
|
||||||
|
private Map<String, String> fieldMappings;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.doctemplate.render.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BusinessPreviewRequest {
|
||||||
|
private Long templateInstanceId;
|
||||||
|
private String businessType;
|
||||||
|
private Long businessId;
|
||||||
|
private Map<String, String> fieldMappings;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user