唐明亮 2 years ago
parent
commit
790fbd5a8a
  1. 32
      be/Hosts/Win_in.Sfs.Wms.Dashboard.Host/Controllers/AsnTimeWindowController.cs
  2. 199
      be/Hosts/Win_in.Sfs.Wms.Dashboard.Host/Controllers/MaterialRequestController.cs
  3. 262
      be/Hosts/Win_in.Sfs.Wms.Dashboard.Host/Controllers/PlanAndActualController.cs
  4. 352
      be/Hosts/Win_in.Sfs.Wms.Dashboard.Host/Controllers/PurchaseReceiptController.cs
  5. 5
      be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/TransferLogs/TransferLogAppService.cs
  6. 6
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/PurchaseReceiptJobs/IPurchaseReceiptJobAppService.cs
  7. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/InspectNotes/IInspectNoteAppService.cs
  8. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/IPurchaseOrderAppService.cs
  9. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs
  10. 15
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAppService.cs
  11. 25
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InspectNotes/InspectNoteAppService.cs
  12. 18
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs
  13. 9
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs
  14. 6
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/InspectNotes/InspectNoteDetail.cs
  15. 42
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/IssueJobAutoMapperProfile.cs
  16. 1
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/MaterialRequestEventHandler.cs
  17. 67
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/IssueNoteEventHandler.cs

32
be/Hosts/Win_in.Sfs.Wms.Dashboard.Host/Controllers/AsnTimeWindowController.cs

@ -8,6 +8,7 @@ using Win_in.Sfs.Wms.Store.Application.Contracts;
namespace Win_in.Sfs.Wms.Dashboard.Host.Controllers; namespace Win_in.Sfs.Wms.Dashboard.Host.Controllers;
using System.Diagnostics.Metrics;
using System.Linq; using System.Linq;
using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Application.Contracts;
@ -29,28 +30,28 @@ public class AsnTimeWindowController : AbpController
[HttpGet("asn-time-window")] [HttpGet("asn-time-window")]
public virtual async Task<List<AsnTimeWindowDashboardDto>> GetAsnTimeWindowsAsync() public virtual async Task<List<AsnTimeWindowDashboardDto>> GetAsnTimeWindowsAsync()
{ {
return await GetAsnTimeWindowDashboardsAsync().ConfigureAwait(false); return await GetAsnTimeWindowDashboardsAsync();
} }
private async Task<List<AsnTimeWindowDashboardDto>> GetAsnTimeWindowDashboardsAsync() private async Task<List<AsnTimeWindowDashboardDto>> GetAsnTimeWindowDashboardsAsync()
{ {
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);
var asnNumbers = supplierAsns.Select(t => t.Number); var asnNumbers = supplierAsns.Select(t => t.Number);
var purchaseReceiptNotes = await GetPurchaseReceiptNotesAsync(asnNumbers).ConfigureAwait(false); var purchaseReceiptNotes = await GetPurchaseReceiptNotesAsync(asnNumbers);
return ConvertToAsnTimeWindowDashboards( return this.ConvertToAsnTimeWindowDashboards(
supplierAsns, supplierAsns,
suppliers, suppliers,
purchaseReceiptNotes); purchaseReceiptNotes);
} }
private static List<AsnTimeWindowDashboardDto> ConvertToAsnTimeWindowDashboards( private List<AsnTimeWindowDashboardDto> ConvertToAsnTimeWindowDashboards(
List<SupplierAsnDTO> supplierAsns, List<SupplierAsnDTO> supplierAsns,
List<SupplierDTO> suppliers, List<SupplierDTO> suppliers,
List<PurchaseReceiptNoteDTO> purchaseReceiptNotes) List<PurchaseReceiptNoteDTO> purchaseReceiptNotes)
@ -70,16 +71,12 @@ public class AsnTimeWindowController : 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;
if (dtos.Exists(t => t.TimeSpan == timeSpan && t.SupplierShortName == supplierShortName)) if (dtos.Exists(t => t.TimeSpan == timeSpan && t.SupplierShortName == supplierShortName))
{
continue; continue;
}
var purchaseReceiptNote = var purchaseReceiptNote =
purchaseReceiptNotes.FirstOrDefault(t => t.AsnNumber == supplierAsn.Number); purchaseReceiptNotes.FirstOrDefault(t => t.AsnNumber == supplierAsn.Number);
@ -111,17 +108,26 @@ public class AsnTimeWindowController : AbpController
endTime.AddDays(-1); endTime.AddDays(-1);
} }
return await _supplierAsnApp.GetByStartTimeEndTimeAsync(startTime, endTime).ConfigureAwait(false); return await this._supplierAsnApp.GetByStartTimeEndTimeAsync(startTime, endTime);
} }
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<PurchaseReceiptNoteDTO>> GetPurchaseReceiptNotesAsync(IEnumerable<string> asnNumbers) private async Task<List<PurchaseReceiptNoteDTO>> GetPurchaseReceiptNotesAsync(IEnumerable<string> asnNumbers)
{ {
return await _purchaseReceiptNoteApp.GetListByAsnNumbers(asnNumbers).ConfigureAwait(false); return await this._purchaseReceiptNoteApp.GetListByAsnNumbers(asnNumbers);
} }
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpGet("get-server-date-time")]
public virtual async Task<string> GetServerDate()
{
return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
} }

199
be/Hosts/Win_in.Sfs.Wms.Dashboard.Host/Controllers/MaterialRequestController.cs

@ -2,151 +2,156 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Win_in.Sfs.Label.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.Linq; using System.Linq;
using NUglify.Helpers;
using Win_in.Sfs.Shared.Domain.Shared; using NUglify.Helpers;
using Win_in.Sfs.Wms.Store.Application.Contracts;
[ApiController] using Win_in.Sfs.Shared.Domain.Shared;
[Route($"{PdaHostConst.ROOT_ROUTE}material-request")] using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using static IdentityServer4.Models.IdentityResources;
public class MaterialRequestController : AbpController [ApiController]
{ [Route($"{PdaHostConst.ROOT_ROUTE}material-request")]
private readonly IMaterialRequestAppService _materialRequestApp;
private readonly IIssueNoteAppService _issueNoteApp; public class MaterialRequestController : AbpController
public MaterialRequestController(IMaterialRequestAppService materialRequestApp, IIssueNoteAppService issueNoteApp)
{ {
_materialRequestApp = materialRequestApp; private readonly IMaterialRequestAppService _materialRequestApp;
_issueNoteApp = issueNoteApp;
}
[HttpGet("un-handled-order-sum")] private readonly IIssueNoteAppService _issueNoteApp;
public virtual async Task<MaterialRequestUnHandledOrderSumDto> GetUnHandledOrderSumAsync() public MaterialRequestController(IMaterialRequestAppService materialRequestApp, IIssueNoteAppService issueNoteApp)
{ {
var dto = new MaterialRequestUnHandledOrderSumDto(); _materialRequestApp = materialRequestApp;
_issueNoteApp = issueNoteApp;
}
var list = await GetMaterialRequestAsync().ConfigureAwait(false); [HttpGet("un-handled-order-sum")]
public virtual async Task<MaterialRequestUnHandledOrderSumDto> GetUnHandledOrderSumAsync()
{
var dto = new MaterialRequestUnHandledOrderSumDto();
dto.Sum = list.Where(t => t.RequestStatus == EnumRequestStatus.New).Count(); var list = await GetMaterialRequestAsync();
return dto; dto.Sum = list.Where(t => t.RequestStatus == EnumRequestStatus.New).Count();
}
[HttpGet("un-issued-item-qty-sum")] return dto;
public virtual async Task<MaterialRequestUnIssuedItemQtySumDto> GetUnIssuedItemQtySumAsync() }
{
var dto = new MaterialRequestUnIssuedItemQtySumDto();
var list = await GetMaterialRequestAsync().ConfigureAwait(false); [HttpGet("un-issued-item-qty-sum")]
public virtual async Task<MaterialRequestUnIssuedItemQtySumDto> GetUnIssuedItemQtySumAsync()
{
var dto = new MaterialRequestUnIssuedItemQtySumDto();
dto.Sum = list.Where(t => t.RequestStatus != EnumRequestStatus.New) var list = await GetMaterialRequestAsync();
.Sum(t => t.Details.Sum(t1 => t1.Qty - t1.IssuedQty));
return dto; dto.Sum = list.Where(t => t.RequestStatus != EnumRequestStatus.New)
} .Sum(t => t.Details.Sum(t1 => t1.Qty - t1.IssuedQty));
[HttpGet("un-received-item-qty-by-item-list")] return dto;
public virtual async Task<List<MaterialRequestUnReceivedItemQtyByItemDto>> }
GetUnIssuedItemQtySumByItemListAsync()
{
var dtos = new List<MaterialRequestUnReceivedItemQtyByItemDto>();
var list = await GetMaterialRequestAsync().ConfigureAwait(false); [HttpGet("un-received-item-qty-by-item-list")]
public virtual async Task<List<MaterialRequestUnReceivedItemQtyByItemDto>>
GetUnIssuedItemQtySumByItemListAsync()
{
var dtos = new List<MaterialRequestUnReceivedItemQtyByItemDto>();
var list = await GetMaterialRequestAsync();
var details = new List<MaterialRequestDetailDTO>(); var details = new List<MaterialRequestDetailDTO>();
list.Where(t => t.RequestStatus != EnumRequestStatus.New).ForEach( list.Where(t => t.RequestStatus != EnumRequestStatus.New).ForEach(
item => item =>
{ {
item.Details.ForEach( item.Details.ForEach(
detail => detail =>
{
if (detail.IssuedQty - detail.ReceivedQty > 0)
{ {
if (detail.IssuedQty - detail.ReceivedQty > 0) details.Add(detail);
{ }
details.Add(detail); });
}
});
}); });
dtos = details.GroupBy(t => t.ItemCode).Select( dtos = details.GroupBy(t => t.ItemCode).Select(
item => new MaterialRequestUnReceivedItemQtyByItemDto() item => new MaterialRequestUnReceivedItemQtyByItemDto()
{ {
ItemCode = item.Key, ItemCode = item.Key,
Sum = item.Sum(t => t.IssuedQty - t.ReceivedQty) Sum = item.Sum(t => t.IssuedQty - t.ReceivedQty)
}).ToList(); }).ToList();
return dtos; return dtos;
} }
[HttpGet("item-qty-by-received-status-list")] [HttpGet("item-qty-by-received-status-list")]
public virtual async Task<List<MaterialRequestItemQtyByReceivedStatusDto>> GetItemQtyByReceivedStatusListAsync() public virtual async Task<List<MaterialRequestItemQtyByReceivedStatusDto>> GetItemQtyByReceivedStatusListAsync()
{ {
var dtos = new List<MaterialRequestItemQtyByReceivedStatusDto>(); var dtos = new List<MaterialRequestItemQtyByReceivedStatusDto>();
var ToBeIssuedQty = 0.0M; var ToBeIssuedQty = 0.0M;
var ToBeReceivedQty = 0.0M; var ToBeReceivedQty = 0.0M;
var Received = 0.0M; var Received = 0.0M;
var list = await GetMaterialRequestAsync().ConfigureAwait(false); var list = await GetMaterialRequestAsync();
list.ForEach( list.ForEach(
item => item =>
{ {
ToBeIssuedQty += item.Details.Sum(t => t.ToBeIssuedQty); ToBeIssuedQty += item.Details.Sum(t => t.ToBeIssuedQty);
ToBeReceivedQty += item.Details.Sum(t => t.ToBeReceivedQty); ToBeReceivedQty += item.Details.Sum(t => t.ToBeReceivedQty);
Received += item.Details.Sum(t => t.ReceivedQty); Received += item.Details.Sum(t => t.ReceivedQty);
}); });
dtos.Add(new MaterialRequestItemQtyByReceivedStatusDto() { ReceivedStatus = "请求未发", Sum = ToBeIssuedQty });
dtos.Add(new MaterialRequestItemQtyByReceivedStatusDto() { ReceivedStatus = "已发未收", Sum = ToBeReceivedQty });
dtos.Add(new MaterialRequestItemQtyByReceivedStatusDto() { ReceivedStatus = "请求已收", Sum = Received });
return dtos;
}
[HttpGet("un-received-item-list")] dtos.Add(new MaterialRequestItemQtyByReceivedStatusDto() { ReceivedStatus = "请求未发", Sum = ToBeIssuedQty });
public virtual async Task<List<MaterialRequestUnReceivedItemDto>> GetUnReceivedItemListAsync() dtos.Add(new MaterialRequestItemQtyByReceivedStatusDto() { ReceivedStatus = "已发未收", Sum = ToBeReceivedQty });
{ dtos.Add(new MaterialRequestItemQtyByReceivedStatusDto() { ReceivedStatus = "请求已收", Sum = Received });
var dtos = new List<MaterialRequestUnReceivedItemDto>();
var notes = await GetIssueNotesAsync().ConfigureAwait(false); return dtos;
}
foreach (var note in notes) [HttpGet("un-received-item-list")]
public virtual async Task<List<MaterialRequestUnReceivedItemDto>> GetUnReceivedItemListAsync()
{ {
foreach (var noteDetail in note.Details) var dtos = new List<MaterialRequestUnReceivedItemDto>();
var notes = await this.GetIssueNotesAsync();
foreach (var note in notes)
{ {
var dto = new MaterialRequestUnReceivedItemDto(); foreach (var noteDetail in note.Details)
{
var dto = new MaterialRequestUnReceivedItemDto();
dto.Number = note.RequestNumber; dto.Number = note.RequestNumber;
dto.ItemCode = noteDetail.ItemCode; dto.ItemCode = noteDetail.ItemCode;
dto.ItemDesc1 = noteDetail.ItemDesc1; dto.ItemDesc1 = noteDetail.ItemDesc1;
dto.PackingCode = noteDetail.FromPackingCode; dto.PackingCode = noteDetail.FromPackingCode;
dto.IssuedQty = noteDetail.Qty; dto.IssuedQty = noteDetail.Qty;
dto.IssuedTime = note.ActiveDate; dto.IssuedTime = note.ActiveDate;
dtos.Add(dto); dtos.Add(dto);
}
} }
}
return dtos; return dtos;
} }
private async Task<List<IssueNoteDTO>> GetIssueNotesAsync() private async Task<List<IssueNoteDTO>> GetIssueNotesAsync()
{ {
return await _issueNoteApp.GetListUnConfirmedByTypeAsync(EnumTransSubType.Issue_WIP.ToString()).ConfigureAwait(false); return await this._issueNoteApp.GetListUnConfirmedByTypeAsync(EnumTransSubType.Issue_WIP.ToString());
} }
private async Task<List<MaterialRequestDTO>> GetMaterialRequestAsync() private async Task<List<MaterialRequestDTO>> GetMaterialRequestAsync()
{ {
return await _materialRequestApp.GetListByTypeAsync(EnumTransSubType.Issue_WIP.ToString()).ConfigureAwait(false); return await this._materialRequestApp.GetListByTypeAsync(EnumTransSubType.Issue_WIP.ToString());
}
} }
} }

262
be/Hosts/Win_in.Sfs.Wms.Dashboard.Host/Controllers/PlanAndActualController.cs

@ -1,174 +1,194 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Serilog;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Wms.Dashboard.Host.Models; using Win_in.Sfs.Wms.Dashboard.Host.Models;
using System;
using System.Linq;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts;
namespace Win_in.Sfs.Wms.Dashboard.Host.Controllers; namespace Win_in.Sfs.Wms.Dashboard.Host.Controllers
[ApiController]
[Route($"{PdaHostConst.ROOT_ROUTE}plan-and-actual")]
public class PlanAndActualController : AbpController
{ {
private readonly ISupplierAsnAppService _supplierAsnApp;
private readonly IPurchaseReceiptNoteAppService _purchaseReceiptNoteApp;
private readonly IPutawayNoteAppService _putawayNoteApp;
private readonly ISupplierAppService _supplierApp;
private readonly IItemSafetyStockAppService _itemSafetyStockApp;
public PlanAndActualController(ISupplierAsnAppService supplierAsnApp, IPurchaseReceiptNoteAppService purchaseReceiptNoteApp, IPutawayNoteAppService putawayNoteApp, ISupplierAppService supplierApp, IItemSafetyStockAppService itemSafetyStockApp) [ApiController]
{ [Route($"{PdaHostConst.ROOT_ROUTE}plan-and-actual")]
_supplierAsnApp = supplierAsnApp;
_purchaseReceiptNoteApp = purchaseReceiptNoteApp;
_putawayNoteApp = putawayNoteApp;
_supplierApp = supplierApp;
_itemSafetyStockApp = itemSafetyStockApp;
}
[HttpGet("plan-actual-list")] public class PlanAndActualController : AbpController
public virtual async Task<List<PlanAndActualDashboardDto>> GetPlanAndActualListAsync()
{ {
return await GetPlanAndActualDashboardsAsync().ConfigureAwait(false); private readonly ISupplierAsnAppService _supplierAsnApp;
} private readonly IPurchaseReceiptNoteAppService _purchaseReceiptNoteApp;
private readonly IPutawayNoteAppService _putawayNoteApp;
private readonly ISupplierAppService _supplierApp;
private readonly IItemSafetyStockAppService _itemSafetyStockApp;
private readonly IPurchaseOrderAppService _purchaseOrderApp;
private readonly IPurchaseReceiptJobAppService _purchaseReceiptJobApp;
public PlanAndActualController(ISupplierAsnAppService supplierAsnApp, IPurchaseReceiptNoteAppService purchaseReceiptNoteApp, IPutawayNoteAppService putawayNoteApp, ISupplierAppService supplierApp, IItemSafetyStockAppService itemSafetyStockApp, IPurchaseOrderAppService purchaseOrderApp, IPurchaseReceiptJobAppService purchaseReceiptJobApp)
{
_supplierAsnApp = supplierAsnApp;
_purchaseReceiptNoteApp = purchaseReceiptNoteApp;
_putawayNoteApp = putawayNoteApp;
_supplierApp = supplierApp;
_itemSafetyStockApp = itemSafetyStockApp;
_purchaseOrderApp = purchaseOrderApp;
_purchaseReceiptJobApp = purchaseReceiptJobApp;
}
private async Task<List<PlanAndActualDashboardDto>> GetPlanAndActualDashboardsAsync()
{
var supplierAsns = await GetSupplierAsnsAsync().ConfigureAwait(false);
var supplierCodes = supplierAsns.Select(t => t.SupplierCode).Distinct(); [HttpGet("plan-actual-list")]
public virtual async Task<List<PlanAndActualDashboardDto>> GetPlanAndActualListAsync()
{
return await GetPlanAndActualDashboardsAsync();
}
var suppliers = await GetSuppliersAsync(supplierCodes).ConfigureAwait(false); private async Task<List<PlanAndActualDashboardDto>> GetPlanAndActualDashboardsAsync()
{
var supplierAsns = await this.GetSupplierAsnsAsync();
var asnNumbers = supplierAsns.Select(t => t.Number); var supplierCodes = supplierAsns.Select(t => t.SupplierCode).Distinct();
var purchaseReceiptNotes = await GetPurchaseReceiptNotesAsync(asnNumbers).ConfigureAwait(false); var suppliers = await GetSuppliersAsync(supplierCodes);
var putawayNotes = await GetPutawayNotesAsync(asnNumbers).ConfigureAwait(false); var asnNumbers = supplierAsns.Select(t => t.Number);
var itemSafetyStorks = await GetItemSafetyStocksAsync(supplierAsns).ConfigureAwait(false); var purchaseReceiptNotes = await GetPurchaseReceiptNotesAsync(asnNumbers);
return ConvertToPlanAndActualDashboards( var putawayNotes = await this.GetPutawayNotesAsync(asnNumbers);
supplierAsns,
suppliers,
purchaseReceiptNotes,
putawayNotes,
itemSafetyStorks);
}
private static List<PlanAndActualDashboardDto> ConvertToPlanAndActualDashboards(List<SupplierAsnDTO> supplierAsns, List<SupplierDTO> suppliers, List<PurchaseReceiptNoteDTO> purchaseReceiptNotes, List<PutawayNoteDTO> putawayNotes, List<ItemSafetyStockDTO> itemSafetyStorks) var itemSafetyStorks = await this.GetItemSafetyStocksAsync(supplierAsns);
{
var dtos = new List<PlanAndActualDashboardDto>(); return await this.ConvertToPlanAndActualDashboards(
supplierAsns,
suppliers,
purchaseReceiptNotes,
putawayNotes,
itemSafetyStorks);
}
foreach (var supplierAsn in supplierAsns) private async Task<List<PlanAndActualDashboardDto>> ConvertToPlanAndActualDashboards(List<SupplierAsnDTO> supplierAsns, List<SupplierDTO> suppliers, List<PurchaseReceiptNoteDTO> purchaseReceiptNotes, List<PutawayNoteDTO> putawayNotes, List<ItemSafetyStockDTO> itemSafetyStorks)
{ {
var purchaseReceipts = purchaseReceiptNotes.FindAll(t => t.AsnNumber == supplierAsn.Number); var dtos = new List<PlanAndActualDashboardDto>();
var putaways = putawayNotes.FindAll(t => t.AsnNumber == supplierAsn.Number);
var supplierShortName = string.Empty; foreach (var supplierAsn in supplierAsns)
{
var purchaseReceipts = purchaseReceiptNotes.FindAll(t => t.AsnNumber == supplierAsn.Number);
var putaways = putawayNotes.FindAll(t => t.AsnNumber == supplierAsn.Number);
var supplier = suppliers.FirstOrDefault(t => t.Code == supplierAsn.SupplierCode); var supplierShortName = string.Empty;
if (supplier == null) var supplier = suppliers.FirstOrDefault(t => t.Code == supplierAsn.SupplierCode);
{
continue;
}
supplierShortName = supplier.ShortName; if (supplier == null)
continue;
foreach (var detail in supplierAsn.Details) supplierShortName = supplier.ShortName;
{
var dto = dtos.FirstOrDefault(t => t.SupplierShortName == supplierShortName && t.ItemCode == detail.ItemCode);
if (dto == null) foreach (var detail in supplierAsn.Details)
{ {
dto = new PlanAndActualDashboardDto(); var dto = dtos.FirstOrDefault(t => t.SupplierShortName == supplierShortName && t.ItemCode == detail.ItemCode);
dto.SupplierShortName = supplierShortName; if (dto == null)
dto.ItemCode = detail.ItemCode; {
dto.ItemDesc1 = detail.ItemDesc1; dto = new PlanAndActualDashboardDto();
dto.ItemName = detail.ItemName;
var itemSafetyStork = itemSafetyStorks.FirstOrDefault(t => t.ItemCode == detail.ItemCode); dto.SupplierShortName = supplierShortName;
dto.ItemCode = detail.ItemCode;
dto.ItemDesc1 = detail.ItemDesc1;
dto.ItemName = detail.ItemName;
if (itemSafetyStork != null) var itemSafetyStork = itemSafetyStorks.FirstOrDefault(t => t.ItemCode == detail.ItemCode);
{
dto.MaxQty = itemSafetyStork.MaxStock;
dto.MinQty = itemSafetyStork.MinStock;
}
dto.ReceiptNoteCount = CountReceiptNoteCount(purchaseReceipts, detail.ItemCode, detail.Lot); if (itemSafetyStork != null)
dto.ReceiptQty = CountReceiptQty(purchaseReceipts, detail.ItemCode, detail.Lot); {
dto.PutawayQty = CountPutawayQty(putawayNotes, detail.ItemCode, detail.Lot); dto.MaxQty = itemSafetyStork.MaxStock;
dto.MinQty = itemSafetyStork.MinStock;
}
dtos.Add(dto); var purchaseOrderDtos = await _purchaseOrderApp.GetListBySupplierCodeAsync(supplierAsn.SupplierCode, detail.ItemCode);
} var supllierAsn = await _supplierAsnApp.GetForTodayListAsync();
var poNumberList = supllierAsn.Select(p => p.PoNumber).ToList();
dto.SupplierAsnCount += 1; purchaseOrderDtos = purchaseOrderDtos.Where(p => poNumberList.Contains(p.Number)).ToList();
dto.PlanArriveQty += detail.Qty;
}
}
return dtos.OrderBy(t => t.SupplierShortName).ToList(); decimal allPutawayQty = 0;
} decimal allReceiptQty = 0;
decimal allPlanArriveQty = 0;
private static decimal CountPutawayQty(List<PutawayNoteDTO> putawayNotes, string itemCode, string lot) foreach (var purchaseOrderDTO in purchaseOrderDtos)
{ {
return putawayNotes.Sum(t => t.Details.Where(t => t.ItemCode == itemCode && t.ToLot == lot).Sum(t => t.Qty)); allPutawayQty += purchaseOrderDTO.Details.Where(p => p.ItemCode == detail.ItemCode).Sum(p => p.PutAwayQty);
} allReceiptQty += purchaseOrderDTO.Details.Where(p => p.ItemCode == detail.ItemCode).Sum(p => p.ReceivedQty);
allPlanArriveQty += purchaseOrderDTO.Details.Where(p => p.ItemCode == detail.ItemCode).Sum(p => p.ShippedQty);
}
private static decimal CountReceiptQty(List<PurchaseReceiptNoteDTO> purchaseReceipts, string itemCode, string lot) dto.PutawayQty = allPutawayQty;
{ dto.PlanArriveQty = allPlanArriveQty;
return purchaseReceipts.Sum(t => t.Details.Where(t => t.ItemCode == itemCode && t.HandledLot == lot).Sum(t => t.Qty)); dto.ReceiptQty = allReceiptQty;
}
private static int CountReceiptNoteCount(List<PurchaseReceiptNoteDTO> purchaseReceipts, string itemCode, string lot) dtos.Add(dto);
{ }
return purchaseReceipts.Sum(t => t.Details.Count(t => t.ItemCode == itemCode && t.Lot == lot));
}
private async Task<List<SupplierAsnDTO>> GetSupplierAsnsAsync() var purchaseReceiptJobDtos = await _purchaseReceiptJobApp.GetListBySupplierCodeOnTodayAsync(supplierAsn.SupplierCode);
{
var startTime = DateTime.Today.AddHours(DashboardConst.AsnReceiptTimeLimitHour); dto.ReceiptNoteCount = purchaseReceiptJobDtos.Count(p => p.JobStatus == EnumJobStatus.Done);
var endTime = startTime.AddDays(1).AddSeconds(-1); dto.SupplierAsnCount = purchaseReceiptJobDtos.Count();
}
}
return dtos.OrderBy(t => t.SupplierShortName).ToList();
}
if (DateTime.Now.Hour < DashboardConst.AsnReceiptTimeLimitHour) private decimal CountReceiptQty(List<PurchaseReceiptNoteDTO> purchaseReceipts, string itemCode)
{ {
startTime.AddDays(-1); return purchaseReceipts.Sum(t => t.Details.Where(t => t.ItemCode == itemCode).Sum(t => t.Qty));
endTime.AddDays(-1);
} }
return await _supplierAsnApp.GetByStartTimeEndTimeAsync(startTime, endTime).ConfigureAwait(false); private int CountReceiptNoteCount(List<PurchaseReceiptNoteDTO> purchaseReceipts, string itemCode)
} {
return purchaseReceipts.Sum(t => t.Details.Count(t => t.ItemCode == itemCode));
}
private async Task<List<SupplierDTO>> GetSuppliersAsync(IEnumerable<string> codes) private async Task<List<SupplierAsnDTO>> GetSupplierAsnsAsync()
{ {
return await _supplierApp.GetByCodesAsync(codes).ConfigureAwait(false); var startTime = DateTime.Today.AddHours(DashboardConst.AsnReceiptTimeLimitHour);
}
private async Task<List<PurchaseReceiptNoteDTO>> GetPurchaseReceiptNotesAsync(IEnumerable<string> asnNumbers) var endTime = startTime.AddDays(1).AddSeconds(-1);
{
return await _purchaseReceiptNoteApp.GetListByAsnNumbers(asnNumbers).ConfigureAwait(false);
}
private async Task<List<PutawayNoteDTO>> GetPutawayNotesAsync(IEnumerable<string> asnNumbers) if (DateTime.Now.Hour < DashboardConst.AsnReceiptTimeLimitHour)
{ {
return await _putawayNoteApp.GetListByAsnNumbers(asnNumbers).ConfigureAwait(false); startTime.AddDays(-1);
} endTime.AddDays(-1);
private async Task<List<ItemSafetyStockDTO>> GetItemSafetyStocksAsync(List<SupplierAsnDTO> supplierAsns) }
{
var itemCodes = new List<string>();
supplierAsns.ForEach(t => { itemCodes.AddRange(t.Details.Select(t => t.ItemCode).ToList()); }); return await this._supplierAsnApp.GetByStartTimeEndTimeAsync(startTime, endTime);
}
var itemSafetyStorks = await _itemSafetyStockApp.GetByItemCodesAsync(itemCodes).ConfigureAwait(false); private async Task<List<SupplierDTO>> GetSuppliersAsync(IEnumerable<string> codes)
return itemSafetyStorks; {
return await this._supplierApp.GetByCodesAsync(codes);
}
private async Task<List<PurchaseReceiptNoteDTO>> GetPurchaseReceiptNotesAsync(IEnumerable<string> asnNumbers)
{
return await this._purchaseReceiptNoteApp.GetListByAsnNumbers(asnNumbers);
}
private async Task<List<PutawayNoteDTO>> GetPutawayNotesAsync(IEnumerable<string> asnNumbers)
{
return await this._putawayNoteApp.GetListByAsnNumbers(asnNumbers);
}
private async Task<List<ItemSafetyStockDTO>> GetItemSafetyStocksAsync(List<SupplierAsnDTO> supplierAsns)
{
var itemCodes = new List<string>();
supplierAsns.ForEach(t => { itemCodes.AddRange(t.Details.Select(t => t.ItemCode).ToList()); });
var itemSafetyStorks = await this._itemSafetyStockApp.GetByItemCodesAsync(itemCodes);
return itemSafetyStorks;
}
} }
} }

352
be/Hosts/Win_in.Sfs.Wms.Dashboard.Host/Controllers/PurchaseReceiptController.cs

@ -5,233 +5,255 @@ 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.Linq; using System;
using System.Linq;
using Win_in.Sfs.Label.Application.Contracts; using Volo.Abp;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Application.Contracts;
[ApiController] using Win_in.Sfs.Label.Application.Contracts;
[Route($"{PdaHostConst.ROOT_ROUTE}purchase-receipt")] using Win_in.Sfs.Label.Domain;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Application.Contracts;
public class PurchaseReceiptController : AbpController [ApiController]
{ [Route($"{PdaHostConst.ROOT_ROUTE}purchase-receipt")]
private readonly IBalanceAppService _balanceApp;
private readonly IInventoryLabelAppService _labelService;
private readonly ISupplierAppService _supplierApp;
private readonly ISupplierAsnAppService _supplierAsnApp;
public PurchaseReceiptController(IBalanceAppService balanceApp, IInventoryLabelAppService labelService, ISupplierAppService supplierApp, ISupplierAsnAppService supplierAsnApp) public class PurchaseReceiptController : AbpController
{ {
this._balanceApp = balanceApp; private readonly IBalanceAppService _balanceApp;
this._labelService = labelService; private readonly IInventoryLabelAppService _labelService;
this._supplierApp = supplierApp; private readonly ISupplierAppService _supplierApp;
this._supplierAsnApp = supplierAsnApp; private readonly ISupplierAsnAppService _supplierAsnApp;
} private readonly IPurchaseReceiptNoteAppService _purchaseReceiptNoteAppService;
private readonly IInspectNoteAppService _inspectNoteAppService;
public PurchaseReceiptController(IBalanceAppService balanceApp, IInventoryLabelAppService labelService, ISupplierAppService supplierApp, ISupplierAsnAppService supplierAsnApp, IPurchaseReceiptNoteAppService purchaseReceiptNoteAppService, IInspectNoteAppService inspectNoteAppService)
{
this._balanceApp = balanceApp;
this._labelService = labelService;
this._supplierApp = supplierApp;
this._supplierAsnApp = supplierAsnApp;
_purchaseReceiptNoteAppService = purchaseReceiptNoteAppService;
_inspectNoteAppService = inspectNoteAppService;
}
[HttpGet("receipt-sum-qty")] /// <summary>
public virtual async Task<PurchaseReceiptSumQtyDashboardDto> GetReceiptSumQtyAsync() /// 未上架数量
{ /// </summary>
var dto = new PurchaseReceiptSumQtyDashboardDto(); /// <returns></returns>
[HttpGet("no-put-away-sum-qty")]
public virtual async Task<PurchaseReceiptSumQtyDashboardDto> GetNoPutAwaySumQtyAsync()
{
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>
var items = await GetPurchaseReceiptItemDashboardAsync().ConfigureAwait(false); /// <returns></returns>
[HttpGet("no-put-away-by-supplier")]
public virtual async Task<List<PurchaseReceiptCountBySupplierDashboardDto>> GetNoPutAwayBySupplierAsync()
{
var items = await GetPurchaseReceiptItemDashboardAsync();
var dtos = items.GroupBy(t => t.SupplierShortName) var dtos = items.GroupBy(t => t.SupplierShortName)
.Select( .Select(
t => new PurchaseReceiptCountBySupplierDashboardDto t => new PurchaseReceiptCountBySupplierDashboardDto
{ {
SupplierShortName = t.Key, SupplierShortName = t.Key,
Qty = t.Sum(t1 => t1.Qty) Qty = t.Sum(t1 => t1.Qty)
}).OrderBy(t => t.SupplierShortName).ToList(); }).OrderBy(t => t.SupplierShortName).ToList();
return dtos; return dtos;
} }
[HttpGet("receipt-item-list")] /// <summary>
public virtual async Task<List<PurchaseReceiptItemDashboardDto>> GetReceiptItemListAsync() /// 未上架明细
{ /// </summary>
return await GetPurchaseReceiptItemDashboardAsync().ConfigureAwait(false); /// <returns></returns>
} [HttpGet("no-put-away-item-list")]
public virtual async Task<List<PurchaseReceiptItemDashboardDto>> GetReceiptItemListAsync()
{
return await GetPurchaseReceiptItemDashboardAsync();
}
[HttpGet("un-receipt-sum-qty")] [HttpGet("un-receipt-sum-qty")]
public virtual async Task<PurchaseReceiptSumQtyDashboardDto> GetUnReceiptSumQtyAsync() public virtual async Task<PurchaseReceiptSumQtyDashboardDto> GetUnReceiptSumQtyAsync()
{ {
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) };
return dto; return dto;
} }
[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(
t => new PurchaseReceiptCountBySupplierDashboardDto t => new PurchaseReceiptCountBySupplierDashboardDto
{ {
SupplierShortName = t.Key, SupplierShortName = t.Key,
Qty = t.Sum(t1 => t1.Qty) Qty = t.Sum(t1 => t1.Qty)
}).OrderBy(t => t.SupplierShortName).ToList(); }).OrderBy(t => t.SupplierShortName).ToList();
return dtos; return dtos;
} }
[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 packingcodes = balances.Select(t => t.PackingCode).Distinct(); //var balances = await GetBalancesAsync("INSPECT", EnumInventoryStatus.OK);
var labels = await GetLabelsAsync(packingcodes).ConfigureAwait(false); var packingcodes = balances.Select(t => t.PackingCode).Distinct();
var supplierCodes = labels.Select(t => t.SupplierCode).Distinct(); var labels = await GetLabelsAsync(packingcodes);
var suppliers = await GetSuppliersAsync(supplierCodes).ConfigureAwait(false); var supplierCodes = labels.Select(t => t.SupplierCode).Distinct();
return ConvertToPurchaseReceiptItemDashboard(balances, labels, suppliers); var suppliers = await GetSuppliersAsync(supplierCodes);
}
private static List<PurchaseReceiptItemDashboardDto> ConvertToPurchaseReceiptItemDashboard( return ConvertToPurchaseReceiptItemDashboard(balances, labels, suppliers);
List<BalanceDTO> balances, }
List<InventoryLabelDto> labels,
List<SupplierDTO> suppliers)
{
var dtos = new List<PurchaseReceiptItemDashboardDto>();
foreach (var balance in balances) private List<PurchaseReceiptItemDashboardDto> ConvertToPurchaseReceiptItemDashboard(
List<BalanceDTO> balances,
List<InventoryLabelDto> labels,
List<SupplierDTO> suppliers)
{ {
var supplierShortName = string.Empty; var dtos = new List<PurchaseReceiptItemDashboardDto>();
var label = labels.FirstOrDefault(t => t.Code == balance.PackingCode); foreach (var balance in balances)
if (label == null)
{ {
continue; var supplierShortName = string.Empty;
}
var supplier = suppliers.FirstOrDefault(t => t != null && t.Code == label.SupplierCode); var label = labels.FirstOrDefault(t => t.Code == balance.PackingCode);
if (supplier == null) if (label == null)
{ continue;
continue;
}
supplierShortName = supplier.ShortName; var supplier = suppliers.FirstOrDefault(t => t != null && t.Code == label.SupplierCode);
var dto = dtos.Find(t => t.SupplierShortName == supplierShortName && t.ItemCode == balance.ItemCode); if (supplier == null)
continue;
if (dto == null) supplierShortName = supplier.ShortName;
{
dto = new PurchaseReceiptItemDashboardDto();
dto.SupplierShortName = supplierShortName; var dto = dtos.Find(t => t.SupplierShortName == supplierShortName && t.ItemCode == balance.ItemCode);
dto.ItemCode = balance.ItemCode;
dto.ItemDesc1 = balance.ItemDesc1;
dto.Qty = 0;
dtos.Add(dto); if (dto == null)
} {
dto = new PurchaseReceiptItemDashboardDto();
dto.Qty += balance.Qty; dto.SupplierShortName = supplierShortName;
} dto.ItemCode = balance.ItemCode;
dto.ItemDesc1 = balance.ItemDesc1;
dto.Qty = 0;
return dtos.OrderBy(t => t.SupplierShortName).ToList(); dtos.Add(dto);
} }
private async Task<List<BalanceDTO>> GetBalancesAsync(string locationCode, EnumInventoryStatus status) dto.Qty += balance.Qty;
{ }
return await _balanceApp.GetListByLocationCodeAndStatusAsync(locationCode, status).ConfigureAwait(false);
}
private async Task<List<InventoryLabelDto>> GetLabelsAsync(IEnumerable<string> codes)
{
return await _labelService.GetByCodesAsync(codes).ConfigureAwait(false);
}
private async Task<List<SupplierDTO>> GetSuppliersAsync(IEnumerable<string> codes)
{
return await _supplierApp.GetByCodesAsync(codes).ConfigureAwait(false);
}
private async Task<List<SupplierAsnDTO>> GetSupplierAsnsAsync() return dtos.OrderBy(t => t.SupplierShortName).ToList();
{ }
return await _supplierAsnApp.GetForTodayUnReceivedListAsync().ConfigureAwait(false);
}
private static List<PurchaseReceiptItemDashboardDto> ConvertToUnPurchaseReceiptItemDashboard( private async Task<List<BalanceDTO>> GetBalancesAsync(string locationCode, EnumInventoryStatus status)
List<SupplierAsnDTO> supplierAsns, {
List<SupplierDTO> suppliers) return await this._balanceApp.GetListByLocationCodeAndStatusAsync(locationCode, status);
{ }
var dtos = new List<PurchaseReceiptItemDashboardDto>(); private async Task<List<InventoryLabelDto>> GetLabelsAsync(IEnumerable<string> codes)
{
return await this._labelService.GetByCodesAsync(codes);
}
private async Task<List<SupplierDTO>> GetSuppliersAsync(IEnumerable<string> codes)
{
return await this._supplierApp.GetByCodesAsync(codes);
}
foreach (var supplierAsn in supplierAsns) private async Task<List<SupplierAsnDTO>> GetSupplierAsnsAsync()
{ {
var supplierShortName = string.Empty; return await this._supplierAsnApp.GetForTodayUnReceivedListAsync();
}
var supplier = suppliers.FirstOrDefault(t => t.Code == supplierAsn.SupplierCode); private List<PurchaseReceiptItemDashboardDto> ConvertToUnPurchaseReceiptItemDashboard(
List<SupplierAsnDTO> supplierAsns,
List<SupplierDTO> suppliers)
{
var dtos = new List<PurchaseReceiptItemDashboardDto>();
if (supplier == null) foreach (var supplierAsn in supplierAsns)
{ {
continue; var supplierShortName = string.Empty;
}
supplierShortName = supplier.ShortName; var supplier = suppliers.FirstOrDefault(t => t.Code == supplierAsn.SupplierCode);
foreach (var detail in supplierAsn.Details) if (supplier == null)
{ continue;
var dto = dtos.Find(t => t.SupplierShortName == supplierShortName && t.ItemCode == detail.ItemCode);
if (dto == null) supplierShortName = supplier.ShortName;
foreach (var detail in supplierAsn.Details)
{ {
dto = new PurchaseReceiptItemDashboardDto(); var dto = dtos.Find(t => t.SupplierShortName == supplierShortName && t.ItemCode == detail.ItemCode);
dto.SupplierShortName = supplierShortName; if (dto == null)
dto.ItemCode = detail.ItemCode; {
dto.ItemDesc1 = detail.ItemDesc1; dto = new PurchaseReceiptItemDashboardDto();
dto.Qty = 0;
dtos.Add(dto); dto.SupplierShortName = supplierShortName;
} dto.ItemCode = detail.ItemCode;
dto.ItemDesc1 = detail.ItemDesc1;
dto.Qty = 0;
dtos.Add(dto);
}
dto.Qty += detail.Qty; dto.Qty += detail.Qty;
}
} }
}
return dtos.OrderBy(t => t.SupplierShortName).ToList(); return dtos.OrderBy(t => t.SupplierShortName).ToList();
} }
private async Task<List<PurchaseReceiptItemDashboardDto>> GetUnPurchaseReceiptItemDashboardAsync() private async Task<List<PurchaseReceiptItemDashboardDto>> GetUnPurchaseReceiptItemDashboardAsync()
{ {
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);
}
} }
} }

5
be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/TransferLogs/TransferLogAppService.cs

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Inventory.Application.Contracts;
@ -23,15 +24,17 @@ public class TransferLogAppService
{ {
private readonly ITransferLogManager _transferLogManager; private readonly ITransferLogManager _transferLogManager;
private readonly IInterfaceCalendarAclService _interfaceCalendarAclService; private readonly IInterfaceCalendarAclService _interfaceCalendarAclService;
private readonly ILocationAppService _locationAppService;
public TransferLogAppService( public TransferLogAppService(
ITransferLogRepository repository ITransferLogRepository repository
, ITransferLogManager transferLogManager , ITransferLogManager transferLogManager
, IInterfaceCalendarAclService interfaceCalendarAclService , IInterfaceCalendarAclService interfaceCalendarAclService
) : base(repository) , ILocationAppService locationAppService) : base(repository)
{ {
_transferLogManager = transferLogManager; _transferLogManager = transferLogManager;
_interfaceCalendarAclService = interfaceCalendarAclService; _interfaceCalendarAclService = interfaceCalendarAclService;
_locationAppService = locationAppService;
} }
[HttpPost("add")] [HttpPost("add")]

6
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/PurchaseReceiptJobs/IPurchaseReceiptJobAppService.cs

@ -48,4 +48,10 @@ public interface IPurchaseReceiptJobAppService
/// <param name="noCache"></param> /// <param name="noCache"></param>
/// <returns></returns> /// <returns></returns>
Task<PurchaseReceiptJobDTO> GetNoCacheAsync(Guid id); Task<PurchaseReceiptJobDTO> GetNoCacheAsync(Guid id);
/// <summary>
/// 根据收货编号获取收货任务
/// </summary>
/// <returns></returns>
Task<List<PurchaseReceiptJobDTO>> GetListBySupplierCodeOnTodayAsync(string supplierCode);
} }

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/InspectNotes/IInspectNoteAppService.cs

@ -21,4 +21,6 @@ public interface IInspectNoteAppService : ISfsStoreMasterReadOnlyAppServiceBase
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task<List<InspectNoteDTO>> CreateSummaryDetailAndDetailByIdAsync(Guid id, InspectNoteEditInput input); Task<List<InspectNoteDTO>> CreateSummaryDetailAndDetailByIdAsync(Guid id, InspectNoteEditInput input);
Task<List<InspectNoteDetailDTO>> GetInspectNoteDetailByToDayTaskAsync();
} }

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Orders/PurchaseOrders/IPurchaseOrderAppService.cs

@ -37,4 +37,6 @@ public interface IPurchaseOrderAppService
/// <param name="inputs"></param> /// <param name="inputs"></param>
/// <returns></returns> /// <returns></returns>
Task<List<PurchaseOrderDTO>> CreateManyAsync(List<PurchaseOrderEditInput> inputs); Task<List<PurchaseOrderDTO>> CreateManyAsync(List<PurchaseOrderEditInput> inputs);
Task<List<PurchaseOrderDTO>> GetListBySupplierCodeAsync(string supplierCode, string itemCode);
} }

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs

@ -34,4 +34,6 @@ public interface ISupplierAsnAppService
Task<string> GenerateSupplierAsnNumberAsync(DateTime activeDate); Task<string> GenerateSupplierAsnNumberAsync(DateTime activeDate);
Task UpdateStatusAsync(string asnNumber, EnumSupplierAsnStatus status); Task UpdateStatusAsync(string asnNumber, EnumSupplierAsnStatus status);
Task<List<SupplierAsnDTO>> GetForTodayListAsync();
} }

15
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAppService.cs

@ -191,6 +191,21 @@ public class PurchaseReceiptJobAppService :
return ObjectMapper.Map<PurchaseReceiptJob, PurchaseReceiptJobDTO>(entity); return ObjectMapper.Map<PurchaseReceiptJob, PurchaseReceiptJobDTO>(entity);
} }
/// <summary>
/// 根据供应商编号获取收货任务
/// </summary>
/// <returns></returns>
[HttpPost("get-by-supplier-code-on-today/{supplierCode}")]
public virtual async Task<List<PurchaseReceiptJobDTO>> GetListBySupplierCodeOnTodayAsync(string supplierCode)
{
var purchaseReceiptJobs = await _repository.GetListAsync(p =>
p.SupplierCode == supplierCode &&
p.PlanArriveDate.Year == DateTime.Now.Year &&
p.PlanArriveDate.Month == DateTime.Now.Month &&
p.PlanArriveDate.Day == DateTime.Now.Day);
var dto = ObjectMapper.Map<List<PurchaseReceiptJob>, List<PurchaseReceiptJobDTO>>(purchaseReceiptJobs);
return dto;
}
#endregion #endregion
/// <summary> /// <summary>

25
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InspectNotes/InspectNoteAppService.cs

@ -87,4 +87,29 @@ public class InspectNoteAppService : SfsStoreWithDetailsAppServiceBase<
return ObjectMapper.Map<List<InspectNote>, List<InspectNoteDTO>>(inspectNotes); return ObjectMapper.Map<List<InspectNote>, List<InspectNoteDTO>>(inspectNotes);
} }
[HttpPost("detail-list/by-to-day")]
public virtual async Task<List<InspectNoteDetailDTO>> GetInspectNoteDetailByToDayTaskAsync()
{
var entitys = await _repository.GetListAsync(
p => p.Details.Any(
y => y.InspectDate.Year == DateTime.Now.Year
&& y.InspectDate.Month == DateTime.Now.Month
&& y.InspectDate.Day == DateTime.Now.Day), true
).ConfigureAwait(false);
List<InspectNoteDetail> list = new List<InspectNoteDetail>();
foreach (var entity in entitys)
{
list.AddRange(entity.Details.Where(y => y.InspectDate.Year == DateTime.Now.Year
&& y.InspectDate.Month == DateTime.Now.Month
&& y.InspectDate.Day == DateTime.Now.Day));
}
var detailDtos = ObjectMapper.Map<List<InspectNoteDetail>, List<InspectNoteDetailDTO>>(list);
return detailDtos;
}
} }

18
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Orders/PurchaseOrders/PurchaseOrderAppService.cs

@ -256,4 +256,22 @@ public class PurchaseOrderAppService :
return dtos; return dtos;
} }
[HttpGet("get-list-by-supplier-code-and-item-code")]
public virtual async Task<List<PurchaseOrderDTO>> GetListBySupplierCodeAsync(string supplierCode, string itemCode)
{
var entitys = await _repository.GetListAsync(p => p.Details.Any(y => y.ItemCode == itemCode) && p.SupplierCode == supplierCode);
List<PurchaseOrder> list = new List<PurchaseOrder>();
foreach (var entity in entitys)
{
var purchaseOrder = await _repository.GetAsync(entity.Id);
list.Add(purchaseOrder);
}
var dtos = ObjectMapper.Map<List<PurchaseOrder>, List<PurchaseOrderDTO>>(list);
return dtos;
}
} }

9
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs

@ -96,6 +96,15 @@ public class SupplierAsnAppService :
await _repository.UpdateAsync(supplierAsn).ConfigureAwait(false); await _repository.UpdateAsync(supplierAsn).ConfigureAwait(false);
} }
[HttpGet("list-for-today")]
public virtual async Task<List<SupplierAsnDTO>> GetForTodayListAsync()
{
var entities = await _repository.GetListAsync(
p => p.PlanArriveDate.Year == DateTime.Now.Year && p.PlanArriveDate.Month == DateTime.Now.Month &&
p.PlanArriveDate.Day == DateTime.Now.Day, true);
return ObjectMapper.Map<List<SupplierAsn>, List<SupplierAsnDTO>>(entities);
}
#endregion #endregion

6
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/InspectNotes/InspectNoteDetail.cs

@ -1,3 +1,4 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain;
@ -161,4 +162,9 @@ public class InspectNoteDetail : SfsStoreDetailWithLotPackingLocationStatusEntit
[Column(TypeName = "decimal(18,6)")] [Column(TypeName = "decimal(18,6)")]
public decimal StdPackQty { get; set; } public decimal StdPackQty { get; set; }
/// <summary>
/// 质检时间
/// </summary>
[Display(Name = "质检时间")]
public DateTime InspectDate { get; set; }
} }

42
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/IssueJobAutoMapperProfile.cs

@ -56,37 +56,37 @@ public partial class StoreEventAutoMapperProfile : Profile
; ;
CreateMap<IssueJobDetail, ExpectOutEditInput>() CreateMap<IssueJobDetail, ExpectOutEditInput>()
.MapExpectInOutFrom() .MapExpectInOutFrom()
.Ignore(x => x.Worker) .Ignore(x => x.Worker)
.Ignore(x => x.SerialNumber) .Ignore(x => x.SerialNumber)
.Ignore(x => x.ExtraProperties); .Ignore(x => x.ExtraProperties);
CreateMap<IssueJob, IssueNoteEditInput>() CreateMap<IssueJob, IssueNoteEditInput>()
.ForMember(x => x.RequestNumber, y => y.MapFrom(d => d.MaterialRequestNumber))
.Ignore(x => x.Confirmed) .Ignore(x => x.Confirmed)
.Ignore(x => x.JobNumber) .Ignore(x => x.JobNumber)
.Ignore(x => x.RequestNumber)
.Ignore(x => x.ActiveDate) .Ignore(x => x.ActiveDate)
; ;
CreateMap<IssueJobDetail, IssueNoteDetailInput>() CreateMap<IssueJobDetail, IssueNoteDetailInput>()
.Ignore(x => x.IssueTime) .ForMember(x => x.Qty, y => y.MapFrom(d => d.HandledQty))
.Ignore(x => x.FromPackingCode) .ForMember(x => x.IssueTime, y => y.MapFrom(d => DateTime.Now))
.Ignore(x => x.ToPackingCode) .ForMember(x => x.FromPackingCode, y => y.MapFrom(d =>d.HandledPackingCode))
.Ignore(x => x.FromContainerCode) .ForMember(x => x.ToPackingCode, y => y.MapFrom(d => d.HandledPackingCode))
.Ignore(x => x.ToContainerCode) .ForMember(x => x.FromContainerCode, y => y.MapFrom(d => d.HandledContainerCode))
.Ignore(x => x.FromLot) .ForMember(x => x.ToContainerCode, y => y.MapFrom(d => d.HandledContainerCode))
.Ignore(x => x.ToLot) .ForMember(x => x.FromLot, y => y.MapFrom(d => d.HandledLot))
.Ignore(x => x.SupplierBatch) .ForMember(x => x.ToLot, y => y.MapFrom(d => d.HandledLot))
.Ignore(x => x.ArriveDate) .ForMember(x => x.SupplierBatch, y => y.MapFrom(d => d.HandledSupplierBatch))
.Ignore(x => x.ProduceDate) .ForMember(x => x.ArriveDate, y => y.MapFrom(d => d.HandledArriveDate))
.Ignore(x => x.ExpireDate) .ForMember(x => x.ProduceDate, y => y.MapFrom(d => d.HandledProduceDate))
.Ignore(x => x.FromLocationCode) .ForMember(x => x.ExpireDate, y => y.MapFrom(d => d.ExpiredTime))
.Ignore(x => x.FromLocationArea) .ForMember(x => x.FromLocationCode, y => y.MapFrom(d => d.HandledFromLocationCode))
.Ignore(x => x.FromLocationGroup) .ForMember(x => x.FromLocationArea, y => y.MapFrom(d => d.HandledFromLocationArea))
.Ignore(x => x.FromLocationErpCode) .ForMember(x => x.FromLocationGroup, y => y.MapFrom(d => d.HandledFromLocationGroup))
.Ignore(x => x.FromWarehouseCode) .ForMember(x => x.FromLocationErpCode, y => y.MapFrom(d => d.HandledFromLocationErpCode))
.Ignore(x => x.FromStatus) .ForMember(x => x.FromWarehouseCode, y => y.MapFrom(d => d.HandledFromWarehouseCode))
.Ignore(x => x.ToStatus) .ForMember(x => x.FromStatus, y => y.MapFrom(d => d.Status))
.Ignore(x => x.Qty) .ForMember(x => x.ToStatus, y => y.MapFrom(d => d.Status))
; ;
} }
} }

1
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/MaterialRequestEventHandler.cs

@ -187,6 +187,7 @@ public class MaterialRequestEventHandler
job.WarehouseCode = fromLocation.WarehouseCode; job.WarehouseCode = fromLocation.WarehouseCode;
job.ProdLine = fromLocation.LocationGroupCode; job.ProdLine = fromLocation.LocationGroupCode;
job.Worker = materialRequest.Worker; job.Worker = materialRequest.Worker;
job.MaterialRequestNumber = materialRequest.Number;
return job; return job;
} }

67
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/IssueNoteEventHandler.cs

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Inventory.Application.Contracts;
@ -20,6 +21,13 @@ public class IssueNoteEventHandler
{ {
private const EnumTransType TransType = EnumTransType.Issue; private const EnumTransType TransType = EnumTransType.Issue;
private readonly ILocationAppService _locationAppService;
public IssueNoteEventHandler(ILocationAppService locationAppService)
{
_locationAppService = locationAppService;
}
[UnitOfWork] [UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData) public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData)
{ {
@ -68,7 +76,7 @@ public class IssueNoteEventHandler
private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList) private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList)
{ {
var transferLogs = new List<TransferLogEditInput>(); var transferLogs = new List<TransferLogEditInput>();
transferLogs.AddRange(inputList); transferLogs.AddRange(inputList);
@ -83,42 +91,48 @@ public class IssueNoteEventHandler
{ {
var transferLog = ObjectMapper.Map<IssueNoteDetail, TransferLogEditInput>(detail); var transferLog = ObjectMapper.Map<IssueNoteDetail, TransferLogEditInput>(detail);
LocationDTO fromLocationDTO = null;
LocationDTO toLocationDTO = null;
if (issueNote.UseOnTheWayLocation) if (issueNote.UseOnTheWayLocation)
{ {
var location = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); var location = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false);
switch (route) switch (route)
{ {
case EnumTransferRoute.SourceToOnTheWay: case EnumTransferRoute.SourceToOnTheWay:
detail.ToLocationCode = detail.OnTheWayLocationCode; fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false);
detail.ToLocationErpCode = location.ErpLocationCode;
detail.ToWarehouseCode = location.WarehouseCode; toLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false);
detail.ToLocationArea = location.AreaCode;
break; break;
case EnumTransferRoute.OnTheWayToDestination: case EnumTransferRoute.OnTheWayToDestination:
detail.FromLocationCode = detail.OnTheWayLocationCode; fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false);
detail.FromLocationErpCode = location.ErpLocationCode;
detail.FromWarehouseCode = location.WarehouseCode; toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false);
detail.FromLocationArea = location.AreaCode;
await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog).ConfigureAwait(false);
break; break;
case EnumTransferRoute.SourceToDestination: case EnumTransferRoute.SourceToDestination:
default: default:
throw new ArgumentOutOfRangeException(nameof(route), route, null); throw new ArgumentOutOfRangeException(nameof(route), route, null);
} }
} }
else
if (issueNote.UseOnTheWayLocation)
{ {
transferLog.FromLocationCode = detail.OnTheWayLocationCode; fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false);
var location = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false);
transferLog.FromLocationGroup = location.LocationGroupCode;
transferLog.FromLocationArea = location.AreaCode;
transferLog.FromLocationErpCode = location.ErpLocationCode;
transferLog.FromWarehouseCode=location.WarehouseCode;
} }
transferLog.TransType = TransType; transferLog.FromLocationCode = fromLocationDTO.Code;
transferLog.FromLocationArea = fromLocationDTO.AreaCode;
transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode;
transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode;
transferLog.ToLocationCode = toLocationDTO.Code;
transferLog.ToLocationArea = toLocationDTO.AreaCode;
transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode;
transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode;
transferLog.TransSubType = Enum.Parse<EnumTransSubType>(issueNote.RequestType); transferLog.TransSubType = Enum.Parse<EnumTransSubType>(issueNote.RequestType);
transferLog.Worker = issueNote.Worker; transferLog.TransType = TransType;
transferLog.DocNumber = issueNote.Number; transferLog.DocNumber = issueNote.Number;
transferLog.JobNumber = issueNote.JobNumber; transferLog.JobNumber = issueNote.JobNumber;
@ -128,4 +142,17 @@ public class IssueNoteEventHandler
return transferLogs; return transferLogs;
} }
private async Task RemovePackingCodeAndContainerCodeAndLotAsync(TransferLogEditInput transferLogCreateInput)
{
transferLogCreateInput.ToPackingCode = "";
transferLogCreateInput.ToLot = "";
transferLogCreateInput.ToContainerCode = "";
transferLogCreateInput.FromPackingCode = "";
transferLogCreateInput.FromLot = "";
transferLogCreateInput.FromContainerCode = "";
}
} }

Loading…
Cancel
Save