1.OA待办事项优化
2.根据适配规则携带对应分录的业务大类,业务小类,成本中心,利润中心(规则-->付款处理) --s
This commit is contained in:
		
							parent
							
								
									46f31cf0fd
								
							
						
					
					
						commit
						a8ae352a38
					
				|  | @ -0,0 +1,64 @@ | |||
| package shjh.jhzj7.fi.fi.plugin.form; | ||||
| 
 | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.form.plugin.AbstractFormPlugin; | ||||
| import kd.bos.orm.query.QCP; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| 
 | ||||
| import java.util.EventObject; | ||||
| 
 | ||||
| /** | ||||
|  * 付款处理表单插件 | ||||
|  * shjh_cas_paybill_ext | ||||
|  */ | ||||
| public class CasPaybillFormPlugin extends AbstractFormPlugin { | ||||
| 
 | ||||
|     @Override | ||||
|     public void afterBindData(EventObject e) { | ||||
|         super.afterBindData(e); | ||||
| 
 | ||||
|         String sourcebilltype = (String)this.getModel().getValue("sourcebilltype");//源单类型:被动付款入账(bei_intelpay) | ||||
|         if (!"bei_intelpay".equals(sourcebilltype)) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         String sourcebillnumber = (String)this.getModel().getValue("sourcebillnumber");//源单编码:被动付款单号(bei_intelpay) | ||||
|         QFilter q1 = new QFilter("billno", QCP.equals, sourcebillnumber); | ||||
|         DynamicObject beiIntelpay = BusinessDataServiceHelper.loadSingle("bei_intelpay", q1.toArray()); | ||||
|         if (null != beiIntelpay) { | ||||
|             String rulename = beiIntelpay.getString("rulename");//适配规则名称 | ||||
|             //根据适配规则名称查询适配规则 (cas_recpayrule) | ||||
|             // 单据:生单/通知规则(shjh_cas_recpayrule_ext)  单据体:入账规则(entryentity) 字段:规则项名称(e_rulesname) | ||||
|             QFilter q2 = new QFilter("entryentity.e_rulesname", QCP.equals, rulename); | ||||
|             DynamicObject rule = BusinessDataServiceHelper.loadSingle("cas_recpayrule",q2.toArray()); | ||||
|             if (null != rule) { | ||||
|                 //根据适配规则携带对应分录的业务大类,业务小类,成本中心,利润中心 | ||||
|                 DynamicObjectCollection collection = rule.getDynamicObjectCollection("entryentity"); | ||||
|                 for (DynamicObject entry : collection) { | ||||
|                     if (rulename.equals(entry.getString("e_rulesname"))) { | ||||
|                         DynamicObject shjhBizbig = (DynamicObject)this.getModel().getValue("shjh_bizbig"); | ||||
|                         if (null == shjhBizbig) { | ||||
|                             this.getModel().setValue("shjh_bizbig", entry.getDynamicObject("shjh_e_bizbig")); | ||||
|                         } | ||||
|                         DynamicObject shjhBizsmall = (DynamicObject)this.getModel().getValue("shjh_bizsmall"); | ||||
|                         if (null == shjhBizsmall) { | ||||
|                             this.getModel().setValue("shjh_bizsmall", entry.getDynamicObject("shjh_e_bizsmall")); | ||||
|                         } | ||||
|                         DynamicObject shjhCostcenter = (DynamicObject)this.getModel().getValue("shjh_costcenter"); | ||||
|                         if (null == shjhCostcenter) { | ||||
|                             this.getModel().setValue("shjh_costcenter", entry.getDynamicObject("shjh_e_cc")); | ||||
|                         } | ||||
|                         DynamicObject shjhPc = (DynamicObject)this.getModel().getValue("shjh_pc"); | ||||
|                         if (null == shjhPc) { | ||||
|                             this.getModel().setValue("shjh_pc", entry.getDynamicObject("shjh_e_pc")); | ||||
|                         } | ||||
|                         return; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | @ -81,11 +81,24 @@ public class todoZyTaskServiceHandler extends AbstractMessageServiceHandler { | |||
|         List<DynamicObject> approvers = new ArrayList<>(); | ||||
|         List<Long> userIds = toDoInfo.getUserIds(); // 审批人ID集合 | ||||
|         List<DynamicObject> approversLists = getApprovers(userIds, approvers); | ||||
|         StringBuilder numbers = new StringBuilder(); | ||||
|         for (DynamicObject approversList : approversLists) { | ||||
|             String number = approversList.getString("number"); | ||||
|             if (numbers.length() > 0) { | ||||
|                 numbers.append(","); | ||||
|             } | ||||
|             numbers.append(number); | ||||
|         } | ||||
|         String approversNumbers = numbers.toString(); // 按英文逗号分隔拼接的number字符串 | ||||
|         // 获取任务标题 | ||||
|         Map<String, Object> params = toDoInfo.getParams(); | ||||
|         String subjectJson = (String) params.get("subject"); | ||||
|         JSONObject subjectObj = JSONObject.parseObject(subjectJson); | ||||
|         String title = subjectObj.getString("zh_CN"); | ||||
|         String title = ""; | ||||
|         if (null != subjectObj) { | ||||
|             title = subjectObj.getString("zh_CN"); | ||||
|         } | ||||
| 
 | ||||
|         // 节点名称 | ||||
|         String executionName = ""; | ||||
|         DynamicObject execution = BusinessDataServiceHelper.loadSingle(executionId, "wf_execution"); | ||||
|  | @ -106,10 +119,16 @@ public class todoZyTaskServiceHandler extends AbstractMessageServiceHandler { | |||
|         } | ||||
|         // 待办创建时间(格式:yyyy-MM-dd HH:mm:ss) | ||||
|         Date createDate = messageContext.getCreateDate(); | ||||
|         SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||||
|         SimpleDateFormat SDF1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | ||||
|         // 使用 SDF 格式化不用毫秒的时间 | ||||
|         String createDateStr = SDF.format(createDate); | ||||
|         // 使用 SDF1 格式化带毫秒的时间 | ||||
|         String createDateStr1 = SDF1.format(createDate); | ||||
| 
 | ||||
| 
 | ||||
|         Map<String, Object> thirdPartyMap = new HashMap<>(); | ||||
|         thirdPartyMap.put("syscode", "Kingdee");// 异构系统标识 | ||||
|         thirdPartyMap.put("syscode", "jindie");// 异构系统标识 | ||||
|         thirdPartyMap.put("flowid", taskId);// 流程任务ID,流程数据的标识,可自定义 | ||||
|         thirdPartyMap.put("requestname", title);// 标题 | ||||
|         thirdPartyMap.put("approversLists", approversLists);// 审批人集合 | ||||
|  | @ -121,8 +140,10 @@ public class todoZyTaskServiceHandler extends AbstractMessageServiceHandler { | |||
|         thirdPartyMap.put("viewtype", viewType);// 流程查看状态;0:未读,1:已读。 | ||||
|         thirdPartyMap.put("creator", startNumber);// 发起人 | ||||
|         thirdPartyMap.put("createDateStr", createDateStr);// 创建日期时间,格式:yyyy-MM-dd HH:mm:ss | ||||
|         thirdPartyMap.put("createDateStr1", createDateStr1);// 创建日期时间,格式:yyyy-MM-dd HH:mm:ss.SSS | ||||
|         thirdPartyMap.put("receiver", approversNumbers);//接收人,工号 可以传多个,以英文逗号分隔 | ||||
|         thirdPartyMap.put("receivedatetime", createDateStr);// 接收日期时间,格式:yyyy-MM-dd HH:mm:ss | ||||
|         thirdPartyMap.put("billNo", billNo);// 单据编号 | ||||
|         thirdPartyMap.put("billno", billNo);// 单据编号 | ||||
| 
 | ||||
|         return thirdPartyMap; | ||||
|     } | ||||
|  |  | |||
|  | @ -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");//todo:识别被调接口并进行路由 | ||||
|         customerHeader.put("senderID", String.valueOf(thirdPartyMap.get("creator")));//定义的发送者.暂定工号 | ||||
|         customerHeader.put("senderID", "FM");//定义的发送者.暂定工号 | ||||
|         return customerHeader; | ||||
|     } | ||||
| 
 | ||||
|  | @ -63,30 +63,26 @@ public class OAUtils { | |||
|     private static JSONObject buildPendingsBody(Map<String, Object> thirdPartyMap) { | ||||
|         //组装请求体 | ||||
|         JSONObject pendingsBody = new JSONObject(); | ||||
|         pendingsBody.put("rootContextID", "qqqqqq");//todo:唯一事务ID,采用UUID或其他强唯一性ID | ||||
|         pendingsBody.put("requestTime", String.valueOf(thirdPartyMap.get("createdatetime")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS | ||||
|         pendingsBody.put("rootContextID", ""+System.currentTimeMillis());//todo:唯一事务ID,采用UUID或其他强唯一性ID | ||||
|         pendingsBody.put("requestTime", String.valueOf(thirdPartyMap.get("createDateStr1")));//请求时间,格式为yyyy-MM-dd HH:mm:ss.SSS | ||||
| 
 | ||||
|         JSONArray data = new JSONArray(); | ||||
|         //接收人信息 | ||||
|         List<DynamicObject> approversLists = (List<DynamicObject>) thirdPartyMap.get("approversLists"); | ||||
|         for (DynamicObject approver : approversLists) { | ||||
|             JSONObject jsonObject = new JSONObject(); | ||||
|             jsonObject.put("syscode", String.valueOf(thirdPartyMap.get("syscode")));//异构系统标识 | ||||
|             jsonObject.put("flowid", String.valueOf(thirdPartyMap.get("flowid")) + approver.getString("number"));//流程任务ID,流程数据的标识,可自定义 | ||||
|             jsonObject.put("requestname", String.valueOf(thirdPartyMap.get("requestname")));//标题 | ||||
|             jsonObject.put("workflowname", String.valueOf(thirdPartyMap.get("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("createdatetime", String.valueOf(thirdPartyMap.get("createdatetime")));//创建日期时间,格式:yyyy-MM-dd HH:mm:ss | ||||
|             jsonObject.put("receiver", approver.getString("number"));//接收人,工号 | ||||
|             jsonObject.put("receivedatetime", String.valueOf(thirdPartyMap.get("receivedatetime")));//接收日期时间,格式:yyyy-MM-dd HH:mm:ss | ||||
|             data.add(jsonObject); | ||||
|         } | ||||
|         pendingsBody.put("data", data); | ||||
|         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 | ||||
|         pendingsBody.put("data", jsonObject); | ||||
|         return pendingsBody; | ||||
|     } | ||||
| 
 | ||||
|  | @ -108,6 +104,9 @@ public class OAUtils { | |||
|             // 检查JSON对象是否为空 | ||||
|             if (jsonObject != null && !jsonObject.isEmpty()) { | ||||
|                 handleResponse(jsonObject, pendingsBody, thirdPartyMap); | ||||
|             }else { | ||||
|                 logger.info("推送OA消息失败!"); | ||||
|                 saveLog("待办:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             handleException(e, pendingsBody, thirdPartyMap, jsonObject); | ||||
|  | @ -135,14 +134,13 @@ public class OAUtils { | |||
|      * @param thirdPartyMap 第三方数据映射 | ||||
|      */ | ||||
|     private static void handleResponse(JSONObject jsonObject, JSONObject pendingsBody, Map<String, Object> thirdPartyMap) { | ||||
|         JSONArray data1 = jsonObject.getJSONArray("data"); | ||||
|         if (data1 == null || data1.isEmpty()) { | ||||
|         JSONObject data = jsonObject.getJSONObject("data"); | ||||
|         if (data == null || data.isEmpty()) { | ||||
|             logger.info("推送OA消息失败!"); | ||||
|             saveLog("待办:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false); | ||||
|             return; | ||||
|         } | ||||
|         JSONObject jsonobject = data1.getJSONObject(0); | ||||
|         String operResult = jsonobject.getString("operResult"); | ||||
|         String operResult = data.getString("operResult"); | ||||
|         String logMessage = Objects.equals(operResult, "1") ? "金蝶系统推送OA消息成功!" : "金蝶系统推送OA消息失败!"; | ||||
| 
 | ||||
|         // 记录日志 | ||||
|  |  | |||
|  | @ -0,0 +1,165 @@ | |||
| package shjh.jhzj7.fi.fi.utils; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.logging.Log; | ||||
| import kd.bos.logging.LogFactory; | ||||
| import kd.bos.util.HttpClientUtils; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Objects; | ||||
| 
 | ||||
| /** | ||||
|  * SAP集成工具类 | ||||
|  * SAP应付凭证锁定解锁状态回写 | ||||
|  */ | ||||
| public class SapUtils { | ||||
| 
 | ||||
|     public static final String oaUrl = "https://hipint-stg.jahwa.com.cn:6443/gateway/HIP_ReceiveFromFM/1.0/fm/send";//测试环境 | ||||
|     public static final String oaAPIKey = "207b5296-9866-4b4b-8146-1fea58b3c8c9";//测试环境APIKey | ||||
|     private static final Log logger = LogFactory.getLog(SapUtils.class); | ||||
|     private static final String Apimenthod = " SAP应付凭证锁定解锁状态回写接口"; | ||||
| 
 | ||||
|     public static void thirdParty(Map<String, Object> thirdPartyMap) { | ||||
|         // 构建请求头 | ||||
|         Map<String, String> customerHeader = buildCustomerHeader(thirdPartyMap); | ||||
|         // 组装请求体 | ||||
|         JSONObject pendingsBody = buildPendingsBody(thirdPartyMap); | ||||
|         // 发送请求并处理响应 | ||||
|         processRequest(customerHeader, pendingsBody, thirdPartyMap); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 构建请求头 | ||||
|      * @param thirdPartyMap 第三方数据映射 | ||||
|      * @return 请求头映射 | ||||
|      */ | ||||
|     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("interfaceID", "TodoFlow");//todo:识别被调接口并进行路由 | ||||
|         customerHeader.put("senderID", String.valueOf(thirdPartyMap.get("cname")));//TODO:定义的发送者.暂定工号 | ||||
|         return customerHeader; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 组装请求体 | ||||
|      * @param thirdPartyMap 第三方数据映射 | ||||
|      * @return 请求体的 JSON 对象 | ||||
|      */ | ||||
|     private static JSONObject buildPendingsBody(Map<String, Object> thirdPartyMap) { | ||||
|         //组装请求体 | ||||
|         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 | ||||
| 
 | ||||
|         JSONArray data = new JSONArray(); | ||||
|         //todo:多凭证 | ||||
|         List<DynamicObject> approversLists = (List<DynamicObject>) thirdPartyMap.get("approversLists"); | ||||
|         for (DynamicObject approver : approversLists) { | ||||
|             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")));//金蝶单据编号 | ||||
|             data.add(jsonObject); | ||||
|         } | ||||
|         pendingsBody.put("data", data); | ||||
|         return pendingsBody; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 发送请求并处理响应 | ||||
|      * | ||||
|      * @param customerHeader 请求头 | ||||
|      * @param pendingsBody   请求体 | ||||
|      * @param thirdPartyMap  第三方数据映射 | ||||
|      */ | ||||
|     private static void processRequest(Map<String, String> customerHeader, JSONObject pendingsBody, Map<String, Object> thirdPartyMap) { | ||||
|         String pendingPostjson = null; | ||||
|         JSONObject jsonObject = null; | ||||
|         try { | ||||
|             // 发送POST请求并获取响应 | ||||
|             pendingPostjson = HttpClientUtils.postjson(OAUtils.oaUrl, customerHeader, pendingsBody.toJSONString()); | ||||
|             jsonObject = parseResponse(pendingPostjson); | ||||
| 
 | ||||
|             // 检查JSON对象是否为空 | ||||
|             if (jsonObject != null && !jsonObject.isEmpty()) { | ||||
|                 handleResponse(jsonObject, pendingsBody, thirdPartyMap); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             handleException(e, pendingsBody, thirdPartyMap, jsonObject); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 解析响应 JSON 字符串 | ||||
|      * @param response 响应的 JSON 字符串 | ||||
|      * @return 解析后的 JSON 对象 | ||||
|      */ | ||||
|     private static JSONObject parseResponse(String response) { | ||||
|         try { | ||||
|             return JSONObject.parseObject(response); | ||||
|         } catch (Exception e) { | ||||
|             logger.error("解析响应 JSON 时出错: {}", e.getMessage()); | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 处理响应结果 | ||||
|      * @param jsonObject 响应的 JSON 对象 | ||||
|      * @param pendingsBody 请求体 | ||||
|      * @param thirdPartyMap 第三方数据映射 | ||||
|      */ | ||||
|     private static void handleResponse(JSONObject jsonObject, JSONObject pendingsBody, Map<String, Object> thirdPartyMap) { | ||||
|         JSONArray data1 = jsonObject.getJSONArray("data"); | ||||
|         if (data1 == null || data1.isEmpty()) { | ||||
|             logger.info("SAP应付凭证锁定解锁状态回写失败!"); | ||||
|             saveLog("状态回写:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false); | ||||
|             return; | ||||
|         } | ||||
|         JSONObject jsonobject = data1.getJSONObject(0); | ||||
|         String operResult = jsonobject.getString("operResult"); | ||||
|         String logMessage = Objects.equals(operResult, "1") ? "SAP应付凭证锁定解锁状态回写成功!" : "SAP应付凭证锁定解锁状态回写失败!"; | ||||
| 
 | ||||
|         // 记录日志 | ||||
|         logger.info(logMessage); | ||||
|         saveLog("状态回写:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, true); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 处理异常情况 | ||||
|      * @param e 捕获的异常 | ||||
|      * @param pendingsBody 请求体 | ||||
|      * @param thirdPartyMap 第三方数据映射 | ||||
|      * @param jsonObject 响应的 JSON 对象 | ||||
|      */ | ||||
|     private static void handleException(Exception e, JSONObject pendingsBody, Map<String, Object> thirdPartyMap, JSONObject jsonObject) { | ||||
|         // 记录异常信息 | ||||
|         String errorMessage = String.format("待办接口异常:%s", e.getMessage()); | ||||
|         logger.error(errorMessage); | ||||
|         saveLog("状态回写:" + String.valueOf(thirdPartyMap.get("billno")), pendingsBody, jsonObject, false); | ||||
|         throw new RuntimeException(e); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 保存日志 | ||||
|      * | ||||
|      * @param billNo       账单号 | ||||
|      * @param pendingsBody 请求体 | ||||
|      * @param jsonObject   响应的 JSON 对象 | ||||
|      * @param isSuccess    是否成功 | ||||
|      */ | ||||
|     private static void saveLog(String billNo, JSONObject pendingsBody, JSONObject jsonObject, boolean isSuccess) { | ||||
|         JhzjUtils.saveLog(billNo, Apimenthod, pendingsBody.toJSONString(), | ||||
|                 jsonObject != null ? jsonObject.toJSONString() : "{}", isSuccess, "API"); | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue