using DotNetCore.CAP; using Hotline.DataSharing; using Hotline.DataSharing.Province; using Hotline.DataSharing.Province.Extend; using Hotline.DataSharing.Province.Notifications; using Hotline.DataSharing.Province.XieTong.Receive; using Hotline.DataSharing.Province.XieTong.Send; using Hotline.Share.Dtos.DataSharing; using Hotline.Share.Dtos.DataSharing.Province; using Hotline.Share.Dtos.DataSharing.Province.XieTong.Receive; using Hotline.Share.Dtos.Order; using Hotline.Share.Enums.Order; using MapsterMapper; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using XF.Domain.Filters; using XF.Domain.Repository; namespace Hotline.Api.Controllers.DataSharing { /// /// 下行,省平台调用 /// public class ProvinceController : BaseController { #region 注入 private readonly IMapper _mapper; private readonly IMediator _mediator; private readonly IRepository _formEnvironMentRepository; private readonly IRepository _formTrafficRepository; private readonly IRepository _formExpressWayRepository; private readonly IRepository _formMedicalRepository; private readonly IRepository _formNetWorktecRepository; private readonly IRepository _formPostRepository; private readonly IRepository _formReturnexChangeRepository; private readonly IRepository _formShamPubRepository; private readonly IRepository _formTaxationComplaintRepository; private readonly IRepository _formTaxationConsultingRepository; private readonly IRepository _receiveCaseExtendsRepository; private readonly IRepository _getCaseMaterialInfoRepository; private readonly IRepository _sendCaseInfoRepository; private readonly IRepository _getCaseBackApplyRepository; private readonly IChannelConfigurationManager _channelConfigurationManager; private readonly IRepository _dsReceiveProvinceDataRepository; /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public ProvinceController(IMapper mapper, IMediator mediator, IRepository formEnvironMentRepository, IRepository formTrafficRepository, IRepository formExpressWayRepository, IRepository formMedicalRepository, IRepository formNetWorktecRepository, IRepository formPostRepository, IRepository formReturnexChangeRepository, IRepository formShamPubRepository, IRepository formTaxationComplaintRepository, IRepository formTaxationConsultingRepository, IRepository receiveCaseExtendsRepository, IRepository getCaseMaterialInfoRepository, IRepository sendCaseInfoRepository, IRepository getCaseBackApplyRepository, IChannelConfigurationManager channelConfigurationManager, IRepository dsReceiveProvinceDataRepository) { _mapper = mapper; _mediator = mediator; _formEnvironMentRepository = formEnvironMentRepository; _formTrafficRepository = formTrafficRepository; _formExpressWayRepository = formExpressWayRepository; _formMedicalRepository = formMedicalRepository; _formNetWorktecRepository = formNetWorktecRepository; _formPostRepository = formPostRepository; _formReturnexChangeRepository = formReturnexChangeRepository; _formShamPubRepository = formShamPubRepository; _formTaxationComplaintRepository = formTaxationComplaintRepository; _formTaxationConsultingRepository = formTaxationConsultingRepository; _receiveCaseExtendsRepository = receiveCaseExtendsRepository; _getCaseMaterialInfoRepository = getCaseMaterialInfoRepository; _sendCaseInfoRepository = sendCaseInfoRepository; _getCaseBackApplyRepository = getCaseBackApplyRepository; _channelConfigurationManager = channelConfigurationManager; _dsReceiveProvinceDataRepository = dsReceiveProvinceDataRepository; } #endregion /// /// 服务工单交办接口--已完成-----1 /// /// /// [HttpPost("rest/receive_case_info")] [AllowAnonymous] public async Task ReceiveCaseInfo([FromBody] ReceiveCaseInfoRequest receiveCaseInfo) { // 验证 if (receiveCaseInfo is null || receiveCaseInfo.paras is null) { return OpenResponse.Ok(Reponse.Failed("数据解析失败")); } //验证接收的数据是否正确 string strResult = receiveCaseInfo.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveCaseInfo.paras; var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "receive_case_info", System.Text.Json.JsonSerializer.Serialize(dto)); //处理组装数据,推送数据 var data = _mapper.Map(dto); if (dto.TrowGuid != "【政民互动直派】") data.IsProvince = true; //处理性别 switch (dto.AppLicantSex) { case "0": data.FromGender = EGender.Female; break; case "1": data.FromGender = EGender.Male; break; case "2": data.FromGender = EGender.Unknown; break; default: data.FromGender = EGender.Unknown; break; } //处理证件类型 switch (dto.CertifiCateType) { case "10": data.LicenceTypeCode = "10"; break; case "20": data.LicenceTypeCode = "40"; break; case "30": data.LicenceTypeCode = "55"; break; case "40": data.LicenceTypeCode = "57"; break; } data.AcceptTypeCode = dto.CaseType; //处理紧急程度 switch (dto.CaseIsUrgent) { case "10": data.EmergencyLevel = EEmergencyLevel.QuiteEmergency; break; case "20": data.EmergencyLevel = EEmergencyLevel.Emergency; break; case "30": data.EmergencyLevel = EEmergencyLevel.Normal; break; } //经纬度处理 var lngLat = dto.CaseLngLat.Split(','); if (lngLat != null && lngLat.Length == 2) { data.Longitude = Convert.ToDouble(lngLat[0]); data.Latitude = Convert.ToDouble(lngLat[1]); } if (!string.IsNullOrEmpty(id)) { //调用工单创建接口 var result = await _mediator.Send(new ReceiveOrderNotify { AddOrderDto = data }, HttpContext.RequestAborted); if (result != null && !string.IsNullOrEmpty(result.Id)) { return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单退回反馈接口--已完成-----1 /// /// 退回反馈 /// [HttpPost("get_case_back_result")] [AllowAnonymous] public async Task GetCaseBackResult([FromBody] GetCaseBackResultRequest receiveBackResult) { // 验证 if (receiveBackResult is null || receiveBackResult.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); //验证接收的数据是否正确 string strResult = receiveBackResult.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveBackResult.paras; var data = await _getCaseBackApplyRepository.GetAsync(p => p.CaseSerial == dto.CaseSerial, HttpContext.RequestAborted); if (data == null) return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "get_case_back_result", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { await _mediator.Send(new OrderSendBackResultNotify { OrderSendBackResultDto = new OrderSendBackResultDto() { Id = data.OrderSendBackId, Reason = dto.BackReason, Result = dto.Result == "1" ? 1 : 0 } }, HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 督办工单派发接口--已完成-----1 /// /// 督办工单对象 /// [HttpPost("send_supervise_info")] [AllowAnonymous] public async Task SendSuperviseInfo([FromBody] SendSuperviseInfoRequest receiveSendSuperviseInfo) { // 验证 if (receiveSendSuperviseInfo is null || receiveSendSuperviseInfo.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveSendSuperviseInfo.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveSendSuperviseInfo.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "send_supervise_info", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 await _mediator.Send(new ProvinceOrderSuperviseNotify { ProvinceOrderSuperviseDto = _mapper.Map(dto) }, HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单催单接口--已完成-----1 /// /// 催单对象 /// [HttpPost("remind_case_info")] [AllowAnonymous] public async Task RemindCaseInfo([FromBody] RemindCaseInfoRequest receiveRemindCaseInfo) { // 验证 if (receiveRemindCaseInfo is null || receiveRemindCaseInfo.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveRemindCaseInfo.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveRemindCaseInfo.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "remind_case_info", System.Text.Json.JsonSerializer.Serialize(dto)); // var id = await _remindCaseInfoRepository.AddAsync(dto, HttpContext.RequestAborted); if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 await _mediator.Send(new ProvinceOrderUrgeNotify { ProvinceOrderUrgeDto = _mapper.Map(dto) }, HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单甄别结果接口--已完成-----1 /// /// 服务工单甄别结果对象 /// [HttpPost("screen_case_result_receive")] [AllowAnonymous] public async Task ScreenCaseResultReceive([FromBody] ScreenCaseResultReceiveRequest receiveScreenCaseResultReceive) { // 验证 if (receiveScreenCaseResultReceive is null || receiveScreenCaseResultReceive.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveScreenCaseResultReceive.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveScreenCaseResultReceive.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "screen_case_result_receive", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { await _mediator.Send(new ScreenProvinceResultNotify { ProvinceScreenResult = _mapper.Map(dto) }, HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单延时审核结果接口---已完成-----1 /// /// 延时审核结果对象 /// [HttpPost("delay_case_result_receive")] [AllowAnonymous] public async Task DelayCaseResultReceive([FromBody] DelayCaseResultRequest receiveDelayCaseResult) { // 验证 if (receiveDelayCaseResult is null || receiveDelayCaseResult.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveDelayCaseResult.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveDelayCaseResult.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "delay_case_result_receive", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 await _mediator.Send(new DelayProvinceResultNotify { IsPass = dto.AuditResult == "1", Opinion = dto.AuditOpinion, No = dto.CaseSerial }, HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单交办补充诉求接口 /// /// 交办补充诉求对象 /// [HttpPost("supply_case_info_receive")] [AllowAnonymous] public async Task SupplyCaseInfoReceive([FromBody] SupplyCaseInfoRequest receiveSupplyCaseInfo) { // 验证 if (receiveSupplyCaseInfo is null || receiveSupplyCaseInfo.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveSupplyCaseInfo.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveSupplyCaseInfo.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "supply_case_info_receive", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 //await _capPublisher.PublishAsync(Sharing.Share.Mq.EventNames.SharingOrderSupplements, _mapper.Map(dto), cancellationToken: HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单撤单接口 /// /// 撤单对象 /// [HttpPost("revoke_case_info")] [AllowAnonymous] public async Task RevokeCaseInfo([FromBody] RevokeCaseInfoRequest receiveRevokeCaseInfo) { // 验证 if (receiveRevokeCaseInfo is null || receiveRevokeCaseInfo.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveRevokeCaseInfo.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveRevokeCaseInfo.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "revoke_case_info", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 // await _capPublisher.PublishAsync(Sharing.Share.Mq.EventNames.SharingOrderRevoke, _mapper.Map(dto), cancellationToken: HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单预警接口 /// /// 预警对象 /// [HttpPost("send_warn_info")] [AllowAnonymous] public async Task SendWarnInfo([FromBody] SendWarnInfoRequest receiveSendWarnInfo) { // 验证 if (receiveSendWarnInfo is null || receiveSendWarnInfo.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveSendWarnInfo.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto =receiveSendWarnInfo.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, null, "send_warn_info", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 //await _capPublisher.PublishAsync(Sharing.Share.Mq.EventNames.SharingOrderWarning, _mapper.Map(dto), cancellationToken: HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 交办工单满意度接收接口 /// /// 交办工单满意度对象 /// [HttpPost("send_case_evl_result")] [AllowAnonymous] public async Task SendCaseEvlResult([FromBody] SendCaseEvlResultRequest receiveSendCaseEvlResult) { // 验证 if (receiveSendCaseEvlResult is null || receiveSendCaseEvlResult.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveSendCaseEvlResult.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveSendCaseEvlResult.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, null, "send_case_evl_result", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 //await _capPublisher.PublishAsync(Sharing.Share.Mq.EventNames.SharingOrderEvlResult, _mapper.Map(dto), cancellationToken: HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 上报工单处理结果/退回接口 /// /// 上报工单处理结果/退回对象 /// [HttpPost] [Route("get_case_result_send")] public async Task GetCaseReultSend([FromBody] GetCaseReultSendRequest receiveGetCaseReultSend) { // 验证 if (receiveGetCaseReultSend is null || receiveGetCaseReultSend.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveGetCaseReultSend.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto =receiveGetCaseReultSend.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "get_case_result_send", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { //查询此工单 var tempData = await _sendCaseInfoRepository.GetAsync(p => p.CaseSerial == dto.CaseSerial, HttpContext.RequestAborted); if (tempData != null) { //将工单的办理状态改为办理完成,终止拉取办理信息 tempData.IsEnd = true; await _sendCaseInfoRepository.UpdateAsync(tempData, HttpContext.RequestAborted); } //向业务系统推送消息 //await _capPublisher.PublishAsync(Sharing.Share.Mq.EventNames.SharingOrderReultSend, _mapper.Map(dto), cancellationToken: HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 上报工单评价接口 /// /// 上报工单评价对象 /// [HttpPost] [Route("get_visit_info_send")] [AllowAnonymous] public async Task GetVisitInfoSend([FromBody] GetVisitInfoSendRequest receiveGetVisitInfoSend) { // 验证 if (receiveGetVisitInfoSend is null || receiveGetVisitInfoSend.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveGetVisitInfoSend.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); //转换数据 var dto = receiveGetVisitInfoSend.paras; //添加数据 var id = await InitReceiveProvinceData(dto.CaseSerial, dto.CliengGuid, "get_visit_info_send", System.Text.Json.JsonSerializer.Serialize(dto)); if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 // await _capPublisher.PublishAsync(Sharing.Share.Mq.EventNames.SharingOrderVisitInfo, _mapper.Map(dto), cancellationToken: HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单拓展信息交办---已完成-----1 /// /// 服务工单拓展信息交办 /// [HttpPost] [Route("rest/receive_case_extends")] [AllowAnonymous] public async Task ReceiveCaseExtends([FromBody] ReceiveCaseExtendsRequest receiveCaseExtendsRequest) { // 验证 if (receiveCaseExtendsRequest is null || receiveCaseExtendsRequest.paras is null) return OpenResponse.Ok(Reponse.Failed("数据解析失败")); string strResult = receiveCaseExtendsRequest.paras.Validate(); if (!string.IsNullOrEmpty(strResult)) return OpenResponse.Ok(Reponse.Failed(strResult)); var data = receiveCaseExtendsRequest.paras; //添加数据 var id = await InitReceiveProvinceData(data.CaseSerial, null, "receive_case_extends", System.Text.Json.JsonSerializer.Serialize(data)); OrderExtensionDto orderExtension = new() { ProvinceNo = data.CaseSerial, OrderTypeCode = data.FormType.ToLower() }; //扩展信息写入 switch (data.FormType.ToLower()) { case "yl"://医疗表单 //转换数据 orderExtension = _mapper.Map(data.FormMedical); orderExtension.OrderType = "医疗服务中心受理单"; break; case "zwfw"://四川政务服务网技术工单 //转换数据 orderExtension = _mapper.Map(data.FormNetWorktec); orderExtension.OrderType = "四川政务服务网技术中心受理单"; break; case "th"://电视购物及商铺购买退换货工单 //转换数据 orderExtension = _mapper.Map(data.FormReturnexChange); orderExtension.OrderType = "电视购物及商铺购买退换货中心受理单"; break; case "gsgl"://高速公路工单 //转换数据 orderExtension = _mapper.Map(data.FormExpressWay); orderExtension.OrderType = "高速公路投诉中心受理单"; break; case "xjgg"://电视台虚假广告工单 //转换数据 orderExtension = _mapper.Map(data.FormShamPub); orderExtension.OrderType = "电视台虚假广告中心受理单"; break; case "swfwsq"://12366热线诉求交办 //转换数据 orderExtension = _mapper.Map(data.FormTaxationComplaint); orderExtension.OrderType = "四川省12366热线诉求交办单"; break; case "swfwzx"://12366热线咨询交办 //转换数据 orderExtension = _mapper.Map(data.FormTaxationConsulting); orderExtension.OrderType = "四川省12366热线咨询交办单"; break; case "jtfwjd"://12328服务监督 //转换数据 orderExtension = _mapper.Map(data.FormTraffic); orderExtension.OrderType = "12328服务监督中心受理单"; break; case "yzxf"://邮政业消费者申诉 //转换数据 orderExtension = _mapper.Map(data.FormPost); orderExtension.OrderType = "邮政业消费者申诉受理单"; break; case "hbjb"://环保举报业务 //转换数据 orderExtension = _mapper.Map(data.FormEnvironMent); orderExtension.OrderType = "环保举报业务受理单"; break; case "scjgj"://12315个性化表单 break; default: break; } if (!string.IsNullOrEmpty(id)) { //向业务系统推送消息 await _mediator.Send(new ReceiveOrderExtensionNotify { OrderExtensionDto = orderExtension }, HttpContext.RequestAborted); return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } else return OpenResponse.Ok(Reponse.Failed("接口调用失败!")); } /// /// 服务工单材料接口 /// /// 工单材料信息 /// 材料文件 /// [HttpPost] [Route("get_case_material_info")] [AllowAnonymous] public async Task GetCaseMaterialInfo([FromForm] string @params, List files) { // 上传文件为必须 if (files is null || files.Count <= 0) { return OpenResponse.Ok(Reponse.Failed("上传文件为必须")); } // 解析附件信息 var vmCaseMaterialInfo = Newtonsoft.Json.JsonConvert.DeserializeObject(@params); if (vmCaseMaterialInfo is null || vmCaseMaterialInfo.paras is null) { return OpenResponse.Ok(Reponse.Failed("数据解析失败")); } GetCaseMaterialInfoModel tmpCaseMaterialInfo = vmCaseMaterialInfo.paras; // 验证 string strResult = tmpCaseMaterialInfo.Validate(); if (false == string.IsNullOrEmpty(strResult)) { return OpenResponse.Ok(Reponse.Failed(strResult)); } // 文件列表 foreach (var file in files) { //这里需要上文件服务器上传 var businessFileDto = await SendFileData(file); // 新增文件到列表 var materialInfo = new DsGetCaseMaterialInfo() { CaseSerial = tmpCaseMaterialInfo.CaseSerial, MaterialType = tmpCaseMaterialInfo.MaterialType, CliengGuid = tmpCaseMaterialInfo.CliengGuid, AreaCode = tmpCaseMaterialInfo.AreaCode, FileName = file.FileName, FileSize = file.Length, Additions = businessFileDto.id, Path = businessFileDto.path, Direction = "2", SyncState = "1" }; await _getCaseMaterialInfoRepository.AddAsync(materialInfo, HttpContext.RequestAborted); //向业务系统推送消息 // await _capPublisher.PublishAsync(Sharing.Share.Mq.EventNames.SharingFileData, _mapper.Map(materialInfo), cancellationToken: HttpContext.RequestAborted); } return OpenResponse.Ok(Reponse.Success("您已成功提交数据!")); } /// /// 服务工单材料接口--测试 /// /// [HttpPost] [Route("get_case_material_info_test")] [AllowAnonymous] public async Task GetCaseMaterialInfotest([FromForm] string @params, List files) { return OpenResponse.Ok(Reponse.Failed("数据解析失败")); // return OpenResponse.Ok("ok"); //var businessFile = _channelConfigurationManager.GetConfigurationBusinessFile(); //string result = ""; //byte[] fileContentBytes = null; //try //{ // string url = string.Format("{0}{1}?Source={2}&Id={3}", businessFile.BaseUrl, businessFile.DownloadUrlAddress, businessFile.Source, "08dbf49c-85cd-414b-8f1d-c16a811ed96e"); // using (var client = _httpClientFactory.CreateClient()) // using (var response = await client.GetAsync(url)) // { // if (response.StatusCode == HttpStatusCode.OK) // { // using var memoryStream = new MemoryStream(); // //await file.CopyToAsync(memoryStream); // //memoryStream.Seek(0, SeekOrigin.Begin); // //byte[] fileContentBytes = memoryStream.ToArray(); // await response.Content.CopyToAsync(memoryStream); // memoryStream.Seek(0, SeekOrigin.Begin); // fileContentBytes = memoryStream.ToArray(); // } // } //} //catch (Exception) //{ } //GetCaseMaterialInfoModel dto = new GetCaseMaterialInfoModel() //{ // CaseSerial = "1111111111", // MaterialType = "10", // CliengGuid = "1122222", // AreaCode = "510000" //}; ////组装请求参数 //var model = new GetCaseMaterialInfoRequest //{ // paras = dto, // token = new ClientInfo("11111", "22222") //}; //Dictionary dicParam = new Dictionary(); ////{ //// { "params", "111111" } // 第一个接口参数,json格式字符串 ////}; //// 文件内容 //// byte[] file = Convert.FromBase64String(result);//这里需要获取附件的流 //// 构造字典文件数据 //// 接口参数名称为files //CFormUpload.FileParameter fileParameter = new CFormUpload.FileParameter("files", fileContentBytes, "测试", null); //dicParam.Add("测试", fileParameter); //dicParam.Add("params", System.Text.Json.JsonSerializer.Serialize(model)); //string strUrl = "http://localhost:7051/api/receive/get_case_material_info"; //// 上传附件 //string strResult = CFormUpload.MultipartFormDataPost(strUrl, null, dicParam, ""); //var responseData = Newtonsoft.Json.JsonConvert.DeserializeObject(strResult); //if (responseData != null && responseData.ReturnInfo != null) //{ //} //return OpenResponse.Ok(Reponse.Failed("成功")); //Dictionary dic = new Dictionary(); //dic.Add("MATERIAL_SERIAL", "1234567890"); //服务工单编号 //dic.Add("MATERIAL_TYPE", "1"); //材料类型 //dic.Add("CLIENG_GUID", Guid.NewGuid().ToString()); //材料标识 //dic.Add("AREA_CODE", "510000"); //行政区划代码 //string strParam = e_DicConvertToJson(dic, true); //Dictionary dicParam = new Dictionary(); //// 第一个接口参数,json格式字符串 //dicParam.Add("params", strParam); //// 文件名称 //string fileName = "测试一个附件上传.txt"; //foreach (var file in files) //{ // // 文件内容字节数据 // using var memoryStream = new MemoryStream(); // await file.CopyToAsync(memoryStream); // memoryStream.Seek(0, SeekOrigin.Begin); // byte[] fileContentBytes = memoryStream.ToArray(); // // 构造字典文件数据 // // 接口参数名称为files // CFormUpload.FileParameter fileParameter = new CFormUpload.FileParameter("files", fileContentBytes, fileName, null); // dicParam.Add(fileName, fileParameter); // var a = CFormUpload.MultipartFormDataPost("http://localhost:50100/api/v1/Province/get_case_material_info", null, dicParam, null); //} } #region 私有方法 /// /// 将数据写入表格 /// /// 工单编号 /// 材料标识 /// 接口名称 /// 数据 /// public async Task InitReceiveProvinceData(string CaseSerial, string CliengGuid, string ServiceInterface, string ReceiveData) { DsReceiveProvinceData dsReceive = new DsReceiveProvinceData() { CaseSerial = CaseSerial, CliengGuid = CliengGuid, ServiceInterface = ServiceInterface, ReceiveData = ReceiveData }; return await _dsReceiveProvinceDataRepository.AddAsync(dsReceive, HttpContext.RequestAborted); } /// /// 将文件流上传到附件服务器 /// /// /// private async Task SendFileData(IFormFile file) { var businessFile = _channelConfigurationManager.GetConfigurationBusinessFile(); // 文件名称 string fileName = file.FileName; // 文件内容字节数据 using var memoryStream = new MemoryStream(); await file.CopyToAsync(memoryStream); memoryStream.Seek(0, SeekOrigin.Begin); byte[] fileContentBytes = memoryStream.ToArray(); // 构造字典文件数据 // 接口参数名称为files CFormUpload.FileParameter fileParameter = new CFormUpload.FileParameter("fileData", fileContentBytes, fileName, "multipart/form-data"); Dictionary dicParam = new() { { fileName, fileParameter } }; string url = string.Format("{0}{1}?source={2}", businessFile.BaseUrl, businessFile.UploadUrlAddress, businessFile.Source); var result = CFormUpload.MultipartFormDataPost(url, null, dicParam, ""); if (!string.IsNullOrEmpty(result)) { var resultData = Newtonsoft.Json.JsonConvert.DeserializeObject(result); if (resultData != null && resultData.code == 0) { return resultData.result; } } return new BusinessFileDto(); } #endregion } }