海运出口复制部分

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> /// <returns></returns>
public DataResult SeaExportCopy(string id); public DataResult SeaExportCopy(string id);
/// <summary>
/// 业务单据复制-返回前端
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult<SeaExportCopyRes>> GetSeaExportCopyInfo(SeaExportCopyReq req);
/// <summary> /// <summary>
/// 获取场站数据 /// 获取场站数据
/// </summary> /// </summary>

@ -31,6 +31,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog; using NLog;
using Org.BouncyCastle.Ocsp;
using SqlSugar; using SqlSugar;
using Logger = NLog.Logger; using Logger = NLog.Logger;
@ -953,78 +954,81 @@ public partial class SeaExportService : ISeaExportService
/// <summary> /// <summary>
/// 业务单据单票复制 /// 业务单据复制-返回前端
/// </summary> /// </summary>
/// <param name="id">业务Id</param> /// <param name="req"></param>
/// <returns></returns> /// <returns></returns>
public DataResult GetSeaExportCopyInfo(string id) public async Task<DataResult<SeaExportCopyRes>> GetSeaExportCopyInfo(SeaExportCopyReq req)
{ {
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var info = tenantDb.Queryable<SeaExport>().Where(x => x.Id == long.Parse(id)).First(); tenantDb.QueryFilter.Clear<IOrgId>();
if (info.IsNullOrEmpty())
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 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(); data.Id = 0;
if (template.IsNullOrEmpty()) data.ParentId = 0;
{
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.BusinessStatus = "";
data.BusinessStatusName = "";
data.CustomerNo = "";
#region 初始化费用状态表 if (data.EdiInfo.IsNotNull())
var feeStatus = BusinessFeeStatus.Init(entity.Id); {
tenantDb.Insertable(feeStatus).ExecuteCommand(); data.EdiInfo.Id = 0;
#endregion data.EdiInfo.BusinessId = 0;
return DataResult.Successed("复制成功!", entity.Id, MultiLanguageConst.DataCopySuccess);
} }
else if (data.CtnInfo.IsNotNull() && data.CtnInfo.Count > 0)
{ {
foreach (var item in data.CtnInfo)
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)
{ {
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 #endregion

Loading…
Cancel
Save