feat(REQ-5369) - 调整获取打印字段变量的接口

This commit is contained in:
wangli 2025-10-11 18:10:37 +08:00
parent d4f6568de0
commit 14f57091d9
2 changed files with 5 additions and 3 deletions

View File

@ -72,5 +72,6 @@ public interface PrintAdminApi {
@GetMapping("/api/print/admin/field/variables") @GetMapping("/api/print/admin/field/variables")
@Manageable @Manageable
@InvokeMode(SYNC) @InvokeMode(SYNC)
CommonResponse<Map<String, Object>> getPrintFieldVariables(@NotBlank(message = "流程实例不能为空") @RequestParam String processInstanceId); CommonResponse<Map<String, Object>> getPrintFieldVariables(@NotBlank(message = "流程实例不能为空") @RequestParam String processInstanceId,
@RequestParam(required = false, defaultValue = "true") Boolean throwException);
} }

View File

@ -322,10 +322,11 @@ public class PrintAdminController implements PrintAdminApi {
@Operation(summary = "获取指定流程下用于替换打印的相关变量") @Operation(summary = "获取指定流程下用于替换打印的相关变量")
@GetMapping("/field/variables") @GetMapping("/field/variables")
@Override @Override
public CommonResponse<Map<String, Object>> getPrintFieldVariables(@NotBlank(message = "流程实例不能为空") @RequestParam String processInstanceId) { public CommonResponse<Map<String, Object>> getPrintFieldVariables(@NotBlank(message = "流程实例不能为空") @RequestParam String processInstanceId,
@RequestParam(required = false, defaultValue = "true") Boolean throwException) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor(); CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
byte[] formInstanceValue = commandExecutor.execute(new CustomGetFormInstanceLatestValuesCmd(processInstanceId)); byte[] formInstanceValue = commandExecutor.execute(new CustomGetFormInstanceLatestValuesCmd(processInstanceId, throwException));
if (!ObjectUtils.isEmpty(formInstanceValue)) { if (!ObjectUtils.isEmpty(formInstanceValue)) {
JSONObject treeNode = JSON.parseObject(new String(formInstanceValue)); JSONObject treeNode = JSON.parseObject(new String(formInstanceValue));
result.putAll(treeNode.getJSONObject("values").getInnerMap()); result.putAll(treeNode.getJSONObject("values").getInnerMap());