wanghaomei 2 years ago
commit fbbbf6d65b

@ -814,113 +814,113 @@ namespace Myshipping.Application
}
#region 废弃代码
//[HttpPost("/BookingOrder/AddOrUpdate")]
//public async Task<long> AddOrUpdate(BookingOrderDto Dto)
//{
// if (Dto == null)
// {
// throw Oops.Bah("请传入正常数据!");
// }
[HttpPost("/BookingOrder/AddOrUpdate")]
public async Task<long> AddOrUpdate(BookingOrderDto Dto)
{
if (Dto == null)
{
throw Oops.Bah("请传入正常数据!");
}
if (Dto.Id == 0)
{
return await Add(Dto);
}
else
{
await Update(Dto);
return Dto.Id;
}
}
/// <summary>
/// 增加订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/Add")]
public async Task<long> Add(BookingOrderDto input)
{
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
var ms = JsonUtil.TrimFields(input);
if (!string.IsNullOrEmpty(ms))
{
throw Oops.Bah(ms);
}
if (input.ctnInputs != null)
{
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
input.CNTRTOTAL = string.Join(" / ", groupList);
}
if (!string.IsNullOrWhiteSpace(input.MBLNO))
{
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId).FirstAsync();
if (et != null)
{
// if (Dto.Id == 0)
// {
// return await Add(Dto);
// }
// else
// {
// await Update(Dto);
// return Dto.Id;
// }
//}
throw Oops.Bah("当前提单号已存在,请勿重复录入!");
///// <summary>
///// 增加订舱
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//[SqlSugarUnitOfWork]
//[HttpPost("/BookingOrder/Add")]
//public async Task<long> Add(BookingOrderDto input)
//{
// JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
// var ms = JsonUtil.TrimFields(input);
// if (!string.IsNullOrEmpty(ms))
// {
// throw Oops.Bah(ms);
// }
// if (input.ctnInputs != null)
// {
// var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
// input.CNTRTOTAL = string.Join(" / ", groupList);
// }
// if (!string.IsNullOrWhiteSpace(input.MBLNO))
// {
// var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId).FirstAsync();
// if (et != null)
// {
}
}
// throw Oops.Bah("当前提单号已存在,请勿重复录入!");
// }
// }
var entity = input.Adapt<BookingOrder>();
entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
//entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
await _rep.InsertAsync(entity);
if (input.ctnInputs != null)
{
foreach (var item in input.ctnInputs)
{
var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity);
//这里保存有可能没有添加多品名,所有箱下没有货物信息
if (item.ctnDetailInputs != null)
{
foreach (var it in item.ctnDetailInputs)
{
var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail);
}
}
}
}
// var entity = input.Adapt<BookingOrder>();
// entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
// //entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
// await _rep.InsertAsync(entity);
// if (input.ctnInputs != null)
// {
// foreach (var item in input.ctnInputs)
// {
// var ctnentity = item.Adapt<BookingCtn>();
// ctnentity.BILLID = entity.Id;
// await _repCtn.InsertAsync(ctnentity);
if (input.BookingEDIExt != null)
{
//写入EDI扩展
var ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
// //这里保存有可能没有添加多品名,所有箱下没有货物信息
// if (item.ctnDetailInputs != null)
// {
// foreach (var it in item.ctnDetailInputs)
// {
// var ctndetail = it.Adapt<BookingCtnDetail>();
// ctndetail.CTNID = ctnentity.Id;
// await _ctndetailrep.InsertAsync(ctndetail);
// }
// }
// }
// }
ediExtEntity.BookingId = entity.Id;
// if (input.BookingEDIExt != null)
// {
// //写入EDI扩展
// var ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
await _bookingEDIExt.InsertAsync(ediExtEntity);
}
// ediExtEntity.BookingId = entity.Id;
////添加booking日志
await _bookinglog.InsertAsync(new BookingLog
{
Type = "Add",
BookingId = entity.Id,
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
});
// await _bookingEDIExt.InsertAsync(ediExtEntity);
// }
//////分单不调用
//if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
//{
// await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
// ////添加booking日志
// await _bookinglog.InsertAsync(new BookingLog
// {
// Type = "Add",
// BookingId = entity.Id,
// TenantId = Convert.ToInt64(UserManager.TENANT_ID),
// CreatedTime = DateTime.Now,
// CreatedUserId = UserManager.UserId,
// CreatedUserName = UserManager.Name
// });
// //////分单不调用
// //if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
// //{
// // await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
// //}
// return entity.Id;
//}
return entity.Id;
}
#endregion
/// <summary>
/// 删除订舱
/// </summary>
@ -1071,161 +1071,161 @@ namespace Myshipping.Application
}
#region 废弃代码
///// <summary>
///// 更新订舱
///// </summary>
///// <param name="input"></param>
///// <returns></returns>
//[SqlSugarUnitOfWork]
//[HttpPost("/BookingOrder/Update")]
//public async Task Update(BookingOrderDto input)
//{
/// <summary>
/// 更新订舱
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/Update")]
public async Task Update(BookingOrderDto input)
{
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
JsonUtil.TrimFields(input);
if (input.ctnInputs != null)
{
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
input.CNTRTOTAL = string.Join(" / ", groupList);
}
var main = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync();
// JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YARDID", "YardContract", "YardContractTel", "YardContractEmail", "MARKS", "DESCRIPTION", "CONSIGNEENAME", "SHIPPERNAME", "NOTIFYPARTYNAME");
// JsonUtil.TrimFields(input);
// if (input.ctnInputs != null)
// {
// var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
// input.CNTRTOTAL = string.Join(" / ", groupList);
// }
// var main = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync();
if (!string.IsNullOrWhiteSpace(input.MBLNO))
{
var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId && x.Id != input.Id).FirstAsync();
if (et != null)
{
// if (!string.IsNullOrWhiteSpace(input.MBLNO))
// {
// var et = await _rep.Where(x => x.MBLNO == input.MBLNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId && x.Id != input.Id).FirstAsync();
// if (et != null)
// {
throw Oops.Bah("当前提单号已存在,请勿重复录入!");
// throw Oops.Bah("当前提单号已存在,请勿重复录入!");
}
}
// }
// }
var entity = input.Adapt<BookingOrder>();
//entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
await _rep.AsUpdateable(entity).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync();
await _repCtn.DeleteAsync(x => x.BILLID == input.Id);
await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID));
if (input.ctnInputs != null)
{
foreach (var item in input.ctnInputs)
{
var ctnentity = item.Adapt<BookingCtn>();
ctnentity.BILLID = entity.Id;
await _repCtn.InsertAsync(ctnentity);
if (item.ctnDetailInputs != null)
{
foreach (var it in item.ctnDetailInputs)
{
var ctndetail = it.Adapt<BookingCtnDetail>();
ctndetail.CTNID = ctnentity.Id;
await _ctndetailrep.InsertAsync(ctndetail);
}
}
}
}
// var entity = input.Adapt<BookingOrder>();
// //entity.TOTALNO = NumberToUpper.ToUpper(entity.PKGS == null ? 0 : entity.PKGS);
// await _rep.AsUpdateable(entity).IgnoreColumns(it => new
// {
// it.ParentId,
// it.TenantId,
// it.CreatedTime,
// it.CreatedUserId,
// it.CreatedUserName,
// it.TenantName,
// it.IsDeleted,
// it.BOOKINGNO
// }).ExecuteCommandAsync();
// var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync();
// await _repCtn.DeleteAsync(x => x.BILLID == input.Id);
// await _ctndetailrep.DeleteAsync(x => ctnlist.Contains((long)x.CTNID));
// if (input.ctnInputs != null)
// {
// foreach (var item in input.ctnInputs)
// {
// var ctnentity = item.Adapt<BookingCtn>();
// ctnentity.BILLID = entity.Id;
// await _repCtn.InsertAsync(ctnentity);
// if (item.ctnDetailInputs != null)
// {
// foreach (var it in item.ctnDetailInputs)
// {
// var ctndetail = it.Adapt<BookingCtnDetail>();
// ctndetail.CTNID = ctnentity.Id;
// await _ctndetailrep.InsertAsync(ctndetail);
// }
// }
// }
// }
if (input.BookingEDIExt != null)
{
//检索EDI扩展
var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == input.Id);
// if (input.BookingEDIExt != null)
// {
// //检索EDI扩展
// var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == input.Id);
if (ediExtEntity == null)
{
//写入EDI扩展
ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
ediExtEntity.BookingId = entity.Id;
// if (ediExtEntity == null)
// {
// //写入EDI扩展
// ediExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
// ediExtEntity.BookingId = entity.Id;
await _bookingEDIExt.InsertAsync(ediExtEntity);
}
else
{
//更新EDI扩展
var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
// await _bookingEDIExt.InsertAsync(ediExtEntity);
// }
// else
// {
// //更新EDI扩展
// var currEdiExtEntity = input.BookingEDIExt.Adapt<BookingEDIExt>();
currEdiExtEntity.Id = ediExtEntity.Id;
currEdiExtEntity.BookingId = ediExtEntity.BookingId;
// currEdiExtEntity.Id = ediExtEntity.Id;
// currEdiExtEntity.BookingId = ediExtEntity.BookingId;
await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new
{
it.BookingId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName
}).ExecuteCommandAsync();
}
}
// await _bookingEDIExt.AsUpdateable(currEdiExtEntity).IgnoreColumns(it => new
// {
// it.BookingId,
// it.TenantId,
// it.CreatedTime,
// it.CreatedUserId,
// it.CreatedUserName
// }).ExecuteCommandAsync();
// }
// }
bool flag = true;
long bid = 0;
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))
{
string name = descriptor.Name;
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
{
continue;
}
object value = descriptor.GetValue(entity);
var oldvalue = main.GetType().GetProperty(name).GetValue(main, null);
// bool flag = true;
// long bid = 0;
// foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))
// {
// string name = descriptor.Name;
// if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
// {
// continue;
// }
// object value = descriptor.GetValue(entity);
// var oldvalue = main.GetType().GetProperty(name).GetValue(main, null);
if (name == "KGS" || name == "CBM")
{
if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue))
{
continue;
}
}
string _oldvalue = oldvalue != null ? oldvalue.ToString() : "";
string _value = value != null ? value.ToString() : "";
if (_oldvalue != _value && !string.IsNullOrWhiteSpace(descriptor.Description))
{
if (flag)
{
////添加booking日志
bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
{
Type = "Edit",
BookingId = entity.Id,
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
CreatedTime = DateTime.Now,
CreatedUserId = UserManager.UserId,
CreatedUserName = UserManager.Name
});
flag = false;
}
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
{
PId = bid,
Field = descriptor.Description,
OldValue = _oldvalue,
NewValue = _value,
});
//if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO")
//{
// if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
// if (name == "KGS" || name == "CBM")
// {
// if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue))
// {
// continue;
// }
// }
// string _oldvalue = oldvalue != null ? oldvalue.ToString() : "";
// string _value = value != null ? value.ToString() : "";
// if (_oldvalue != _value && !string.IsNullOrWhiteSpace(descriptor.Description))
// {
// if (flag)
// {
// await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
// ////添加booking日志
// bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
// {
// Type = "Edit",
// BookingId = entity.Id,
// TenantId = Convert.ToInt64(UserManager.TENANT_ID),
// CreatedTime = DateTime.Now,
// CreatedUserId = UserManager.UserId,
// CreatedUserName = UserManager.Name
// });
// flag = false;
// }
// await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
// {
// PId = bid,
// Field = descriptor.Description,
// OldValue = _oldvalue,
// NewValue = _value,
// });
// //if (descriptor.Name == "YARDID" || descriptor.Name == "YARD" || descriptor.Name == "MBLNO")
// //{
// // if (!string.IsNullOrWhiteSpace(input.YARDID) && !string.IsNullOrWhiteSpace(input.YARD) && !string.IsNullOrWhiteSpace(input.MBLNO))
// // {
// // await SendTrace(entity.Id.ToString(), entity.YARDID, entity.YARD, entity.MBLNO);
// // }
// //}
// }
// }
//}
}
}
}
#endregion
/// <summary>
/// 获取订舱明细
/// </summary>
@ -1591,7 +1591,7 @@ namespace Myshipping.Application
var userid = order.CreatedUserId;
if (userid != null)
{
//获取当前用户已经录入的货物状态
var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == input.BookingId).
OrderBy((goods, config) => config.Sort).
@ -1609,7 +1609,7 @@ namespace Myshipping.Application
Sort = config.Sort
}).ToListAsync();
//配置中所有的货物状态
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
{
@ -1624,11 +1624,12 @@ namespace Myshipping.Application
Remark = null,
Sort = config.Sort
}).ToList();
//去掉两个list中重复的货物状态
foreach (var item in list)
{
config.RemoveAll(x => x.ConfigId == item.ConfigId);
}
var t = list.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).DistinctBy(x => x.StatusName).ToList();
if (t != null)
{
@ -1652,12 +1653,7 @@ namespace Myshipping.Application
it.BOOKINGNO
}).ExecuteCommandAsync();
}
List<long> tslist = new List<long>();
tslist.Add((long)input.BookingId);
var itemcode = _cache.GetAllTenantParam().Result.Where(x => x.ParaCode == "BOOKING_DATA_PUSH" && x.TenantId == UserManager.TENANT_ID).Select(x => x.ItemCode).FirstOrDefault();

@ -1273,7 +1273,7 @@ namespace Myshipping.Application
BLNo = currBC.BLNo?.Trim().ToUpper(),
Vessel = currBC.Vessel?.Trim().ToUpper(),
Voyage = currBC.Voyage?.Trim().ToUpper(),
ClosingDate = currBC.ClosingDate,
ClosingDate = currBC.CutSingleTime,
CYCutOffTime = currBC.CYCutOffTime,
ETD = currBC.ETD
};
@ -1370,6 +1370,32 @@ namespace Myshipping.Application
2
3
*/
var bookingOrder = _bookingOrderRepository.AsQueryable().First(a => a.Id == model.BookingOrderId);
if(bookingOrder == null)
throw Oops.Bah($"订舱信息获取失败,订舱信息不存在或已作废");
if (model.ClosingDate.HasValue)
bookingOrder.CLOSINGDATE = model.ClosingDate;
if (model.VGMCutOffTime.HasValue)
bookingOrder.CLOSEVGMDATE = model.VGMCutOffTime;
if (model.CYCutOffTime.HasValue)
bookingOrder.CLOSEDOCDATE = model.CYCutOffTime;
if (model.ETD.HasValue)
bookingOrder.ETD = model.ETD;
if(!string.IsNullOrWhiteSpace(model.Vessel))
bookingOrder.VESSEL = model.Vessel;
if (!string.IsNullOrWhiteSpace(model.Voyage))
bookingOrder.VOYNO = model.Voyage;
if (!string.IsNullOrWhiteSpace(model.Voyage))
bookingOrder.VOYNO = model.Voyage;
if (model.IsLetterYard)
{
_logger.LogInformation("批次={no} 单票BC更新订舱后用户选择了转为入货通知开始发送入货通知", batchNo);

@ -97,7 +97,7 @@ namespace Myshipping.Application
public Nullable<DateTime> PortOfDestinationETA { get; set; }
/// <summary>
/// 预付地点
/// 截单时间
/// </summary>
public Nullable<DateTime> CutSingleTime { get; set; }

@ -23,15 +23,20 @@ namespace Myshipping.Application
public Nullable<long> LetterYardId { get; set; }
/// <summary>
/// 截关时间
/// 截单日期
/// </summary>
public Nullable<DateTime> ClosingDate { get; set; }
/// <summary>
/// 截港时间
/// 截港日期
/// </summary>
public Nullable<DateTime> CYCutOffTime { get; set; }
/// <summary>
/// 截VGM时间
/// </summary>
public Nullable<DateTime> VGMCutOffTime { get; set; }
/// <summary>
/// 船名
/// </summary>

@ -1272,6 +1272,8 @@ namespace Myshipping.Application
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
List<Task<TaskManageOrderResultDto>> taskRunList = new List<Task<TaskManageOrderResultDto>>();
string batchNo = IDGen.NextID().ToString();
_logger.LogInformation("批次={no} ids={ids} 完成任务开始", batchNo, string.Join(",", PKIds));
@ -1282,33 +1284,96 @@ namespace Myshipping.Application
_logger.LogInformation("批次={no} 获取任务完成Num={Num}", batchNo, taskList.Count);
taskList.ForEach(async tsk =>
var noList = PKIds.Select((a, idx) => new { no = idx + 1, id = a }).ToList();
foreach (var bk in taskList)
{
var sortNo = noList.FirstOrDefault(a => a.id == bk.PK_ID).no;
taskRunList.Add(Task.Run(() => InnerManualTask(batchNo,bk, TaskOperTypeEnum.COMPLETE_TASK, sortNo)));
}
await InnerManualTask(batchNo, tsk, TaskOperTypeEnum.COMPLETE_TASK);
});
Task.WaitAll(taskRunList.ToArray());
result.succ = true;
result.msg = "执行成功";
var downResultList = taskRunList.Select(x => x.Result).ToList();
if (downResultList.Any(x => !x.succ))
{
result.succ = false;
result.msg = "执行失败";
}
else
{
result.succ = true;
result.msg = downResultList.FirstOrDefault().msg;
}
result.ext = downResultList;
var succ = downResultList.Count(x => x.succ);
var fail = downResultList.Count(x => !x.succ);
if (succ > 0)
{
result.batchTotal = succ.ToString();
}
else
{
result.batchTotal = "- ";
}
if (fail > 0)
{
result.batchTotal += "/" + fail.ToString();
}
else
{
result.batchTotal += " -";
}
}
catch (Exception ex)
{
throw Oops.Bah("完成任务异常,{0}", ex.Message);
result.succ = false;
result.msg = $"执行异常,原因:{ex.Message}";
}
return result;
}
#endregion
private async Task<TaskManageOrderResultDto> InnerManualTask(string batchNo, TaskBaseInfo taskBaseInfo, TaskOperTypeEnum taskOperTypeEnum)
#region 单票执行任务
/// <summary>
/// 单票执行任务
/// </summary>
/// <param name="batchNo">批次号</param>
/// <param name="taskBaseInfo">任务详情</param>
/// <param name="taskOperTypeEnum">操作类型</param>
/// <param name="sortNo">顺序号</param>
/// <returns>返回回执</returns>
private async Task<TaskManageOrderResultDto> InnerManualTask(string batchNo, TaskBaseInfo model,
TaskOperTypeEnum taskOperTypeEnum, int sortNo)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
result.bno = model.TASK_NO;
try
{
var model = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskBaseInfo.PK_ID);
//var model = _taskBaseInfoRepository.Context.CopyNew().Queryable<TaskBaseInfo>().First(t => t.PK_ID == taskBaseInfo.PK_ID);
if (taskOperTypeEnum == TaskOperTypeEnum.COMPLETE_TASK)
{
if(model.TASK_TYPE == TaskBusiTypeEnum.TRUCK_DISPATCH.ToString())
{
if(model.STATUS == TaskStatusEnum.Cancel.ToString())
{
throw Oops.Bah($"当前状态是{TaskStatusEnum.Cancel.GetDescription()} 不能执行完成");
}
}
if (taskBaseInfo.TASK_TYPE == TaskBusiTypeEnum.CANCELLATION.ToString())
if (model.TASK_TYPE == TaskBusiTypeEnum.CANCELLATION.ToString())
{
//收到订舱已被取消邮件后生成的任务,如果点击完成,(订舱状态变为【退舱】,注意这里还需要确认)
}
@ -1332,7 +1397,7 @@ namespace Myshipping.Application
}
else if (taskOperTypeEnum == TaskOperTypeEnum.CANCEL_TASK)
{
if (taskBaseInfo.TASK_TYPE == TaskBusiTypeEnum.CHANGE_SHIP.ToString())
if (model.TASK_TYPE == TaskBusiTypeEnum.CHANGE_SHIP.ToString())
{
model.STATUS = TaskStatusEnum.Cancel.ToString();
model.STATUS_NAME = TaskStatusEnum.Cancel.GetDescription();
@ -1347,7 +1412,7 @@ namespace Myshipping.Application
it.STATUS_NAME
}).ExecuteCommand();
}
else if (taskBaseInfo.TASK_TYPE == TaskBusiTypeEnum.ABORT_CHANGE_SHIP.ToString())
else if (model.TASK_TYPE == TaskBusiTypeEnum.ABORT_CHANGE_SHIP.ToString())
{
/*
1.
@ -1376,15 +1441,19 @@ namespace Myshipping.Application
}).ExecuteCommand();
}
}
result.succ = true;
result.msg = "执行成功";
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"异常,{ex.Message}";
result.msg = ex.Message;
}
return result;
}
#endregion
#region 取消任务(可批量)
/// <summary>
@ -1399,6 +1468,8 @@ namespace Myshipping.Application
string batchNo = IDGen.NextID().ToString();
List<Task<TaskManageOrderResultDto>> taskRunList = new List<Task<TaskManageOrderResultDto>>();
_logger.LogInformation("批次={no} ids={ids} 取消任务开始", batchNo, string.Join(",", PKIds));
try
@ -1407,15 +1478,58 @@ namespace Myshipping.Application
_logger.LogInformation("批次={no} 获取任务完成Num={Num}", batchNo, taskList.Count);
taskList.ForEach(async tsk =>
var noList = PKIds.Select((a, idx) => new { no = idx + 1, id = a }).ToList();
foreach (var bk in taskList)
{
var sortNo = noList.FirstOrDefault(a => a.id == bk.PK_ID).no;
taskRunList.Add(Task.Run(() => InnerManualTask(batchNo, bk, TaskOperTypeEnum.CANCEL_TASK, sortNo)));
}
await InnerManualTask(batchNo, tsk, TaskOperTypeEnum.CANCEL_TASK);
});
Task.WaitAll(taskRunList.ToArray());
result.succ = true;
result.msg = "执行成功";
var downResultList = taskRunList.Select(x => x.Result).ToList();
if (downResultList.Any(x => !x.succ))
{
result.succ = false;
result.msg = "执行失败";
}
else
{
result.succ = true;
result.msg = downResultList.FirstOrDefault().msg;
}
result.ext = downResultList;
var succ = downResultList.Count(x => x.succ);
var fail = downResultList.Count(x => !x.succ);
if (succ > 0)
{
result.batchTotal = succ.ToString();
}
else
{
result.batchTotal = "- ";
}
if (fail > 0)
{
result.batchTotal += "/" + fail.ToString();
}
else
{
result.batchTotal += " -";
}
}
catch (Exception ex)
{
throw Oops.Bah("完成任务异常,{0}", ex.Message);
throw Oops.Bah("执行异常,{0}", ex.Message);
}
return result;
@ -1437,17 +1551,62 @@ namespace Myshipping.Application
_logger.LogInformation("批次={no} ids={ids} 挂起任务开始", batchNo, string.Join(",", PKIds));
List<Task<TaskManageOrderResultDto>> taskRunList = new List<Task<TaskManageOrderResultDto>>();
try
{
var taskList = _taskBaseInfoRepository.AsQueryable().Where(t => PKIds.Contains(t.PK_ID)).ToList();
_logger.LogInformation("批次={no} 获取任务完成Num={Num}", batchNo, taskList.Count);
taskList.ForEach(async tsk =>
var noList = PKIds.Select((a, idx) => new { no = idx + 1, id = a }).ToList();
foreach (var bk in taskList)
{
var sortNo = noList.FirstOrDefault(a => a.id == bk.PK_ID).no;
taskRunList.Add(Task.Run(() => InnerManualTask(batchNo, bk, TaskOperTypeEnum.PENDING_TASK, sortNo)));
}
await InnerManualTask(batchNo, tsk, TaskOperTypeEnum.PENDING_TASK);
});
Task.WaitAll(taskRunList.ToArray());
result.succ = true;
result.msg = "执行成功";
var downResultList = taskRunList.Select(x => x.Result).ToList();
if (downResultList.Any(x => !x.succ))
{
result.succ = false;
result.msg = "执行失败";
}
else
{
result.succ = true;
result.msg = downResultList.FirstOrDefault().msg;
}
result.ext = downResultList;
var succ = downResultList.Count(x => x.succ);
var fail = downResultList.Count(x => !x.succ);
if (succ > 0)
{
result.batchTotal = succ.ToString();
}
else
{
result.batchTotal = "- ";
}
if (fail > 0)
{
result.batchTotal += "/" + fail.ToString();
}
else
{
result.batchTotal += " -";
}
}
catch (Exception ex)
{

@ -95,7 +95,7 @@ namespace Myshipping.Application
catch (Exception ex)
{
result.succ = false;
result.msg = $"保存派车异常,原因:{ex.Message}";
result.msg = $"{ex.Message}";
}
return result;
@ -114,6 +114,9 @@ namespace Myshipping.Application
if (entity == null)
throw Oops.Oh($"派车信息不能为空");
if(!entity.KGS.HasValue)
throw Oops.Oh($"吨数不能为空");
List<TaskTruckCtn> entityCtnList = info.ContaList.Adapt<List<TaskTruckCtn>>();
if (entityCtnList != null && entityCtnList.Count > 0)
@ -901,6 +904,9 @@ namespace Myshipping.Application
{
ValidateTruck(OperateTypeEnum.SendDispatch, new TaskTruckInfo[] { info });
if (!info.KGS.HasValue)
throw Oops.Oh($"吨数不能为空");
info.UpdatedTime = DateTime.Now;
info.UpdatedUserId = UserManager.UserId;
info.UpdatedUserName = UserManager.Name;
@ -1205,10 +1211,9 @@ namespace Myshipping.Application
{
if (operateType == OperateTypeEnum.Save)
{
if (entityArg.Any(a => a.Status != BookingTruckStatus.TEMP.ToString()
&& a.Status != BookingTruckStatus.CANCELED.ToString() && a.Status != BookingTruckStatus.CANCEL_DISPATCH.ToString()))
if (entityArg.Any(a => a.Status != BookingTruckStatus.TEMP.ToString()))
{
throw Oops.Oh($"派车状态只有暂存、已撤销才能保存");
throw Oops.Oh($"派车状态只有暂存才能保存");
}
}
else if (operateType == OperateTypeEnum.Submit)

Loading…
Cancel
Save