using Furion.DependencyInjection; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Myshipping.Application { public class TaskManageExternalService : ITaskManageExternalService, ITransient { private readonly INamedServiceProvider _namedServiceProvider; public TaskManageExternalService(INamedServiceProvider namedServiceProvider) { _namedServiceProvider = namedServiceProvider; } /// /// 提交派车 /// /// 请求派车报文 /// 返回回执 public async Task SubmitTruckDispatchAsync(TaskManageOrderMessageInfo info) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); try { var service = _namedServiceProvider.GetService(nameof(TaskManageService)); var rlt = await service.CreateTaskJob(info); if(!rlt.succ) { result.succ = false; result.msg = $"提交派车失败,原因:{rlt.msg}"; } else { result.succ = true; result.msg = "提交成功"; //提取任务流水号 result.ext = rlt.ext; } } catch(Exception ex) { result.succ = false; result.msg = $"保存派车异常,原因:{ex.Message}"; } return result; } /// /// 撤销派车 /// /// 请求派车报文 /// 返回回执 public async Task CancelTruckDispatchAsync(TaskManageOrderMessageInfo info) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); try { var service = _namedServiceProvider.GetService(nameof(TaskManageService)); var rlt = await service.CancelTaskJob(info); if (!rlt.succ) { result.succ = false; result.msg = $"提交派车失败,原因:{rlt.msg}"; } else { result.succ = true; result.msg = "提交成功"; //提取任务流水号 result.ext = rlt.ext; } } catch (Exception ex) { result.succ = false; result.msg = $"保存派车异常,原因:{ex.Message}"; } return result; } } }