|
|
|
@ -3,15 +3,23 @@ using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.DjyServiceStatus;
|
|
|
|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
|
|
using DS.WMS.Core.Op.Dtos;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Interface;
|
|
|
|
|
using DS.WMS.Core.Op.Method;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Dtos;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
|
using DS.WMS.Core.TaskPlat.Dtos;
|
|
|
|
|
using DS.WMS.Core.TaskPlat.Entity;
|
|
|
|
|
using LanguageExt;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
@ -23,7 +31,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
{
|
|
|
|
|
const TaskBaseTypeEnum BL_CONFIRM_TASK = TaskBaseTypeEnum.WAIT_BILL_CONFIRM;
|
|
|
|
|
readonly Lazy<IDjyServiceStatusService> djyService;
|
|
|
|
|
|
|
|
|
|
readonly Lazy<ISeaExportCommonService> seaComService;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
@ -31,24 +39,109 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
public SeaExportTaskService(IServiceProvider provider) : base(provider)
|
|
|
|
|
{
|
|
|
|
|
djyService = new Lazy<IDjyServiceStatusService>(provider.GetRequiredService<IDjyServiceStatusService>());
|
|
|
|
|
seaComService = new Lazy<ISeaExportCommonService>(provider.GetRequiredService<ISeaExportCommonService>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Task<DataResult> CreateTaskAsync(TaskCreationRequest request, bool useTransaction = true)
|
|
|
|
|
public override async Task<DataResult> CreateTaskAsync(TaskCreationRequest request, bool useTransaction = true)
|
|
|
|
|
{
|
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.WAIT_BILL_CONFIRM)
|
|
|
|
|
{
|
|
|
|
|
request.Steps ??= [];
|
|
|
|
|
if (!request.Steps.Exists(x => x.Type == StepType.OPConfirm))
|
|
|
|
|
{
|
|
|
|
|
request.Steps.Add(new TaskStepDto
|
|
|
|
|
request.Steps.Add(new TaskStepDto
|
|
|
|
|
{
|
|
|
|
|
Type = StepType.OPConfirm,
|
|
|
|
|
Name = StepType.OPConfirm.ToString()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region
|
|
|
|
|
//第二次提交判断
|
|
|
|
|
var check = await GetTasks(request.BusinessId, request.BusinessType, false, request.TaskType);
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
if (check.Count>0)
|
|
|
|
|
{
|
|
|
|
|
//货物状态
|
|
|
|
|
var goodsStatus = TenantDb.Queryable<BookingGoodsStatus>().First(x => x.StatusCode == "TIJIAO" && x.BusinessId == request.BusinessId);
|
|
|
|
|
if (goodsStatus == null)
|
|
|
|
|
{
|
|
|
|
|
var gsCfg = TenantDb.Queryable<BookingGoodsStatusConfig>().First(x => x.SystemCode == "TIJIAO");
|
|
|
|
|
if (gsCfg != null)
|
|
|
|
|
{
|
|
|
|
|
var gs = new BookingGoodsStatus()
|
|
|
|
|
{
|
|
|
|
|
BusinessId = request.BusinessId,
|
|
|
|
|
ConfigId = gsCfg.Id,
|
|
|
|
|
FinishTime = DateTime.Now,
|
|
|
|
|
FinishUserName = User.UserId.IsNull() ? "超级管理员" : User.UserName,
|
|
|
|
|
FinishBy = User.UserId.IsNull() ? 0 : long.Parse(User.UserId),
|
|
|
|
|
StatusCode = gsCfg.SystemCode,
|
|
|
|
|
StatusName = gsCfg.StatusName,
|
|
|
|
|
};
|
|
|
|
|
await TenantDb.Insertable(gs).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//主单状态变更
|
|
|
|
|
var order = TenantDb.Queryable<SeaExport>().Filter(null, true).First(x => x.Id == request.BusinessId);
|
|
|
|
|
var oldOrder = order.Adapt<SeaExport>();
|
|
|
|
|
order.BusinessStatusName = "已提交";
|
|
|
|
|
order.BusinessStatus = "TIJIAO";
|
|
|
|
|
await TenantDb.Updateable(order).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessStatusName,
|
|
|
|
|
x.BusinessStatus
|
|
|
|
|
}).EnableDiffLogEvent().ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
await seaComService.Value.SaveSeaExportLogAsync(new SeaExportSaveLog()
|
|
|
|
|
{
|
|
|
|
|
OperateType = "Update",
|
|
|
|
|
OldOrder = oldOrder,
|
|
|
|
|
NewOrder = order,
|
|
|
|
|
SourceCode = "CreateTaskAsync",
|
|
|
|
|
SourceName = "审单再次提交更新",
|
|
|
|
|
}, TenantDb);
|
|
|
|
|
|
|
|
|
|
return base.CreateTaskAsync(request, useTransaction);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
var res1 = await base.CreateTaskAsync(request, true);
|
|
|
|
|
if (res1.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
if (check.Count > 0) {
|
|
|
|
|
//更新大简云货物状态
|
|
|
|
|
var pushModel = new EmbedServiceProjectStatusDto
|
|
|
|
|
{
|
|
|
|
|
businessId = request.BusinessId.ToString(),
|
|
|
|
|
SourceType = 1,
|
|
|
|
|
StatusCodes = new List<EmbedServiceProjectStatusDetailDto> {
|
|
|
|
|
new EmbedServiceProjectStatusDetailDto{
|
|
|
|
|
StatusCode = "TIJIAO"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await djyStatusService.Value.SaveServiceStatus(pushModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
return res1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|