|
|
@ -1,15 +1,18 @@ |
|
|
|
using System; |
|
|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using NUglify.Helpers; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Caching; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Basedata.Domain; |
|
|
|
using Win_in.Sfs.Basedata.Domain.Shared; |
|
|
|
using Win_in.Sfs.Basedata.Kittings.Inputs; |
|
|
|
using Win_in.Sfs.Shared; |
|
|
|
|
|
|
|
|
|
|
@ -21,6 +24,8 @@ namespace Win_in.Sfs.Basedata.Application; |
|
|
|
public class KittingAppService : SfsBaseDataWithCodeAppServiceBase<Kitting, KittingDTO, SfsBaseDataRequestInputBase, KittingEditInput, KittingImportInput>, IKittingAppService |
|
|
|
{ |
|
|
|
private new readonly IKittingRepository _repository; |
|
|
|
|
|
|
|
|
|
|
|
private readonly IKittingManager _manager; |
|
|
|
|
|
|
|
public KittingAppService(IKittingRepository repository, IDistributedCache<KittingDTO> cache, IKittingManager manager) : base(repository,cache) |
|
|
@ -35,18 +40,54 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase<Kitting, Kitt |
|
|
|
[Route("")] |
|
|
|
public override async Task<KittingDTO> CreateAsync(KittingEditInput input) |
|
|
|
{ |
|
|
|
var entity = ObjectMapper.Map<KittingEditInput, Kitting>(input); |
|
|
|
|
|
|
|
entity.SetId(Guid.NewGuid()); |
|
|
|
|
|
|
|
entity.Details.ForEach(item => |
|
|
|
|
|
|
|
var detailquery=await _repository.WithDetailsAsync().ConfigureAwait(false); |
|
|
|
var first = detailquery.FirstOrDefault(p => p.Code == input.Code); |
|
|
|
var codes = input.Details.Select(p => p.PartCode); |
|
|
|
if (first != null) |
|
|
|
{ |
|
|
|
item.MasterId = entity.Id; |
|
|
|
}); |
|
|
|
|
|
|
|
entity = await _repository.InsertAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
return ObjectMapper.Map<Kitting, KittingDTO>(entity); |
|
|
|
throw new UserFriendlyException($"已存在编码:{input.Code}的Kitting箱"); |
|
|
|
|
|
|
|
|
|
|
|
// var query = from itm in input.Details
|
|
|
|
// join itm1 in first.Details on itm.PartCode equals itm1.PartCode
|
|
|
|
// into temp1
|
|
|
|
// from tm1 in temp1.DefaultIfEmpty()
|
|
|
|
// where tm1==null
|
|
|
|
// select itm;
|
|
|
|
//var details=ObjectMapper.Map<List<KittingDetailInput>,List<KittingDetail>>(query.ToList());
|
|
|
|
//foreach (var itm in details)
|
|
|
|
//{
|
|
|
|
// itm.MasterId = first.Id;
|
|
|
|
// first.Details.Add(itm);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//var entity = await _repository.UpdateAsync(first, true).ConfigureAwait(false);
|
|
|
|
// return ObjectMapper.Map<Kitting, KittingDTO>(first);
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var entity = ObjectMapper.Map<KittingEditInput, Kitting>(input); |
|
|
|
entity.SetId(Guid.NewGuid()); |
|
|
|
entity.Details.ForEach(item => |
|
|
|
{ |
|
|
|
item.MasterId = entity.Id; |
|
|
|
}); |
|
|
|
entity = await _repository.InsertAsync(entity).ConfigureAwait(false); |
|
|
|
return ObjectMapper.Map<Kitting, KittingDTO>(entity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//first.Details.Where(p => codes.Contains(p.PartCode));
|
|
|
|
//var entity = ObjectMapper.Map<KittingEditInput, Kitting>(input);
|
|
|
|
//entity.SetId(Guid.NewGuid());
|
|
|
|
//entity.Details.ForEach(item =>
|
|
|
|
//{
|
|
|
|
// item.MasterId = entity.Id;
|
|
|
|
//});
|
|
|
|
//entity = await _repository.InsertAsync(entity).ConfigureAwait(false);
|
|
|
|
//return ObjectMapper.Map<Kitting, KittingDTO>(entity);
|
|
|
|
} |
|
|
|
|
|
|
|
[HttpPut] |
|
|
|