优化
This commit is contained in:
@@ -80,8 +80,12 @@ namespace WMS.Web.Repositories
|
||||
if (!string.IsNullOrEmpty(dto.MaterialNumber))
|
||||
materials = materials.Where(w => w.MaterialNumber.Contains(dto.MaterialNumber)).ToList();
|
||||
|
||||
var query=_context.InStockDetails
|
||||
.GroupJoin(_context.Instock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
//var query=_context.InStockDetails
|
||||
// .GroupJoin(_context.Instock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
// .SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
|
||||
// .Where(adv => 1 == 1);
|
||||
var query = _context.InStockTotalDetails
|
||||
.GroupJoin(_context.Instock, detail => detail.InStockId, order => order.Id, (detail, orders) => new { detail, orders })
|
||||
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
|
||||
.Where(adv => 1 == 1);
|
||||
|
||||
@@ -99,12 +103,12 @@ namespace WMS.Web.Repositories
|
||||
query = query.Where(w => w.detail.SupplierId == dto.SupplierId.Value);
|
||||
|
||||
if (dto.OrgId.HasValue)
|
||||
query = query.Where(w => w.detail.OrgId == dto.OrgId.Value);
|
||||
query = query.Where(w => w.order.OrgId == dto.OrgId.Value);
|
||||
|
||||
if (!string.IsNullOrEmpty(dto.StockCode))
|
||||
{
|
||||
var splitStrs = dto.StockCode.Split("_$");
|
||||
query = query.Where(w => w.detail.StockCode == splitStrs[0] && w.detail.OrgCode == splitStrs[1]);
|
||||
query = query.Where(w => w.order.StockCode == splitStrs[0] && w.order.OrgCode == splitStrs[1]);
|
||||
}
|
||||
|
||||
if (dto.Type.HasValue)
|
||||
@@ -126,11 +130,11 @@ namespace WMS.Web.Repositories
|
||||
Type=s.order.Type.GetRemark(),
|
||||
SourceBillNo=s.detail.SourceBillNo,
|
||||
Supplier= _erpBasicDataExtendService.GetSupplierName(suppliers, s.detail.SupplierId),
|
||||
Org = _erpBasicDataExtendService.GetOrgName(orgs, s.detail.OrgId),
|
||||
Org = _erpBasicDataExtendService.GetOrgName(orgs, s.order.OrgId),
|
||||
MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialId),
|
||||
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.detail.MaterialId),
|
||||
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialId),
|
||||
Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, _loginRepositories.CompanyId, s.detail.StockCode+s.detail.OrgCode),
|
||||
Stock = _singleDataService.GetSingleData(SingleAction.StocksJoinOrgCode, _loginRepositories.CompanyId, s.order.StockCode+s.order.OrgCode),
|
||||
Qty =s.detail.Qty,
|
||||
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.order.CreatorId),
|
||||
CreateTime =s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
@@ -215,5 +219,35 @@ namespace WMS.Web.Repositories
|
||||
};
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加:入库汇总明细
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddRangeTotalDetails(List<InStockTotalDetails> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (entitys != null && entitys.Count != 0)
|
||||
{
|
||||
await _context.InStockTotalDetails.AddRangeAsync(entitys);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user