|
@@ -1,4 +1,5 @@
|
|
|
package fi.cas.opplugin;
|
|
|
+import com.kingdee.util.StringUtils;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
import kd.bos.encrypt.Encrypters;
|
|
@@ -6,6 +7,7 @@ import kd.bos.entity.EntityMetadataCache;
|
|
|
import kd.bos.logging.Log;
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.sdk.util.KHttpClientUtils;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
|
|
import java.io.*;
|
|
@@ -16,6 +18,7 @@ import java.util.*;
|
|
|
|
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
+import nckd.base.helper.CommonHelperUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
@@ -182,7 +185,7 @@ public class PayBillToolUtil {
|
|
|
param.put("data", data);
|
|
|
param.put("txDateTime", Utils.getData(new Date(), "yyyyMMddHHmmss"));
|
|
|
param.put("batchNo", TypeUtils.nullToString(info.get("billno")) + "-" + TypeUtils.nullToString(info.get("nckd_bbh")) + "-" + Utils.getData(new Date(), "yyyyMMddHHmmss"));
|
|
|
- param.put("code", "NSTC-T003");
|
|
|
+ param.put("code", "JY-NSTC-T003");
|
|
|
|
|
|
return param.toString();
|
|
|
} catch (Exception e) {
|
|
@@ -437,10 +440,59 @@ public class PayBillToolUtil {
|
|
|
url = "http://172.16.150.71:7081/FDLKF_OUTER/webservice/TxServiceGateway";
|
|
|
}
|
|
|
Date dd = new Date();
|
|
|
- JSONObject cbsReturnJson = httpjhxService(url, qjjson);
|
|
|
- log.info("单据号:" + billNum + "返回参数" + cbsReturnJson.toString());
|
|
|
+
|
|
|
+
|
|
|
+// JSONObject cbsReturnJson = httpjhxService(url, qjjson);
|
|
|
+// log.info("单据号:" + billNum + "返回参数" + cbsReturnJson.toString());
|
|
|
+// //存入日志表
|
|
|
+// saveAgentlog(payBillEntity, qjjson, cbsReturnJson.toString(), "1");
|
|
|
+
|
|
|
+ /***************************************add by wanghaiwu 20225/05/24*************************************************************/
|
|
|
+
|
|
|
+ //改成调用轻舟的方式
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("Content-Type", "application/json; charset=UTF-8");
|
|
|
+
|
|
|
+ String bodyString = buildEsbApiBodyJSON(new JSONObject(qjjson));
|
|
|
+ String apiResult = "";
|
|
|
+ try {
|
|
|
+ apiResult = KHttpClientUtils.postjson(url, header, bodyString);
|
|
|
+ } catch (IOException e) {
|
|
|
+// throw new RuntimeException(e);
|
|
|
+
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
+ errMsg.append(",错误原因:").append("接口无法连通,未获取到返回结果");
|
|
|
+ errMsg.append("\r\n");
|
|
|
+ return errMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(apiResult)){
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
+ errMsg.append(",错误原因:").append("接口无法连通,未获取到返回结果");
|
|
|
+ errMsg.append("\r\n");
|
|
|
+
|
|
|
+ return errMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("单据号:" + billNum + "返回参数" + apiResult);
|
|
|
//存入日志表
|
|
|
- saveAgentlog(payBillEntity, qjjson, cbsReturnJson.toString(), "1");
|
|
|
+ saveAgentlog(payBillEntity, qjjson, apiResult, "1");
|
|
|
+
|
|
|
+ JSONObject apiResultJSON = new JSONObject(apiResult);
|
|
|
+ if(apiResultJSON.get("responseData") == null || apiResultJSON.getJSONArray("responseData").length() == 0){
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
+ errMsg.append(",错误原因:").append("接口无法连通,未获取到返回结果");
|
|
|
+ errMsg.append("\r\n");
|
|
|
+
|
|
|
+ return errMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject cbsReturnJson = apiResultJSON.getJSONArray("responseData").getJSONObject(0);
|
|
|
+
|
|
|
+ /************************************************************/
|
|
|
|
|
|
if (cbsReturnJson == null) {
|
|
|
isSuccess = false;
|
|
@@ -576,9 +628,9 @@ public class PayBillToolUtil {
|
|
|
String settletype = payBillEntity.get("settletype.number") + "";
|
|
|
if (settletype != null && !"".equals(settletype)) {
|
|
|
if (settletype.equals("BILL")) {//票据
|
|
|
- JKNO = "NSTC-T002";
|
|
|
+ JKNO = "JY-NSTC-T002";
|
|
|
} else {
|
|
|
- JKNO = "NSTC-T001";
|
|
|
+ JKNO = "JY-NSTC-T001";
|
|
|
}
|
|
|
} else {
|
|
|
isZFQZ = false;
|
|
@@ -612,10 +664,57 @@ public class PayBillToolUtil {
|
|
|
}
|
|
|
|
|
|
Date dd = new Date();
|
|
|
- JSONObject cbsReturnJson = httpjhxService(url, qjjson);
|
|
|
- log.info("单据号:" + billNum + "返回参数" + cbsReturnJson.toString());
|
|
|
+// JSONObject cbsReturnJson = httpjhxService(url, qjjson);
|
|
|
+
|
|
|
+// log.info("单据号:" + billNum + "返回参数" + cbsReturnJson.toString());
|
|
|
+// //存入日志表
|
|
|
+// saveAgentlog(payBillEntity, qjjson, cbsReturnJson.toString(), "1");
|
|
|
+
|
|
|
+ /***************************************add by wanghaiwu 20225/05/24*************************************************************/
|
|
|
+ //改成调用restful ebs api的方式
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("Content-Type", "application/json; charset=UTF-8");
|
|
|
+
|
|
|
+ String bodyString = buildEsbApiBodyJSON(new JSONObject(qjjson));
|
|
|
+ String apiResult = "";
|
|
|
+ try {
|
|
|
+ apiResult = KHttpClientUtils.postjson(url, header, bodyString);
|
|
|
+ } catch (IOException e) {
|
|
|
+// throw new RuntimeException(e);
|
|
|
+
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
+ errMsg.append(",错误原因:").append("接口无法连通,未获取到返回结果");
|
|
|
+ errMsg.append("\r\n");
|
|
|
+ return errMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(apiResult)){
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
+ errMsg.append(",错误原因:").append("接口无法连通,未获取到返回结果");
|
|
|
+ errMsg.append("\r\n");
|
|
|
+
|
|
|
+ return errMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("单据号:" + billNum + "返回参数" + apiResult);
|
|
|
//存入日志表
|
|
|
- savelog(payBillEntity, qjjson, cbsReturnJson.toString());
|
|
|
+ savelog(payBillEntity, qjjson, apiResult);
|
|
|
+
|
|
|
+ JSONObject apiResultJSON = new JSONObject(apiResult);
|
|
|
+ if(apiResultJSON.get("responseData") == null || apiResultJSON.getJSONArray("responseData").length() == 0){
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
+ errMsg.append(",错误原因:").append("接口无法连通,未获取到返回结果");
|
|
|
+ errMsg.append("\r\n");
|
|
|
+
|
|
|
+ return errMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject cbsReturnJson = apiResultJSON.getJSONArray("responseData").getJSONObject(0);
|
|
|
+
|
|
|
+ /************************************************************/
|
|
|
|
|
|
|
|
|
if (cbsReturnJson == null) {
|
|
@@ -624,7 +723,9 @@ public class PayBillToolUtil {
|
|
|
errMsg.append("错误号:").append("XXXXXXX");
|
|
|
errMsg.append(",错误原因:").append("接口无法连通,未获取到返回结果");
|
|
|
errMsg.append("\r\n");
|
|
|
- }if (!"000000".equals(cbsReturnJson.get("resultCode"))) {
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"000000".equals(cbsReturnJson.get("resultCode"))) {
|
|
|
isSuccess = false;
|
|
|
String resultCode = cbsReturnJson.get("resultCode")+"";
|
|
|
String resultMsg = cbsReturnJson.get("resultMsg") + "";
|
|
@@ -849,4 +950,32 @@ public class PayBillToolUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static String buildEsbApiBodyJSON(JSONObject inputData){
|
|
|
+ JSONObject jsonBody = new JSONObject();
|
|
|
+
|
|
|
+ //requestHead参数
|
|
|
+ JSONObject requestHead = new JSONObject();
|
|
|
+
|
|
|
+ requestHead.put("system", "");
|
|
|
+ requestHead.put("tenantId", "");
|
|
|
+ requestHead.put("apiversion", "");
|
|
|
+ requestHead.put("timestamp", "");
|
|
|
+ requestHead.put("retrycount", "");
|
|
|
+ requestHead.put("mainBodyId", "JY");
|
|
|
+ requestHead.put("mainBodyEx1", "");
|
|
|
+ requestHead.put("mainBodyEx2", "");
|
|
|
+ requestHead.put("mainBodyEx3", "");
|
|
|
+
|
|
|
+ jsonBody.put("requestHead", requestHead);
|
|
|
+
|
|
|
+ //requestData参数
|
|
|
+ JSONArray requestData = new JSONArray();
|
|
|
+ if(inputData != null) {
|
|
|
+ requestData.put(inputData);
|
|
|
+ }
|
|
|
+ jsonBody.put("requestData", requestData);
|
|
|
+
|
|
|
+ return jsonBody.toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|