|
|
|
@ -31,6 +31,7 @@ using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using NLog;
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using Logger = NLog.Logger;
|
|
|
|
|
|
|
|
|
@ -953,78 +954,81 @@ public partial class SeaExportService : ISeaExportService
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 业务单据单票复制
|
|
|
|
|
/// 业务单据复制-返回前端
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">业务Id</param>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult GetSeaExportCopyInfo(string id)
|
|
|
|
|
public async Task<DataResult<SeaExportCopyRes>> GetSeaExportCopyInfo(SeaExportCopyReq req)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var info = tenantDb.Queryable<SeaExport>().Where(x => x.Id == long.Parse(id)).First();
|
|
|
|
|
if (info.IsNullOrEmpty())
|
|
|
|
|
tenantDb.QueryFilter.Clear<IOrgId>();
|
|
|
|
|
|
|
|
|
|
var id = req.Id;
|
|
|
|
|
var data = await tenantDb.Queryable<SeaExport>()
|
|
|
|
|
.Where(a => a.Id == id)
|
|
|
|
|
.Select<SeaExportCopyRes>()
|
|
|
|
|
.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.OrderContactList = tenantDb.Queryable<BusinessOrderContact>().Where(x => x.BusinessId == it.Id).Select<BusinessOrderContactRes>().ToList();
|
|
|
|
|
})
|
|
|
|
|
.FirstAsync();
|
|
|
|
|
if (data.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist);
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportCopyRes>.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist));
|
|
|
|
|
}
|
|
|
|
|
//获取表单复制模板
|
|
|
|
|
var template = tenantDb.Queryable<CodeFormCopy>().Where(x => x.PermissionId == 1772509201441099776).First();
|
|
|
|
|
//var sequence = commonService.GetSequenceNextAsync<SeaExport>(tenantDb, user, info.SaleId).GetAwaiter().GetResult();
|
|
|
|
|
//if (!sequence.Succeeded)
|
|
|
|
|
//{
|
|
|
|
|
// return DataResult.Failed(sequence.Message, MultiLanguageConst.SequenceSetNotExist);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
var data = new SeaExport();
|
|
|
|
|
if (template.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
data = info.Adapt(data);
|
|
|
|
|
data.Id = 0;
|
|
|
|
|
data.ParentId = 0;
|
|
|
|
|
//data.IsBusinessLocking = false;
|
|
|
|
|
//data.IsFeeLocking = false;
|
|
|
|
|
//data.CustomerNo = sequence.Data;
|
|
|
|
|
data.BusinessStatusName = "";
|
|
|
|
|
data.CustomerNo = "";
|
|
|
|
|
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
|
|
|
|
|
data.Id = 0;
|
|
|
|
|
data.ParentId = 0;
|
|
|
|
|
|
|
|
|
|
data.BusinessStatus = "";
|
|
|
|
|
data.BusinessStatusName = "";
|
|
|
|
|
data.CustomerNo = "";
|
|
|
|
|
|
|
|
|
|
#region 初始化费用状态表
|
|
|
|
|
var feeStatus = BusinessFeeStatus.Init(entity.Id);
|
|
|
|
|
tenantDb.Insertable(feeStatus).ExecuteCommand();
|
|
|
|
|
#endregion
|
|
|
|
|
return DataResult.Successed("复制成功!", entity.Id, MultiLanguageConst.DataCopySuccess);
|
|
|
|
|
if (data.EdiInfo.IsNotNull())
|
|
|
|
|
{
|
|
|
|
|
data.EdiInfo.Id = 0;
|
|
|
|
|
data.EdiInfo.BusinessId = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (data.CtnInfo.IsNotNull() && data.CtnInfo.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
data = info.Adapt(data);
|
|
|
|
|
data.Id = 0;
|
|
|
|
|
data.ParentId = 0;
|
|
|
|
|
data.CustomerNo = "";
|
|
|
|
|
data.BusinessStatusName = "";
|
|
|
|
|
//data.IsBusinessLocking = false;
|
|
|
|
|
//data.IsFeeLocking = false;
|
|
|
|
|
//data.CustomerNo = sequence.Data;
|
|
|
|
|
|
|
|
|
|
var list0 = template.CopyFields.Split(",");
|
|
|
|
|
var list1 = new List<string>();
|
|
|
|
|
foreach (var item in list0)
|
|
|
|
|
foreach (var item in data.CtnInfo)
|
|
|
|
|
{
|
|
|
|
|
list1.Add(item.ToUpperCamelCase());
|
|
|
|
|
item.Id = 0;
|
|
|
|
|
item.BSNO = "";
|
|
|
|
|
}
|
|
|
|
|
list1.Add("IsBusinessLocking");
|
|
|
|
|
list1.Add("IsFeeLocking");
|
|
|
|
|
//list1.Add("CustomerNo");
|
|
|
|
|
var insertColumns = list1.ToArray();
|
|
|
|
|
//insertColumns.AddRange(["Id", "ParentId", "IsBusinessLocking", "IsFeeLocking", "CustomerNo"]);
|
|
|
|
|
var entity = tenantDb.Insertable(data).InsertColumns(insertColumns).ExecuteReturnEntity();
|
|
|
|
|
#region 初始化费用状态表
|
|
|
|
|
var feeStatus = BusinessFeeStatus.Init(entity.Id);
|
|
|
|
|
tenantDb.Insertable(feeStatus).ExecuteCommand();
|
|
|
|
|
#endregion
|
|
|
|
|
return DataResult.Successed("复制成功!", entity.Id, MultiLanguageConst.DataCopySuccess);
|
|
|
|
|
}
|
|
|
|
|
if (data.CtnPriceInfo.IsNotNull() && data.CtnPriceInfo.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in data.CtnPriceInfo)
|
|
|
|
|
{
|
|
|
|
|
item.Id = 0;
|
|
|
|
|
item.BusinessId = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (data.OrderContactList.IsNotNull() && data.OrderContactList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in data.OrderContactList)
|
|
|
|
|
{
|
|
|
|
|
item.Id = 0;
|
|
|
|
|
item.BusinessId = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (template.IsNotNull())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return await Task.FromResult(DataResult<SeaExportCopyRes>.Success("复制成功!", data, MultiLanguageConst.DataCopySuccess));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|