Browse Source

删除agv,拆箱业务

交付给东阳的源代码
郑勃旭 1 month ago
parent
commit
ad6c0668e0
  1. 249
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs
  2. 378
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs
  3. 367
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs
  4. 379
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs
  5. 365
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs
  6. 165
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs
  7. 147
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs
  8. 91
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs
  9. 171
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs

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

@ -7,22 +7,15 @@ using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter;
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Office2016.Excel;
using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MyNamespace;
using Omu.ValueInjecter;
using Org.BouncyCastle.Asn1.Ocsp;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Uow;
using Volo.Abp.Users;
using Win_in.Sfs.Basedata.Application;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Shared.Domain.Shared.Enums.Store;
@ -78,11 +71,8 @@ public class AssembleIssueJobAppService
, IOptions<AgvOptions> agvOptions
, IPostionLocationAppService postionLocationAppService, ILocationDeliveryAppService locationDeliveryAppService
, ITransferNoteAppService transferNoteAppService
) : base(
repository, assembleIssueJobManager
)
{
_postionLocationAppService = postionLocationAppService;
@ -118,7 +108,8 @@ public class AssembleIssueJobAppService
{
await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false);
//如果是立库 就给直接承接了
var dimensionalStorehouseflag = await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false);
var dimensionalStorehouseflag =
await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false);
if (dimensionalStorehouseflag)
{
input.IsClaims = true;
@ -152,7 +143,8 @@ public class AssembleIssueJobAppService
{
await DoingDimensionalStorehouseAsync(assembleIssueJobDto).ConfigureAwait(false);
var firstDetail = assembleIssueJobDto.Details.First();
await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false);
await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode,
firstDetail.RecommendToLocationCode).ConfigureAwait(false);
}
return assembleIssueJobDtos;
@ -162,7 +154,8 @@ public class AssembleIssueJobAppService
public override async Task<AssembleIssueJobDTO> CreateAsync(AssembleIssueJobEditInput input)
{
await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false);
var flagDimensionalStorehouse= await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false);
var flagDimensionalStorehouse =
await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false);
if (flagDimensionalStorehouse == false)
{
await UpdateJobStatusWaitByAgvAsync(input).ConfigureAwait(false);
@ -173,7 +166,8 @@ public class AssembleIssueJobAppService
if (flagDimensionalStorehouse == false)
{
var firstDetail = assembleIssueJobDto.Details.First();
await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false);
await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode,
firstDetail.RecommendToLocationCode).ConfigureAwait(false);
}
return assembleIssueJobDto;
@ -429,11 +423,13 @@ public class AssembleIssueJobAppService
[HttpPost("get-job-by-packing/{packingCode}")]
public virtual async Task<AssembleIssueJobDTO> GetJobByPackingCodeAsync(string packingCode)
{
var list = await _repository.GetListAsync(p => p.Details.Any(r => r.RecommendFromPackingCode == packingCode)).ConfigureAwait(false);
var list = await _repository.GetListAsync(p => p.Details.Any(r => r.RecommendFromPackingCode == packingCode))
.ConfigureAwait(false);
if (list == null || list.Count < 1)
{
throw new UserFriendlyException("未找到该箱码的任务");
}
var dto = ObjectMapper.Map<AssembleIssueJob, AssembleIssueJobDTO>(list.First());
return dto;
}
@ -448,7 +444,7 @@ public class AssembleIssueJobAppService
[HttpPost("Do-Call-Back")]
public async Task DoTransferLibCallbackAsync(TransferLibJobDTO dto)
{
var job = await _repository.FindAsync(p => p.Number == dto.CallJobNumber,true).ConfigureAwait(false);
var job = await _repository.FindAsync(p => p.Number == dto.CallJobNumber).ConfigureAwait(false);
if (job.JobStatus != EnumJobStatus.Wait)
{
@ -493,7 +489,9 @@ public class AssembleIssueJobAppService
var jobDto = ObjectMapper.Map<AssembleIssueJob, AssembleIssueJobDTO>(job);
var isDoingAgv=await DoingAgvAsync(jobDto, transferLibNoteDetail.HandledToLocationCode, jobDetail.RecommendToLocationCode).ConfigureAwait(false);
var isDoingAgv =
await DoingAgvAsync(jobDto, transferLibNoteDetail.HandledToLocationCode, jobDetail.RecommendToLocationCode)
.ConfigureAwait(false);
_logger.LogInformation("是否agv:" + isDoingAgv);
@ -512,7 +510,7 @@ public class AssembleIssueJobAppService
: _options.Value.StereosPassword;
}
_logger.LogInformation("任务状态:"+job.JobStatus.ToString());
_logger.LogInformation("任务状态:" + job.JobStatus);
job = await _repository.UpdateAsync(job, true).ConfigureAwait(false);
@ -708,7 +706,6 @@ public class AssembleIssueJobAppService
foreach (var itm in dtos)
{
var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<AssembleIssueJobDetailDTO>();
@ -720,12 +717,14 @@ public class AssembleIssueJobAppService
{
errors.Add($"来源库位{detail.FromLocationCode}没查到");
}
var toloc = await _locationAppService.GetByCodeAsync(detail.ToLocationCode)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"目标库位{detail.ToLocationCode}没查到");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.ItemCode);
if (entity == null)
{
@ -781,6 +780,7 @@ public class AssembleIssueJobAppService
Data = json
};
}
itm.Worker = "LITK";
itm.Details = details;
// await CompleteAsync(itm.Id, itm).ConfigureAwait(false);
@ -830,32 +830,11 @@ public class AssembleIssueJobAppService
/// <param name="fromLocationCode"></param>
/// <param name="toLocationCode"></param>
/// <returns></returns>
private async Task<bool> DoingAgvAsync(AssembleIssueJobDTO assembleIssueJobDto,string fromLocationCode,string toLocationCode)
{
var jobDetailInputdetail = assembleIssueJobDto.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
fromLocationCode, toLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
//TODO AGV
//来源永远是库位 目标永远是工位
var ret = await CallAgvAsync(assembleIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false);
if (ret.Code != 0)
{
throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}");
}
else
{
return true;
}
}
else
private async Task<bool> DoingAgvAsync(AssembleIssueJobDTO assembleIssueJobDto, string fromLocationCode,
string toLocationCode)
{
return false;
}
}
/// <summary>
/// 判断是不是有Agv
@ -864,17 +843,6 @@ public class AssembleIssueJobAppService
/// <returns></returns>
private async Task<bool> UpdateJobStatusWaitByAgvAsync(AssembleIssueJobEditInput input)
{
var jobDetailInputdetail = input.Details.FirstOrDefault();
var locationDeliveryDto=await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false);
if (locationDeliveryDto!=null&& locationDeliveryDto.EnumLocationDeliveryType==EnumLocationDeliveryType.Agv)
{
input.JobStatus = EnumJobStatus.WaitAgv;
return true;
}
return false;
}
@ -888,28 +856,7 @@ public class AssembleIssueJobAppService
[HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(AssembleIssueJobDTO input, string beginPosition, string endPosition)
{
var res = new ReusltObject();
List<string> errors = new List<string>();
List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).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;
return null;
}
/// <summary>
@ -920,101 +867,6 @@ public class AssembleIssueJobAppService
[HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvIssueAsync(AgvRequestDto request)
{
_logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}");
if (request.Data.Count==0)
{
return ReturnMessage("-1", "请求Data明细数量不能为0");
}
var entity=await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
if (entity == null)
{
return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!");
}
var dto=ObjectMapper.Map<AssembleIssueJob, AssembleIssueJobDTO>(entity);
if (entity.JobStatus == EnumJobStatus.Done)
{
return ReturnMessage("-1", $"{entity.Number}任务单据已结束!");
}
try
{
foreach (var detail in entity.Details)
{
var detailDto = new AssembleIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{
var fromloc = new LocationDTO();
if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode &&
detail.TransferLibToLocationCode == detail.RecommendToLocationCode)
{
//库移的最终目标 挪到 推荐的目标
fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
}
else
{
//库移的最终目标 挪到 推荐的目标
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 fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).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.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;
}
await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
}
}
catch (Exception e)
{
return ReturnMessage("-1", e.Message);
}
return ReturnMessage("0", "OK");
}
@ -1026,17 +878,10 @@ public class AssembleIssueJobAppService
/// <returns></returns>
private AgvResultObject ReturnMessage(string code, string message)
{
return new AgvResultObject()
{
Code = code,
Message = message,
ReqCode = ""
};
return new AgvResultObject { Code = code, Message = message, ReqCode = "" };
}
/// <summary>
/// Agv 回库 接口
/// </summary>
@ -1055,9 +900,6 @@ public class AssembleIssueJobAppService
var ret = ReturnMessage("0", "OK");
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
@ -1075,17 +917,23 @@ public class AssembleIssueJobAppService
transfer.Confirmed = true;
var detailInput = new TransferNoteDetailInput();
var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition)
.ConfigureAwait(false);
if (fromPosition == null)
{
errors.Add($"未查询到工位{detail.BeginPosition}关联的库位");
}
var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false);
var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode)
.ConfigureAwait(false);
var tolocationDto =
await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
if (tolocationDto != null)
{
tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
@ -1098,11 +946,12 @@ public class AssembleIssueJobAppService
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
if (errors.Count > 0)
{
return ReturnMessage("-1", string.Join(",", errors.ToArray()));
}
detailInput.ToLocationCode = tolocationDto.Code;
detailInput.ToLocationGroup = tolocationDto.LocationGroupCode;
detailInput.ToLocationArea = tolocationDto.AreaCode;
@ -1146,11 +995,8 @@ public class AssembleIssueJobAppService
ret = ReturnMessage("-1", string.Join(",", errors.ToArray()));
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
return ret;
}
@ -1161,32 +1007,20 @@ public class AssembleIssueJobAppService
/// <param name="beginPosition"></param>
/// <param name="endPosition"></param>
/// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(AssembleIssueJobDTO job,string beginPosition, string endPosition)
private async Task<AgvResultObject> SendInterFaceAsync(AssembleIssueJobDTO job, string beginPosition,
string endPosition)
{
#if DEBUG
#endif
return
new AgvResultObject
{
Code = "0",
ReqCode = job.AssembleRequestNumber,
Message = "OK"
};
new AgvResultObject { Code = "0", ReqCode = job.AssembleRequestNumber, Message = "OK" };
var ret = new AgvResultObject
{
Code = "0",
ReqCode = job.AssembleRequestNumber,
Message = "OK"
};
var ret = new AgvResultObject { Code = "0", ReqCode = job.AssembleRequestNumber, Message = "OK" };
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
@ -1196,6 +1030,7 @@ public class AssembleIssueJobAppService
{
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
}
var first = job.Details.FirstOrDefault();
var request = new AgvRequest();
request.MatCode = first.ItemCode;
@ -1236,7 +1071,6 @@ public class AssembleIssueJobAppService
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path);
ret = await client.PushOutTaskAssembleAsync(request).ConfigureAwait(false);
}
catch (Exception e)
{
@ -1247,6 +1081,7 @@ public class AssembleIssueJobAppService
await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
}
return ret;
}

378
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs

@ -840,33 +840,6 @@ public class CoatingIssueJobAppService
/// <returns></returns>
private async Task<bool> DoingAgvAsync(CoatingIssueJobDTO CoatingIssueJobDto, string fromLocationCode, string toLocationCode)
{
var jobDetailInputdetail = CoatingIssueJobDto.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
fromLocationCode, toLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
//TODO AGV
//来源永远是库位 目标永远是工位
var ret = await CallAgvAsync(CoatingIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false);
#if DEBUG
return true;
#endif
if (ret.Code != 0)
{
throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}");
}
else
{
return true;
}
}
return false;
}
@ -877,17 +850,6 @@ public class CoatingIssueJobAppService
/// <returns></returns>
private async Task<bool> UpdateJobStatusWaitByAgvAsync(CoatingIssueJobEditInput input)
{
var jobDetailInputdetail = input.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
input.JobStatus = EnumJobStatus.WaitAgv;
return true;
}
return false;
}
@ -901,28 +863,7 @@ public class CoatingIssueJobAppService
[HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(CoatingIssueJobDTO input, string beginPosition, string endPosition)
{
var res = new ReusltObject();
List<string> errors = new List<string>();
List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).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;
return null;
}
/// <summary>
@ -933,100 +874,6 @@ public class CoatingIssueJobAppService
[HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvIssueAsync(AgvRequestDto request)
{
_logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}");
if (request.Data.Count == 0)
{
return ReturnMessage("-1", "请求Data明细数量不能为0");
}
var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
if (entity == null)
{
return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!");
}
var dto = ObjectMapper.Map<CoatingIssueJob, CoatingIssueJobDTO>(entity);
if (entity.JobStatus == EnumJobStatus.Done)
{
return ReturnMessage("-1", $"{entity.Number}任务单据已结束!");
}
try
{
foreach (var detail in entity.Details)
{
var detailDto = new CoatingIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{
var fromloc = new LocationDTO();
if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode &&
detail.TransferLibToLocationCode == detail.RecommendToLocationCode)
{
//库移的最终目标 挪到 推荐的目标
fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
}
else
{
//库移的最终目标 挪到 推荐的目标
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 fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).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.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;
}
await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
}
}
catch (Exception e)
{
return ReturnMessage("-1", e.Message);
}
return ReturnMessage("0", "OK");
}
/// <summary>
@ -1037,21 +884,7 @@ public class CoatingIssueJobAppService
/// <returns></returns>
private AgvResultObject ReturnMessage(string code, string message)
{
var result = new AgvResultObject()
{
Code = code,
Message = message,
ReqCode = ""
};
if (code == "0")
{
_logger.LogInformation("成功:" + JsonSerializer.Serialize(result));
}
else
{
_logger.LogInformation("失败:" + JsonSerializer.Serialize(result));
}
return result;
return new AgvResultObject();
}
/// <summary>
@ -1062,126 +895,7 @@ public class CoatingIssueJobAppService
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
var transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Transfer_WIP.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
transfer.Confirmed = true;
var detailInput = new TransferNoteDetailInput();
var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromPosition == null)
{
errors.Add($"未查询到工位{detail.BeginPosition}关联的库位");
}
var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false);
var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
if (tolocationDto != null)
{
tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"ERP料号{detail.MatCode}不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
if (errors.Count > 0)
{
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
detailInput.ToLocationCode = tolocationDto.Code;
detailInput.ToLocationGroup = tolocationDto.LocationGroupCode;
detailInput.ToLocationArea = tolocationDto.AreaCode;
detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode;
detailInput.ToWarehouseCode = tolocationDto.WarehouseCode;
detailInput.FromLocationCode = fromLocationDto.Code;
detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode;
detailInput.FromLocationArea = fromLocationDto.AreaCode;
detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode;
detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode;
detailInput.Qty = detail.MatQty;
detailInput.ToLot = detail.BatchAttr07;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromLot = detail.BatchAttr07;
detailInput.FromPackingCode = detail.PakingCode;
detailInput.FromStatus = EnumInventoryStatus.OK;
detailInput.ToStatus = EnumInventoryStatus.OK;
detailInput.Remark = "AGV反库";
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
return new AgvResultObject();
}
@ -1194,91 +908,7 @@ public class CoatingIssueJobAppService
/// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(CoatingIssueJobDTO job, string beginPosition, string endPosition)
{
#if DEBUG
#endif
var ret = new AgvResultObject
{
Code = "0",
ReqCode = job.CoatingRequestNumber,
Message = "OK"
};
//return ret;//暂时无接口直接返回
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
}
if (job.Details.Count == 0)
{
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
}
var first = job.Details.FirstOrDefault();
var request = new AgvRequest();
request.MatCode = first.ItemCode;
request.MatQty = first.RecommendFromQty;
request.OrderNum = job.Number;
request.OrderType = ((int)EnumJobType.CoatingIssueJob).ToString();
request.BeginPosition = beginPosition;
request.EndPosition = endPosition;
request.State = "1";
request.PakingCode = !string.IsNullOrEmpty(first.HandledFromPackingCode) ? first.HandledFromPackingCode : string.Empty;
request.Batch = "";
var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
? "http://7e42682n64.goho.co:21171/"
: _agvOptions.Value.Address; //测试地址
_agvOptions.Value.Token =
string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token
_agvOptions.Value.UserName =
string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名
_agvOptions.Value.Password =
string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码
_agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path)
? "zozocnApi/custom/receiveProductionPlan"
: _agvOptions.Value.Path; //测试密码
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
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;
var password = _agvOptions.Value.Password;
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")));
}
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path);
_logger.LogInformation($"发送Json{JsonSerializer.Serialize(request)}{DateTime.Now.ToString()}");
ret = await client.PushOutTaskCoatingAsync(request).ConfigureAwait(false);
}
catch (Exception e)
{
ret = new AgvResultObject();
ret.Code = "1";
ret.Message = e.Message;
ret.ReqCode = job.CoatingRequestNumber;
await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
}
return ret;
return new AgvResultObject();
}
#endregion

367
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs

@ -804,28 +804,6 @@ public class InjectionIssueJobAppService
/// <returns></returns>
private async Task<bool> DoingAgvAsync(InjectionIssueJobDTO InjectionIssueJobDto, string fromLocationCode, string toLocationCode)
{
var jobDetailInputdetail = InjectionIssueJobDto.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
fromLocationCode, toLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
//TODO AGV
//来源永远是库位 目标永远是工位
var ret = await CallAgvAsync(InjectionIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false);
#if DEBUG
return true;
#endif
if (ret.Code != 0)
{
throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}");
}
else
{
return true;
}
}
return false;
}
@ -836,17 +814,6 @@ public class InjectionIssueJobAppService
/// <returns></returns>
private async Task<bool> UpdateJobStatusWaitByAgvAsync(InjectionIssueJobEditInput input)
{
var jobDetailInputdetail = input.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
input.JobStatus = EnumJobStatus.WaitAgv;
return true;
}
return false;
}
@ -860,28 +827,7 @@ public class InjectionIssueJobAppService
[HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(InjectionIssueJobDTO input, string beginPosition, string endPosition)
{
var res = new ReusltObject();
List<string> errors = new List<string>();
List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).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;
return new ReusltObject();
}
/// <summary>
@ -892,103 +838,7 @@ public class InjectionIssueJobAppService
[HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvIssueAsync(AgvRequestDto request)
{
_logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}");
if (request.Data.Count == 0)
{
return ReturnMessage("-1", "请求Data明细数量不能为0");
}
var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
if (entity == null)
{
return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!");
}
var dto = ObjectMapper.Map<InjectionIssueJob, InjectionIssueJobDTO>(entity);
if (entity.JobStatus == EnumJobStatus.Done)
{
return ReturnMessage("-1", $"{entity.Number}任务单据已结束!");
}
try
{
foreach (var detail in entity.Details)
{
var detailDto = new InjectionIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{
var fromloc = new LocationDTO();
if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode &&
detail.TransferLibToLocationCode == detail.RecommendToLocationCode)
{
//库移的最终目标 挪到 推荐的目标
fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
}
else
{
//库移的最终目标 挪到 推荐的目标
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 fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).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.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;
}
await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
}
}
catch (Exception e)
{
return ReturnMessage("-1", e.Message);
}
return ReturnMessage("0", "OK");
return new AgvResultObject();
}
/// <summary>
/// 返回信息
@ -998,12 +848,7 @@ public class InjectionIssueJobAppService
/// <returns></returns>
private AgvResultObject ReturnMessage(string code, string message)
{
return new AgvResultObject()
{
Code = code,
Message = message,
ReqCode = ""
};
return new AgvResultObject();
}
/// <summary>
@ -1014,127 +859,7 @@ public class InjectionIssueJobAppService
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
var transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Transfer_WIP.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
transfer.Confirmed = true;
var detailInput = new TransferNoteDetailInput();
var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromPosition == null)
{
errors.Add($"未查询到工位{detail.BeginPosition}关联的库位");
}
var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false);
var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
if (tolocationDto != null)
{
tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"ERP料号{detail.MatCode}不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
if (errors.Count > 0)
{
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
detailInput.ToLocationCode = tolocationDto.Code;
detailInput.ToLocationGroup = tolocationDto.LocationGroupCode;
detailInput.ToLocationArea = tolocationDto.AreaCode;
detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode;
detailInput.ToWarehouseCode = tolocationDto.WarehouseCode;
detailInput.FromLocationCode = fromLocationDto.Code;
detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode;
detailInput.FromLocationArea = fromLocationDto.AreaCode;
detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode;
detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode;
detailInput.Qty = detail.MatQty;
detailInput.ToLot = detail.BatchAttr07;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromLot = detail.BatchAttr07;
detailInput.FromPackingCode = detail.PakingCode;
detailInput.FromStatus = EnumInventoryStatus.OK;
detailInput.ToStatus = EnumInventoryStatus.OK;
detailInput.Remark = "AGV反库";
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
return new AgvResultObject();
}
@ -1147,84 +872,7 @@ public class InjectionIssueJobAppService
/// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(InjectionIssueJobDTO job, string beginPosition, string endPosition)
{
#if DEBUG
#endif
var ret = new AgvResultObject
{
Code = "0",
ReqCode = job.InjectionRequestNumber,
Message = "OK"
};
return ret;
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
}
if (job.Details.Count == 0)
{
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
}
var first = job.Details.FirstOrDefault();
var request = new AgvRequest();
request.MatCode = first.ItemCode;
request.MatQty = first.HandledToQty;
request.OrderNum = job.Number;
request.OrderType = EnumJobType.InjectionIssueJob.ToString();
request.BeginPosition = beginPosition;
request.EndPosition = endPosition;
var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
? "http://7e42682n64.goho.co:21171/"
: _agvOptions.Value.Address; //测试地址
_agvOptions.Value.Token =
string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token
_agvOptions.Value.UserName =
string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名
_agvOptions.Value.Password =
string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码
_agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path)
? "zozocnApi/custom/receiveProductionPlan"
: _agvOptions.Value.Path; //测试密码
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
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;
var password = _agvOptions.Value.Password;
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.PushOutTaskInjectionAsync(request).ConfigureAwait(false);
}
catch (Exception e)
{
ret = new AgvResultObject();
ret.Code = "1";
ret.Message = e.Message;
ret.ReqCode = job.InjectionRequestNumber;
await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
}
return ret;
return new AgvResultObject();
}
#endregion
@ -1380,9 +1028,4 @@ public class InjectionIssueJobAppService
#endregion
}

379
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs

@ -802,32 +802,6 @@ public class KittingIssueJobAppService
/// <returns></returns>
private async Task<bool> DoingAgvAsync(KittingIssueJobDTO KittingIssueJobDto, string fromLocationCode, string toLocationCode)
{
var jobDetailInputdetail = KittingIssueJobDto.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
fromLocationCode, toLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
//TODO AGV
//来源永远是库位 目标永远是工位
var ret = await CallAgvAsync(KittingIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false);
#if DEBUG
return true;
#endif
if (ret.Code != 0)
{
throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}");
}
else
{
return true;
}
}
return false;
}
@ -838,17 +812,6 @@ public class KittingIssueJobAppService
/// <returns></returns>
private async Task<bool> UpdateJobStatusWaitByAgvAsync(KittingIssueJobEditInput input)
{
var jobDetailInputdetail = input.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
input.JobStatus = EnumJobStatus.WaitAgv;
return true;
}
return false;
}
@ -862,28 +825,7 @@ public class KittingIssueJobAppService
[HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(KittingIssueJobDTO input, string beginPosition, string endPosition)
{
var res = new ReusltObject();
List<string> errors = new List<string>();
List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).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;
return new ReusltObject();
}
/// <summary>
@ -894,101 +836,7 @@ public class KittingIssueJobAppService
[HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvIssueAsync(AgvRequestDto request)
{
_logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}");
if (request.Data.Count == 0)
{
return ReturnMessage("-1", "请求Data明细数量不能为0");
}
var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
if (entity == null)
{
return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!");
}
var dto = ObjectMapper.Map<KittingIssueJob, KittingIssueJobDTO>(entity);
if (entity.JobStatus == EnumJobStatus.Done)
{
return ReturnMessage("-1", $"{entity.Number}任务单据已结束!");
}
try
{
foreach (var detail in entity.Details)
{
var detailDto = new KittingIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{
var fromloc = new LocationDTO();
if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode &&
detail.TransferLibToLocationCode == detail.RecommendToLocationCode)
{
//库移的最终目标 挪到 推荐的目标
fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
}
else
{
//库移的最终目标 挪到 推荐的目标
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 fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).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.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;
}
await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
}
}
catch (Exception e)
{
return ReturnMessage("-1", e.Message);
}
return ReturnMessage("0", "OK");
return new AgvResultObject();
}
/// <summary>
/// 返回信息
@ -998,22 +846,7 @@ public class KittingIssueJobAppService
/// <returns></returns>
private AgvResultObject ReturnMessage(string code, string message)
{
var result = new AgvResultObject()
{
Code = code,
Message = message,
ReqCode = ""
};
if(code == "0")
{
_logger.LogInformation("成功:"+JsonSerializer.Serialize(result));
}
else
{
_logger.LogInformation("失败:"+JsonSerializer.Serialize(result));
}
return result;
return new AgvResultObject();
}
/// <summary>
@ -1024,126 +857,7 @@ public class KittingIssueJobAppService
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
var transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Transfer_WIP.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
transfer.Confirmed = true;
var detailInput = new TransferNoteDetailInput();
var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromPosition == null)
{
errors.Add($"未查询到工位{detail.BeginPosition}关联的库位");
}
var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false);
var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
if (tolocationDto != null)
{
tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"ERP料号{detail.MatCode}不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
if (errors.Count > 0)
{
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
detailInput.ToLocationCode = tolocationDto.Code;
detailInput.ToLocationGroup = tolocationDto.LocationGroupCode;
detailInput.ToLocationArea = tolocationDto.AreaCode;
detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode;
detailInput.ToWarehouseCode = tolocationDto.WarehouseCode;
detailInput.FromLocationCode = fromLocationDto.Code;
detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode;
detailInput.FromLocationArea = fromLocationDto.AreaCode;
detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode;
detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode;
detailInput.Qty = detail.MatQty;
detailInput.ToLot = detail.BatchAttr07;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromLot = detail.BatchAttr07;
detailInput.FromPackingCode = detail.PakingCode;
detailInput.FromStatus = EnumInventoryStatus.OK;
detailInput.ToStatus = EnumInventoryStatus.OK;
detailInput.Remark = "AGV反库";
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
return new AgvResultObject();
}
@ -1156,90 +870,7 @@ public class KittingIssueJobAppService
/// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(KittingIssueJobDTO job, string beginPosition, string endPosition)
{
#if DEBUG
#endif
var ret = new AgvResultObject
{
Code = "0",
ReqCode = job.KittingRequestNumber,
Message = "OK"
};
// return ret;//暂时无接口直接返回
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
}
if (job.Details.Count == 0)
{
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
}
var first = job.Details.FirstOrDefault();
var request = new AgvRequest();
request.MatCode = first.ItemCode;
request.MatQty = first.RecommendFromQty;
request.OrderNum = job.Number;
request.State = "1";
request.PakingCode = !string.IsNullOrEmpty(first.HandledFromPackingCode)?first.HandledFromPackingCode:string.Empty;
request.Batch = "";
request.OrderType = ((int)EnumJobType.KittingIssueJob).ToString();
request.BeginPosition = beginPosition;
request.EndPosition = endPosition;
var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
? "http://7e42682n64.goho.co:21171/"
: _agvOptions.Value.Address; //测试地址
_agvOptions.Value.Token =
string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token
_agvOptions.Value.UserName =
string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名
_agvOptions.Value.Password =
string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码
_agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path)
? "zozocnApi/custom/receiveProductionPlan"
: _agvOptions.Value.Path; //测试密码
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
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;
var password = _agvOptions.Value.Password;
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")));
}
var json = JsonSerializer.Serialize(request);
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path);
_logger.LogInformation($"{flag}发送AGV任务请求:{json }");
ret = await client.PushOutTaskKittingAsync(request).ConfigureAwait(false);
}
catch (Exception e)
{
ret = new AgvResultObject();
ret.Code = "1";
ret.Message = e.Message;
ret.ReqCode = job.KittingRequestNumber;
await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
}
return ret;
return new AgvResultObject();
}
#endregion

365
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs

@ -801,32 +801,6 @@ public class SparePartIssueJobAppService
/// <returns></returns>
private async Task<bool> DoingAgvAsync(SparePartIssueJobDTO sparePartIssueJobDto, string fromLocationCode, string toLocationCode)
{
var jobDetailInputdetail = sparePartIssueJobDto.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
fromLocationCode, toLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
//TODO AGV
//来源永远是库位 目标永远是工位
var ret = await CallAgvAsync(sparePartIssueJobDto, fromLocationCode, jobDetailInputdetail.Remark).ConfigureAwait(false);
#if DEBUG
return true;
#endif
if (ret.Code != 0)
{
throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}");
}
else
{
return true;
}
}
return false;
}
@ -837,17 +811,6 @@ public class SparePartIssueJobAppService
/// <returns></returns>
private async Task<bool> UpdateJobStatusWaitByAgvAsync(SparePartIssueJobEditInput input)
{
var jobDetailInputdetail = input.Details.FirstOrDefault();
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync(
jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false);
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv)
{
input.JobStatus = EnumJobStatus.WaitAgv;
return true;
}
return false;
}
@ -861,28 +824,7 @@ public class SparePartIssueJobAppService
[HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(SparePartIssueJobDTO input, string beginPosition, string endPosition)
{
var res = new ReusltObject();
List<string> errors = new List<string>();
List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).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;
return new ReusltObject();
}
/// <summary>
@ -893,106 +835,7 @@ public class SparePartIssueJobAppService
[HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvIssueAsync(AgvRequestDto request)
{
_logger.LogInformation($"发料回库{JsonSerializer.Serialize(request)}");
if (request.Data.Count == 0)
{
return ReturnMessage("-1", "请求Data明细数量不能为0");
}
var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
if (entity == null)
{
return ReturnMessage("-1", $"{request.Data.First().OrderNum}任务单据不存在!");
}
var dto = ObjectMapper.Map<SparePartIssueJob, SparePartIssueJobDTO>(entity);
if (entity.JobStatus == EnumJobStatus.Done)
{
return ReturnMessage("-1", $"{entity.Number}任务单据已结束!");
}
try
{
foreach (var detail in entity.Details)
{
var detailDto = new SparePartIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{
var fromloc = new LocationDTO();
if (detail.TransferLibFromLocationCode == detail.RecommendFromLocationCode &&
detail.TransferLibToLocationCode == detail.RecommendToLocationCode)
{
//库移的最终目标 挪到 推荐的目标
fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
}
else
{
//库移的最终目标 挪到 推荐的目标
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 fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).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.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;
}
await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
}
}
catch (Exception e)
{
return ReturnMessage("-1", e.Message);
}
return new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
return new AgvResultObject();
}
/// <summary>
/// 返回信息
@ -1002,12 +845,7 @@ public class SparePartIssueJobAppService
/// <returns></returns>
private AgvResultObject ReturnMessage(string code, string message)
{
return new AgvResultObject()
{
Code = code,
Message = message,
ReqCode = ""
};
return new AgvResultObject();
}
/// <summary>
@ -1018,125 +856,7 @@ public class SparePartIssueJobAppService
[HttpPost("call-return-back-agv")]
public async Task<AgvResultObject> CallReturnBackAgvAsync(AgvRequestDto 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 ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = "",
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var notes = request.Data;
foreach (var detail in notes)
{
var transfer = new TransferNoteEditInput();
transfer.CallJobNumber = detail.OrderNum;
transfer.Type = EnumTransSubType.Transfer_WIP.ToString();
transfer.Worker = "Agv";
transfer.UseOnTheWayLocation = false;
transfer.Confirmed = true;
var detailInput = new TransferNoteDetailInput();
var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromPosition == null)
{
errors.Add($"未查询到工位{detail.BeginPosition}关联的库位");
}
var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false);
var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
if (tolocationDto != null)
{
tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false);
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"ERP料号{detail.MatCode}不存在!");
}
else
{
detailInput.ItemCode = item.Code;
detailInput.Uom = item.BasicUom;
detailInput.ItemName = item.Name;
detailInput.ItemDesc1 = !string.IsNullOrEmpty(item.Desc1) ? item.Desc1 : string.Empty;
}
if (errors.Count > 0)
{
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
detailInput.ToLocationCode = tolocationDto.Code;
detailInput.ToLocationGroup = tolocationDto.LocationGroupCode;
detailInput.ToLocationArea = tolocationDto.AreaCode;
detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode;
detailInput.ToWarehouseCode = tolocationDto.WarehouseCode;
detailInput.FromLocationCode = fromLocationDto.Code;
detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode;
detailInput.FromLocationArea = fromLocationDto.AreaCode;
detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode;
detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode;
detailInput.Qty = detail.MatQty;
detailInput.ToLot = detail.BatchAttr07;
detailInput.ToPackingCode = detail.PakingCode;
detailInput.FromLot = detail.BatchAttr07;
detailInput.FromPackingCode = detail.PakingCode;
detailInput.FromStatus = EnumInventoryStatus.OK;
detailInput.ToStatus = EnumInventoryStatus.OK;
detailInput.Remark = "AGV反库";
transfer.Details.Add(detailInput);
await _transferNoteAppService.CreateAsync(transfer).ConfigureAwait(false);
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = "",
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = ""
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
}
return ret;
return new AgvResultObject();
}
@ -1150,82 +870,7 @@ public class SparePartIssueJobAppService
/// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(SparePartIssueJobDTO job, string beginPosition, string endPosition)
{
#if DEBUG
#endif
var ret = new AgvResultObject
{
Code = "0",
ReqCode = job.SparePartRequestNumber,
Message = "OK"
};
return ret;
//暂时无接口直接返回
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
}
if (job.Details.Count == 0)
{
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
}
var first = job.Details.FirstOrDefault();
var request = new AgvRequest();
request.MatCode = first.ItemCode;
request.MatQty = first.HandledToQty;
request.OrderNum = job.Number;
request.OrderType = EnumJobType.SparePartIssueJob.ToString();
request.BeginPosition = beginPosition;
request.EndPosition = endPosition;
var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
? "http://7e42682n64.goho.co:21171/"
: _agvOptions.Value.Address; //测试地址
_agvOptions.Value.Token =
string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token
_agvOptions.Value.UserName =
string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名
_agvOptions.Value.Password =
string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码
_agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path)
? "zozocnApi/custom/receiveProductionPlan"
: _agvOptions.Value.Path; //测试密码
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
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;
var password = _agvOptions.Value.Password;
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.PushOutTaskSparePartAsync(request).ConfigureAwait(false);
}
catch (Exception e)
{
ret = new AgvResultObject();
ret.Code = "1";
ret.Message = e.Message;
ret.ReqCode = job.SparePartRequestNumber;
await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
}
return ret;
return new AgvResultObject();
}
#endregion

165
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs

@ -702,28 +702,7 @@ public class UnplannedIssueJobAppService
[HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(UnplannedIssueJob job, UnplannedIssueJobDetail detail)
{
var res = new ReusltObject();
List<string> errors = new List<string>();
List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(job, detail).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;
return new ReusltObject();
}
/// <summary>
@ -734,59 +713,7 @@ 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,true).ConfigureAwait(false);
if (job == null)
{
return ReturnMessage("-1", $"{agvRequest.OrderNum}未找到该任务");
}
if (job.JobStatus != EnumJobStatus.WaitAgv)
{
return ReturnMessage("-1", "该任务状态不是等待AGV中");
}
var toLocationDto = await _locationAppService.GetByCodeAsync(agvRequest.EndPosition ).ConfigureAwait(false);//agvRequest.BeginPosition调试时确认
if (toLocationDto == null)
{
return ReturnMessage("-1", $"{agvRequest.EndPosition}库位没查到!");
}
var detail = new UnplannedIssueJobDetail();
detail.HandledQty = agvRequest.MatQty;
detail.HandledPackingCode = agvRequest.PakingCode;
detail.HandledLot = agvRequest.BatchAttr07;
detail.Status = EnumInventoryStatus.OK;
detail.HandledFromWarehouseCode = toLocationDto.WarehouseCode;
detail.HandledFromLocationCode = toLocationDto.Code;
detail.HandledFromLocationGroup = toLocationDto.LocationGroupCode;
detail.HandledFromLocationArea = toLocationDto.AreaCode;
detail.HandledFromLocationErpCode = toLocationDto.ErpLocationCode;
detail.ItemCode = job.ItemCode;
detail.ItemDesc1=job.ItemDesc1;
detail.ItemDesc2=job.ItemDesc2;
detail.ItemName=job.ItemName;
detail.CaseCode=job.CaseCode;
detail.Explain=job.Explain;
detail.OnceBusiCode=job.OnceBusiCode;
detail.ProjCapacityCode=job.ProjCapacityCode;
detail.Number=job.Number;
job.Details.Add(detail);
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");
return new AgvResultObject();
}
/// <summary>
@ -797,12 +724,7 @@ public class UnplannedIssueJobAppService
/// <returns></returns>
private AgvResultObject ReturnMessage(string code, string message)
{
return new AgvResultObject()
{
Code = code,
Message = message,
ReqCode = ""
};
return new AgvResultObject();
}
@ -816,88 +738,7 @@ public class UnplannedIssueJobAppService
/// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(UnplannedIssueJob job, UnplannedIssueJobDetail detail)
{
#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
{
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
}
var request = new AgvRequestUnplanned();
request.MatCode = detail.ItemCode;
request.MatQty = detail.RecommendQty;
request.OrderNum = job.Number;
request.Batch = detail.HandledPackingCode;
request.ErpLocationCode = job.FromErpLocationCode;
request.PakingCode = detail.HandledPackingCode;
request.BeginPosition = detail.HandledFromLocationCode;
request.EndPosition = detail.HandledFromLocationCode;
request.OrderType = job.UnplannedIssueType == EnumUnplannedIssueType.Raw ? ((int)EnumJobType.UnplannedIssueJobHasPacking).ToString() :((int)EnumJobType.UnplannedIssueJobNoPacking).ToString(); ;
request.State = "1";
request.PakingCode = !string.IsNullOrEmpty(detail.HandledPackingCode) ? detail.HandledPackingCode : string.Empty;
request.Batch = "";
var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
? "http://7e42682n64.goho.co:21171/"
: _agvOptions.Value.Address; //测试地址
_agvOptions.Value.Token =
string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token
_agvOptions.Value.UserName =
string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名
_agvOptions.Value.Password =
string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码
_agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path)
? "zozocnApi/custom/receiveProductionPlan"
: _agvOptions.Value.Path; //测试密码
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
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;
var password = _agvOptions.Value.Password;
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")));
}
_logger.LogInformation($"发送Json{JsonSerializer.Serialize(request)}{DateTime.Now.ToString()}");
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path);
ret = await client.PushOutTaskUnplannedAsync(request).ConfigureAwait(false);
}
catch (Exception e)
{
ret = new AgvResultObject();
ret.Code = "1";
ret.Message = e.Message;
ret.ReqCode = job.UnplannedIssueRequestNumber;
await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
}
return ret;
}

147
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs

@ -355,28 +355,7 @@ public class UnplannedReceiptJobAppService
[HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(UnplannedReceiptJob job,UnplannedReceiptJobDetail detail)
{
var res = new ReusltObject();
List<string> errors = new List<string>();
List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(job,detail).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;
return new ReusltObject();
}
/// <summary>
@ -387,41 +366,7 @@ public class UnplannedReceiptJobAppService
[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)
{
return ReturnMessage("-1", $"{agvRequest.OrderNum}未找到该任务");
}
if (job.JobStatus != EnumJobStatus.WaitAgv)
{
return ReturnMessage("-1", $"{agvRequest.OrderNum}任务状态不是等待AGV中");
}
var toLocationDto = await _locationAppService.GetByCodeAsync(agvRequest.EndPosition).ConfigureAwait(false);
if (toLocationDto == null)
{
return ReturnMessage("-1", $"{agvRequest.EndPosition}库位没查到!");
}
var detail = job.Details.First();
detail.HandledQty = agvRequest.MatQty;
detail.HandledPackingCode = agvRequest.PakingCode;
detail.HandledToWarehouseCode = toLocationDto.WarehouseCode;
detail.HandledToLocationCode = toLocationDto.Code;
detail.HandledToLocationGroup = toLocationDto.LocationGroupCode;
detail.HandledToLocationArea = toLocationDto.AreaCode;
detail.HandledToLocationErpCode = toLocationDto.ErpLocationCode;
job.JobStatus = EnumJobStatus.Done;
job = await _repository.UpdateAsync(job).ConfigureAwait(false);
await LocalEventBus.PublishAsync(new SfsCompletedEntityEventData<UnplannedReceiptJob>(job), false)
.ConfigureAwait(false);
await UpdateRequestStatusAsync(job.UnplannedReceiptRequestNumber).ConfigureAwait(false);//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
return ReturnMessage("0", "OK");
return new AgvResultObject();
}
/// <summary>
/// 返回信息
@ -431,12 +376,7 @@ public class UnplannedReceiptJobAppService
/// <returns></returns>
private AgvResultObject ReturnMessage(string code, string message)
{
return new AgvResultObject()
{
Code = code,
Message = message,
ReqCode = ""
};
return new AgvResultObject();
}
/// <summary>
@ -447,87 +387,6 @@ public class UnplannedReceiptJobAppService
/// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(UnplannedReceiptJob job,UnplannedReceiptJobDetail detail)
{
#if DEBUG
return new AgvResultObject();
#endif
var ret = new AgvResultObject
{
Code = "0",
ReqCode = job.UnplannedReceiptRequestNumber,
Message = "OK"
};
//return ret;//暂时无接口直接返回
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (job.JobStatus == EnumJobStatus.Done)
{
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
}
var request = new AgvRequestUnplanned();
request.MatCode = detail.ItemCode;
request.MatQty = detail.RecommendQty;
request.OrderNum = job.Number;
request.Batch = detail.HandledPackingCode;
request.ErpLocationCode = job.FromErpLocationCode;
request.PakingCode = detail.HandledPackingCode;
request.EndPosition = detail.HandledToLocationCode;
request.OrderType = job.UnplannedReceiptType == EnumUnplannedReceiptType.Raw ? ((int)EnumJobType.UnplannedReceiptJobHasPacking).ToString() : ((int)EnumJobType.UnplannedReceiptJobNoPacking).ToString();
request.State = "1";
request.PakingCode = !string.IsNullOrEmpty(detail.HandledPackingCode) ? detail.HandledPackingCode : string.Empty;
request.Batch = "";
var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
? "http://7e42682n64.goho.co:21171/"
: _agvOptions.Value.Address; //测试地址
_agvOptions.Value.Token =
string.IsNullOrEmpty(_agvOptions.Value.Token) ? string.Empty : _agvOptions.Value.Token; //测试token
_agvOptions.Value.UserName =
string.IsNullOrEmpty(_agvOptions.Value.UserName) ? "" : _agvOptions.Value.UserName; //测试用户名
_agvOptions.Value.Password =
string.IsNullOrEmpty(_agvOptions.Value.Password) ? "" : _agvOptions.Value.Password; //测试密码
_agvOptions.Value.Path = string.IsNullOrEmpty(_agvOptions.Value.Path)
? "zozocnApi/custom/receiveProductionPlan"
: _agvOptions.Value.Path; //测试密码
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
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;
var password = _agvOptions.Value.Password;
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")));
}
var client = new AgvJobClient(_agvOptions.Value.Address, httpclient, _agvOptions.Value.Path);
_logger.LogInformation($"发送Json{JsonSerializer.Serialize(request)}{DateTime.Now.ToString()}");
ret = await client.PushOutTaskUnplannedReceiptAsync(request).ConfigureAwait(false);
}
catch (Exception e)
{
ret = new AgvResultObject();
ret.Code = "1";
ret.Message = e.Message;
ret.ReqCode = job.UnplannedReceiptRequestNumber;
await unitOfWork.RollbackAsync().ConfigureAwait(false);
throw new UserFriendlyException($"接口报错 错误信息{e.Message}");
}
return ret;
}
}

91
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs

@ -73,52 +73,7 @@ public class IntegrationPackingNoteAppService :
[HttpPost("")]
public override async Task<IntegrationPackingNoteDTO> CreateAsync(IntegrationPackingNoteEditInput input)
{
var transferLogEditInputs = new List<TransferLogEditInput>();
var outDtos = await _expectOutAppService.GetListByPackingCodeAsync(input.PackingCode).ConfigureAwait(false);
var balanceMainDto = await _balanceAppService.GetByPackingCodeAsync(input.PackingCode).ConfigureAwait(false);
if (outDtos.Any())
{
throw new UserFriendlyException($"此库存{input.PackingCode}已经被【任务编号:{outDtos.First().JobNumber}】占用");
}
var entity = input.ToObject<IntegrationPackingNote>();
var number = await GenerateNumberAsync(nameof(IntegrationPackingNote), Clock.Now).ConfigureAwait(false);
entity.Number = number;
entity.SetId(GuidGenerator.Create());
entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number);
entity.WarehouseCode = string.Empty;
entity.Details.ForEach(p=>p.WarehouseCode=string.Empty);
entity = await _repository.InsertAsync(entity).ConfigureAwait(false);
var balanceDetailDtos = new List<BalanceDTO>();
foreach (var detailInput in input.Details)
{
var balanceDetailDto=await _balanceAppService.GetByPackingCodeAsync(detailInput.PackingCode).ConfigureAwait(false);
if (balanceDetailDto.LocationCode != balanceMainDto.LocationCode)
{
throw new UserFriendlyException($"箱码【{detailInput.PackingCode}】的库存需要再{balanceMainDto.LocationCode}库位上才可合并");
}
//库存移动
var transferLogEditInput =
await BuildTransferLogsAsync(entity, detailInput)
.ConfigureAwait(false);
transferLogEditInputs.Add(transferLogEditInput);
balanceDetailDtos.Add(balanceDetailDto);
}
if (balanceDetailDtos.Sum(p=>p.Qty) > input.StdPackQty)
{
throw new UserFriendlyException($"合箱数量超过标包数量");
}
await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false);
var dto = entity.ToObject<IntegrationPackingNoteDTO>();
return dto;
return new IntegrationPackingNoteDTO();
}
/// <summary>
@ -131,48 +86,6 @@ public class IntegrationPackingNoteAppService :
IntegrationPackingNote entity,
IntegrationPackingNoteDetailInput detailInput)
{
var fromLocationDto = await _locationAppService.GetByCodeAsync(detailInput.LocationCode).ConfigureAwait(false);
var toLocationDto = await _locationAppService.GetByCodeAsync(entity.LocationCode).ConfigureAwait(false);
var transferLogEditInput = new TransferLogEditInput
{
Worker = entity.Worker,
Qty = detailInput.Qty,
ItemCode = detailInput.ItemCode,
FromLocationCode = fromLocationDto.Code,
FromLocationErpCode = fromLocationDto.ErpLocationCode,
FromLocationArea = fromLocationDto.AreaCode,
FromLocationGroup = fromLocationDto.LocationGroupCode,
FromWarehouseCode = fromLocationDto.WarehouseCode,
ToLocationCode = toLocationDto.Code,
ToLocationErpCode = toLocationDto.ErpLocationCode,
ToLocationArea = toLocationDto.AreaCode,
ToLocationGroup = toLocationDto.LocationGroupCode,
ToWarehouseCode = toLocationDto.WarehouseCode,
ToPackingCode = entity.PackingCode,
Remark = entity.Remark,
ArriveDate = entity.ArriveDate,
DocNumber = string.Empty,
ExpireDate = entity.ExpireDate,
FromContainerCode = detailInput.ContainerCode,
FromLot = detailInput.Lot,
FromPackingCode = detailInput.PackingCode,
Uom = detailInput.Uom,
FromStatus = EnumInventoryStatus.OK,
JobNumber = string.Empty,
ItemDesc1 = entity.ItemDesc1,
StdPackQty = entity.StdPackQty,
TransType = EnumTransType.Transfer,
ToLot = entity.Lot,
ItemDesc2 = entity.ItemDesc2,
ItemName = entity.ItemName,
ProduceDate = entity.ProduceDate,
SupplierBatch = entity.SupplierBatch,
ToContainerCode = detailInput.ContainerCode,
ToStatus = EnumInventoryStatus.OK,
TransSubType = EnumTransSubType.Transfer_Integration,
};
return transferLogEditInput;
return new TransferLogEditInput();
}
}

171
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs

@ -61,132 +61,7 @@ public class SeparationPackingNoteAppService :
[HttpPost("")]
public override async Task<SeparationPackingNoteDTO> CreateAsync(SeparationPackingNoteEditInput input)
{
var transferLogEditInputs = new List<TransferLogEditInput>();
var outDtos = await _expectOutAppService.GetListByPackingCodeAsync(input.PackingCode).ConfigureAwait(false);
if (outDtos.Any())
{
throw new UserFriendlyException($"此库存{input.PackingCode}已经被【任务编号:{outDtos.First().JobNumber}】占用");
}
if (input.Details.Sum(p => p.Qty) > input.Qty)
{
throw new UserFriendlyException($"拆出数量大于原箱数量");
}
if (input.Qty <= 0)
{
throw new UserFriendlyException($"被拆箱的数量小于或等于0");
}
var entity = input.ToObject<SeparationPackingNote>();
var number = await GenerateNumberAsync(nameof(SeparationPackingNote), Clock.Now).ConfigureAwait(false);
entity.Number = number;
entity.SetId(GuidGenerator.Create());
entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number);
entity = await _repository.InsertAsync(entity).ConfigureAwait(false);
foreach (var detail in entity.Details)
{
//创建标签
var splitPackingRecDtos = await _splitPackingRecAppService.GetListByToPackingCode(new List<string> { input.PackingCode }).ConfigureAwait(false);
var splitPackingRecDto = splitPackingRecDtos.First();
var inventoryLabelWithoutCodeCreateInput = new InventoryLabelWithoutCodeCreateInput
{
Qty = detail.Qty,
ItemCode = detail.ItemCode,
SupplierCode = detail.SupplierCode,
Lot = detail.Lot,
Uom = detail.Uom,
LocationErpCode = detail.LocationErpCode,
ItemDesc1 = detail.ItemDesc1,
ArriveDate = detail.ArriveDate,
StdPackQty = detail.StdPackQty,
ProdLine = string.Empty,
AsnNumber = detail.PurchaseInfo_AsnNumber,
ContainerCode = detail.ContainerCode,
ExpireDate = detail.ExpireDate,
FullBarcodeString = string.Empty,
ItemDesc2 = detail.ItemDesc2,
ItemName = detail.ItemName,
SupplierName = detail.SupplierName,
Remark = detail.Remark,
LabelStatus = LabelStatus.Enable,
LabelType = detail.LabelType,
PlanArriveDate = detail.PlanArriveDate,
PoNumber = detail.PurchaseInfo_PoNumber,
ProduceDate = detail.ProduceDate,
QLevel = string.Empty,
QualityFile = string.Empty,
RecommendLocationCode = detail.RecommendLocationCode,
RpNumber = detail.RpNumber,
Shift = string.Empty,
Specifications = string.Empty,
SupplierBatch = detail.SupplierBatch,
SupplierItemCode = detail.ItemCode,
SupplierItemName = detail.SupplierItemName,
SupplierSimpleName = detail.SupplierSimpleName,
Team = string.Empty,
};
var inventoryLabelDto = await _inventoryLabelAppService.GenerateAndCreateAsync(inventoryLabelWithoutCodeCreateInput).ConfigureAwait(false);
var splitPackingRecEditInputs = new List<SplitPackingRecEditInput>()
{
new SplitPackingRecEditInput()
{
ItemCode = inventoryLabelDto.ItemCode,
SupplierCode = inventoryLabelDto.SupplierCode,
ToPackingCode = inventoryLabelDto.Code,
FromPackingCode = input.PackingCode,
LocationErpCode = inventoryLabelDto.LocationErpCode,
ItemDesc1 = inventoryLabelDto.ItemDesc1,
FromLot = input.Lot,
ToLot = inventoryLabelDto.Lot,
ArriveDate = inventoryLabelDto.ArriveDate,
ItemName = inventoryLabelDto.ItemName,
ItemDesc2 = inventoryLabelDto.ItemDesc2,
PurchaseInfo_PoNumber = inventoryLabelDto.PoNumber,
LabelType = (EnumLabelType)inventoryLabelDto.LabelType,
RecommendLocationCode = inventoryLabelDto.RecommendLocationCode,
RpNumber = inventoryLabelDto.RpNumber,
SupplierName = inventoryLabelDto.SupplierName,
Remark = inventoryLabelDto.Remark,
FromQty = input.Qty,
ToQty = inventoryLabelDto.Qty,
PurchaseInfo_AsnNumber = inventoryLabelDto.AsnNumber,
ExpireDate = inventoryLabelDto.ExpireDate,
FullBarcodeString = inventoryLabelDto.FullBarcodeString,
SupplierBatch = inventoryLabelDto.SupplierBatch,
ProduceDate = inventoryLabelDto.ProduceDate,
LabelStatus = Basedata.LabelStatus.Enable,
SupplierSimpleName = inventoryLabelDto.SupplierSimpleName,
SupplierItemCode = inventoryLabelDto.SupplierItemCode,
SupplierItemName = inventoryLabelDto.SupplierItemName,
PlanArriveDate = inventoryLabelDto.PlanArriveDate,
FromStdPackQty = input.StdPackQty,
FromUom = input.Uom,
OprType = OprTypeEnum.SplitBox,
ReceiptRecNumber = inventoryLabelDto.RpNumber,
ToStdPackQty = inventoryLabelDto.StdPackQty,
ToUom = inventoryLabelDto.Uom,
TaskOrderNumber = detail.TaskOrderNumber,
ArrivalNoticNumber = detail.ArrivalNoticNumber,
PutOnShelfNumber = detail.PutOnShelfNumber,
}
};
await _splitPackingRecAppService.BatchInsertAsync(splitPackingRecEditInputs).ConfigureAwait(false);
detail.PackingCode = inventoryLabelDto.Code;
//库存移动
var transferLogEditInput = await BuildTransferLogsAsync(entity, detail, splitPackingRecEditInputs.First()).ConfigureAwait(false);
transferLogEditInputs.Add(transferLogEditInput);
}
//await _repository.UpdateAsync(entity).ConfigureAwait(false);
var dto = entity.ToObject<SeparationPackingNoteDTO>();
await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false);
return dto;
return new SeparationPackingNoteDTO();
}
/// <summary>
@ -201,48 +76,6 @@ public class SeparationPackingNoteAppService :
SeparationPackingNoteDetail detail,
SplitPackingRecEditInput splitPackingRecEditInput)
{
var fromLocationDto = await _locationAppService.GetByCodeAsync(entity.LocationCode).ConfigureAwait(false);
var toLocationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false);
var transferLogEditInput = new TransferLogEditInput
{
Worker = entity.Worker,
Qty = detail.Qty,
ItemCode = detail.ItemCode,
FromLocationCode = fromLocationDto.Code,
FromLocationErpCode = fromLocationDto.ErpLocationCode,
FromLocationArea = fromLocationDto.AreaCode,
FromLocationGroup = fromLocationDto.LocationGroupCode,
FromWarehouseCode = fromLocationDto.WarehouseCode,
ToLocationCode = toLocationDto.Code,
ToLocationErpCode = toLocationDto.ErpLocationCode,
ToLocationArea = toLocationDto.AreaCode,
ToLocationGroup = toLocationDto.LocationGroupCode,
ToWarehouseCode = toLocationDto.WarehouseCode,
ToPackingCode = splitPackingRecEditInput.ToPackingCode,
Remark = splitPackingRecEditInput.Remark,
ArriveDate = splitPackingRecEditInput.ArriveDate,
DocNumber = string.Empty,
ExpireDate = splitPackingRecEditInput.ExpireDate,
FromContainerCode = detail.ContainerCode,
FromLot = splitPackingRecEditInput.FromLot,
FromPackingCode = entity.PackingCode,
Uom = splitPackingRecEditInput.FromUom,
FromStatus = EnumInventoryStatus.OK,
JobNumber = string.Empty,
ItemDesc1 = splitPackingRecEditInput.ItemDesc1,
StdPackQty = splitPackingRecEditInput.FromStdPackQty,
TransType = EnumTransType.Transfer,
ToLot = splitPackingRecEditInput.ToLot,
ItemDesc2 = splitPackingRecEditInput.ItemDesc2,
ItemName = splitPackingRecEditInput.ItemName,
ProduceDate = splitPackingRecEditInput.ProduceDate,
SupplierBatch = splitPackingRecEditInput.SupplierBatch,
ToContainerCode = detail.ContainerCode,
ToStatus = EnumInventoryStatus.OK,
TransSubType = EnumTransSubType.Transfer_SplitPacking
};
return transferLogEditInput;
return new TransferLogEditInput();
}
}

Loading…
Cancel
Save