Browse Source

提交明细

Agv分支2024-11-19
赵新宇 4 months ago
parent
commit
cc9b28ac56
  1. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/CoatingIssueJobs/ICoatingIssueJobAppService.cs
  2. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/IInjectionIssueJobAppService.cs
  3. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/IKittingIssueJobAppService.cs
  4. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/SparePartIssueJobs/ISparePartIssueJobAppService.cs
  5. 326
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobOutputService.cs
  6. 601
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs
  7. 300
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs
  8. 315
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs
  9. 318
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs

4
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/CoatingIssueJobs/ICoatingIssueJobAppService.cs

@ -28,6 +28,6 @@ public interface ICoatingIssueJobAppService
Task<CoatingIssueJobDTO> GetByNumber2Async(string number); Task<CoatingIssueJobDTO> GetByNumber2Async(string number);
Task<CoatingIssueJobDTO> GetJobByPackingCodeAsync(string packingCode); Task<CoatingIssueJobDTO> GetJobByPackingCodeAsync(string packingCode);
Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request);
Task<ReusltObject> CallAgvAsync(CoatingIssueJobDTO input);
} }

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/InjectionJobs/IInjectionIssueJobAppService.cs

@ -30,6 +30,6 @@ public interface IInjectionIssueJobAppService
Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request); Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request);
Task<ReusltObject> CallAgvAsync(InjectionIssueJobDTO input);
} }

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/KittingIssueJobs/IKittingIssueJobAppService.cs

@ -28,5 +28,5 @@ public interface IKittingIssueJobAppService
Task<KittingIssueJobDTO> GetByNumber2Async(string number); Task<KittingIssueJobDTO> GetByNumber2Async(string number);
Task<KittingIssueJobDTO> GetJobByPackingCodeAsync(string packingCode); Task<KittingIssueJobDTO> GetJobByPackingCodeAsync(string packingCode);
Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request); Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request);
Task<ReusltObject> CallAgvAsync(KittingIssueJobDTO input);
} }

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/SparePartIssueJobs/ISparePartIssueJobAppService.cs

@ -29,5 +29,5 @@ public interface ISparePartIssueJobAppService
Task<SparePartIssueJobDTO> GetJobByPackingCodeAsync(string packingCode); Task<SparePartIssueJobDTO> GetJobByPackingCodeAsync(string packingCode);
Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request); Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request);
Task<ReusltObject> CallAgvAsync(SparePartIssueJobDTO input);
} }

326
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobOutputService.cs

@ -77,169 +77,169 @@ public class AgvJobOutputService : ApplicationService
/// <summary> ///// <summary>
/// 装配闻荫调用海康AGV接口测试 ///// 装配闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="id"></param> ///// <param name="id"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("assemble-test-callagv-id")] //[HttpPost("assemble-test-callagv-id")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Assemble_CallAgvAsync(Guid id) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Assemble_CallAgvAsync(Guid id)
{ //{
var jobdto= await _assembleIssueJobAppService.GetAsync(id).ConfigureAwait(false); // var jobdto= await _assembleIssueJobAppService.GetAsync(id).ConfigureAwait(false);
var ret= await _assembleIssueJobAppService.CallAgvAsync(jobdto,"123","321").ConfigureAwait(false); // var ret= await _assembleIssueJobAppService.CallAgvAsync(jobdto,"123","321").ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 装配闻荫调用海康AGV接口测试 ///// 装配闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="jobdto"></param> ///// <param name="jobdto"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("assemble-test-callagv1")] //[HttpPost("assemble-test-callagv1")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Assemble_CallAgvAsync1(AssembleIssueJobDTO jobdto) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Assemble_CallAgvAsync1(AssembleIssueJobDTO jobdto)
{ //{
var ret = await _assembleIssueJobAppService.CallAgvAsync(jobdto, "123", "321").ConfigureAwait(false); // var ret = await _assembleIssueJobAppService.CallAgvAsync(jobdto, "123", "321").ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 喷涂闻荫调用海康AGV接口测试 ///// 喷涂闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="id"></param> ///// <param name="id"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("coating-test-callagv-id")] //[HttpPost("coating-test-callagv-id")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Coating_CallAgvAsync(Guid id) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Coating_CallAgvAsync(Guid id)
{ //{
var jobdto= await _coatingIssueJobAppService.GetAsync(id).ConfigureAwait(false); // var jobdto= await _coatingIssueJobAppService.GetAsync(id).ConfigureAwait(false);
var ret = await _coatingIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _coatingIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 喷涂闻荫调用海康AGV接口测试 ///// 喷涂闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="jobdto"></param> ///// <param name="jobdto"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("coating-test-callagv")] //[HttpPost("coating-test-callagv")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Coating_CallAgvAsync(CoatingIssueJobDTO jobdto) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Coating_CallAgvAsync(CoatingIssueJobDTO jobdto)
{ //{
var ret = await _coatingIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _coatingIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 注塑闻荫调用海康AGV接口测试 ///// 注塑闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="jobdto"></param> ///// <param name="jobdto"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("injection-test-callagv-id")] //[HttpPost("injection-test-callagv-id")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Injection_CallAgvAsync(Guid id) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Injection_CallAgvAsync(Guid id)
{ //{
var jobdto = await _injectionIssueJobAppService.GetAsync(id).ConfigureAwait(false); // var jobdto = await _injectionIssueJobAppService.GetAsync(id).ConfigureAwait(false);
var ret = await _injectionIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _injectionIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 注塑闻荫调用海康AGV接口测试 ///// 注塑闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="jobdto"></param> ///// <param name="jobdto"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("injection-test-callagv")] //[HttpPost("injection-test-callagv")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Injection_CallAgvAsync1(InjectionIssueJobDTO jobdto) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Injection_CallAgvAsync1(InjectionIssueJobDTO jobdto)
{ //{
var ret = await _injectionIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _injectionIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 注塑闻荫调用海康AGV接口测试 ///// 注塑闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="id"></param> ///// <param name="id"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("kitting-test-callagv-id")] //[HttpPost("kitting-test-callagv-id")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Kitting_CallAgvAsync(Guid id) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Kitting_CallAgvAsync(Guid id)
{ //{
var jobdto=await _kittingIssueJobAppService.GetAsync(id).ConfigureAwait(false); // var jobdto=await _kittingIssueJobAppService.GetAsync(id).ConfigureAwait(false);
var ret = await _kittingIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _kittingIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// Kitting闻荫调用海康AGV接口测试 ///// Kitting闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="jobdto"></param> ///// <param name="jobdto"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("kitting-test-callagv")] //[HttpPost("kitting-test-callagv")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Kitting_CallAgvAsync1(KittingIssueJobDTO jobdto) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> Kitting_CallAgvAsync1(KittingIssueJobDTO jobdto)
{ //{
var ret = await _kittingIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _kittingIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 备件闻荫调用海康AGV接口测试 ///// 备件闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="id"></param> ///// <param name="id"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("sparePart-test-callagv-id")] //[HttpPost("sparePart-test-callagv-id")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> SparePart_CallAgvAsync(Guid id) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> SparePart_CallAgvAsync(Guid id)
{ //{
var jobdto = await _sparePartIssueJobAppService.GetAsync(id).ConfigureAwait(false); // var jobdto = await _sparePartIssueJobAppService.GetAsync(id).ConfigureAwait(false);
var ret = await _sparePartIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _sparePartIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 备件闻荫调用海康AGV接口测试 ///// 备件闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="jobdto"></param> ///// <param name="jobdto"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("sparePart-test-callagv")] //[HttpPost("sparePart-test-callagv")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> SparePart_CallAgvAsync1(SparePartIssueJobDTO jobdto) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> SparePart_CallAgvAsync1(SparePartIssueJobDTO jobdto)
{ //{
var ret = await _sparePartIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _sparePartIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 非生产领料闻荫调用海康AGV接口测试 ///// 非生产领料闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="id"></param> ///// <param name="id"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("unplannedIssue-test-callagv-id")] //[HttpPost("unplannedIssue-test-callagv-id")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> UnplannedIssue_CallAgvAsync(Guid id) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> UnplannedIssue_CallAgvAsync(Guid id)
{ //{
var jobdto = await _unplannedIssueJobAppService.GetAsync(id).ConfigureAwait(false); // var jobdto = await _unplannedIssueJobAppService.GetAsync(id).ConfigureAwait(false);
var ret = await _unplannedIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _unplannedIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 非生产领料闻荫调用海康AGV接口测试 ///// 非生产领料闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="jobdto"></param> ///// <param name="jobdto"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("unplannedIssue-test-callagv")] //[HttpPost("unplannedIssue-test-callagv")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> UnplannedIssue_CallAgvAsync1(UnplannedIssueJobDTO jobdto) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> UnplannedIssue_CallAgvAsync1(UnplannedIssueJobDTO jobdto)
{ //{
var ret = await _unplannedIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _unplannedIssueJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 非生产退料闻荫调用海康AGV接口测试 ///// 非生产退料闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="id"></param> ///// <param name="id"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("unplannedReceipt-test-callagv-id")] //[HttpPost("unplannedReceipt-test-callagv-id")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> UnplannedReceipt_CallAgvAsync(Guid id) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> UnplannedReceipt_CallAgvAsync(Guid id)
{ //{
var jobdto = await _unplannedReceiptJobAppService.GetAsync(id).ConfigureAwait(false); // var jobdto = await _unplannedReceiptJobAppService.GetAsync(id).ConfigureAwait(false);
var ret = await _unplannedReceiptJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _unplannedReceiptJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}
/// <summary> ///// <summary>
/// 非生产退料闻荫调用海康AGV接口测试 ///// 非生产退料闻荫调用海康AGV接口测试
/// </summary> ///// </summary>
/// <param name="jobdto"></param> ///// <param name="jobdto"></param>
/// <returns></returns> ///// <returns></returns>
[HttpPost("unplannedReceipt-test-callagv")] //[HttpPost("unplannedReceipt-test-callagv")]
public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> UnplannedReceipt_CallAgvAsync1(UnplannedReceiptJobDTO jobdto) //public async Task<Win_in.Sfs.Wms.Store.Application.Contracts.ReusltObject> UnplannedReceipt_CallAgvAsync1(UnplannedReceiptJobDTO jobdto)
{ //{
var ret = await _unplannedReceiptJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false); // var ret = await _unplannedReceiptJobAppService.CallAgvAsync(jobdto).ConfigureAwait(false);
return ret; // return ret;
} //}

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

@ -55,6 +55,7 @@ public class CoatingIssueJobAppService
private readonly IPostionLocationAppService _postionLocationAppService; private readonly IPostionLocationAppService _postionLocationAppService;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService; private readonly ITransferNoteAppService _transferNoteAppService;
private readonly ILocationDeliveryAppService _locationDeliveryAppService;
protected ICoatingIssueRequestAppService CoatingIssueRequestAppService => protected ICoatingIssueRequestAppService CoatingIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<ICoatingIssueRequestAppService>(); LazyServiceProvider.LazyGetRequiredService<ICoatingIssueRequestAppService>();
@ -68,7 +69,10 @@ public class CoatingIssueJobAppService
, IHttpClientFactory httpClientFactory , IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IOptions<AgvOptions> agvOptions , IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IOptions<AgvOptions> agvOptions
, UnitOfWorkManager unitOfWorkManager , UnitOfWorkManager unitOfWorkManager
, IPostionLocationAppService postionLocationAppService, IItemBasicAppService _itemBasicAppService, ITransferNoteAppService transferNoteAppService , IPostionLocationAppService postionLocationAppService, IItemBasicAppService _itemBasicAppService,
ITransferNoteAppService transferNoteAppService,
ILocationDeliveryAppService locationDeliveryAppService
) : base( ) : base(
repository, coatingIssueJobManager) repository, coatingIssueJobManager)
{ {
@ -86,6 +90,7 @@ public class CoatingIssueJobAppService
_agvOptions = agvOptions; _agvOptions = agvOptions;
_postionLocationAppService = postionLocationAppService; _postionLocationAppService = postionLocationAppService;
_transferLibRequestAppService= transferLibRequestAppService; _transferLibRequestAppService= transferLibRequestAppService;
_locationDeliveryAppService= locationDeliveryAppService;
} }
[HttpPost("get-by-number-2")] [HttpPost("get-by-number-2")]
@ -102,28 +107,66 @@ public class CoatingIssueJobAppService
foreach (var input in inputs) foreach (var input in inputs)
{ {
await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false); await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false);
await CheckDimensionalStorehouseAsync(input).ConfigureAwait(false); //如果是立库 就给直接承接了
var dimensionalStorehouseflag = await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false);
if (dimensionalStorehouseflag)
{
input.IsClaims = true;
input.ClaimsUserId = string.IsNullOrEmpty(_options.Value.StereosUser)
? "LYF"
: _options.Value.StereosUser;
input.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword)
? "LYF"
: _options.Value.StereosPassword;
}
if (dimensionalStorehouseflag == false)
{
//如果是Agv
var agvFlag = await UpdateJobStatusWaitByAgvAsync(input).ConfigureAwait(false);
if (agvFlag)
{
input.IsClaims = true;
input.ClaimsUserId = string.IsNullOrEmpty(_options.Value.StereosUser)
? "AGV"
: _options.Value.StereosUser;
input.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword)
? "AGV"
: _options.Value.StereosPassword;
}
}
} }
var coatingIssueJobDtos = await base.CreateManyAsync(inputs).ConfigureAwait(false); var assembleIssueJobDtos = await base.CreateManyAsync(inputs).ConfigureAwait(false);
foreach (var coatingIssueJobDto in coatingIssueJobDtos) foreach (var assembleIssueJobDto in assembleIssueJobDtos)
{ {
await DoingDimensionalStorehouseAsync(coatingIssueJobDto).ConfigureAwait(false); await DoingDimensionalStorehouseAsync(assembleIssueJobDto).ConfigureAwait(false);
var firstDetail = assembleIssueJobDto.Details.First();
await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false);
} }
return coatingIssueJobDtos; return assembleIssueJobDtos;
} }
[HttpPost("")] [HttpPost("")]
public override async Task<CoatingIssueJobDTO> CreateAsync(CoatingIssueJobEditInput input) public override async Task<CoatingIssueJobDTO> CreateAsync(CoatingIssueJobEditInput input)
{ {
await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false); await CheckMinRowAndSetStatusAsync(input).ConfigureAwait(false);
await CheckDimensionalStorehouseAsync(input).ConfigureAwait(false); var flagDimensionalStorehouse = await UpdateJobStatusWaitByDimensionalStorehouseAsync(input).ConfigureAwait(false);
if (flagDimensionalStorehouse == false)
{
await UpdateJobStatusWaitByAgvAsync(input).ConfigureAwait(false);
}
var coatingIssueJobDto = await base.CreateAsync(input).ConfigureAwait(false); var assembleIssueJobDto = await base.CreateAsync(input).ConfigureAwait(false);
await DoingDimensionalStorehouseAsync(coatingIssueJobDto).ConfigureAwait(false); await DoingDimensionalStorehouseAsync(assembleIssueJobDto).ConfigureAwait(false);
if (flagDimensionalStorehouse == false)
{
var firstDetail = assembleIssueJobDto.Details.First();
await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false);
}
return coatingIssueJobDto; return assembleIssueJobDto;
} }
[HttpPost("invalid")] [HttpPost("invalid")]
@ -214,7 +257,23 @@ public class CoatingIssueJobAppService
jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch; jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch;
jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode; jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode;
await _repository.UpdateAsync(job).ConfigureAwait(false); var jobDto = ObjectMapper.Map<CoatingIssueJob, CoatingIssueJobDTO>(job);
var isDoingAgv = await DoingAgvAsync(jobDto, jobDetail.TransferLibToLocationCode, jobDetail.RecommendToLocationCode).ConfigureAwait(false);
if (isDoingAgv)
{
job.JobStatus = EnumJobStatus.WaitAgv;
job.IsClaims = true;
job.ClaimsUserId = string.IsNullOrEmpty(_options.Value.StereosUser)
? "AGV"
: _options.Value.StereosUser;
job.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword)
? "AGV"
: _options.Value.StereosPassword;
}
job = await _repository.UpdateAsync(job).ConfigureAwait(false);
} }
/// <summary> /// <summary>
@ -475,6 +534,50 @@ public class CoatingIssueJobAppService
#region 立库 #region 立库
/// <summary>
/// 调用立体库
/// </summary>
/// <param name="CoatingIssueJobDto"></param>
/// <returns></returns>
private async Task DoingDimensionalStorehouseAsync(CoatingIssueJobDTO CoatingIssueJobDto)
{
var jobDetailInputdetail = CoatingIssueJobDto.Details.FirstOrDefault();
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode)
.ConfigureAwait(false);
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse)
{
//TODO 立体库
var ret = await SyncIssueJobStereoAsync(new List<CoatingIssueJobDTO> { CoatingIssueJobDto },
jobDetailInputdetail.RecommendToLocationCode, CoatingIssueJobDto.Id).ConfigureAwait(false);
if (ret.Code != 0)
{
throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}");
}
}
}
/// <summary>
/// 判断是不是在立体库
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private async Task<bool> UpdateJobStatusWaitByDimensionalStorehouseAsync(CoatingIssueJobEditInput input)
{
var jobDetailInputdetail = input.Details.FirstOrDefault();
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode)
.ConfigureAwait(false);
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse)
{
input.JobStatus = EnumJobStatus.Wait;
return true;
}
return false;
}
/// <summary> /// <summary>
/// 立体库同步 /// 立体库同步
/// </summary> /// </summary>
@ -482,27 +585,29 @@ public class CoatingIssueJobAppService
/// <param name="pLoc"></param> /// <param name="pLoc"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("sync-issue-job-stereo")] [HttpPost("sync-issue-job-stereo")]
public async Task<ReusltObject> SyncIssueJobStereoAsync(List<CoatingIssueJobDTO> input, string pLoc) public async Task<ReusltObject> SyncIssueJobStereoAsync(List<CoatingIssueJobDTO> input, string pLoc, Guid uid)
{ {
var ret = new ReusltObject(); var ret = new ReusltObject();
ret.Code = int.Parse(GaoTongResultStatus.Success); ret.Code = 0;
ret.Message = "操作成功"; ret.Message = "操作成功";
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd");
using var unitOfWork = _unitOfWorkManager.Begin();
try try
{ {
var IssueJobToRestoDetailDTOs = new List<IssueJobToRestoDetailDTO>(); var IssueJobToRestoDetailDTOs = new List<IssueJobToRestoDetailDTO>();
var main = new IssueJobToRestoDTO(); var main = new IssueJobToRestoDTO();
main.OperatorName = CurrentUser.UserName; main.Uuid = uid;
main.OperatorName = string.IsNullOrEmpty(CurrentUser.UserName) ? "admin" : CurrentUser.UserName;
foreach (var job in input) foreach (var job in input)
{ {
foreach (var jobitem in job.Details) foreach (var jobitem in job.Details)
{ {
IssueJobToRestoDetailDTOs.Add(new IssueJobToRestoDetailDTO IssueJobToRestoDetailDTOs.Add(new IssueJobToRestoDetailDTO
{ {
Count = jobitem.HandledToQty, Count = jobitem.RecommendFromQty,
ProductNo = jobitem.ItemCode, ProductNo = jobitem.ItemCode,
NeedSite = pLoc, NeedSite = pLoc,
WorkNo = job.Number, WorkNo = job.CoatingRequestNumber,
TaskNo = job.Number TaskNo = job.Number
}); });
} }
@ -513,26 +618,31 @@ public class CoatingIssueJobAppService
#if DEBUG #if DEBUG
var json = JsonSerializer.Serialize(main); var json = JsonSerializer.Serialize(main);
_options.Value.Address = "http://7e42682n64.goho.co:21171/"; //测试地址 _options.Value.Address = "http://localhost:59094/"; //测试地址
_options.Value.Token = ""; //测试token _options.Value.Token = ""; //测试token
_options.Value.UserName = ""; //测试用户名 _options.Value.UserName = ""; //测试用户名
_options.Value.Password = ""; //测试密码 _options.Value.Password = ""; //测试密码
_options.Value.Path = "zozocnApi/custom/receiveProductionPlan"; //测试密码
#endif #endif
//var json = JsonSerializer.Serialize(main); //var json = JsonSerializer.Serialize(main);
_options.Value.Address = "http://7e42682n64.goho.co:21171/"; //测试地址 _options.Value.Address = string.IsNullOrEmpty(_options.Value.Address)
_options.Value.Token = ""; //测试token ? "http://7e42682n64.goho.co:21171/"
_options.Value.UserName = ""; //测试用户名 : _options.Value.Address; //测试地址
_options.Value.Password = ""; //测试密码 _options.Value.Token =
_options.Value.Path = "zozocnApi/custom/receiveProductionPlan"; //测试密码 string.IsNullOrEmpty(_options.Value.Token) ? string.Empty : _options.Value.Token; //测试token
_options.Value.UserName =
_logger.LogInformation(System.Text.Json.JsonSerializer.Serialize(_options)); string.IsNullOrEmpty(_options.Value.UserName) ? "" : _options.Value.UserName; //测试用户名
_options.Value.Password =
string.IsNullOrEmpty(_options.Value.Password) ? "" : _options.Value.Password; //测试密码
_options.Value.Path = string.IsNullOrEmpty(_options.Value.Path)
? "zozocnApi/custom/receiveProductionPlan"
: _options.Value.Path; //测试密码
_logger.LogInformation(JsonSerializer.Serialize(_options));
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{JsonSerializer.Serialize(main)}");
if (!string.IsNullOrEmpty(_options.Value.Token)) if (!string.IsNullOrEmpty(_options.Value.Token))
@ -550,24 +660,17 @@ public class CoatingIssueJobAppService
} }
var client = new IssueJobToRestoClient(_options.Value.Address, httpclient, _options.Value.Path); var client = new IssueJobToRestoClient(_options.Value.Address, httpclient, _options.Value.Path);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"标志{flag}开始调用高通WMS:传递值{System.Text.Json.JsonSerializer.Serialize(main)}");
//_logger.LogInformation(MakeGrid($"标志{flag}开始调用高通WMS明细", main.Details.ToList()));
ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false); ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false);
_logger.LogInformation($"标志{flag}调用高通WMS:返回值{ret}"); _logger.LogInformation($"标志{flag}调用高通WMS:返回值{JsonSerializer.Serialize(ret)}");
} }
catch (Exception ex) catch (Exception ex)
{ {
ret = new ReusltObject(); ret = new ReusltObject();
ret.Code = int.Parse(GaoTongResultStatus.Failure); ret.Code = 1;
ret.Message = ex.Message; ret.Message = ex.Message;
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd");
await unitOfWork.RollbackAsync().ConfigureAwait(false);
} }
return ret; return ret;
@ -576,11 +679,19 @@ public class CoatingIssueJobAppService
[HttpPost("receive-issue-job-stereo")] [HttpPost("receive-issue-job-stereo")]
public virtual async Task<ReusltObject> SyncReciveIssueJobStereoAsync(IssueRequestFromRestoDTO input) public virtual async Task<ReusltObject> SyncReciveIssueJobStereoAsync(IssueRequestFromRestoDTO input)
{ {
#if DEBUG
var json = JsonSerializer.Serialize(input); var json = JsonSerializer.Serialize(input);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json);
#if DEBUG
#endif #endif
var errors = new List<string>(); var errors = new List<string>();
var ret = new ReusltObject { Code = 1, OperateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Message = "操作成功" }; var ret = new ReusltObject
{
Code = int.Parse(GaoTongResultStatus.Success),
OperateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
Message = "操作成功"
};
using var unitOfWork = _unitOfWorkManager.Begin();
try try
{ {
if (input.Jobs.Count > 0) if (input.Jobs.Count > 0)
@ -588,40 +699,102 @@ public class CoatingIssueJobAppService
var jobs = input.Jobs; var jobs = input.Jobs;
var numbers = jobs.Select(p => p.JobNumber); var numbers = jobs.Select(p => p.JobNumber);
var query = _repository.WithDetails() var query = _repository.WithDetails()
.Where(p => numbers.Contains(p.Number)); .Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done);
var entities = query.ToList(); var entities = query.ToList();
var dtos = ObjectMapper.Map<List<CoatingIssueJob>, List<CoatingIssueJobDTO>>(entities);
if (entities.Count == 0) if (entities.Count == 0)
{ {
errors.Add($"任务号{string.Join(",", numbers)}不存在!"); errors.Add($"任务号{string.Join(",", numbers)}不存在!");
} }
if (input.Jobs.Count == entities.Count)
var dtos = ObjectMapper.Map<List<CoatingIssueJob>, List<CoatingIssueJobDTO>>(entities);
if (input.Jobs.Count != entities.Count)
{ {
errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n"); errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n");
} }
foreach (var itm in dtos) foreach (var itm in dtos)
{ {
var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number);
var itmDetails = itm.Details.ToList(); var itmDetails = itm.Details.ToList();
var details = new List<CoatingIssueJobDetailDTO>(); var details = new List<CoatingIssueJobDetailDTO>();
foreach (var detail in first.Details) foreach (var detail in first.Details)
{ {
var fromloc = await _locationAppService.GetByCodeAsync(detail.FromLocationCode)
.ConfigureAwait(false);
if (fromloc == null)
{
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); var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.ItemCode);
if (entity == null)
{
errors.Add($"物料号{detail.ItemCode}不在任务明细内!");
}
var dto = new CoatingIssueJobDetailDTO(); var dto = new CoatingIssueJobDetailDTO();
dto.HandledFromLocationCode = entity.HandledFromLocationCode; dto.InjectFrom(entity);
dto.HandledToLocationCode = entity.HandledToLocationCode;
dto.ItemCode = detail.ItemCode; /*
dto.RecommendFromQty = detail.Qty; dto.RecommendFromQty = detail.Qty;
dto.RecommendToQty = detail.Qty; dto.RecommendToQty = detail.Qty;
dto.HandledFromQty = detail.Qty; dto.HandledFromQty = detail.Qty;
dto.HandledToQty = detail.Qty; dto.HandledToQty = detail.Qty;
dto.Status = entity.Status; */
//dto.RecommendFromQty = detail.Qty;
//dto.RecommendToQty = detail.Qty;
//dto.HandledFromQty = detail.Qty;
//dto.HandledToQty = detail.Qty;
dto.HandledToLocationCode = toloc.Code;
dto.HandledToLocationGroup = toloc.LocationGroupCode;
dto.HandledToLocationArea = toloc.AreaCode;
dto.HandledToLocationErpCode = toloc.ErpLocationCode;
dto.HandledToLot = string.Empty;
dto.HandledToWarehouseCode = toloc.WarehouseCode;
dto.HandledToQty = detail.Qty;
dto.HandledToLot = string.Empty;
dto.HandledToPackingCode = string.Empty;
dto.HandledFromWarehouseCode = fromloc.WarehouseCode;
dto.HandledFromLocationCode = fromloc.Code;
dto.HandledFromLocationGroup = fromloc.LocationGroupCode;
dto.HandledFromLocationArea = fromloc.AreaCode;
dto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
dto.HandledFromQty = detail.Qty;
dto.HandledFromLot = string.Empty;
dto.HandledFromPackingCode = string.Empty;
details.Add(dto); details.Add(dto);
await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
} }
if (errors.Count > 0)
{
ret = new ReusltObject
{
Code = int.Parse(GaoTongResultStatus.Failure),
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"),
Message = string.Join(",", errors.ToArray()),
Data = json
};
}
itm.Worker = "LITK";
itm.Details = details; itm.Details = details;
await CompleteAsync(itm.Id, itm).ConfigureAwait(false); // await CompleteAsync(itm.Id, itm).ConfigureAwait(false);
_logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json + "立体库任务完成");
} }
} }
else else
@ -635,8 +808,10 @@ public class CoatingIssueJobAppService
{ {
Code = int.Parse(GaoTongResultStatus.Failure), Code = int.Parse(GaoTongResultStatus.Failure),
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), OperateTime = DateTime.Now.ToString("yyyy-MM-dd"),
Message = ex.Message Message = ex.Message,
Data = json
}; };
await unitOfWork.RollbackAsync();
return ret; return ret;
} }
@ -646,7 +821,8 @@ public class CoatingIssueJobAppService
{ {
Code = int.Parse(GaoTongResultStatus.Failure), Code = int.Parse(GaoTongResultStatus.Failure),
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), OperateTime = DateTime.Now.ToString("yyyy-MM-dd"),
Message = string.Join(",", errors.ToArray()) Message = string.Join(",", errors.ToArray()),
Data = json
}; };
} }
@ -655,6 +831,7 @@ public class CoatingIssueJobAppService
#endregion #endregion
#region 私有 #region 私有
/// <summary> /// <summary>
@ -739,34 +916,7 @@ public class CoatingIssueJobAppService
} }
} }
/// <summary>
/// 调用立体库
/// </summary>
/// <param name="coatingIssueJobDto"></param>
/// <returns></returns>
private async Task DoingDimensionalStorehouseAsync(CoatingIssueJobDTO coatingIssueJobDto)
{
var jobDetailInputdetail = coatingIssueJobDto.Details.FirstOrDefault();
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode)
.ConfigureAwait(false);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"立体库任务检查开始{flag}");
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse)
{
_logger.LogInformation($"立体库任务开始标记{flag}");
//TODO 立体库
var ret = await SyncIssueJobStereoAsync(new List<CoatingIssueJobDTO> { coatingIssueJobDto },
loctionDto.Code).ConfigureAwait(false);
_logger.LogInformation($"立体库任务结束标记{flag},返回值{ret}");
if (ret.Code != 0)
{
throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}");
}
}
}
/// <summary> /// <summary>
/// 修改当前任务状态 和 该任务的请求状态 /// 修改当前任务状态 和 该任务的请求状态
@ -826,21 +976,77 @@ public class CoatingIssueJobAppService
handledToQty).ConfigureAwait(false); handledToQty).ConfigureAwait(false);
} }
/// <summary>
/// 调用AGV
/// </summary>
/// <param name="assembleIssueJobDto"></param>
/// <param name="fromLocationCode"></param>
/// <param name="toLocationCode"></param>
/// <returns></returns>
private async Task<bool> DoingAgvAsync(CoatingIssueJobDTO 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 DEBUG
return true;
#endif
if (ret.Code != 0)
{
throw new UserFriendlyException($"调用AGV不成功!原因:{ret.Message}");
}
}
return false;
}
/// <summary>
/// 判断是不是有Agv
/// </summary>
/// <param name="input"></param>
/// <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;
}
/// <summary> /// <summary>
/// 调用 Agv 接口 /// 调用 Agv 接口
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <param name="pLoc"></param> /// <param name="beginPosition"></param>
/// <param name="uid"></param> /// <param name="endPosition"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("call-agv")] [HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(CoatingIssueJobDTO input) public async Task<ReusltObject> CallAgvAsync(CoatingIssueJobDTO input, string beginPosition, string endPosition)
{ {
var res = new ReusltObject(); var res = new ReusltObject();
List<string> errors = new List<string>(); List<string> errors = new List<string>();
List<string> successList = new List<string>(); List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input).ConfigureAwait(false); var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false);
if (jobres.Code != "0") if (jobres.Code != "0")
{ {
_logger.LogInformation(jobres.Message); _logger.LogInformation(jobres.Message);
@ -868,170 +1074,74 @@ public class CoatingIssueJobAppService
[HttpPost("call-back-agv")] [HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request) public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request)
{ {
var json = JsonSerializer.Serialize(request);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.CoatingRequestNumber,
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{
if (request.Data.Count > 0)
{
var jobs = request.Data;
var numbers = jobs.Select(p => p.OrderNum);
var query = _repository.WithDetails()
.Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done);
var entities = query.ToList();
if (entities.Count == 0)
{
errors.Add($"任务号{string.Join(",", numbers)}不存在!");
}
var dtos = ObjectMapper.Map<List<CoatingIssueJob>, List<CoatingIssueJobDTO>>(entities);
foreach (var itm in dtos) var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
{ var dto = ObjectMapper.Map<CoatingIssueJob, CoatingIssueJobDTO>(entity);
var arys = jobs.Where(p => p.OrderNum == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<CoatingIssueJobDetailDTO>();
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) foreach (var detail in entity.Details)
.ConfigureAwait(false); {
if (toloc == null) var detailDto = new CoatingIssueJobDetailDTO();
{ if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
errors.Add($"结束点{detail.EndPosition}库位没查到"); {
} //库移的最终目标 挪到 推荐的目标
var fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false);
LocationDTO tolocation = null; var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
if (toloc != null) detailDto.InjectFrom(detail);
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false); detailDto.HandledToLocationCode = toloc.Code;
} detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
if (tolocation == null) detailDto.HandledToLocationArea = toloc.AreaCode;
{ detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
errors.Add($"结束点{detail.EndPosition}库位没查到"); detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
} detailDto.HandledToQty = request.Data.First().MatQty;
detailDto.HandledToLot = detail.TransferLibToLot;
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false); detailDto.HandledToPackingCode = detail.TransferLibToPackingCode;
if (item == null) detailDto.HandledFromLocationCode = fromloc.Code;
{ detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
errors.Add($"零件号{detail.MatCode}不存在!"); detailDto.HandledFromLocationArea = fromloc.AreaCode;
} detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode); detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
if (entity == null) detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
{ detailDto.HandledFromLot = detail.TransferLibToLot;
errors.Add($"零件号{detail.MatCode}不在任务明细内!"); detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode;
}
if (errors.Count > 0)
{
await unitOfWork.RollbackAsync().ConfigureAwait(false);
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
var dto = new CoatingIssueJobDetailDTO();
dto.InjectFrom(entity);
dto.HandledToLocationCode = tolocation.Code;
dto.HandledToLocationGroup = tolocation.LocationGroupCode;
dto.HandledToLocationArea = tolocation.AreaCode;
dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
dto.HandledToWarehouseCode = tolocation.WarehouseCode;
dto.HandledToQty = detail.MatQty;
dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledToPackingCode = string.Empty;
dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
dto.HandledFromLocationCode = fromlocation.Code;
dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
dto.HandledFromLocationArea = fromlocation.AreaCode;
dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
dto.HandledFromQty = detail.MatQty;
dto.HandledFromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
await unitOfWork.RollbackAsync().ConfigureAwait(false);
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
} }
else else
{ {
errors.Add("Agv确认单据里无数据! \n"); var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
detailDto.InjectFrom(detail);
detailDto.HandledToLocationCode = toloc.Code;
detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
detailDto.HandledToLocationArea = toloc.AreaCode;
detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
detailDto.HandledToQty = request.Data.First().MatQty;
detailDto.HandledToLot = detail.RecommendToLot;
detailDto.HandledToPackingCode = detail.RecommendToPackingCode;
detailDto.HandledFromLocationCode = fromloc.Code;
detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
detailDto.HandledFromLocationArea = fromloc.AreaCode;
detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
detailDto.HandledFromLot = detail.RecommendToLot;
detailDto.HandledFromPackingCode = detail.RecommendToPackingCode;
} }
}
catch (Exception ex) await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.CoatingRequestNumber,
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
return ret;
} }
if (errors.Count > 0) return new AgvResultObject
{ {
ret = new AgvResultObject Code = "0",
{ Message = "OK",
Code = "-1", ReqCode = "",
Message = string.Join(",", errors.ToArray()), };
ReqCode = job.CoatingRequestNumber
};
}
return ret;
} }
/// <summary> /// <summary>
@ -1188,12 +1298,12 @@ public class CoatingIssueJobAppService
/// <summary> /// <summary>
/// 调用Agv接口实现 /// 调用Agv接口实现
/// </summary> /// </summary>
/// <param name="job"></param> /// <param name="job"></param>
/// <returns></returns> /// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(CoatingIssueJobDTO job) private async Task<AgvResultObject> SendInterFaceAsync(CoatingIssueJobDTO job, string beginPosition, string endPosition)
{ {
#if DEBUG #if DEBUG
@ -1225,8 +1335,9 @@ public class CoatingIssueJobAppService
request.MatQty = first.HandledToQty; request.MatQty = first.HandledToQty;
request.OrderNum = job.Number; request.OrderNum = job.Number;
request.OrderType = EnumJobType.CoatingIssueJob.ToString(); request.OrderType = EnumJobType.CoatingIssueJob.ToString();
request.BeginPosition = beginPosition;
request.EndPosition = endPosition;
var httpclient = _httpClientFactory.CreateClient(); var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
? "http://7e42682n64.goho.co:21171/" ? "http://7e42682n64.goho.co:21171/"

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

@ -53,6 +53,7 @@ public class InjectionIssueJobAppService
private readonly ILogger<InjectionIssueJobAppService> _logger; private readonly ILogger<InjectionIssueJobAppService> _logger;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService; private readonly ITransferNoteAppService _transferNoteAppService;
private readonly ILocationDeliveryAppService _locationDeliveryAppService;
protected IInjectionIssueRequestAppService InjectionIssueRequestAppService => protected IInjectionIssueRequestAppService InjectionIssueRequestAppService =>
@ -64,7 +65,7 @@ public class InjectionIssueJobAppService
ILocationAppService locationAppService, ILocationAppService locationAppService,
IInjectionIssueNoteAppService injectionIssueNoteAppService, IExpectOutAppService expectOutAppService IInjectionIssueNoteAppService injectionIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory , IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser , IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, ILocationDeliveryAppService locationDeliveryAppService
, IOptions<AgvOptions> agvOptions , IOptions<AgvOptions> agvOptions
, UnitOfWorkManager unitOfWorkManager , UnitOfWorkManager unitOfWorkManager
, IItemBasicAppService itemBasicAppService , IItemBasicAppService itemBasicAppService
@ -84,6 +85,7 @@ public class InjectionIssueJobAppService
_agvOptions = agvOptions; _agvOptions = agvOptions;
_logger = logger; _logger = logger;
_itemBasicAppService = itemBasicAppService; _itemBasicAppService = itemBasicAppService;
_locationDeliveryAppService = locationDeliveryAppService;
} }
[HttpPost("get-by-number-2")] [HttpPost("get-by-number-2")]
public async Task<InjectionIssueJobDTO> GetByNumber2Async(string number) public async Task<InjectionIssueJobDTO> GetByNumber2Async(string number)
@ -106,6 +108,8 @@ public class InjectionIssueJobAppService
foreach (var injectionIssueJobDto in injectionIssueJobDtos) foreach (var injectionIssueJobDto in injectionIssueJobDtos)
{ {
await DoingDimensionalStorehouseAsync(injectionIssueJobDto).ConfigureAwait(false); await DoingDimensionalStorehouseAsync(injectionIssueJobDto).ConfigureAwait(false);
var firstDetail = injectionIssueJobDto.Details.First();
await DoingAgvAsync(injectionIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false);
} }
return injectionIssueJobDtos; return injectionIssueJobDtos;
@ -119,6 +123,8 @@ public class InjectionIssueJobAppService
var injectionIssueJobDto = await base.CreateAsync(input).ConfigureAwait(false); var injectionIssueJobDto = await base.CreateAsync(input).ConfigureAwait(false);
await DoingDimensionalStorehouseAsync(injectionIssueJobDto).ConfigureAwait(false); await DoingDimensionalStorehouseAsync(injectionIssueJobDto).ConfigureAwait(false);
var firstDetail = injectionIssueJobDto.Details.First();
await DoingAgvAsync(injectionIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false);
return injectionIssueJobDto; return injectionIssueJobDto;
} }
@ -765,23 +771,80 @@ public class InjectionIssueJobAppService
injectionIssueJobDetailDto.Status, injectionIssueJobDetailDto.HandledToLot, injectionIssueJobDetailDto.Status, injectionIssueJobDetailDto.HandledToLot,
handledToQty).ConfigureAwait(false); handledToQty).ConfigureAwait(false);
} }
#region Agv
/// <summary>
/// 调用AGV
/// </summary>
/// <param name="InjectionIssueJobDto"></param>
/// <param name="fromLocationCode"></param>
/// <param name="toLocationCode"></param>
/// <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}");
}
}
return false;
}
/// <summary>
/// 判断是不是有Agv
/// </summary>
/// <param name="input"></param>
/// <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;
}
/// <summary> /// <summary>
/// 调用 Agv 接口 /// 调用 Agv 接口
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <param name="pLoc"></param> /// <param name="beginPosition"></param>
/// <param name="uid"></param> /// <param name="endPosition"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("call-agv")] [HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(InjectionIssueJobDTO input) public async Task<ReusltObject> CallAgvAsync(InjectionIssueJobDTO input, string beginPosition, string endPosition)
{ {
var res = new ReusltObject(); var res = new ReusltObject();
List<string> errors = new List<string>(); List<string> errors = new List<string>();
List<string> successList = new List<string>(); List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input).ConfigureAwait(false); var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false);
if (jobres.Code != "0") if (jobres.Code != "0")
{ {
_logger.LogInformation(jobres.Message); _logger.LogInformation(jobres.Message);
@ -809,169 +872,75 @@ public class InjectionIssueJobAppService
[HttpPost("call-back-agv")] [HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request) public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request)
{ {
var json = JsonSerializer.Serialize(request); var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); var dto = ObjectMapper.Map<InjectionIssueJob, InjectionIssueJobDTO>(entity);
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG foreach (var detail in entity.Details)
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.InjectionRequestNumber,
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{ {
if (request.Data.Count > 0) var detailDto = new InjectionIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{ {
var jobs = request.Data; //库移的最终目标 挪到 推荐的目标
var numbers = jobs.Select(p => p.OrderNum); var fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false);
var query = _repository.WithDetails() var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
.Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done);
var entities = query.ToList(); detailDto.InjectFrom(detail);
if (entities.Count == 0)
{ detailDto.HandledToLocationCode = toloc.Code;
errors.Add($"任务号{string.Join(",", numbers)}不存在!"); detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
} detailDto.HandledToLocationArea = toloc.AreaCode;
var dtos = ObjectMapper.Map<List<InjectionIssueJob>, List<InjectionIssueJobDTO>>(entities); detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
foreach (var itm in dtos) detailDto.HandledToQty = request.Data.First().MatQty;
{ detailDto.HandledToLot = detail.TransferLibToLot;
var arys = jobs.Where(p => p.OrderNum == itm.Number); detailDto.HandledToPackingCode = detail.TransferLibToPackingCode;
var itmDetails = itm.Details.ToList();
var details = new List<InjectionIssueJobDetailDTO>(); detailDto.HandledFromLocationCode = fromloc.Code;
foreach (var detail in arys) detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
{ detailDto.HandledFromLocationArea = fromloc.AreaCode;
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
if (fromloc == null) detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
{ detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
errors.Add($"来源起始点{detail.BeginPosition}没查到"); detailDto.HandledFromLot = detail.TransferLibToLot;
} detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode;
LocationDTO fromlocation = null;
if (fromloc != null)
{
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.LocationCode).ConfigureAwait(false);
}
if (fromlocation == null)
{
errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
}
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
LocationDTO tolocation = null;
if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}不存在!");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
if (entity == null)
{
errors.Add($"零件号{detail.MatCode}不在任务明细内!");
}
if (errors.Count > 0)
{
await unitOfWork.RollbackAsync().ConfigureAwait(false);
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
var dto = new InjectionIssueJobDetailDTO();
dto.InjectFrom(entity);
dto.HandledToLocationCode = tolocation.Code;
dto.HandledToLocationGroup = tolocation.LocationGroupCode;
dto.HandledToLocationArea = tolocation.AreaCode;
dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
dto.HandledToWarehouseCode = tolocation.WarehouseCode;
dto.HandledToQty = detail.MatQty;
dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledToPackingCode = string.Empty;
dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
dto.HandledFromLocationCode = fromlocation.Code;
dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
dto.HandledFromLocationArea = fromlocation.AreaCode;
dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
dto.HandledFromQty = detail.MatQty;
dto.HandledFromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
await unitOfWork.RollbackAsync().ConfigureAwait(false);
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
} }
else else
{ {
errors.Add("Agv确认单据里无数据! \n"); var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
detailDto.InjectFrom(detail);
detailDto.HandledToLocationCode = toloc.Code;
detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
detailDto.HandledToLocationArea = toloc.AreaCode;
detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
detailDto.HandledToQty = request.Data.First().MatQty;
detailDto.HandledToLot = detail.RecommendToLot;
detailDto.HandledToPackingCode = detail.RecommendToPackingCode;
detailDto.HandledFromLocationCode = fromloc.Code;
detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
detailDto.HandledFromLocationArea = fromloc.AreaCode;
detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
detailDto.HandledFromLot = detail.RecommendToLot;
detailDto.HandledFromPackingCode = detail.RecommendToPackingCode;
} }
}
catch (Exception ex) await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.InjectionRequestNumber,
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
return ret;
} }
if (errors.Count > 0) return new AgvResultObject
{ {
ret = new AgvResultObject Code = "0",
{ Message = "OK",
Code = "-1", ReqCode = "",
Message = string.Join(",", errors.ToArray()), };
ReqCode = job.InjectionRequestNumber
};
}
return ret;
} }
/// <summary> /// <summary>
/// Agv 回库 接口 /// Agv 回库 接口
/// </summary> /// </summary>
@ -1121,15 +1090,14 @@ public class InjectionIssueJobAppService
} }
/// <summary> /// <summary>
/// 调用Agv接口实现 /// 调用Agv接口实现
/// </summary> /// </summary>
/// <param name="job"></param> /// <param name="job"></param>
/// <param name="beginPosition"></param>
/// <param name="endPosition"></param>
/// <returns></returns> /// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(InjectionIssueJobDTO job) private async Task<AgvResultObject> SendInterFaceAsync(InjectionIssueJobDTO job, string beginPosition, string endPosition)
{ {
#if DEBUG #if DEBUG
@ -1153,15 +1121,14 @@ public class InjectionIssueJobAppService
{ {
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
} }
var first = job.Details.FirstOrDefault(); var first = job.Details.FirstOrDefault();
var request = new AgvRequest(); var request = new AgvRequest();
request.MatCode = first.ItemCode; request.MatCode = first.ItemCode;
request.MatQty = first.HandledToQty; request.MatQty = first.HandledToQty;
request.OrderNum = job.Number; request.OrderNum = job.Number;
request.OrderType = EnumJobType.InjectionIssueJob.ToString(); request.OrderType = EnumJobType.InjectionIssueJob.ToString();
request.BeginPosition = beginPosition;
request.EndPosition = endPosition;
var httpclient = _httpClientFactory.CreateClient(); var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
@ -1208,6 +1175,7 @@ public class InjectionIssueJobAppService
return ret; return ret;
} }
#endregion

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

@ -54,6 +54,7 @@ public class KittingIssueJobAppService
private readonly ILogger<KittingIssueJobAppService> _logger; private readonly ILogger<KittingIssueJobAppService> _logger;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService; private readonly ITransferNoteAppService _transferNoteAppService;
private readonly ILocationDeliveryAppService _locationDeliveryAppService;
protected IKittingIssueRequestAppService KittingIssueRequestAppService => protected IKittingIssueRequestAppService KittingIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IKittingIssueRequestAppService>(); LazyServiceProvider.LazyGetRequiredService<IKittingIssueRequestAppService>();
@ -67,7 +68,7 @@ public class KittingIssueJobAppService
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IItemBasicAppService itemBasicAppService , IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IItemBasicAppService itemBasicAppService
,IOptions<AgvOptions> agvOptions, ,IOptions<AgvOptions> agvOptions,
ILocationDeliveryAppService locationDeliveryAppService,
UnitOfWorkManager unitOfWorkManager UnitOfWorkManager unitOfWorkManager
) : base( ) : base(
repository, kittingIssueJobManager) repository, kittingIssueJobManager)
@ -85,6 +86,7 @@ public class KittingIssueJobAppService
_unitOfWorkManager = unitOfWorkManager; _unitOfWorkManager = unitOfWorkManager;
_agvOptions = agvOptions; _agvOptions = agvOptions;
_itemBasicAppService = itemBasicAppService; _itemBasicAppService = itemBasicAppService;
_locationDeliveryAppService = locationDeliveryAppService;
} }
[HttpPost("get-by-number-2")] [HttpPost("get-by-number-2")]
@ -219,7 +221,23 @@ public class KittingIssueJobAppService
jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch; jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch;
jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode; jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode;
await _repository.UpdateAsync(job).ConfigureAwait(false); var jobDto = ObjectMapper.Map<KittingIssueJob, KittingIssueJobDTO>(job);
var isDoingAgv = await DoingAgvAsync(jobDto, jobDetail.TransferLibToLocationCode, jobDetail.RecommendToLocationCode).ConfigureAwait(false);
if (isDoingAgv)
{
job.JobStatus = EnumJobStatus.WaitAgv;
job.IsClaims = true;
job.ClaimsUserId = string.IsNullOrEmpty(_options.Value.StereosUser)
? "AGV"
: _options.Value.StereosUser;
job.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword)
? "AGV"
: _options.Value.StereosPassword;
}
job = await _repository.UpdateAsync(job).ConfigureAwait(false);
} }
/// <summary> /// <summary>
@ -774,21 +792,85 @@ public class KittingIssueJobAppService
kittingIssueJobDetailDto.Status, kittingIssueJobDetailDto.HandledToLot, kittingIssueJobDetailDto.Status, kittingIssueJobDetailDto.HandledToLot,
handledToQty).ConfigureAwait(false); handledToQty).ConfigureAwait(false);
} }
#endregion
#region Agv
/// <summary>
/// 调用AGV
/// </summary>
/// <param name="KittingIssueJobDto"></param>
/// <param name="fromLocationCode"></param>
/// <param name="toLocationCode"></param>
/// <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}");
}
}
return false;
}
/// <summary>
/// 判断是不是有Agv
/// </summary>
/// <param name="input"></param>
/// <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;
}
/// <summary> /// <summary>
/// 调用 Agv 接口 /// 调用 Agv 接口
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <param name="pLoc"></param> /// <param name="beginPosition"></param>
/// <param name="uid"></param> /// <param name="endPosition"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("call-agv")] [HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(KittingIssueJobDTO input) public async Task<ReusltObject> CallAgvAsync(KittingIssueJobDTO input, string beginPosition, string endPosition)
{ {
var res = new ReusltObject(); var res = new ReusltObject();
List<string> errors = new List<string>(); List<string> errors = new List<string>();
List<string> successList = new List<string>(); List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input).ConfigureAwait(false); var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false);
if (jobres.Code != "0") if (jobres.Code != "0")
{ {
_logger.LogInformation(jobres.Message); _logger.LogInformation(jobres.Message);
@ -816,168 +898,73 @@ public class KittingIssueJobAppService
[HttpPost("call-back-agv")] [HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request) public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request)
{ {
var json = JsonSerializer.Serialize(request); var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); var dto = ObjectMapper.Map<KittingIssueJob, KittingIssueJobDTO>(entity);
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG foreach (var detail in entity.Details)
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.KittingRequestNumber,
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{ {
if (request.Data.Count > 0) var detailDto = new KittingIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{ {
var jobs = request.Data; //库移的最终目标 挪到 推荐的目标
var numbers = jobs.Select(p => p.OrderNum); var fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false);
var query = _repository.WithDetails() var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
.Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done);
var entities = query.ToList(); detailDto.InjectFrom(detail);
if (entities.Count == 0)
{ detailDto.HandledToLocationCode = toloc.Code;
errors.Add($"任务号{string.Join(",", numbers)}不存在!"); detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
} detailDto.HandledToLocationArea = toloc.AreaCode;
var dtos = ObjectMapper.Map<List<KittingIssueJob>, List<KittingIssueJobDTO>>(entities); detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
foreach (var itm in dtos) detailDto.HandledToQty = request.Data.First().MatQty;
{ detailDto.HandledToLot = detail.TransferLibToLot;
var arys = jobs.Where(p => p.OrderNum == itm.Number); detailDto.HandledToPackingCode = detail.TransferLibToPackingCode;
var itmDetails = itm.Details.ToList();
var details = new List<KittingIssueJobDetailDTO>(); detailDto.HandledFromLocationCode = fromloc.Code;
foreach (var detail in arys) detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
{ detailDto.HandledFromLocationArea = fromloc.AreaCode;
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
if (fromloc == null) detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
{ detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
errors.Add($"来源起始点{detail.BeginPosition}没查到"); detailDto.HandledFromLot = detail.TransferLibToLot;
} detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode;
LocationDTO fromlocation = null;
if (fromloc != null)
{
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.LocationCode).ConfigureAwait(false);
}
if (fromlocation == null)
{
errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
}
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
LocationDTO tolocation = null;
if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}不存在!");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
if (entity == null)
{
errors.Add($"零件号{detail.MatCode}不在任务明细内!");
}
if (errors.Count > 0)
{
await unitOfWork.RollbackAsync().ConfigureAwait(false);
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
var dto = new KittingIssueJobDetailDTO();
dto.InjectFrom(entity);
dto.HandledToLocationCode = tolocation.Code;
dto.HandledToLocationGroup = tolocation.LocationGroupCode;
dto.HandledToLocationArea = tolocation.AreaCode;
dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
dto.HandledToWarehouseCode = tolocation.WarehouseCode;
dto.HandledToQty = detail.MatQty;
dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledToPackingCode = string.Empty;
dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
dto.HandledFromLocationCode = fromlocation.Code;
dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
dto.HandledFromLocationArea = fromlocation.AreaCode;
dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
dto.HandledFromQty = detail.MatQty;
dto.HandledFromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
await unitOfWork.RollbackAsync().ConfigureAwait(false);
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
} }
else else
{ {
errors.Add("Agv确认单据里无数据! \n"); var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
detailDto.InjectFrom(detail);
detailDto.HandledToLocationCode = toloc.Code;
detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
detailDto.HandledToLocationArea = toloc.AreaCode;
detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
detailDto.HandledToQty = request.Data.First().MatQty;
detailDto.HandledToLot = detail.RecommendToLot;
detailDto.HandledToPackingCode = detail.RecommendToPackingCode;
detailDto.HandledFromLocationCode = fromloc.Code;
detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
detailDto.HandledFromLocationArea = fromloc.AreaCode;
detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
detailDto.HandledFromLot = detail.RecommendToLot;
detailDto.HandledFromPackingCode = detail.RecommendToPackingCode;
} }
}
catch (Exception ex) await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.KittingRequestNumber,
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
return ret;
} }
if (errors.Count > 0) return new AgvResultObject
{ {
ret = new AgvResultObject Code = "0",
{ Message = "OK",
Code = "-1", ReqCode = "",
Message = string.Join(",", errors.ToArray()), };
ReqCode = job.KittingRequestNumber
};
}
return ret;
} }
/// <summary> /// <summary>
@ -1133,8 +1120,10 @@ public class KittingIssueJobAppService
/// 调用Agv接口实现 /// 调用Agv接口实现
/// </summary> /// </summary>
/// <param name="job"></param> /// <param name="job"></param>
/// <param name="beginPosition"></param>
/// <param name="endPosition"></param>
/// <returns></returns> /// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(KittingIssueJobDTO job) private async Task<AgvResultObject> SendInterFaceAsync(KittingIssueJobDTO job, string beginPosition, string endPosition)
{ {
#if DEBUG #if DEBUG
@ -1164,8 +1153,8 @@ public class KittingIssueJobAppService
request.MatQty = first.HandledToQty; request.MatQty = first.HandledToQty;
request.OrderNum = job.Number; request.OrderNum = job.Number;
request.OrderType = EnumJobType.KittingIssueJob.ToString(); request.OrderType = EnumJobType.KittingIssueJob.ToString();
request.BeginPosition = first.HandledFromLocationCode; request.BeginPosition = beginPosition;
request.EndPosition = first.HandledToLocationCode; request.EndPosition = endPosition;
var httpclient = _httpClientFactory.CreateClient(); var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
@ -1211,8 +1200,6 @@ public class KittingIssueJobAppService
} }
return ret; return ret;
} }
#endregion #endregion
} }

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

@ -53,6 +53,7 @@ public class SparePartIssueJobAppService
private readonly ILogger<SparePartIssueJobAppService> _logger; private readonly ILogger<SparePartIssueJobAppService> _logger;
private readonly IItemBasicAppService _itemBasicAppService; private readonly IItemBasicAppService _itemBasicAppService;
private readonly ITransferNoteAppService _transferNoteAppService; private readonly ITransferNoteAppService _transferNoteAppService;
private readonly ILocationDeliveryAppService _locationDeliveryAppService;
protected ISparePartIssueRequestAppService SparePartIssueRequestAppService => protected ISparePartIssueRequestAppService SparePartIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<ISparePartIssueRequestAppService>(); LazyServiceProvider.LazyGetRequiredService<ISparePartIssueRequestAppService>();
@ -64,7 +65,10 @@ public class SparePartIssueJobAppService
ISparePartIssueNoteAppService sparePartIssueNoteAppService, IExpectOutAppService expectOutAppService ISparePartIssueNoteAppService sparePartIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory , IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, ILogger<SparePartIssueJobAppService> logger , IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, ILogger<SparePartIssueJobAppService> logger
, UnitOfWorkManager unitOfWorkManager, IOptions<AgvOptions> agvOptions, IItemBasicAppService itemBasicAppService, ITransferNoteAppService transferNoteAppService , UnitOfWorkManager unitOfWorkManager, IOptions<AgvOptions> agvOptions,
IItemBasicAppService itemBasicAppService,
ITransferNoteAppService transferNoteAppService,
ILocationDeliveryAppService locationDeliveryAppService
) : base( ) : base(
repository, sparePartIssueJobManager) repository, sparePartIssueJobManager)
{ {
@ -82,6 +86,7 @@ public class SparePartIssueJobAppService
_logger = logger; _logger = logger;
_itemBasicAppService = itemBasicAppService; _itemBasicAppService = itemBasicAppService;
_transferNoteAppService = transferNoteAppService; _transferNoteAppService = transferNoteAppService;
_locationDeliveryAppService = locationDeliveryAppService;
} }
[HttpPost("get-by-number-2")] [HttpPost("get-by-number-2")]
@ -210,7 +215,23 @@ public class SparePartIssueJobAppService
jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch; jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch;
jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode; jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode;
await _repository.UpdateAsync(job).ConfigureAwait(false); var jobDto = ObjectMapper.Map<SparePartIssueJob, SparePartIssueJobDTO>(job);
var isDoingAgv = await DoingAgvAsync(jobDto, jobDetail.TransferLibToLocationCode, jobDetail.RecommendToLocationCode).ConfigureAwait(false);
if (isDoingAgv)
{
job.JobStatus = EnumJobStatus.WaitAgv;
job.IsClaims = true;
job.ClaimsUserId = string.IsNullOrEmpty(_options.Value.StereosUser)
? "AGV"
: _options.Value.StereosUser;
job.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword)
? "AGV"
: _options.Value.StereosPassword;
}
job = await _repository.UpdateAsync(job).ConfigureAwait(false);
} }
/// <summary> /// <summary>
@ -750,21 +771,82 @@ public class SparePartIssueJobAppService
handledToQty).ConfigureAwait(false); handledToQty).ConfigureAwait(false);
} }
#endregion
#region Agv
/// <summary>
/// 调用AGV
/// </summary>
/// <param name="SparePartIssueJobDto"></param>
/// <param name="fromLocationCode"></param>
/// <param name="toLocationCode"></param>
/// <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}");
}
}
return false;
}
/// <summary>
/// 判断是不是有Agv
/// </summary>
/// <param name="input"></param>
/// <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;
}
/// <summary> /// <summary>
/// 调用 Agv 接口 /// 调用 Agv 接口
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <param name="pLoc"></param> /// <param name="beginPosition"></param>
/// <param name="uid"></param> /// <param name="endPosition"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("call-agv")] [HttpPost("call-agv")]
public async Task<ReusltObject> CallAgvAsync(SparePartIssueJobDTO input) public async Task<ReusltObject> CallAgvAsync(SparePartIssueJobDTO input, string beginPosition, string endPosition)
{ {
var res = new ReusltObject(); var res = new ReusltObject();
List<string> errors = new List<string>(); List<string> errors = new List<string>();
List<string> successList = new List<string>(); List<string> successList = new List<string>();
var jobres = await SendInterFaceAsync(input).ConfigureAwait(false); var jobres = await SendInterFaceAsync(input, beginPosition, endPosition).ConfigureAwait(false);
if (jobres.Code != "0") if (jobres.Code != "0")
{ {
_logger.LogInformation(jobres.Message); _logger.LogInformation(jobres.Message);
@ -792,169 +874,75 @@ public class SparePartIssueJobAppService
[HttpPost("call-back-agv")] [HttpPost("call-back-agv")]
public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request) public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request)
{ {
var json = JsonSerializer.Serialize(request); var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); var dto = ObjectMapper.Map<SparePartIssueJob, SparePartIssueJobDTO>(entity);
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG foreach (var detail in entity.Details)
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.SparePartRequestNumber,
};
using var unitOfWork = _unitOfWorkManager.Begin();
try
{ {
if (request.Data.Count > 0) var detailDto = new SparePartIssueJobDetailDTO();
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode))
{ {
var jobs = request.Data; //库移的最终目标 挪到 推荐的目标
var numbers = jobs.Select(p => p.OrderNum); var fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false);
var query = _repository.WithDetails() var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
.Where(p => numbers.Contains(p.Number) && p.JobStatus != EnumJobStatus.Done);
var entities = query.ToList(); detailDto.InjectFrom(detail);
if (entities.Count == 0)
{ detailDto.HandledToLocationCode = toloc.Code;
errors.Add($"任务号{string.Join(",", numbers)}不存在!"); detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
} detailDto.HandledToLocationArea = toloc.AreaCode;
var dtos = ObjectMapper.Map<List<SparePartIssueJob>, List<SparePartIssueJobDTO>>(entities); detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
foreach (var itm in dtos) detailDto.HandledToQty = request.Data.First().MatQty;
{ detailDto.HandledToLot = detail.TransferLibToLot;
var arys = jobs.Where(p => p.OrderNum == itm.Number); detailDto.HandledToPackingCode = detail.TransferLibToPackingCode;
var itmDetails = itm.Details.ToList();
var details = new List<SparePartIssueJobDetailDTO>(); detailDto.HandledFromLocationCode = fromloc.Code;
foreach (var detail in arys) detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
{ detailDto.HandledFromLocationArea = fromloc.AreaCode;
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
if (fromloc == null) detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
{ detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
errors.Add($"来源起始点{detail.BeginPosition}没查到"); detailDto.HandledFromLot = detail.TransferLibToLot;
} detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode;
LocationDTO fromlocation = null;
if (fromloc != null)
{
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.LocationCode).ConfigureAwait(false);
}
if (fromlocation == null)
{
errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
}
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
LocationDTO tolocation = null;
if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false);
if (item == null)
{
errors.Add($"零件号{detail.MatCode}不存在!");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
if (entity == null)
{
errors.Add($"零件号{detail.MatCode}不在任务明细内!");
}
if (errors.Count > 0)
{
await unitOfWork.RollbackAsync().ConfigureAwait(false);
return ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
var dto = new SparePartIssueJobDetailDTO();
dto.InjectFrom(entity);
dto.HandledToLocationCode = tolocation.Code;
dto.HandledToLocationGroup = tolocation.LocationGroupCode;
dto.HandledToLocationArea = tolocation.AreaCode;
dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
dto.HandledToWarehouseCode = tolocation.WarehouseCode;
dto.HandledToQty = detail.MatQty;
dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledToPackingCode = string.Empty;
dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
dto.HandledFromLocationCode = fromlocation.Code;
dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
dto.HandledFromLocationArea = fromlocation.AreaCode;
dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
dto.HandledFromQty = detail.MatQty;
dto.HandledFromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
await unitOfWork.RollbackAsync().ConfigureAwait(false);
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
} }
else else
{ {
errors.Add("Agv确认单据里无数据! \n"); var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false);
var fromloc = await _locationAppService.GetByCodeAsync(detail.RecommendFromLocationCode).ConfigureAwait(false);
detailDto.InjectFrom(detail);
detailDto.HandledToLocationCode = toloc.Code;
detailDto.HandledToLocationGroup = toloc.LocationGroupCode;
detailDto.HandledToLocationArea = toloc.AreaCode;
detailDto.HandledToLocationErpCode = toloc.ErpLocationCode;
detailDto.HandledToWarehouseCode = toloc.WarehouseCode;
detailDto.HandledToQty = request.Data.First().MatQty;
detailDto.HandledToLot = detail.RecommendToLot;
detailDto.HandledToPackingCode = detail.RecommendToPackingCode;
detailDto.HandledFromLocationCode = fromloc.Code;
detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode;
detailDto.HandledFromLocationArea = fromloc.AreaCode;
detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode;
detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode;
detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
detailDto.HandledFromLot = detail.RecommendToLot;
detailDto.HandledFromPackingCode = detail.RecommendToPackingCode;
} }
}
catch (Exception ex) await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false);
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.SparePartRequestNumber,
Message = ex.Message
};
await unitOfWork.RollbackAsync().ConfigureAwait(false);
return ret;
} }
if (errors.Count > 0) return new AgvResultObject
{ {
ret = new AgvResultObject Code = "0",
{ Message = "OK",
Code = "-1", ReqCode = "",
Message = string.Join(",", errors.ToArray()), };
ReqCode = job.SparePartRequestNumber
};
}
return ret;
} }
/// <summary> /// <summary>
/// Agv 回库 接口 /// Agv 回库 接口
/// </summary> /// </summary>
@ -1061,7 +1049,7 @@ public class SparePartIssueJobAppService
detailInput.ToStatus = fromlocation.DefaultInventoryStatus; detailInput.ToStatus = fromlocation.DefaultInventoryStatus;
detailInput.Qty = detail.MatQty; detailInput.Qty = detail.MatQty;
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty; detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
detailInput.FromPackingCode =detail.PakingCode; detailInput.FromPackingCode = detail.PakingCode;
transfer.Details.Add(detailInput); transfer.Details.Add(detailInput);
@ -1104,13 +1092,14 @@ public class SparePartIssueJobAppService
} }
/// <summary> /// <summary>
/// 调用Agv接口实现 /// 调用Agv接口实现
/// </summary> /// </summary>
/// <param name="job"></param> /// <param name="job"></param>
/// <param name="beginPosition"></param>
/// <param name="endPosition"></param>
/// <returns></returns> /// <returns></returns>
private async Task<AgvResultObject> SendInterFaceAsync(SparePartIssueJobDTO job) private async Task<AgvResultObject> SendInterFaceAsync(SparePartIssueJobDTO job, string beginPosition, string endPosition)
{ {
#if DEBUG #if DEBUG
@ -1121,7 +1110,6 @@ public class SparePartIssueJobAppService
ReqCode = job.SparePartRequestNumber, ReqCode = job.SparePartRequestNumber,
Message = "OK" Message = "OK"
}; };
using var unitOfWork = _unitOfWorkManager.Begin(); using var unitOfWork = _unitOfWorkManager.Begin();
try try
{ {
@ -1130,6 +1118,7 @@ public class SparePartIssueJobAppService
{ {
throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!"); throw new UserFriendlyException($"任务{job.Number}为已完成状态,不能发起AGV任务!");
} }
if (job.Details.Count == 0) if (job.Details.Count == 0)
{ {
throw new UserFriendlyException($"任务{job.Number}没有推荐库存!"); throw new UserFriendlyException($"任务{job.Number}没有推荐库存!");
@ -1140,6 +1129,8 @@ public class SparePartIssueJobAppService
request.MatQty = first.HandledToQty; request.MatQty = first.HandledToQty;
request.OrderNum = job.Number; request.OrderNum = job.Number;
request.OrderType = EnumJobType.SparePartIssueJob.ToString(); request.OrderType = EnumJobType.SparePartIssueJob.ToString();
request.BeginPosition = beginPosition;
request.EndPosition = endPosition;
var httpclient = _httpClientFactory.CreateClient(); var httpclient = _httpClientFactory.CreateClient();
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) _agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address)
@ -1186,6 +1177,5 @@ public class SparePartIssueJobAppService
return ret; return ret;
} }
#endregion #endregion
} }

Loading…
Cancel
Save