|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using AngleSharp.Dom;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core.Enums;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
@ -15,6 +17,9 @@ using DS.WMS.Core.Op.Entity.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Op.Interface;
|
|
|
|
|
using DS.WMS.Core.Op.Interface.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Op.Method.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using DS.WMS.Core.Sys.Interface;
|
|
|
|
|
using DS.WMS.Core.Sys.Method;
|
|
|
|
|
using DS.WMS.Core.TaskPlat.Dtos;
|
|
|
|
|
using DS.WMS.Core.TaskPlat.Entity;
|
|
|
|
|
using LanguageExt;
|
|
|
|
@ -41,6 +46,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
|
private readonly IUser user;
|
|
|
|
|
private readonly ISaasDbService saasService;
|
|
|
|
|
private readonly ICommonService commonService;
|
|
|
|
|
readonly ITaskService taskService;
|
|
|
|
|
private readonly ISeaExportCommonService seaComService;
|
|
|
|
|
/// <summary>
|
|
|
|
@ -52,10 +58,116 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
|
|
|
commonService = _serviceProvider.GetRequiredService<ICommonService>();
|
|
|
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
|
seaComService = _serviceProvider.GetRequiredService<ISeaExportCommonService>();
|
|
|
|
|
taskService = serviceProvider.GetRequiredService<ITaskService>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<SeaExportListRes>> GetListByPage(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
//启用海运出口列表可视数据权限
|
|
|
|
|
(ISugarQueryable<SeaExport> query, _) = await commonService.GetVisibleDataRuleFilter<SeaExport>(tenantDb);
|
|
|
|
|
|
|
|
|
|
var orgList = db.Queryable<SysOrg>().Where(x => x.Status == StatusEnum.Enable);
|
|
|
|
|
//序列化查询条件
|
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
//var result = tenantDb.Queryable<SeaExport>()
|
|
|
|
|
var statusList = tenantDb.Queryable<BookingStatus>().Select<BookingStatusRes>().ToList();
|
|
|
|
|
var result = query.Where(a=>(a.IsRefund == true || a.IsChangeETD == true) )
|
|
|
|
|
.InnerJoin<BusinessFeeStatus>((a, b) => a.Id == b.BusinessId)
|
|
|
|
|
//.LeftJoin<SysOrg>((a, b, c) => a.SaleOrgId == c.Id, "shippingweb8_dev.sys_org")
|
|
|
|
|
//.LeftJoin<SysOrg>((a, b, c) => a.SaleDeptId == c.Id, "shippingweb8_dev.sys_org")
|
|
|
|
|
.Select((a, b) => new SeaExportRes()
|
|
|
|
|
{
|
|
|
|
|
//SaleDeptName = c.OrgName,
|
|
|
|
|
},
|
|
|
|
|
true)//true表示 其余字段自动映射,根据字段名字
|
|
|
|
|
//.Select<SeaExportRes>()
|
|
|
|
|
.MergeTable()
|
|
|
|
|
.Mapper(it =>
|
|
|
|
|
{
|
|
|
|
|
it.BookingStatus = statusList.Where(x => x.BusinessId == it.Id).ToList();
|
|
|
|
|
//it.BookingStatus = tenantDb.Queryable<BookingStatus>().Where(x => x.BusinessId == it.Id).Select<BookingStatusRes>().ToList();
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.Where(whereList);
|
|
|
|
|
//.ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
var list = result.ToList();
|
|
|
|
|
var data = await result.ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
var totalData = new SeaExportDataTotalRes()
|
|
|
|
|
{
|
|
|
|
|
MainCount = list.Where(x => x.ParentId == 0).Count(),
|
|
|
|
|
PartCount = list.Where(x => x.ParentId != 0).Count(),
|
|
|
|
|
ReturnCount = 0,
|
|
|
|
|
TEU = list.Sum(x => x.TEU),
|
|
|
|
|
PKGS = list.Sum(x => x.PKGS),
|
|
|
|
|
CBM = list.Sum(x => x.CBM),
|
|
|
|
|
KGS = list.Sum(x => x.KGS),
|
|
|
|
|
Cntr1 = list.Sum(x => x.Cntr1),
|
|
|
|
|
Cntr2 = list.Sum(x => x.Cntr2),
|
|
|
|
|
Cntr3 = list.Sum(x => x.Cntr3),
|
|
|
|
|
Cntr4 = list.Sum(x => x.Cntr4),
|
|
|
|
|
Cntr5 = list.Sum(x => x.Cntr5),
|
|
|
|
|
Cntr6 = list.Sum(x => x.Cntr6),
|
|
|
|
|
Cntr7 = list.Sum(x => x.Cntr7),
|
|
|
|
|
Cntr8 = list.Sum(x => x.Cntr8),
|
|
|
|
|
Cntr9 = list.Sum(x => x.Cntr9),
|
|
|
|
|
Cntr10 = list.Sum(x => x.Cntr10),
|
|
|
|
|
OtherCntr = list.Sum(x => x.OtherCntr),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
var res = new SeaExportListRes()
|
|
|
|
|
{
|
|
|
|
|
List = data.Data,
|
|
|
|
|
TotalCount = list.Count(),
|
|
|
|
|
DataTotal = totalData
|
|
|
|
|
};
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportListRes>.Success(res, MultiLanguageConst.DataQuerySuccess));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<SeaExportRes>> GetSeaExportRefundInfo(string id)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
tenantDb.QueryFilter.Clear<IOrgId>();
|
|
|
|
|
var data = await tenantDb.Queryable<SeaExport>()
|
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
|
.Select<SeaExportRes>()
|
|
|
|
|
.Mapper(it =>
|
|
|
|
|
{
|
|
|
|
|
var edi = tenantDb.Queryable<SeaExportEdi>().First(x => x.BusinessId == it.Id);
|
|
|
|
|
|
|
|
|
|
if (edi != null)
|
|
|
|
|
it.EdiInfo = edi.Adapt<SeaExportEdiRes>();
|
|
|
|
|
|
|
|
|
|
it.CtnInfo = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == it.Id.ToString()).Select<OpCtnRes>().ToList();
|
|
|
|
|
it.CtnPriceInfo = tenantDb.Queryable<BusinessCtnPrice>().Where(x => x.BusinessId == it.Id).Select<BusinessCtnPriceRes>().ToList();
|
|
|
|
|
it.BusinessLogList = tenantDb.Queryable<OpBusinessLog>().Where(x => x.BusinessId == it.Id)
|
|
|
|
|
.Select<OpBusinessLogRes>()
|
|
|
|
|
.Mapper(a =>
|
|
|
|
|
{
|
|
|
|
|
a.Details = tenantDb.Queryable<OpBusinessLogDetail>().Where(x => x.Pid == a.Id).ToList();
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
it.OrderContactList = tenantDb.Queryable<BusinessOrderContact>().Where(x => x.BusinessId == it.Id).Select<BusinessOrderContactRes>().ToList();
|
|
|
|
|
})
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportRes>.Success(data, MultiLanguageConst.DataQuerySuccess));
|
|
|
|
|
}
|
|
|
|
|
#region 发起改配
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -72,17 +184,18 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
var task = await tenantDb.Queryable<BusinessTask>().Where(x => x.BusinessId == id && x.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT).FirstAsync();
|
|
|
|
|
if (task.IsNull())
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult<string>.Failed("此单未审,可直接编辑调整!"));
|
|
|
|
|
}
|
|
|
|
|
if (task.IsNotNull() && task.TaskStatus == TaskStatusEnum.Create)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult<string>.Failed("此单未审,可直接编辑调整!"));
|
|
|
|
|
//return await Task.FromResult(DataResult<string>.Failed("此单未审,可直接编辑调整!"));
|
|
|
|
|
return await Task.FromResult(DataResult<string>.Success("未审单"));
|
|
|
|
|
}
|
|
|
|
|
//if (task.IsNotNull() && task.TaskStatus == TaskStatusEnum.Create)
|
|
|
|
|
//{
|
|
|
|
|
// return await Task.FromResult(DataResult<string>.Failed("此单未审,可直接编辑调整!"));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (info.ETD.IsNotNull() && info.ETD < DateTime.Now)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult<string>.Failed("此单已开船,无法改配!"));
|
|
|
|
|
}
|
|
|
|
|
//if (info.ETD.IsNotNull() && info.ETD < DateTime.Now)
|
|
|
|
|
//{
|
|
|
|
|
// return await Task.FromResult(DataResult<string>.Failed("此单已开船,无法改配!"));
|
|
|
|
|
//}
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Complete && string.IsNullOrEmpty(info.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult<string>.Success("已审未出号"));
|
|
|
|
@ -235,20 +348,23 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
info.IsCustoms = false;
|
|
|
|
|
info.IsLand = false;
|
|
|
|
|
info.IsVGM = false;
|
|
|
|
|
info.OrderProgress = "0";
|
|
|
|
|
|
|
|
|
|
await tenantDb.Updateable(info).UpdateColumns(x => new { x.CustomerNo,x.IsBooking,x.IsCustoms,x.IsLand,x.IsVGM }).ExecuteCommandAsync();
|
|
|
|
|
await tenantDb.Updateable(info).UpdateColumns(x => new { x.CustomerNo,x.IsBooking,x.IsCustoms,x.IsLand,x.IsVGM,x.OrderProgress }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
var oldOrder = entity.Adapt<SeaExport>();
|
|
|
|
|
entity.IsChangeETD = true;
|
|
|
|
|
entity.ChangeReason = req.ChangeReason;
|
|
|
|
|
entity.ChangeRemark = req.ChangeRemark;
|
|
|
|
|
entity.ChangeOrderId = req.Id;
|
|
|
|
|
entity.OrderProgress = req.OrderProgress;
|
|
|
|
|
int rows = await tenantDb.Updateable(entity).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.IsChangeETD,
|
|
|
|
|
x.ChangeReason,
|
|
|
|
|
x.ChangeRemark,
|
|
|
|
|
x.ChangeOrderId
|
|
|
|
|
x.ChangeOrderId,
|
|
|
|
|
x.OrderProgress,
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
await seaComService.SaveSeaExportLogAsync(new SeaExportSaveLog()
|
|
|
|
|
{
|
|
|
|
@ -262,19 +378,39 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
|
|
|
|
|
if (req.IsRefund)
|
|
|
|
|
{
|
|
|
|
|
var taskReq = new TaskCreationRequest()
|
|
|
|
|
var userList = new List<long>();
|
|
|
|
|
if (req.OrderProgress =="2") //已出号未申报 发起退舱入池任务 推给当票商务
|
|
|
|
|
{
|
|
|
|
|
userList.Add(entity.LaneId);
|
|
|
|
|
var taskReq = new TaskCreationRequest()
|
|
|
|
|
{
|
|
|
|
|
BusinessId = newKey,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.RETURN_CABIN_POOL.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.RETURN_CABIN_POOL.GetDescription()}】{entity?.CustomerNo}",
|
|
|
|
|
TaskDescription = $"【{TaskBaseTypeEnum.RETURN_CABIN_POOL.GetDescription()}】{entity?.CustomerNo}",
|
|
|
|
|
RecvUserIdList = userList.ToArray()
|
|
|
|
|
};
|
|
|
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
|
|
|
}
|
|
|
|
|
else //退舱确认任务 推给当票操作
|
|
|
|
|
{
|
|
|
|
|
BusinessId = newKey,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.RETURN_CABIN.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{info?.CustomerNo}",
|
|
|
|
|
TaskDescription = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{info?.CustomerNo}",
|
|
|
|
|
};
|
|
|
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userList.Add(info.OperatorId);
|
|
|
|
|
var taskReq = new TaskCreationRequest()
|
|
|
|
|
{
|
|
|
|
|
BusinessId = newKey,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.RETURN_CABIN.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{entity?.CustomerNo}",
|
|
|
|
|
TaskDescription = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{entity?.CustomerNo}",
|
|
|
|
|
RecvUserIdList = userList.ToArray()
|
|
|
|
|
};
|
|
|
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
|
|
|
}
|
|
|
|
|
//await seaComService.SetGoodsStatus("YFTC", req.Id, tenantDb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -329,9 +465,10 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
info.RefundTag = RefundTagEnum.Normal;
|
|
|
|
|
info.RefundReason = req.RefundReason;
|
|
|
|
|
info.RefundRemark = req.RefundRemark;
|
|
|
|
|
info.OrderProgress = req.OrderProgress;
|
|
|
|
|
int rows = await tenantDb.Updateable(info).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.RefundTag,x.RefundReason,x.RefundRemark
|
|
|
|
|
x.RefundTag,x.RefundReason,x.RefundRemark,x.OrderProgress
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await seaComService.SetGoodsStatus("YFTC", req.Id, tenantDb);
|
|
|
|
@ -370,20 +507,42 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
await seaComService.SetGoodsStatus("YSTC", callback.BusinessId, tenantDb);
|
|
|
|
|
//发起退舱确认任务
|
|
|
|
|
var taskReq = new TaskCreationRequest()
|
|
|
|
|
var userList = new List<long>();
|
|
|
|
|
if (info.OrderProgress =="2")//已出号未申报 发起退舱入池任务 推给当票商务
|
|
|
|
|
{
|
|
|
|
|
BusinessId = info.Id,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.RETURN_CABIN.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{info?.CustomerNo}",
|
|
|
|
|
TaskDescription = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{info?.CustomerNo}",
|
|
|
|
|
};
|
|
|
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
|
|
|
userList.Add(info.LaneId);
|
|
|
|
|
var taskReq = new TaskCreationRequest()
|
|
|
|
|
{
|
|
|
|
|
BusinessId = info.Id,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.RETURN_CABIN_POOL.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.RETURN_CABIN_POOL.GetDescription()}】{info?.CustomerNo}",
|
|
|
|
|
TaskDescription = $"【{TaskBaseTypeEnum.RETURN_CABIN_POOL.GetDescription()}】{info?.CustomerNo}",
|
|
|
|
|
RecvUserIdList = userList.ToArray()
|
|
|
|
|
};
|
|
|
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
|
|
|
}
|
|
|
|
|
else //退舱确认任务 推给当票操作
|
|
|
|
|
{
|
|
|
|
|
userList.Add(info.OperatorId);
|
|
|
|
|
//发起退舱确认任务
|
|
|
|
|
var taskReq = new TaskCreationRequest()
|
|
|
|
|
{
|
|
|
|
|
BusinessId = info.Id,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.RETURN_CABIN.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{info?.CustomerNo}",
|
|
|
|
|
TaskDescription = $"【{TaskBaseTypeEnum.RETURN_CABIN.GetDescription()}】{info?.CustomerNo}",
|
|
|
|
|
RecvUserIdList = userList.ToArray()
|
|
|
|
|
};
|
|
|
|
|
var result = await taskService.CreateTaskAsync(taskReq, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed(result.Message));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|