1、新增同步东胜7功能

2、修改BC拆单转发功能
usertest
jianghaiqing 3 months ago
parent f38a864e1e
commit 690aa31b9d

@ -1626,4 +1626,16 @@ public class SeaExport : BaseOrgModel<long>
/// </summary>
[SugarColumn(ColumnDescription = "服务项目", ColumnDataType = "text", IsNullable = true)]
public string? ServiceItem { get; set; }
/// <summary>
/// 订舱方式
/// </summary>
[SugarColumn(ColumnDescription = "订舱方式 CONTRACT_ORDER-合约订舱SPOT_ORDER-SPOT订舱", IsNullable = true, Length = 20)]
public string BookingSlotType { get; set; }
/// <summary>
/// 订舱方式名称
/// </summary>
[SugarColumn(ColumnDescription = "订舱方式名称 CONTRACT_ORDER-合约订舱SPOT_ORDER-SPOT订舱", IsNullable = true, Length = 40)]
public string BookingSlotTypeName { get; set; }
}

@ -3,6 +3,7 @@ using Autofac.Core;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.DjyServiceStatus;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Invoice.Dtos;
@ -14,7 +15,11 @@ using DS.WMS.Core.Sys.Entity;
using LanguageExt;
using LanguageExt.Common;
using Mapster;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
@ -23,6 +28,7 @@ using NPOI.SS.UserModel;
using Org.BouncyCastle.Ocsp;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
namespace DS.WMS.Core.Op.Method
@ -32,6 +38,7 @@ namespace DS.WMS.Core.Op.Method
/// </summary>
public partial class SeaExportService
{
const string CONST_AUTO_SYNC_DONGSHENG_BY_MQ = "AutoSyncBookingOrderToDongshengMQ";
/// <summary>
/// 打印保函
@ -2649,5 +2656,318 @@ namespace DS.WMS.Core.Op.Method
}
}
#endregion
#region 推送东胜(MQ)
/// <summary>
/// 推送东胜(MQ)
/// </summary>
/// <param name="ids">海运订单主键数组</param>
/// <returns></returns>
public async Task<dynamic> SendBookingOrder(long[] ids)
{
var logTitle = $"同步订舱数据ids:{string.Join(',', ids.ToList())}";
_logger.Info($"开始{logTitle}");
var BookingOrderMQUri = AppSetting.app(new string[] { "SyncDongSheng7", "MQConfig" });
var paramConfig = _configService.GetConfig(CONST_AUTO_SYNC_DONGSHENG_BY_MQ, long.Parse(user.TenantId), false).GetAwaiter().GetResult()?.Data?.Value;
_logger.Info($"{logTitle}订舱数据回推地址:{BookingOrderMQUri}{CONST_AUTO_SYNC_DONGSHENG_BY_MQ}{paramConfig}");
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (!string.IsNullOrEmpty(paramConfig) && paramConfig.Equals("ENABLE",StringComparison.OrdinalIgnoreCase))
{
if (ids.Count() == 0)
{
_logger.Info($"{logTitle}请求参数错误,未提供上传订单的主键,结束");
throw new Exception("请求参数错误,未提供上传订单的主键");
}
var order = await tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => ids.Contains(x.Id) && x.Deleted == false).ToListAsync();
foreach (var item in order)
{
//2023-9-8增加校验分单不能单独推送东胜只能随主单推送
if (item.ParentId > 0)
{
_logger.Info($"Id:{item.Id}分单不能单独推送东胜只能随主单推送continue跳过");
continue;
}
/*
//2023-9-26添加校验推送前通过Cache判断一下待推送的数据是否正在走删除逻辑
if (await _cache.ExistsAsync($"DeletingBookingOrderId_{item.Id}"))
{
_logger.Info($"Id:{item.Id}正在走删除逻辑continue跳过");
continue;
}
var dto = item.Adapt<SyncBookingOrderDto>();
//if (syncTypeEnum != null)
//{
// dto.SyncType = syncTypeEnum.ToString();
//}
if (!string.IsNullOrWhiteSpace(dto.YARDREMARK))
{
dto.YARDREMARK += "\\n" + item.BookingSlotTypeName;
}
else
{
dto.YARDREMARK = item.BookingSlotTypeName;
}
List<EmbedServiceProjectStatusDto> statusList = new List<EmbedServiceProjectStatusDto>();
QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus
{
BookingId = item.Id,
QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT,
TenantId = item.TenantId.Value
};
var queryRlt = await _serviceWorkFlowManageService.GetEnableStatusListByBusiness(queryInfo);
if (queryRlt.succ)
{
statusList = JsonConvert.DeserializeObject<List<EmbedServiceProjectStatusDto>>(JsonConvert.SerializeObject(queryRlt.ext));
}
if (statusList != null && statusList.Any(x => x.StatusSKUCode == "SQXS" && x.IsYield))
{
dto.CtnDayNum = statusList.FirstOrDefault(x => x.StatusSKUCode == "SQXS" && x.IsYield)?.ActVal;
}
var ctn = await tenantDb.Queryable<SeaExportctn>.AsQueryable().Filter(null, true).Where(x => x.BILLID == item.Id && x.IsDeleted == false).ToListAsync();
dto.ctnInputs = ctn.Adapt<List<BookingCtnDto>>();
foreach (var it in dto.ctnInputs)
{
var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
it.ctnDetailInputs = ctnDetailInputs.Adapt<List<BookingCtnDetailDto>>();
}
//2024-06-20 这里如果遇到拆票情况需要重新组织提单号
if (item.SplitOrMergeFlag.HasValue && (item.SplitOrMergeFlag.Value == 1 || item.SplitOrMergeFlag.Value == 2))
{
dto.MBLNO = $"{item.MBLNO}-{item.HBLNO}";
//如果当前是合票时,需要所有子票的箱型箱量合并到主票同步到东胜,子票的箱型箱量不同步东胜
if (item.SplitOrMergeFlag.Value == 2)
{
//如果当前是主票
if (dto.CUSTNO.Equals(dto.HBLNO, StringComparison.OrdinalIgnoreCase))
{
var allOrderList = await _rep.AsQueryable().Filter(null, true).Where(x => dto.HBLNO == x.HBLNO && (x.SPLIT_OR_MERGE_FLAG != null && x.SPLIT_OR_MERGE_FLAG == 2)
&& x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync();
if (allOrderList.Count > 0)
{
var allOrderIds = allOrderList.Select(x => x.Id).ToList();
var currCtn = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID != null && allOrderIds.Contains(x.BILLID.Value)
&& x.IsDeleted == false).ToListAsync();
dto.ctnInputs = currCtn.Adapt<List<BookingCtnDto>>();
foreach (var it in dto.ctnInputs)
{
var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
it.ctnDetailInputs = ctnDetailInputs.Adapt<List<BookingCtnDetailDto>>();
}
dto.CNTRTOTAL = string.Join(",", dto.ctnInputs.GroupBy(x => x.CTNALL).Select(x => $"{x.Key}*{x.Sum(b => b.CTNNUM)}").ToArray());
}
}
else
{
dto.ctnInputs = new List<BookingCtnDto>();
dto.CNTRTOTAL = string.Empty;
}
}
}
//EDI
var BookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && x.IsDeleted == false).FirstAsync();
if (BookingEDIExt != null)
{
dto.BookingEDIExt = BookingEDIExt.Adapt<BookingEDIExtDto>();
}
if (App.Configuration["ServiceStatusOpenAuto"] == "1")
{
if (statusList != null && statusList.Any(x => x.IsYield))
{
dto.GoodsStatus = statusList.Where(x => x.IsYield).OrderBy(x => x.SortNo).Select(x => new BookingGoodsStatusDto
{
StatusName = x.ShowName,
FinishTime = x.ActDate,
Remark = x.ActRemark,
ExtData = x.ActVal
}).ToList();
}
else
{
dto.GoodsStatus = new List<BookingGoodsStatusDto>();
}
}
else
{
//货物状态
dto.GoodsStatus = await _goodsStatus.AsQueryable().Filter(null, true).Where(x => x.bookingId == item.Id).InnerJoin<BookingGoodsStatusConfig>((t, d) => t.ConfigId == d.Id).Select((t, d) => new BookingGoodsStatusDto
{
StatusName = d.StatusName,
FinishTime = t.FinishTime,
Remark = t.Remark,
ExtData = t.ExtData
}).Distinct().ToListAsync();
}
//等拓展数据
var extData = await _repextendstate.AsQueryable().Filter(null, true).FirstAsync(x => x.bookingId == item.Id);
if (extData != null)
{
dto.ExtendState = extData.Adapt<BookingExtendStateDto>();
}
//提箱返场
var statusloglist = _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && x.IsDeleted == false && x.Category == "yunzong").ToList();
var statuslogId = statusloglist.Select(x => x.Id).ToList();
//运踪状态详情
var statuslogdetaillist = _statuslogdetail.AsQueryable().Where(x => statuslogId.Contains(x.PId)).ToList();
var staLogListDto = statusloglist.Adapt<List<BookingStatusLogSyncDto>>();
dto.StatusLogs = staLogListDto;
foreach (var sl in dto.StatusLogs)
{
var detailList = statuslogdetaillist.Where(x => x.PId == sl.Id).ToList();
sl.Details = detailList.Adapt<List<BookingStatusLogDetailSyncDto>>();
}
var childrens = await _rep.AsQueryable().Filter(null, true).Where(x => x.ParentId == item.Id && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync();
dto.childrens = childrens.Adapt<List<Children>>();
var files = await _bookingfile.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id).ToListAsync();
dto.Files = files.Select(x => new ReceiveBcInfoDto.DownloadFile()
{
Id = x.Id,
FileName = x.FileName,
FileType = x.TypeCode,
FilePath = x.FilePath
}).ToList();
foreach (var childitem in dto.childrens)
{
var ctnInputs = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == childitem.Id && x.IsDeleted == false).ToListAsync();
childitem.ctnInputs = ctnInputs.Adapt<List<BookingCtnDto>>();
foreach (var it in childitem.ctnInputs)
{
var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
it.ctnDetailInputs = ctnDetailInputs.Adapt<List<BookingCtnDetailDto>>();
}
var childBookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == childitem.Id && x.IsDeleted == false).FirstAsync();
if (childBookingEDIExt != null)
{
childitem.BookingEDIExt = childBookingEDIExt.Adapt<BookingEDIExtDto>();
}
}
var json = dto.ToJsonString();
json = $"[{json}]";
_logger.Info($"Id:{item.Id},订舱数据回推,消息内容:{json}");
try
{
string MqActionExchangeName = AppSetting.app(new string[] { "SyncDongSheng7", "MQConfig" }); //djy.output.dingcang.ds6
string MqActionQueueName = AppSetting.app(new string[] { "SyncDongSheng7", "MQConfig" }); //djy.output.dingcang.ds6
//ConnectionFactory factory = new ConnectionFactory();
//factory.Uri = new Uri(BookingOrderMQUri);
//using (IConnection conn = factory.CreateConnection())
//{
// IModel mqModel = conn.CreateModel();
// mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
// var queueName = $"{MqActionQueueName}.{(item.SubTenantId.HasValue && item.SubTenantId > 0 ? item.SubTenantId.Value : item.TenantId)}";
// mqModel.QueueDeclare(queueName, false, false, false, null);
// mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
// byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json));
// IBasicProperties props = mqModel.CreateBasicProperties();
// props.DeliveryMode = 2;
// mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes);
// conn.Close();
// _logger.LogInformation($"Id:{item.Id},订舱数据回推,已发送数据到消息队列【{BookingOrderMQUri}】,队列名称:【{queueName}】");
//}
}
catch (Exception ex)
{
_logger.Error(ex.Message, $"Id:{item.Id},订舱数据回推推送过程中出现异常");
_logger.Error($"Id:{item.Id}订舱数据回推推送过程中出现异常ex.StackTrace{ex.StackTrace}");
}
await SendLetterYard(item.Id);
*/
}
if (order.Count == 0)
{
_logger.Info($"{logTitle}未查到订舱数据,结束");
}
return order;
}
return null;
}
#endregion
#region 放舱推送东胜
/// <summary>
/// 放舱推送东胜
/// </summary>
/// <returns></returns>
public async Task<dynamic> SendLetterYard(long bookingId)
{
/*
var entity = _repLetterYard.AsQueryable().Filter(null, true).First(x => x.BookingId == bookingId && x.IsDeleted == false);
if (entity != null)
{
var json = entity.ToJsonString();
try
{
const string MqActionExchangeName = "djy.output.dingcang.ds6";
const string MqActionQueueName = "djy.output.dingcang.ds6_fangcang";
ConnectionFactory factory = new ConnectionFactory();
factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault());
using (IConnection conn = factory.CreateConnection())
{
IModel mqModel = conn.CreateModel();
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
mqModel.QueueDeclare(queueName, false, false, false, null);
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(json);
IBasicProperties props = mqModel.CreateBasicProperties();
props.DeliveryMode = 2;
mqModel.BasicPublish(MqActionExchangeName,
queueName, props,
messageBodyBytes);
conn.Close();
_logger.LogInformation($"放舱数据回推,已发送数据到消息队列【{_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()}】,数据内容:【{json}】");
}
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
_logger.LogError(ex.StackTrace);
}
}
*/
return null;
}
#endregion
}
}

@ -41,6 +41,8 @@ public partial class SeaExportService : ISeaExportService
private readonly IDjyServiceStatusService _djyServiceStatusService;
private readonly IRuleEngineService _ruleEngineService;
private readonly IOpJobService opJobService;
private readonly IConfigService _configService;
private readonly ISysCacheService _sysCacheService;
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT";
@ -53,6 +55,8 @@ public partial class SeaExportService : ISeaExportService
const string CONST_TSL_TYPE_CODE = "TslWeb";
const string CONST_ONE_SOFILE_CATE_CODE = "one_so_file_template";
const string PRINT_DATASOURCE_KEY = "booking_order";
/// <summary>
///
/// </summary>
@ -71,6 +75,7 @@ public partial class SeaExportService : ISeaExportService
_djyServiceStatusService = _serviceProvider.GetRequiredService<IDjyServiceStatusService>();
_ruleEngineService = _serviceProvider.GetRequiredService<IRuleEngineService>();
opJobService = _serviceProvider.GetRequiredService<IOpJobService>();
_configService = _serviceProvider.GetRequiredService<IConfigService>();
}
/// <summary>

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.TaskPlat.Dtos.BC
{
/// <summary>
///
/// </summary>
public class DrawModifyBCConfig
{
/// <summary>
/// 擦除枚举
/// </summary>
public DrawModifyBCConfigTypeEnum[] drawTypeArg { get; set; }
/// <summary>
/// 原箱数量
/// </summary>
public Nullable<int> origCtnNum { get; set; }
/// <summary>
/// 修改箱数量
/// </summary>
public Nullable<int> newCtnNum { get; set; }
/// <summary>
/// 箱类型
/// </summary>
public string ctnAll { get; set; }
/// <summary>
/// 原提单号
/// </summary>
public string origBillNo { get; set; }
/// <summary>
/// 新提单号
/// </summary>
public string newBillNo { get; set; }
}
/// <summary>
///
/// </summary>
public enum DrawModifyBCConfigTypeEnum
{
/// <summary>
/// 标准
/// </summary>
[Description("标准")]
Standard,
/// <summary>
/// 擦除更多(展鸿要求)
/// </summary>
[Description("擦除更多")]
EraseMore,
/// <summary>
/// 手工指定截单时间
/// </summary>
[Description("手工指定截单时间")]
DrawManualSIDate,
/// <summary>
/// 分票修改(康乾,主要考虑拆票时箱数量按照拆票显示)
/// </summary>
[Description("分票修改")]
SplitBC,
/// <summary>
/// 改提单号为分票号
/// </summary>
[Description("改提单号为分票号")]
ChangeToSplitBillNo,
}
}

@ -552,5 +552,35 @@ namespace DS.WMS.Core.TaskPlat.Entity
/// </summary>
[SugarColumn(ColumnDescription = "冷藏通风量", IsNullable = true, Length = 10)]
public string? REEFER_QUANTITY { get; set; }
/// <summary>
/// 是否已转发客户 1-是 0-否
/// </summary>
[SugarColumn(ColumnDescription = "是否已转发客户 1-是 0-否", IsNullable = true, Length = 1)]
public Nullable<bool> IS_TRANSFER_USER { get; set; }
/// <summary>
/// 最后转发客户邮件时间
/// </summary>
[SugarColumn(ColumnDescription = "最后转发客户邮件时间", IsNullable = true)]
public DateTime? LST_TRANSFER_USER_DATE { get; set; }
/// <summary>
/// 最后转发客户邮件结果
/// </summary>
[SugarColumn(ColumnDescription = "最后转发客户邮件结果", IsNullable = true, Length = 500)]
public string? LST_TRANSFER_NOTES { get; set; }
/// <summary>
/// 最后转发客户邮件状态 TEMP-暂存 SUCC-发送成功 FAILURE-发送失败
/// </summary>
[SugarColumn(ColumnDescription = "最后转发客户邮件状态 TEMP-暂存 SUCC-发送成功 FAILURE-发送失败", IsNullable = true, Length = 20)]
public string? LST_STATUS { get; set; }
/// <summary>
/// 最后转发客户邮件状态名称
/// </summary>
[SugarColumn(ColumnDescription = "最后转发客户邮件状态名称", IsNullable = true, Length = 50)]
public string? LST_STATUS_NAME { get; set; }
}
}

@ -30,11 +30,14 @@ using HtmlAgilityPack;
using Mapster;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using NLog;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using System.Collections.Specialized;
using System.Net.Http.Headers;
using System.Text;
using System.Text.RegularExpressions;
@ -75,6 +78,7 @@ namespace DS.WMS.Core.TaskPlat.Method
private Lazy<ICodeVesselService> codeVesselService;
private Lazy<ITaskMailService> _taskMailService;
private Lazy<ITaskLogService> _logService;
private Lazy<ISysFileService> _sysFileService;
private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
@ -87,6 +91,9 @@ namespace DS.WMS.Core.TaskPlat.Method
const string CONST_AUTO_TRANS_EMAIL_OP_CCTO = "AUTO_TRANS_EMAIL_OP_CCTO";
public TaskManageBCService(IUser user,
ILogger<TaskManageBCService> logger,
@ -126,6 +133,7 @@ namespace DS.WMS.Core.TaskPlat.Method
codeVesselService = new Lazy<ICodeVesselService>(serviceProvider.GetRequiredService<ICodeVesselService>);
_taskMailService = new Lazy<ITaskMailService>(serviceProvider.GetRequiredService<ITaskMailService>);
_logService = new Lazy<ITaskLogService>(serviceProvider.GetRequiredService<ITaskLogService>);
_sysFileService = new Lazy<ISysFileService>(serviceProvider.GetRequiredService<ISysFileService>);
tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
tenantDb.QueryFilter.Clear<IOrgId>();
@ -3126,7 +3134,7 @@ namespace DS.WMS.Core.TaskPlat.Method
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
var entity = tenantDb.Queryable<TaskPolContainerNotPickup>().Filter(null, true).First(a => a.TASK_ID == taskPKId);
var entity = tenantDb.Queryable<TaskBCInfo>().Filter(null, true).First(a => a.TASK_ID == taskPKId);
var baseInfo = tenantDb.Queryable<TaskBaseInfo>().Filter(null, true).First(a => a.Id == taskPKId);
@ -3149,7 +3157,7 @@ namespace DS.WMS.Core.TaskPlat.Method
BusinessId = taskPKId,
BusinessType = BusinessType.OceanShippingExport,
AutoCreateNext = true,
TaskTypeName = TaskBaseTypeEnum.POL_CTN_NOT_PICKUP.ToString(),
TaskTypeName = TaskBaseTypeEnum.BC_MODIFY.ToString(),
}, $"未能根据任务配置值获取邮件模板设置");
@ -3175,7 +3183,7 @@ namespace DS.WMS.Core.TaskPlat.Method
{
var taskAllocList = tenantDb.Queryable<TaskBaseAllocation>().Where(a => a.TaskId == taskPKId).ToList();
var searchAllotUserRlt = taskAllocationService.Value.GetAllotUserBySeaExportId(TaskBaseTypeEnum.POL_CTN_NOT_PICKUP, id, new TaskFlowDataContext()).GetAwaiter().GetResult();
var searchAllotUserRlt = taskAllocationService.Value.GetAllotUserBySeaExportId(TaskBaseTypeEnum.BC_MODIFY, id, new TaskFlowDataContext()).GetAwaiter().GetResult();
if (searchAllotUserRlt.Succeeded && searchAllotUserRlt.Data?.Count > 0)
{
@ -3224,7 +3232,7 @@ namespace DS.WMS.Core.TaskPlat.Method
if (taskAllocList.Count == 0)
{
var searchAllotUserRlt = taskAllocationService.Value.GetAllotUserBySeaExportId(TaskBaseTypeEnum.POL_CTN_NOT_PICKUP, orderInfo.currOrder.Id, new TaskFlowDataContext()).GetAwaiter().GetResult();
var searchAllotUserRlt = taskAllocationService.Value.GetAllotUserBySeaExportId(TaskBaseTypeEnum.BC_MODIFY, orderInfo.currOrder.Id, new TaskFlowDataContext()).GetAwaiter().GetResult();
if (searchAllotUserRlt.Succeeded && searchAllotUserRlt.Data?.Count > 0)
{
@ -3263,6 +3271,8 @@ namespace DS.WMS.Core.TaskPlat.Method
Detail = new List<TaskTransferMsgDataDto>()
};
TaskBCTransferDto taskBCTransferDto = new TaskBCTransferDto();
Dictionary<long, Tuple<bool, string, string>> dict = new Dictionary<long, Tuple<bool, string, string>>();
foreach (var id in orderIdList)
@ -3272,13 +3282,15 @@ namespace DS.WMS.Core.TaskPlat.Method
BusinessId = id,
};
var model = new MailTemplateModel<TaskPOLContainerNotPickUpShowDto>(taskInfo)
var model = new MailTemplateModel<TaskBCTransferDto>(taskBCTransferDto)
{
BusinessId = id,
BusinessType = BusinessType.OceanShippingExport,
};
MailService mailService = new MailService(serviceProvider);
//如果是拆票需要每票调用生成拆票的BC文件
var result = await mailService.SendAsync(mailConfig, model);
if (!result.Succeeded)
@ -3288,7 +3300,7 @@ namespace DS.WMS.Core.TaskPlat.Method
BusinessId = taskPKId,
BusinessType = BusinessType.OceanShippingExport,
AutoCreateNext = true,
TaskTypeName = TaskBaseTypeEnum.POL_CTN_NOT_PICKUP.ToString(),
TaskTypeName = TaskBaseTypeEnum.BC_MODIFY.ToString(),
}, result.Message);
@ -3312,7 +3324,7 @@ namespace DS.WMS.Core.TaskPlat.Method
entity.LST_STATUS = "SUCC";
entity.LST_STATUS_NAME = "发送成功";
await tenantDb.Updateable<TaskPolContainerNotPickup>(entity).UpdateColumns(x => new
await tenantDb.Updateable<TaskBCInfo>(entity).UpdateColumns(x => new
{
x.IS_TRANSFER_USER,
x.LST_TRANSFER_USER_DATE,
@ -3321,7 +3333,7 @@ namespace DS.WMS.Core.TaskPlat.Method
}).ExecuteCommandAsync();
//发送完邮件,自动标记任务状态为完成
await SetTaskStatus(taskPKId, TaskBaseTypeEnum.POL_CTN_NOT_PICKUP, TaskStatusEnum.Complete, DateTime.Now, null);
await SetTaskStatus(taskPKId, TaskBaseTypeEnum.BC_MODIFY, TaskStatusEnum.Complete, DateTime.Now, null);
}
return DataResult<TaskTransferMsgDto>.Success(resultDto);
@ -3351,7 +3363,7 @@ namespace DS.WMS.Core.TaskPlat.Method
BusinessId = taskPKId,
BusinessType = BusinessType.OceanShippingExport,
AutoCreateNext = true,
TaskTypeName = TaskBaseTypeEnum.POL_CTN_NOT_PICKUP.ToString(),
TaskTypeName = TaskBaseTypeEnum.BC_MODIFY.ToString(),
}, $"缺少参数:{nameof(BusinessTaskMail)}.{nameof(BusinessTaskMail.Id)}");
@ -3386,5 +3398,132 @@ namespace DS.WMS.Core.TaskPlat.Method
return await InnerSendEmailToCustomer(taskPKId, businessTaskMailId);
}
#endregion
#region 重新获取生成BookingAmendment文件
/// <summary>
/// 重新获取生成BookingAmendment文件
/// </summary>
/// <param name="bookingOrder"></param>
/// <param name="ctnList"></param>
/// <param name="origFilePath"></param>
/// <returns></returns>
private async Task<DataResult<string>> ReGenerateBAFile(SeaExport bookingOrder, List<OpCtn> ctnList, string origFilePath)
{
DrawModifyBCConfig mConfig = new DrawModifyBCConfig
{
drawTypeArg = new DrawModifyBCConfigTypeEnum[] { DrawModifyBCConfigTypeEnum.ChangeToSplitBillNo, DrawModifyBCConfigTypeEnum.SplitBC },
origBillNo = bookingOrder.OrderNo,
newBillNo = bookingOrder.MBLNO,
newCtnNum = ctnList.Sum(a => a.CtnNum),
ctnAll = ctnList.FirstOrDefault().CtnAll
};
NameValueCollection modifyPar = new NameValueCollection();
modifyPar.Add("jsonMessage", JsonConvert.SerializeObject(mConfig));
DynameFileInfo dynameFile = null;
var fileName = Path.GetFileName(origFilePath);
var fileBytes = File.ReadAllBytes(origFilePath);
if (fileBytes.Length > 0)
{
dynameFile = new DynameFileInfo
{
FileName = fileName,
FileBytes = fileBytes
};
}
string batchNo = SnowFlakeSingle.Instance.NextId().ToString();
byte[] modifyBytes = ModifyFile(modifyPar, dynameFile).GetAwaiter().GetResult();
var noExtensionFileName = Path.GetFileNameWithoutExtension(fileName);
var fileRlt = await _sysFileService.Value.SaveFileDirect(bookingOrder.Id.ToString(), modifyBytes, batchNo, noExtensionFileName,"bcsplitnoticefiles");
if(fileRlt != null && fileRlt.Data != null && !string.IsNullOrWhiteSpace(fileRlt.Data.Item1))
{
return DataResult<string>.Success(fileRlt.Data.Item1);
}
return DataResult<string>.FailedData(string.Empty);
}
#endregion
#region 请求变更BookingAmendment后的文件
/// <summary>
/// 请求变更BookingAmendment后的文件
/// </summary>
/// <param name="nameValueCollection">请求参数</param>
/// <param name="fileInfo">文件</param>
/// <param name="contentType">请求类型</param>
/// <returns>返回回执</returns>
private async Task<byte[]> ModifyFile(NameValueCollection nameValueCollection, dynamic fileInfo,
string contentType = "application/json")
{
//Stream ms = null;
byte[] bytes;
var result = string.Empty;
using (var httpClient = new HttpClient())
{
try
{
using (var reduceAttach = new MultipartFormDataContent())
{
string[] allKeys = nameValueCollection.AllKeys;
foreach (string key in allKeys)
{
var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(nameValueCollection[key]));
dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
{
Name = key
};
reduceAttach.Add(dataContent);
}
#region 文件参数
if (fileInfo != null)
{
var Content = new ByteArrayContent(fileInfo.FileBytes);
//Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
//{
// Name = fileInfo.file.ToString(),
// FileName = fileInfo.fileName.ToString(),
//};
Content.Headers.Add("Content-Type", contentType);
reduceAttach.Add(Content, "file", HttpUtility.UrlEncode(fileInfo.FileName.ToString()));
}
#endregion
//httpClient.DefaultRequestHeaders.Add("USER_KEY", App.Configuration["ApiUserKey"]);
//httpClient.DefaultRequestHeaders.Add("USER_SECRET", App.Configuration["ApiUserSecret"]);
//请求
var response = httpClient.PostAsync(AppSetting.app(new string[] { "BookingAmend", "ModifyFileUrl" }), reduceAttach).Result;
bytes = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
}
}
catch (Exception ex)
{
logger.LogInformation("请求自动变更BookingAmendment文件内容异常原因{error}", ex.Message);
throw new Exception($"请求自动变更BookingAmendment文件内容异常原因{ex.Message}");
}
}
return bytes;
}
#endregion
}
}

@ -122,5 +122,10 @@
"WorkerCount": 10,
"ServerName": "OpApi",
"Queues": "op"
},
"SyncDongSheng7": {
"MQConfig": "amqp://djy_booking_new:123qwe@60.209.125.238:40101/djy_booking_new",
"MQExchangeName": "djy.output.dingcang.ds6",
"MQQueueName": "djy.output.dingcang.ds6"
}
}

@ -102,5 +102,8 @@
"JsonPrintByCode": "/printApi/OpenPrint/GetOpenJsonPrintInfoByTemplateCode",
"SQLPrint": "/printApi/OpenPrint/GetOpenSqlPrintInfo",
"MailApiUrl": "http://47.104.73.97:8801/mail/send"
},
"BookingAmend": {
"ModifyFileUrl": "http://localhost:5110/api/TaskBookingAmendmentParser/ModifyBookingAmendmentFile"
}
}

Loading…
Cancel
Save