|
|
@ -16,7 +16,7 @@ public class CoatingMaterialRequestManager |
|
|
|
, ICoatingMaterialRequestManager |
|
|
|
{ |
|
|
|
private readonly ICoatingMaterialRequestRepository _repository; |
|
|
|
private readonly ICoatingIssueJobRepository _issueJobRepository; |
|
|
|
|
|
|
|
|
|
|
|
public CoatingMaterialRequestManager( |
|
|
|
ICoatingMaterialRequestRepository repository |
|
|
@ -24,7 +24,7 @@ public class CoatingMaterialRequestManager |
|
|
|
) : base(repository) |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
_issueJobRepository = issueJobRepository; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -44,75 +44,7 @@ public class CoatingMaterialRequestManager |
|
|
|
await _repository.InsertAsync(entity).ConfigureAwait(false); |
|
|
|
return entity; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task UpdateDetailsAsync(CoatingMaterialRequest newEntity) |
|
|
|
{ |
|
|
|
var oldEntity = await Repository.FindAsync(newEntity.Id, true).ConfigureAwait(false); |
|
|
|
if (oldEntity != null) |
|
|
|
{ |
|
|
|
foreach (var newDetail in newEntity.Details) |
|
|
|
{ |
|
|
|
oldEntity.ReplaceDetail(newDetail.Id, newDetail); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var detail in oldEntity.Details) |
|
|
|
{ |
|
|
|
SetMaterialRequestDetailStatus(detail); |
|
|
|
} |
|
|
|
|
|
|
|
await SetMaterialRequestStatus(oldEntity).ConfigureAwait(false); |
|
|
|
|
|
|
|
await Repository.UpdateAsync(oldEntity).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void SetMaterialRequestDetailStatus(CoatingMaterialRequestDetail detail) |
|
|
|
{ |
|
|
|
if (detail.ReceivedQty >= detail.Qty)//执行的时候 实际收料 多余 要料数
|
|
|
|
{ |
|
|
|
detail.Status = EnumStatus.Close; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
detail.Status = EnumStatus.Open; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task SetMaterialRequestStatus(CoatingMaterialRequest materialRequest) |
|
|
|
{ |
|
|
|
if (materialRequest.Details.All(p => p.Status == EnumStatus.Close)) |
|
|
|
{ |
|
|
|
materialRequest.RequestStatus = EnumRequestStatus.Completed; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var issueJobs = await _issueJobRepository.GetListAsync(t => t.MaterialRequestNumber == materialRequest.Number).ConfigureAwait(false); |
|
|
|
if (issueJobs.Count > 0) |
|
|
|
{ |
|
|
|
if (issueJobs.All(t => t.JobStatus is EnumJobStatus.Done or EnumJobStatus.Closed or EnumJobStatus.Cancelled)) |
|
|
|
{ |
|
|
|
if (materialRequest.Details.All(p => p.ReceivedQty >= p.Qty)) |
|
|
|
{ |
|
|
|
materialRequest.RequestStatus = EnumRequestStatus.Completed; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
materialRequest.RequestStatus = EnumRequestStatus.Partial; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
materialRequest.RequestStatus = EnumRequestStatus.Partial; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
materialRequest.RequestStatus = EnumRequestStatus.Partial; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task CompleteAsync(string number) |
|
|
|
{ |
|
|
|
var entity = await GetByNumberAsync(number).ConfigureAwait(false); |
|
|
@ -121,90 +53,7 @@ public class CoatingMaterialRequestManager |
|
|
|
await CompleteAsync(entity).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region 公有
|
|
|
|
|
|
|
|
/* |
|
|
|
// /// <summary>
|
|
|
|
// /// 处理
|
|
|
|
// /// </summary>
|
|
|
|
// /// <returns></returns>
|
|
|
|
// public virtual async Task<bool> Handle(Guid id)
|
|
|
|
// {
|
|
|
|
// var entity =await Repository.GetAsync(id);
|
|
|
|
// if (entity == null)
|
|
|
|
// {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// entity.Handle();
|
|
|
|
// await Repository.UpdateAsync(entity);
|
|
|
|
//
|
|
|
|
// await HandledPublishAsync(entity);
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// private async Task HandledPublishAsync(MaterialRequest entity)
|
|
|
|
// {
|
|
|
|
// //发布,以生成发料任务
|
|
|
|
// var eto = BuildMaterialRequestHandledETO(entity);
|
|
|
|
// await DistributedEventBus.PublishAsync(eto);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// /// <summary>
|
|
|
|
// /// 关闭
|
|
|
|
// /// </summary>
|
|
|
|
// /// <returns></returns>
|
|
|
|
// public virtual async Task<bool> Close(Guid id)
|
|
|
|
// {
|
|
|
|
// var entity = await Repository.GetAsync(id);
|
|
|
|
// if (entity == null)
|
|
|
|
// {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// entity.Close();
|
|
|
|
// await Repository.UpdateAsync(entity);
|
|
|
|
//
|
|
|
|
// //发布,以关闭发料任务
|
|
|
|
// var eto = BuildMaterialRequestClosedETO(entity);
|
|
|
|
// await DistributedEventBus.PublishAsync(eto);
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// /// <summary>
|
|
|
|
// /// 打开
|
|
|
|
// /// </summary>
|
|
|
|
// /// <returns></returns>
|
|
|
|
// public virtual async Task<bool> Open(Guid id)
|
|
|
|
// {
|
|
|
|
// var entity = await Repository.GetAsync(id);
|
|
|
|
// if (entity == null)
|
|
|
|
// {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// entity.Open();
|
|
|
|
//
|
|
|
|
// await Repository.UpdateAsync(entity);
|
|
|
|
//
|
|
|
|
// //发布,以打开发料任务
|
|
|
|
// var eto = BuildMaterialRequestOpenedETO(entity);
|
|
|
|
// await DistributedEventBus.PublishAsync(eto);
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
|
|
|
|
public virtual async Task<MaterialRequest> CreateAndHandleAsync(MaterialRequest entity) |
|
|
|
{ |
|
|
|
|
|
|
|
await base.CreateAsync(entity); |
|
|
|
|
|
|
|
await base.HandleAsync(entity.Id); |
|
|
|
|
|
|
|
return entity; |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Import
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -221,89 +70,6 @@ public class CoatingMaterialRequestManager |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
/* |
|
|
|
#region 私有
|
|
|
|
|
|
|
|
private MaterialRequestOpenedETO BuildMaterialRequestOpenedETO(MaterialRequest materialRequest) |
|
|
|
{ |
|
|
|
var materialRequestETO = new MaterialRequestOpenedETO() |
|
|
|
{ |
|
|
|
Number = materialRequest.Number, |
|
|
|
Workshop = materialRequest.Workshop, |
|
|
|
Status = materialRequest.Status, |
|
|
|
Details = BuildMaterialRequestDetailETO(materialRequest.Details) |
|
|
|
}; |
|
|
|
return materialRequestETO; |
|
|
|
} |
|
|
|
|
|
|
|
private MaterialRequestClosedETO BuildMaterialRequestClosedETO(MaterialRequest materialRequest) |
|
|
|
{ |
|
|
|
var materialRequestETO = new MaterialRequestClosedETO() |
|
|
|
{ |
|
|
|
Company = materialRequest.Company, |
|
|
|
Number = materialRequest.Number |
|
|
|
}; |
|
|
|
return materialRequestETO; |
|
|
|
} |
|
|
|
|
|
|
|
private MaterialRequestHandledETO BuildMaterialRequestHandledETO(MaterialRequest materialRequest) |
|
|
|
{ |
|
|
|
var materialRequestETO = new MaterialRequestHandledETO() |
|
|
|
{ |
|
|
|
Company = materialRequest.Company, |
|
|
|
Number = materialRequest.Number, |
|
|
|
Workshop = materialRequest.Workshop, |
|
|
|
Status = materialRequest.Status, |
|
|
|
Details = BuildMaterialRequestDetailETO(materialRequest.Details) |
|
|
|
}; |
|
|
|
return materialRequestETO; |
|
|
|
} |
|
|
|
|
|
|
|
private List<MaterialRequestDetailETO> BuildMaterialRequestDetailETO(List<MaterialRequestDetail> materialRequestDetail) |
|
|
|
{ |
|
|
|
var list = new List<MaterialRequestDetailETO>(); |
|
|
|
foreach (var detail in materialRequestDetail) |
|
|
|
{ |
|
|
|
var materialRequestDetailETO = new MaterialRequestDetailETO() |
|
|
|
{ |
|
|
|
Number = detail.Number, |
|
|
|
Item = detail.Item, |
|
|
|
ItemCode = detail.ItemCode, |
|
|
|
Qty = detail.Qty, |
|
|
|
ToLocationCode = detail.ToLocationCode, |
|
|
|
ProdLine = detail.ProdLine, |
|
|
|
WorkStation = detail.WorkStation, |
|
|
|
ExpiredTime = detail.ExpiredTime, |
|
|
|
Status = detail.Status |
|
|
|
}; |
|
|
|
list.Add(materialRequestDetailETO); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
///// 为了解决补料时 无法拿到订阅错误信息
|
|
|
|
///// </summary>
|
|
|
|
///// <param name="entity"></param>
|
|
|
|
///// <param name="flag"></param>
|
|
|
|
///// <returns></returns>
|
|
|
|
//public virtual async Task<MaterialRequest> CreateAndHandleAsync(MaterialRequest entity, bool flag)
|
|
|
|
//{
|
|
|
|
// await entity.Handle();
|
|
|
|
// foreach (var detail in entity.Details)
|
|
|
|
// {
|
|
|
|
// detail.Status = EnumStoreStatus.Handle;
|
|
|
|
// }
|
|
|
|
// await base.CreateAsync(entity);
|
|
|
|
|
|
|
|
// //发布,以打开发料任务??
|
|
|
|
// //var eto = BuildMaterialRequestHandledETO(entity);
|
|
|
|
// //await DistributedEventBus.PublishAsync(eto);
|
|
|
|
|
|
|
|
// return entity;
|
|
|
|
//}
|
|
|
|