1.优化电子回单接口

--s
This commit is contained in:
weiyunlong 2025-03-18 10:25:30 +08:00
parent 550a30eddd
commit 183f271e38
1 changed files with 25 additions and 20 deletions

View File

@ -67,43 +67,48 @@ public class PayreceiptQueryControler {
return handleErrorAndReturn("同步失败,费控单据编号:" + fkBillNumber + "的组织编码不存在", fkBillNumber, jsonBodyString);
}
// if (kdPayBillID == null || kdPayBillID.isEmpty()) {
// return handleErrorAndReturn("同步失败, kdPayBillID 为空或未设置", fkBillNumber, jsonBodyString);
// }
QFilter q1 = null;
try {
Long kdPayBillIDLong = Long.valueOf(kdPayBillID);
q1 = new QFilter("id", QCP.equals, kdPayBillIDLong);
} catch (NumberFormatException e) {
return handleErrorAndReturn("同步失败, kdPayBillID 格式不正确: " + kdPayBillID, fkBillNumber, jsonBodyString);
}
QFilter q2 = new QFilter("openorg.number", QCP.equals, companyNum);
QFilter q3 = new QFilter("shjh_fkbillid", QCP.equals, fkBillID);
QFilter q4 = new QFilter("shjh_fkentryid", QCP.equals, fkEntryID);
DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{q1, q2, q3, q4});
QFilter q1 = new QFilter("openorg.number", QCP.equals, companyNum);
q1 = addFilterIfNotNull(q1, "id", Long.valueOf(kdPayBillID));
q1 = addFilterIfNotEmpty(q1, "shjh_fkbillid", fkBillID);
q1 = addFilterIfNotEmpty(q1, "shjh_fkentryid", fkEntryID);
DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{q1});
if (null == paybill) {
return handleErrorAndReturn("同步失败:付款单不存在", fkEntryID, jsonBodyString);
}
customApiResult.setHeaders(map);
customApiResult.getHeaders().put("companyNum",companyNum);
customApiResult.getHeaders().put("kdPayBillID",kdPayBillID);
customApiResult.getHeaders().put("fkBillID",fkBillID);
customApiResult.getHeaders().put("fkEntryID",fkEntryID);
customApiResult.getHeaders().put("kdPayBillID", String.valueOf(paybill.getPkValue()));
customApiResult.getHeaders().put("fkBillID",paybill.getString("shjh_fkbillid"));
customApiResult.getHeaders().put("fkEntryID",paybill.getString("shjh_fkentryid"));
//todo:url待确认
RequestContext requestContext = RequestContext.get();
String clientFullContextPath = requestContext.getClientFullContextPath();//http://127.0.0.1:8881/ierp/
String globalSessionId = requestContext.getGlobalSessionId();//2162562979827025920_uIw8k6LSDffGGXcNLur8vqBPSXGNOIQ2BHoN53tSU1FagJQbARpXMSJdt6Wl1nER56l4J8Mmgj4XjltiCtnQ3d1X5UsGy72g7zUi02
System.out.println("clientFullContextPath:" + clientFullContextPath+",globalSessionId:"+globalSessionId);
// https://ip:port/ierp/index.html?formId=er_tripreqbill&pkId=721810009540800512
// http://127.0.0.1:8881/ierp/kapi/v2/shjh/base/payreceipt_query
String url = clientFullContextPath + "index.html?formId=cas_paybill&pkId=" + kdPayBillID;
String url = clientFullContextPath + "index.html?formId=cas_paybill&pkId=" + paybill.getPkValue();
customApiResult.getHeaders().put("receipturl",url);
}
return CustomApiResult.success(customApiResult);
}
private static QFilter addFilterIfNotNull(QFilter baseFilter, String field, Long value) {
if (value != null) {
QFilter newFilter = new QFilter(field, QCP.equals, value);
return baseFilter.and(newFilter);
}
return baseFilter;
}
private static QFilter addFilterIfNotEmpty(QFilter baseFilter, String field, String value) {
if (value != null && !value.isEmpty()) {
QFilter newFilter = new QFilter(field, QCP.equals, value);
return baseFilter.and(newFilter);
}
return baseFilter;
}
/**
* 处理错误并返回失败结果
*