|
|
@ -676,243 +676,99 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase |
|
|
|
#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 = "", |
|
|
|
}; |
|
|
|
// using var unitOfWork = _unitOfWorkManager.Begin();
|
|
|
|
try |
|
|
|
{ |
|
|
|
if (request.Data.Count > 0) |
|
|
|
{ |
|
|
|
var notes = request.Data; |
|
|
|
var numbers = notes.Select(p => p.OrderNum); |
|
|
|
foreach (var number in numbers) |
|
|
|
|
|
|
|
foreach (var detail in notes) |
|
|
|
{ |
|
|
|
var details= notes.Where(p => p.OrderNum == number).ToList(); |
|
|
|
TransferNoteEditInput transfer= new TransferNoteEditInput(); |
|
|
|
transfer.CallJobNumber = number; |
|
|
|
transfer.Type= EnumTransSubType.Agv_Transfer_WIP.ToString(); |
|
|
|
transfer.Worker = "Agv"; |
|
|
|
transfer.UseOnTheWayLocation = false; |
|
|
|
|
|
|
|
foreach (var detail in details) |
|
|
|
{ |
|
|
|
TransferNoteEditInput transfer = new TransferNoteEditInput(); |
|
|
|
transfer.CallJobNumber = detail.OrderNum; |
|
|
|
transfer.Type = EnumTransSubType.Agv_Transfer_WIP.ToString(); |
|
|
|
transfer.Worker = "Agv"; |
|
|
|
transfer.UseOnTheWayLocation = false; |
|
|
|
|
|
|
|
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>(); |
|
|
|
|
|
|
|
TransferNoteDetailInput detailInput = new TransferNoteDetailInput(); |
|
|
|
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) |
|
|
|
{ |
|
|
|
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>(); |
|
|
|
|
|
|
|
errors.Add($"零件号{detail.MatCode}的零件不存在!"); |
|
|
|
} |
|
|
|
else |
|
|
|
TransferNoteDetailInput detailInput = new TransferNoteDetailInput(); |
|
|
|
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}的零件不存在!"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
detailInput.ItemCode = item.Code; |
|
|
|
detailInput.Uom = item.BasicUom; |
|
|
|
detailInput.ItemName = item.Name; |
|
|
|
} |
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
return ret = new AgvResultObject() |
|
|
|
{ |
|
|
|
detailInput.ItemCode = item.Code; |
|
|
|
detailInput.Uom = item.BasicUom; |
|
|
|
detailInput.ItemName = item.Name; |
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
return ret = new AgvResultObject() |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
ReqCode = "", |
|
|
|
Message = string.Join(",", errors.ToArray()) |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
detailInput.ToLocationCode = tolocation.Code; |
|
|
|
detailInput.ToLocationGroup = tolocation.LocationGroupCode; |
|
|
|
detailInput.ToLocationArea = tolocation.AreaCode; |
|
|
|
detailInput.ToLocationErpCode = tolocation.ErpLocationCode; |
|
|
|
|
|
|
|
detailInput.ToWarehouseCode = tolocation.WarehouseCode; |
|
|
|
detailInput.Qty = detail.MatQty; |
|
|
|
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty; |
|
|
|
detailInput.ToPackingCode = string.Empty; |
|
|
|
|
|
|
|
detailInput.FromWarehouseCode = fromlocation.WarehouseCode; |
|
|
|
detailInput.FromLocationCode = fromlocation.Code; |
|
|
|
detailInput.FromLocationGroup = fromlocation.LocationGroupCode; |
|
|
|
detailInput.FromLocationArea = fromlocation.AreaCode; |
|
|
|
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode; |
|
|
|
detailInput.Qty = detail.MatQty; |
|
|
|
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty; |
|
|
|
detailInput.FromPackingCode = string.Empty; |
|
|
|
|
|
|
|
transfer.Details.Add(detailInput); |
|
|
|
|
|
|
|
Code = "-1", |
|
|
|
ReqCode = "", |
|
|
|
Message = string.Join(",", errors.ToArray()) |
|
|
|
}; |
|
|
|
} |
|
|
|
detailInput.ToLocationCode = tolocation.Code; |
|
|
|
detailInput.ToLocationGroup = tolocation.LocationGroupCode; |
|
|
|
detailInput.ToLocationArea = tolocation.AreaCode; |
|
|
|
detailInput.ToLocationErpCode = tolocation.ErpLocationCode; |
|
|
|
detailInput.ToWarehouseCode = tolocation.WarehouseCode; |
|
|
|
detailInput.Qty = detail.MatQty; |
|
|
|
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty; |
|
|
|
detailInput.ToPackingCode = string.Empty; |
|
|
|
detailInput.FromWarehouseCode = fromlocation.WarehouseCode; |
|
|
|
detailInput.FromLocationCode = fromlocation.Code; |
|
|
|
detailInput.FromLocationGroup = fromlocation.LocationGroupCode; |
|
|
|
detailInput.FromLocationArea = fromlocation.AreaCode; |
|
|
|
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode; |
|
|
|
detailInput.Qty = detail.MatQty; |
|
|
|
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty; |
|
|
|
detailInput.FromPackingCode = string.Empty; |
|
|
|
transfer.Details.Add(detailInput); |
|
|
|
await CreateAsync(transfer).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var query = _repository.WithDetails()
|
|
|
|
// .Where(p => numbers.Contains(p.Number));
|
|
|
|
|
|
|
|
|
|
|
|
//var query = _repository.WithDetails()
|
|
|
|
// .Where(p => numbers.Contains(p.Number) );
|
|
|
|
//var entities = query.ToList();
|
|
|
|
//if (entities.Count == 0)
|
|
|
|
//{
|
|
|
|
// errors.Add($"任务号{string.Join(",", numbers)}不存在!");
|
|
|
|
//}
|
|
|
|
//var dtos = ObjectMapper.Map<List<TransferNote>, List<TransferNoteDTO>>(entities);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//List<TransferNote> notelist = new List<TransferNote>();
|
|
|
|
|
|
|
|
|
|
|
|
//foreach (var itm in dtos)
|
|
|
|
//{
|
|
|
|
// var note = ObjectMapper.Map<TransferNoteDTO, TransferNote>(itm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// itm.Type = EnumTransSubType.Agv_Transfer_WIP.ToString();
|
|
|
|
// var arys = jobs.Where(p => p.OrderNum == itm.Number);
|
|
|
|
// var itmDetails = itm.Details.ToList();
|
|
|
|
// var details = new List<TransferNoteDetailDTO>();
|
|
|
|
// 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 TransferNoteDetailDTO();
|
|
|
|
// dto.InjectFrom(entity);
|
|
|
|
// dto.ToLocationCode = toloc.Code;
|
|
|
|
// dto.ToLocationGroup = tolocation.LocationGroupCode;
|
|
|
|
// dto.ToLocationArea = tolocation.AreaCode;
|
|
|
|
// dto.ToLocationErpCode = tolocation.ErpLocationCode;
|
|
|
|
|
|
|
|
// dto.ToWarehouseCode = tolocation.WarehouseCode;
|
|
|
|
// dto.Qty = detail.MatQty;
|
|
|
|
// dto.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
|
|
|
|
// dto.ToPackingCode = string.Empty;
|
|
|
|
|
|
|
|
// dto.FromWarehouseCode = fromlocation.WarehouseCode;
|
|
|
|
// dto.FromLocationCode = fromlocation.Code;
|
|
|
|
// dto.FromLocationGroup = fromlocation.LocationGroupCode;
|
|
|
|
// dto.FromLocationArea = fromlocation.AreaCode;
|
|
|
|
// dto.FromLocationErpCode = fromlocation.ErpLocationCode;
|
|
|
|
// dto.Qty = detail.MatQty;
|
|
|
|
// dto.FromLot = string.Empty;
|
|
|
|
// dto.FromPackingCode = string.Empty;
|
|
|
|
// details.Add(dto);
|
|
|
|
|
|
|
|
// //var details=
|
|
|
|
|
|
|
|
|
|
|
|
// //note.Details.Add()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //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"); |
|
|
@ -920,13 +776,11 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
ReqCode ="", |
|
|
|
Message = ex.Message |
|
|
|
ReqCode = "", |
|
|
|
Message = ex.Message |
|
|
|
}; |
|
|
|
//await unitOfWork.RollbackAsync();
|
|
|
|
return ret; |
|
|
@ -959,7 +813,7 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase |
|
|
|
request.MatCode = first.ItemCode; |
|
|
|
request.MatQty = first.Qty; |
|
|
|
request.OrderNum = job.Number; |
|
|
|
request.OrderType = EnumJobType.AssembleIssueJob.ToString(); |
|
|
|
request.OrderType =EnumTransSubType.Agv_Transfer_WIP.ToString(); |
|
|
|
|
|
|
|
var httpclient = _httpClientFactory.CreateClient(); |
|
|
|
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) |
|
|
@ -975,13 +829,12 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase |
|
|
|
? "zozocnApi/custom/receiveProductionPlan" |
|
|
|
: _agvOptions.Value.Path; //测试密码
|
|
|
|
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); |
|
|
|
// _logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}");
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_agvOptions.Value.Token)) |
|
|
|
{ |
|
|
|
var token = _agvOptions.Value.Token; |
|
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_agvOptions.Value.UserName) && !string.IsNullOrEmpty(_agvOptions.Value.Password)) |
|
|
|
{ |
|
|
|
var username = _agvOptions.Value.UserName; |
|
|
@ -989,10 +842,8 @@ public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase |
|
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", |
|
|
|
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); |
|
|
|
} |
|
|
|
|
|
|
|
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path); |
|
|
|
ret = await client.PushOutTask4FWAsync(request).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|