|
|
@ -5,6 +5,7 @@ using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using NUglify.Helpers; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
@ -75,6 +76,7 @@ public class UnplannedReceiptRequestForDongyangAppService : UnplannedReceiptRequ |
|
|
|
if (flag) |
|
|
|
{ |
|
|
|
var unplannedReceiptRequest = await _repository.FindAsync(p => p.Number == requestNumber).ConfigureAwait(false); |
|
|
|
unplannedReceiptRequest.RequestStatus = EnumRequestStatus.Completed; |
|
|
|
await _repository.UpdateAsync(unplannedReceiptRequest).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -88,6 +90,28 @@ public class UnplannedReceiptRequestForDongyangAppService : UnplannedReceiptRequ |
|
|
|
{ |
|
|
|
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); |
|
|
|
|
|
|
|
var listDetails = new List<UnplannedReceiptRequestDetail>(); |
|
|
|
addList.ForEach(p=> |
|
|
|
{ |
|
|
|
listDetails.AddRange(p.Details); |
|
|
|
}); |
|
|
|
var groupBy=listDetails.GroupBy(p =>new { p.ItemCode, p.FromErpLocationCode }); |
|
|
|
foreach (var keyGroup in groupBy) |
|
|
|
{ |
|
|
|
if (keyGroup.ToList().Count > 1) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"Erp料号【{keyGroup.Key.ItemCode}】和储位【{keyGroup.Key.FromErpLocationCode}】有重复项"); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var detail in keyGroup) |
|
|
|
{ |
|
|
|
if (detail.Qty <= 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"数量必须大于0"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var unplannedReceiptRequest in addList) |
|
|
|
{ |
|
|
|
if (unplannedReceiptRequest.UnplannedReceiptType != EnumUnplannedReceiptType.Wip && unplannedReceiptRequest.UnplannedReceiptType != EnumUnplannedReceiptType.Raw) |
|
|
@ -119,6 +143,7 @@ public class UnplannedReceiptRequestForDongyangAppService : UnplannedReceiptRequ |
|
|
|
{ |
|
|
|
var itemBasic = await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
CheckItemBasic(itemBasic, detail.ItemCode); |
|
|
|
await CheckErpLocationCodeAsync(detail.FromErpLocationCode).ConfigureAwait(false); |
|
|
|
if (itemBasic != null) |
|
|
|
{ |
|
|
|
detail.ItemName = itemBasic.Name; |
|
|
@ -199,6 +224,16 @@ public class UnplannedReceiptRequestForDongyangAppService : UnplannedReceiptRequ |
|
|
|
throw new UserFriendlyException($"库位代码为【{locationCode}】不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task CheckErpLocationCodeAsync(string erpLoationCode) |
|
|
|
{ |
|
|
|
var codes=await _locationAppService.GetListByErpLocationCodes(new List<string>{ erpLoationCode }).ConfigureAwait(false); |
|
|
|
if (!codes.Any()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"储位代码为【{erpLoationCode}】下,无任何库位"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task<BalanceDTO> CheckBalanceAsync(UnplannedReceiptRequestImportInput importInput, List<ValidationResult> validationRresult) |
|
|
|
{ |
|
|
|
var balance = await BalanceAclService.GetByItemLocationAndPackingAsync( |
|
|
|