|
|
@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Caching; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Basedata.Domain; |
|
|
@ -29,8 +30,9 @@ public class ProductionLineItemAppService : |
|
|
|
{ |
|
|
|
private readonly IProductionLineAppService _productionLineAppService ; |
|
|
|
private readonly ILocationAppService _locationAppService ; |
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
public ProductionLineItemAppService( |
|
|
|
IProductionLineItemRepository repository, IDistributedCache<ProductionLineItemDTO> cache, IProductionLineAppService productionLineAppService, ILocationAppService locationAppService |
|
|
|
IProductionLineItemRepository repository, IDistributedCache<ProductionLineItemDTO> cache, IProductionLineAppService productionLineAppService, ILocationAppService locationAppService, IItemBasicAppService itemBasicAppService |
|
|
|
) : base(repository, cache) |
|
|
|
{ |
|
|
|
base.CreatePolicyName = ProductionLineItemPermissions.Create; |
|
|
@ -38,6 +40,7 @@ public class ProductionLineItemAppService : |
|
|
|
base.DeletePolicyName = ProductionLineItemPermissions.Delete; |
|
|
|
_productionLineAppService = productionLineAppService; |
|
|
|
_locationAppService = locationAppService; |
|
|
|
_itemBasicAppService= itemBasicAppService; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("upsert")] |
|
|
@ -73,6 +76,10 @@ public class ProductionLineItemAppService : |
|
|
|
var wiplocationcodelist = list.WipLocationCodeListJson.Split(","); |
|
|
|
list.WipLocationCodeListJson = JsonSerializer.Serialize(wiplocationcodelist); |
|
|
|
} |
|
|
|
var baseItem= await _itemBasicAppService.GetByCodeAsync(list.ItemCode).ConfigureAwait(false); |
|
|
|
list.ItemName = baseItem?.Name; |
|
|
|
list.ItemDesc1 = baseItem?.Desc1; |
|
|
|
list.ItemDesc2 = baseItem?.Desc2; |
|
|
|
} |
|
|
|
return dictionary; |
|
|
|
} |
|
|
@ -82,11 +89,21 @@ public class ProductionLineItemAppService : |
|
|
|
await base.ValidateImportModelAsync(importInput, validationRresult).ConfigureAwait(false); |
|
|
|
await CheckItemBasicItemCodeAsync(importInput.ItemCode, validationRresult).ConfigureAwait(false); |
|
|
|
await CheckProductionLineProdLineCodeAsync(importInput.ProdLineCode, validationRresult).ConfigureAwait(false); |
|
|
|
await CheckSameItem(importInput.ProdLineCode, importInput.ItemCode, validationRresult).ConfigureAwait(false); |
|
|
|
CheckProductionLineProdLineCodeJsonAsync(importInput.RawLocationCodeListJson, validationRresult); |
|
|
|
CheckProductionLineProdLineCodeJsonAsync(importInput.ProductLocationCodeListJson, validationRresult); |
|
|
|
CheckProductionLineProdLineCodeJsonAsync(importInput.WipLocationCodeListJson, validationRresult); |
|
|
|
|
|
|
|
} |
|
|
|
private async Task CheckSameItem(string ProdLineCode,string ItemCode, List<ValidationResult> validationRresult) |
|
|
|
{ |
|
|
|
var item =await _repository.FirstOrDefaultAsync(r=>r.ProdLineCode== ProdLineCode&&r.ItemCode==ItemCode).ConfigureAwait(false); |
|
|
|
if (item!=null) |
|
|
|
{ |
|
|
|
validationRresult.Add(new ValidationResult($"生产线{ProdLineCode}物料号{ItemCode}已存在", new string[] { "生产线", "物料号" })); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
private void CheckProductionLineProdLineCodeJsonAsync(string locationCodeList, List<ValidationResult> validationRresult) |
|
|
|
{ |
|
|
|
if(!string.IsNullOrEmpty(locationCodeList)) |
|
|
|