提交内容:推送星空电子回单,增加上划下拨联查推送逻辑

时间:2025-07-25 11:51
提交人:邹江涛
This commit is contained in:
zoujiangtao 2025-07-25 11:52:13 +08:00
parent 119ef80ad6
commit 8530ae9da8
3 changed files with 231 additions and 105 deletions

View File

@ -1057,17 +1057,22 @@ public class ApiService {
/**
* 查询星空收付款单司库推送星空
* @param dataEntity API映射元数据对象
* @param billMark 单据类型收付款
* @param billNumber 单据编码
* @param billMark 单据类型上划下拨
* @param billNumber 单据编码星瀚单据编码
* @return
*/
public static HashMap<String, Object> getSKPushXKBill(DynamicObject dataEntity, String billMark, String billNumber) {
logger.info("获取推送单据类型 → billMark{}", billMark);
String xkBillType = null;
if ("cas_paybill".equals(billMark)) {
xkBillType = "AP_PAYBILL";
xkBillType = "AP_PAYBILL";// 表单id付款处理 付款单AP_PAYBILL
} else if ("cas_recbill".equals(billMark)) {
xkBillType = "AR_RECEIVEBILL";
xkBillType = "AR_RECEIVEBILL";// 表单id收款处理 收款单AR_RECEIVEBILL
} else if ("fca_transupbill".equals(billMark)) {
xkBillType = "AR_RECEIVEBILL";// 表单id上划处理 收款单AR_RECEIVEBILL
} else if ("fca_transdownbil".equals(billMark)) {
xkBillType = "AP_PAYBILL";// 表单id下拨处理 付款单AP_PAYBILL
}
HashMap<String, Object> result = new HashMap<>();
@ -1101,7 +1106,7 @@ public class ApiService {
/**
* 查询星空收付款单星空推送司库
* @param dataEntity API映射元数据对象
* @param billMark 单据类型收付款
* @param billMark 单据类型上划下拨
* @param billNumber 推送单据编码星空单据编码
* @return
*/
@ -1109,9 +1114,13 @@ public class ApiService {
logger.info("获取推送单据类型 → billMark{}", billMark);
String xkBillType = null;
if ("cas_paybill".equals(billMark)) {
xkBillType = "AP_PAYBILL";
xkBillType = "AP_PAYBILL";// 表单id付款处理 付款单AP_PAYBILL
} else if ("cas_recbill".equals(billMark)) {
xkBillType = "AR_RECEIVEBILL";
xkBillType = "AR_RECEIVEBILL";// 表单id收款处理 收款单AR_RECEIVEBILL
} else if ("fca_transupbill".equals(billMark)) {
xkBillType = "AR_RECEIVEBILL";// 表单id上划处理 收款单AR_RECEIVEBILL
} else if ("fca_transdownbil".equals(billMark)) {
xkBillType = "AP_PAYBILL";// 表单id下拨处理 付款单AP_PAYBILL
}
HashMap<String, Object> result = new HashMap<>();

View File

@ -8,6 +8,7 @@ import com.kingdee.bos.webapi.sdk.K3CloudApi;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.IFormView;
import kd.bos.form.control.CodeEdit;
import kd.bos.form.control.Toolbar;
import kd.bos.form.control.events.ItemClickEvent;
@ -17,10 +18,14 @@ import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import kd.tmc.fca.common.helper.HandLinkBillHelper;
import shkd.sys.sys.mservice.ApiService;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import static shkd.sys.sys.mservice.ApiService.*;
@ -205,6 +210,48 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
}
}
}
// 查询上划单的回单编号
if ("shkd_upbill".equals(itemKey)) {
String shkdSourcenumber = dataEntity.getString("shkd_sourcenumber");
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("fca_transupbill", "id,billno,name", new QFilter("billno", QCP.equals, shkdSourcenumber).toArray());
List<String> receiptNos = HandLinkBillHelper.getReceiptNoByDetails(dynamicObject, dynamicObject.getDataEntityType().getName());
logger.info("上划单回单编号:{}", receiptNos);//电子回单号
DynamicObject[] bei_elecreceipts = BusinessDataServiceHelper.load("bei_elecreceipt", "id,receiptno", new QFilter("receiptno", QCP.equals, receiptNos.get(0)).toArray());
DynamicObject bei_elecreceipt = BusinessDataServiceHelper.loadSingle(bei_elecreceipts[0].getPkValue(), bei_elecreceipts[0].getDynamicObjectType().getName());
IFormView viewByDynamicObj = createViewByDynamicObj(bei_elecreceipt);
List<String> errMsgList = new ArrayList<>();
DynamicObjectCollection receipts = QueryServiceHelper.query("bei_elecreceipt", "id,bank," +
"fileflag,filepath,biztype,bankcheckflag,fileserverurl,tcpurl,uploadfilename,username,password," +
"bank.bank_cate bankcate", new QFilter[]{new QFilter("id", QCP.equals, bei_elecreceipt.getPkValue())});
String pdfUrl = getPdfUrl(viewByDynamicObj.getPageId(), receipts, errMsgList);
Path path = Paths.get(bei_elecreceipt.getString("filepath"));
String upfileName = path.getFileName().toString();
this.getView().showTipNotification("上划单回单编号:" + receiptNos.get(0) + ",电子回单查询 → 获取pdf地址" + pdfUrl);
}
// 查询下拨单的回单编号
if ("shkd_dowbill".equals(itemKey)) {
String shkdSourcenumber = dataEntity.getString("shkd_sourcenumber");
// 这个方法可以查询付款单收款单上划单下拨单关联的回单编号
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("fca_transdownbill", "id,billno,name", new QFilter("billno", QCP.equals, shkdSourcenumber).toArray());
List<String> receiptNos = HandLinkBillHelper.getReceiptNoByDetails(dynamicObject, dynamicObject.getDataEntityType().getName());
logger.info("下拨单回单编号:{}", receiptNos);
DynamicObject[] bei_elecreceipts = BusinessDataServiceHelper.load("bei_elecreceipt", "id,receiptno", new QFilter("receiptno", QCP.equals, receiptNos.get(0)).toArray());
DynamicObject bei_elecreceipt = BusinessDataServiceHelper.loadSingle(bei_elecreceipts[0].getPkValue(), bei_elecreceipts[0].getDynamicObjectType().getName());
IFormView viewByDynamicObj = createViewByDynamicObj(bei_elecreceipt);
List<String> errMsgList = new ArrayList<>();
DynamicObjectCollection receipts = QueryServiceHelper.query("bei_elecreceipt", "id,bank," +
"fileflag,filepath,biztype,bankcheckflag,fileserverurl,tcpurl,uploadfilename,username,password," +
"bank.bank_cate bankcate", new QFilter[]{new QFilter("id", QCP.equals, bei_elecreceipt.getPkValue())});
String pdfUrl = getPdfUrl(viewByDynamicObj.getPageId(), receipts, errMsgList);
Path path = Paths.get(bei_elecreceipt.getString("filepath"));
String upfileName = path.getFileName().toString();
this.getView().showTipNotification("上划单回单编号:" + receiptNos.get(0) + ",电子回单查询 → 获取pdf地址" + pdfUrl);
}
}
private void parseJson(Object obj, int level, String parentKey) {

View File

@ -18,6 +18,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;
import kd.tmc.fca.common.helper.HandLinkBillHelper;
import shkd.sys.sys.mservice.ApiService;
import java.nio.file.Path;
@ -239,6 +240,8 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
case "bei_xkfile":
ArrayList<DynamicObject> paymentObjects = new ArrayList<>(); //所有符合条件存在电子回单的付款单
ArrayList<DynamicObject> receivableObjects = new ArrayList<>(); //所有符合条件存在电子回单的收款单
ArrayList<DynamicObject> TopObjects = new ArrayList<>(); //所有符合条件存在电子回单的上划单
ArrayList<DynamicObject> AllocatedObjects = new ArrayList<>(); //所有符合条件存在电子回单的下拨单
HashMap<String, Object> resultMap = null;
@ -253,6 +256,9 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
DynamicObject xkApiMapping = shkd_apimappings[0];
// 获取k3cloudapi
K3CloudApi k3CloudApi = getK3CloudApi(xkApiMapping);
// 获取多选基础资料业务单元推送组织
ArrayList<Long> orgIds = new ArrayList<>();
DynamicObjectCollection orgsArr = xkApiMapping.getDynamicObjectCollection("shkd_orgs");
@ -288,58 +294,21 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
}
}
// 获取k3cloudapi
K3CloudApi k3CloudApi = getK3CloudApi(xkApiMapping);
// 筛选出符合条件的付款单查询是否有回单如果有则推送
for (DynamicObject dynamicObject : paymentObjects) {
// 银行收付处理
DynamicObjectCollection transDetails = QueryServiceHelper.query("bei_transdetail_cas", "id,receredway,debitamount,creditamount,recedbillentry.e_recedbillid", (new QFilter("recedbillentry.e_recedbillid", QCP.equals, dynamicObject.getPkValue())).and(new QFilter("recedbillentry.e_recedbilltype", QCP.equals, "cas_paybill")).toArray());
if (!transDetails.isEmpty()) {
// 交易明细查询
DynamicObjectCollection details = QueryServiceHelper.query("bei_transdetail", "id,company,accountbank,currency,matchreceiptentry.e_receiptno receiptno", new QFilter[]{new QFilter("id", QCP.equals, transDetails.get(0).getPkValue())});
if (!details.isEmpty()) {
// 交易明细查询的电子回单关联标记字段
if (details.get(0).get("receiptno") != null) {
//
DynamicObject[] dynamicObjects1 = BusinessDataServiceHelper.load("t_bei_elecreceipt", "id,receiptno", new QFilter("receiptno", QCP.equals, details.get(0).getString("receiptno")).toArray());
DynamicObject dynamicObjectObj = BusinessDataServiceHelper.loadSingle(dynamicObjects1[0].getPkValue(), dynamicObjects1[0].getDynamicObjectType().getName());
IFormView viewByDynamicObj = createViewByDynamicObj(dynamicObjectObj);
List<String> errMsgList = new ArrayList<>();
DynamicObjectCollection receipts = QueryServiceHelper.query("bei_elecreceipt", "id,bank," +
"fileflag,filepath,biztype,bankcheckflag,fileserverurl,tcpurl,uploadfilename,username,password," +
"bank.bank_cate bankcate", new QFilter[]{new QFilter("id", QCP.equals, dynamicObject.getPkValue())});
String pdfUrl = getPdfUrl(viewByDynamicObj.getPageId(), receipts, errMsgList);
Path path = Paths.get(dynamicObject.getString("filepath"));
String upfileName = path.getFileName().toString();
List<String> receiptNos = HandLinkBillHelper.getReceiptNoByDetails(dynamicObject, dynamicObject.getDataEntityType().getName());
if (receiptNos.isEmpty()) {
logger.info("付款单:{},无回单", dynamicObject.getString("billno"));
}else {
Map<String, Object> receiptResult = new HashMap<>();
// 获取回单
getReceipt(receiptNos.get(0), receiptResult);
String pdfUrl = receiptResult.get("pdfUrl").toString();
String fileName = receiptResult.get("fileName").toString();
logger.info("付款单:{},电子回单查询 → 电子回单附件推送接口 → 获取pdf地址{}", dynamicObject.getString("billno"), pdfUrl);
JSONObject jsonObject = new JSONObject();
jsonObject.put("FileName", upfileName);// 文件名
jsonObject.put("FormId", "AP_PAYBILL");// 表单id付款单AP_PAYBILL
jsonObject.put("IsLast", true);// 是否最后一次上传
jsonObject.put("InterId", resultMap.get("billId"));// 单据内码
jsonObject.put("BillNO", resultMap.get("billNumber"));// 单据编码
jsonObject.put("AliasFileName", upfileName);// 附件别名
jsonObject.put("SendByte", attachmentBase64(pdfUrl));// 文件字节数组转base64后的字符串
String uploadAttachmentResult;
try {
uploadAttachmentResult = k3CloudApi.attachmentUpload(jsonObject.toString());
JSONObject resultJson = JSON.parseObject(uploadAttachmentResult);
JSONObject Result = resultJson.getJSONObject("Result");
JSONObject ResponseStatus = Result.getJSONObject("ResponseStatus");
Boolean isSuccess = ResponseStatus.getBoolean("IsSuccess");
if (isSuccess) {
dynamicObject.set("shkd_xkfilestatus", "已推送");
logger.info("付款处理 → 电子回单推送星空,单据编码:" + dynamicObject.getString("billno") + "\n附件上传结果" + uploadAttachmentResult);
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
// 推送星空附件
pushXkAttachment(dynamicObject, pdfUrl, fileName, resultMap, k3CloudApi);
}
}
@ -363,55 +332,84 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
}
for (DynamicObject dynamicObject : receivableObjects) {
// 银行收付处理
DynamicObjectCollection transDetails = QueryServiceHelper.query("bei_transdetail_cas", "id,receredway,debitamount,creditamount,recedbillentry.e_recedbillid", (new QFilter("recedbillentry.e_recedbillid", QCP.equals, dynamicObject.getPkValue())).and(new QFilter("recedbillentry.e_recedbilltype", QCP.equals, "cas_recbill")).toArray());
if (!transDetails.isEmpty()) {
// 交易明细查询
DynamicObjectCollection details = QueryServiceHelper.query("bei_transdetail", "id,company,accountbank,currency,matchreceiptentry.e_receiptno receiptno", new QFilter[]{new QFilter("id", QCP.equals, transDetails.get(0).getPkValue())});
if (!details.isEmpty()) {
// 交易明细查询的电子回单关联标记字段
if (details.get(0).get("receiptno") != null) {
//
DynamicObject[] dynamicObjects1 = BusinessDataServiceHelper.load("t_bei_elecreceipt", "id,receiptno", new QFilter("receiptno", QCP.equals, details.get(0).getString("receiptno")).toArray());
DynamicObject dynamicObjectObj = BusinessDataServiceHelper.loadSingle(dynamicObjects1[0].getPkValue(), dynamicObjects1[0].getDynamicObjectType().getName());
IFormView viewByDynamicObj = createViewByDynamicObj(dynamicObjectObj);
List<String> errMsgList = new ArrayList<>();
DynamicObjectCollection receipts = QueryServiceHelper.query("bei_elecreceipt", "id,bank," +
"fileflag,filepath,biztype,bankcheckflag,fileserverurl,tcpurl,uploadfilename,username,password," +
"bank.bank_cate bankcate", new QFilter[]{new QFilter("id", QCP.equals, dynamicObject.getPkValue())});
String pdfUrl = getPdfUrl(viewByDynamicObj.getPageId(), receipts, errMsgList);
Path path = Paths.get(dynamicObject.getString("filepath"));
String upfileName = path.getFileName().toString();
List<String> receiptNos = HandLinkBillHelper.getReceiptNoByDetails(dynamicObject, dynamicObject.getDataEntityType().getName());
if (receiptNos.isEmpty()) {
logger.info("收款单:{},无匹配回单", dynamicObject.getString("billno"));
}else {
Map<String, Object> receiptResult = new HashMap<>();
// 获取回单
getReceipt(receiptNos.get(0), receiptResult);
String pdfUrl = receiptResult.get("pdfUrl").toString();
String fileName = receiptResult.get("fileName").toString();
logger.info("收款单:{},电子回单查询 → 电子回单附件推送接口 → 获取pdf地址{}", dynamicObject.getString("billno"), pdfUrl);
// 推送星空附件
pushXkAttachment(dynamicObject, pdfUrl, fileName, resultMap, k3CloudApi);
}
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("FileName", upfileName);// 文件名
jsonObject.put("FormId", "AR_RECEIVEBILL");// 表单id收款单AR_RECEIVEBILL
jsonObject.put("IsLast", true);// 是否最后一次上传
jsonObject.put("InterId", resultMap.get("billId"));// 单据内码
jsonObject.put("BillNO", resultMap.get("billNumber"));// 单据编码
jsonObject.put("AliasFileName", upfileName);// 附件别名
jsonObject.put("SendByte", attachmentBase64(pdfUrl));// 文件字节数组转base64后的字符串
// 上划处理
DynamicObject[] objects7 = BusinessDataServiceHelper.load("fca_transupbill",
"id,billno,shkd_pushxknumber,shkd_xkfilestatus,company",
new QFilter("shkd_pushxknumber", QCP.not_equals, "")
.and("shkd_xkfilestatus", QCP.not_equals, "已推送")
.and("company", QCP.equals, "").toArray());
String uploadAttachmentResult;
try {
uploadAttachmentResult = k3CloudApi.attachmentUpload(jsonObject.toString());
for (DynamicObject dynamicObject : objects7) {
// 只有司库推送星空业务
resultMap = getSKPushXKBill(xkApiMapping, dynamicObject.getDataEntityType().getName(), dynamicObject.getString("billno"));
if ((boolean) resultMap.get("result")) {
TopObjects.add(dynamicObject);
logger.info("上划处理:{},为司库推送星空单据,星空单据编码:{}", dynamicObject.getString("billno"), resultMap.get("billNumber"));
}
}
JSONObject resultJson = JSON.parseObject(uploadAttachmentResult);
JSONObject Result = resultJson.getJSONObject("Result");
JSONObject ResponseStatus = Result.getJSONObject("ResponseStatus");
Boolean isSuccess = ResponseStatus.getBoolean("IsSuccess");
if (isSuccess) {
dynamicObject.set("shkd_xkfilestatus", "已推送");
logger.info("收款处理 → 电子回单推送星空,单据编码:" + dynamicObject.getString("billno") + "\n附件上传结果" + uploadAttachmentResult);
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
}
} catch (Exception e) {
throw new RuntimeException(e);
for (DynamicObject dynamicObject : TopObjects) {
List<String> receiptNos = HandLinkBillHelper.getReceiptNoByDetails(dynamicObject, dynamicObject.getDataEntityType().getName());
if (receiptNos.isEmpty()) {
logger.info("上划处理:{},无匹配回单", dynamicObject.getString("billno"));
}else {
Map<String, Object> receiptResult = new HashMap<>();
// 获取回单
getReceipt(receiptNos.get(0), receiptResult);
String pdfUrl = receiptResult.get("pdfUrl").toString();
String fileName = receiptResult.get("fileName").toString();
logger.info("上划处理:{},电子回单查询 → 电子回单附件推送接口 → 获取pdf地址{}", dynamicObject.getString("billno"), pdfUrl);
// 推送星空附件
pushXkAttachment(dynamicObject, pdfUrl, fileName, resultMap, k3CloudApi);
}
}
// 下拨处理
DynamicObject[] objects8 = BusinessDataServiceHelper.load("fca_transdownbil",
"id,billno,shkd_pushxknumber,shkd_xkfilestatus,company",
new QFilter("shkd_pushxknumber", QCP.not_equals, "")
.and("shkd_xkfilestatus", QCP.not_equals, "已推送")
.and("company", QCP.equals, "").toArray());
for (DynamicObject dynamicObject : objects8) {
// 只有司库推送星空业务
resultMap = getSKPushXKBill(xkApiMapping, dynamicObject.getDataEntityType().getName(), dynamicObject.getString("billno"));
if ((boolean) resultMap.get("result")) {
AllocatedObjects.add(dynamicObject);
logger.info("下拨处理:{},为司库推送星空单据,星空单据编码:{}", dynamicObject.getString("billno"), resultMap.get("billNumber"));
}
}
for (DynamicObject dynamicObject : AllocatedObjects) {
List<String> receiptNos = HandLinkBillHelper.getReceiptNoByDetails(dynamicObject, dynamicObject.getDataEntityType().getName());
if (receiptNos.isEmpty()) {
logger.info("下拨处理:{},无匹配回单", dynamicObject.getString("billno"));
}else {
Map<String, Object> receiptResult = new HashMap<>();
// 获取回单
getReceipt(receiptNos.get(0), receiptResult);
String pdfUrl = receiptResult.get("pdfUrl").toString();
String fileName = receiptResult.get("fileName").toString();
logger.info("下拨处理:{},电子回单查询 → 电子回单附件推送接口 → 获取pdf地址{}", dynamicObject.getString("billno"), pdfUrl);
// 推送星空附件
pushXkAttachment(dynamicObject, pdfUrl, fileName, resultMap, k3CloudApi);
}
}
break;
default:
@ -475,4 +473,76 @@ public class PushTaskPlugin extends AbstractTask implements Plugin {
return Date.from(firstDayOfMonth.atStartOfDay(DEFAULT_ZONE).toInstant());
}
}
/**
* 获取付款单收款单上划单下拨单关联的回单附件地址
*
* @param receiptNo 回单编号
* @param resultMap 回单信息
* @return
*/
private static void getReceipt(String receiptNo, Map<String, Object> resultMap) {
DynamicObject[] bei_elecreceipts = BusinessDataServiceHelper.load("bei_elecreceipt", "id,receiptno", new QFilter("receiptno", QCP.equals, receiptNo).toArray());
DynamicObject bei_elecreceipt = BusinessDataServiceHelper.loadSingle(bei_elecreceipts[0].getPkValue(), bei_elecreceipts[0].getDynamicObjectType().getName());
IFormView viewByDynamicObj = createViewByDynamicObj(bei_elecreceipt);
List<String> errMsgList = new ArrayList<>();
DynamicObjectCollection receipts = QueryServiceHelper.query("bei_elecreceipt", "id,bank," +
"fileflag,filepath,biztype,bankcheckflag,fileserverurl,tcpurl,uploadfilename,username,password," +
"bank.bank_cate bankcate", new QFilter[]{new QFilter("id", QCP.equals, bei_elecreceipt.getPkValue())});
String pdfUrl = getPdfUrl(viewByDynamicObj.getPageId(), receipts, errMsgList);
Path path = Paths.get(bei_elecreceipt.getString("filepath"));
String upfileName = path.getFileName().toString();
resultMap.put("pdfUrl", pdfUrl);
resultMap.put("fileName", upfileName);
}
/**
* 推送星空回单附件
*
* @param dynamicObject 星瀚单据
* @param pdfUrl 星瀚回单附件地址
* @param fileName 星瀚回单附件名称
* @param resultMap 查询星空单据结果编码id
* @param k3CloudApi 星瀚接口访问实例对象
* @return
*/
private static void pushXkAttachment(DynamicObject dynamicObject, String pdfUrl, String fileName, Map<String, Object> resultMap, K3CloudApi k3CloudApi) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("FileName", fileName);// 文件名
String entityName = dynamicObject.getDataEntityType().getName();
if ("cas_paybill".equals(entityName)) {
jsonObject.put("FormId", "AP_PAYBILL");// 表单id付款处理 付款单AP_PAYBILL
} else if ("cas_recbill".equals(entityName)) {
jsonObject.put("FormId", "AR_RECEIVEBILL");// 表单id收款处理 收款单AR_RECEIVEBILL
} else if ("fca_transupbill".equals(entityName)) {
jsonObject.put("FormId", "AR_RECEIVEBILL");// 表单id上划处理 收款单AR_RECEIVEBILL
} else if ("fca_transdownbil".equals(entityName)) {
jsonObject.put("FormId", "AP_PAYBILL");// 表单id下拨处理 付款单AP_PAYBILL
}
jsonObject.put("IsLast", true);// 是否最后一次上传
jsonObject.put("InterId", resultMap.get("billId"));// 单据内码
jsonObject.put("BillNO", resultMap.get("billNumber"));// 单据编码
jsonObject.put("AliasFileName", fileName);// 附件别名
jsonObject.put("SendByte", attachmentBase64(pdfUrl));// 文件字节数组转base64后的字符串
String uploadAttachmentResult;
try {
uploadAttachmentResult = k3CloudApi.attachmentUpload(jsonObject.toString());
JSONObject resultJson = JSON.parseObject(uploadAttachmentResult);
JSONObject Result = resultJson.getJSONObject("Result");
JSONObject ResponseStatus = Result.getJSONObject("ResponseStatus");
Boolean isSuccess = ResponseStatus.getBoolean("IsSuccess");
if (isSuccess) {
dynamicObject.set("shkd_xkfilestatus", "已推送");
logger.info(entityName + " → 电子回单推送星空,单据编码:" + dynamicObject.getString("billno") + "\n附件上传结果" + uploadAttachmentResult);
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}