海运出口复制部分

dev
cjy 2 months ago
parent 32d1964c30
commit b2af5e7b66

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Dtos
{
/// <summary>
/// 海运出口复制请求
/// </summary>
public class SeaExportCopyReq
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 是否复制费用
/// </summary>
public bool IsCopyFee { get; set; } =false;
}
}

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Dtos
{
/// <summary>
///
/// </summary>
public class SeaExportCopyRes: SeaExportRes
{
}
}

@ -77,6 +77,13 @@ public interface ISeaExportService
/// <returns></returns>
public DataResult SeaExportCopy(string id);
/// <summary>
/// 业务单据复制-返回前端
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult<SeaExportCopyRes>> GetSeaExportCopyInfo(SeaExportCopyReq req);
/// <summary>
/// 获取场站数据
/// </summary>

@ -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 =>
{
return DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist);
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 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.BusinessStatus = "";
data.BusinessStatusName = "";
data.CustomerNo = "";
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
#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

Loading…
Cancel
Save