|
@ -133,22 +133,37 @@ public class TransactionAppService |
|
|
public virtual async Task<List<ReportItemSerialDto>> GetItemSerialList(List<string> itemCodes,string erpLocationCode,DateTime startDateTime,DateTime endDateTime) |
|
|
public virtual async Task<List<ReportItemSerialDto>> GetItemSerialList(List<string> itemCodes,string erpLocationCode,DateTime startDateTime,DateTime endDateTime) |
|
|
{ |
|
|
{ |
|
|
var itemSerialDtos = new List<ReportItemSerialDto>(); |
|
|
var itemSerialDtos = new List<ReportItemSerialDto>(); |
|
|
|
|
|
var allItemBasicDtos = new List<ItemBasicDTO>(); |
|
|
|
|
|
var allTransactions = new List<Transaction>(); |
|
|
|
|
|
var locationDtos = await _locationAppService.GetAllAsync().ConfigureAwait(false); |
|
|
|
|
|
var balanceDtos = await _balanceAppService |
|
|
|
|
|
.GetAllListByFilterAsync(new SfsInventoryRequestInputBase()).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
var itemBasicDtos_i = await _itemBasicAppService.GetAllListByFilterAsync(new SfsBaseDataRequestInputBase()).ConfigureAwait(false); |
|
|
|
|
|
allItemBasicDtos = itemBasicDtos_i; |
|
|
|
|
|
|
|
|
if (!itemCodes.Any()) |
|
|
if (!itemCodes.Any()) |
|
|
{ |
|
|
{ |
|
|
var itemBasicDtos_i= await _itemBasicAppService.GetAllListByFilterAsync(new SfsBaseDataRequestInputBase()).ConfigureAwait(false); |
|
|
|
|
|
var itemBasicDtos_t = await _repository.GetListAsync().ConfigureAwait(false); |
|
|
var itemBasicDtos_t = await _repository.GetListAsync().ConfigureAwait(false); |
|
|
|
|
|
allTransactions = itemBasicDtos_t; |
|
|
|
|
|
|
|
|
itemCodes.AddRange(itemBasicDtos_i.Select(p => p.Code)); |
|
|
itemCodes.AddRange(itemBasicDtos_i.Select(p => p.Code)); |
|
|
itemCodes.AddRange(itemBasicDtos_t.Select(p => p.ItemCode)); |
|
|
itemCodes.AddRange(itemBasicDtos_t.Select(p => p.ItemCode)); |
|
|
|
|
|
|
|
|
itemCodes=itemCodes.Distinct().ToList(); |
|
|
itemCodes=itemCodes.Distinct().ToList(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
var itemBasicDtos_t = await _repository.GetListAsync(p=> itemCodes.Contains(p.ItemCode)).ConfigureAwait(false); |
|
|
|
|
|
allTransactions = itemBasicDtos_t; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
foreach (var itemCode in itemCodes) |
|
|
foreach (var itemCode in itemCodes) |
|
|
{ |
|
|
{ |
|
|
var itemSerialDto = new ReportItemSerialDto(); |
|
|
var itemSerialDto = new ReportItemSerialDto(); |
|
|
|
|
|
|
|
|
var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(itemCode).ConfigureAwait(false); |
|
|
var itemBasicDto = allItemBasicDtos.FirstOrDefault(p=>p.Code== itemCode); |
|
|
if (itemBasicDto==null) |
|
|
if (itemBasicDto==null) |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException($"物品代码{itemCode}不存在"); |
|
|
throw new UserFriendlyException($"物品代码{itemCode}不存在"); |
|
@ -161,13 +176,12 @@ public class TransactionAppService |
|
|
itemSerialDto.ItemName = itemBasicDto.Name; |
|
|
itemSerialDto.ItemName = itemBasicDto.Name; |
|
|
|
|
|
|
|
|
//所有这个零件的事务
|
|
|
//所有这个零件的事务
|
|
|
var transactions=await _repository.GetListAsync(p => p.ItemCode == itemCode).ConfigureAwait(false); |
|
|
var transactions = allTransactions.Where(p => p.ItemCode == itemCode); |
|
|
if (!string.IsNullOrEmpty(erpLocationCode)) |
|
|
if (!string.IsNullOrEmpty(erpLocationCode)) |
|
|
{ |
|
|
{ |
|
|
transactions = transactions.Where(p => p.LocationErpCode == erpLocationCode).ToList(); |
|
|
transactions = transactions.Where(p => p.LocationErpCode == erpLocationCode).ToList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var locationDtos=await _locationAppService.GetAllAsync().ConfigureAwait(false); |
|
|
|
|
|
if (!string.IsNullOrEmpty(erpLocationCode)) |
|
|
if (!string.IsNullOrEmpty(erpLocationCode)) |
|
|
{ |
|
|
{ |
|
|
locationDtos = locationDtos.Where(p => p.ErpLocationCode == erpLocationCode).ToList(); |
|
|
locationDtos = locationDtos.Where(p => p.ErpLocationCode == erpLocationCode).ToList(); |
|
@ -219,10 +233,8 @@ public class TransactionAppService |
|
|
decimal tempNowSum = 0; |
|
|
decimal tempNowSum = 0; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var balanceDtos = await _balanceAppService |
|
|
var balanceDtosWithLocation = balanceDtos.Where(p =>p.ItemCode== itemCode && p.LocationCode == locationDto.Code); |
|
|
.GetListByLocationCodeAndItemCodeAsync(locationDto.Code, itemSerialDto.ItemCode) |
|
|
tempNowSum = balanceDtosWithLocation.Sum(p => p.Qty); |
|
|
.ConfigureAwait(false); |
|
|
|
|
|
tempNowSum = balanceDtos.Sum(p => p.Qty); |
|
|
|
|
|
} |
|
|
} |
|
|
catch |
|
|
catch |
|
|
{ |
|
|
{ |
|
|