- 调用SAP收款凭证清账状态查询接口(优化接口入参,和返回页面错误信息)

--s
This commit is contained in:
weiyunlong 2025-04-25 14:43:18 +08:00
parent f24dac1263
commit eb0c2a1604
3 changed files with 19 additions and 4 deletions

View File

@ -149,6 +149,11 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
if (response != null) { if (response != null) {
try { try {
JSONObject json = JSONObject.parseObject(response); JSONObject json = JSONObject.parseObject(response);
String code = json.getString("code");
if (!"0".equals(code)) {
this.getView().showTipNotification("SAP收款凭证清账状态查询接口调用失败错误信息"+json.getString("msg"));
return;
}
JSONObject data = json.getJSONObject("data"); JSONObject data = json.getJSONObject("data");
JSONArray itItems = data.getJSONArray("IT_ITEMS"); JSONArray itItems = data.getJSONArray("IT_ITEMS");
if (itItems != null && !itItems.isEmpty()) { if (itItems != null && !itItems.isEmpty()) {

View File

@ -56,6 +56,11 @@ public class ClosingStatusValidator extends AbstractValidator {
if (response != null) { if (response != null) {
try { try {
JSONObject json = JSONObject.parseObject(response); JSONObject json = JSONObject.parseObject(response);
String code = json.getString("code");
if (!"0".equals(code)) {
this.addErrorMessage(dataEntity, "SAP收款凭证清账状态查询接口调用失败错误信息"+json.getString("msg"));
return;
}
JSONObject data = json.getJSONObject("data"); JSONObject data = json.getJSONObject("data");
JSONArray itItems = data.getJSONArray("IT_ITEMS"); JSONArray itItems = data.getJSONArray("IT_ITEMS");
if (itItems != null && !itItems.isEmpty()) { if (itItems != null && !itItems.isEmpty()) {

View File

@ -640,7 +640,11 @@ public class SapUtils {
List<Map<String, Object>> items = new ArrayList<>(); List<Map<String, Object>> items = new ArrayList<>();
items.add(item); items.add(item);
LocalDateTime date = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
String dates = date.format(formatter);
body.put("rootContextID", "" + System.currentTimeMillis());//唯一事务ID采用UUID或其他强唯一性ID
body.put("requestTime", dates);//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("IT_ITEMS", items); data.put("IT_ITEMS", items);
@ -648,9 +652,10 @@ public class SapUtils {
String response = ApiUtils.sendPost(head, body, QUERY_STATE_URL); String response = ApiUtils.sendPost(head, body, QUERY_STATE_URL);
if (null != response) { if (null != response) {
boolean isSuccess = ApiUtils.parseResponse(response, billNumber, body, API_METHOD4, message); boolean isSuccess = ApiUtils.parseResponse(response, billNumber, body, API_METHOD4, message);
if (isSuccess) { // if (isSuccess) {
return response; // return response;
} // }
return response;
} }
} catch (IOException e) { } catch (IOException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());