refactor: 收敛审批通过金蝶同步提示文案至监听器统一构建
This commit is contained in:
+1
-14
@@ -201,20 +201,7 @@ public class FormalSettlementController extends BladeController {
|
||||
@Operation(summary = "审批通过")
|
||||
public R approve(@RequestBody FormalSettlementStatusRequest request) {
|
||||
formalSettlementService.approve(request);
|
||||
return approveResponse();
|
||||
}
|
||||
|
||||
/** 审批接口统一响应:审批已生效,自动推送结果(成功单据号/失败原因)一并返回;失败用 data=false 供前端区分提示样式 */
|
||||
private R approveResponse() {
|
||||
String syncFailure = KingdeeApprovalSyncListener.pollSyncFailure();
|
||||
String syncResult = KingdeeApprovalSyncListener.pollSyncResult();
|
||||
if (syncFailure != null) {
|
||||
return R.data(Boolean.FALSE, "审批通过,但自动同步金蝶失败:" + syncFailure);
|
||||
}
|
||||
if (syncResult != null) {
|
||||
return R.success("审批通过,单据号[" + syncResult + "]已同步金蝶");
|
||||
}
|
||||
return R.success("审批通过");
|
||||
return KingdeeApprovalSyncListener.billSyncedResponse();
|
||||
}
|
||||
|
||||
@PostMapping("/return")
|
||||
|
||||
+1
-14
@@ -131,20 +131,7 @@ public class InvoiceApplicationController extends BladeController {
|
||||
@Operation(summary = "审批通过开票申请")
|
||||
public R approve(@RequestBody InvoiceApplicationStatusRequest request) {
|
||||
invoiceApplicationService.approve(request);
|
||||
return approveResponse();
|
||||
}
|
||||
|
||||
/** 审批接口统一响应:审批已生效,自动推送结果(成功单据号/失败原因)一并返回;失败用 data=false 供前端区分提示样式 */
|
||||
private R approveResponse() {
|
||||
String syncFailure = KingdeeApprovalSyncListener.pollSyncFailure();
|
||||
String syncResult = KingdeeApprovalSyncListener.pollSyncResult();
|
||||
if (syncFailure != null) {
|
||||
return R.data(Boolean.FALSE, "审批通过,但自动同步金蝶失败:" + syncFailure);
|
||||
}
|
||||
if (syncResult != null) {
|
||||
return R.success("审批通过,单据号[" + syncResult + "]已同步金蝶");
|
||||
}
|
||||
return R.success("审批通过");
|
||||
return KingdeeApprovalSyncListener.billSyncedResponse();
|
||||
}
|
||||
|
||||
@PostMapping("/return")
|
||||
|
||||
+1
-14
@@ -149,20 +149,7 @@ public class InvoiceReceiptController extends BladeController {
|
||||
@Operation(summary = "审批通过收票登记")
|
||||
public R approve(@RequestBody InvoiceReceiptStatusRequest request) {
|
||||
invoiceReceiptService.approve(request);
|
||||
return approveResponse();
|
||||
}
|
||||
|
||||
/** 审批接口统一响应:审批已生效,自动推送结果(成功单据号/失败原因)一并返回;失败用 data=false 供前端区分提示样式 */
|
||||
private R approveResponse() {
|
||||
String syncFailure = KingdeeApprovalSyncListener.pollSyncFailure();
|
||||
String syncResult = KingdeeApprovalSyncListener.pollSyncResult();
|
||||
if (syncFailure != null) {
|
||||
return R.data(Boolean.FALSE, "审批通过,但自动同步金蝶失败:" + syncFailure);
|
||||
}
|
||||
if (syncResult != null) {
|
||||
return R.success("审批通过,已同步金蝶:" + syncResult);
|
||||
}
|
||||
return R.success("审批通过");
|
||||
return KingdeeApprovalSyncListener.summarySyncedResponse();
|
||||
}
|
||||
|
||||
@PostMapping("/return")
|
||||
|
||||
+2
-10
@@ -106,11 +106,9 @@ public class PaymentApplicationController extends BladeController {
|
||||
return approveResponse(request.getId());
|
||||
}
|
||||
|
||||
/** 审批接口统一响应:审批已生效,付款特批发起/自动同步结果(成功单据号/失败原因)一并返回;失败用 data=false 供前端区分提示样式 */
|
||||
/** 审批接口统一响应:审批已生效,付款特批发起结果优先返回;特批完成/未走特批时金蝶同步结果走统一响应(成功单据号/失败原因) */
|
||||
private R approveResponse(Long id) {
|
||||
String hcsFailure = HcsImmediatePushSupport.pollSyncFailure();
|
||||
String syncFailure = KingdeeApprovalSyncListener.pollSyncFailure();
|
||||
String syncResult = KingdeeApprovalSyncListener.pollSyncResult();
|
||||
if (hcsFailure != null) {
|
||||
return R.data(Boolean.FALSE, "审批通过,但发起付款特批/推送合规失败:" + hcsFailure + ",可稍后重推合规");
|
||||
}
|
||||
@@ -122,13 +120,7 @@ public class PaymentApplicationController extends BladeController {
|
||||
if (Arrays.asList(HcsSyncConstant.SPEC_STATUS_PUSHING, HcsSyncConstant.SPEC_STATUS_PROCESSING).contains(specStatus)) {
|
||||
return R.success("审批通过,已发起付款特批,特批通过后将自动推送履约数据并同步金蝶");
|
||||
}
|
||||
if (syncFailure != null) {
|
||||
return R.data(Boolean.FALSE, "审批通过,但自动同步金蝶失败:" + syncFailure);
|
||||
}
|
||||
if (syncResult != null) {
|
||||
return R.success("审批通过,单据号[" + syncResult + "]已同步金蝶");
|
||||
}
|
||||
return R.success("审批通过");
|
||||
return KingdeeApprovalSyncListener.billSyncedResponse();
|
||||
}
|
||||
@PostMapping("/return")
|
||||
@ApiOperationSupport(order = 8)
|
||||
|
||||
+2
-13
@@ -36,20 +36,9 @@ public class SettlementAdjustmentController extends BladeController {
|
||||
@PostMapping("/remove") public R remove(@RequestParam Long id) { service.removeDraft(id); return R.success("删除成功"); }
|
||||
@PostMapping("/submit") public R submit(@RequestBody SettlementAdjustmentStatusRequest request) { service.submit(request); return R.success("提交成功"); }
|
||||
@PostMapping("/approve") public R approve(@RequestBody SettlementAdjustmentStatusRequest request) {
|
||||
// 未推送场景自动推送失败原因以警告文案返回(data=false 供前端区分提示样式);hint 优先于同步成功提示
|
||||
String hint = service.approve(request);
|
||||
// 未推送场景自动推送失败原因以警告文案返回(data=false 供前端区分提示样式)
|
||||
String syncFailure = KingdeeApprovalSyncListener.pollSyncFailure();
|
||||
String syncResult = KingdeeApprovalSyncListener.pollSyncResult();
|
||||
if (Func.isNotBlank(syncFailure)) {
|
||||
return R.data(Boolean.FALSE, "审批通过,但自动同步金蝶失败:" + syncFailure);
|
||||
}
|
||||
if (Func.isNotBlank(hint)) {
|
||||
return R.data(Boolean.TRUE, "审批通过;" + hint);
|
||||
}
|
||||
if (Func.isNotBlank(syncResult)) {
|
||||
return R.success("审批通过,单据号[" + syncResult + "]已同步金蝶");
|
||||
}
|
||||
return R.success("审批通过");
|
||||
return KingdeeApprovalSyncListener.billSyncedResponse(Func.isBlank(hint) ? null : hint);
|
||||
}
|
||||
@PostMapping("/return") public R returnBill(@RequestBody SettlementAdjustmentStatusRequest request) { service.returnBill(request); return R.success("已驳回"); }
|
||||
@PostMapping("/repush") public R<String> repush(@RequestParam Long id) { return R.data(service.repush(id)); }
|
||||
|
||||
+42
@@ -21,6 +21,7 @@ package org.springblade.transport.listener;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.transport.config.BfiProperties;
|
||||
import org.springblade.transport.constant.HcsSyncConstant;
|
||||
import org.springblade.transport.event.KingdeeBillApprovedEvent;
|
||||
@@ -98,6 +99,47 @@ public class KingdeeApprovalSyncListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批接口统一金蝶同步响应(单据号域:正式结算单/开票申请/付款申请/结算调整):
|
||||
* 同步失败原因以 data=false 返回供前端区分提示样式,成功提示"单据号[xxx]已同步金蝶",未触发推送返回"审批通过"
|
||||
*/
|
||||
public static R billSyncedResponse() {
|
||||
return billSyncedResponse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同 {@link #billSyncedResponse()},pendingHint 非空时优先于同步成功提示返回(结算调整 hint 场景)
|
||||
*
|
||||
* @param pendingHint 审批附带提示(如"存在未勾稽明细"),无同步失败时以 data=true 警告返回
|
||||
*/
|
||||
public static R billSyncedResponse(String pendingHint) {
|
||||
String syncResult = pollSyncResult();
|
||||
return response(syncResult == null ? null : "审批通过,单据号[" + syncResult + "]已同步金蝶", pendingHint);
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批接口统一金蝶同步响应(收票登记域):A303-2 推送结果为笔数汇总而非单据号,成功提示原样返回汇总文案
|
||||
*/
|
||||
public static R summarySyncedResponse() {
|
||||
String syncResult = pollSyncResult();
|
||||
return response(syncResult == null ? null : "审批通过,已同步金蝶:" + syncResult, null);
|
||||
}
|
||||
|
||||
/** 同步响应骨架:同步失败原因优先(data=false),其次审批附带提示(data=true),再次成功提示,均无返回"审批通过" */
|
||||
private static R response(String syncedTip, String pendingHint) {
|
||||
String syncFailure = pollSyncFailure();
|
||||
if (syncFailure != null) {
|
||||
return R.data(Boolean.FALSE, "审批通过,但自动同步金蝶失败:" + syncFailure);
|
||||
}
|
||||
if (pendingHint != null) {
|
||||
return R.data(Boolean.TRUE, "审批通过;" + pendingHint);
|
||||
}
|
||||
if (syncedTip != null) {
|
||||
return R.success(syncedTip);
|
||||
}
|
||||
return R.success("审批通过");
|
||||
}
|
||||
|
||||
/**
|
||||
* 事务提交后同步推送。fallbackExecution=true 兜底:approve 未开启事务时事件不再被默认丢弃。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user