星空对接接口开发:修改对接星空接口逻辑,补充直接调拨单json实体
This commit is contained in:
parent
7996f41b74
commit
6bcea6484e
|
@ -1,5 +1,7 @@
|
||||||
package com.ruoyi.webApi;
|
package com.ruoyi.webApi;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.ruoyi.bill.domain.PoundBill;
|
import com.ruoyi.bill.domain.PoundBill;
|
||||||
|
@ -41,7 +43,7 @@ public class ApiPostBack {
|
||||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
//单据保存(更新)
|
//单据保存(更新)
|
||||||
public String makePoundBillFormData(String id) throws IOException {
|
public void makePoundBillFormData(String id) throws IOException {
|
||||||
PoundBill poundBill = poundBillService.selectPoundBillById(id);
|
PoundBill poundBill = poundBillService.selectPoundBillById(id);
|
||||||
if (poundBill == null) throw new RuntimeException("磅单不存在!");
|
if (poundBill == null) throw new RuntimeException("磅单不存在!");
|
||||||
|
|
||||||
|
@ -55,10 +57,34 @@ public class ApiPostBack {
|
||||||
try {
|
try {
|
||||||
jsonInputString = objectMapper.writeValueAsString(request);
|
jsonInputString = objectMapper.writeValueAsString(request);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
return "JSON序列化失败:" + e.getMessage();
|
throw new RuntimeException("JSON序列化失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return sendPostRequest(url, jsonInputString);
|
String resultJSON = sendPostRequest(url, jsonInputString);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(resultJSON);
|
||||||
|
// 获取 Result.NeedReturnData 数组,更新fid ,fentryid的值
|
||||||
|
JSONArray needReturnDataArray = jsonObject.getJSONObject("Result").getJSONArray("NeedReturnData");
|
||||||
|
String fid = "0";
|
||||||
|
String fEntryID = "0";
|
||||||
|
for (int i = 0; i < needReturnDataArray.size(); i++) {
|
||||||
|
JSONObject needReturnDataItem = needReturnDataArray.getJSONObject(i);
|
||||||
|
// 取得 FID
|
||||||
|
fid = needReturnDataItem.getString("FID");
|
||||||
|
// 取得 FEntity 数组
|
||||||
|
JSONArray fEntityArray = needReturnDataItem.getJSONArray("FEntity");
|
||||||
|
if (fEntityArray != null && !fEntityArray.isEmpty()){
|
||||||
|
fEntityArray = needReturnDataItem.getJSONArray("FBillEntry");
|
||||||
|
}
|
||||||
|
for (int j = 0; j < fEntityArray.size(); j++) {
|
||||||
|
JSONObject fEntityItem = fEntityArray.getJSONObject(j);
|
||||||
|
// 取得 FEntryID
|
||||||
|
fEntryID = fEntityItem.getString("FEntryID");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
poundBill.setFid(fid);
|
||||||
|
poundBill.setFentity_fentryid(fEntryID);
|
||||||
|
poundBillService.updatePoundBill(poundBill);
|
||||||
}
|
}
|
||||||
|
|
||||||
//单据下推
|
//单据下推
|
||||||
|
|
Loading…
Reference in New Issue