|
|
|
@ -21,6 +21,7 @@ using NLog;
|
|
|
|
|
using Logger = NLog.Logger;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Op.Method
|
|
|
|
|
{
|
|
|
|
@ -233,6 +234,136 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="list"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> SaveShippingBillAsync(List<ShippingBillReq> list)
|
|
|
|
|
{
|
|
|
|
|
var dbScope = (SqlSugarScope)db;
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
if (list.IsNull() || list.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("数据不能为空!"));
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//开启事务
|
|
|
|
|
await dbScope.Ado.BeginTranAsync();
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(item.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
var et = await tenantDb.Queryable<SeaExportShippingBill>().Where(x => x.MBLNO == item.MBLNO && x.HBLNO == item.HBLNO && x.Id != item.Id).FirstAsync();
|
|
|
|
|
if (et != null)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("当前提单号已存在,请勿重复录入!"));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (item.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
var data = item.Adapt<SeaExportShippingBill>();
|
|
|
|
|
data.State = "已录入";
|
|
|
|
|
|
|
|
|
|
if (data.CarrierId != 0)
|
|
|
|
|
{
|
|
|
|
|
data.Carrier = await tenantDb.Queryable<MappingCarrier>().Where(x => x.LinkId == data.CarrierId).Select(x => x.MapCode).FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
if (data.CargoId != "D")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
data.DangerClass = string.Empty;
|
|
|
|
|
data.DangerNo = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
if (item.CtnInfo.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (var item1 in item.CtnInfo)
|
|
|
|
|
{
|
|
|
|
|
var ctn = item1.Adapt<SeaExportShippingBillCtn>();
|
|
|
|
|
ctn.Pid = entity.Id;
|
|
|
|
|
await tenantDb.Insertable(ctn).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var info = await tenantDb.Queryable<SeaExportShippingBill>().Where(x => x.Id == item.Id).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (info.State != "已录入")
|
|
|
|
|
{
|
|
|
|
|
if (item.State != info.State)
|
|
|
|
|
{
|
|
|
|
|
item.State = info.State; //防止前端数据覆盖状态
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.HBLNO != info.HBLNO)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("已直发状态不能修改分单号"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info = item.Adapt(info);
|
|
|
|
|
if (info.CarrierId != 0)
|
|
|
|
|
{
|
|
|
|
|
info.Carrier = await tenantDb.Queryable<MappingCarrier>().Where(x => x.LinkId == info.CarrierId).Select(x => x.MapCode).FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
if (info.CargoId != "D")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
info.DangerClass = string.Empty;
|
|
|
|
|
info.DangerNo = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
await tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).IgnoreColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.MBLNO,
|
|
|
|
|
it.BusinessId,
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
if (item.CtnInfo.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var ctnList = tenantDb.Queryable<SeaExportShippingBillCtn>().Where(x => x.Pid == item.Id).ToList();
|
|
|
|
|
foreach (var item1 in item.CtnInfo)
|
|
|
|
|
{
|
|
|
|
|
if (item1.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
var ctn = item1.Adapt<SeaExportShippingBillCtn>();
|
|
|
|
|
ctn.Pid = info.Id;
|
|
|
|
|
await tenantDb.Insertable(ctn).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var ctn = ctnList.First(x => x.Id == item.Id);
|
|
|
|
|
ctn = item1.Adapt(ctn);
|
|
|
|
|
await tenantDb.Updateable(ctn).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
await dbScope.Ado.CommitTranAsync();
|
|
|
|
|
return await Task.FromResult(DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await dbScope.Ado.RollbackTranAsync();
|
|
|
|
|
await ex.LogAsync(tenantDb);
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("更新失败!" + ",请联系管理员!"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 详情
|
|
|
|
|
/// </summary>
|
|
|
|
|