jianghaiqing 7 months ago
commit eeac22b2c0

@ -61,6 +61,8 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<DjyApiAuth> _repApiAuth; private readonly SqlSugarRepository<DjyApiAuth> _repApiAuth;
private readonly SqlSugarRepository<DjyMessage> _repMessage; private readonly SqlSugarRepository<DjyMessage> _repMessage;
private readonly IBookingOrderService bookingOrderService; private readonly IBookingOrderService bookingOrderService;
private readonly SqlSugarRepository<DjyCustomer> _repCustomer;
private readonly SqlSugarRepository<DjyCustomerParamValue> _repCustomerParamValue;
public BookingCustomerOrderService(SqlSugarRepository<BookingCustomerOrder> rep, SqlSugarRepository<BookingCtn> repCtn, public BookingCustomerOrderService(SqlSugarRepository<BookingCustomerOrder> rep, SqlSugarRepository<BookingCtn> repCtn,
ILogger<BookingOrderService> logger, ISysCacheService cache, SqlSugarRepository<BookingFile> repFile, ILogger<BookingOrderService> logger, ISysCacheService cache, SqlSugarRepository<BookingFile> repFile,
@ -68,7 +70,8 @@ namespace Myshipping.Application
SqlSugarRepository<BookingOrder> repOrder, SqlSugarRepository<BookingStatusLogDetail> repStatuslogDetail, SqlSugarRepository<BookingOrder> repOrder, SqlSugarRepository<BookingStatusLogDetail> repStatuslogDetail,
SqlSugarRepository<BookingCustomerOrderTemplate> repOrderTempl, SqlSugarRepository<BookingCustomerOrderTemplate> repOrderTempl,
SqlSugarRepository<BookingEDIExt> repEdiExt, SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<BookingEDIExt> repEdiExt, SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig,
IEventPublisher publisher, SqlSugarRepository<DjyApiAuth> repApiAuth, SqlSugarRepository<DjyMessage> repMessage, IBookingOrderService bookingOrderService) IEventPublisher publisher, SqlSugarRepository<DjyApiAuth> repApiAuth, SqlSugarRepository<DjyMessage> repMessage, IBookingOrderService bookingOrderService,
SqlSugarRepository<DjyCustomer> repCustomer, SqlSugarRepository<DjyCustomerParamValue> repCustomerParamValue)
{ {
this._logger = logger; this._logger = logger;
this._rep = rep; this._rep = rep;
@ -87,6 +90,8 @@ namespace Myshipping.Application
this._repApiAuth = repApiAuth; this._repApiAuth = repApiAuth;
this._repMessage = repMessage; this._repMessage = repMessage;
this.bookingOrderService = bookingOrderService; this.bookingOrderService = bookingOrderService;
this._repCustomer = repCustomer;
this._repCustomerParamValue = repCustomerParamValue;
} }
#region 订舱草稿及附件 #region 订舱草稿及附件
@ -1582,6 +1587,7 @@ namespace Myshipping.Application
var rtnList = new List<BookingSubmitResultModel>(); var rtnList = new List<BookingSubmitResultModel>();
var ordIdList = new List<long>();
foreach (var item in list) foreach (var item in list)
{ {
var strId = item.Id.ToString(); var strId = item.Id.ToString();
@ -1618,6 +1624,8 @@ namespace Myshipping.Application
await _rep.UpdateAsync(order); await _rep.UpdateAsync(order);
} }
ordIdList.Add(order.Id);
//箱信息 //箱信息
await _repCtn.DeleteAsync(x => x.BILLID == order.Id); await _repCtn.DeleteAsync(x => x.BILLID == order.Id);
foreach (var ctn in item.CtnList) foreach (var ctn in item.CtnList)
@ -1661,6 +1669,27 @@ namespace Myshipping.Application
SaveAuditLog($"待审核", order.Id); SaveAuditLog($"待审核", order.Id);
} }
//全部成功后,才能自动订舱和审核
if (rtnList.Count(x => x.Success == false) == 0)
{
var tCustId = list.First().BookingTenantId;
//自动订舱和自动审核
var cust = await _repCustomer.AsQueryable().FirstAsync(x => x.CustSysId == tCustId);
if (cust != null)
{
var paraCallApiAuditAuto = await _repCustomerParamValue.AsQueryable().FirstAsync(x => x.CustomerId == cust.Id && x.ParaCode == "BookingCallApiAndAuditAuto");
if (paraCallApiAuditAuto != null && paraCallApiAuditAuto.ItemCode == "YES")
{
foreach (var ordId in ordIdList)
{
await PostApiSO(ordId);
await AuditBooking(ordId, true, "系统自动审核");
}
}
}
}
return rtnList; return rtnList;
} }

@ -2306,6 +2306,10 @@ namespace Myshipping.Application
{ {
continue; continue;
} }
// 通过租户参数判断这一票的租户是否启用了舱位引入功能
var isCancelAllocationSlot = tenantParamList.FirstOrDefault(x => x.TenantId == order.TenantId && x.ParaCode == TenantParamCode.ENABLE_SLOT_ABILITY)?.ItemCode;
var mblno = order.MBLNO; var mblno = order.MBLNO;
// 将待删除的订舱单id存放到Cache中。目的使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑来决定是否推送(如果是正在处理删除逻辑的数据,则不推送) // 将待删除的订舱单id存放到Cache中。目的使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑来决定是否推送(如果是正在处理删除逻辑的数据,则不推送)
@ -2349,6 +2353,12 @@ namespace Myshipping.Application
// 取消订阅运踪 // 取消订阅运踪
waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno));
if (isCancelAllocationSlot == "YES")
{
// 取消关联舱位
await CancelAllocationSlot(Id);
}
// 记录日志 // 记录日志
var newOrder = order.Adapt<BookingOrder>(); var newOrder = order.Adapt<BookingOrder>();
newOrder.IsDeleted = true; newOrder.IsDeleted = true;
@ -2379,6 +2389,12 @@ namespace Myshipping.Application
// 取消订阅运踪 // 取消订阅运踪
waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno));
if (isCancelAllocationSlot == "YES")
{
// 取消关联舱位
await CancelAllocationSlot(Id);
}
// 记录日志 // 记录日志
var newOrder = order.Adapt<BookingOrder>(); var newOrder = order.Adapt<BookingOrder>();
newOrder.IsDeleted = true; newOrder.IsDeleted = true;
@ -4256,25 +4272,25 @@ namespace Myshipping.Application
{ {
string value = null; string value = null;
var fieldType = item.Field.Split('.')[0].ToLower(); var destName = item.Field.Split('.')[0].ToLower();
var fieldProperty = item.Field.Split('.')[1]; var fieldName = item.Field.Split('.')[1];
if (fieldType == "order") if (destName == "order" || destName == "suborder")
{ {
if (order != null) if (order != null)
{ {
value = typeof(BookingOrder).GetProperty(fieldProperty).GetValue(order)?.ToString(); value = typeof(BookingOrder).GetProperty(fieldName).GetValue(order)?.ToString();
} }
} }
else if (fieldType == "edi") else if (destName == "edi")
{ {
if (edi != null) if (edi != null)
{ {
value = typeof(BookingEDIExt).GetProperty(fieldProperty).GetValue(edi)?.ToString(); value = typeof(BookingEDIExt).GetProperty(fieldName).GetValue(edi)?.ToString();
} }
} }
else if (fieldType == "userinfo") else if (destName == "userinfo")
{ {
var propertyLower = fieldProperty.ToLower(); var propertyLower = fieldName.ToLower();
switch (propertyLower) switch (propertyLower)
{ {
case "username": case "username":
@ -4291,6 +4307,18 @@ namespace Myshipping.Application
value = null; break; value = null; break;
}; };
} }
else if (destName == "other")
{
var propertyLower = fieldName.ToLower();
switch (propertyLower)
{
case "printdate":
value = DateTime.Now.ToString("yyyy-MM-dd");
break;
default:
value = null; break;
}
}
if (!string.IsNullOrWhiteSpace(value)) if (!string.IsNullOrWhiteSpace(value))
{ {
foreach (var itemTemp in group) foreach (var itemTemp in group)
@ -4320,13 +4348,15 @@ namespace Myshipping.Application
{ {
var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault(); var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault();
if (name.Split('.')[0].ToLower() == "order") var destName = name.Split('.')[0].ToLower();
if (destName == "order" || destName == "suborder")
{ {
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order))
{ {
var _name = descriptor.Name.ToLower(); var _name = descriptor.Name.ToLower();
if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == _name) if (name.Split('.')[1].ToLower() == _name)
{ {
var value = descriptor.GetValue(order) != null ? descriptor.GetValue(order).ToString() : ""; var value = descriptor.GetValue(order) != null ? descriptor.GetValue(order).ToString() : "";
ICell cell = row.GetCell(_cellNum - 1); ICell cell = row.GetCell(_cellNum - 1);
@ -4344,7 +4374,7 @@ namespace Myshipping.Application
} }
} }
if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == "_pkgs" && _name == "pkgs") if (name.Split('.')[1].ToLower() == "_pkgs" && _name == "pkgs")
{ {
var value = string.Empty; var value = string.Empty;
if (order.PKGS != null) if (order.PKGS != null)
@ -4371,7 +4401,7 @@ namespace Myshipping.Application
} }
} }
if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == "_kgs" && _name == "kgs") if (name.Split('.')[1].ToLower() == "_kgs" && _name == "kgs")
{ {
var value = string.Empty; var value = string.Empty;
if (order.KGS != null) if (order.KGS != null)
@ -4399,7 +4429,7 @@ namespace Myshipping.Application
} }
if (name.Split('.')[0].ToLower() == "order" && name.Split('.')[1].ToLower() == "_cbm" && _name == "cbm") if (name.Split('.')[1].ToLower() == "_cbm" && _name == "cbm")
{ {
var value = string.Empty; var value = string.Empty;
if (order.CBM != null) if (order.CBM != null)
@ -4430,7 +4460,7 @@ namespace Myshipping.Application
} }
if (name.Split('.')[0].ToLower() == "edi") if (destName == "edi")
{ {
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi)) foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi))
@ -4458,7 +4488,7 @@ namespace Myshipping.Application
} }
if (name.Split('.')[0].ToLower() == "userinfo") if (destName == "userinfo")
{ {
ICell cell = row.GetCell(_cellNum - 1); ICell cell = row.GetCell(_cellNum - 1);
var value = string.Empty; var value = string.Empty;
@ -4491,6 +4521,26 @@ namespace Myshipping.Application
row.CreateCell(_cellNum - 1).SetCellValue(value); row.CreateCell(_cellNum - 1).SetCellValue(value);
} }
} }
if (destName == "other")
{
ICell cell = row.GetCell(_cellNum - 1);
var fieldName = name.Split('.')[1].ToLower();
var value = fieldName switch
{
"printdate" => DateTime.Now.ToString("yyyy-MM-dd"),
_ => "",
};
if (cell != null)
{
row.Cells[_cellNum - 1].SetCellValue(value);
}
else
{
row.CreateCell(_cellNum - 1).SetCellValue(value);
}
}
} }
} }
} }
@ -4504,13 +4554,13 @@ namespace Myshipping.Application
if (entity.Where(x => x.Row == _row && x.Column == _cellNum).Count() > 0) if (entity.Where(x => x.Row == _row && x.Column == _cellNum).Count() > 0)
{ {
var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault(); var name = entity.Where(x => x.Row == _row && x.Column == _cellNum).Select(x => x.Field).FirstOrDefault();
var destName = name.Split('.')[0].ToLower();
if (name.Split('.')[0].ToLower() == "order") if (destName == "order" || destName == "suborder")
{ {
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order))
{ {
var _name = descriptor.Name.ToLower(); var _name = descriptor.Name.ToLower();
if (name.Split('.')[1].ToLower() == _name && name.Split('.')[0].ToLower() == "order") if (name.Split('.')[1].ToLower() == _name)
{ {
var value = descriptor.GetValue(order) != null ? descriptor.GetValue(order).ToString() : ""; var value = descriptor.GetValue(order) != null ? descriptor.GetValue(order).ToString() : "";
if (descriptor.PropertyType.FullName.Contains("DateTime")) if (descriptor.PropertyType.FullName.Contains("DateTime"))
@ -4522,7 +4572,7 @@ namespace Myshipping.Application
} }
} }
if (name.Split('.')[0].ToLower() == "edi") if (destName == "edi")
{ {
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi)) foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(edi))
{ {
@ -4539,7 +4589,7 @@ namespace Myshipping.Application
} }
} }
if (name.Split('.')[0].ToLower() == "userinfo") if (destName == "userinfo")
{ {
var value = string.Empty; var value = string.Empty;
@ -4567,6 +4617,18 @@ namespace Myshipping.Application
srow.CreateCell(_cellNum - 1).SetCellValue(value); srow.CreateCell(_cellNum - 1).SetCellValue(value);
} }
if (destName == "other")
{
var fieldName = name.Split('.')[1].ToLower();
var value = fieldName switch
{
"printdate" => DateTime.Now.ToString("yyyy-MM-dd"),
_ => "",
};
srow.CreateCell(_cellNum - 1).SetCellValue(value);
}
} }
} }
} }
@ -9680,16 +9742,24 @@ namespace Myshipping.Application
BookingCtn ctn = new BookingCtn(); BookingCtn ctn = new BookingCtn();
BookingEDIExt edi = new BookingEDIExt(); BookingEDIExt edi = new BookingEDIExt();
Dictionary<string, string> dic = new Dictionary<string, string>(); Dictionary<string, string> dic = new Dictionary<string, string>();
Dictionary<string, string> dic4 = new Dictionary<string, string>();
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order)) foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order))
{ {
string name = descriptor.Name; string name = descriptor.Name;
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName") if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId")
{ {
continue; continue;
} }
if (name == "CreatedUserName")
{
dic.Add("order.CreatedUserName", "录入人");
dic4.Add("suborder.CreatedUserName", "录入人");
continue;
}
if (!string.IsNullOrWhiteSpace(descriptor.Description)) if (!string.IsNullOrWhiteSpace(descriptor.Description))
{ {
dic.Add("order." + descriptor.Name, descriptor.Description); dic.Add("order." + descriptor.Name, descriptor.Description);
dic4.Add("suborder." + descriptor.Name, descriptor.Description);
} }
} }
@ -9735,12 +9805,19 @@ namespace Myshipping.Application
dic3.Add("userinfo.useremail", "当前登录人邮箱"); dic3.Add("userinfo.useremail", "当前登录人邮箱");
dic3.Add("userinfo.usertenant", "当前登录人所在公司"); dic3.Add("userinfo.usertenant", "当前登录人所在公司");
Dictionary<string, string> dic5 = new Dictionary<string, string>()
{
{"other.PrintDate", "打印日期" }
};
var dynamic = new var dynamic = new
{ {
order = dic, order = dic,
ctn = dic1, ctn = dic1,
edi = dic2, edi = dic2,
userinfo = dic3 userinfo = dic3,
suborder = dic4,
other = dic5
}; };
return dynamic; return dynamic;
} }
@ -11805,10 +11882,22 @@ namespace Myshipping.Application
[HttpPost("/BookingOrder/CancelAllocationSlot")] [HttpPost("/BookingOrder/CancelAllocationSlot")]
public async Task CancelAllocationSlot(long id) public async Task CancelAllocationSlot(long id)
{ {
var slotList = await _repSlotAllocation.AsQueryable().Where(a => a.BOOKING_ID == id).ToListAsync(); var slotList = await _repSlotAllocation.AsQueryable().Where(a => a.BOOKING_ID == id).Select(x => new
var slotIdList = slotList.Select(s => s.Id); {
x.Id,
x.BOOKING_SLOT_TYPE,
x.CARRIERID,
x.CONTRACT_NO,
x.VESSEL,
x.VOYNO,
x.PLACERECEIPT,
x.PLACEDELIVERY
}).ToListAsync();
await _repSlotAllocation.Context.Updateable<BookingSlotAllocation>() if (slotList.Count > 0)
{
var slotIdList = slotList.Select(s => s.Id);
await _repSlotAllocation.Context.Updateable<BookingSlotAllocation>()
.SetColumns(a => a.IsDeleted == true) .SetColumns(a => a.IsDeleted == true)
.SetColumns(a => a.UpdatedTime == DateTime.Now) .SetColumns(a => a.UpdatedTime == DateTime.Now)
.SetColumns(a => a.UpdatedUserId == UserManager.UserId) .SetColumns(a => a.UpdatedUserId == UserManager.UserId)
@ -11816,27 +11905,28 @@ namespace Myshipping.Application
.Where(a => slotIdList.Contains(a.Id)) .Where(a => slotIdList.Contains(a.Id))
.ExecuteCommandAsync(); .ExecuteCommandAsync();
await _repSlotAllocationCtn.Context.Updateable<BookingSlotAllocationCtn>() await _repSlotAllocationCtn.Context.Updateable<BookingSlotAllocationCtn>()
.SetColumns(a => a.IsDeleted == true) .SetColumns(a => a.IsDeleted == true)
.SetColumns(a => a.UpdatedTime == DateTime.Now) .SetColumns(a => a.UpdatedTime == DateTime.Now)
.SetColumns(a => a.UpdatedUserId == UserManager.UserId) .SetColumns(a => a.UpdatedUserId == UserManager.UserId)
.SetColumns(a => a.UpdatedUserName == UserManager.Name) .SetColumns(a => a.UpdatedUserName == UserManager.Name)
.Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID)) .Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID))
.ExecuteCommandAsync(); .ExecuteCommandAsync();
// 更新库存 // 更新库存
foreach (var item in slotList) foreach (var item in slotList)
{ {
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel
{ {
BOOKING_SLOT_TYPE = item.BOOKING_SLOT_TYPE, BOOKING_SLOT_TYPE = item.BOOKING_SLOT_TYPE,
CARRIERID = item.CARRIERID, CARRIERID = item.CARRIERID,
CONTRACT_NO = item.CONTRACT_NO, CONTRACT_NO = item.CONTRACT_NO,
VESSEL = item.VESSEL, VESSEL = item.VESSEL,
VOYNO = item.VOYNO, VOYNO = item.VOYNO,
PLACERECEIPT = item.PLACERECEIPT, PLACERECEIPT = item.PLACERECEIPT,
PLACEDELIVERY = item.PLACEDELIVERY PLACEDELIVERY = item.PLACEDELIVERY
})); }));
}
} }
} }
#endregion #endregion

@ -39,6 +39,13 @@ namespace Myshipping.Core.Entity
[Description("客户id")] [Description("客户id")]
public long? CustomerId { get; set; } public long? CustomerId { get; set; }
/// <summary>
/// 客户名称
/// </summary>
[SugarColumn(ColumnName = "CustomerName")]
[Description("客户名称")]
public string CustomerName { get; set; }
/// <summary> /// <summary>
/// 选项代码 /// 选项代码
/// </summary> /// </summary>

@ -2259,6 +2259,11 @@
客户id 客户id
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.Entity.DjyCustomerParamValue.CustomerName">
<summary>
客户名称
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyCustomerParamValue.ItemCode"> <member name="P:Myshipping.Core.Entity.DjyCustomerParamValue.ItemCode">
<summary> <summary>
选项代码 选项代码
@ -11654,6 +11659,11 @@
客户id 客户id
</summary> </summary>
</member> </member>
<member name="P:Myshipping.Core.Service.DjyCustomerParamValueDto.CustomerName">
<summary>
客户名称
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyCustomerParamValueDto.ItemCode"> <member name="P:Myshipping.Core.Service.DjyCustomerParamValueDto.ItemCode">
<summary> <summary>
选项代码 选项代码

@ -80,27 +80,7 @@ namespace Myshipping.Core.Service
.OrderBy(x => x.Sort) .OrderBy(x => x.Sort)
.ToPagedListAsync(input.PageNo, input.PageSize); .ToPagedListAsync(input.PageNo, input.PageSize);
return list.Adapt<SqlSugarPagedList<DjyCustomerParamValueListOutput>>();
var rtn = list.Adapt<SqlSugarPagedList<DjyCustomerParamValueListOutput>>();
var listParam = await _repParam.AsQueryable().ToListAsync();
var listParamItem = await _repParamItem.AsQueryable().ToListAsync();
var listCustomer = await _repCustomer.AsQueryable().Select(x => new { x.Id, x.ShortName }).ToListAsync();
foreach (var item in rtn.Items)
{
var p = listParam.FirstOrDefault(x => x.ParaCode == item.ParaCode);
item.ParaName = p.ParaName;
var t = listCustomer.FirstOrDefault(x => x.Id == item.CustomerId);
item.CustomerName = t.ShortName;
var it = listParamItem.FirstOrDefault(x => x.ParaCode == item.ParaCode && x.ItemCode == item.ItemCode);
if (it != null)
{
item.ItemCodeName = it.ItemName;
}
}
return rtn;
} }

@ -42,6 +42,11 @@ namespace Myshipping.Core.Service
/// </summary> /// </summary>
public long? CustomerId { get; set; } public long? CustomerId { get; set; }
/// <summary>
/// 客户名称
/// </summary>
public string CustomerName { get; set; }
/// <summary> /// <summary>
/// 选项代码 /// 选项代码
/// </summary> /// </summary>

Loading…
Cancel
Save