|
|
|
@ -66,8 +66,8 @@ namespace Myshipping.Application
|
|
|
|
|
const string MQ_EXCHANGE_NAME = "djy.output.booktruck.ds6";
|
|
|
|
|
const string MQ_QUEUE_NAME = "djy.output.booktruck.ds6";
|
|
|
|
|
|
|
|
|
|
public BookingTruckService(ISysCacheService cache, ILogger<BookingTruckService> logger,
|
|
|
|
|
SqlSugarRepository<BookingTruck> bookingTruckRepository,
|
|
|
|
|
public BookingTruckService(ISysCacheService cache, ILogger<BookingTruckService> logger,
|
|
|
|
|
SqlSugarRepository<BookingTruck> bookingTruckRepository,
|
|
|
|
|
SqlSugarRepository<BookingTruckCtn> bookingTruckContaRepository,
|
|
|
|
|
SqlSugarRepository<BookingOrder> bookingOrderRepository,
|
|
|
|
|
SqlSugarRepository<BookingCtn> bookingCtnRepository,
|
|
|
|
@ -130,7 +130,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="isCallBack">是否回写</param>
|
|
|
|
|
/// <returns>返回派车Id</returns>
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
private async Task<long> InnerSave(BookingTruckDto info,bool isCallBack = false)
|
|
|
|
|
private async Task<long> InnerSave(BookingTruckDto info, bool isCallBack = false)
|
|
|
|
|
{
|
|
|
|
|
BookingTruck entity = info.Adapt<BookingTruck>();
|
|
|
|
|
|
|
|
|
@ -139,7 +139,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
List<BookingTruckCtn> entityCtnList = info.ContaList.Adapt<List<BookingTruckCtn>>();
|
|
|
|
|
|
|
|
|
|
if(entityCtnList != null && entityCtnList.Count > 0)
|
|
|
|
|
if (entityCtnList != null && entityCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//保存时默认统计箱型箱量
|
|
|
|
|
entity.CntrTotal = string.Join(";", entityCtnList.GroupBy(a => a.CTNALL)
|
|
|
|
@ -182,8 +182,8 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Oh($"派车信息获取失败,派车信息不存在或已作废", typeof(InvalidOperationException));
|
|
|
|
|
|
|
|
|
|
if (!isCallBack)
|
|
|
|
|
{
|
|
|
|
|
//校验
|
|
|
|
|
{
|
|
|
|
|
//校验
|
|
|
|
|
ValidateTruck(OperateTypeEnum.Save, new BookingTruck[] { model });
|
|
|
|
|
|
|
|
|
|
entity.UpdatedTime = DateTime.Now;
|
|
|
|
@ -229,7 +229,7 @@ namespace Myshipping.Application
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _bookingTruckContaRepository.DeleteAsync(x => x.TruckId == model.Id);
|
|
|
|
|
|
|
|
|
@ -521,7 +521,7 @@ namespace Myshipping.Application
|
|
|
|
|
//这里岗位是调度的信息,如果默认只有一条记录,取第一条,其他情况不返回默认值
|
|
|
|
|
var userPosInfo = await _sysUserService.QueryUserByPos("", "PCDD");
|
|
|
|
|
|
|
|
|
|
if(userPosInfo.Count == 1)
|
|
|
|
|
if (userPosInfo.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
model.DispatcherId = userPosInfo.FirstOrDefault().SysEmpId;
|
|
|
|
|
model.DispatcherName = userPosInfo.FirstOrDefault().SysEmpName;
|
|
|
|
@ -529,9 +529,9 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
var yardList = await _djyCustomerService.QuerytDjyCustomerInfo("", new string[] { "yard" }, 999);
|
|
|
|
|
|
|
|
|
|
if(yardList.Count > 0)
|
|
|
|
|
if (yardList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if((string.IsNullOrWhiteSpace(model.YARDCONTRACT) || string.IsNullOrWhiteSpace(model.YARDCONTRACTTEL))
|
|
|
|
|
if ((string.IsNullOrWhiteSpace(model.YARDCONTRACT) || string.IsNullOrWhiteSpace(model.YARDCONTRACTTEL))
|
|
|
|
|
&& !string.IsNullOrWhiteSpace(model.YARD))
|
|
|
|
|
{
|
|
|
|
|
var currYardList = yardList.Select(a =>
|
|
|
|
@ -834,7 +834,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 批量提交派车
|
|
|
|
|
/// <summary>
|
|
|
|
@ -856,7 +856,7 @@ namespace Myshipping.Application
|
|
|
|
|
var list = _bookingTruckRepository.AsQueryable()
|
|
|
|
|
.Where(a => ids.Contains(a.Id)).ToList();
|
|
|
|
|
|
|
|
|
|
if(list.Count != ids.Length)
|
|
|
|
|
if (list.Count != ids.Length)
|
|
|
|
|
throw Oops.Oh($"部分派车信息获取失败,不能提交,派车信息不存在或已作废");
|
|
|
|
|
|
|
|
|
|
//校验
|
|
|
|
@ -864,19 +864,21 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
List<Task<TaskManageOrderResultDto>> taskList = new List<Task<TaskManageOrderResultDto>>();
|
|
|
|
|
|
|
|
|
|
list.ForEach(async tk => {
|
|
|
|
|
list.ForEach(async tk =>
|
|
|
|
|
{
|
|
|
|
|
taskList.Add(InnerSubmit(new BookingTruckDto { Id = tk.Id }, batchNo, false));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//等待所有结果
|
|
|
|
|
Task.WaitAll(taskList.ToArray(),20000);
|
|
|
|
|
Task.WaitAll(taskList.ToArray(), 20000);
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "提交成功";
|
|
|
|
|
|
|
|
|
|
List<string> msgList = new List<string>();
|
|
|
|
|
|
|
|
|
|
taskList.ForEach(async a => {
|
|
|
|
|
taskList.ForEach(async a =>
|
|
|
|
|
{
|
|
|
|
|
var rlt = a.Result;
|
|
|
|
|
|
|
|
|
|
if (!rlt.succ)
|
|
|
|
@ -971,7 +973,8 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
List<Task<TaskManageOrderResultDto>> taskList = new List<Task<TaskManageOrderResultDto>>();
|
|
|
|
|
|
|
|
|
|
list.ForEach(async tk => {
|
|
|
|
|
list.ForEach(async tk =>
|
|
|
|
|
{
|
|
|
|
|
taskList.Add(InnerCancel(tk.Id, batchNo));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -983,7 +986,8 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
List<string> msgList = new List<string>();
|
|
|
|
|
|
|
|
|
|
taskList.ForEach(async a => {
|
|
|
|
|
taskList.ForEach(async a =>
|
|
|
|
|
{
|
|
|
|
|
var rlt = a.Result;
|
|
|
|
|
|
|
|
|
|
if (!rlt.succ)
|
|
|
|
@ -1014,7 +1018,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="id">派车主键</param>
|
|
|
|
|
/// <param name="batchNo">批次号</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
private async Task<TaskManageOrderResultDto> InnerCancel(long id,string batchNo)
|
|
|
|
|
private async Task<TaskManageOrderResultDto> InnerCancel(long id, string batchNo)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
撤销派车流程
|
|
|
|
@ -1074,7 +1078,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
DateTime eDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TimeSpan ts = eDate.Subtract(bDate);
|
|
|
|
|
var timeDiff = ts.TotalMilliseconds;
|
|
|
|
|
|
|
|
|
@ -1091,7 +1095,7 @@ namespace Myshipping.Application
|
|
|
|
|
model.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
model.UpdatedUserName = UserManager.Name;
|
|
|
|
|
model.TaskNo = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _bookingTruckRepository.AsUpdateable(model).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.Status,
|
|
|
|
@ -1148,7 +1152,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="ids">派车主键组</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpPost("/BookingTruck/DeleteBatch")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> DeleteBatch([FromBody]long[] ids)
|
|
|
|
|
public async Task<TaskManageOrderResultDto> DeleteBatch([FromBody] long[] ids)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
@ -1164,7 +1168,8 @@ namespace Myshipping.Application
|
|
|
|
|
//先校验
|
|
|
|
|
ValidateTruck(OperateTypeEnum.Delete, truckOrderList.ToArray());
|
|
|
|
|
|
|
|
|
|
truckOrderList.ForEach(async tk => {
|
|
|
|
|
truckOrderList.ForEach(async tk =>
|
|
|
|
|
{
|
|
|
|
|
await _bookingTruckRepository.UpdateAsync(x => x.Id == tk.Id,
|
|
|
|
|
x => new BookingTruck { IsDeleted = true });
|
|
|
|
|
});
|
|
|
|
@ -1247,7 +1252,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="printType">打印类型,10:FastReport、20:Excel模板</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/BookingTruck/Print")]
|
|
|
|
|
public async Task<string> Print([FromQuery]long id, [FromQuery] long templateId, [FromQuery] string cateCode, [FromQuery] PrintFileTypeEnum printFileType = PrintFileTypeEnum.PDF,
|
|
|
|
|
public async Task<string> Print([FromQuery] long id, [FromQuery] long templateId, [FromQuery] string cateCode, [FromQuery] PrintFileTypeEnum printFileType = PrintFileTypeEnum.PDF,
|
|
|
|
|
[FromQuery] BookingPrintTemplateType printType = BookingPrintTemplateType.FastReport)
|
|
|
|
|
{
|
|
|
|
|
var printTemplate = await _bookingPrintTemplateTemplate.AsQueryable().Filter(null, true)
|
|
|
|
@ -1259,7 +1264,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var truckOrder = await _bookingTruckRepository.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
if(!truckOrder.NeedArriveTime.HasValue)
|
|
|
|
|
if (!truckOrder.NeedArriveTime.HasValue)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh("要求送达日期不能为空");
|
|
|
|
|
}
|
|
|
|
@ -1275,7 +1280,7 @@ namespace Myshipping.Application
|
|
|
|
|
//{
|
|
|
|
|
// throw Oops.Bah("分类代码参数不正确");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (printType == BookingPrintTemplateType.FastReport)
|
|
|
|
|
{
|
|
|
|
|
#region FastReport打印
|
|
|
|
@ -1616,7 +1621,7 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
model.Vessel = bookingOrder.VESSEL;
|
|
|
|
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(bookingOrder.VOYNO))
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.VOYNO))
|
|
|
|
|
{
|
|
|
|
|
model.VoyNo = bookingOrder.VOYNO;
|
|
|
|
|
}
|
|
|
|
@ -1624,7 +1629,7 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
model.VoyNo = bookingOrder.VOYNOINNER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.MBLNo = bookingOrder.MBLNO;
|
|
|
|
|
model.CarrierID = bookingOrder.CARRIERID;
|
|
|
|
|
model.Carrier = bookingOrder.CARRIER;
|
|
|
|
@ -1668,7 +1673,7 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Oh($"派车状态只有暂存、已撤销才能提交", typeof(InvalidOperationException));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(entityArg.Any(a=> !a.DispatcherId.HasValue ||(a.DispatcherId.HasValue && a.DispatcherId.Value == 0)))
|
|
|
|
|
if (entityArg.Any(a => !a.DispatcherId.HasValue || (a.DispatcherId.HasValue && a.DispatcherId.Value == 0)))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"未填写调度,不能提交", typeof(InvalidOperationException));
|
|
|
|
|
}
|
|
|
|
@ -1693,9 +1698,9 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Oh($"派车状态只有暂存、已撤销才能作废", typeof(InvalidOperationException));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(operateType == OperateTypeEnum.DispatchBackSave)
|
|
|
|
|
else if (operateType == OperateTypeEnum.DispatchBackSave)
|
|
|
|
|
{
|
|
|
|
|
if (entityArg.Any(a => a.Status != BookingTruckStatus.SUBMITED.ToString()
|
|
|
|
|
if (entityArg.Any(a => a.Status != BookingTruckStatus.SUBMITED.ToString()
|
|
|
|
|
&& a.Status != BookingTruckStatus.SEND_DISPATCH.ToString()
|
|
|
|
|
&& a.Status != BookingTruckStatus.CANCEL_DISPATCH.ToString()))
|
|
|
|
|
{
|
|
|
|
@ -1729,12 +1734,12 @@ namespace Myshipping.Application
|
|
|
|
|
if (bookingTruckInfo == null)
|
|
|
|
|
throw Oops.Oh($"派车信息不存在", typeof(InvalidOperationException));
|
|
|
|
|
|
|
|
|
|
if(bookingTruckInfo.Status != BookingTruckStatus.SUBMITED.ToString()
|
|
|
|
|
&& bookingTruckInfo.Status != BookingTruckStatus.SEND_DISPATCH.ToString()
|
|
|
|
|
if (bookingTruckInfo.Status != BookingTruckStatus.SUBMITED.ToString()
|
|
|
|
|
&& bookingTruckInfo.Status != BookingTruckStatus.SEND_DISPATCH.ToString()
|
|
|
|
|
&& bookingTruckInfo.Status != BookingTruckStatus.CANCEL_DISPATCH.ToString())
|
|
|
|
|
throw Oops.Oh($"当前派车信息不是已提交状态不能接收回写", typeof(InvalidOperationException));
|
|
|
|
|
|
|
|
|
|
var id = await InnerSave(info,true);
|
|
|
|
|
var id = await InnerSave(info, true);
|
|
|
|
|
|
|
|
|
|
BookingTruckSyncMessageInfo messageInfo = new BookingTruckSyncMessageInfo();
|
|
|
|
|
|
|
|
|
@ -1757,7 +1762,7 @@ namespace Myshipping.Application
|
|
|
|
|
BookingTruckSyncMessageMainInfo bookingTruckSyncDto = info.Adapt<BookingTruckSyncMessageMainInfo>();
|
|
|
|
|
bookingTruckSyncDto.ContaList = info.ContaList.Adapt<List<BookingTruckCtnDto>>();
|
|
|
|
|
|
|
|
|
|
if(info.CallBackStatus == BookingTruckStatus.CANCEL_DISPATCH.ToString())
|
|
|
|
|
if (info.CallBackStatus == BookingTruckStatus.CANCEL_DISPATCH.ToString())
|
|
|
|
|
{
|
|
|
|
|
bookingTruckSyncDto.OperType = "Delete";
|
|
|
|
|
}
|
|
|
|
@ -1773,12 +1778,12 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
var mqRlt = await PushSyncBookingTruckMQToDS6(messageInfo);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("发送MQ,rlt={rlt}",JSON.Serialize(mqRlt));
|
|
|
|
|
_logger.LogInformation("发送MQ,rlt={rlt}", JSON.Serialize(mqRlt));
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "保存成功";
|
|
|
|
|
result.ext = id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -1809,13 +1814,13 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
throw Oops.Bah("字典未配置 url_set->BookingOrderMQUri 请联系管理员");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//请求MQ
|
|
|
|
|
var json = JSON.Serialize(bookingTruckSyncMessageInfo);
|
|
|
|
|
var mqRlt = MQHelper.SendMQ(json, mqUrl, MQ_EXCHANGE_NAME, MQ_QUEUE_NAME
|
|
|
|
|
, bookingTruckSyncMessageInfo.Main.TenantId);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("发送MQ请求完成,结果={rlt}",JSON.Serialize(mqRlt));
|
|
|
|
|
_logger.LogInformation("发送MQ请求完成,结果={rlt}", JSON.Serialize(mqRlt));
|
|
|
|
|
|
|
|
|
|
if (mqRlt.succ)
|
|
|
|
|
{
|
|
|
|
@ -1828,7 +1833,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = ex.GetMessage("同步东胜失败");
|
|
|
|
@ -1854,8 +1859,8 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Oh($"派车信息不能为空", typeof(InvalidOperationException));
|
|
|
|
|
|
|
|
|
|
BookingOrder bookingOrder = null;
|
|
|
|
|
|
|
|
|
|
if(entity.BookingId.HasValue)
|
|
|
|
|
|
|
|
|
|
if (entity.BookingId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
bookingOrder = _bookingOrderRepository.AsQueryable().First(x => x.Id == entity.BookingId.Value);
|
|
|
|
|
}
|
|
|
|
@ -1863,13 +1868,13 @@ namespace Myshipping.Application
|
|
|
|
|
string yardId = string.Empty;
|
|
|
|
|
string mblNo = string.Empty;
|
|
|
|
|
|
|
|
|
|
if(bookingOrder != null)
|
|
|
|
|
if (bookingOrder != null)
|
|
|
|
|
{
|
|
|
|
|
yardId = bookingOrder.YARDID;
|
|
|
|
|
mblNo = bookingOrder.MBLNO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(yardId))
|
|
|
|
|
if (string.IsNullOrWhiteSpace(yardId))
|
|
|
|
|
yardId = entity.YARDID;
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(mblNo))
|
|
|
|
@ -1885,8 +1890,8 @@ namespace Myshipping.Application
|
|
|
|
|
throw Oops.Bah("提单号不能为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rtn = await YardDataHelper.GetYardData(bookingOrder.TenantId.Value, bookingOrder.TenantName,
|
|
|
|
|
mblNo, yardId , isWeb);
|
|
|
|
|
var rtn = await YardDataHelper.GetYardData(UserManager.UserId, bookingOrder.TenantId.Value, bookingOrder.TenantName,
|
|
|
|
|
mblNo, yardId, isWeb);
|
|
|
|
|
|
|
|
|
|
if (!rtn.Key)
|
|
|
|
|
{
|
|
|
|
|