optimize
wet 2 years ago
parent 3379c51fcb
commit 1b59fb5a6a

@ -9968,6 +9968,13 @@
数据同步服务
</summary>
</member>
<member name="M:Myshipping.Application.DataSyncService.SyncCustomer(Myshipping.Application.DjyCustomerSyncDto)">
<summary>
同步客户
</summary>
<param name="model"></param>
<returns></returns>
</member>
<member name="T:Myshipping.Application.DjyCustomerSyncDto">
<summary>
订舱客户同步

@ -46,9 +46,11 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingCtn> _repCtn;
private readonly SqlSugarRepository<SysUser> _repUser;
private readonly SqlSugarRepository<SysTenant> _repTenant;
private readonly SqlSugarRepository<DjyCustomer> _djycustomer;
private readonly SqlSugarRepository<DjyCustomerContact> _djycustomercontact;
public DataSyncService(ILogger<BookingOrderService> logger, ISysCacheService cache, SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn,
SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant)
SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<DjyCustomer> djycustomer, SqlSugarRepository<DjyCustomerContact> djycustomercontact)
{
this._logger = logger;
this._rep = rep;
@ -56,6 +58,8 @@ namespace Myshipping.Application
this._cache = cache;
this._repUser = repUser;
this._repTenant = repTenant;
this._djycustomer = djycustomer;
this._djycustomercontact = djycustomercontact;
}
@ -68,19 +72,38 @@ namespace Myshipping.Application
[HttpPost("/DataSync/SyncCustomer"), ApiUser]
public async Task<long> SyncCustomer(DjyCustomerSyncDto model)
{
return 0;
if (string.IsNullOrWhiteSpace(model.CodeName)) {
throw Oops.Bah("请上传正确数据,Code未录入");
}
var m = await _djycustomer.Where(x => x.CodeName == model.CodeName).FirstAsync();
var entity = model.Adapt<DjyCustomer>();
if (m == null)
{
await _djycustomer.InsertAsync(entity);
foreach (var item in model.ContactList)
{
var contact = item.Adapt<DjyCustomerContact>();
contact.CustomerId = entity.Id;
await _djycustomercontact.InsertAsync(contact);
}
}
else {
entity.Id=m.Id;
await _djycustomer.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
await _djycustomercontact.DeleteAsync(x => x.CustomerId == entity.Id);
foreach (var item in model.ContactList)
{
var contact = item.Adapt<DjyCustomerContact>();
contact.CustomerId = entity.Id;
await _djycustomercontact.InsertAsync(contact);
}
}
return entity.Id;
}
#endregion

@ -7,7 +7,7 @@ namespace Myshipping.Application.Entity
/// <summary>
/// 船期信息
/// </summary>
[SugarTable("vesselinfo")]
[SugarTable("djy_vesselinfo")]
[Description("船期信息")]
public class DjyVesselInfo : PrimaryKeyEntity
{

@ -1006,7 +1006,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
public async Task AddOrUpdateMappingCtn([FromBody] MappingCtnDto dto)
{
var list = await _sysCacheService.GetAllMappingCtn();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.GID != dto.GID).Count();
var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module&&x.CarrierCode==dto.CarrierCode && x.GID != dto.GID).Count();
if (count > 0)
{
throw Oops.Bah(ErrorCode.D1006);

Loading…
Cancel
Save