电子回单查询接口优化入参

This commit is contained in:
yuxueliang0813 2025-08-11 17:53:41 +08:00
parent dd9d816ef8
commit 94026016a5
1 changed files with 47 additions and 27 deletions

View File

@ -1,6 +1,7 @@
package shjh.jhzj7.fi.fi.webapi; package shjh.jhzj7.fi.fi.webapi;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.drew.lang.annotations.NotNull; import com.drew.lang.annotations.NotNull;
@ -46,44 +47,55 @@ public class PayreceiptQueryControler {
//select * from T_CAS_PaymentBill where fbillno = 'FKZJ2025030006'; 2168985504052162560 //select * from T_CAS_PaymentBill where fbillno = 'FKZJ2025030006'; 2168985504052162560
//select * from t_org_org where fid = 2116753963226241024; //select * from t_org_org where fid = 2116753963226241024;
JSONObject json_body; JSONObject json_body;
String jsonBodyString;
try { try {
// 解析入参如果格式不正确日志记录并反馈esb7.4.1 // 解析入参如果格式不正确日志记录并反馈esb7.4.1
json_body = (JSONObject) JSON.toJSON(PayreceiptQuerybill); json_body = (JSONObject) JSON.toJSON(PayreceiptQuerybill);
jsonBodyString = JSON.toJSONString(json_body);
} catch (JSONException e) { } catch (JSONException e) {
return handleErrorAndReturn("付款电子回单查询接口入参异常:" + e.getMessage(), Apimenthod, null,apiResultExt); return handleErrorAndReturn("付款电子回单查询接口入参异常:" + e.getMessage(), Apimenthod, null,apiResultExt);
} }
List<ApiResultExt.EntryBean> entryBeans = new ArrayList<>(); List<ApiResultExt.EntryBean> entryBeans = new ArrayList<>();//结果返回值
List<PayreceiptQueryModel.EntryBean> items = PayreceiptQuerybill.getItems(); JSONArray itemarray = json_body.getJSONArray("items");
for (PayreceiptQueryModel.EntryBean item : items) { JSONObject json_item;
String companyNum = item.getCompanyNum();//公司编号 String companyNum;
String kdPayBillID = item.getKdPayBillID();//金蝶付款单ID String kdPayBillID;
String fkBillID = item.getFkBillID();//费控单据主表ID String fkBillID;
String fkEntryID = item.getFkEntryID();//费控单据分录ID String fkEntryID;
String fkBillNumber = item.getFkBillNumber();//费控单据编号 String fkBillNumber;
String voucherNum = item.getVoucherNum();//付款凭证号 String voucherNum;
String voucherYear = item.getVoucherYear();//付款凭证会计年度 String voucherYear;
DynamicObject orginfo;
DynamicObject paybill;
ApiResultExt.EntryBean entryBean;
for (int i = 0; i < itemarray.size(); i++) {
json_item = itemarray.getJSONObject(i);
companyNum = json_item.getString("companyNum");//公司编号
kdPayBillID = json_item.getString("kdPayBillID");//金蝶付款单ID
fkBillID = json_item.getString("fkBillID");//费控单据主表ID
fkEntryID = json_item.getString("fkEntryID");//费控单据分录ID
fkBillNumber = json_item.getString("fkBillNumber");//费控单据编号
voucherNum = json_item.getString("voucherNum");//付款凭证号
voucherYear = json_item.getString("voucherYear");//付款凭证会计年度
DynamicObject org = loadOrgByCompanyNum(companyNum); orginfo = loadOrgByCompanyNum(companyNum);
if (org == null) { if (orginfo == null) {
handleError("查询失败,费控单据编号:" + fkBillNumber + "的组织编码不存在", fkBillNumber, jsonBodyString); handleError("查询失败,费控单据编号:" + fkBillNumber + "的组织编码不存在", fkBillNumber, json_item.toJSONString());
continue;
} }
QFilter q1 = new QFilter("openorg.number", QCP.equals, companyNum);//公司编号 QFilter q1 = new QFilter("openorg.number", QCP.equals, companyNum);//公司编号
if (kdPayBillID != null && !kdPayBillID.isEmpty()) { if (!JhzjUtils.isEmpty(kdPayBillID)) {
q1 = addFilterIfNotNull(q1, "id", Long.valueOf(kdPayBillID));//金蝶付款单ID q1 = addFilterIfNotNull(q1, "id", Long.valueOf(kdPayBillID));//金蝶付款单ID
} }
q1 = addFilterIfNotEmpty(q1, "shjh_fkbillid", fkBillID);//费控单据主表ID q1 = addFilterIfNotEmpty(q1, "shjh_fkbillid", fkBillID);//费控单据主表ID
q1 = addFilterIfNotEmpty(q1, "shjh_fkentryid", fkEntryID);//费控单据分录ID q1 = addFilterIfNotEmpty(q1, "shjh_fkentryid", fkEntryID);//费控单据分录ID
q1 = addFilterIfNotEmpty(q1, "entry.shjh_fkdjbh", fkBillNumber);//费控单据编号-外部系统单号 q1 = addFilterIfNotEmpty(q1, "entry.shjh_fkdjbh", fkBillNumber);//费控单据编号-外部系统单号
q1 = addFilterIfNotEmpty(q1, "shjh_credentialnum", voucherNum);//凭证号 q1 = addFilterIfNotEmpty(q1, "entry.shjh_vouchernums", voucherNum);//付凭证号
q1 = addFilterIfNotEmpty(q1, "shjh_sapfiscalyear", voucherYear);//凭证年份 q1 = addFilterIfNotEmpty(q1, "entry.shjh_voucheryear", voucherYear);//付凭证年份
DynamicObject paybill = BusinessDataServiceHelper.loadSingle(paybillName, new QFilter[]{q1}); paybill = BusinessDataServiceHelper.loadSingle(paybillName, new QFilter[]{q1});
//申明此次查询的返回值 //申明此次查询的返回值
ApiResultExt.EntryBean entryBean = new ApiResultExt.EntryBean(); entryBean = new ApiResultExt.EntryBean();
entryBean.setCompanyNum(companyNum);//公司编号 entryBean.setCompanyNum(companyNum);//公司编号
entryBean.setKdPayBillID(kdPayBillID);//金蝶付款单ID entryBean.setKdPayBillID(kdPayBillID);//金蝶付款单ID
entryBean.setFkBillID(fkBillID);//费控单据主表ID entryBean.setFkBillID(fkBillID);//费控单据主表ID
@ -94,7 +106,11 @@ public class PayreceiptQueryControler {
entryBean.setReceipturl("");//电子回单路径 entryBean.setReceipturl("");//电子回单路径
entryBeans.add(entryBean); entryBeans.add(entryBean);
if (null == paybill) { if (null == paybill) {
handleError("查询失败:付款单不存在", fkEntryID, jsonBodyString); if(JhzjUtils.isEmpty(fkEntryID)){
//说明本次是sap来查询的不是费控来查询的
fkEntryID = voucherNum;
}
handleError("查询失败:付款单不存在", fkEntryID, json_item.toJSONString());
continue; continue;
} }
//查询电子回单,返回pdf url //查询电子回单,返回pdf url
@ -141,23 +157,27 @@ public class PayreceiptQueryControler {
// } // }
} catch (Exception var11) { } catch (Exception var11) {
logger.error("电子回单获取文件路径异常: " + var11.getMessage()); logger.error("电子回单获取文件路径异常: " + var11.getMessage());
handleError("查询失败:电子回单获取文件路径异常", receiptNo, jsonBodyString); handleError("查询失败:电子回单获取文件路径异常", receiptNo, json_item.toJSONString());
} }
} else { } else {
logger.warn(receiptNo + "回单为非文件类回单"); logger.warn(receiptNo + "回单为非文件类回单");
handleError("查询失败:回单为非文件类回单", receiptNo, jsonBodyString); handleError("查询失败:回单为非文件类回单", receiptNo, json_item.toJSONString());
} }
}else{ }else{
handleError("查询失败:电子回单不存在", eReceiptid+"", jsonBodyString); handleError("查询失败:电子回单不存在", eReceiptid+"", json_item.toJSONString());
} }
}else{ }else{
handleError("查询失败:交易明细未关联电子回单", edetailbillno, jsonBodyString); handleError("查询失败:交易明细未关联电子回单", edetailbillno, json_item.toJSONString());
} }
}else{ }else{
handleError("查询失败:交易明细编号不存在", edetailbillno, jsonBodyString); handleError("查询失败:交易明细编号不存在", edetailbillno, json_item.toJSONString());
} }
}else{ }else{
handleError("查询失败:付款单未关联交易明细", fkEntryID, jsonBodyString); if(JhzjUtils.isEmpty(fkEntryID)){
//说明本次是sap来查询的不是费控来查询的
fkEntryID = voucherNum;
}
handleError("查询失败:付款单未关联交易明细", fkEntryID, json_item.toJSONString());
} }
} }
return handleSuccessAndReturn(apiResultExt, entryBeans); return handleSuccessAndReturn(apiResultExt, entryBeans);