|
@ -5,11 +5,15 @@ using Volo.Abp.AspNetCore.Mvc; |
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Dashboard.Host.Models; |
|
|
using Win_in.Sfs.Wms.Dashboard.Host.Models; |
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.Dashboard.Host.Controllers; |
|
|
namespace Win_in.Sfs.Wms.Dashboard.Host.Controllers |
|
|
|
|
|
{ |
|
|
|
|
|
using System; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
|
|
|
|
|
|
using Volo.Abp; |
|
|
|
|
|
|
|
|
using Win_in.Sfs.Label.Application.Contracts; |
|
|
using Win_in.Sfs.Label.Application.Contracts; |
|
|
|
|
|
using Win_in.Sfs.Label.Domain; |
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
@ -23,31 +27,43 @@ public class PurchaseReceiptController : AbpController |
|
|
private readonly IInventoryLabelAppService _labelService; |
|
|
private readonly IInventoryLabelAppService _labelService; |
|
|
private readonly ISupplierAppService _supplierApp; |
|
|
private readonly ISupplierAppService _supplierApp; |
|
|
private readonly ISupplierAsnAppService _supplierAsnApp; |
|
|
private readonly ISupplierAsnAppService _supplierAsnApp; |
|
|
|
|
|
private readonly IPurchaseReceiptNoteAppService _purchaseReceiptNoteAppService; |
|
|
|
|
|
private readonly IInspectNoteAppService _inspectNoteAppService; |
|
|
|
|
|
|
|
|
public PurchaseReceiptController(IBalanceAppService balanceApp, IInventoryLabelAppService labelService, ISupplierAppService supplierApp, ISupplierAsnAppService supplierAsnApp) |
|
|
public PurchaseReceiptController(IBalanceAppService balanceApp, IInventoryLabelAppService labelService, ISupplierAppService supplierApp, ISupplierAsnAppService supplierAsnApp, IPurchaseReceiptNoteAppService purchaseReceiptNoteAppService, IInspectNoteAppService inspectNoteAppService) |
|
|
{ |
|
|
{ |
|
|
this._balanceApp = balanceApp; |
|
|
this._balanceApp = balanceApp; |
|
|
this._labelService = labelService; |
|
|
this._labelService = labelService; |
|
|
this._supplierApp = supplierApp; |
|
|
this._supplierApp = supplierApp; |
|
|
this._supplierAsnApp = supplierAsnApp; |
|
|
this._supplierAsnApp = supplierAsnApp; |
|
|
|
|
|
_purchaseReceiptNoteAppService = purchaseReceiptNoteAppService; |
|
|
|
|
|
_inspectNoteAppService = inspectNoteAppService; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpGet("receipt-sum-qty")] |
|
|
/// <summary>
|
|
|
public virtual async Task<PurchaseReceiptSumQtyDashboardDto> GetReceiptSumQtyAsync() |
|
|
/// 未上架数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("no-put-away-sum-qty")] |
|
|
|
|
|
public virtual async Task<PurchaseReceiptSumQtyDashboardDto> GetNoPutAwaySumQtyAsync() |
|
|
{ |
|
|
{ |
|
|
var dto = new PurchaseReceiptSumQtyDashboardDto(); |
|
|
var dto = new PurchaseReceiptSumQtyDashboardDto(); |
|
|
|
|
|
|
|
|
var items = await GetPurchaseReceiptItemDashboardAsync().ConfigureAwait(false); |
|
|
var items = await GetPurchaseReceiptItemDashboardAsync(); |
|
|
|
|
|
|
|
|
dto = new PurchaseReceiptSumQtyDashboardDto() { Qty = items.Sum(t => t.Qty) }; |
|
|
dto = new PurchaseReceiptSumQtyDashboardDto() { Qty = items.Sum(t => t.Qty) }; |
|
|
|
|
|
|
|
|
return dto; |
|
|
return dto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpGet("receipt-count-by-supplier")] |
|
|
/// <summary>
|
|
|
public virtual async Task<List<PurchaseReceiptCountBySupplierDashboardDto>> GetReceiptCountBySupplierQtyAsync() |
|
|
/// 未上架汇总
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("no-put-away-by-supplier")] |
|
|
|
|
|
public virtual async Task<List<PurchaseReceiptCountBySupplierDashboardDto>> GetNoPutAwayBySupplierAsync() |
|
|
{ |
|
|
{ |
|
|
var items = await GetPurchaseReceiptItemDashboardAsync().ConfigureAwait(false); |
|
|
var items = await GetPurchaseReceiptItemDashboardAsync(); |
|
|
|
|
|
|
|
|
var dtos = items.GroupBy(t => t.SupplierShortName) |
|
|
var dtos = items.GroupBy(t => t.SupplierShortName) |
|
|
.Select( |
|
|
.Select( |
|
@ -60,10 +76,14 @@ public class PurchaseReceiptController : AbpController |
|
|
return dtos; |
|
|
return dtos; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpGet("receipt-item-list")] |
|
|
/// <summary>
|
|
|
|
|
|
/// 未上架明细
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("no-put-away-item-list")] |
|
|
public virtual async Task<List<PurchaseReceiptItemDashboardDto>> GetReceiptItemListAsync() |
|
|
public virtual async Task<List<PurchaseReceiptItemDashboardDto>> GetReceiptItemListAsync() |
|
|
{ |
|
|
{ |
|
|
return await GetPurchaseReceiptItemDashboardAsync().ConfigureAwait(false); |
|
|
return await GetPurchaseReceiptItemDashboardAsync(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpGet("un-receipt-sum-qty")] |
|
|
[HttpGet("un-receipt-sum-qty")] |
|
@ -71,7 +91,7 @@ public class PurchaseReceiptController : AbpController |
|
|
{ |
|
|
{ |
|
|
var dto = new PurchaseReceiptSumQtyDashboardDto(); |
|
|
var dto = new PurchaseReceiptSumQtyDashboardDto(); |
|
|
|
|
|
|
|
|
var items = await GetUnPurchaseReceiptItemDashboardAsync().ConfigureAwait(false); |
|
|
var items = await this.GetUnPurchaseReceiptItemDashboardAsync(); |
|
|
|
|
|
|
|
|
dto = new PurchaseReceiptSumQtyDashboardDto() { Qty = items.Sum(t => t.Qty) }; |
|
|
dto = new PurchaseReceiptSumQtyDashboardDto() { Qty = items.Sum(t => t.Qty) }; |
|
|
|
|
|
|
|
@ -81,7 +101,7 @@ public class PurchaseReceiptController : AbpController |
|
|
[HttpGet("un-receipt-count-by-supplier")] |
|
|
[HttpGet("un-receipt-count-by-supplier")] |
|
|
public virtual async Task<List<PurchaseReceiptCountBySupplierDashboardDto>> GetUnReceiptCountBySupplierQtyAsync() |
|
|
public virtual async Task<List<PurchaseReceiptCountBySupplierDashboardDto>> GetUnReceiptCountBySupplierQtyAsync() |
|
|
{ |
|
|
{ |
|
|
var items = await GetUnPurchaseReceiptItemDashboardAsync().ConfigureAwait(false); |
|
|
var items = await GetUnPurchaseReceiptItemDashboardAsync(); |
|
|
|
|
|
|
|
|
var dtos = items.GroupBy(t => t.SupplierShortName) |
|
|
var dtos = items.GroupBy(t => t.SupplierShortName) |
|
|
.Select( |
|
|
.Select( |
|
@ -97,25 +117,30 @@ public class PurchaseReceiptController : AbpController |
|
|
[HttpGet("un-receipt-item-list")] |
|
|
[HttpGet("un-receipt-item-list")] |
|
|
public virtual async Task<List<PurchaseReceiptItemDashboardDto>> GetUnReceiptItemListAsync() |
|
|
public virtual async Task<List<PurchaseReceiptItemDashboardDto>> GetUnReceiptItemListAsync() |
|
|
{ |
|
|
{ |
|
|
return await GetUnPurchaseReceiptItemDashboardAsync().ConfigureAwait(false); |
|
|
return await this.GetUnPurchaseReceiptItemDashboardAsync(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async Task<List<PurchaseReceiptItemDashboardDto>> GetPurchaseReceiptItemDashboardAsync() |
|
|
private async Task<List<PurchaseReceiptItemDashboardDto>> GetPurchaseReceiptItemDashboardAsync() |
|
|
{ |
|
|
{ |
|
|
var balances = await GetBalancesAsync("INSPECT", EnumInventoryStatus.OK).ConfigureAwait(false); |
|
|
var inspectNoteDetailDto = await _inspectNoteAppService.GetInspectNoteDetailByToDayTaskAsync(); |
|
|
|
|
|
var packingCodeList = inspectNoteDetailDto.Where(p => p.Status == EnumInventoryStatus.OK).Select(p => p.PackingCode).ToList(); |
|
|
|
|
|
var balances = await _balanceApp.GetListByPackingCodesAsync(packingCodeList); |
|
|
|
|
|
balances = balances.Where(p => p.LocationCode == "INSPECT").ToList(); |
|
|
|
|
|
|
|
|
|
|
|
//var balances = await GetBalancesAsync("INSPECT", EnumInventoryStatus.OK);
|
|
|
|
|
|
|
|
|
var packingcodes = balances.Select(t => t.PackingCode).Distinct(); |
|
|
var packingcodes = balances.Select(t => t.PackingCode).Distinct(); |
|
|
|
|
|
|
|
|
var labels = await GetLabelsAsync(packingcodes).ConfigureAwait(false); |
|
|
var labels = await GetLabelsAsync(packingcodes); |
|
|
|
|
|
|
|
|
var supplierCodes = labels.Select(t => t.SupplierCode).Distinct(); |
|
|
var supplierCodes = labels.Select(t => t.SupplierCode).Distinct(); |
|
|
|
|
|
|
|
|
var suppliers = await GetSuppliersAsync(supplierCodes).ConfigureAwait(false); |
|
|
var suppliers = await GetSuppliersAsync(supplierCodes); |
|
|
|
|
|
|
|
|
return ConvertToPurchaseReceiptItemDashboard(balances, labels, suppliers); |
|
|
return ConvertToPurchaseReceiptItemDashboard(balances, labels, suppliers); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static List<PurchaseReceiptItemDashboardDto> ConvertToPurchaseReceiptItemDashboard( |
|
|
private List<PurchaseReceiptItemDashboardDto> ConvertToPurchaseReceiptItemDashboard( |
|
|
List<BalanceDTO> balances, |
|
|
List<BalanceDTO> balances, |
|
|
List<InventoryLabelDto> labels, |
|
|
List<InventoryLabelDto> labels, |
|
|
List<SupplierDTO> suppliers) |
|
|
List<SupplierDTO> suppliers) |
|
@ -129,16 +154,12 @@ public class PurchaseReceiptController : AbpController |
|
|
var label = labels.FirstOrDefault(t => t.Code == balance.PackingCode); |
|
|
var label = labels.FirstOrDefault(t => t.Code == balance.PackingCode); |
|
|
|
|
|
|
|
|
if (label == null) |
|
|
if (label == null) |
|
|
{ |
|
|
|
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var supplier = suppliers.FirstOrDefault(t => t != null && t.Code == label.SupplierCode); |
|
|
var supplier = suppliers.FirstOrDefault(t => t != null && t.Code == label.SupplierCode); |
|
|
|
|
|
|
|
|
if (supplier == null) |
|
|
if (supplier == null) |
|
|
{ |
|
|
|
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
supplierShortName = supplier.ShortName; |
|
|
supplierShortName = supplier.ShortName; |
|
|
|
|
|
|
|
@ -164,23 +185,23 @@ public class PurchaseReceiptController : AbpController |
|
|
|
|
|
|
|
|
private async Task<List<BalanceDTO>> GetBalancesAsync(string locationCode, EnumInventoryStatus status) |
|
|
private async Task<List<BalanceDTO>> GetBalancesAsync(string locationCode, EnumInventoryStatus status) |
|
|
{ |
|
|
{ |
|
|
return await _balanceApp.GetListByLocationCodeAndStatusAsync(locationCode, status).ConfigureAwait(false); |
|
|
return await this._balanceApp.GetListByLocationCodeAndStatusAsync(locationCode, status); |
|
|
} |
|
|
} |
|
|
private async Task<List<InventoryLabelDto>> GetLabelsAsync(IEnumerable<string> codes) |
|
|
private async Task<List<InventoryLabelDto>> GetLabelsAsync(IEnumerable<string> codes) |
|
|
{ |
|
|
{ |
|
|
return await _labelService.GetByCodesAsync(codes).ConfigureAwait(false); |
|
|
return await this._labelService.GetByCodesAsync(codes); |
|
|
} |
|
|
} |
|
|
private async Task<List<SupplierDTO>> GetSuppliersAsync(IEnumerable<string> codes) |
|
|
private async Task<List<SupplierDTO>> GetSuppliersAsync(IEnumerable<string> codes) |
|
|
{ |
|
|
{ |
|
|
return await _supplierApp.GetByCodesAsync(codes).ConfigureAwait(false); |
|
|
return await this._supplierApp.GetByCodesAsync(codes); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async Task<List<SupplierAsnDTO>> GetSupplierAsnsAsync() |
|
|
private async Task<List<SupplierAsnDTO>> GetSupplierAsnsAsync() |
|
|
{ |
|
|
{ |
|
|
return await _supplierAsnApp.GetForTodayUnReceivedListAsync().ConfigureAwait(false); |
|
|
return await this._supplierAsnApp.GetForTodayUnReceivedListAsync(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static List<PurchaseReceiptItemDashboardDto> ConvertToUnPurchaseReceiptItemDashboard( |
|
|
private List<PurchaseReceiptItemDashboardDto> ConvertToUnPurchaseReceiptItemDashboard( |
|
|
List<SupplierAsnDTO> supplierAsns, |
|
|
List<SupplierAsnDTO> supplierAsns, |
|
|
List<SupplierDTO> suppliers) |
|
|
List<SupplierDTO> suppliers) |
|
|
{ |
|
|
{ |
|
@ -193,9 +214,7 @@ public class PurchaseReceiptController : AbpController |
|
|
var supplier = suppliers.FirstOrDefault(t => t.Code == supplierAsn.SupplierCode); |
|
|
var supplier = suppliers.FirstOrDefault(t => t.Code == supplierAsn.SupplierCode); |
|
|
|
|
|
|
|
|
if (supplier == null) |
|
|
if (supplier == null) |
|
|
{ |
|
|
|
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
supplierShortName = supplier.ShortName; |
|
|
supplierShortName = supplier.ShortName; |
|
|
|
|
|
|
|
@ -226,12 +245,15 @@ public class PurchaseReceiptController : AbpController |
|
|
{ |
|
|
{ |
|
|
var dtos = new List<PurchaseReceiptItemDashboardDto>(); |
|
|
var dtos = new List<PurchaseReceiptItemDashboardDto>(); |
|
|
|
|
|
|
|
|
var supplierAsns = await GetSupplierAsnsAsync().ConfigureAwait(false); |
|
|
var supplierAsns = await this.GetSupplierAsnsAsync(); |
|
|
|
|
|
|
|
|
var supplierCodes = supplierAsns.Select(t => t.SupplierCode).Distinct(); |
|
|
var supplierCodes = supplierAsns.Select(t => t.SupplierCode).Distinct(); |
|
|
|
|
|
|
|
|
var suppliers = await GetSuppliersAsync(supplierCodes).ConfigureAwait(false); |
|
|
var suppliers = await GetSuppliersAsync(supplierCodes); |
|
|
|
|
|
|
|
|
return ConvertToUnPurchaseReceiptItemDashboard(supplierAsns, suppliers); |
|
|
return this.ConvertToUnPurchaseReceiptItemDashboard(supplierAsns, suppliers); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|