|
|
@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Win_in.Sfs.Basedata.Application; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Shared.Domain; |
|
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
@ -30,13 +31,15 @@ public class PurchaseOrderAppService : |
|
|
|
private readonly ISupplierAppService _supplierAppService; |
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
public readonly IPurchasePriceSheetAppService _purchasePriceSheetAppService; |
|
|
|
|
|
|
|
public PurchaseOrderAppService( |
|
|
|
IPurchaseOrderRepository repository, |
|
|
|
IPurchaseOrderManager purchaseOrderManager, |
|
|
|
ISupplierAppService supplierAppService, |
|
|
|
IItemBasicAppService itemBasicAppService |
|
|
|
, ILocationAppService locationAppService) : base(repository) |
|
|
|
, ILocationAppService locationAppService, |
|
|
|
IPurchasePriceSheetAppService purchasePriceSheetAppService) : base(repository) |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
_purchaseOrderManager = purchaseOrderManager; |
|
|
@ -46,6 +49,7 @@ public class PurchaseOrderAppService : |
|
|
|
base.CreatePolicyName = PurchaseOrderPermissions.Create; |
|
|
|
base.UpdatePolicyName = PurchaseOrderPermissions.Update; |
|
|
|
base.DeletePolicyName = PurchaseOrderPermissions.Delete; |
|
|
|
_purchasePriceSheetAppService = purchasePriceSheetAppService; |
|
|
|
} |
|
|
|
|
|
|
|
#region 东阳使用
|
|
|
@ -60,7 +64,6 @@ public class PurchaseOrderAppService : |
|
|
|
{ |
|
|
|
var ImportData = dictionary.Select(p => p.Key); |
|
|
|
|
|
|
|
|
|
|
|
#region 校验ERP库位是否存在
|
|
|
|
var allTempErpLocationCode = ImportData.Select(p => p.Details.Select(p => p.LocationErpCode).ToList()).ToList(); |
|
|
|
var allErpLocationCode = new List<string>(); |
|
|
@ -87,6 +90,7 @@ public class PurchaseOrderAppService : |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var purchaseOrder in ImportData) |
|
|
|
{ |
|
|
|
purchaseOrder.CreatorId = CurrentUser.Id; |
|
|
@ -98,10 +102,18 @@ public class PurchaseOrderAppService : |
|
|
|
purchaseOrder.SupplierName = supplierDto.Name; |
|
|
|
if (purchaseOrder.OrderStatus == EnumOrderStatus.Close) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"不允许导入关闭订单状态的订单"); |
|
|
|
throw new UserFriendlyException($"不允许导入关闭订单状态的订单!"); |
|
|
|
} |
|
|
|
#region 校验行号是否有重复的
|
|
|
|
var polineCount = purchaseOrder.Details.GroupBy(r => r.PoLine).Count(); |
|
|
|
if (polineCount != purchaseOrder.Details.Count) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"同一订单号内行号不允许重复!"); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
foreach (var detail in purchaseOrder.Details) |
|
|
|
{ |
|
|
|
await CheckItemPrice(purchaseOrder.SupplierCode,detail.ItemCode).ConfigureAwait(false); |
|
|
|
detail.LineStatus = EnumOrderStatus.Open; |
|
|
|
var itemBasicDto = itemBasicDtos.First(p => p.Code == detail.ItemCode); |
|
|
|
|
|
|
@ -115,6 +127,8 @@ public class PurchaseOrderAppService : |
|
|
|
return dictionary; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 【创建】采购订单
|
|
|
|
/// </summary>
|
|
|
@ -209,6 +223,18 @@ public class PurchaseOrderAppService : |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 校验采购价格
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckItemPrice(string supplierCode, string itemCode ) |
|
|
|
{ |
|
|
|
var isprice = await _purchasePriceSheetAppService.CheckPurPriceAsync(supplierCode, itemCode).ConfigureAwait(false); |
|
|
|
if (isprice) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"供应商【{supplierCode}】零件名称【{itemCode}】无采购价格无法执行采购上架!"); |
|
|
|
} |
|
|
|
} |
|
|
|
private async Task<List<LocationDTO>> CheckErpLocationCodeAsync(List<string> erpLocationCodes) |
|
|
|
{ |
|
|
|
erpLocationCodes = erpLocationCodes.Distinct().ToList(); |
|
|
|