* Added GetOrderNumbersByWz method to MaterialTransactionService
This commit is contained in:
@@ -8,4 +8,5 @@ public interface IMaterialTransactionService
|
|||||||
Task<MaterialTransactionDto?> GetByWzNumber(string wzNumber);
|
Task<MaterialTransactionDto?> GetByWzNumber(string wzNumber);
|
||||||
Task<IEnumerable<MaterialTransactionDto>> GetByWzNumbers(ISet<string> wzNumbers);
|
Task<IEnumerable<MaterialTransactionDto>> GetByWzNumbers(ISet<string> wzNumbers);
|
||||||
Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber(string orderNumber);
|
Task<IEnumerable<MaterialTransactionDto>> GetByOrderNumber(string orderNumber);
|
||||||
|
Task<IEnumerable<MaterialTransactionDto>> GetOrderNumbersByWz(ISet<string> wzNumbers);
|
||||||
}
|
}
|
||||||
@@ -45,4 +45,25 @@ public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper
|
|||||||
return await context.MaterialTransactions.Where(x => x.RefNum == orderNumber).OrderByDescending(x => x.TransDate)
|
return await context.MaterialTransactions.Where(x => x.RefNum == orderNumber).OrderByDescending(x => x.TransDate)
|
||||||
.Select(x => mapper.Map<MaterialTransactionDto>(x)).ToListAsync();
|
.Select(x => mapper.Map<MaterialTransactionDto>(x)).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<MaterialTransactionDto>> GetOrderNumbersByWz(ISet<string> wzNumbers)
|
||||||
|
{
|
||||||
|
if (!wzNumbers.Any())
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var wzNumbersList = string.Join(",", wzNumbers.Select(w => $"'{w}'"));
|
||||||
|
|
||||||
|
var sql = $@"
|
||||||
|
SELECT z.*
|
||||||
|
FROM ZPL_InternalNum_Matltran z
|
||||||
|
WHERE z.MTGroupNum <> ''
|
||||||
|
AND z.MTGroupNum IN ({wzNumbersList})";
|
||||||
|
|
||||||
|
IList<MaterialTransaction> result = await context.MaterialTransactions
|
||||||
|
.FromSqlRaw(sql)
|
||||||
|
.AsNoTracking()
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return result.Select(x => mapper.Map<MaterialTransactionDto>(x));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user