|
|
@ -7,6 +7,7 @@ using System.Text; |
|
|
|
using System.Text.Json; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Castle.Components.DictionaryAdapter; |
|
|
|
using DocumentFormat.OpenXml.Office2016.Excel; |
|
|
|
using DocumentFormat.OpenXml.Spreadsheet; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
@ -845,15 +846,200 @@ public class AssembleIssueJobAppService |
|
|
|
/// <param name="uid"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("call-agv")] |
|
|
|
public async Task<ReusltObject> CallAgvAsync(List<AssembleIssueJobDTO> input) |
|
|
|
public async Task<ReusltObject> CallAgvAsync(List<AssembleIssueJobDTO> inputs) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
|
|
|
|
var res = new ReusltObject(); |
|
|
|
List<string> errors = new List<string>(); |
|
|
|
List<string> successList= new List<string>(); |
|
|
|
foreach (var itm in inputs) |
|
|
|
{ |
|
|
|
var jobres= await PushOutTaskAsync(itm).ConfigureAwait(false); |
|
|
|
if (jobres.Code != "0") |
|
|
|
{ |
|
|
|
_logger.LogInformation(jobres.Message); |
|
|
|
errors.Add(jobres.Message); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
successList.Add(jobres.Message); |
|
|
|
} |
|
|
|
} |
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
res.Code = -1; |
|
|
|
res.Message = string.Join(",", errors); |
|
|
|
res.Data=""; |
|
|
|
return res; |
|
|
|
} |
|
|
|
return res; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("call-back-agv")] |
|
|
|
public virtual async Task<ReusltObject> CallBackAgvAsync(IssueRequestFromRestoDTO input) |
|
|
|
public async Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
var json = JsonSerializer.Serialize(request); |
|
|
|
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 |
|
|
|
{ |
|
|
|
Code = "0", |
|
|
|
Message = "OK", |
|
|
|
ReqCode = job.AssembleRequestNumber, |
|
|
|
}; |
|
|
|
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 entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode); |
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
errors.Add($"物料号{detail.MatCode}不在任务明细内!"); |
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
return ret = new AgvResultObject() |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
ReqCode = "", |
|
|
|
Message = string.Join(",", errors.ToArray()) |
|
|
|
}; |
|
|
|
} |
|
|
|
var dto = new AssembleIssueJobDetailDTO(); |
|
|
|
dto.InjectFrom(entity); |
|
|
|
dto.HandledToLocationCode = toloc.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 : string.Empty; |
|
|
|
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.Empty; |
|
|
|
dto.HandledFromPackingCode = string.Empty; |
|
|
|
details.Add(dto); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
|
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
ret = new AgvResultObject() |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
ReqCode = "", |
|
|
|
Message = string.Join(",", errors.ToArray()) |
|
|
|
}; |
|
|
|
} |
|
|
|
itm.Worker = "AGV"; |
|
|
|
itm.Details = details; |
|
|
|
|
|
|
|
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
errors.Add("Agv确认单据里无数据! \n"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
ReqCode = job.AssembleRequestNumber, |
|
|
|
Message = ex.Message, |
|
|
|
}; |
|
|
|
await unitOfWork.RollbackAsync(); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
Message = string.Join(",", errors.ToArray()), |
|
|
|
ReqCode = job.AssembleRequestNumber |
|
|
|
}; |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
@ -985,8 +1171,8 @@ public class AssembleIssueJobAppService |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost("PushOutTask")] |
|
|
|
public async Task<AgvResultObject> PushOutTaskAsync(AssembleIssueJobDTO job) |
|
|
|
|
|
|
|
private async Task<AgvResultObject> PushOutTaskAsync(AssembleIssueJobDTO job) |
|
|
|
{ |
|
|
|
var ret = new AgvResultObject |
|
|
|
{ |
|
|
@ -1002,7 +1188,7 @@ public class AssembleIssueJobAppService |
|
|
|
request.MatCode = first.ItemCode; |
|
|
|
request.MatQty = first.HandledToQty; |
|
|
|
request.OrderNum = job.Number; |
|
|
|
request.OrderType = "2"; |
|
|
|
request.OrderType = "1001"; |
|
|
|
|
|
|
|
var httpclient = _httpClientFactory.CreateClient(); |
|
|
|
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) |
|
|
@ -1049,163 +1235,6 @@ public class AssembleIssueJobAppService |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("accountOutOrder")] |
|
|
|
public async Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request) |
|
|
|
{ |
|
|
|
var json = JsonSerializer.Serialize(request); |
|
|
|
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 |
|
|
|
{ |
|
|
|
Code = "0", |
|
|
|
Message = "OK", |
|
|
|
ReqCode = job.AssembleRequestNumber, |
|
|
|
|
|
|
|
}; |
|
|
|
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.Code).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.Code).ConfigureAwait(false); |
|
|
|
} |
|
|
|
if (tolocation == null) |
|
|
|
{ |
|
|
|
errors.Add($"结束点{detail.EndPosition}库位没查到"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode); |
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
errors.Add($"物料号{detail.MatCode}不在任务明细内!"); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = new AssembleIssueJobDetailDTO(); |
|
|
|
dto.InjectFrom(entity); |
|
|
|
dto.HandledToLocationCode = toloc.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: string.Empty; |
|
|
|
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.Empty; |
|
|
|
dto.HandledFromPackingCode = string.Empty; |
|
|
|
details.Add(dto); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
|
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
ret = new AgvResultObject() |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
ReqCode="", |
|
|
|
Message = string.Join(",", errors.ToArray()) |
|
|
|
}; |
|
|
|
} |
|
|
|
itm.Worker = "AGV"; |
|
|
|
itm.Details = details; |
|
|
|
|
|
|
|
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
errors.Add("Agv确认单据里无数据! \n"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
ReqCode=job.AssembleRequestNumber, |
|
|
|
Message = ex.Message, |
|
|
|
}; |
|
|
|
await unitOfWork.RollbackAsync(); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
Message = string.Join(",", errors.ToArray()), |
|
|
|
ReqCode=job.AssembleRequestNumber |
|
|
|
}; |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|