修改订舱台账的批量修改

master
jianghaiqing 6 months ago
parent 0a8e7b55b9
commit f89e467b41

@ -12824,6 +12824,8 @@ namespace Myshipping.Application
//oldOrderList.ForEach()
List<string> updateColumnList = new List<string>();
foreach (var oldOrder in oldOrderList)
{
var newOrder = oldOrder.Adapt<BookingOrder>();
@ -12833,46 +12835,64 @@ namespace Myshipping.Application
if(!string.IsNullOrWhiteSpace(dto.VESSEL))
{
newOrder.VESSEL = dto.VESSEL;
updateColumnList.Add(nameof(BookingOrder.VESSEL));
}
if (!string.IsNullOrWhiteSpace(dto.VOYNOINNER))
{
newOrder.VOYNOINNER = dto.VOYNOINNER;
updateColumnList.Add(nameof(BookingOrder.VOYNOINNER));
}
if (dto.ETD.HasValue)
{
newOrder.ETD = dto.ETD;
updateColumnList.Add(nameof(BookingOrder.ETD));
}
if (!string.IsNullOrWhiteSpace(dto.PORTDISCHARGEID))
{
newOrder.PORTDISCHARGEID = dto.PORTDISCHARGEID;
updateColumnList.Add(nameof(BookingOrder.PORTDISCHARGEID));
}
if (!string.IsNullOrWhiteSpace(dto.PORTDISCHARGE))
{
newOrder.PORTDISCHARGE = dto.PORTDISCHARGE;
updateColumnList.Add(nameof(BookingOrder.PORTDISCHARGE));
}
if (!string.IsNullOrWhiteSpace(dto.DESTINATIONID))
{
newOrder.DESTINATIONID = dto.DESTINATIONID;
updateColumnList.Add(nameof(BookingOrder.DESTINATIONID));
}
if (!string.IsNullOrWhiteSpace(dto.DESTINATION))
{
newOrder.DESTINATION = dto.DESTINATION;
updateColumnList.Add(nameof(BookingOrder.DESTINATION));
}
if (dto.CLOSINGDATE.HasValue)
{
newOrder.CLOSINGDATE = dto.CLOSINGDATE;
updateColumnList.Add(nameof(BookingOrder.CLOSINGDATE));
}
if (dto.CLOSEDOCDATE.HasValue)
{
newOrder.CLOSEDOCDATE = dto.CLOSEDOCDATE;
updateColumnList.Add(nameof(BookingOrder.CLOSEDOCDATE));
}
//这里只处理值为空,并且前端强制指定了才赋空值处理
@ -12881,46 +12901,57 @@ namespace Myshipping.Application
if (dto.enforceUpdateField.Any(a => a.Equals("VESSEL", StringComparison.OrdinalIgnoreCase)) && string.IsNullOrWhiteSpace(dto.VESSEL))
{
newOrder.VESSEL = dto.VESSEL;
updateColumnList.Add(nameof(BookingOrder.VESSEL));
}
if (dto.enforceUpdateField.Any(a => a.Equals("VOYNOINNER", StringComparison.OrdinalIgnoreCase)) && string.IsNullOrWhiteSpace(dto.VOYNOINNER))
{
newOrder.VOYNOINNER = dto.VOYNOINNER;
}
if (dto.enforceUpdateField.Any(a => a.Equals("ETD", StringComparison.OrdinalIgnoreCase)) && !dto.ETD.HasValue)
{
newOrder.ETD = dto.ETD;
updateColumnList.Add(nameof(BookingOrder.VOYNOINNER));
}
if (dto.enforceUpdateField.Any(a => a.Equals("PORTDISCHARGEID", StringComparison.OrdinalIgnoreCase)) && string.IsNullOrWhiteSpace(dto.PORTDISCHARGEID))
{
newOrder.PORTDISCHARGEID = dto.PORTDISCHARGEID;
updateColumnList.Add(nameof(BookingOrder.PORTDISCHARGEID));
}
if (dto.enforceUpdateField.Any(a => a.Equals("PORTDISCHARGE", StringComparison.OrdinalIgnoreCase)) && string.IsNullOrWhiteSpace(dto.PORTDISCHARGE))
{
newOrder.PORTDISCHARGE = dto.PORTDISCHARGE;
updateColumnList.Add(nameof(BookingOrder.PORTDISCHARGE));
}
if (dto.enforceUpdateField.Any(a => a.Equals("DESTINATIONID", StringComparison.OrdinalIgnoreCase)) && string.IsNullOrWhiteSpace(dto.DESTINATIONID))
{
newOrder.DESTINATIONID = dto.DESTINATIONID;
updateColumnList.Add(nameof(BookingOrder.DESTINATIONID));
}
if (dto.enforceUpdateField.Any(a => a.Equals("DESTINATION", StringComparison.OrdinalIgnoreCase)) && string.IsNullOrWhiteSpace(dto.DESTINATION))
{
newOrder.DESTINATION = dto.DESTINATION;
updateColumnList.Add(nameof(BookingOrder.DESTINATION));
}
if (dto.enforceUpdateField.Any(a => a.Equals("CLOSINGDATE", StringComparison.OrdinalIgnoreCase)) && !dto.CLOSINGDATE.HasValue)
{
newOrder.CLOSINGDATE = dto.CLOSINGDATE;
updateColumnList.Add(nameof(BookingOrder.CLOSINGDATE));
}
if (dto.enforceUpdateField.Any(a => a.Equals("CLOSEDOCDATE", StringComparison.OrdinalIgnoreCase)) && !dto.CLOSEDOCDATE.HasValue)
{
newOrder.CLOSEDOCDATE = dto.CLOSEDOCDATE;
updateColumnList.Add(nameof(BookingOrder.CLOSEDOCDATE));
}
}
//newOrder.VOYNOINNER = dto.VOYNOINNER;
@ -12936,23 +12967,29 @@ namespace Myshipping.Application
//newOrder.CLOSEDOCDATE = dto.CLOSEDOCDATE;
await SaveLog(newOrder, oldOrder, "批量编辑台账");
await _rep.AsUpdateable(newOrder).UpdateColumns(updateColumnList.ToArray()).ExecuteCommandAsync();
//await _rep.UpdateAsync(x => dto.Id.Contains(x.Id), x => new BookingOrder
//{
// VERSION = version,
// VESSEL = dto.VESSEL,
// VOYNOINNER = dto.VOYNOINNER,
// ETD = dto.ETD,
// VOYNO = dto.VOYNO,
// PORTDISCHARGEID = dto.PORTDISCHARGEID,
// PORTDISCHARGE = dto.PORTDISCHARGE,
// DESTINATIONID = dto.DESTINATIONID,
// DESTINATION = dto.DESTINATION,
// CLOSINGDATE = dto.CLOSINGDATE,
// CLOSEDOCDATE = dto.CLOSEDOCDATE
//});
await SendBookingOrder(dto.Id.ToArray());
}
await _rep.UpdateAsync(x => dto.Id.Contains(x.Id), x => new BookingOrder
{
VERSION = version,
VESSEL = dto.VESSEL,
VOYNOINNER = dto.VOYNOINNER,
ETD = dto.ETD,
VOYNO = dto.VOYNO,
PORTDISCHARGEID = dto.PORTDISCHARGEID,
PORTDISCHARGE = dto.PORTDISCHARGE,
DESTINATIONID = dto.DESTINATIONID,
DESTINATION = dto.DESTINATION,
CLOSINGDATE = dto.CLOSINGDATE,
CLOSEDOCDATE = dto.CLOSEDOCDATE
});
await SendBookingOrder(dto.Id.ToArray());
}
#endregion
}

@ -337,21 +337,47 @@ namespace Myshipping.Application
if (detailPKIds.Length != detailList.Count)
{
throw Oops.Oh($"未选择订单明细检索失败");
throw Oops.Oh($"检索明细数据失败,检索数据不存在或已作废");
}
var bookIdList = detailList.Where(t => t.IS_ENABLE == true)
.Select(t => t.BOOKING_ID.Value).ToList();
if (bookIdList.Count == 0)
if (detailList.Any(a => !a.BOOKING_ID.HasValue))
{
throw Oops.Oh($"相关订单没有课");
throw Oops.Oh($"明细相关的订舱数据检索失败,请确认订舱数据是否存在");
}
//需要根据订单的往来单位统一推送一封邮件,里面有提单号列表
var bookList = _bookingOrderRepository.AsQueryable().Where(a => bookIdList.Contains(a.Id)
&& a.IsDeleted == false && (a.ParentId == null || a.ParentId == 0)).ToList();
var checkList = detailList.GroupJoin(bookList, l => l.BOOKING_ID.Value, r => r.Id, (l, r) =>
{
var currList = r.ToList();
if (currList.Count == 0)
return new { IsNoBooking = true, MblNo = l.MBL_NO };
return new { IsNoBooking = false, MblNo = l.MBL_NO };
}).Where(a => a.IsNoBooking).Select(a => a.MblNo).ToList();
if (checkList.Count > 0)
{
throw Oops.Oh($"明细提单号对应订舱没有记录,{string.Join(",", checkList.ToArray())}");
}
//还需要判断订舱是否录了客户联系人
var bookingContactList = _bookingOrderContactRepository.AsQueryable().Filter(null, true)
.Where(a => bookIdList.Contains(a.BookingId.Value) && a.IsDeleted == false).ToList();
//按照往来单位来合并订单,一个客户一个邮件来提醒
var gList = bookList.GroupBy(a => a.CUSTOMERID).Select(a =>
{
var currList = a.ToList();
return new { CustId = a.Key, CustName = currList.FirstOrDefault().CUSTOMERNAME, OrderList = currList };
}).ToList();
}
@ -382,8 +408,7 @@ namespace Myshipping.Application
var bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == bookingId);
var bookingContactList = _bookingOrderContactRepository.AsQueryable().Filter(null, true)
.Where(a => a.BookingId == bookingId).ToList();
if (bookingContactList == null || bookingContactList.Count == 0)
{

Loading…
Cancel
Save