星空对接接口开发:对同步星空接口添加修改校验
This commit is contained in:
parent
6bcea6484e
commit
c3d9be48cc
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.bill.domain.PoundBill;
|
||||
import com.ruoyi.bill.domain.Poundappli;
|
||||
import com.ruoyi.bill.service.IPoundBillService;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.webApi.saveRequestBody.billHandlerUtil.BillHandler;
|
||||
|
@ -20,9 +21,15 @@ import java.io.BufferedReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 各个单据回传星空接口(单据更新,单据下推)
|
||||
|
@ -50,9 +57,18 @@ public class ApiPostBack {
|
|||
String url = sysConfigService.selectConfigByKey("OA_Url") +
|
||||
"/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc";
|
||||
|
||||
BillHandler handler = BillHandlers.getHandler(poundBill.getSrcblltype());
|
||||
DynamicFormRequest request = handler.buildRequest(poundBill);
|
||||
//星空单据类型 (发货通知单,收料通知单有下游单据 ;存在下游单据时不允许计量同步星空)
|
||||
String srcblltype = poundBill.getSrcblltype();
|
||||
if ("SAL_DELIVERYNOTICE".equals(srcblltype) || "PUR_ReceiveBill".equals(srcblltype)){
|
||||
String fid = poundBill.getFid();
|
||||
if(!"0".equals(fid)){
|
||||
if(checkOaBillExist(srcblltype,id)) throw new RuntimeException("磅单在星空已经存在下游单据,不允许修改,如需修改请前往星空平台删除下游单据!");
|
||||
}
|
||||
}
|
||||
|
||||
//构建请求体
|
||||
BillHandler handler = BillHandlers.getHandler(srcblltype);
|
||||
DynamicFormRequest request = handler.buildRequest(poundBill);
|
||||
String jsonInputString;
|
||||
try {
|
||||
jsonInputString = objectMapper.writeValueAsString(request);
|
||||
|
@ -148,5 +164,64 @@ public class ApiPostBack {
|
|||
}
|
||||
}
|
||||
|
||||
//查询单据在星空的是否存在下游 返回boolean值(true为不允许下推)
|
||||
public Boolean checkOaBillExist(String billId,String fid) throws IOException {
|
||||
Boolean result = false;
|
||||
|
||||
//查询单据是否存在下游
|
||||
// 目标URL
|
||||
String url = sysConfigService.selectConfigByKey("OA_Url")+"/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
|
||||
String jsonInputString = "";
|
||||
switch (billId){
|
||||
case "SAL_DELIVERYNOTICE":
|
||||
jsonInputString = "{\n" +
|
||||
" \"data\": {\n" +
|
||||
" \"FormId\": \"SAL_DELIVERYNOTICE\",\n" +
|
||||
" \"FieldKeys\": \"FJoinOutQty\",\n" +
|
||||
" \"OrderString\": \"\",\n" +
|
||||
" \"FilterString\": \"FID = "+fid+"\",\n" +
|
||||
" \"TopRowCount\": 0,\n" +
|
||||
" \"StartRow\": 0,\n" +
|
||||
" \"Limit\": 2000,\n" +
|
||||
" \"SubSystemId\": \"\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
break;
|
||||
case "PUR_ReceiveBill":
|
||||
jsonInputString = "{\n" +
|
||||
" \"data\": {\n" +
|
||||
" \"FormId\": \"PUR_ReceiveBill\",\n" +
|
||||
" \"FieldKeys\": \"FInStockJoinQty\",\n" +
|
||||
" \"OrderString\": \"\",\n" +
|
||||
" \"FilterString\": \"FID = "+fid+"\",\n" +
|
||||
" \"TopRowCount\": 0,\n" +
|
||||
" \"StartRow\": 0,\n" +
|
||||
" \"Limit\": 2000,\n" +
|
||||
" \"SubSystemId\": \"\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (jsonInputString.isEmpty()) return result;
|
||||
|
||||
String oaData = sendPostRequest(url, jsonInputString);
|
||||
|
||||
//查询的参数为FJoinOutQty/FInStockJoinQty,这两者如果有存在大于0的情况或者存在什么也没查到的情况就返回true
|
||||
JSONArray dataList = JSONArray.parseArray(oaData);
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
JSONArray row = dataList.getJSONArray(i);
|
||||
Integer joinQty = row.getInteger(0);
|
||||
if (joinQty > 0) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue