|
@@ -7,6 +7,7 @@ import kd.bos.entity.EntityMetadataCache;
|
|
import kd.bos.logging.Log;
|
|
import kd.bos.logging.Log;
|
|
import kd.bos.logging.LogFactory;
|
|
import kd.bos.logging.LogFactory;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.orm.query.QFilter;
|
|
|
|
+import kd.bos.sdk.util.KHttpClientUtils;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -15,6 +16,7 @@ import java.sql.Timestamp;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
|
+import nckd.base.helper.CommonHelperUtils;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
|
|
@@ -461,9 +463,31 @@ public class PayBillToolUtil {
|
|
|
|
|
|
/***************************************add by wanghaiwu 20225/05/24*************************************************************/
|
|
/***************************************add by wanghaiwu 20225/05/24*************************************************************/
|
|
|
|
|
|
|
|
+
|
|
|
|
+ Map<String, String> tokenMap = getNtscToken();
|
|
|
|
+
|
|
|
|
+ if(tokenMap == null){
|
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
|
+ errMsg.append(",错误原因:").append("接口异常, 获取token失败");
|
|
|
|
+ errMsg.append("\r\n");
|
|
|
|
+ return errMsg.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!"0".equals(tokenMap.get("code"))){
|
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
|
+ errMsg.append(",错误原因:").append("接口异常, 获取token失败, " + tokenMap.get("msg"));
|
|
|
|
+ errMsg.append("\r\n");
|
|
|
|
+ return errMsg.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String token = tokenMap.get("msg");
|
|
|
|
+
|
|
//改成调用轻舟的方式
|
|
//改成调用轻舟的方式
|
|
Map<String, String> header = new HashMap<>();
|
|
Map<String, String> header = new HashMap<>();
|
|
header.put("Content-Type", "application/json; charset=UTF-8");
|
|
header.put("Content-Type", "application/json; charset=UTF-8");
|
|
|
|
+ header.put("Authorization", "Bearer " + token);
|
|
|
|
|
|
//如果是esb接口,需要包一层参数
|
|
//如果是esb接口,需要包一层参数
|
|
if(isESBApi) {
|
|
if(isESBApi) {
|
|
@@ -699,8 +723,31 @@ public class PayBillToolUtil {
|
|
|
|
|
|
/***************************************add by wanghaiwu 20225/05/24*************************************************************/
|
|
/***************************************add by wanghaiwu 20225/05/24*************************************************************/
|
|
//改成调用restful ebs api的方式
|
|
//改成调用restful ebs api的方式
|
|
|
|
+
|
|
|
|
+ Map<String, String> tokenMap = getNtscToken();
|
|
|
|
+
|
|
|
|
+ if(tokenMap == null){
|
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
|
+ errMsg.append(",错误原因:").append("接口异常, 获取token失败");
|
|
|
|
+ errMsg.append("\r\n");
|
|
|
|
+ return errMsg.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!"0".equals(tokenMap.get("code"))){
|
|
|
|
+ errMsg.append("单据号:").append(billNum).append(",推送资金系统失败,");
|
|
|
|
+ errMsg.append("错误号:").append("XXXXXXX");
|
|
|
|
+ errMsg.append(",错误原因:").append("接口异常, 获取token失败, " + tokenMap.get("msg"));
|
|
|
|
+ errMsg.append("\r\n");
|
|
|
|
+ return errMsg.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String token = tokenMap.get("msg");
|
|
|
|
+
|
|
|
|
+ //改成调用轻舟的方式
|
|
Map<String, String> header = new HashMap<>();
|
|
Map<String, String> header = new HashMap<>();
|
|
header.put("Content-Type", "application/json; charset=UTF-8");
|
|
header.put("Content-Type", "application/json; charset=UTF-8");
|
|
|
|
+ header.put("Authorization", "Bearer " + token);
|
|
|
|
|
|
//如果是esb接口,需要包一层参数
|
|
//如果是esb接口,需要包一层参数
|
|
if(isESBApi) {
|
|
if(isESBApi) {
|
|
@@ -986,6 +1033,69 @@ public class PayBillToolUtil {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static Map<String,String> getNtscToken() {
|
|
|
|
+ Map<String,String> returnMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ Map<String, String> mapentity = CommonHelperUtils.getCommonParams("ntsc");
|
|
|
|
+ if(mapentity == null ){
|
|
|
|
+ log.info("PayBillTollUtil:nckd_entryentity is null");
|
|
|
|
+
|
|
|
|
+ returnMap.put("code", "1");
|
|
|
|
+ returnMap.put("msg", "未配置SRM系统对接参数!");
|
|
|
|
+ return returnMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String getTokenApi = mapentity.get("gettoken");
|
|
|
|
+ String grantType = mapentity.get("grant_type");
|
|
|
|
+ String clientId = mapentity.get("client_id");
|
|
|
|
+ String clientSecret = mapentity.get("client_secret");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(kd.bos.util.StringUtils.isEmpty(getTokenApi) || kd.bos.util.StringUtils.isEmpty(grantType)
|
|
|
|
+ || kd.bos.util.StringUtils.isEmpty(clientId) || kd.bos.util.StringUtils.isEmpty(clientSecret)){
|
|
|
|
+ returnMap.put("code", "1");
|
|
|
|
+ returnMap.put("msg", "请检查是否配置九恒星获取token参数:gettoken、grant_type、client_id、client_secret");
|
|
|
|
+ return returnMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ JSONObject jsonData = new JSONObject();
|
|
|
|
+ jsonData.put("grant_type", grantType);
|
|
|
|
+ jsonData.put("client_id", clientId);
|
|
|
|
+ jsonData.put("client_secret", clientSecret);
|
|
|
|
+
|
|
|
|
+ String response = KHttpClientUtils.postjson(getTokenApi, null, jsonData.toString());
|
|
|
|
+ if(StringUtils.isEmpty(response)){
|
|
|
|
+ returnMap.put("code", "1");
|
|
|
|
+ returnMap.put("msg", "获取token失败, getToken返回为空");
|
|
|
|
+
|
|
|
|
+ return returnMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject resultJSON = new JSONObject(response);
|
|
|
|
+ if (resultJSON !=null &&!StringUtils.isEmpty(resultJSON.get("access_token").toString())) {
|
|
|
|
+ returnMap.put("code", "0");
|
|
|
|
+ returnMap.put("msg", resultJSON.get("access_token").toString());
|
|
|
|
+ } else{
|
|
|
|
+ returnMap.put("code","1");
|
|
|
|
+ returnMap.put("msg", response);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return returnMap;
|
|
|
|
+ } catch(IOException e){
|
|
|
|
+ returnMap.put("code", "1");
|
|
|
|
+ returnMap.put("msg", "获取token失败, " + e.getMessage());
|
|
|
|
+
|
|
|
|
+ return returnMap;
|
|
|
|
+ } catch(Exception e){
|
|
|
|
+ returnMap.put("code", "1");
|
|
|
|
+ returnMap.put("msg", "获取token失败, " + e.getMessage());
|
|
|
|
+
|
|
|
|
+ return returnMap;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
public static String buildEsbApiBodyJSON(JSONObject inputData){
|
|
public static String buildEsbApiBodyJSON(JSONObject inputData){
|
|
JSONObject jsonBody = new JSONObject();
|
|
JSONObject jsonBody = new JSONObject();
|