fix(approval): approve 默认记「同意」审批意见,供报表审批段显示
approve 原只在审批人手填意见时才写 act_hi_comment,且无默认前缀。报表审批段按 message LIKE '同意%' 匹配,故不填意见的审批在报表不显示。新增 agreeComment():空→"同意",有意见→"同意:意见",已带「同意」→原样,保证恒以「同意」开头。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -319,7 +319,7 @@ public class ApprovalController {
|
|||||||
private ResponseEntity<Map<String, Object>> approve(String taskId, GatewayRequests.ApprovalActionRequest req) {
|
private ResponseEntity<Map<String, Object>> approve(String taskId, GatewayRequests.ApprovalActionRequest req) {
|
||||||
Map<String, Object> vars = new LinkedHashMap<>();
|
Map<String, Object> vars = new LinkedHashMap<>();
|
||||||
vars.put("approveResult", "agree");
|
vars.put("approveResult", "agree");
|
||||||
flowableClient.complete(taskId, vars, req.comment);
|
flowableClient.complete(taskId, vars, agreeComment(req.comment));
|
||||||
|
|
||||||
boolean ended = isProcessEnded(req.processInstanceId);
|
boolean ended = isProcessEnded(req.processInstanceId);
|
||||||
String table = resolveTable(req.tableName, req.businessKey);
|
String table = resolveTable(req.tableName, req.businessKey);
|
||||||
@@ -332,6 +332,19 @@ public class ApprovalController {
|
|||||||
return ResponseEntity.ok(r);
|
return ResponseEntity.ok(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 「同意」审批意见归一:保证以「同意」开头,对齐老系统并使报表审批段可见
|
||||||
|
* (报表 SQL 按 {@code message_ LIKE '同意%'} 匹配、{@code regexp_replace(message_,'^同意:|^同意','')} 取意见)。
|
||||||
|
* 空意见 → {@code "同意"};已以「同意」开头 → 原样;否则 → {@code "同意:" + 意见}。
|
||||||
|
*/
|
||||||
|
static String agreeComment(String opinion) {
|
||||||
|
String s = opinion == null ? "" : opinion.trim();
|
||||||
|
if (s.isEmpty()) {
|
||||||
|
return "同意";
|
||||||
|
}
|
||||||
|
return s.startsWith("同意") ? s : "同意:" + s;
|
||||||
|
}
|
||||||
|
|
||||||
/** 拒绝:终止流程(引擎 deleteProcessInstance)+回写 SYS_DATASTATUS=4(驳回)。 */
|
/** 拒绝:终止流程(引擎 deleteProcessInstance)+回写 SYS_DATASTATUS=4(驳回)。 */
|
||||||
private ResponseEntity<Map<String, Object>> reject(String taskId, GatewayRequests.ApprovalActionRequest req) {
|
private ResponseEntity<Map<String, Object>> reject(String taskId, GatewayRequests.ApprovalActionRequest req) {
|
||||||
Map<String, Object> engine = flowableClient.reject(taskId, req.comment);
|
Map<String, Object> engine = flowableClient.reject(taskId, req.comment);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.eip4.platform.flowgateway;
|
package com.eip4.platform.flowgateway;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyNoInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
@@ -92,6 +94,33 @@ class ApprovalControllerActionTest {
|
|||||||
verify(flowableClient).assist("t3", List.of("u-a", "u-z"), null);
|
verify(flowableClient).assist("t3", List.of("u-a", "u-z"), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同意意见落 act_hi_comment 必须以「同意」开头——报表审批段按 {@code message LIKE '同意%'} 匹配
|
||||||
|
* 并 {@code regexp_replace} 去前缀取意见。空意见 → 默认「同意」(修审批意见在报表不显示=原因B go-forward)。
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void approve_blankComment_recordsDefault同意() {
|
||||||
|
ResponseEntity<Map<String, Object>> resp = controller.action("t1", req("approve"));
|
||||||
|
assertThat(resp.getStatusCode().is2xxSuccessful()).isTrue();
|
||||||
|
verify(flowableClient).complete(eq("t1"), any(), eq("同意"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void approve_withOpinion_prefixesWith同意() {
|
||||||
|
GatewayRequests.ApprovalActionRequest r = req("approve");
|
||||||
|
r.comment = "已审核无误";
|
||||||
|
controller.action("t2", r);
|
||||||
|
verify(flowableClient).complete(eq("t2"), any(), eq("同意:已审核无误"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void approve_opinionAlreadyStartsWith同意_keptAsIs() {
|
||||||
|
GatewayRequests.ApprovalActionRequest r = req("approve");
|
||||||
|
r.comment = "同意,按计划执行";
|
||||||
|
controller.action("t3", r);
|
||||||
|
verify(flowableClient).complete(eq("t3"), any(), eq("同意,按计划执行"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void assist_withoutTargets_returns400() {
|
void assist_withoutTargets_returns400() {
|
||||||
ResponseEntity<Map<String, Object>> resp = controller.action("t4", req("assist"));
|
ResponseEntity<Map<String, Object>> resp = controller.action("t4", req("assist"));
|
||||||
|
|||||||
Reference in New Issue
Block a user