|
@@ -1,10 +1,13 @@
|
|
|
-using DotNetCore.CAP;
|
|
|
-using Hotline.DataSharing;
|
|
|
+using Hotline.DataSharing;
|
|
|
using Hotline.DataSharing.Enterprise;
|
|
|
using Hotline.DataSharing.Order;
|
|
|
+using Hotline.DataSharing.Province;
|
|
|
using Hotline.DataSharing.Province.Notifications;
|
|
|
using Hotline.Share.Dtos.DataSharing;
|
|
|
using Hotline.Share.Dtos.DataSharing.Enterprise.Receive;
|
|
|
+using Hotline.Share.Dtos.DataSharing.Province;
|
|
|
+using Hotline.Share.Dtos.File;
|
|
|
+using Hotline.Share.Dtos.FlowEngine.Workflow;
|
|
|
using MapsterMapper;
|
|
|
using MediatR;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
@@ -25,6 +28,7 @@ namespace Hotline.Api.Controllers.DataSharing
|
|
|
private readonly EnterpriseClient _enterpriseClient;
|
|
|
private readonly IMediator _mediator;
|
|
|
private readonly IRepository<DsOrder> _dataOrderRepository;
|
|
|
+ private readonly IChannelConfigurationManager _channelConfigurationManager;
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -34,14 +38,17 @@ namespace Hotline.Api.Controllers.DataSharing
|
|
|
/// <param name="enterpriseClient"></param>
|
|
|
/// <param name="mediator"></param>
|
|
|
/// <param name="dataOrderRepository"></param>
|
|
|
+ /// <param name="channelConfigurationManager"></param>
|
|
|
public EnterpriseController(IMapper mapper, IRepository<DsReceiveWriteResult> receiveWriteResultRepository, EnterpriseClient enterpriseClient,
|
|
|
- IMediator mediator, IRepository<DsOrder> dataOrderRepository)
|
|
|
+ IMediator mediator, IRepository<DsOrder> dataOrderRepository,
|
|
|
+ IChannelConfigurationManager channelConfigurationManager)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_receiveWriteResultRepository = receiveWriteResultRepository;
|
|
|
_enterpriseClient = enterpriseClient;
|
|
|
_mediator = mediator;
|
|
|
_dataOrderRepository = dataOrderRepository;
|
|
|
+ _channelConfigurationManager = channelConfigurationManager;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -87,23 +94,97 @@ namespace Hotline.Api.Controllers.DataSharing
|
|
|
var data = _mapper.Map<DsReceiveWriteResult>(dto);
|
|
|
|
|
|
var id = await _receiveWriteResultRepository.AddAsync(data, HttpContext.RequestAborted);
|
|
|
+ var order = await _dataOrderRepository.GetAsync(p => p.OrderNo == dto.ReplyCode, HttpContext.RequestAborted);
|
|
|
+ List<FileDto> Files = null;
|
|
|
+ if (dto.ReplyFiles != null && dto.ReplyFiles.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in dto.ReplyFiles)
|
|
|
+ {
|
|
|
+ byte[] fileContentBytes = Convert.FromBase64String(item.FileText);
|
|
|
+ var fileData = await SendFileData(fileContentBytes, item.Filename, item.Fileformat, dto.ReplyResultType == 2 ? "退回附件" : "办理上传");
|
|
|
+ if (fileData != null)
|
|
|
+ {
|
|
|
+ Files.Add(fileData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (!string.IsNullOrEmpty(id))
|
|
|
{
|
|
|
- string FinishType = "";
|
|
|
- if (dto.ReplyResultType == 2)
|
|
|
- FinishType = "0";
|
|
|
- else if (dto.ReplyResultType == 1)
|
|
|
- FinishType = "1";
|
|
|
+ //如果是办理中调用
|
|
|
+ if (dto.ReplyResultType != 0)
|
|
|
+ {
|
|
|
+ string FinishType = "";
|
|
|
+ if (dto.ReplyResultType == 2)
|
|
|
+ FinishType = "0";
|
|
|
+ else if (dto.ReplyResultType == 1)
|
|
|
+ FinishType = "1";
|
|
|
+
|
|
|
+ if (order != null)
|
|
|
+ await _mediator.Send(new OrderResultNotify { OrderId = order.OrderId, FinishType = FinishType, Opinion = dto.ReplyContent, Files = Files }, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //这里调用业务接口,推送办理数据
|
|
|
+ List<WorkflowTraceDto> Traces = new List<WorkflowTraceDto>
|
|
|
+ {
|
|
|
+ new()
|
|
|
+ {
|
|
|
+ HandlerName = dto.ReplyUserName,
|
|
|
+ HandlerOrgName = dto.ReplyBMName,
|
|
|
+ HandleTime = dto.ReplyDate,
|
|
|
+ Opinion = dto.ReplyContent,
|
|
|
+ Files=Files
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (order != null)
|
|
|
+ await _mediator.Send(new AddOrderTracesAsyncNotify { OrderId = order.OrderId, Traces = Traces }, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
|
|
|
- var order = await _dataOrderRepository.GetAsync(p => p.OrderNo == dto.ReplyCode, HttpContext.RequestAborted);
|
|
|
- if (order != null)
|
|
|
- await _mediator.Send(new OrderResultNotify { OrderId = order.OrderId, FinishType = FinishType, Opinion = dto.ReplyContent }, HttpContext.RequestAborted);
|
|
|
- //向业务系统推送消息
|
|
|
- // await _capPublisher.PublishAsync("", _mapper.Map<DataWriteResultDto>(dto), cancellationToken: HttpContext.RequestAborted);
|
|
|
//这里往业务系统推送数据
|
|
|
return OpenResponse.Ok(EnterpriseDeResponse.Success("回复提交成功"));
|
|
|
}
|
|
|
return OpenResponse.Ok(EnterpriseDeResponse.Failed("接口调用失败!"));
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 将文件流上传到附件服务器
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="fileContentBytes">文件流</param>
|
|
|
+ /// <param name="fileName">文件名称</param>
|
|
|
+ /// <param name="type">文件类型</param>
|
|
|
+ /// <param name="classify">文件分类</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private async Task<FileDto> SendFileData(byte[] fileContentBytes, string fileName, string type, string classify)
|
|
|
+ {
|
|
|
+ var businessFile = _channelConfigurationManager.GetConfigurationBusinessFile();
|
|
|
+ // 构造字典文件数据
|
|
|
+ // 接口参数名称为files
|
|
|
+ CFormUpload.FileParameter fileParameter = new("fileData", fileContentBytes, fileName, "multipart/form-data");
|
|
|
+
|
|
|
+ Dictionary<string, object> 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, "");
|
|
|
+ FileDto fileDto = null;
|
|
|
+ if (!string.IsNullOrEmpty(result))
|
|
|
+ {
|
|
|
+ var resultData = Newtonsoft.Json.JsonConvert.DeserializeObject<BusinessFileResponse>(result);
|
|
|
+ if (resultData != null && resultData.code == 0)
|
|
|
+ {
|
|
|
+ fileDto = new()
|
|
|
+ {
|
|
|
+ Name = fileName,
|
|
|
+ Type = type,
|
|
|
+ Classify = classify,
|
|
|
+ Additions = resultData.result.id,
|
|
|
+ Path = resultData.result.path
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fileDto;
|
|
|
+ }
|
|
|
}
|
|
|
}
|