|
|
@ -19,10 +19,12 @@ using Win_in.Sfs.Shared.Domain; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Win_in.Sfs.Shared.Application.Contracts; |
|
|
|
using Volo.Abp; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
namespace Win_in.Sfs.Basedata.Application; |
|
|
|
|
|
|
|
[Authorize] |
|
|
|
[AllowAnonymous] |
|
|
|
[Route($"{BasedataConsts.RootPath}PostionLocation")] |
|
|
|
|
|
|
|
public class PostionLocationAppService |
|
|
@ -87,6 +89,40 @@ public class PostionLocationAppService |
|
|
|
return pageResult; |
|
|
|
} |
|
|
|
|
|
|
|
protected override async Task ValidateImportModelAsync(PostionLocationImportInput importInput, |
|
|
|
List<ValidationResult> validationRresult) |
|
|
|
{ |
|
|
|
await base.ValidateImportModelAsync(importInput, validationRresult).ConfigureAwait(false); |
|
|
|
await CheckLocationCodeAsync(importInput.LocationCode, validationRresult).ConfigureAwait(false); |
|
|
|
await CheckSameItem(importInput.Code,importInput.LocationCode,validationRresult).ConfigureAwait(false); |
|
|
|
//CheckProductionLineProdLineCodeJsonAsync(importInput.RawLocationCodeListJson, validationRresult);
|
|
|
|
//CheckProductionLineProdLineCodeJsonAsync(importInput.ProductLocationCodeListJson, validationRresult);
|
|
|
|
//CheckProductionLineProdLineCodeJsonAsync(importInput.WipLocationCodeListJson, validationRresult);
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private async Task CheckLocationCodeAsync(string locationCode, List<ValidationResult> validationRresult) |
|
|
|
{ |
|
|
|
var list = await _locationAppService.GetByCodeAsync(locationCode).ConfigureAwait(false); |
|
|
|
if (list == null) |
|
|
|
{ |
|
|
|
validationRresult.Add(new ValidationResult($"{locationCode}库位编码不存在,请查看库位信息!")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task CheckSameItem(string code, string locationCode, List<ValidationResult> validationRresult) |
|
|
|
{ |
|
|
|
var item = await _repository.FirstOrDefaultAsync(r => r.Code == code && r.LocationCode == locationCode).ConfigureAwait(false); |
|
|
|
if (item != null) |
|
|
|
{ |
|
|
|
validationRresult.Add(new ValidationResult($"工作站编码{code}库位编码{locationCode}已存在", new string[] { "工作站编码", "库位编码" })); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost("get-or-add")] |
|
|
|
public virtual async Task<PostionLocationDTO> GetOrAddAsync(PostionLocationEditInput input) |
|
|
|
{ |
|
|
@ -94,6 +130,7 @@ public class PostionLocationAppService |
|
|
|
var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false); |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
|
|
|
|
var entity = ObjectMapper.Map<PostionLocationEditInput, PostionLocation>(input); |
|
|
|
result = await _repository.InsertAsync(entity, true).ConfigureAwait(false); |
|
|
|
} |
|
|
|