Browse Source

Merge branch 'Agv分支2024-11-19' of http://dev.ccwin-in.com:3000/BoXu.Zheng/WZC2 into Agv分支2024-11-19

Agv分支2024-11-19
赵新宇 5 months ago
parent
commit
6960943503
  1. 331
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs

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

@ -7,6 +7,7 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter; using Castle.Components.DictionaryAdapter;
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Office2016.Excel; using DocumentFormat.OpenXml.Office2016.Excel;
using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -897,168 +898,182 @@ public class AssembleIssueJobAppService
[HttpPost("call-back-agv")] [HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request) public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request)
{ {
var json = JsonSerializer.Serialize(request); using var unitOfWork = _unitOfWorkManager.Begin();
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject var ret = new AgvResultObject
{ {
Code = "0", Code = "1",
Message = "OK", Message = "Json转换错误",
ReqCode = job.AssembleRequestNumber, ReqCode = "Json转换错误"
}; };
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var jobs = request.Data;
var numbers = jobs.Select(p => p.OrderNum);
var query = _repository.WithDetails()
.Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done);
var entities = query.ToList();
if (entities.Count == 0)
{
errors.Add($"任务号{string.Join(",", numbers)}不存在!");
}
var dtos = ObjectMapper.Map<List<AssembleIssueJob>, List<AssembleIssueJobDTO>>(entities);
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)
{
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
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任务完成"); // try
} // {
} // var json = JsonSerializer.Serialize(request);
else // var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
{ // _logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
errors.Add("Agv确认单据里无数据! \n"); //#if DEBUG
}
} //#endif
catch (Exception ex)
{ // foreach (var agvRequestDetailDto in request.Data)
ret = new AgvResultObject // {
{ // var job = await _repository.FindAsync(p => p.Number == agvRequestDetailDto.OrderNum).ConfigureAwait(false);
Code = "-1", // if (job == null)
ReqCode = job.AssembleRequestNumber, // {
Message = ex.Message // ret.ReqCode = agvRequestDetailDto.OrderNum;
}; // throw new UserFriendlyException($"未找到{agvRequestDetailDto.OrderNum}单号");
await unitOfWork.RollbackAsync().ConfigureAwait(false); // }
return ret; // if (job.JobStatus != EnumJobStatus.WaitAgv)
} // {
// throw new UserFriendlyException($"{agvRequestDetailDto.OrderNum}单号的任务状态错误");
if (errors.Count > 0) // }
{ // var postionLocationDtoFrom= await _postionLocationAppService.GetByCodeAsync(agvRequestDetailDto.BeginPosition).ConfigureAwait(false);
ret = new AgvResultObject // if (postionLocationDtoFrom == null)
{ // {
Code = "-1", // throw new UserFriendlyException($"{agvRequestDetailDto.BeginPosition}起始点位未找到");
Message = string.Join(",", errors.ToArray()), // }
ReqCode = job.AssembleRequestNumber // 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; return ret;
} }

Loading…
Cancel
Save