/// <summary> /// 调用业务系统接口 推送状态处理 /// </summary> /// <param name="msgItem"></param> /// <returns></returns> private ResponseResultInfo CallBusinessService(ProcessEventMessage msgItem) { PushBusInterfaceModel pushInfo = new PushBusInterfaceModel(); if (msgItem.EventType == ProcessEventEnum.ProcessStarted.ToString()) //流程开始 { pushInfo.actionResult = ActionType.Submit.ToString(); //已提交 } else if (msgItem.EventType == ProcessEventEnum.ActivityStarted.ToString()) //节点开始 { pushInfo.actionResult = ActionType.Approve.ToString(); //同意 if (msgItem.ActivityName == SystemSettings.ReActivity) { //000重新发起环节开始 审批结果为驳回 pushInfo.actionResult = ActionType.Reject.ToString();//驳回 } } else if (msgItem.EventType == ProcessEventEnum.ActivityCompleted.ToString()) //节点结束 { pushInfo.actionResult = ActionType.Approve.ToString(); //同意 if (msgItem.ActivityName == SystemSettings.ReActivity) { pushInfo.actionResult = ActionType.ReSubmit.ToString();//重新提交 } } else if (msgItem.EventType == ProcessEventEnum.ProcessCompleted.ToString()) //流程结束 { pushInfo.actionResult = ActionType.AdminFinalPass.ToString(); //审批通过 if (_formInstanceSevice.IsProcessDelete(msgItem.FormId)) //单据有作废 则 审批结果为作废 { pushInfo.actionResult = ActionType.Cancel.ToString(); //作废 } } else if (msgItem.EventType == ProcessEventEnum.ActivityRejected.ToString()) //节点驳回 { pushInfo.actionResult = ActionType.Reject.ToString(); //驳回 } return(_requestBusinessService.RequestBusInterface(msgItem, pushInfo)); }
/// <summary> /// 初始化 调用业务系统总模型 /// </summary> /// <param name="proEventMsgInfo"></param> /// <param name="pushBusInfo"></param> /// <returns></returns> private BusinessServiceInfo InitBusinessServiceInfo(ProcessEventMessage proEventMsgInfo, PushBusInterfaceModel pushBusInfo) { var busServiceInfo = new BusinessServiceInfo() { ProEventMsgInfo = proEventMsgInfo, ResultInfo = new ResponseResultInfo(), BusInterfaceLog = new Domain.Models.PrcServer_BusinessInterfaceLog() { FormID = proEventMsgInfo.FormId, K2ID = proEventMsgInfo.K2ID, ActivityName = proEventMsgInfo.ActivityName, ActionResult = pushBusInfo.actionResult, EventInterfaceId = proEventMsgInfo.EventInterfaceId.ToString(), RequstID = proEventMsgInfo.RequstID, RequestTime = DateTime.Now, Parameters = Newtonsoft.Json.JsonConvert.SerializeObject(proEventMsgInfo), IsRetry = 0 } }; return(busServiceInfo); }
/// <summary> /// 调用业务服务系统接口 /// </summary> /// <param name="proEventMsg"></param> /// <param name="pushInfo"></param> /// <returns></returns> public ResponseResultInfo RequestBusInterface(ProcessEventMessage proEventMsg, PushBusInterfaceModel pushInfo) { var serviceInfo = InitBusinessServiceInfo(proEventMsg, pushInfo); try { //验证单据是否发起 var formInstanceInfo = _formInstanceSevice.GetPrcFormInstanceByFormId(proEventMsg.FormId); if (formInstanceInfo == null) { serviceInfo.ResultInfo.returnMsg = string.Format("FormId:{0},未获取到表单实例数据。", proEventMsg.FormId); AddBusErrorLog(serviceInfo); return(serviceInfo.ResultInfo); } pushInfo.bizId = formInstanceInfo.BizId; serviceInfo.ProEventMsgInfo.K2ID = pushInfo.k2Id = formInstanceInfo.Folio; serviceInfo.InterfaceConfig = _eventInterfaceService.GetProEventInterfaceInfo(proEventMsg.EventInterfaceId); string param = GetRequstParameter(serviceInfo.InterfaceConfig.DataType, formInstanceInfo.SubmitterAccount, proEventMsg, pushInfo); string responseString = string.Empty; try { serviceInfo.BegInterfaceTime = DateTime.Now; responseString = HttpHelper.HttpPostRequest(serviceInfo.InterfaceConfig.Url, param, 60); serviceInfo.EndInterfaceTime = DateTime.Now; var resInfo = JsonConvert.DeserializeObject <ResultModel <ResponseResultInfo> >(responseString); serviceInfo.ResultInfo = resInfo.resultInfo; AddBusinessInterfaceLog(serviceInfo, param, responseString); } catch (Exception ex) { _logger.Error(ex, $"FormId:{ proEventMsg.FormId }"); serviceInfo.ResultInfo.returnMsg = "访问ESB服务异常;" + ex.Message.ToString(); AddBusErrorLog(serviceInfo, 9, param, responseString); } } catch (Exception ex) { _logger.Error(ex, $"FormId:{ proEventMsg.FormId }"); if (serviceInfo.ResultInfo == null) { serviceInfo.ResultInfo = new ResponseResultInfo() { returnStatus = 500 }; //返回的格式不对 } serviceInfo.ResultInfo.returnMsg = "调用业务接口异常!" + ex.Message; AddBusErrorLog(serviceInfo, 999); } return(serviceInfo.ResultInfo); }
/// <summary> /// 获取请求接口参数字符串 /// </summary> /// <param name="dataType"></param> /// <param name="submitUser"></param> /// <param name="proEventMsgInfo"></param> /// <param name="pushBusInfo"></param> /// <returns></returns> private string GetRequstParameter(string dataType, string submitUser, ProcessEventMessage proEventMsgInfo, PushBusInterfaceModel pushBusInfo) { ResultModel <PushBusInterfaceModel> paramData = new ResultModel <PushBusInterfaceModel>(); string requstParameter = string.Empty; if (dataType == "FormData") { pushBusInfo.actionResult = string.Empty; pushBusInfo.bizData = _formInstanceSevice.GetPrcFormContent(proEventMsgInfo.FormId); } else { var approverInfo = GetApproverInfo(proEventMsgInfo, submitUser, pushBusInfo.actionResult); if (dataType == "ApprovalData") { pushBusInfo.activityName = proEventMsgInfo.ActivityName; pushBusInfo.comment = approverInfo.Comment; } else if (dataType == "FormAndApprovalData") { pushBusInfo.activityName = proEventMsgInfo.ActivityName; pushBusInfo.comment = approverInfo.Comment; pushBusInfo.bizData = _formInstanceSevice.GetPrcFormContent(proEventMsgInfo.FormId); } pushBusInfo.activityName = proEventMsgInfo.ActivityName; pushBusInfo.comment = approverInfo.Comment; } paramData.resultInfo = pushBusInfo; requstParameter = Newtonsoft.Json.JsonConvert.SerializeObject(paramData); return(requstParameter); }