同步金蝶-代码处理提交
This commit is contained in:
@@ -187,6 +187,11 @@ namespace WMS.Web.Repositories.Configuration
|
||||
.WithOne()
|
||||
.HasForeignKey(p => p.Fid)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
ent.HasMany(p => p.ErpDetails)
|
||||
.WithOne()
|
||||
.HasForeignKey(p => p.Fid)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
builder.Entity<InStockDetails>(ent =>
|
||||
{
|
||||
@@ -200,6 +205,11 @@ namespace WMS.Web.Repositories.Configuration
|
||||
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
|
||||
c => (List<string>)c.ToList()));
|
||||
});
|
||||
builder.Entity<InStockErpDetails>(ent =>
|
||||
{
|
||||
ent.ToTable("t_wms_instock_erp_details");
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
builder.Entity<InStockTotalDetails>(ent =>
|
||||
{
|
||||
ent.ToTable("t_wms_instock_total_details");
|
||||
|
||||
@@ -14,6 +14,7 @@ using WMS.Web.Core.Internal.Results;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Domain.Mappers;
|
||||
using WMS.Web.Domain.Values;
|
||||
using WMS.Web.Domain.Values.Single;
|
||||
using WMS.Web.Repositories.Configuration;
|
||||
@@ -249,5 +250,55 @@ namespace WMS.Web.Repositories
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<InStock> Update(InStock entity, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var model = await _context.Instock
|
||||
.AsNoTracking()
|
||||
.Include(s => s.Details)
|
||||
.FirstOrDefaultAsync(f => f.Id == entity.Id);
|
||||
if (model == null)
|
||||
return null;
|
||||
_mapper.Map(entity, model);
|
||||
//子集单独映射
|
||||
_mapper.ToMapList(entity.Details, model.Details);
|
||||
await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return model;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据单据头id获取数据
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<InStock>> GetList(List<int> ids)
|
||||
{
|
||||
var res = await _context.Instock
|
||||
.Include(s => s.Details)
|
||||
.Include(s => s.ErpDetails)
|
||||
.Where(f => ids.Contains(f.Id))
|
||||
.ToListAsync();
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user