Browse Source

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

Agv分支2024-11-19
赵新宇 5 months ago
parent
commit
aa2eab7761
  1. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccount.cs
  2. 104
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobAccountService.cs
  3. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/AssembleIssueJobs/AssembleIssueJobAppService.cs
  4. 3
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/CoatingIssueJobs/CoatingIssueJobAppService.cs
  5. 166
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/InjectionIssueJobs/InjectionIssueJobAppService.cs
  6. 164
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/KittingIssueJobs/KittingIssueJobAppService.cs
  7. 167
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/IssueJobs/SparePartIssueJobs/SparePartIssueJobAppService.cs
  8. 168
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs
  9. 171
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedReceiptJobs/UnplannedReceiptJobAppService.cs
  10. 42
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationModule.cs

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Jobs/IssueJobs/AgvJobs/IAgvJobAccount.cs

@ -7,7 +7,7 @@ using Volo.Abp;
using Volo.Abp.Application.Services;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
public interface IAgvJobAccount
public interface IAgvJobAccountService
{
Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request);

104
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/AgvJobs/AgvJobAccountService.cs

@ -24,108 +24,38 @@ namespace Win_in.Sfs.Wms.Store.Jobs.AgvJobs;
[Route($"{StoreConsts.RootPath}agv-job-Account")]
public class AgvJobAccountService : ApplicationService
{
private IAssembleIssueJobAppService _assembleIssueJobAppService;
private ICoatingIssueJobAppService _coatingIssueJobAppService;
private IInjectionIssueJobAppService _injectionIssueJobAppService;
private IKittingIssueJobAppService _kittingIssueJobAppService;
private ISparePartIssueJobAppService _sparePartIssueJobAppService;
private IProductionLineAppService _productionLineAppService;
private readonly Func<string, IAgvJobAccountService> _Accessor;
public AgvJobAccountService(
Func<string, IAgvJobAccountService> Accessor
IAssembleIssueJobAppService assembleIssueJobAppService,
ICoatingIssueJobAppService coatingIssueJobAppService,
IInjectionIssueJobAppService injectionIssueJobAppService,
IKittingIssueJobAppService kittingIssueJobAppService,
ISparePartIssueJobAppService sparePartIssueJobAppService,
IProductionLineAppService productionLineAppService
)
{
_assembleIssueJobAppService = assembleIssueJobAppService;
_coatingIssueJobAppService = coatingIssueJobAppService;
_injectionIssueJobAppService = injectionIssueJobAppService;
_kittingIssueJobAppService = kittingIssueJobAppService;
_sparePartIssueJobAppService = sparePartIssueJobAppService;
_productionLineAppService = productionLineAppService;
_Accessor = Accessor;
}
public async Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request)
{
var res = new AgvResultObject();
res.Code = "0";
foreach (var itm in request.Data)
{
switch (itm.OrderType)
{
case "1":
var assemblejob = new AssembleIssueJobDTO();
var assemb = await _assembleIssueJobAppService.GetByNumberAsync(itm.OrderNum).ConfigureAwait(false);
var assembDetail = assemb.Details.FirstOrDefault();
foreach (var detail in request.Data)
{
var begin = detail.BeginPosition;
var end = detail.EndPosition;
await _productionLineAppService.GetByCodeAsync(begin).ConfigureAwait(false);
await _productionLineAppService.GetByCodeAsync(end).ConfigureAwait(false);
}
await _assembleIssueJobAppService.CompleteAsync(assemb.Id).ConfigureAwait(false);
res.ReqCode = assemb.AssembleRequestNumber;
res.Message = "OK";
break;
case "2":
var coating = await _coatingIssueJobAppService.GetByNumberAsync(itm.OrderNum).ConfigureAwait(false);
await _coatingIssueJobAppService.CompleteAsync(coating.Id).ConfigureAwait(false);
break;
case "3":
var injection = await _injectionIssueJobAppService.GetByNumberAsync(itm.OrderNum).ConfigureAwait(false);
await _injectionIssueJobAppService.CompleteAsync(injection.Id).ConfigureAwait(false);
break;
case "4":
var kitting = await _kittingIssueJobAppService.GetByNumberAsync(itm.OrderNum).ConfigureAwait(false);
await _kittingIssueJobAppService.CompleteAsync(kitting.Id).ConfigureAwait(false);
break;
case "5":
var sparePart = await _sparePartIssueJobAppService.GetByNumberAsync(itm.OrderNum).ConfigureAwait(false);
await _sparePartIssueJobAppService.CompleteAsync(sparePart.Id).ConfigureAwait(false);
break;
var first=request.Data.FirstOrDefault();
var agvJobAccountService = _Accessor(first.OrderType);
var result = await agvJobAccountService.AccountOutOrderAsync(request).ConfigureAwait(false);
if (result.Code!= "0")
{
res.Code = "1";
res.Message = result.Message;
}
}
return res;
return null;
}
private async Task CheckPostionLocation(AgvRequestOnlyJobHK request, Action<string> action, List<string> errors)
{
foreach (var detail in request.Data)
{
var begin = detail.BeginPosition;
var end = detail.EndPosition;
var beginLocation = await _productionLineAppService.GetByCodeAsync(begin).ConfigureAwait(false);
if (beginLocation == null)
{
errors.Add($"任务号:{detail.OrderNum}开始工作位置号:{begin}没找到对应库位");
}
var endLocation = await _productionLineAppService.GetByCodeAsync(end).ConfigureAwait(false);
if (endLocation == null)
{
errors.Add($"任务号:{detail.OrderNum}结束工作位置号:{end}没找到对应库位");
}
}
}
}

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

@ -38,7 +38,7 @@ namespace Win_in.Sfs.Wms.Store.Application;
public class AssembleIssueJobAppService
: SfsJobAppServiceBase<AssembleIssueJob, AssembleIssueJobDetail, AssembleIssueJobDTO, SfsJobRequestInputBase,
AssembleIssueJobCheckInput, AssembleIssueJobEditInput>,
IAssembleIssueJobAppService, ITransferLibCallback, IAgvJobAccount
IAssembleIssueJobAppService, ITransferLibCallback, IAgvJobAccountService
{
protected IAssembleIssueRequestAppService AssembleIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IAssembleIssueRequestAppService>();
@ -804,7 +804,7 @@ public class AssembleIssueJobAppService
#if DEBUG
ret.Code = 1;
return;
#endif

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

@ -38,7 +38,7 @@ namespace Win_in.Sfs.Wms.Store.Application;
public class CoatingIssueJobAppService
: SfsJobAppServiceBase<CoatingIssueJob, CoatingIssueJobDetail, CoatingIssueJobDTO, SfsJobRequestInputBase,
CoatingIssueJobCheckInput, CoatingIssueJobEditInput>,
ICoatingIssueJobAppService, ITransferLibCallback,IAgvJobAccount
ICoatingIssueJobAppService, ITransferLibCallback, IAgvJobAccountService
{
private readonly ICoatingIssueJobManager _coatingIssueJobManager;
private readonly ILocationAppService _locationAppService;
@ -54,6 +54,7 @@ public class CoatingIssueJobAppService
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService;
protected ICoatingIssueRequestAppService CoatingIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<ICoatingIssueRequestAppService>();

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

@ -9,8 +9,10 @@ using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MyNamespace;
using Omu.ValueInjecter;
using Volo.Abp;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
@ -33,7 +35,7 @@ namespace Win_in.Sfs.Wms.Store.Application;
public class InjectionIssueJobAppService
: SfsJobAppServiceBase<InjectionIssueJob, InjectionIssueJobDetail, InjectionIssueJobDTO, SfsJobRequestInputBase,
InjectionIssueJobCheckInput, InjectionIssueJobEditInput>,
IInjectionIssueJobAppService, ITransferLibCallback
IInjectionIssueJobAppService, ITransferLibCallback, IAgvJobAccountService
{
private readonly IInjectionIssueJobManager _injectionIssueJobManager;
private readonly ILocationAppService _locationAppService;
@ -47,13 +49,15 @@ public class InjectionIssueJobAppService
private readonly UnitOfWorkManager _unitOfWorkManager;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILogger<InjectionIssueJobAppService> _logger;
protected IInjectionIssueRequestAppService InjectionIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IInjectionIssueRequestAppService>();
public InjectionIssueJobAppService(
IAgvJobOutputService agvOutJob,
IInjectionIssueJobRepository repository, IInjectionIssueJobManager injectionIssueJobManager,
IInjectionIssueJobRepository repository, IInjectionIssueJobManager injectionIssueJobManager, ILogger<InjectionIssueJobAppService> logger,
ILocationAppService locationAppService,
IInjectionIssueNoteAppService injectionIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory
@ -74,6 +78,7 @@ public class InjectionIssueJobAppService
_agvOutJob = agvOutJob;
_unitOfWorkManager = unitOfWorkManager;
_agvOptions = agvOptions;
_logger = logger;
}
[HttpPost("get-by-number-2")]
public async Task<InjectionIssueJobDTO> GetByNumber2Async(string number)
@ -744,6 +749,163 @@ public class InjectionIssueJobAppService
}
return ret;
}
[HttpPost("accountOutOrder")]
public async Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request)
{
var json = JsonSerializer.Serialize(request);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.InjectionRequestNumber,
};
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<InjectionIssueJob>, List<InjectionIssueJobDTO>>(entities);
foreach (var itm in dtos)
{
var arys = jobs.Where(p => p.OrderNum == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<InjectionIssueJobDetailDTO>();
foreach (var detail in arys)
{
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromloc == null)
{
errors.Add($"来源起始点{detail.BeginPosition}没查到");
}
LocationDTO fromlocation = null;
if (fromloc != null)
{
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.Code).ConfigureAwait(false);
}
if (fromlocation == null)
{
errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
}
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
LocationDTO tolocation = null;
if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.Code).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
if (entity == null)
{
errors.Add($"物料号{detail.MatCode}不在任务明细内!");
}
var dto = new InjectionIssueJobDetailDTO();
dto.InjectFrom(entity);
dto.HandledToLocationCode = toloc.Code;
dto.HandledToLocationGroup = tolocation.LocationGroupCode;
dto.HandledToLocationArea = tolocation.AreaCode;
dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
dto.HandledToWarehouseCode = tolocation.WarehouseCode;
dto.HandledToQty = detail.MatQty;
dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledToPackingCode = string.Empty;
dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
dto.HandledFromLocationCode = fromlocation.Code;
dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
dto.HandledFromLocationArea = fromlocation.AreaCode;
dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
dto.HandledFromQty = detail.MatQty;
dto.HandledFromLot = string.Empty;
dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.InjectionRequestNumber,
Message = ex.Message,
};
await unitOfWork.RollbackAsync();
return ret;
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = job.InjectionRequestNumber
};
}
return ret;
}
#endregion

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

@ -9,8 +9,10 @@ using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MyNamespace;
using Omu.ValueInjecter;
using Volo.Abp;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
@ -33,7 +35,7 @@ namespace Win_in.Sfs.Wms.Store.Application;
public class KittingIssueJobAppService
: SfsJobAppServiceBase<KittingIssueJob, KittingIssueJobDetail, KittingIssueJobDTO, SfsJobRequestInputBase,
KittingIssueJobCheckInput, KittingIssueJobEditInput>,
IKittingIssueJobAppService, ITransferLibCallback
IKittingIssueJobAppService, ITransferLibCallback,IAgvJobAccountService
{
private readonly IKittingIssueJobManager _kittingIssueJobManager;
private readonly ILocationAppService _locationAppService;
@ -48,6 +50,7 @@ public class KittingIssueJobAppService
private readonly IHttpClientFactory _httpClientFactory;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILogger<KittingIssueJobAppService> _logger;
protected IKittingIssueRequestAppService KittingIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IKittingIssueRequestAppService>();
@ -56,7 +59,7 @@ public class KittingIssueJobAppService
IAgvJobOutputService agvOutJob,
IKittingIssueJobRepository repository, IKittingIssueJobManager kittingIssueJobManager,
ILocationAppService locationAppService,
IKittingIssueNoteAppService kittingIssueNoteAppService, IExpectOutAppService expectOutAppService
IKittingIssueNoteAppService kittingIssueNoteAppService, IExpectOutAppService expectOutAppService, ILogger<KittingIssueJobAppService> logger
, IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser
,IOptions<AgvOptions> agvOptions,
@ -758,6 +761,163 @@ public class KittingIssueJobAppService
}
return ret;
}
[HttpPost("accountOutOrder")]
public async Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request)
{
var json = JsonSerializer.Serialize(request);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.KittingRequestNumber,
};
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<KittingIssueJob>, List<KittingIssueJobDTO>>(entities);
foreach (var itm in dtos)
{
var arys = jobs.Where(p => p.OrderNum == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<KittingIssueJobDetailDTO>();
foreach (var detail in arys)
{
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromloc == null)
{
errors.Add($"来源起始点{detail.BeginPosition}没查到");
}
LocationDTO fromlocation = null;
if (fromloc != null)
{
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.Code).ConfigureAwait(false);
}
if (fromlocation == null)
{
errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
}
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
LocationDTO tolocation = null;
if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.Code).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
if (entity == null)
{
errors.Add($"物料号{detail.MatCode}不在任务明细内!");
}
var dto = new KittingIssueJobDetailDTO();
dto.InjectFrom(entity);
dto.HandledToLocationCode = toloc.Code;
dto.HandledToLocationGroup = tolocation.LocationGroupCode;
dto.HandledToLocationArea = tolocation.AreaCode;
dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
dto.HandledToWarehouseCode = tolocation.WarehouseCode;
dto.HandledToQty = detail.MatQty;
dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledToPackingCode = string.Empty;
dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
dto.HandledFromLocationCode = fromlocation.Code;
dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
dto.HandledFromLocationArea = fromlocation.AreaCode;
dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
dto.HandledFromQty = detail.MatQty;
dto.HandledFromLot = string.Empty;
dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.KittingRequestNumber,
Message = ex.Message,
};
await unitOfWork.RollbackAsync();
return ret;
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = job.KittingRequestNumber
};
}
return ret;
}
#endregion

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

@ -9,8 +9,10 @@ using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MyNamespace;
using Omu.ValueInjecter;
using Volo.Abp;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
@ -33,7 +35,7 @@ namespace Win_in.Sfs.Wms.Store.Application;
public class SparePartIssueJobAppService
: SfsJobAppServiceBase<SparePartIssueJob, SparePartIssueJobDetail, SparePartIssueJobDTO, SfsJobRequestInputBase,
SparePartIssueJobCheckInput, SparePartIssueJobEditInput>,
ISparePartIssueJobAppService, ITransferLibCallback
ISparePartIssueJobAppService, ITransferLibCallback, IAgvJobAccountService
{
private readonly ISparePartIssueJobManager _sparePartIssueJobManager;
private readonly ILocationAppService _locationAppService;
@ -47,6 +49,7 @@ public class SparePartIssueJobAppService
private readonly UnitOfWorkManager _unitOfWorkManager;
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILogger<SparePartIssueJobAppService> _logger;
protected ISparePartIssueRequestAppService SparePartIssueRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<ISparePartIssueRequestAppService>();
@ -57,7 +60,7 @@ public class SparePartIssueJobAppService
ILocationAppService locationAppService,
ISparePartIssueNoteAppService sparePartIssueNoteAppService, IExpectOutAppService expectOutAppService
, IHttpClientFactory httpClientFactory
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, ILogger<SparePartIssueJobAppService> logger
, UnitOfWorkManager unitOfWorkManager, IOptions<AgvOptions> agvOptions
) : base(
repository, sparePartIssueJobManager)
@ -72,7 +75,8 @@ public class SparePartIssueJobAppService
_currentUser = currentUser;
_agvOutJob = agvOutJob;
_unitOfWorkManager = unitOfWorkManager;
_agvOptions = agvOptions;
_agvOptions = agvOptions;
_logger = logger;
}
[HttpPost("get-by-number-2")]
@ -734,6 +738,163 @@ public class SparePartIssueJobAppService
}
return ret;
}
[HttpPost("accountOutOrder")]
public async Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request)
{
var json = JsonSerializer.Serialize(request);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.SparePartRequestNumber,
};
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<SparePartIssueJob>, List<SparePartIssueJobDTO>>(entities);
foreach (var itm in dtos)
{
var arys = jobs.Where(p => p.OrderNum == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<SparePartIssueJobDetailDTO>();
foreach (var detail in arys)
{
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromloc == null)
{
errors.Add($"来源起始点{detail.BeginPosition}没查到");
}
LocationDTO fromlocation = null;
if (fromloc != null)
{
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.Code).ConfigureAwait(false);
}
if (fromlocation == null)
{
errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
}
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
LocationDTO tolocation = null;
if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.Code).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
if (entity == null)
{
errors.Add($"物料号{detail.MatCode}不在任务明细内!");
}
var dto = new SparePartIssueJobDetailDTO();
dto.InjectFrom(entity);
dto.HandledToLocationCode = toloc.Code;
dto.HandledToLocationGroup = tolocation.LocationGroupCode;
dto.HandledToLocationArea = tolocation.AreaCode;
dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
dto.HandledToWarehouseCode = tolocation.WarehouseCode;
dto.HandledToQty = detail.MatQty;
dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
dto.HandledToPackingCode = string.Empty;
dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
dto.HandledFromLocationCode = fromlocation.Code;
dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
dto.HandledFromLocationArea = fromlocation.AreaCode;
dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
dto.HandledFromQty = detail.MatQty;
dto.HandledFromLot = string.Empty;
dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.SparePartRequestNumber,
Message = ex.Message,
};
await unitOfWork.RollbackAsync();
return ret;
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = job.SparePartRequestNumber
};
}
return ret;
}
#endregion

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

@ -23,6 +23,9 @@ using Win_in.Sfs.Wms.Store.Domain.Shared;
using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy;
using Microsoft.Extensions.Options;
using Win_in.Sfs.Wms.Store.Options;
using Volo.Abp.ObjectMapping;
using Win_in.Sfs.Basedata.Application;
using System.Text.Json;
namespace Win_in.Sfs.Wms.Store.Application;
@ -31,7 +34,7 @@ namespace Win_in.Sfs.Wms.Store.Application;
public class UnplannedIssueJobAppService
: SfsJobAppServiceBase<UnplannedIssueJob, UnplannedIssueJobDetail, UnplannedIssueJobDTO, SfsJobRequestInputBase,
UnplannedIssueJobCheckInput, UnplannedIssueJobEditInput>,
IUnplannedIssueJobAppService
IUnplannedIssueJobAppService,IAgvJobAccountService
{
protected IUnplannedIssueRequestAppService UnplannedReceiptRequestAppService =>
LazyServiceProvider.LazyGetRequiredService<IUnplannedIssueRequestAppService>();
@ -46,13 +49,16 @@ public class UnplannedIssueJobAppService
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IHttpClientFactory _httpClientFactory;
private readonly IPostionLocationAppService _postionLocationAppService;
public UnplannedIssueJobAppService(
IUnplannedIssueJobRepository repository, IUnplannedIssueJobManager unplannedIssueJobManager,
ILocationAppService locationAppService,
IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService,
IUnitOfWorkManager unitOfWorkManager, ILogger<UnplannedIssueJobAppService> logger,
IItemBasicAppService itemBasicAppService, IOptions<AgvOptions> agvOptions
IItemBasicAppService itemBasicAppService, IOptions<AgvOptions> agvOptions,
IPostionLocationAppService postionLocationAppService
, IHttpClientFactory httpClientFactory
) : base(repository, unplannedIssueJobManager)
@ -66,6 +72,7 @@ public class UnplannedIssueJobAppService
_itemBasicAppService = itemBasicAppService;
_agvOptions = agvOptions;
_httpClientFactory = httpClientFactory;
_postionLocationAppService = postionLocationAppService;
}
/// <summary>
@ -707,6 +714,163 @@ public class UnplannedIssueJobAppService
}
return ret;
}
[HttpPost("accountOutOrder")]
public async Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request)
{
var json = JsonSerializer.Serialize(request);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.UnplannedIssueRequestNumber,
};
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<UnplannedIssueJob>, List<UnplannedIssueJobDTO>>(entities);
foreach (var itm in dtos)
{
var arys = jobs.Where(p => p.OrderNum == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<UnplannedIssueJobDetailDTO>();
foreach (var detail in arys)
{
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromloc == null)
{
errors.Add($"来源起始点{detail.BeginPosition}没查到");
}
LocationDTO fromlocation = null;
if (fromloc != null)
{
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.Code).ConfigureAwait(false);
}
if (fromlocation == null)
{
errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
}
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
LocationDTO tolocation = null;
if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.Code).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
if (entity == null)
{
errors.Add($"物料号{detail.MatCode}不在任务明细内!");
}
var dto = new UnplannedIssueJobDetailDTO();
dto.InjectFrom(entity);
//dto.HandledQty = toloc.Code;
//dto.location = tolocation.LocationGroupCode;
//dto.HandledToLocationArea = tolocation.AreaCode;
//dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
//dto.HandledToWarehouseCode = tolocation.WarehouseCode;
//dto.HandledToQty = detail.MatQty;
//dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
//dto.HandledToPackingCode = string.Empty;
//dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
//dto.HandledFromLocationCode = fromlocation.Code;
//dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
//dto.HandledFromLocationArea = fromlocation.AreaCode;
//dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
//dto.HandledFromQty = detail.MatQty;
//dto.HandledFromLot = string.Empty;
//dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.UnplannedIssueRequestNumber,
Message = ex.Message,
};
await unitOfWork.RollbackAsync();
return ret;
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = job.UnplannedIssueRequestNumber
};
}
return ret;
}
}

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

@ -32,13 +32,16 @@ using Win_in.Sfs.Wms.Store.Jobs.IssueJobs.proxy;
using Win_in.Sfs.Wms.Store.Options;
using Microsoft.Extensions.Options;
using Volo.Abp.Uow;
using Omu.ValueInjecter;
using Win_in.Sfs.Basedata.Application;
using Microsoft.Extensions.Logging;
[Authorize]
[Route($"{StoreConsts.RootPath}unplanned-receipt-job")]
public class UnplannedReceiptJobAppService
: SfsJobAppServiceBase<UnplannedReceiptJob, UnplannedReceiptJobDetail, UnplannedReceiptJobDTO, SfsJobRequestInputBase, UnplannedReceiptJobCheckInput, UnplannedReceiptJobEditInput>,
IUnplannedReceiptJobAppService
IUnplannedReceiptJobAppService, IAgvJobAccountService
{
protected IUnplannedReceiptRequestAppService UnplannedReceiptRequestAppService=>
LazyServiceProvider.LazyGetRequiredService<IUnplannedReceiptRequestAppService>();
@ -51,16 +54,19 @@ public class UnplannedReceiptJobAppService
private readonly IOptions<AgvOptions> _agvOptions;
private readonly IHttpClientFactory _httpClientFactory;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IPostionLocationAppService _postionLocationAppService;
private readonly ILogger<UnplannedReceiptJobAppService> _logger;
public UnplannedReceiptJobAppService(
IUnplannedReceiptJobRepository repository, IUnplannedReceiptJobManager UnplannedReceiptJobManager,
IUnplannedReceiptJobRepository repository, IUnplannedReceiptJobManager UnplannedReceiptJobManager, IPostionLocationAppService postionLocationAppService,
ILocationAppService locationAppService,
IBalanceAppService balanceAppService,
IExpectOutAppService expectOutAppService, IItemBasicAppService itemBasicAppService,
IOptions<AgvOptions> agvOptions,
IHttpClientFactory httpClientFactory,
IUnitOfWorkManager unitOfWorkManager
IUnitOfWorkManager unitOfWorkManager,
ILogger<UnplannedReceiptJobAppService> logger
) : base(repository, UnplannedReceiptJobManager)
@ -73,6 +79,8 @@ public class UnplannedReceiptJobAppService
_agvOptions = agvOptions;
_httpClientFactory = httpClientFactory;
_unitOfWorkManager = unitOfWorkManager;
_logger = logger;
_postionLocationAppService = postionLocationAppService;
}
@ -382,4 +390,161 @@ public class UnplannedReceiptJobAppService
}
return ret;
}
[HttpPost("accountOutOrder")]
public async Task<AgvResultObject> AccountOutOrderAsync(AgvRequestOnlyJobHK request)
{
var json = JsonSerializer.Serialize(request);
var flag = DateTime.Now.ToString("yyyyMMddHHmmss");
_logger.LogInformation($"{flag}接收到AGV确认单据内容:" + json);
#if DEBUG
#endif
var errors = new List<string>();
var first = request.Data.FirstOrDefault();
var job = await _repository.GetAsync(p => p.Number == first.OrderNum).ConfigureAwait(false);
var ret = new AgvResultObject
{
Code = "0",
Message = "OK",
ReqCode = job.UnplannedReceiptRequestNumber,
};
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<UnplannedReceiptJob>, List<UnplannedReceiptJobDTO>>(entities);
foreach (var itm in dtos)
{
var arys = jobs.Where(p => p.OrderNum == itm.Number);
var itmDetails = itm.Details.ToList();
var details = new List<UnplannedReceiptJobDetailDTO>();
foreach (var detail in arys)
{
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false);
if (fromloc == null)
{
errors.Add($"来源起始点{detail.BeginPosition}没查到");
}
LocationDTO fromlocation = null;
if (fromloc != null)
{
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.Code).ConfigureAwait(false);
}
if (fromlocation == null)
{
errors.Add($"来源起始点{detail.BeginPosition}库位没查到");
}
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition)
.ConfigureAwait(false);
if (toloc == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
LocationDTO tolocation = null;
if (toloc != null)
{
tolocation = await _locationAppService.GetByCodeAsync(toloc.Code).ConfigureAwait(false);
}
if (tolocation == null)
{
errors.Add($"结束点{detail.EndPosition}库位没查到");
}
var entity = itmDetails.FirstOrDefault(p => p.ItemCode == detail.MatCode);
if (entity == null)
{
errors.Add($"物料号{detail.MatCode}不在任务明细内!");
}
var dto = new UnplannedReceiptJobDetailDTO();
dto.InjectFrom(entity);
// dto.HandledQty = toloc.Code;
//dto.location = tolocation.LocationGroupCode;
//dto.HandledToLocationArea = tolocation.AreaCode;
//dto.HandledToLocationErpCode = tolocation.ErpLocationCode;
//dto.HandledToWarehouseCode = tolocation.WarehouseCode;
//dto.HandledToQty = detail.MatQty;
//dto.HandledToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty;
//dto.HandledToPackingCode = string.Empty;
//dto.HandledFromWarehouseCode = fromlocation.WarehouseCode;
//dto.HandledFromLocationCode = fromlocation.Code;
//dto.HandledFromLocationGroup = fromlocation.LocationGroupCode;
//dto.HandledFromLocationArea = fromlocation.AreaCode;
//dto.HandledFromLocationErpCode = fromlocation.ErpLocationCode;
//dto.HandledFromQty = detail.MatQty;
//dto.HandledFromLot = string.Empty;
//dto.HandledFromPackingCode = string.Empty;
details.Add(dto);
//await ExecuteDetailExtAsync(itm.Id, entity.Id, dto).ConfigureAwait(false);
}
if (errors.Count > 0)
{
ret = new AgvResultObject()
{
Code = "-1",
ReqCode = "",
Message = string.Join(",", errors.ToArray())
};
}
itm.Worker = "AGV";
itm.Details = details;
_logger.LogInformation($"{flag}接收Agv确认单据内容:" + json + "Agv任务完成");
}
}
else
{
errors.Add("Agv确认单据里无数据! \n");
}
}
catch (Exception ex)
{
ret = new AgvResultObject
{
Code = "-1",
ReqCode = job.UnplannedReceiptRequestNumber,
Message = ex.Message,
};
await unitOfWork.RollbackAsync();
return ret;
}
if (errors.Count > 0)
{
ret = new AgvResultObject
{
Code = "-1",
Message = string.Join(",", errors.ToArray()),
ReqCode = job.UnplannedReceiptRequestNumber
};
}
return ret;
}
}

42
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/StoreApplicationModule.cs

@ -1,3 +1,4 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.Application;
@ -6,6 +7,7 @@ using Volo.Abp.Modularity;
using Volo.Abp.Settings;
using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Jobs.AgvJobs;
using Win_in.Sfs.Wms.Store.Options;
namespace Win_in.Sfs.Wms.Store.Application;
@ -38,6 +40,46 @@ public class StoreApplicationModule : AbpModule
context.Services.Replace(ServiceDescriptor.Transient<IUnplannedIssueRequestAppService, UnplannedIssueRequestForDongyangAppService>());
context.Services.Replace(ServiceDescriptor.Transient<IUnplannedReceiptRequestAppService, UnplannedReceiptRequestForDongyangAppService>());
context.Services.Replace(ServiceDescriptor.Transient<ICountAdjustRequestAppService, CountAdjustRequestForDongyangAppService>());
context.Services.AddTransient(implementationFactory =>
{
Func<string, IAgvJobAccountService> accesor = key =>
{
if (key.Equals("1001"))
{
return implementationFactory.GetService<AssembleIssueJobAppService>();
}
if (key.Equals("1002"))
{
return implementationFactory.GetService<CoatingIssueJobAppService>();
}
if (key.Equals("1003"))
{
return implementationFactory.GetService<KittingIssueJobAppService>();
}
if (key.Equals("1004"))
{
return implementationFactory.GetService<InjectionIssueJobAppService>();
}
if (key.Equals("1005"))
{
return implementationFactory.GetService<SparePartIssueJobAppService>();
}
if (key.Equals("1005"))
{
return implementationFactory.GetService<UnplannedIssueJobAppService>();
}
if (key.Equals("1005"))
{
return implementationFactory.GetService<UnplannedReceiptJobAppService>();
}
else
{
throw new ArgumentException($"Not Support key:{key}");
}
}; return accesor;
});
//context.Services.Replace(ServiceDescriptor.Transient<IDeliverRequestAppService, deli>());
Configure<AbpSettingOptions>(options =>

Loading…
Cancel
Save