|
|
@ -63,20 +63,16 @@ IItemBasicAppService itemBasicAppService) |
|
|
|
request.Remark = "成品发运手动导入"; |
|
|
|
request.ActiveDate = DateTime.Now; |
|
|
|
await SetRequestAutoPropertiesAsync(request).ConfigureAwait(false); |
|
|
|
var detailGroupCount= request.Details.GroupBy(r => new { r.AreaCode, r.MesDeliveryNo, r.MesDeliveryPlan }).Count(); |
|
|
|
var detailGroupCount= request.Details.GroupBy(r => new { r.AreaCode,r.MesDeliveryPlan }).Count(); |
|
|
|
if (detailGroupCount != 1) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"同一发货类型、发货时间、客户的发货区域、Mes发货单号、Mes发货计划号必须相同!"); |
|
|
|
throw new UserFriendlyException($"同一发货类型、发货时间、客户的发货区域、Mes发货计划号必须相同!"); |
|
|
|
} |
|
|
|
if (request.Details.Count != request.Details.Select(r => r.ItemCode).Distinct().Count()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"同一发货类型、发货时间、客户的存在相同零件号!"); |
|
|
|
} |
|
|
|
if(request.DeliverRequestType== EnumDeliverRequestType.FIS) |
|
|
|
{ |
|
|
|
request.DeliverPlanNumber = request.Details.First().MesDeliveryNo; |
|
|
|
} |
|
|
|
else if (request.DeliverRequestType == EnumDeliverRequestType.Normal) |
|
|
|
if(request.DeliverRequestType== EnumDeliverRequestType.FIS|| request.DeliverRequestType == EnumDeliverRequestType.Normal) |
|
|
|
{ |
|
|
|
request.DeliverPlanNumber = request.Details.First().MesDeliveryPlan; |
|
|
|
} |
|
|
@ -126,13 +122,13 @@ IItemBasicAppService itemBasicAppService) |
|
|
|
{ |
|
|
|
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货必须填写底盘号", new string[] { "底盘号" })); |
|
|
|
} |
|
|
|
if (string.IsNullOrEmpty(model.MesDeliveryNo)) |
|
|
|
if (string.IsNullOrEmpty(model.MesDeliveryContainer)) |
|
|
|
{ |
|
|
|
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货必须填写MES发货单号", new string[] { "MES发货单号" })); |
|
|
|
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货必须填写Mes器具号", new string[] { "Mes器具号" })); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(model.MesDeliveryPlan)) |
|
|
|
if (string.IsNullOrEmpty(model.MesDeliveryPlan)) |
|
|
|
{ |
|
|
|
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货MES发货计划单号应该为空", new string[] { "MES发货计划单号" })); |
|
|
|
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为看板发货必须填写MES发货计划单号", new string[] { "MES发货计划单号" })); |
|
|
|
} |
|
|
|
} |
|
|
|
if (model.DeliverRequestType == EnumDeliverRequestType.Normal ) |
|
|
@ -141,9 +137,9 @@ IItemBasicAppService itemBasicAppService) |
|
|
|
{ |
|
|
|
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为看板发货必须填写MES发货计划单号", new string[] { "MES发货计划单号" })); |
|
|
|
} |
|
|
|
if(!string.IsNullOrEmpty(model.IdentityNo)|| !string.IsNullOrEmpty(model.MesDeliveryNo)) |
|
|
|
if(!string.IsNullOrEmpty(model.IdentityNo)) |
|
|
|
{ |
|
|
|
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为看板发货底盘号和MES发货单号应该为空", new string[] { "底盘号" , "MES发货单号" })); |
|
|
|
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为看板发货底盘号应该为空", new string[] { "底盘号"})); |
|
|
|
} |
|
|
|
} |
|
|
|
var area = await _areaApp.GetByCodeAsync(model.AreaCode).ConfigureAwait(false); |
|
|
@ -165,16 +161,26 @@ IItemBasicAppService itemBasicAppService) |
|
|
|
/// 处理请求
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
/// <param name="truckNumber"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
[HttpPost("handle-list")] |
|
|
|
|
|
|
|
public virtual async Task<List<DeliverRequestDTO>> HandleListAsync(List<Guid> ids) |
|
|
|
public virtual async Task<List<DeliverRequestDTO>> HandleListAsync(List<Guid> ids,string truckNumber) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(truckNumber)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"车牌号不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
var entitys = await _repository.GetListAsync(r=> ids.Contains(r.Id),true).ConfigureAwait(false); |
|
|
|
//if (entitys.Select(r => r.CustomerCode).Distinct().Count()>1)
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException($"所选申请涉及多个客户不能创建为一个发货单,请重新选择!");
|
|
|
|
//}
|
|
|
|
if (entitys.Select(r => r.CustomerCode).Distinct().Count() > 1) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"所选申请涉及多个客户不能创建为一个发货单,请重新选择!"); |
|
|
|
} |
|
|
|
//一车发运车牌号相同
|
|
|
|
entitys.ForEach(r => { r.MesTruckNumber = truckNumber; }); |
|
|
|
|
|
|
|
Check.NotNull(entitys, typeof(DeliverRequest).Name); |
|
|
|
var result = await _deliverRequestManager.HandleListAsync(entitys).ConfigureAwait(false); |
|
|
|
var dtos = ObjectMapper.Map<List<DeliverRequest>, List<DeliverRequestDTO>>(entitys); |
|
|
|