🐛 修复开票申请推送未回填星瀚内码导致金蝶附件始终无法上传

This commit is contained in:
刘泉佳
2026-11-04 01:29:15 +08:00
parent 0818e493d3
commit 858a889b79
@@ -43,6 +43,7 @@ import org.springblade.thirdparty.bfi.pojo.dto.BfiInvoiceApplyQueryDTO;
import org.springblade.thirdparty.bfi.pojo.dto.BfiInvoiceApplySaveDTO;
import org.springblade.thirdparty.bfi.pojo.dto.BfiInvoiceApplySaveEntryDTO;
import org.springblade.thirdparty.bfi.pojo.dto.BfiInvoiceApplySaveFreightDTO;
import org.springblade.thirdparty.bfi.pojo.vo.BfiBillSaveResultItemVO;
import org.springblade.thirdparty.bfi.pojo.vo.BfiBillSaveResultVO;
import org.springblade.thirdparty.bfi.pojo.vo.BfiInvoiceApplyOpenApiBillVO;
import org.springblade.thirdparty.bfi.pojo.vo.BfiInvoiceApplyOpenApiInvoiceVO;
@@ -733,9 +734,11 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
public String doSyncKingdee(Long id) {
InvoiceApplication entity = lockedExisting(id);
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的开票申请允许同步金蝶");
// 已同步/已开票幂等返回(开票完成为终态);星瀚内码由附件补传分支经 A303-4 反查回填
if (KingdeeBfiConstant.KINGDEE_STATUS_SYNCED.equals(entity.getKingdeeStatus())
|| KingdeeBfiConstant.KINGDEE_STATUS_INVOICED.equals(entity.getKingdeeStatus())) {
// 已开票为终态幂等返回;已同步且星瀚内码齐备幂等返回——
// 已同步但内码缺失(历史推送未落内码)放行,走下方 A303-4 勾稽反查补内码,供 A902 附件上传定位金蝶单据
if (KingdeeBfiConstant.KINGDEE_STATUS_INVOICED.equals(entity.getKingdeeStatus())
|| (KingdeeBfiConstant.KINGDEE_STATUS_SYNCED.equals(entity.getKingdeeStatus())
&& Func.isNotBlank(entity.getKingdeeBillId()))) {
return entity.getKingdeeBillNo();
}
if (Func.isBlank(entity.getApplicationNo())) throw new ServiceException("推送金蝶开票申请失败:开票申请单号为空");
@@ -882,7 +885,12 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
BfiBillSaveResultVO saveResult = bfiService.saveInvoiceApply(param);
kingdeeApBillSyncSupport.requireBfiSaveSuccess(saveResult,
"推送金蝶开票申请发票张[" + Func.toStr(sheet.getSheetNo()) + "]");
String kingdeeNo = saveResult.getResult().get(0).getNumber();
BfiBillSaveResultItemVO saveItem = saveResult.getResult().get(0);
String kingdeeNo = saveItem.getNumber();
// 星瀚内码随 A303-1 保存结果回填(A902 附件上传定位金蝶单据用),缺失时由 A303-4 勾稽反查兜底
if (Func.isBlank(entity.getKingdeeBillId()) && saveItem.getId() != null) {
entity.setKingdeeBillId(String.valueOf(saveItem.getId()));
}
sheet.setKingdeeBillNo(kingdeeNo);
savedBillNos.add(kingdeeNo);
pushedNew = true;