|
|
@ -47,24 +47,25 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase<Kitting, Kitt |
|
|
|
if (first != null) |
|
|
|
{ |
|
|
|
|
|
|
|
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);
|
|
|
|
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.SetId(GuidGenerator.Create());
|
|
|
|
// itm.MasterId = first.Id;
|
|
|
|
// first.AddDetails(itm);
|
|
|
|
//}
|
|
|
|
//var entity= await _repository.UpdateAsync(first).ConfigureAwait(false);
|
|
|
|
|
|
|
|
//return ObjectMapper.Map<Kitting, KittingDTO>(entity);
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -92,8 +93,30 @@ public class KittingAppService : SfsBaseDataWithCodeAppServiceBase<Kitting, Kitt |
|
|
|
|
|
|
|
[HttpPut] |
|
|
|
[Route("{id}")] |
|
|
|
public override Task<KittingDTO> UpdateAsync(Guid id, KittingEditInput input) |
|
|
|
public override Task<KittingDTO> UpdateAsync(Guid id, KittingEditInput input) |
|
|
|
{ |
|
|
|
var detailquery = _repository.WithDetails(); |
|
|
|
var first = detailquery.FirstOrDefault(p => p.Id == id); |
|
|
|
if (first.Code == input.Code) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"已存在编码:{input.Code}的Kitting箱"); |
|
|
|
} |
|
|
|
|
|
|
|
var query = from itm in input.Details |
|
|
|
join itm1 in first.Details on itm.PartCode equals itm1.PartCode |
|
|
|
select itm; |
|
|
|
List<string> errors = new List<string>(); |
|
|
|
foreach (var itm in query.ToList()) |
|
|
|
{ |
|
|
|
errors.Add(itm.PartCode); |
|
|
|
} |
|
|
|
if(errors.Count > 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"零件号${string.Join(",", errors)}已存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return base.UpdateAsync(id, input); |
|
|
|
} |
|
|
|
|
|
|
|