|
|
@ -55,6 +55,7 @@ public class CoatingIssueJobAppService |
|
|
|
private readonly IPostionLocationAppService _postionLocationAppService; |
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
private readonly ITransferNoteAppService _transferNoteAppService; |
|
|
|
private readonly ILocationDeliveryAppService _locationDeliveryAppService; |
|
|
|
|
|
|
|
protected ICoatingIssueRequestAppService CoatingIssueRequestAppService => |
|
|
|
LazyServiceProvider.LazyGetRequiredService<ICoatingIssueRequestAppService>(); |
|
|
@ -68,7 +69,10 @@ public class CoatingIssueJobAppService |
|
|
|
, IHttpClientFactory httpClientFactory |
|
|
|
, IOptions<RestoOptions> options, ITransferLibRequestAppService transferLibRequestAppService, ICurrentUser currentUser, IOptions<AgvOptions> agvOptions |
|
|
|
, UnitOfWorkManager unitOfWorkManager |
|
|
|
, IPostionLocationAppService postionLocationAppService, IItemBasicAppService _itemBasicAppService, ITransferNoteAppService transferNoteAppService |
|
|
|
, IPostionLocationAppService postionLocationAppService, IItemBasicAppService _itemBasicAppService, |
|
|
|
ITransferNoteAppService transferNoteAppService, |
|
|
|
ILocationDeliveryAppService locationDeliveryAppService |
|
|
|
|
|
|
|
) : base( |
|
|
|
repository, coatingIssueJobManager) |
|
|
|
{ |
|
|
@ -86,6 +90,7 @@ public class CoatingIssueJobAppService |
|
|
|
_agvOptions = agvOptions; |
|
|
|
_postionLocationAppService = postionLocationAppService; |
|
|
|
_transferLibRequestAppService= transferLibRequestAppService; |
|
|
|
_locationDeliveryAppService= locationDeliveryAppService; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("get-by-number-2")] |
|
|
@ -102,28 +107,66 @@ public class CoatingIssueJobAppService |
|
|
|
foreach (var input in inputs) |
|
|
|
{ |
|
|
|
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); |
|
|
|
foreach (var coatingIssueJobDto in coatingIssueJobDtos) |
|
|
|
var assembleIssueJobDtos = await base.CreateManyAsync(inputs).ConfigureAwait(false); |
|
|
|
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("")] |
|
|
|
public override async Task<CoatingIssueJobDTO> CreateAsync(CoatingIssueJobEditInput input) |
|
|
|
{ |
|
|
|
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); |
|
|
|
await DoingDimensionalStorehouseAsync(coatingIssueJobDto).ConfigureAwait(false); |
|
|
|
var assembleIssueJobDto = await base.CreateAsync(input).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")] |
|
|
@ -214,7 +257,23 @@ public class CoatingIssueJobAppService |
|
|
|
jobDetail.TransferLibToSupplierBatch = transferLibNoteDetail.HandledToSupplierBatch; |
|
|
|
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>
|
|
|
@ -475,6 +534,50 @@ public class CoatingIssueJobAppService |
|
|
|
|
|
|
|
#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>
|
|
|
@ -482,27 +585,29 @@ public class CoatingIssueJobAppService |
|
|
|
/// <param name="pLoc"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[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(); |
|
|
|
ret.Code = int.Parse(GaoTongResultStatus.Success); |
|
|
|
ret.Code = 0; |
|
|
|
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 |
|
|
|
{ |
|
|
|
var IssueJobToRestoDetailDTOs = new List<IssueJobToRestoDetailDTO>(); |
|
|
|
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 jobitem in job.Details) |
|
|
|
{ |
|
|
|
IssueJobToRestoDetailDTOs.Add(new IssueJobToRestoDetailDTO |
|
|
|
{ |
|
|
|
Count = jobitem.HandledToQty, |
|
|
|
Count = jobitem.RecommendFromQty, |
|
|
|
ProductNo = jobitem.ItemCode, |
|
|
|
NeedSite = pLoc, |
|
|
|
WorkNo = job.Number, |
|
|
|
WorkNo = job.CoatingRequestNumber, |
|
|
|
TaskNo = job.Number |
|
|
|
}); |
|
|
|
} |
|
|
@ -513,26 +618,31 @@ public class CoatingIssueJobAppService |
|
|
|
#if DEBUG
|
|
|
|
|
|
|
|
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.UserName = ""; //测试用户名
|
|
|
|
_options.Value.Password = ""; //测试密码
|
|
|
|
_options.Value.Path = "zozocnApi/custom/receiveProductionPlan"; //测试密码
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//var json = JsonSerializer.Serialize(main);
|
|
|
|
_options.Value.Address = "http://7e42682n64.goho.co:21171/"; //测试地址
|
|
|
|
_options.Value.Token = ""; //测试token
|
|
|
|
_options.Value.UserName = ""; //测试用户名
|
|
|
|
_options.Value.Password = ""; //测试密码
|
|
|
|
_options.Value.Path = "zozocnApi/custom/receiveProductionPlan"; //测试密码
|
|
|
|
|
|
|
|
_logger.LogInformation(System.Text.Json.JsonSerializer.Serialize(_options)); |
|
|
|
|
|
|
|
|
|
|
|
_options.Value.Address = string.IsNullOrEmpty(_options.Value.Address) |
|
|
|
? "http://7e42682n64.goho.co:21171/" |
|
|
|
: _options.Value.Address; //测试地址
|
|
|
|
_options.Value.Token = |
|
|
|
string.IsNullOrEmpty(_options.Value.Token) ? string.Empty : _options.Value.Token; //测试token
|
|
|
|
_options.Value.UserName = |
|
|
|
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)) |
|
|
@ -550,24 +660,17 @@ public class CoatingIssueJobAppService |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
_logger.LogInformation($"标志{flag}调用高通WMS:返回值{ret}"); |
|
|
|
|
|
|
|
_logger.LogInformation($"标志{flag}调用高通WMS:返回值{JsonSerializer.Serialize(ret)}"); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
ret = new ReusltObject(); |
|
|
|
ret.Code = int.Parse(GaoTongResultStatus.Failure); |
|
|
|
ret.Code = 1; |
|
|
|
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; |
|
|
@ -576,11 +679,19 @@ public class CoatingIssueJobAppService |
|
|
|
[HttpPost("receive-issue-job-stereo")] |
|
|
|
public virtual async Task<ReusltObject> SyncReciveIssueJobStereoAsync(IssueRequestFromRestoDTO input) |
|
|
|
{ |
|
|
|
#if DEBUG
|
|
|
|
var json = JsonSerializer.Serialize(input); |
|
|
|
var flag = DateTime.Now.ToString("yyyyMMddHHmmss"); |
|
|
|
_logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json); |
|
|
|
#if DEBUG
|
|
|
|
#endif
|
|
|
|
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 |
|
|
|
{ |
|
|
|
if (input.Jobs.Count > 0) |
|
|
@ -588,40 +699,102 @@ public class CoatingIssueJobAppService |
|
|
|
var jobs = input.Jobs; |
|
|
|
var numbers = jobs.Select(p => p.JobNumber); |
|
|
|
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 dtos = ObjectMapper.Map<List<CoatingIssueJob>, List<CoatingIssueJobDTO>>(entities); |
|
|
|
if (entities.Count == 0) |
|
|
|
{ |
|
|
|
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"); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var itm in dtos) |
|
|
|
{ |
|
|
|
|
|
|
|
var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); |
|
|
|
var itmDetails = itm.Details.ToList(); |
|
|
|
var details = new List<CoatingIssueJobDetailDTO>(); |
|
|
|
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); |
|
|
|
if (entity == null) |
|
|
|
{ |
|
|
|
errors.Add($"物料号{detail.ItemCode}不在任务明细内!"); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = new CoatingIssueJobDetailDTO(); |
|
|
|
dto.HandledFromLocationCode = entity.HandledFromLocationCode; |
|
|
|
dto.HandledToLocationCode = entity.HandledToLocationCode; |
|
|
|
dto.ItemCode = detail.ItemCode; |
|
|
|
dto.InjectFrom(entity); |
|
|
|
|
|
|
|
/* 客户说整单完成后才回传 |
|
|
|
dto.RecommendFromQty = detail.Qty; |
|
|
|
dto.RecommendToQty = detail.Qty; |
|
|
|
dto.HandledFromQty = 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); |
|
|
|
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; |
|
|
|
await CompleteAsync(itm.Id, itm).ConfigureAwait(false); |
|
|
|
// await CompleteAsync(itm.Id, itm).ConfigureAwait(false);
|
|
|
|
_logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json + "立体库任务完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
@ -635,8 +808,10 @@ public class CoatingIssueJobAppService |
|
|
|
{ |
|
|
|
Code = int.Parse(GaoTongResultStatus.Failure), |
|
|
|
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), |
|
|
|
Message = ex.Message |
|
|
|
Message = ex.Message, |
|
|
|
Data = json |
|
|
|
}; |
|
|
|
await unitOfWork.RollbackAsync(); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
@ -646,7 +821,8 @@ public class CoatingIssueJobAppService |
|
|
|
{ |
|
|
|
Code = int.Parse(GaoTongResultStatus.Failure), |
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
#region 私有
|
|
|
|
|
|
|
|
/// <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>
|
|
|
|
/// 修改当前任务状态 和 该任务的请求状态
|
|
|
@ -826,21 +976,77 @@ public class CoatingIssueJobAppService |
|
|
|
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>
|
|
|
|
/// 调用 Agv 接口
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <param name="pLoc"></param>
|
|
|
|
/// <param name="uid"></param>
|
|
|
|
/// <param name="beginPosition"></param>
|
|
|
|
/// <param name="endPosition"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[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(); |
|
|
|
List<string> errors = 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") |
|
|
|
{ |
|
|
|
_logger.LogInformation(jobres.Message); |
|
|
@ -868,170 +1074,74 @@ public class CoatingIssueJobAppService |
|
|
|
[HttpPost("call-back-agv")] |
|
|
|
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 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 entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false); |
|
|
|
var dto = ObjectMapper.Map<CoatingIssueJob, CoatingIssueJobDTO>(entity); |
|
|
|
|
|
|
|
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 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任务完成"); |
|
|
|
} |
|
|
|
foreach (var detail in entity.Details) |
|
|
|
{ |
|
|
|
var detailDto = new CoatingIssueJobDetailDTO(); |
|
|
|
if (!string.IsNullOrEmpty(detail.TransferLibFromLocationCode)) |
|
|
|
{ |
|
|
|
//库移的最终目标 挪到 推荐的目标
|
|
|
|
var fromloc = await _locationAppService.GetByCodeAsync(detail.TransferLibToLocationCode).ConfigureAwait(false); |
|
|
|
var toloc = await _locationAppService.GetByCodeAsync(detail.RecommendToLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
detailDto.InjectFrom(detail); |
|
|
|
|
|
|
|
detailDto.HandledToLocationCode = toloc.Code; |
|
|
|
detailDto.HandledToLocationGroup = toloc.LocationGroupCode; |
|
|
|
detailDto.HandledToLocationArea = toloc.AreaCode; |
|
|
|
detailDto.HandledToLocationErpCode = toloc.ErpLocationCode; |
|
|
|
detailDto.HandledToWarehouseCode = toloc.WarehouseCode; |
|
|
|
detailDto.HandledToQty = request.Data.First().MatQty; |
|
|
|
detailDto.HandledToLot = detail.TransferLibToLot; |
|
|
|
detailDto.HandledToPackingCode = detail.TransferLibToPackingCode; |
|
|
|
|
|
|
|
detailDto.HandledFromLocationCode = fromloc.Code; |
|
|
|
detailDto.HandledFromLocationGroup = fromloc.LocationGroupCode; |
|
|
|
detailDto.HandledFromLocationArea = fromloc.AreaCode; |
|
|
|
detailDto.HandledFromLocationErpCode = fromloc.ErpLocationCode; |
|
|
|
detailDto.HandledFromWarehouseCode = fromloc.WarehouseCode; |
|
|
|
detailDto.HandledFromQty = request.Data.First().MatQty;//2024-12-16 和励 张旭确认的 因为没有人工干预 也没校验 一托就直接顶走了
|
|
|
|
detailDto.HandledFromLot = detail.TransferLibToLot; |
|
|
|
detailDto.HandledFromPackingCode = detail.TransferLibToPackingCode; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
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) |
|
|
|
{ |
|
|
|
ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
ReqCode = job.CoatingRequestNumber, |
|
|
|
Message = ex.Message |
|
|
|
}; |
|
|
|
await unitOfWork.RollbackAsync().ConfigureAwait(false); |
|
|
|
return ret; |
|
|
|
|
|
|
|
await ExecuteDetailExtAsync(entity.Id, entity.Details.First().Id, detailDto).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
if (errors.Count > 0) |
|
|
|
return new AgvResultObject |
|
|
|
{ |
|
|
|
ret = new AgvResultObject |
|
|
|
{ |
|
|
|
Code = "-1", |
|
|
|
Message = string.Join(",", errors.ToArray()), |
|
|
|
ReqCode = job.CoatingRequestNumber |
|
|
|
}; |
|
|
|
} |
|
|
|
return ret; |
|
|
|
Code = "0", |
|
|
|
Message = "OK", |
|
|
|
ReqCode = "", |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -1188,12 +1298,12 @@ public class CoatingIssueJobAppService |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调用Agv接口实现
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="job"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<AgvResultObject> SendInterFaceAsync(CoatingIssueJobDTO job) |
|
|
|
/// <summary>
|
|
|
|
/// 调用Agv接口实现
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="job"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<AgvResultObject> SendInterFaceAsync(CoatingIssueJobDTO job, string beginPosition, string endPosition) |
|
|
|
{ |
|
|
|
#if DEBUG
|
|
|
|
|
|
|
@ -1225,8 +1335,9 @@ public class CoatingIssueJobAppService |
|
|
|
request.MatQty = first.HandledToQty; |
|
|
|
request.OrderNum = job.Number; |
|
|
|
request.OrderType = EnumJobType.CoatingIssueJob.ToString(); |
|
|
|
|
|
|
|
|
|
|
|
request.BeginPosition = beginPosition; |
|
|
|
request.EndPosition = endPosition; |
|
|
|
var httpclient = _httpClientFactory.CreateClient(); |
|
|
|
_agvOptions.Value.Address = string.IsNullOrEmpty(_agvOptions.Value.Address) |
|
|
|
? "http://7e42682n64.goho.co:21171/" |
|
|
|