Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
951f295654
  1. 4
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Materials/MaterialAppService.cs
  2. 6
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs
  3. 37
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

4
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Materials/MaterialAppService.cs

@ -174,7 +174,7 @@ namespace Win.Sfs.SettleAccount.Entities.Materials
var _first = result.FirstOrDefault(p => p.MaterialCode == itm); var _first = result.FirstOrDefault(p => p.MaterialCode == itm);
if (_first != null) if (_first != null)
{ {
var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.MaterialPrice, _first.MaterialCode, 0, GuidGenerator.Create(), version); var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.MaterialPrice, _first.MaterialCode, 0, GuidGenerator.Create(), version,string.Empty);
_priceList.Add(_price); _priceList.Add(_price);
} }
} }
@ -183,7 +183,7 @@ namespace Win.Sfs.SettleAccount.Entities.Materials
var _first = result.FirstOrDefault(p => p.ChildMaterialCode == itm); var _first = result.FirstOrDefault(p => p.ChildMaterialCode == itm);
if (_first != null) if (_first != null)
{ {
var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.ChildMaterialPrice, _first.ChildMaterialCode, 0, GuidGenerator.Create(), version); var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.ChildMaterialPrice, _first.ChildMaterialCode, 0, GuidGenerator.Create(), version,string.Empty);
_priceList.Add(_price); _priceList.Add(_price);
} }
} }

6
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs

@ -20,7 +20,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{ {
public PriceList() public PriceList()
{ } { }
public PriceList(Guid Id,DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type,Guid parentId,string version):base(Id) public PriceList(Guid Id,DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type,Guid parentId,string version, string customerCode) :base(Id)
{ {
BeginDate = beginDate; BeginDate = beginDate;
EndDate = endDate; EndDate = endDate;
@ -29,15 +29,17 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
Type = type; Type = type;
ParentId = parentId; ParentId = parentId;
Version = version; Version = version;
CustomerCode = customerCode;
} }
public void Set(DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type) public void Set(DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type,string customerCode)
{ {
BeginDate = beginDate; BeginDate = beginDate;
EndDate = endDate; EndDate = endDate;
Price = price; Price = price;
MaterialCode = materialCode; MaterialCode = materialCode;
Type = type; Type = type;
CustomerCode = customerCode;
} }
public void Update(Guid id,string version) public void Update(Guid id,string version)
{ {

37
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

@ -84,19 +84,34 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
// on emp.DeptID equals dept.ID into JoinedEmpDept // on emp.DeptID equals dept.ID into JoinedEmpDept
// from dept in JoinedEmpDept.DefaultIfEmpty() // from dept in JoinedEmpDept.DefaultIfEmpty()
var add= from itm1 in entities join itm2 in pricelist
on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode }
into temp from itm3 in temp.DefaultIfEmpty() where itm3 == null select itm1;
var update = from itm1 in entities var update = from itm1 in entities
join itm2 in pricelist join itm2 in pricelist
on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode } on new { itm1.Type, itm1.MaterialCode } equals new { itm2.Type, itm2.MaterialCode }
where itm1.Price != itm2.Price where itm1.Price != itm2.Price
select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode,itm2.Type, itm2.ParentId, itm2.Version); select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode);
if (update.Count() > 0)
{
await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
}
else
{
var add = from itm1 in entities
join itm2 in pricelist
on new { itm1.Type, itm1.MaterialCode }
equals new { itm2.Type, itm2.MaterialCode }
into temp
from itm3 in temp.DefaultIfEmpty()
where itm3 == null
select itm1;
await _repository.GetDbContext().BulkInsertAsync<PriceList>(add.ToList());
}
await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
await _repository.GetDbContext().BulkInsertAsync<PriceList>(add.ToList());
var _first = _versionRepository.FirstOrDefault(p => p.Version == version); var _first = _versionRepository.FirstOrDefault(p => p.Version == version);
@ -113,7 +128,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public virtual async Task<PriceList> CreateAsync(PriceList input) public virtual async Task<PriceList> CreateAsync(PriceList input)
{ {
var entity = new PriceList( var entity = new PriceList(
GuidGenerator.Create(), input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.ParentId,input.Version GuidGenerator.Create(), input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.ParentId,input.Version,input.CustomerCode
); );
return await _repository.InsertAsync(entity); return await _repository.InsertAsync(entity);
@ -125,7 +140,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{ {
var entity = await _repository.GetAsync(id); var entity = await _repository.GetAsync(id);
entity.Set( entity.Set(
input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.CustomerCode
); );
return await _repository.UpdateAsync(entity); return await _repository.UpdateAsync(entity);

Loading…
Cancel
Save