|
|
@ -477,128 +477,6 @@ public class UnplannedIssueJobAppService |
|
|
|
var job = await _repository.GetAsync(id).ConfigureAwait(false); |
|
|
|
|
|
|
|
var isHasAgvFlag = false; |
|
|
|
|
|
|
|
//var details = ObjectMapper.Map<List<UnplannedReceiptJobDetailDTO>, List<UnplannedReceiptJobDetail>>(detailDtos);
|
|
|
|
//var job = await _repository.FindAsync(p => p.Number == jobNumber).ConfigureAwait(false);
|
|
|
|
//var isHasAgvFlag = false;
|
|
|
|
|
|
|
|
//if (job == null)
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException($"{jobNumber}【任务】不存在");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//if (job.JobStatus != EnumJobStatus.Doing)
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException($"{jobNumber}【任务】不是【执行】状态");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//if (detailDtos.Count(p => p.ItemCode != job.ItemCode) > 0)
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException("请确认ERP料号是否正确");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//if (detailDtos.Sum(p => p.HandledQty) > job.Qty)
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException("实际数量大于申请数量");
|
|
|
|
//}
|
|
|
|
|
|
|
|
//foreach (var detail in details)
|
|
|
|
//{
|
|
|
|
// var locationDto = await _locationAppService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false);
|
|
|
|
// var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false);
|
|
|
|
|
|
|
|
// detail.HandledToLocationArea = locationDto.AreaCode;
|
|
|
|
// detail.HandledToLocationErpCode = locationDto.ErpLocationCode;
|
|
|
|
// detail.HandledToLocationGroup = locationDto.LocationGroupCode;
|
|
|
|
// detail.HandledToLocationCode = locationDto.Code;
|
|
|
|
// detail.Status = EnumInventoryStatus.OK;
|
|
|
|
// detail.HandledArriveDate = DateTime.Now;
|
|
|
|
// detail.HandledProduceDate = DateTime.Now;
|
|
|
|
// detail.Uom = itemBasicDto.BasicUom;
|
|
|
|
// detail.ItemName = itemBasicDto.Name;
|
|
|
|
// detail.ItemDesc1 = itemBasicDto.Desc1;
|
|
|
|
// detail.ItemDesc2 = itemBasicDto.Desc2;
|
|
|
|
// detail.StdPackQty = itemBasicDto.StdPackQty;
|
|
|
|
// #region 过期时间
|
|
|
|
|
|
|
|
// if (itemBasicDto.ValidityUnit == EnumValidityUnit.Day)
|
|
|
|
// {
|
|
|
|
// detail.HandledExpireDate = detail.HandledArriveDate.AddDays(itemBasicDto.Validity);
|
|
|
|
// }
|
|
|
|
// else if (itemBasicDto.ValidityUnit == EnumValidityUnit.WeeK)
|
|
|
|
// {
|
|
|
|
// detail.HandledExpireDate = detail.HandledArriveDate.AddDays(itemBasicDto.Validity * 7);
|
|
|
|
// }
|
|
|
|
// else if (itemBasicDto.ValidityUnit == EnumValidityUnit.Month)
|
|
|
|
// {
|
|
|
|
// detail.HandledExpireDate = detail.HandledArriveDate.AddDays(itemBasicDto.Validity * 30);
|
|
|
|
// }
|
|
|
|
// else if (itemBasicDto.ValidityUnit == EnumValidityUnit.Infinite)
|
|
|
|
// {
|
|
|
|
// detail.HandledExpireDate = DateTime.MaxValue;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
// if (locationDto.ErpLocationCode != job.FromErpLocationCode)
|
|
|
|
// {
|
|
|
|
// throw new UserFriendlyException($"库位【{locationDto.ErpLocationCode}】不在【{job.FromErpLocationCode}】储位下");
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (locationDto.Type == EnumLocationType.DimensionalStorehouse)
|
|
|
|
// {
|
|
|
|
// throw new UserFriendlyException("立库功能暂未开放");
|
|
|
|
// }
|
|
|
|
|
|
|
|
// var dto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(detail.HandledToLocationCode, detail.HandledToLocationCode).ConfigureAwait(false);
|
|
|
|
// if (dto != null)
|
|
|
|
// {
|
|
|
|
// await CallAgvAsync(job, detail).ConfigureAwait(false);
|
|
|
|
// isHasAgvFlag = true;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
//job.Details = details;
|
|
|
|
//job.CompleteUserName = worker;
|
|
|
|
//job.JobStatus = EnumJobStatus.Done;
|
|
|
|
//job.CompleteTime = DateTime.Now;
|
|
|
|
//job.Worker = worker;
|
|
|
|
|
|
|
|
//if (isHasAgvFlag)
|
|
|
|
//{
|
|
|
|
// job.JobStatus = EnumJobStatus.WaitAgv;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//job = await _repository.UpdateAsync(job).ConfigureAwait(false);
|
|
|
|
|
|
|
|
//if (!isHasAgvFlag)//没有AGV就执行
|
|
|
|
//{
|
|
|
|
// await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData<UnplannedReceiptJob>(job), false)
|
|
|
|
// .ConfigureAwait(false);
|
|
|
|
// await UpdateRequestStatusAsync(job.UnplannedReceiptRequestNumber).ConfigureAwait(false);
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dto.Details.Count > 0) |
|
|
|
{ |
|
|
@ -801,8 +679,13 @@ public class UnplannedIssueJobAppService |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
handleDto = ObjectMapper.Map<UnplannedIssueJob, UnplannedIssueJobDTO>(job); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//};
|
|
|
|
|
|
|
|
|
|
|
@ -850,20 +733,28 @@ public class UnplannedIssueJobAppService |
|
|
|
[HttpPost("call-back-agv")] |
|
|
|
public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestUnplannedDto request) |
|
|
|
{ |
|
|
|
|
|
|
|
if (request.Data.Count == 0) |
|
|
|
{ |
|
|
|
return ReturnMessage("-1", "请求明细Data数量不能为0"); |
|
|
|
} |
|
|
|
var agvRequest = request.Data.First(); |
|
|
|
|
|
|
|
var job = await _repository.FindAsync(p => p.Number == agvRequest.OrderNum).ConfigureAwait(false); |
|
|
|
if (job == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("未找到该任务"); |
|
|
|
return ReturnMessage("-1", $"{agvRequest.OrderNum}未找到该任务"); |
|
|
|
} |
|
|
|
|
|
|
|
if (job.JobStatus != EnumJobStatus.WaitAgv) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("该任务状态不是等待AGV中"); |
|
|
|
return ReturnMessage("-1", "该任务状态不是等待AGV中"); |
|
|
|
} |
|
|
|
var toLocationDto = await _locationAppService.GetByCodeAsync(agvRequest.EndPosition ).ConfigureAwait(false);//agvRequest.BeginPosition调试时确认
|
|
|
|
if (toLocationDto == null) |
|
|
|
{ |
|
|
|
return ReturnMessage("-1", $"{agvRequest.EndPosition}库位没查到!"); |
|
|
|
} |
|
|
|
|
|
|
|
var toLocationDto = await _locationAppService.GetByCodeAsync(agvRequest.EndPosition).ConfigureAwait(false); |
|
|
|
|
|
|
|
var detail = job.Details.First(); |
|
|
|
detail.HandledQty = agvRequest.MatQty; |
|
|
@ -873,37 +764,34 @@ public class UnplannedIssueJobAppService |
|
|
|
detail.HandledFromLocationGroup = toLocationDto.LocationGroupCode; |
|
|
|
detail.HandledFromLocationArea = toLocationDto.AreaCode; |
|
|
|
detail.HandledFromLocationErpCode = toLocationDto.ErpLocationCode; |
|
|
|
|
|
|
|
job.JobStatus= EnumJobStatus.Done; |
|
|
|
job = await _repository.UpdateAsync(job).ConfigureAwait(false); |
|
|
|
await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData<UnplannedIssueJob>(job), false) |
|
|
|
.ConfigureAwait(false); |
|
|
|
await UpdateRequestStatusAsync(job.UnplannedIssueRequestNumber).ConfigureAwait(false);//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
|
|
|
|
|
|
|
|
return ReturnMessage("0", "OK"); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 返回信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="Code">0成功其他失败</param>
|
|
|
|
/// <param name="Message">OK成功其他错误信息</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private AgvResultObject ReturnMessage(string code, string message) |
|
|
|
{ |
|
|
|
return new AgvResultObject() |
|
|
|
{ |
|
|
|
Code = "", |
|
|
|
Message = "", |
|
|
|
Code = code, |
|
|
|
Message = message, |
|
|
|
ReqCode = "" |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
///// Agv 回库 接口
|
|
|
|
///// </summary>
|
|
|
|
///// <param name="request"></param>
|
|
|
|
///// <returns></returns>
|
|
|
|
//[HttpPost("call-return-back-agv")]
|
|
|
|
//public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto request)
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调用Agv接口实现
|
|
|
@ -915,12 +803,19 @@ public class UnplannedIssueJobAppService |
|
|
|
#if DEBUG
|
|
|
|
return new AgvResultObject(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "0", |
|
|
|
ReqCode = job.UnplannedIssueRequestNumber, |
|
|
|
Message = "OK" |
|
|
|
}; |
|
|
|
|
|
|
|
return ret;//暂时无接口直接返回
|
|
|
|
|
|
|
|
using var unitOfWork = _unitOfWorkManager.Begin(); |
|
|
|
try |
|
|
|
{ |
|
|
|