1.接收流程数据:可接收待办、已办、归档的流程数据
2.SAP应付凭证清单 3.SAP应付凭证锁定解锁状态回写 4.生成代扣款记账单接口 --s
This commit is contained in:
parent
c422c87b0f
commit
d8f62a2361
|
|
@ -128,11 +128,11 @@ public class todoZyTaskServiceHandler extends AbstractMessageServiceHandler {
|
|||
|
||||
|
||||
Map<String, Object> thirdPartyMap = new HashMap<>();
|
||||
thirdPartyMap.put("syscode", "jindie");// 异构系统标识
|
||||
// thirdPartyMap.put("syscode", "jindie");// 异构系统标识
|
||||
thirdPartyMap.put("flowid", taskId);// 流程任务ID,流程数据的标识,可自定义
|
||||
thirdPartyMap.put("requestname", title);// 标题
|
||||
thirdPartyMap.put("approversLists", approversLists);// 审批人集合
|
||||
thirdPartyMap.put("workflowname", "流程类型名称");// todo:流程类型名称
|
||||
// thirdPartyMap.put("workflowname", "流程类型名称");// todo:流程类型名称
|
||||
thirdPartyMap.put("nodename", executionName);// 步骤名称(节点名称)
|
||||
thirdPartyMap.put("pcurl", url);// PC地址,第三方系统中流程处理界面的PC端地址
|
||||
thirdPartyMap.put("appurl", appurl);// APP地址,第三方系统中流程处理界面的移动端地址
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class OAUtils {
|
|||
customerHeader.put("Content-Type", "application/json;charset=UTF-8");//请求报文类型
|
||||
customerHeader.put("x-Gateway-APIKey",oaAPIKey);//apiKey,由ESB提供
|
||||
customerHeader.put("interfaceID", "TodoFlow");//识别被调接口并进行路由
|
||||
customerHeader.put("senderID", "FM");//定义的发送者.暂定工号
|
||||
customerHeader.put("senderID", "FM");//定义的发送者
|
||||
return customerHeader;
|
||||
}
|
||||
|
||||
|
|
@ -64,24 +64,24 @@ public class OAUtils {
|
|||
//组装请求体
|
||||
JSONObject pendingsBody = new JSONObject();
|
||||
pendingsBody.put("rootContextID", ""+System.currentTimeMillis());//todo:唯一事务ID,采用UUID或其他强唯一性ID
|
||||
pendingsBody.put("requestTime", String.valueOf(thirdPartyMap.get("createDateStr1")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
|
||||
pendingsBody.put("requestTime", ""+(thirdPartyMap.get("createDateStr1")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("syscode", String.valueOf(thirdPartyMap.get("syscode")));//异构系统标识
|
||||
jsonObject.put("flowid", String.valueOf(thirdPartyMap.get("flowid")));//流程任务ID,流程数据的标识,可自定义
|
||||
jsonObject.put("requestname", String.valueOf(thirdPartyMap.get("requestname")));//标题
|
||||
jsonObject.put("workflowname", "流程类型测试用");//todo:流程类型名称
|
||||
jsonObject.put("nodename", String.valueOf(thirdPartyMap.get("nodename")));//步骤名称(节点名称)
|
||||
jsonObject.put("pcurl", String.valueOf(thirdPartyMap.get("pcurl")));//PC地址,第三方系统中流程处理界面的PC端地址
|
||||
jsonObject.put("appurl", String.valueOf(thirdPartyMap.get("appurl")));//APP地址,第三方系统中流程处理界面的移动端地址
|
||||
jsonObject.put("isremark", String.valueOf(thirdPartyMap.get("isremark")));//流程处理状态;0:待办 ,2:已办 ,4:办结。
|
||||
jsonObject.put("viewtype", String.valueOf(thirdPartyMap.get("viewtype")));//流程查看状态;0:未读,1:已读。
|
||||
// jsonObject.put("creator", String.valueOf(thirdPartyMap.get("creator")));//创建人,工号
|
||||
jsonObject.put("creator", "GH001657");//创建人,工号
|
||||
jsonObject.put("createdatetime", String.valueOf(thirdPartyMap.get("createDateStr")));//创建日期时间,格式:yyyy-MM-dd HH:mm:ss
|
||||
// jsonObject.put("receiver", String.valueOf(thirdPartyMap.get("receiver")));//接收人,工号 可以传多个,以英文逗号分隔
|
||||
jsonObject.put("receiver", "GH001657");//接收人,工号 可以传多个,以英文逗号分隔
|
||||
jsonObject.put("receivedatetime", String.valueOf(thirdPartyMap.get("receivedatetime")));//接收日期时间,格式:yyyy-MM-dd HH:mm:ss
|
||||
jsonObject.put("syscode", "jindie");//异构系统标识
|
||||
jsonObject.put("flowid", ""+(thirdPartyMap.get("flowid")));//流程任务ID,流程数据的标识,可自定义
|
||||
jsonObject.put("requestname", ""+(thirdPartyMap.get("requestname")));//标题
|
||||
jsonObject.put("workflowname", "流程类型测试用");
|
||||
jsonObject.put("nodename", ""+(thirdPartyMap.get("nodename")));//步骤名称(节点名称)
|
||||
jsonObject.put("pcurl", ""+(thirdPartyMap.get("pcurl")));//PC地址,第三方系统中流程处理界面的PC端地址
|
||||
jsonObject.put("appurl", ""+(thirdPartyMap.get("appurl")));//APP地址,第三方系统中流程处理界面的移动端地址
|
||||
jsonObject.put("isremark", ""+(thirdPartyMap.get("isremark")));//流程处理状态;0:待办 ,2:已办 ,4:办结。
|
||||
jsonObject.put("viewtype", ""+(thirdPartyMap.get("viewtype")));//流程查看状态;0:未读,1:已读。
|
||||
jsonObject.put("creator", ""+(thirdPartyMap.get("creator")));//创建人,工号
|
||||
// jsonObject.put("creator", "GH001657");//创建人,工号
|
||||
jsonObject.put("createdatetime", ""+(thirdPartyMap.get("createDateStr")));//创建日期时间,格式:yyyy-MM-dd HH:mm:ss
|
||||
jsonObject.put("receiver", ""+(thirdPartyMap.get("receiver")));//接收人,工号 可以传多个,以英文逗号分隔
|
||||
// jsonObject.put("receiver", "GH001657");//接收人,工号 可以传多个,以英文逗号分隔
|
||||
jsonObject.put("receivedatetime", ""+(thirdPartyMap.get("receivedatetime")));//接收日期时间,格式:yyyy-MM-dd HH:mm:ss
|
||||
pendingsBody.put("data", jsonObject);
|
||||
return pendingsBody;
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ public class OAUtils {
|
|||
JSONObject jsonObject = null;
|
||||
try {
|
||||
// 发送POST请求并获取响应
|
||||
pendingPostjson = HttpClientUtils.postjson(OAUtils.oaUrl, customerHeader, pendingsBody.toJSONString());
|
||||
pendingPostjson = HttpClientUtils.postjson(oaUrl, customerHeader, pendingsBody.toJSONString());
|
||||
jsonObject = parseResponse(pendingPostjson);
|
||||
|
||||
// 检查JSON对象是否为空
|
||||
|
|
@ -106,7 +106,7 @@ public class OAUtils {
|
|||
handleResponse(jsonObject, pendingsBody, thirdPartyMap);
|
||||
}else {
|
||||
logger.info("推送OA消息失败!");
|
||||
saveLog("待办:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false);
|
||||
saveLog("待办:" +(thirdPartyMap.get("billno").toString()), pendingsBody, jsonObject, false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleException(e, pendingsBody, thirdPartyMap, jsonObject);
|
||||
|
|
@ -137,7 +137,7 @@ public class OAUtils {
|
|||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
if (data == null || data.isEmpty()) {
|
||||
logger.info("推送OA消息失败!");
|
||||
saveLog("待办:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false);
|
||||
saveLog("待办:" + (thirdPartyMap.get("billno").toString()), pendingsBody, jsonObject, false);
|
||||
return;
|
||||
}
|
||||
String operResult = data.getString("operResult");
|
||||
|
|
@ -145,7 +145,7 @@ public class OAUtils {
|
|||
|
||||
// 记录日志
|
||||
logger.info(logMessage);
|
||||
saveLog("待办:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, true);
|
||||
saveLog("待办:" + (thirdPartyMap.get("billno").toString()), pendingsBody, jsonObject, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -159,14 +159,14 @@ public class OAUtils {
|
|||
// 记录异常信息
|
||||
String errorMessage = String.format("待办接口异常:%s", e.getMessage());
|
||||
logger.error(errorMessage);
|
||||
saveLog("待办:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false);
|
||||
saveLog("待办:" + (thirdPartyMap.get("billno").toString()), pendingsBody, jsonObject, false);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
*
|
||||
* @param billNo 账单号
|
||||
* @param billNo 单号
|
||||
* @param pendingsBody 请求体
|
||||
* @param jsonObject 响应的 JSON 对象
|
||||
* @param isSuccess 是否成功
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import kd.bos.logging.Log;
|
|||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.util.HttpClientUtils;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -18,17 +19,23 @@ import java.util.Objects;
|
|||
public class SapUtils {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(SapUtils.class);
|
||||
public static final String APIKey = "207b5296-9866-4b4b-8146-1fea58b3c8c9";//测试环境APIKey
|
||||
// public static final String APIKey = "8281da80-b39b-48c4-83bd-f8e480740c6a";//测试环境APIKey
|
||||
private static final String Apimenthod1 = "SAP应付凭证锁定解锁状态回写接口";
|
||||
private static final String interfaceID1 = "PayableVoucherStatus";//识别被调接口并进行路由
|
||||
public static final String unlockedUrl = "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//测试环境(SAP应付凭证锁定解锁状态回写)
|
||||
// public static final String unlockedUrl = "https://hipint.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//正式环境
|
||||
// public static final String unlockedUrl = "https://hipint.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//正式环境
|
||||
private static final String Apimenthod2 = "SAP应付凭证清单接口";
|
||||
public static final String vouchersUrl = "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//测试环境(SAP应付凭证清单接口)
|
||||
// public static final String vouchersUrl = "https://hipint.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//正式环境
|
||||
public static final String oaAPIKey = "207b5296-9866-4b4b-8146-1fea58b3c8c9";//测试环境APIKey
|
||||
// public static final String oaAPIKey = "8281da80-b39b-48c4-83bd-f8e480740c6a";//测试环境APIKey
|
||||
|
||||
|
||||
private static final String interfaceID2 = "ZFS_GET_AP_OPENITEMS";//识别被调接口并进行路由
|
||||
|
||||
public static final String vouchersUrl = "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//测试环境(SAP应付凭证清单)
|
||||
// public static final String vouchersUrl = "https://hipint.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//正式环境
|
||||
public static final String receiverID1 = "SAP";//定义的发送者
|
||||
private static final String Apimenthod3 = "生成代扣款记账单接口";
|
||||
private static final String interfaceID3 = "FMCreateDKKRecord";//识别被调接口并进行路由
|
||||
public static final String withholdingUrl = "https://hipint-stg.jahwa.com.cn:6443/gateway//HIP_ReceiveFromFM/1.0/fm/send";//测试环境(生成代扣款记账单)
|
||||
// public static final String withholdingUrl = "https://hipint.jahwa.com.cn:6443/gateway//HIP_ReceiveFromFM/1.0/fm/send";//正式环境
|
||||
public static final String receiverID2 = "FeiKong";//定义的发送者
|
||||
|
||||
/**
|
||||
* 构建请求头
|
||||
|
|
@ -38,20 +45,19 @@ public class SapUtils {
|
|||
private static Map<String, String> buildCustomerHeader(Map<String, Object> thirdPartyMap) {
|
||||
Map<String, String> customerHeader = new HashMap<>();
|
||||
customerHeader.put("Content-Type", "application/json;charset=UTF-8");//请求报文类型
|
||||
customerHeader.put("x-Gateway-APIKey",oaAPIKey);//apiKey,由ESB提供
|
||||
customerHeader.put("x-Gateway-APIKey",APIKey);//apiKey,由ESB提供
|
||||
customerHeader.put("interfaceID", ""+thirdPartyMap.get("interfaceID"));//识别被调接口并进行路由
|
||||
customerHeader.put("senderID", ""+thirdPartyMap.get("senderID"));
|
||||
customerHeader.put("receiverID", ""+thirdPartyMap.get("receiverID"));
|
||||
return customerHeader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SAP应付凭证锁定解锁状态回写
|
||||
* @param thirdPartyMap
|
||||
*/
|
||||
public static void unlocked_status(Map<String, Object> thirdPartyMap) {
|
||||
thirdPartyMap.put("interfaceID","PayableVoucherStatus");
|
||||
thirdPartyMap.put("senderID","SAP");
|
||||
thirdPartyMap.put("interfaceID",interfaceID1);
|
||||
thirdPartyMap.put("receiverID",receiverID1);
|
||||
thirdPartyMap.put("URL",unlockedUrl);
|
||||
// 构建请求头
|
||||
Map<String, String> customerHeader = buildCustomerHeader(thirdPartyMap);
|
||||
|
|
@ -70,21 +76,21 @@ public class SapUtils {
|
|||
//组装请求体
|
||||
JSONObject pendingsBody = new JSONObject();
|
||||
pendingsBody.put("rootContextID",""+System.currentTimeMillis());//todo:唯一事务ID,采用UUID或其他强唯一性ID
|
||||
pendingsBody.put("requestTime", String.valueOf(thirdPartyMap.get("createdatetime")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
|
||||
pendingsBody.put("requestTime", ""+(thirdPartyMap.get("createdatetime")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
JSONArray IT_INPUT = new JSONArray();
|
||||
//todo:多凭证
|
||||
List<DynamicObject> approversLists = (List<DynamicObject>) thirdPartyMap.get("approversLists");
|
||||
for (DynamicObject approver : approversLists) {
|
||||
//todo:多
|
||||
List<DynamicObject> Lists = (List<DynamicObject>) thirdPartyMap.get("Lists");
|
||||
for (DynamicObject obj : Lists) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("bukrs", String.valueOf(thirdPartyMap.get("bukrs")));//公司代码
|
||||
jsonObject.put("belnr", String.valueOf(thirdPartyMap.get("belnr")));//会计凭证编号
|
||||
jsonObject.put("gjahr", String.valueOf(thirdPartyMap.get("gjahr")));//会计年度
|
||||
jsonObject.put("stasus", String.valueOf(thirdPartyMap.get("stasus")));//状态 01:锁定,02:解锁,03:关闭,04:退单:05:作废
|
||||
jsonObject.put("cname", String.valueOf(thirdPartyMap.get("cname")));//创建人,工号
|
||||
jsonObject.put("zjddjid", String.valueOf(thirdPartyMap.get("zjddjid")));//金蝶单据ID
|
||||
jsonObject.put("zjddjbh", String.valueOf(thirdPartyMap.get("zjddjbh")));//金蝶单据编号
|
||||
jsonObject.put("bukrs", ""+(thirdPartyMap.get("bukrs")));//公司代码
|
||||
jsonObject.put("belnr", ""+(thirdPartyMap.get("belnr")));//会计凭证编号
|
||||
jsonObject.put("gjahr", ""+(thirdPartyMap.get("gjahr")));//会计年度
|
||||
jsonObject.put("stasus", ""+(thirdPartyMap.get("stasus")));//状态 01:锁定,02:解锁,03:关闭,04:退单:05:作废
|
||||
jsonObject.put("cname", ""+(thirdPartyMap.get("cname")));//创建人,工号
|
||||
jsonObject.put("zjddjid", ""+(thirdPartyMap.get("zjddjid")));//金蝶单据ID
|
||||
jsonObject.put("zjddjbh", ""+(thirdPartyMap.get("zjddjbh")));//金蝶单据编号
|
||||
IT_INPUT.add(jsonObject);
|
||||
}
|
||||
data.put("IT_INPUT",IT_INPUT);
|
||||
|
|
@ -95,18 +101,17 @@ public class SapUtils {
|
|||
|
||||
/**
|
||||
* SAP应付凭证清单接口
|
||||
* @param thirdPartyMap
|
||||
*/
|
||||
public static void vouchers_payable(Map<String, Object> thirdPartyMap) {
|
||||
thirdPartyMap.put("interfaceID","ZFS_GET_AP_OPENITEMS");
|
||||
thirdPartyMap.put("senderID","SAP");
|
||||
thirdPartyMap.put("interfaceID",interfaceID2);
|
||||
thirdPartyMap.put("senderID",receiverID1);
|
||||
thirdPartyMap.put("URL",vouchersUrl);
|
||||
// 构建请求头
|
||||
Map<String, String> customerHeader = buildCustomerHeader(thirdPartyMap);
|
||||
// 组装请求体
|
||||
JSONObject pendingsBody = payableBody(thirdPartyMap);
|
||||
JSONObject payableBody = payableBody(thirdPartyMap);
|
||||
// 发送请求并处理响应
|
||||
processRequest(customerHeader, pendingsBody, thirdPartyMap,Apimenthod2);
|
||||
processRequest(customerHeader, payableBody, thirdPartyMap,Apimenthod2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -118,18 +123,18 @@ public class SapUtils {
|
|||
//组装请求体
|
||||
JSONObject pendingsBody = new JSONObject();
|
||||
pendingsBody.put("rootContextID",""+System.currentTimeMillis());//todo:唯一事务ID,采用UUID或其他强唯一性ID
|
||||
pendingsBody.put("requestTime", String.valueOf(thirdPartyMap.get("createdatetime")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
|
||||
pendingsBody.put("requestTime", ""+(thirdPartyMap.get("createdatetime")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
JSONArray IT_LIST = new JSONArray();
|
||||
//todo:多凭证
|
||||
List<DynamicObject> approversLists = (List<DynamicObject>) thirdPartyMap.get("approversLists");
|
||||
for (DynamicObject approver : approversLists) {
|
||||
//todo:多
|
||||
List<DynamicObject> Lists = (List<DynamicObject>) thirdPartyMap.get("Lists");
|
||||
for (DynamicObject obj : Lists) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("FIELD", String.valueOf(thirdPartyMap.get("FIELD")));//字段
|
||||
jsonObject.put("SIGN", String.valueOf(thirdPartyMap.get("SIGN")));//I:包含 E:排除
|
||||
jsonObject.put("LOW", String.valueOf(thirdPartyMap.get("LOW")));//LOW ,枚举字段所代表值的区间开始值
|
||||
jsonObject.put("HIGH", String.valueOf(thirdPartyMap.get("HIGH")));//HIGH,枚举字段所代表值的区间结束值
|
||||
jsonObject.put("FIELD", ""+(thirdPartyMap.get("FIELD")));//字段
|
||||
jsonObject.put("SIGN", ""+(thirdPartyMap.get("SIGN")));//I:包含 E:排除
|
||||
jsonObject.put("LOW", ""+(thirdPartyMap.get("LOW")));//LOW ,枚举字段所代表值的区间开始值
|
||||
jsonObject.put("HIGH", ""+(thirdPartyMap.get("HIGH")));//HIGH,枚举字段所代表值的区间结束值
|
||||
jsonObject.put("OPTION", "BT");//默认BT
|
||||
IT_LIST.add(jsonObject);
|
||||
}
|
||||
|
|
@ -138,12 +143,80 @@ public class SapUtils {
|
|||
return pendingsBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成代扣款记账单接口
|
||||
*/
|
||||
public static void withholding_billing(Map<String, Object> thirdPartyMap) {
|
||||
thirdPartyMap.put("interfaceID",interfaceID3);
|
||||
thirdPartyMap.put("senderID",receiverID2);
|
||||
thirdPartyMap.put("URL",withholdingUrl);
|
||||
// 构建请求头
|
||||
Map<String, String> customerHeader = buildCustomerHeader(thirdPartyMap);
|
||||
// 组装请求体
|
||||
JSONObject withholdingBody = withholdingBody(thirdPartyMap);
|
||||
// 发送请求并处理响应
|
||||
processRequest(customerHeader, withholdingBody, thirdPartyMap, Apimenthod3);
|
||||
}
|
||||
|
||||
/**
|
||||
* SAP应付凭证清单接口组装请求体:
|
||||
* @param thirdPartyMap 第三方数据映射
|
||||
* @return 请求体的 JSON 对象
|
||||
*/
|
||||
private static JSONObject withholdingBody(Map<String, Object> thirdPartyMap) {
|
||||
//组装请求体
|
||||
JSONObject pendingsBody = new JSONObject();
|
||||
pendingsBody.put("rootContextID",""+System.currentTimeMillis());//todo:唯一事务ID,采用UUID或其他强唯一性ID
|
||||
pendingsBody.put("requestTime", ""+(thirdPartyMap.get("createdatetime")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject header = new JSONObject();
|
||||
header.put("FM_RequestBillCode", "DKK");//单据类型编码,固定值:DKK
|
||||
header.put("FM_RequestCode", ""+(thirdPartyMap.get("FM_RequestCode")));//资金系统的申请单号
|
||||
header.put("FM_CompanyCode", ""+(thirdPartyMap.get("FM_CompanyCode")));//公司编码
|
||||
header.put("FM_DeptCode", ""+(thirdPartyMap.get("FM_DeptCode")));//部门编码
|
||||
header.put("FM_UserCode", ""+(thirdPartyMap.get("FM_UserCode")));//员工工号
|
||||
header.put("FM_CreateUserCode", ""+(thirdPartyMap.get("FM_CreateUserCode")));//创建人工号
|
||||
header.put("FM_ExpenseTypeCode", ""+(thirdPartyMap.get("FM_ExpenseTypeCode")));//业务大类编码(EQ49,EQ44,EQ1101)
|
||||
header.put("FM_CurrencyCode", ""+(thirdPartyMap.get("FM_CurrencyCode")));//币种编码,默认:RMB
|
||||
header.put("FM_RequestName", ""+(thirdPartyMap.get("FM_RequestName")));//单据主题
|
||||
header.put("FM_AttachUrl", JSONArray.parse(""+(thirdPartyMap.get("FM_AttachUrl"))));//todo:附件URL地址:array
|
||||
header.put("FM_BudType", Integer.valueOf(""+thirdPartyMap.get("FM_AttachUr")));//预算类别0-组织预算,1-全年预算,当前只处理0 int
|
||||
header.put("Remark", ""+(thirdPartyMap.get("Remark")));//事项描述
|
||||
JSONArray body = new JSONArray();
|
||||
//todo:多
|
||||
List<DynamicObject> Lists = (List<DynamicObject>) thirdPartyMap.get("Lists");
|
||||
for (DynamicObject obj : Lists) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("FM_ClaimAmt", Double.valueOf(""+(thirdPartyMap.get("FM_ClaimAmt"))));//含税金额
|
||||
jsonObject.put("FM_ExcluAmt", Double.valueOf(""+(thirdPartyMap.get("FM_ExcluAmt"))));//未税金额
|
||||
jsonObject.put("FM_VatAmt", Double.valueOf(""+(thirdPartyMap.get("FM_VatAmt"))));//税额
|
||||
jsonObject.put("FM_FiscalYear", Integer.valueOf(""+(thirdPartyMap.get("FM_FiscalYear"))));//费用年度
|
||||
jsonObject.put("FM_FiscalMoth", Integer.valueOf(""+(thirdPartyMap.get("FM_FiscalMoth"))));//费用月度
|
||||
jsonObject.put("FM_ExItemDate1", Date.valueOf(""+thirdPartyMap.get("FM_ExItemDate1")));//业务日期
|
||||
jsonObject.put("FM_SupplierCode", ""+(thirdPartyMap.get("FM_SupplierCode")));//供应商编码,业务大类=EQ49时必填
|
||||
jsonObject.put("FM_CostCenterCode", ""+(thirdPartyMap.get("FM_CostCenterCode")));//成本中心编码,业务大类=EQ49时必填
|
||||
jsonObject.put("FM_ProfitCenterCode", ""+(thirdPartyMap.get("FM_ProfitCenterCode")));//利润中心编码,业务大类=EQ49时必填
|
||||
jsonObject.put("FM_ExpenseItemCode", ""+(thirdPartyMap.get("FM_ExpenseItemCode")));//业务小类编码,业务大类=EQ49时必填
|
||||
jsonObject.put("FM_InvoiceTypeCode", ""+(thirdPartyMap.get("FM_InvoiceTypeCode")));//发票类型编码(普票:INVOICE001,专票:INVOICE002,其它票据:INVOICE003)
|
||||
jsonObject.put("FM_TaxRateCode", ""+(thirdPartyMap.get("FM_TaxRateCode")));//税率编码(传J0时,发票类型选INVOICE003),参考附表
|
||||
jsonObject.put("FM_DetailAttachUrl", JSONArray.parse(""+(thirdPartyMap.get("FM_DetailAttachUrl"))));//todo:附件URL地址:array
|
||||
jsonObject.put("Remark", ""+(thirdPartyMap.get("Remark")));//备注
|
||||
body.add(jsonObject);
|
||||
}
|
||||
data.put("header",header);
|
||||
data.put("body",body);
|
||||
pendingsBody.put("data", data);
|
||||
return pendingsBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送请求并处理响应
|
||||
*
|
||||
* @param customerHeader 请求头
|
||||
* @param pendingsBody 请求体
|
||||
* @param thirdPartyMap 第三方数据映射
|
||||
* @param apiName 接口名称
|
||||
*/
|
||||
private static void processRequest(Map<String, String> customerHeader, JSONObject pendingsBody, Map<String, Object> thirdPartyMap,String apiName) {
|
||||
String pendingPostjson = null;
|
||||
|
|
@ -158,7 +231,7 @@ public class SapUtils {
|
|||
handleResponse(jsonObject, pendingsBody, thirdPartyMap,apiName);
|
||||
}else {
|
||||
logger.info(apiName +"失败!");
|
||||
saveLog(apiName + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false,apiName);
|
||||
saveLog(apiName +(thirdPartyMap.get("billno").toString()), pendingsBody, jsonObject, false,apiName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleException(e, pendingsBody, thirdPartyMap, jsonObject,apiName);
|
||||
|
|
@ -168,6 +241,7 @@ public class SapUtils {
|
|||
/**
|
||||
* 解析响应 JSON 字符串
|
||||
* @param response 响应的 JSON 字符串
|
||||
* @param apiName 接口名称
|
||||
* @return 解析后的 JSON 对象
|
||||
*/
|
||||
private static JSONObject parseResponse(String response,String apiName) {
|
||||
|
|
@ -181,15 +255,16 @@ public class SapUtils {
|
|||
|
||||
/**
|
||||
* 处理响应结果
|
||||
* @param jsonObject 响应的 JSON 对象
|
||||
* @param pendingsBody 请求体
|
||||
* @param thirdPartyMap 第三方数据映射
|
||||
* @param jsonObject 响应的 JSON 对象
|
||||
* @param pendingsBody 请求体
|
||||
* @param thirdPartyMap 第三方数据映射
|
||||
* @param apiName 接口名称
|
||||
*/
|
||||
private static void handleResponse(JSONObject jsonObject, JSONObject pendingsBody, Map<String, Object> thirdPartyMap,String apiName) {
|
||||
JSONArray data1 = jsonObject.getJSONArray("data");
|
||||
if (data1 == null || data1.isEmpty()) {
|
||||
logger.info(apiName + "失败!");
|
||||
saveLog(apiName + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false,apiName);
|
||||
saveLog(apiName + (thirdPartyMap.get("billno").toString()), pendingsBody, jsonObject, false,apiName);
|
||||
return;
|
||||
}
|
||||
JSONObject jsonobject = data1.getJSONObject(0);
|
||||
|
|
@ -198,21 +273,22 @@ public class SapUtils {
|
|||
|
||||
// 记录日志
|
||||
logger.info(logMessage);
|
||||
saveLog(apiName + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, true,apiName);
|
||||
saveLog(apiName + (thirdPartyMap.get("billno").toString()), pendingsBody, jsonObject, true,apiName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理异常情况
|
||||
* @param e 捕获的异常
|
||||
* @param pendingsBody 请求体
|
||||
* @param thirdPartyMap 第三方数据映射
|
||||
* @param jsonObject 响应的 JSON 对象
|
||||
* @param pendingsBody 请求体
|
||||
* @param thirdPartyMap 第三方数据映射
|
||||
* @param jsonObject 响应的 JSON 对象
|
||||
* @param apiName 接口名称
|
||||
*/
|
||||
private static void handleException(Exception e, JSONObject pendingsBody, Map<String, Object> thirdPartyMap, JSONObject jsonObject,String apiName) {
|
||||
// 记录异常信息
|
||||
String errorMessage = String.format(apiName +"状态回写接口异常:%s", e.getMessage());
|
||||
logger.error(errorMessage);
|
||||
saveLog(apiName + thirdPartyMap.get("billno"), pendingsBody, jsonObject, false,apiName);
|
||||
saveLog(apiName + thirdPartyMap.get("billno").toString(), pendingsBody, jsonObject, false,apiName);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
|
@ -223,6 +299,7 @@ public class SapUtils {
|
|||
* @param pendingsBody 请求体
|
||||
* @param jsonObject 响应的 JSON 对象
|
||||
* @param isSuccess 是否成功
|
||||
* @param apiName 接口名称
|
||||
*/
|
||||
private static void saveLog(String billNo, JSONObject pendingsBody, JSONObject jsonObject, boolean isSuccess,String apiName) {
|
||||
JhzjUtils.saveLog(billNo, apiName, pendingsBody.toJSONString(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue