修改往来单位增加地址

optimize
jianghaiqing 1 year ago
parent c67fbd1584
commit 6180e648d9

@ -0,0 +1,34 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Core.Entity
{
/// <summary>
/// 客户地址
/// </summary>
[SugarTable("djy_customer_addr")]
[Description("客户地址")]
public class DjyCustomerAddr
{
/// <summary>
/// 客户Id
/// </summary>
public long CustomerId { get; set; }
/// <summary>
/// 地址简称
/// </summary>
public string AddrName { get; set; }
/// <summary>
/// 地址详情
/// </summary>
public string Addr { get; set; }
/// <summary>
/// 地址类型 factory-工厂地址
/// </summary>
public string AddrType { get; set; }
}
}

@ -1949,6 +1949,31 @@
等级
</summary>
</member>
<member name="T:Myshipping.Core.Entity.DjyCustomerAddr">
<summary>
客户地址
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyCustomerAddr.CustomerId">
<summary>
客户Id
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyCustomerAddr.AddrName">
<summary>
地址简称
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyCustomerAddr.Addr">
<summary>
地址详情
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyCustomerAddr.AddrType">
<summary>
地址类型 factory-工厂地址
</summary>
</member>
<member name="T:Myshipping.Core.Entity.DjyCustomerContact">
<summary>
@ -10186,6 +10211,31 @@
<param name="top">默认最大行数</param>
<returns>返回回执</returns>
</member>
<member name="T:Myshipping.Core.Service.DjyCustomerAddrInput">
<summary>
往来单位地址
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyCustomerAddrInput.CustomerId">
<summary>
客户Id
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyCustomerAddrInput.AddrName">
<summary>
地址简称
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyCustomerAddrInput.Addr">
<summary>
地址详情
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyCustomerAddrInput.AddrType">
<summary>
地址类型 factory-工厂地址
</summary>
</member>
<member name="T:Myshipping.Core.Service.DjyCustomerContactDto">
<summary>
订舱客户联系人输出参数
@ -10726,6 +10776,11 @@
服务项目
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyCustomerInput.Addrs">
<summary>
地址列表
</summary>
</member>
<member name="T:Myshipping.Core.Service.AddDjyCustomerInput">
<summary>
订舱客户新增输入参数
@ -11041,6 +11096,11 @@
服务项目
</summary>
</member>
<member name="P:Myshipping.Core.Service.DjyCustomerOutput.Addrs">
<summary>
地址列表
</summary>
</member>
<member name="M:Myshipping.Core.Service.IDjyCustomerService.QuerytDjyCustomerInfo(System.String,System.String[],System.Int32)">
<summary>
检索车队参数

@ -26,15 +26,18 @@ namespace Myshipping.Core.Service
{
private readonly SqlSugarRepository<DjyCustomer> _rep;
private readonly SqlSugarRepository<DjyCustomerContact> _repContact;
private readonly SqlSugarRepository<DjyCustomerAddr> _repAddr;
private readonly ILogger<DjyCustomerService> _logger;
public DjyCustomerService(SqlSugarRepository<DjyCustomer> rep, SqlSugarRepository<DjyCustomerContact> repContact, ILogger<DjyCustomerService> logger)
public DjyCustomerService(SqlSugarRepository<DjyCustomer> rep, SqlSugarRepository<DjyCustomerContact> repContact, ILogger<DjyCustomerService> logger, SqlSugarRepository<DjyCustomerAddr> addrRepContact)
{
_rep = rep;
_repContact = repContact;
_logger = logger;
_repAddr = addrRepContact;
}
/// <summary>
@ -106,6 +109,12 @@ namespace Myshipping.Core.Service
var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>();
contactList.ForEach(x => x.CustomerId = entity.Id);
await _repContact.InsertAsync(contactList);
//地址
var addrList = input.Contacts.Adapt<List<DjyCustomerAddr>>();
addrList.ForEach(x => x.CustomerId = entity.Id);
await _repAddr.InsertAsync(addrList);
return entity.Id;
}
@ -148,6 +157,11 @@ namespace Myshipping.Core.Service
var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>();
contactList.ForEach(x => x.CustomerId = entity.Id);
await _repContact.InsertAsync(contactList);
//地址
await _repAddr.DeleteAsync(x => x.CustomerId == input.Id);
var addrList = input.Contacts.Adapt<List<DjyCustomerAddr>>();
addrList.ForEach(x => x.CustomerId = entity.Id);
await _repAddr.InsertAsync(addrList);
return entity.Id;
}
@ -167,6 +181,7 @@ namespace Myshipping.Core.Service
else
{
await _repContact.DeleteAsync(x => x.CustomerId == input.Id);
await _repAddr.DeleteAsync(x => x.CustomerId == input.Id);
await _rep.DeleteAsync(entity);
}
}
@ -188,6 +203,8 @@ namespace Myshipping.Core.Service
}
var custOut = cust.Adapt<DjyCustomerOutput>();
custOut.Contacts = _repContact.Where(x => x.CustomerId == input.Id).OrderBy(x => x.Sort).ToList().Adapt<List<DjyCustomerContactOutput>>();
custOut.Addrs = _repAddr.Where(x => x.CustomerId == input.Id).ToList().Adapt<List<DjyCustomerAddrInput>>();
return custOut;
}
@ -263,6 +280,9 @@ namespace Myshipping.Core.Service
var contactList = _repContact.AsQueryable()
.Where(a => custsArg.Contains(a.CustomerId.Value)).ToList();
var addrList = _repAddr.AsQueryable()
.Where(a => custsArg.Contains(a.CustomerId)).ToList();
list = list.GroupJoin(contactList, l => l.Id, r => r.CustomerId.Value, (l, r) =>
{
var curList = r.ToList();
@ -273,6 +293,21 @@ namespace Myshipping.Core.Service
return l;
}).ToList();
if(addrList.Count > 0)
{
list = list.GroupJoin(addrList, l => l.Id, r => r.CustomerId, (l, r) =>
{
var curList = r.ToList();
if (curList.Count > 0)
l.Addrs = curList.Adapt<List<DjyCustomerAddrInput>>();
return l;
}).ToList();
}
}
}

@ -0,0 +1,32 @@
using Myshipping.Core;
using System;
using System.ComponentModel.DataAnnotations;
namespace Myshipping.Core.Service
{
/// <summary>
/// 往来单位地址
/// </summary>
public class DjyCustomerAddrInput
{
/// <summary>
/// 客户Id
/// </summary>
public long CustomerId { get; set; }
/// <summary>
/// 地址简称
/// </summary>
public string AddrName { get; set; }
/// <summary>
/// 地址详情
/// </summary>
public string Addr { get; set; }
/// <summary>
/// 地址类型 factory-工厂地址
/// </summary>
public string AddrType { get; set; }
}
}

@ -13,6 +13,8 @@ namespace Myshipping.Core.Service
public DjyCustomerInput()
{
this.Contacts = new List<AddDjyCustomerContactInput>();
this.Addrs = new List<DjyCustomerAddrInput>();
}
/// <summary>
@ -167,6 +169,11 @@ namespace Myshipping.Core.Service
/// </summary>
public string ServiceItem { get; set; }
public List<AddDjyCustomerContactInput> Contacts { get; set; }
/// <summary>
/// 地址列表
/// </summary>
public List<DjyCustomerAddrInput> Addrs { get; set; }
}
/// <summary>

@ -160,5 +160,9 @@ namespace Myshipping.Core.Service
/// </summary>
public string ServiceItem { get; set; }
public List<DjyCustomerContactOutput> Contacts { get; set; }
/// <summary>
/// 地址列表
/// </summary>
public List<DjyCustomerAddrInput> Addrs { get; set; }
}
}

Loading…
Cancel
Save