Browse Source

修改叫料

Agv分支2024-11-19
郑勃旭 5 months ago
parent
commit
b9cc983db6
  1. 264
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs

264
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs

@ -293,7 +293,6 @@ public class AssembleIssueJobAppService
/// 执行任务明细
/// </summary>
/// <returns></returns>
private async Task ExecuteDetailExtAsync(Guid masterId, Guid detailId, AssembleIssueJobDetailDTO issueJobDetailDto)
{
var assembleIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false);
@ -502,10 +501,23 @@ public class AssembleIssueJobAppService
jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch;
jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode;
job=await _repository.UpdateAsync(job).ConfigureAwait(false);
var jobDto=ObjectMapper.Map<AssembleIssueJob, AssembleIssueJobDTO>(job);
await DoingAgvAsync(jobDto, jobDetail.TransferLibToLocationCode,jobDetail.RecommendToLocationCode).ConfigureAwait(false);
var isDoingAgv=await DoingAgvAsync(jobDto, jobDetail.TransferLibToLocationCode,jobDetail.RecommendToLocationCode).ConfigureAwait(false);
if (isDoingAgv)
{
job.JobStatus = EnumJobStatus.WaitAgv;
job.IsClaims = true;
job.ClaimsUserId = string.IsNullOrEmpty(_options.Value.StereosUser)
? "AGV"
: _options.Value.StereosUser;
job.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword)
? "AGV"
: _options.Value.StereosPassword;
}
job = await _repository.UpdateAsync(job).ConfigureAwait(false);
}
#endregion
@ -818,7 +830,7 @@ public class AssembleIssueJobAppService
/// <param name="fromLocationCode"></param>
/// <param name="toLocationCode"></param>
/// <returns></returns>
private async Task DoingAgvAsync(AssembleIssueJobDTO assembleIssueJobDto,string fromLocationCode,string toLocationCode)
private async Task<bool> DoingAgvAsync(AssembleIssueJobDTO assembleIssueJobDto,string fromLocationCode,string toLocationCode)
{
var jobDetailInputdetail = assembleIssueJobDto.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
@ -832,7 +844,7 @@ public class AssembleIssueJobAppService
#if DEBUG
return;
return true;
#endif
@ -841,6 +853,8 @@ public class AssembleIssueJobAppService
throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}");
}
}
return false;
}
/// <summary>
@ -906,183 +920,73 @@ public class AssembleIssueJobAppService
[HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request)
{
using var unitOfWork = _unitOfWorkManager.Begin();
var ret = new AgvResultObject
var entity=await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
var dto=ObjectMapper.Map<AssembleIssueJob, AssembleIssueJobDTO>(entity);
foreach (var detail in entity.Details)
{
Code = "1",
Message = "Json转换错误",
ReqCode = "Json转换错误"
};
var detailDto = new AssembleIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{
//库移的最终目标 挪到 推荐的目标
var fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false);
var toloc =await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
detailDto.InjectFrom(detail);
detailDto.HandledToLocationCode = toloc.Code;
detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
detailDto.HandledToLocationArea = toloc.AreaCode;
detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
detailDto.HandledToQty = request.Data.First().MatQty;
detailDto.HandledToLot = detail.TransferLibToLot;
detailDto.HandledToPackingCode = detail.TransferLibToPackingCode;
detailDto.HandledFromLocationCode = fromloc.Code;
detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
detailDto.HandledFromLocationArea = fromloc.AreaCode;
detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
detailDto.HandledFromLot = detail.TransferLibToLot;
detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode;
}
else
{
var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
detailDto.InjectFrom(detail);
detailDto.HandledToLocationCode = toloc.Code;
detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
detailDto.HandledToLocationArea = toloc.AreaCode;
detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
detailDto.HandledToQty = request.Data.First().MatQty;
detailDto.HandledToLot = detail.RecommendToLot;
detailDto.HandledToPackingCode = detail.RecommendToPackingCode;
detailDto.HandledFromLocationCode = fromloc.Code;
detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
detailDto.HandledFromLocationArea = fromloc.AreaCode;
detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
detailDto.HandledFromLot = detail.RecommendToLot;
detailDto.HandledFromPackingCode = detail.RecommendToPackingCode;
}
// try
// {
// var json = JsonSerializer.Serialize(request);
// var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
// _logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
//#if DEBUG
//#endif
// foreach (var agvRequestDetailDto in request.Data)
// {
// var job = await _repository.FindAsync(p => p.Number == agvRequestDetailDto.OrderNum).ConfigureAwait(false);
// if (job == null)
// {
// ret.ReqCode = agvRequestDetailDto.OrderNum;
// throw new UserFriendlyException($"未找到{agvRequestDetailDto.OrderNum}单号");
// }
// if (job.JobStatus != EnumJobStatus.WaitAgv)
// {
// throw new UserFriendlyException($"{agvRequestDetailDto.OrderNum}单号的任务状态错误");
// }
// var postionLocationDtoFrom= await _postionLocationAppService.GetByCodeAsync(agvRequestDetailDto.BeginPosition).ConfigureAwait(false);
// if (postionLocationDtoFrom == null)
// {
// throw new UserFriendlyException($"{agvRequestDetailDto.BeginPosition}起始点位未找到");
// }
// var postionLocationDtoEnd=await _postionLocationAppService.GetByCodeAsync(agvRequestDetailDto.EndPosition).ConfigureAwait(false);
// if (postionLocationDtoEnd==null)
// {
// throw new UserFriendlyException($"{agvRequestDetailDto.EndPosition}目标点位未找到");
// }
// }
// var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
// jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false);
// if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
// {
// }
// foreach (var itm in dtos)
// {
// var arys = jobs.Where(p => p.OrderNum == itm.Number);
// var itmDetails = itm.Details.ToList();
// var details = new List<AssembleIssueJobDetailDTO>();
// foreach (var detail in arys)
// {
// if (fromloc == null)
// {
// errors.Add($"来源起始点{detail.BeginPosition}没查到");
// }
// LocationDTO fromlocation = null;
// if (fromloc != null)
// {
// fromlocation = await _locationAppService.GetByCodeAsync(fromloc.LocationCode).ConfigureAwait(false);
// }
// if (fromlocation == null)
// {
// errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
// }
// var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
// .ConfigureAwait(false);
// if (toloc == null)
// {
// errors.Add($"结束点{detail.EndPosition}库位没查到");
// }
// LocationDTO tolocation = null;
// if (toloc != null)
// {
// tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false);
// }
// if (tolocation == null)
// {
// errors.Add($"结束点{detail.EndPosition}库位没查到");
// }
// var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
// if (item == null)
// {
// errors.Add($"零件号{detail.MatCode}不存在!");
// }
// var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
// if (entity == null)
// {
// errors.Add($"零件号{detail.MatCode}不在任务明细内!");
// }
// if (errors.Count > 0)
// {
// await unitOfWork.RollbackAsync().ConfigureAwait(false);
// return ret = new AgvResultObject()
// {
// Code = "-1",
// ReqCode = "",
// Message = string.Join(",", errors.ToArray())
// };
// }
// var dto = new AssembleIssueJobDetailDTO();
// dto.InjectFrom(entity);
// dto.HandledToLocationCode = tolocation.Code;
// dto.HandledToLocationGroup = tolocation.LocationGroupCode;
// dto.HandledToLocationArea = tolocation.AreaCode;
// dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
// dto.HandledToWarehouseCode = tolocation.WarehouseCode;
// dto.HandledToQty = detail.MatQty;
// dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : entity.RecommendFromLot;
// dto.HandledToPackingCode = string.Empty;
// dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
// dto.HandledFromLocationCode = fromlocation.Code;
// dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
// dto.HandledFromLocationArea = fromlocation.AreaCode;
// dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
// dto.HandledFromQty = detail.MatQty;
// dto.HandledFromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : entity.RecommendToLot;
// dto.HandledFromPackingCode = string.Empty;
// details.Add(dto);
// await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
// }
// if (errors.Count > 0)
// {
// await unitOfWork.RollbackAsync().ConfigureAwait(false);
// ret = new AgvResultObject()
// {
// Code = "-1",
// ReqCode = "",
// Message = string.Join(",", errors.ToArray())
// };
// }
// itm.Worker = "AGV";
// itm.Details = details;
// _logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
// }
// }
// catch (Exception ex)
// {
// await unitOfWork.RollbackAsync().ConfigureAwait(false);
// return ret;
// }
// if (errors.Count > 0)
// {
// ret = new AgvResultObject
// {
// Code = "-1",
// Message = string.Join(",", errors.ToArray()),
// ReqCode = first.OrderNum
// };
// }
return ret;
await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
}
return new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
}
/// <summary>

Loading…
Cancel
Save