/// <summary> /// 获取当前楼盘报备规则 /// </summary> /// <param name="user"></param> /// <param name="buildingId"></param> /// <returns></returns> public async Task <GatewayInterface.Dto.ResponseMessage <GatewayInterface.Dto.Response.BuildingRuleInfoResponse> > GetBuilidngRule(string buildingId) { using (var scope = ApplicationContext.Current.Provider.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var response = new ApplicationCore.ResponseMessage <XYHShopsPlugin.Dto.Response.BuildingRuleInfoResponse>(); response = await scope.ServiceProvider.GetRequiredService <BuildingRuleController>().GetBuildingRule(buildingId); if (response.Extension == null) { return(null); } var res = new GatewayInterface.Dto.ResponseMessage <GatewayInterface.Dto.Response.BuildingRuleInfoResponse>(); //res.Extension = response.Extension.ValidityDay < 1 ? 1: response.Extension.ValidityDay; //return res; var ss = new GatewayInterface.Dto.Response.BuildingRuleInfoResponse(); ss.Id = response.Extension.Id; ss.AdvanceTime = response.Extension.AdvanceTime; ss.BeltProtectDay = response.Extension.BeltProtectDay < 1 ? 30 : response.Extension.ValidityDay; ss.IsCompletenessPhone = response.Extension.IsCompletenessPhone; ss.IsUse = response.Extension.IsUse; ss.LiberatingEnd = response.Extension.LiberatingEnd; ss.LiberatingStart = response.Extension.LiberatingStart; ss.Mark = response.Extension.Mark; ss.MaxCustomer = response.Extension.MaxCustomer; ss.ReportedTemplate = response.Extension.ReportedTemplate; ss.ReportTime = response.Extension.ReportTime.Value; ss.ValidityDay = response.Extension.ValidityDay < 1 ? 1 : response.Extension.ValidityDay; res.Extension = ss; //未找到映射类型 很烦 return /*Mapper.Map<GatewayInterface.Dto.ResponseMessage<GatewayInterface.Dto.Response.BuildingRuleInfoResponse>>(response)*/ (res); } }
public async Task <ResponseMessage> ExamineTaskCallback([FromBody] ExamineCallbackRequest examineCallbackRequest) { Logger.Trace("收到审核流程回调请求(ExamineTaskCallback)api/examines/flowcallback,请求参数为:\r\n" + (examineCallbackRequest != null ? JsonHelper.ToJson(examineCallbackRequest) : "")); ResponseMessage response = new ResponseMessage(); if (examineCallbackRequest == null) { response.Code = ResponseCodeDefines.ArgumentNullError; response.Message = "参数为空"; Logger.Error($"审核流程回调(ExamineTaskCallback)失败:请求参数ExamineCallbackRequest为空"); return(response); } try { var flow = await _examineFlowManager.FindExamineFlowByTaskGuid(examineCallbackRequest.TaskGuid); if (flow == null) { response.Code = ResponseCodeDefines.NotFound; response.Message = "未找到审核流程"; Logger.Error($"审核流程回调(ExamineTaskCallback)失败:\r\n未找到相应审核流程,\r\n请求参数为:\r\n" + (examineCallbackRequest != null ? JsonHelper.ToJson(examineCallbackRequest) : "")); return(response); } GatewayInterface.Dto.ExamineResponse examineResponse = new GatewayInterface.Dto.ExamineResponse(); examineResponse.ContentId = flow.ContentId; examineResponse.FlowId = flow.Id; examineResponse.ContentType = flow.ContentType; examineResponse.Content = flow.Content; examineResponse.Ext1 = flow.Ext1; examineResponse.Ext2 = flow.Ext2; examineResponse.Ext3 = flow.Ext3; examineResponse.Ext4 = flow.Ext4; examineResponse.Ext5 = flow.Ext5; examineResponse.Ext6 = flow.Ext6; examineResponse.Ext7 = flow.Ext7; examineResponse.Ext8 = flow.Ext8; examineResponse.SubmitDefineId = flow.SubmitDefineId; examineResponse.ExamineStatus = GatewayInterface.Dto.ExamineStatus.Examined; var _shopsInterface = ApplicationContext.Current.Provider.GetRequiredService <IShopsInterface>(); var _customerInterface = ApplicationContext.Current.Provider.GetRequiredService <ICustomerInterface>(); var _contractInterface = ApplicationContext.Current.Provider.GetRequiredService <IContractInterface>(); var response3 = new GatewayInterface.Dto.ResponseMessage(); if (flow.ContentType == "building") { response3 = await _shopsInterface.SubmitBuildingCallback(examineResponse); } else if (flow.ContentType == "shops") { response3 = await _shopsInterface.SubmitShopsCallback(examineResponse); } else if (flow.ContentType == "TransferCustomer") { response3 = await _customerInterface.TransferCallback(examineResponse); } else if (flow.ContentType == "BuildingsOnSite") { response3 = await _shopsInterface.BuildingsOnSiteCallback(examineResponse); } else if (flow.ContentType == "CustomerDeal") { response3 = await _customerInterface.CustomerDealCallback(examineResponse); } else if (flow.ContentType == "ContractCommit") { response3 = await _contractInterface.SubmitContractCallback(examineResponse); } else { response3 = await _shopsInterface.UpdateRecordSubmitCallback(examineResponse); } if (response3.Code != ResponseCodeDefines.SuccessCode) { response.Code = ResponseCodeDefines.ServiceError; response.Message = "回调客户端返回错误:" + response3.Message; Logger.Error($"审核流程回调(ExamineTaskCallback)失败:\r\n审核中心回调相应的应用失败{response3.Message},\r\n请求参数为:\r\n" + (examineCallbackRequest != null ? JsonHelper.ToJson(examineCallbackRequest) : "")); return(response); } var response2 = await _examineFlowManager.FlowCallback(examineCallbackRequest); if (response2.Code != ResponseCodeDefines.SuccessCode) { response.Code = ResponseCodeDefines.ServiceError; response.Message = response2.Message; Logger.Error($"审核流程回调(ExamineTaskCallback)失败:\r\n审核中心保存失败{response2.Message},\r\n请求参数为:\r\n" + (examineCallbackRequest != null ? JsonHelper.ToJson(examineCallbackRequest) : "")); return(response); } } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"审核流程回调(ExamineTaskCallback)失败:\r\n{e.ToString()},\r\n请求参数为:\r\n" + (examineCallbackRequest != null ? JsonHelper.ToJson(examineCallbackRequest) : "")); return(response); } return(response); }
public async Task <ResponseMessage> ExamineReject(UserInfo user, [FromRoute] string recordId, [FromBody] string desc) { Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject),请求体为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); ResponseMessage response = new ResponseMessage(); if (string.IsNullOrEmpty(recordId)) { response.Code = ResponseCodeDefines.ArgumentNullError; return(response); } try { var record = await _examineFlowManager.FindExamineRecordById(recordId); if (record == null) { response.Code = ResponseCodeDefines.NotFound; response.Message = "未找到审核流程"; Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject)失败:\r\n未找到相应的审核记录{response.Message},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); return(response); } GatewayInterface.Dto.ExamineResponse examineResponse = new GatewayInterface.Dto.ExamineResponse(); examineResponse.ContentId = record.ExamineFlow.ContentId; examineResponse.ContentType = record.ExamineFlow.ContentType; examineResponse.FlowId = record.ExamineFlow.Id; examineResponse.Content = record.ExamineFlow.Content; examineResponse.Ext1 = record.ExamineFlow.Ext1; examineResponse.Ext2 = record.ExamineFlow.Ext2; examineResponse.Ext3 = record.ExamineFlow.Ext3; examineResponse.Ext4 = record.ExamineFlow.Ext4; examineResponse.Ext5 = record.ExamineFlow.Ext5; examineResponse.Ext6 = record.ExamineFlow.Ext6; examineResponse.Ext7 = record.ExamineFlow.Ext7; examineResponse.Ext8 = record.ExamineFlow.Ext8; examineResponse.SubmitDefineId = record.ExamineFlow.SubmitDefineId; examineResponse.ExamineStatus = GatewayInterface.Dto.ExamineStatus.Reject; var _shopsInterface = ApplicationContext.Current.Provider.GetRequiredService <IShopsInterface>(); var _customerInterface = ApplicationContext.Current.Provider.GetRequiredService <ICustomerInterface>(); var response3 = new GatewayInterface.Dto.ResponseMessage(); if (record.ExamineFlow.ContentType == "building") { response3 = await _shopsInterface.SubmitBuildingCallback(examineResponse); } else if (record.ExamineFlow.ContentType == "shops") { response3 = await _shopsInterface.SubmitShopsCallback(examineResponse); } else if (record.ExamineFlow.ContentType == "TransferCustomer") { response3 = await _customerInterface.TransferCallback(examineResponse); } else if (record.ExamineFlow.ContentType == "BuildingsOnSite") { response3 = await _shopsInterface.BuildingsOnSiteCallback(examineResponse); } else if (record.ExamineFlow.ContentType == "CustomerDeal") { response3 = await _customerInterface.CustomerDealCallback(examineResponse); } else { response3 = await _shopsInterface.UpdateRecordSubmitCallback(examineResponse); } //var response3 = JsonHelper.ToObject<ResponseMessage>(result); if (response3.Code != ResponseCodeDefines.SuccessCode) { response.Code = ResponseCodeDefines.ServiceError; response.Message = "回调客户端返回错误:" + response3.Message; Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject)失败:\r\n回调相关应用失败{response3.Message},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); return(response); } NameValueCollection nameValueCollection = new NameValueCollection(); nameValueCollection.Add("appToken", "app:nwf"); var taskCallback = new TaskCallback { Message = "", TaskGuid = record.ExamineFlow.TaskGuid, StepID = record.ExamineFlow.CurrentStepId, CallbackProtocol = new FlowProtocol { ProtocolType = "", Protocol = "false" }, Status = TaskStatusEnum.Finished }; Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})审核驳回回调nwf协议:\r\n{0}", JsonHelper.ToJson(taskCallback)); string response4 = await _restClient.Post(ApplicationContext.Current.NWFExamineCallbackUrl, taskCallback, "POST", nameValueCollection); Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})审核驳回回调nwf返回:\r\n{0}", response4); var nwfresponse = JsonHelper.ToObject <ResponseMessage>(response4); if (nwfresponse.Code != "0") { Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})像NWF发起驳回审核请求(ExaminePass)失败:NWF返回失败:\r\n{nwfresponse.Message},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); return(nwfresponse); } var response2 = await _examineFlowManager.ExamineReject(user.Id, recordId, desc); if (response2.Code != ResponseCodeDefines.SuccessCode) { response.Code = ResponseCodeDefines.ServiceError; response.Message = "审核中心处理出错"; Logger.Info($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject)失败:\r\n未找到相应的审核记录{response2.Message},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); return(response); } //发送通知消息 SendMessageRequest sendMessageRequest = new SendMessageRequest(); sendMessageRequest.MessageTypeCode = "ExamineReject"; MessageItem messageItem = new MessageItem(); messageItem.UserIds = new List <string> { record.ExamineFlow.SubmitUserId }; messageItem.MessageTypeItems = new List <TypeItem> { new TypeItem { Key = "NOTICETYPE", Value = ExamineContentTypeConvert.GetContentTypeString(record.ExamineFlow.ContentType) }, new TypeItem { Key = "NAME", Value = record.ExamineFlow.ContentName }, new TypeItem { Key = "TIME", Value = DateTime.Now.ToString("MM-dd hh:mm") } }; sendMessageRequest.MessageList = new List <MessageItem> { messageItem }; try { MessageLogger.Info("发送通知消息协议:\r\n{0}", JsonHelper.ToJson(sendMessageRequest)); _restClient.Post(ApplicationContext.Current.MessageServerUrl, sendMessageRequest, "POST", new NameValueCollection()); } catch (Exception e) { MessageLogger.Error("发送通知消息出错:\r\n{0}", e.ToString()); } } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起审核驳回请求(ExamineReject)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n(recordId){recordId ?? ""},(desc){desc ?? ""}"); } return(response); }