海运出口订单联系人 及海运出口编辑修改

usertest
ZR20090193-陈敬勇 5 months ago
parent 772352f49d
commit 788977cd55

@ -0,0 +1,57 @@
using DS.WMS.Core.Op.Entity;
using SqlSugar;
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 BusinessOrderContactReq
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 业务Id
/// </summary>
public long BusinessId { get; set; }
/// <summary>
/// 业务类型 1.海运出口
/// </summary>
public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
/// <summary>
/// 客户类别
/// </summary>
public string CustomerType { get; set; }
/// <summary>
/// 客户类别名称
/// </summary>
public string CustomerTypeName { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string Name { get; set; }
/// <summary>
/// 电话
/// </summary>
public string Tel { get; set; }
/// <summary>
/// Desc:邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; }
}
}

@ -0,0 +1,61 @@
using DS.WMS.Core.Op.Entity;
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 BusinessOrderContactRes
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 业务Id
/// </summary>
public long BusinessId { get; set; }
/// <summary>
/// 业务类型 1.海运出口
/// </summary>
public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
/// <summary>
/// 客户类别
/// </summary>
public string CustomerType { get; set; }
/// <summary>
/// 客户类别名称
/// </summary>
public string CustomerTypeName { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string Name { get; set; }
/// <summary>
/// 电话
/// </summary>
public string Tel { get; set; }
/// <summary>
/// Desc:邮箱
/// </summary>
public string Email { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}
}

@ -0,0 +1,56 @@
using DS.Module.Core.Data;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Entity
{
/// <summary>
/// 业务订单联系人信息
/// </summary>
[SqlSugar.SugarTable("op_business_order_contact", "业务订单联系人信息")]
public class BusinessOrderContact : BaseOrgModel<long>
{
/// <summary>
/// 业务Id
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "业务Id", IsNullable = false, Length = 100)]
public long BusinessId { get; set; }
/// <summary>
/// 业务类型 1.海运出口
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "业务类型 1.海运出口", IsNullable = false, DefaultValue = "1")]
public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
/// <summary>
/// 客户类别
/// </summary>
[SugarColumn(ColumnDescription = "客户类别", Length = 50, IsNullable = true)]
public string CustomerType { get; set; }
/// <summary>
/// 客户类别名称
/// </summary>
[SugarColumn(ColumnDescription = "客户类别名称", Length = 50, IsNullable = true)]
public string CustomerTypeName { get; set; }
/// <summary>
/// 联系人
/// </summary>
[SugarColumn(ColumnDescription = "联系人", Length = 50, IsNullable = true)]
public string Name { get; set; }
/// <summary>
/// 电话
/// </summary>
[SugarColumn(ColumnDescription = "电话", Length = 50, IsNullable = true)]
public string Tel { get; set; }
/// <summary>
/// Desc:邮箱
/// </summary>
[SugarColumn(ColumnDescription = "邮箱", Length = 50, IsNullable = true)]
public string Email { get; set; }
}
}

@ -12,7 +12,7 @@ namespace DS.WMS.Core.Op.Entity
/// 业务派车信息
/// </summary>
[SqlSugar.SugarTable("op_business_truck", "业务派车信息")]
public class OpBusinessTruck : BaseOrgModel<long>
public class BusinessTruck : BaseOrgModel<long>
{
/// <summary>
/// 业务Id

@ -12,7 +12,7 @@ namespace DS.WMS.Core.Op.Entity
/// 业务派车箱信息
/// </summary>
[SugarTable("op_business_truck_ctn", "业务派车箱信息")]
public class OpBusinessTruckCtn : BaseModel<long>
public class BusinessTruckCtn : BaseModel<long>
{
/// <summary>
/// 业务Id

@ -12,7 +12,7 @@ namespace DS.WMS.Core.Op.Entity
/// 业务场站入货通知信息
/// </summary>
[SqlSugar.SugarTable("op_business_yard", "业务场站入货通知信息")]
public class OpBusinessYard : BaseOrgModel<long>
public class BusinessYard : BaseOrgModel<long>
{
/// <summary>
/// 业务Id

@ -0,0 +1,43 @@
using DS.Module.Core.Data;
using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Interface
{
public interface IBusinessOrderContactService
{
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<BusinessOrderContactRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult EditBusinessOrderContact(BusinessOrderContactReq model);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<BusinessOrderContactRes> GetBusinessOrderContactInfo(string id);
/// <summary>
/// 批量删除
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult BatchDelBusinessOrderContact(IdModel req);
}
}

@ -14,14 +14,14 @@ public interface ISeaExportService
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<SeaExportRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult EditSeaExport(SeaExportReq model);
Task<DataResult> EditSeaExport(SeaExportReq model);
/// <summary>
/// 获取详情

@ -0,0 +1,97 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Map.Entity;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using Org.BouncyCastle.Ocsp;
using SqlSugar;
using Logger = NLog.Logger;
namespace DS.WMS.Core.Op.Method
{
public class BusinessOrderContactService: IBusinessOrderContactService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly ISeaExportCommonService seaComService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public BusinessOrderContactService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
public DataResult<List<BusinessOrderContactRes>> GetListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<BusinessOrderContact>()
.Where(whereList)
.Select<BusinessOrderContactRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult EditBusinessOrderContact(BusinessOrderContactReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
var data = req.Adapt<BusinessOrderContact>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = tenantDb.Queryable<BusinessOrderContact>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).IgnoreColumns(it => new
{
it.BusinessId,
}).ExecuteCommand();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
public DataResult<BusinessOrderContactRes> GetBusinessOrderContactInfo(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<BusinessOrderContact>()
.Where(a => a.Id == long.Parse(id))
.Select<BusinessOrderContactRes>()
.First();
return DataResult<BusinessOrderContactRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
public DataResult BatchDelBusinessOrderContact(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = tenantDb.Queryable<BusinessOrderContact>().Where(x => req.Ids.Contains(x.Id)).ToList();
if (list.Count > 0)
{
tenantDb.Deleteable(list).ExecuteCommand();
}
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
}
}

@ -43,7 +43,7 @@ namespace DS.WMS.Core.Op.Method
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<OpBusinessTruck>()
var data = tenantDb.Queryable<BusinessTruck>()
.Where(whereList)
.Select<OpBusinessTruckRes>().ToQueryPage(request.PageCondition);
return data;
@ -55,7 +55,7 @@ namespace DS.WMS.Core.Op.Method
if (req.Id == 0)
{
var data = req.Adapt<OpBusinessTruck>();
var data = req.Adapt<BusinessTruck>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
@ -64,7 +64,7 @@ namespace DS.WMS.Core.Op.Method
foreach (var item in req.TruckCtnList)
{
var ctn = item.Adapt<OpBusinessTruckCtn>();
var ctn = item.Adapt<BusinessTruckCtn>();
ctn.Pid = entity.Id;
tenantDb.Insertable(ctn).ExecuteCommand();
}
@ -74,7 +74,7 @@ namespace DS.WMS.Core.Op.Method
}
else
{
var info = tenantDb.Queryable<OpBusinessTruck>().Where(x => x.Id == req.Id).First();
var info = tenantDb.Queryable<BusinessTruck>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
@ -85,12 +85,12 @@ namespace DS.WMS.Core.Op.Method
if (req.TruckCtnList.Count > 0)
{
var ctnList = tenantDb.Queryable<OpBusinessTruckCtn>().Where(x => x.Pid == req.Id).ToList();
var ctnList = tenantDb.Queryable<BusinessTruckCtn>().Where(x => x.Pid == req.Id).ToList();
foreach (var item in req.TruckCtnList)
{
if (item.Id == 0)
{
var ctn = item.Adapt<OpBusinessTruckCtn>();
var ctn = item.Adapt<BusinessTruckCtn>();
ctn.Pid = info.Id;
tenantDb.Insertable(ctn).ExecuteCommand();
}
@ -109,7 +109,7 @@ namespace DS.WMS.Core.Op.Method
public DataResult<OpBusinessTruckRes> GetOpBusinessTruckInfo(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<OpBusinessTruck>()
var data = tenantDb.Queryable<BusinessTruck>()
.Where(a => a.Id == long.Parse(id))
.Select<OpBusinessTruckRes>()
.First();
@ -119,10 +119,10 @@ namespace DS.WMS.Core.Op.Method
public DataResult BatchDelOpBusinessTruck(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = tenantDb.Queryable<OpBusinessTruck>().Where(x => req.Ids.Contains(x.Id)).ToList();
var list = tenantDb.Queryable<BusinessTruck>().Where(x => req.Ids.Contains(x.Id)).ToList();
if (list.Count > 0)
{
var ctns = tenantDb.Queryable<OpBusinessTruckCtn>().Where(x => req.Ids.Contains(x.Pid)).ToList();
var ctns = tenantDb.Queryable<BusinessTruckCtn>().Where(x => req.Ids.Contains(x.Pid)).ToList();
tenantDb.Deleteable(ctns).ExecuteCommand();
tenantDb.Deleteable(list).ExecuteCommand();
@ -135,7 +135,7 @@ namespace DS.WMS.Core.Op.Method
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<OpBusinessTruckCtn>()
var data = tenantDb.Queryable<BusinessTruckCtn>()
.Where(whereList)
.Select<OpBusinessTruckCtnRes>().ToQueryPage(request.PageCondition);
return data;
@ -144,7 +144,7 @@ namespace DS.WMS.Core.Op.Method
public DataResult BatchDelTruckCtns(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = tenantDb.Queryable<OpBusinessTruckCtn>().Where(x => req.Ids.Contains(x.Id)).ToList();
var list = tenantDb.Queryable<BusinessTruckCtn>().Where(x => req.Ids.Contains(x.Id)).ToList();
if (list.Count > 0)
{
tenantDb.Deleteable(list).ExecuteCommand();

@ -43,7 +43,7 @@ namespace DS.WMS.Core.Op.Method
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<OpBusinessYard>()
var data = tenantDb.Queryable<BusinessYard>()
.Where(whereList)
.Select<OpBusinessYardRes>().ToQueryPage(request.PageCondition);
return data;
@ -55,13 +55,13 @@ namespace DS.WMS.Core.Op.Method
if (req.Id == 0)
{
var data = req.Adapt<OpBusinessYard>();
var data = req.Adapt<BusinessYard>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = tenantDb.Queryable<OpBusinessYard>().Where(x => x.Id == req.Id).First();
var info = tenantDb.Queryable<BusinessYard>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
@ -77,7 +77,7 @@ namespace DS.WMS.Core.Op.Method
public DataResult<OpBusinessYardRes> GetOpBusinessYardInfo(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<OpBusinessYard>()
var data = tenantDb.Queryable<BusinessYard>()
.Where(a => a.Id == long.Parse(id))
.Select<OpBusinessYardRes>()
.First();
@ -87,7 +87,7 @@ namespace DS.WMS.Core.Op.Method
public DataResult BatchDelOpBusinessYard(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = tenantDb.Queryable<OpBusinessYard>().Where(x => req.Ids.Contains(x.Id)).ToList();
var list = tenantDb.Queryable<BusinessYard>().Where(x => req.Ids.Contains(x.Id)).ToList();
if (list.Count > 0)
{
tenantDb.Deleteable(list).ExecuteCommand();

@ -7,6 +7,7 @@ using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface;
@ -15,6 +16,7 @@ using DS.WMS.Core.Sys.Interface;
using LanguageExt;
using Mapster;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using SqlSugar;
@ -235,32 +237,33 @@ public partial class SeaExportService : ISeaExportService
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult EditSeaExport(SeaExportReq req)
public async Task<DataResult> EditSeaExport(SeaExportReq req)
{
var dbScope = (SqlSugarScope)db;
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
if (req.BLType != "拼箱分票" && tenantDb.Queryable<SeaExport>().Where(x => x.MBLNO == req.MBLNO.Trim()).Any())
{
return DataResult.Failed("海运出口信息主提单号已存在!", MultiLanguageConst.SeaExportMBLNOExist);
return await Task.FromResult(DataResult.Failed("海运出口信息主提单号已存在!", MultiLanguageConst.SeaExportMBLNOExist));
}
if (tenantDb.Queryable<SeaExport>().Where(x => x.HBLNO == req.HBLNO.Trim()).Any())
{
return DataResult.Failed("海运出口信息分提单号已存在!", MultiLanguageConst.SeaExportHBLNOExist);
return await Task.FromResult(DataResult.Failed("海运出口信息分提单号已存在!", MultiLanguageConst.SeaExportHBLNOExist));
}
//TODO 会计期间不允许小于已结转期间
if (req.CloseDocDate.IsNotNull() && req.CloseDocDate < req.ETD)
{
return DataResult.Failed("截单日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDocDateLimit);
return await Task.FromResult(DataResult.Failed("截单日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDocDateLimit));
}
if (req.ClosingDate.IsNotNull() && req.ClosingDate < req.ETD)
{
return DataResult.Failed("截港日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDateLimit);
return await Task.FromResult(DataResult.Failed("截港日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDateLimit));
}
var sequence = commonService.GetSequenceNext<SeaExport>();
if (!sequence.Succeeded)
{
return DataResult.Failed(sequence.Message, MultiLanguageConst.SequenceSetNotExist);
return await Task.FromResult(DataResult.Failed(sequence.Message, MultiLanguageConst.SequenceSetNotExist));
}
var data = req.Adapt<SeaExport>();
data.CustomerNo = sequence.Data;
@ -278,55 +281,69 @@ public partial class SeaExportService : ISeaExportService
if (!stlInfo.Succeeded)
{
return DataResult.Failed(stlInfo.Message);
return await Task.FromResult(DataResult.Failed(stlInfo.Message));
}
data.StlName = stlInfo.Data.StlName;
data.StlDate = stlInfo.Data.StlDate;
#endregion
try
{
//开启事务
await dbScope.Ado.BeginTranAsync();
var entity = await tenantDb.Insertable(data).ExecuteReturnEntityAsync();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
//处理订单联系人信息
DealBusinessOrderContact(entity, tenantDb);
if (req.CtnInfo.Count > 0)
{
foreach (var item in req.CtnInfo)
if (req.CtnInfo.Count > 0)
{
var ctn = item.Adapt<OpCtn>();
ctn.BSNO = entity.Id.ToString();
tenantDb.Insertable(ctn).ExecuteCommand();
foreach (var item in req.CtnInfo)
{
var ctn = item.Adapt<OpCtn>();
ctn.BSNO = entity.Id.ToString();
await tenantDb.Insertable(ctn).ExecuteCommandAsync();
}
}
if (req.EdiInfo.IsNotNull())
{
var edi = req.EdiInfo.Adapt<SeaExportEdi>();
edi.BusinessId = entity.Id;
await tenantDb.Insertable(edi).ExecuteCommandAsync();
}
#region 初始化费用状态表
var feeStatus = BusinessFeeStatus.Init(entity.Id);
await tenantDb.Insertable(feeStatus).ExecuteCommandAsync();
#endregion
//return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
await dbScope.Ado.CommitTranAsync();
return await Task.FromResult(DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess));
}
if (req.EdiInfo.IsNotNull())
catch (Exception ex)
{
var edi = req.EdiInfo.Adapt<SeaExportEdi>();
edi.BusinessId = entity.Id;
tenantDb.Insertable(edi).ExecuteCommand();
await dbScope.Ado.RollbackTranAsync();
return await Task.FromResult(DataResult.Failed("添加失败!" + ",请联系管理员!" + ex.ToString()));
}
#region 初始化费用状态表
var feeStatus = BusinessFeeStatus.Init(entity.Id);
tenantDb.Insertable(feeStatus).ExecuteCommand();
#endregion
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = tenantDb.Queryable<SeaExport>().Where(x => x.Id == req.Id).First();
var feeStatus = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == req.Id).First();
var info = await tenantDb.Queryable<SeaExport>().Where(x => x.Id == req.Id).FirstAsync();
var feeStatus = await tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == req.Id).FirstAsync();
if (feeStatus.IsNotNull() && (bool)feeStatus.IsBusinessLocking)
{
return DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock);
return await Task.FromResult(DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock));
}
info = req.Adapt(info);
//TODO 会计期间不允许小于已结转期间
if (info.CloseDocDate.IsNotNull() && info.CloseDocDate < info.ETD)
{
return DataResult.Failed("截单日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDocDateLimit);
return await Task.FromResult(DataResult.Failed("截单日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDocDateLimit));
}
if (info.ClosingDate.IsNotNull() && info.ClosingDate < info.ETD)
{
return DataResult.Failed("截港日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDateLimit);
return await Task.FromResult(DataResult.Failed("截港日期不允许小于开船日期!", MultiLanguageConst.SeaExportCloseDateLimit));
}
#region 处理箱型箱量
if (req.CtnInfo.Count > 0)
@ -341,62 +358,148 @@ public partial class SeaExportService : ISeaExportService
if (!stlInfo.Succeeded)
{
return DataResult.Failed(stlInfo.Message);
return await Task.FromResult(DataResult.Failed(stlInfo.Message));
}
info.StlName = stlInfo.Data.StlName;
info.StlDate = stlInfo.Data.StlDate;
#endregion
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
try
{
//开启事务
await dbScope.Ado.BeginTranAsync();
await tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommandAsync();
//处理订单联系人信息
DealBusinessOrderContact(info, tenantDb);
if (req.CtnInfo.Count > 0)
{
var ctnList = await tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == req.Id.ToString()).ToListAsync();
foreach (var item in req.CtnInfo)
{
if (item.Id == 0)
{
var ctn = item.Adapt<OpCtn>();
ctn.BSNO = info.Id.ToString();
await tenantDb.Insertable(ctn).ExecuteCommandAsync();
}
else
{
var ctn = ctnList.First(x => x.Id == item.Id);
ctn = item.Adapt(ctn);
await tenantDb.Updateable(ctn).ExecuteCommandAsync();
}
if (req.CtnInfo.Count > 0)
{
var ctnList = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == req.Id.ToString()).ToList();
foreach (var item in req.CtnInfo)
}
}
if (req.EdiInfo.IsNotNull())
{
if (item.Id == 0)
var edi = await tenantDb.Queryable<SeaExportEdi>().Where(x => x.BusinessId == req.Id).FirstAsync();
if (edi.IsNull())
{
var ctn = item.Adapt<OpCtn>();
ctn.BSNO = info.Id.ToString();
tenantDb.Insertable(ctn).ExecuteCommand();
var ediInfo = req.EdiInfo.Adapt<SeaExportEdi>();
ediInfo.BusinessId = req.Id;
await tenantDb.Insertable(ediInfo).ExecuteCommandAsync();
}
else
{
var ctn = ctnList.First(x => x.Id == item.Id);
ctn = item.Adapt(ctn);
tenantDb.Updateable(ctn).ExecuteCommand();
var ediInfo = req.EdiInfo.Adapt(edi);
await tenantDb.Updateable(ediInfo).ExecuteCommandAsync();
}
}
#region 处理未初始化费用状态表
if (feeStatus.IsNull())
{
feeStatus = BusinessFeeStatus.Init(req.Id);
await tenantDb.Insertable(feeStatus).ExecuteCommandAsync();
}
#endregion
//return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
await dbScope.Ado.CommitTranAsync();
return await Task.FromResult(DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess));
}
if (req.EdiInfo.IsNotNull())
catch (Exception ex)
{
var edi = tenantDb.Queryable<SeaExportEdi>().Where(x => x.BusinessId == req.Id).First();
if (edi.IsNull())
await dbScope.Ado.RollbackTranAsync();
return await Task.FromResult(DataResult.Failed("更新失败!" + ",请联系管理员!" + ex.ToString()));
}
}
}
/// <summary>
/// 处理订单联系人信息
/// </summary>
/// <param name="seaExport"></param>
/// <param name="sqlSugarScope"></param>
private void DealBusinessOrderContact(SeaExport seaExport,SqlSugarScopeProvider sqlSugarScope)
{
var contactLists = sqlSugarScope.Queryable<BusinessOrderContact>().Where(x => x.BusinessId == seaExport.Id).ToList();
var addList = new List<BusinessOrderContact>();
if (seaExport.CustomerId!=0)
{
var defaultContact = sqlSugarScope.Queryable<InfoClientContact>().Where(x => x.ClientId == seaExport.CustomerId && x.IsOperator == true).First();
if (defaultContact.IsNotNull())
{
if (!contactLists.Where(x=>x.BusinessType == BusinessType.OceanShippingExport &&x.CustomerType == "controller"&& x.Name == defaultContact.ShortName).Any())
{
var ediInfo = req.EdiInfo.Adapt<SeaExportEdi>();
ediInfo.BusinessId = req.Id;
tenantDb.Insertable(ediInfo).ExecuteCommand();
addList.Add(new BusinessOrderContact()
{
BusinessId = seaExport.Id,
CustomerType = "controller",
CustomerTypeName="委托单位",
Name = defaultContact.ShortName,
Tel = defaultContact.Tel,
Email = defaultContact.Email,
});
}
else
}
}
if (seaExport.TruckerId != 0)
{
var defaultContact = sqlSugarScope.Queryable<InfoClientContact>().Where(x => x.ClientId == seaExport.TruckerId && x.IsOperator == true).First();
if (defaultContact.IsNotNull())
{
if (!contactLists.Where(x => x.BusinessType == BusinessType.OceanShippingExport && x.CustomerType == "truck" && x.Name == defaultContact.ShortName).Any())
{
var ediInfo = req.EdiInfo.Adapt(edi);
tenantDb.Updateable(ediInfo).ExecuteCommand();
addList.Add(new BusinessOrderContact()
{
BusinessId = seaExport.Id,
CustomerType = "truck",
CustomerTypeName = "车队",
Name = defaultContact.ShortName,
Tel = defaultContact.Tel,
Email = defaultContact.Email,
});
}
}
#region 处理未初始化费用状态表
if (feeStatus.IsNull())
}
if (seaExport.YardId != 0)
{
var defaultContact = sqlSugarScope.Queryable<InfoClientContact>().Where(x => x.ClientId == seaExport.YardId && x.IsOperator == true).First();
if (defaultContact.IsNotNull())
{
feeStatus = BusinessFeeStatus.Init(req.Id);
tenantDb.Insertable(feeStatus).ExecuteCommand();
if (!contactLists.Where(x => x.BusinessType == BusinessType.OceanShippingExport && x.CustomerType == "yard" && x.Name == defaultContact.ShortName).Any())
{
addList.Add(new BusinessOrderContact()
{
BusinessId = seaExport.Id,
CustomerType = "yard",
CustomerTypeName = "场站",
Name = defaultContact.ShortName,
Tel = defaultContact.Tel,
Email = defaultContact.Email,
});
}
}
#endregion
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
if (addList.Count > 0)
sqlSugarScope.Insertable(addList).ExecuteCommand();
}
/// <summary>
/// 详情
/// </summary>

@ -0,0 +1,83 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Interface;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace DS.WMS.OpApi.Controllers;
/// <summary>
/// 业务订单联系人-服务
/// </summary>
public class BusinessOrderContactController : ApiController
{
private readonly IBusinessOrderContactService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public BusinessOrderContactController(IBusinessOrderContactService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetBusinessOrderContactList")]
public DataResult<List<BusinessOrderContactRes>> GetBusinessOrderContactList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("EditBusinessOrderContact")]
public DataResult EditBusinessOrderContact([FromBody] BusinessOrderContactReq model)
{
var res = _invokeService.EditBusinessOrderContact(model);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetBusinessOrderContactInfo")]
public DataResult<BusinessOrderContactRes> GetBusinessOrderContactInfo([FromQuery] string id)
{
var res = _invokeService.GetBusinessOrderContactInfo(id);
return res;
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="req">主表Ids</param>
/// <returns></returns>
[HttpPost]
[Route("BatchDelBusinessOrderContact")]
public DataResult BatchDelBusinessOrderContact([FromBody] IdModel req)
{
var res = _invokeService.BatchDelBusinessOrderContact(req);
return res;
}
}

@ -48,9 +48,9 @@ public class SeaExportController : ApiController
/// <returns></returns>
[HttpPost]
[Route("EditSeaExport")]
public DataResult EditSeaExport([FromBody] SeaExportReq req)
public async Task<DataResult> EditSeaExport([FromBody] SeaExportReq req)
{
var res = _invokeService.EditSeaExport(req);
var res = await _invokeService.EditSeaExport(req);
return res;
}

@ -63,7 +63,7 @@ public class SaasTest
{
var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
tenantDb.CodeFirst.InitTables(typeof(OpBusinessYard));
tenantDb.CodeFirst.InitTables(typeof(BusinessOrderContact));
//db.CodeFirst.InitTables(typeof(OpBusinessTruckCtn));
Assert.True(true);
}

Loading…
Cancel
Save