|
|
@ -338,17 +338,11 @@ public class InjectionIssueJobAppService |
|
|
|
{ |
|
|
|
var injectionIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); |
|
|
|
injectionIssueJob.JobStatus = EnumJobStatus.Doing; |
|
|
|
if (injectionIssueJob.IsClaims) |
|
|
|
{ |
|
|
|
if (injectionIssueJob.ClaimsUserId != _currentUser.Id.ToString()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"该任务已被【{injectionIssueJob.ClaimsUserName}】承接"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("该任务未被承接,请重新刷新页面,承接任务"); |
|
|
|
} |
|
|
|
injectionIssueJob.ClaimsUserId = |
|
|
|
string.IsNullOrEmpty(_options.Value.StereosUser) ? "LYF" : _options.Value.StereosUser; |
|
|
|
injectionIssueJob.ClaimsUserName = string.IsNullOrEmpty(_options.Value.StereosPassword) |
|
|
|
? "LYF" |
|
|
|
: _options.Value.StereosPassword; |
|
|
|
|
|
|
|
var injectionIssueJobDto = ObjectMapper.Map<InjectionIssueJob, InjectionIssueJobDTO>(injectionIssueJob); |
|
|
|
injectionIssueJobDto.Details = new List<InjectionIssueJobDetailDTO> { issueJobDetailDto }; |
|
|
@ -487,71 +481,28 @@ public class InjectionIssueJobAppService |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 私有
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建补料记录实体
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="injectionIssueJobDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<InjectionIssueNoteEditInput> BuildInjectionIssueNoteAsync(InjectionIssueJobDTO injectionIssueJobDto) |
|
|
|
{ |
|
|
|
var injectionIssueNoteCreateInput = |
|
|
|
ObjectMapper.Map<InjectionIssueJobDTO, InjectionIssueNoteEditInput>(injectionIssueJobDto); |
|
|
|
injectionIssueNoteCreateInput.JobNumber = injectionIssueJobDto.Number; |
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
|
|
|
|
return injectionIssueNoteCreateInput; |
|
|
|
} |
|
|
|
#region 立库
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断是不是在最底层 如果不是则把状态变更为待库移 并把库移推荐的From和To赋值
|
|
|
|
/// 调用立体库
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <param name="InjectionIssueJobDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckMinRowAndSetStatusAsync(InjectionIssueJobEditInput input) |
|
|
|
private async Task DoingDimensionalStorehouseAsync(InjectionIssueJobDTO InjectionIssueJobDto) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = input.Details.FirstOrDefault(); |
|
|
|
|
|
|
|
var jobDetailInputdetail = InjectionIssueJobDto.Details.FirstOrDefault(); |
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode != 1) |
|
|
|
{ |
|
|
|
input.JobStatus = EnumJobStatus.Wait; |
|
|
|
} |
|
|
|
else if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode == 1) |
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
{ |
|
|
|
jobDetailInputdetail.TransferLibFromArriveDate = jobDetailInputdetail.RecommendFromArriveDate; |
|
|
|
jobDetailInputdetail.TransferLibFromContainerCode = jobDetailInputdetail.RecommendFromContainerCode; |
|
|
|
jobDetailInputdetail.TransferLibFromExpireDate = jobDetailInputdetail.RecommendFromExpireDate; |
|
|
|
jobDetailInputdetail.TransferLibFromLocationArea = jobDetailInputdetail.RecommendFromLocationArea; |
|
|
|
jobDetailInputdetail.TransferLibFromLocationCode = jobDetailInputdetail.RecommendFromLocationCode; |
|
|
|
jobDetailInputdetail.TransferLibFromLocationErpCode = jobDetailInputdetail.RecommendFromLocationErpCode; |
|
|
|
jobDetailInputdetail.TransferLibFromLocationGroup = jobDetailInputdetail.RecommendFromLocationGroup; |
|
|
|
jobDetailInputdetail.TransferLibFromLot = jobDetailInputdetail.RecommendFromLot; |
|
|
|
jobDetailInputdetail.TransferLibFromPackingCode = jobDetailInputdetail.RecommendFromPackingCode; |
|
|
|
jobDetailInputdetail.TransferLibFromProduceDate = jobDetailInputdetail.RecommendFromProduceDate; |
|
|
|
jobDetailInputdetail.TransferLibFromQty = jobDetailInputdetail.RecommendFromQty; |
|
|
|
jobDetailInputdetail.TransferLibFromSupplierBatch = jobDetailInputdetail.RecommendFromSupplierBatch; |
|
|
|
jobDetailInputdetail.TransferLibFromWarehouseCode = jobDetailInputdetail.RecommendFromWarehouseCode; |
|
|
|
|
|
|
|
jobDetailInputdetail.TransferLibToArriveDate = jobDetailInputdetail.RecommendToArriveDate; |
|
|
|
jobDetailInputdetail.TransferLibToContainerCode = jobDetailInputdetail.RecommendToContainerCode; |
|
|
|
jobDetailInputdetail.TransferLibToExpireDate = jobDetailInputdetail.RecommendToExpireDate; |
|
|
|
jobDetailInputdetail.TransferLibToLot = jobDetailInputdetail.RecommendToLot; |
|
|
|
jobDetailInputdetail.TransferLibToPackingCode = jobDetailInputdetail.RecommendToPackingCode; |
|
|
|
jobDetailInputdetail.TransferLibToProduceDate = jobDetailInputdetail.RecommendToProduceDate; |
|
|
|
jobDetailInputdetail.TransferLibToQty = jobDetailInputdetail.RecommendToQty; |
|
|
|
jobDetailInputdetail.TransferLibToSupplierBatch = jobDetailInputdetail.RecommendToSupplierBatch; |
|
|
|
jobDetailInputdetail.TransferLibToWarehouseCode = jobDetailInputdetail.TransferLibFromWarehouseCode; |
|
|
|
jobDetailInputdetail.TransferLibToLocationArea = jobDetailInputdetail.TransferLibFromLocationArea; |
|
|
|
jobDetailInputdetail.TransferLibToLocationCode = jobDetailInputdetail.TransferLibFromLocationCode; |
|
|
|
jobDetailInputdetail.TransferLibToLocationErpCode = jobDetailInputdetail.TransferLibFromLocationErpCode; |
|
|
|
jobDetailInputdetail.TransferLibToLocationGroup = jobDetailInputdetail.TransferLibFromLocationGroup; |
|
|
|
//TODO 立体库
|
|
|
|
var ret = await SyncIssueJobStereoAsync(new List<InjectionIssueJobDTO> { InjectionIssueJobDto }, |
|
|
|
jobDetailInputdetail.RecommendToLocationCode, InjectionIssueJobDto.Id).ConfigureAwait(false); |
|
|
|
if (ret.Code != 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -560,7 +511,7 @@ public class InjectionIssueJobAppService |
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckDimensionalStorehouseAsync(InjectionIssueJobEditInput input) |
|
|
|
private async Task<bool> UpdateJobStatusWaitByDimensionalStorehouseAsync(InjectionIssueJobEditInput input) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = input.Details.FirstOrDefault(); |
|
|
|
|
|
|
@ -570,125 +521,312 @@ public class InjectionIssueJobAppService |
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
{ |
|
|
|
input.JobStatus = EnumJobStatus.Wait; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改当前任务状态 和 该任务的请求状态
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="injectionIssueJob"></param>
|
|
|
|
/// <param name="injectionIssueJobDetailDto"></param>
|
|
|
|
/// <param name="handledToQty"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
private async Task UpdateRequestAndjobStatusDoneAsync(InjectionIssueJob injectionIssueJob, |
|
|
|
InjectionIssueJobDetailDTO injectionIssueJobDetailDto, decimal handledToQty) |
|
|
|
{ |
|
|
|
if (injectionIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None |
|
|
|
or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中
|
|
|
|
{ |
|
|
|
throw new UserFriendlyException( |
|
|
|
$"任务状态错误:编号为【{injectionIssueJob.Number}】的任务状态为【{injectionIssueJob.JobStatus.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
|
|
|
|
injectionIssueJob.JobStatus = EnumJobStatus.Done; |
|
|
|
|
|
|
|
await RemoveExpectOutAsync(injectionIssueJob, injectionIssueJobDetailDto, handledToQty).ConfigureAwait(false); |
|
|
|
|
|
|
|
//await _expectOutAppService.RemoveByNumberAsync(injectionIssueJob.Number).ConfigureAwait(false);
|
|
|
|
|
|
|
|
await InjectionIssueRequestAppService.UpdateStatusCompletedAsync(injectionIssueJob.InjectionRequestNumber) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断实际TO的箱码是否被占用
|
|
|
|
/// 立体库同步
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="packingCode"></param>
|
|
|
|
/// <param name="jobNumber"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <param name="pLoc"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
private async Task CheckPackingCodeIsUserAsync(string packingCode, string jobNumber) |
|
|
|
[HttpPost("sync-issue-job-stereo")] |
|
|
|
public async Task<ReusltObject> SyncIssueJobStereoAsync(List<InjectionIssueJobDTO> input, string pLoc, Guid uid) |
|
|
|
{ |
|
|
|
var list = await _expectOutAppService.GetListByPackingCodeAsync(packingCode).ConfigureAwait(false); |
|
|
|
list = list.Where(p => p.JobNumber != jobNumber).ToList(); |
|
|
|
if (list.Any()) |
|
|
|
var ret = new ReusltObject(); |
|
|
|
ret.Code = 0; |
|
|
|
ret.Message = "操作成功"; |
|
|
|
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
using var unitOfWork = _unitOfWorkManager.Begin(); |
|
|
|
try |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"任务号【{list.First().JobNumber}】的任务,已占用【{packingCode}】箱码的库存。"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task RemoveExpectOutAsync(InjectionIssueJob injectionIssueJob, |
|
|
|
InjectionIssueJobDetailDTO injectionIssueJobDetailDto, |
|
|
|
decimal handledToQty) |
|
|
|
{ |
|
|
|
await _expectOutAppService.RemoveByNumberAndInventoryAsync(injectionIssueJob.Number, |
|
|
|
injectionIssueJobDetailDto.ItemCode, |
|
|
|
injectionIssueJobDetailDto.HandledToLocationCode, injectionIssueJobDetailDto.HandledToPackingCode, |
|
|
|
injectionIssueJobDetailDto.Status, injectionIssueJobDetailDto.HandledToLot, |
|
|
|
handledToQty).ConfigureAwait(false); |
|
|
|
} |
|
|
|
var IssueJobToRestoDetailDTOs = new List<IssueJobToRestoDetailDTO>(); |
|
|
|
var main = new IssueJobToRestoDTO(); |
|
|
|
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.RecommendFromQty, |
|
|
|
ProductNo = jobitem.ItemCode, |
|
|
|
NeedSite = pLoc, |
|
|
|
WorkNo = job.InjectionRequestNumber, |
|
|
|
TaskNo = job.Number |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
main.Details = IssueJobToRestoDetailDTOs; |
|
|
|
var httpclient = _httpClientFactory.CreateClient(); |
|
|
|
#if DEBUG
|
|
|
|
|
|
|
|
var json = JsonSerializer.Serialize(main); |
|
|
|
_options.Value.Address = "http://localhost:59094/"; //测试地址
|
|
|
|
_options.Value.Token = ""; //测试token
|
|
|
|
_options.Value.UserName = ""; //测试用户名
|
|
|
|
_options.Value.Password = ""; //测试密码
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//var json = JsonSerializer.Serialize(main);
|
|
|
|
_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)) |
|
|
|
{ |
|
|
|
var token = _options.Value.Token; |
|
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Agv
|
|
|
|
if (!string.IsNullOrEmpty(_options.Value.UserName) && !string.IsNullOrEmpty(_options.Value.Password)) |
|
|
|
{ |
|
|
|
var username = _options.Value.UserName; |
|
|
|
var password = _options.Value.Password; |
|
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", |
|
|
|
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); |
|
|
|
} |
|
|
|
|
|
|
|
/// <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); |
|
|
|
var client = new IssueJobToRestoClient(_options.Value.Address, httpclient, _options.Value.Path); |
|
|
|
ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false); |
|
|
|
|
|
|
|
if (locationDeliveryDto != null && locationDeliveryDto.EnumLocationDeliveryType == EnumLocationDeliveryType.Agv) |
|
|
|
_logger.LogInformation($"标志{flag}调用高通WMS:返回值{JsonSerializer.Serialize(ret)}"); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
//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}"); |
|
|
|
} |
|
|
|
ret = new ReusltObject(); |
|
|
|
ret.Code = 1; |
|
|
|
ret.Message = ex.Message; |
|
|
|
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
await unitOfWork.RollbackAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断是不是有Agv
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<bool> UpdateJobStatusWaitByAgvAsync(InjectionIssueJobEditInput input) |
|
|
|
[HttpPost("receive-issue-job-stereo")] |
|
|
|
public virtual async Task<ReusltObject> SyncReciveIssueJobStereoAsync(IssueRequestFromRestoDTO input) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = input.Details.FirstOrDefault(); |
|
|
|
|
|
|
|
var locationDeliveryDto = await _locationDeliveryAppService.GetByFromLocationCodeAndToLocationCodeAsync( |
|
|
|
jobDetailInputdetail.RecommendFromLocationCode, jobDetailInputdetail.RecommendToLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
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 = 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) |
|
|
|
{ |
|
|
|
var jobs = input.Jobs; |
|
|
|
var numbers = jobs.Select(p => p.JobNumber); |
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
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<InjectionIssueJobDetailDTO>(); |
|
|
|
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 InjectionIssueJobDetailDTO(); |
|
|
|
dto.InjectFrom(entity); |
|
|
|
|
|
|
|
/* 客户说整单完成后才回传 |
|
|
|
dto.RecommendFromQty = detail.Qty; |
|
|
|
dto.RecommendToQty = detail.Qty; |
|
|
|
dto.HandledFromQty = detail.Qty; |
|
|
|
dto.HandledToQty = detail.Qty; |
|
|
|
*/ |
|
|
|
//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);
|
|
|
|
_logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json + "立体库任务完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
errors.Add("立体库确认单据里无数据! \n"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
ret = new ReusltObject |
|
|
|
{ |
|
|
|
Code = int.Parse(GaoTongResultStatus.Failure), |
|
|
|
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), |
|
|
|
Message = ex.Message, |
|
|
|
Data = json |
|
|
|
}; |
|
|
|
await unitOfWork.RollbackAsync(); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
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 |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
#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; |
|
|
@ -1027,304 +1165,161 @@ public class InjectionIssueJobAppService |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 立库
|
|
|
|
#region 私有
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调用立体库
|
|
|
|
/// 创建补料记录实体
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="InjectionIssueJobDto"></param>
|
|
|
|
/// <param name="injectionIssueJobDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task DoingDimensionalStorehouseAsync(InjectionIssueJobDTO InjectionIssueJobDto) |
|
|
|
private async Task<InjectionIssueNoteEditInput> BuildInjectionIssueNoteAsync(InjectionIssueJobDTO injectionIssueJobDto) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = InjectionIssueJobDto.Details.FirstOrDefault(); |
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
var injectionIssueNoteCreateInput = |
|
|
|
ObjectMapper.Map<InjectionIssueJobDTO, InjectionIssueNoteEditInput>(injectionIssueJobDto); |
|
|
|
injectionIssueNoteCreateInput.JobNumber = injectionIssueJobDto.Number; |
|
|
|
|
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
{ |
|
|
|
//TODO 立体库
|
|
|
|
var ret = await SyncIssueJobStereoAsync(new List<InjectionIssueJobDTO> { InjectionIssueJobDto }, |
|
|
|
jobDetailInputdetail.RecommendToLocationCode, InjectionIssueJobDto.Id).ConfigureAwait(false); |
|
|
|
if (ret.Code != 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}"); |
|
|
|
} |
|
|
|
} |
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
|
|
|
|
return injectionIssueNoteCreateInput; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断是不是在立体库
|
|
|
|
/// 判断是不是在最底层 如果不是则把状态变更为待库移 并把库移推荐的From和To赋值
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<bool> UpdateJobStatusWaitByDimensionalStorehouseAsync(InjectionIssueJobEditInput input) |
|
|
|
private async Task CheckMinRowAndSetStatusAsync(InjectionIssueJobEditInput input) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = input.Details.FirstOrDefault(); |
|
|
|
|
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode != 1) |
|
|
|
{ |
|
|
|
input.JobStatus = EnumJobStatus.Wait; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 立体库同步
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <param name="pLoc"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("sync-issue-job-stereo")] |
|
|
|
public async Task<ReusltObject> SyncIssueJobStereoAsync(List<InjectionIssueJobDTO> input, string pLoc, Guid uid) |
|
|
|
{ |
|
|
|
var ret = new ReusltObject(); |
|
|
|
ret.Code = 0; |
|
|
|
ret.Message = "操作成功"; |
|
|
|
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
using var unitOfWork = _unitOfWorkManager.Begin(); |
|
|
|
try |
|
|
|
else if (loctionDto.Type == EnumLocationType.RAW && loctionDto.RowCode == 1) |
|
|
|
{ |
|
|
|
var IssueJobToRestoDetailDTOs = new List<IssueJobToRestoDetailDTO>(); |
|
|
|
var main = new IssueJobToRestoDTO(); |
|
|
|
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.RecommendFromQty, |
|
|
|
ProductNo = jobitem.ItemCode, |
|
|
|
NeedSite = pLoc, |
|
|
|
WorkNo = job.InjectionRequestNumber, |
|
|
|
TaskNo = job.Number |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
main.Details = IssueJobToRestoDetailDTOs; |
|
|
|
var httpclient = _httpClientFactory.CreateClient(); |
|
|
|
#if DEBUG
|
|
|
|
|
|
|
|
var json = JsonSerializer.Serialize(main); |
|
|
|
_options.Value.Address = "http://localhost:59094/"; //测试地址
|
|
|
|
_options.Value.Token = ""; //测试token
|
|
|
|
_options.Value.UserName = ""; //测试用户名
|
|
|
|
_options.Value.Password = ""; //测试密码
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//var json = JsonSerializer.Serialize(main);
|
|
|
|
_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)}"); |
|
|
|
|
|
|
|
jobDetailInputdetail.TransferLibFromArriveDate = jobDetailInputdetail.RecommendFromArriveDate; |
|
|
|
jobDetailInputdetail.TransferLibFromContainerCode = jobDetailInputdetail.RecommendFromContainerCode; |
|
|
|
jobDetailInputdetail.TransferLibFromExpireDate = jobDetailInputdetail.RecommendFromExpireDate; |
|
|
|
jobDetailInputdetail.TransferLibFromLocationArea = jobDetailInputdetail.RecommendFromLocationArea; |
|
|
|
jobDetailInputdetail.TransferLibFromLocationCode = jobDetailInputdetail.RecommendFromLocationCode; |
|
|
|
jobDetailInputdetail.TransferLibFromLocationErpCode = jobDetailInputdetail.RecommendFromLocationErpCode; |
|
|
|
jobDetailInputdetail.TransferLibFromLocationGroup = jobDetailInputdetail.RecommendFromLocationGroup; |
|
|
|
jobDetailInputdetail.TransferLibFromLot = jobDetailInputdetail.RecommendFromLot; |
|
|
|
jobDetailInputdetail.TransferLibFromPackingCode = jobDetailInputdetail.RecommendFromPackingCode; |
|
|
|
jobDetailInputdetail.TransferLibFromProduceDate = jobDetailInputdetail.RecommendFromProduceDate; |
|
|
|
jobDetailInputdetail.TransferLibFromQty = jobDetailInputdetail.RecommendFromQty; |
|
|
|
jobDetailInputdetail.TransferLibFromSupplierBatch = jobDetailInputdetail.RecommendFromSupplierBatch; |
|
|
|
jobDetailInputdetail.TransferLibFromWarehouseCode = jobDetailInputdetail.RecommendFromWarehouseCode; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_options.Value.Token)) |
|
|
|
{ |
|
|
|
var token = _options.Value.Token; |
|
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); |
|
|
|
} |
|
|
|
jobDetailInputdetail.TransferLibToArriveDate = jobDetailInputdetail.RecommendToArriveDate; |
|
|
|
jobDetailInputdetail.TransferLibToContainerCode = jobDetailInputdetail.RecommendToContainerCode; |
|
|
|
jobDetailInputdetail.TransferLibToExpireDate = jobDetailInputdetail.RecommendToExpireDate; |
|
|
|
jobDetailInputdetail.TransferLibToLot = jobDetailInputdetail.RecommendToLot; |
|
|
|
jobDetailInputdetail.TransferLibToPackingCode = jobDetailInputdetail.RecommendToPackingCode; |
|
|
|
jobDetailInputdetail.TransferLibToProduceDate = jobDetailInputdetail.RecommendToProduceDate; |
|
|
|
jobDetailInputdetail.TransferLibToQty = jobDetailInputdetail.RecommendToQty; |
|
|
|
jobDetailInputdetail.TransferLibToSupplierBatch = jobDetailInputdetail.RecommendToSupplierBatch; |
|
|
|
jobDetailInputdetail.TransferLibToWarehouseCode = jobDetailInputdetail.TransferLibFromWarehouseCode; |
|
|
|
jobDetailInputdetail.TransferLibToLocationArea = jobDetailInputdetail.TransferLibFromLocationArea; |
|
|
|
jobDetailInputdetail.TransferLibToLocationCode = jobDetailInputdetail.TransferLibFromLocationCode; |
|
|
|
jobDetailInputdetail.TransferLibToLocationErpCode = jobDetailInputdetail.TransferLibFromLocationErpCode; |
|
|
|
jobDetailInputdetail.TransferLibToLocationGroup = jobDetailInputdetail.TransferLibFromLocationGroup; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_options.Value.UserName) && !string.IsNullOrEmpty(_options.Value.Password)) |
|
|
|
{ |
|
|
|
var username = _options.Value.UserName; |
|
|
|
var password = _options.Value.Password; |
|
|
|
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", |
|
|
|
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))); |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 判断是不是在立体库
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckDimensionalStorehouseAsync(InjectionIssueJobEditInput input) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = input.Details.FirstOrDefault(); |
|
|
|
|
|
|
|
var client = new IssueJobToRestoClient(_options.Value.Address, httpclient, _options.Value.Path); |
|
|
|
ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false); |
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
_logger.LogInformation($"标志{flag}调用高通WMS:返回值{JsonSerializer.Serialize(ret)}"); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
{ |
|
|
|
ret = new ReusltObject(); |
|
|
|
ret.Code = 1; |
|
|
|
ret.Message = ex.Message; |
|
|
|
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
await unitOfWork.RollbackAsync().ConfigureAwait(false); |
|
|
|
input.JobStatus = EnumJobStatus.Wait; |
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("receive-issue-job-stereo")] |
|
|
|
public virtual async Task<ReusltObject> SyncReciveIssueJobStereoAsync(IssueRequestFromRestoDTO input) |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改当前任务状态 和 该任务的请求状态
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="injectionIssueJob"></param>
|
|
|
|
/// <param name="injectionIssueJobDetailDto"></param>
|
|
|
|
/// <param name="handledToQty"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
private async Task UpdateRequestAndjobStatusDoneAsync(InjectionIssueJob injectionIssueJob, |
|
|
|
InjectionIssueJobDetailDTO injectionIssueJobDetailDto, decimal handledToQty) |
|
|
|
{ |
|
|
|
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 = int.Parse(GaoTongResultStatus.Success), |
|
|
|
OperateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
Message = "操作成功" |
|
|
|
}; |
|
|
|
using var unitOfWork = _unitOfWorkManager.Begin(); |
|
|
|
try |
|
|
|
if (injectionIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None |
|
|
|
or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中
|
|
|
|
{ |
|
|
|
if (input.Jobs.Count > 0) |
|
|
|
{ |
|
|
|
var jobs = input.Jobs; |
|
|
|
var numbers = jobs.Select(p => p.JobNumber); |
|
|
|
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)}不存在!"); |
|
|
|
} |
|
|
|
throw new UserFriendlyException( |
|
|
|
$"任务状态错误:编号为【{injectionIssueJob.Number}】的任务状态为【{injectionIssueJob.JobStatus.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
|
|
|
|
var dtos = ObjectMapper.Map<List<InjectionIssueJob>, List<InjectionIssueJobDTO>>(entities); |
|
|
|
injectionIssueJob.JobStatus = EnumJobStatus.Done; |
|
|
|
|
|
|
|
await RemoveExpectOutAsync(injectionIssueJob, injectionIssueJobDetailDto, handledToQty).ConfigureAwait(false); |
|
|
|
|
|
|
|
if (input.Jobs.Count != entities.Count) |
|
|
|
{ |
|
|
|
errors.Add("立体库提交出库任务和WMS任务不符,请核对! \n"); |
|
|
|
} |
|
|
|
//await _expectOutAppService.RemoveByNumberAsync(injectionIssueJob.Number).ConfigureAwait(false);
|
|
|
|
|
|
|
|
foreach (var itm in dtos) |
|
|
|
{ |
|
|
|
await InjectionIssueRequestAppService.UpdateStatusCompletedAsync(injectionIssueJob.InjectionRequestNumber) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
var first = jobs.FirstOrDefault(p => p.JobNumber == itm.Number); |
|
|
|
var itmDetails = itm.Details.ToList(); |
|
|
|
var details = new List<InjectionIssueJobDetailDTO>(); |
|
|
|
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}不在任务明细内!"); |
|
|
|
} |
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = new InjectionIssueJobDetailDTO(); |
|
|
|
dto.InjectFrom(entity); |
|
|
|
/// <summary>
|
|
|
|
/// 判断实际TO的箱码是否被占用
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="packingCode"></param>
|
|
|
|
/// <param name="jobNumber"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
private async Task CheckPackingCodeIsUserAsync(string packingCode, string jobNumber) |
|
|
|
{ |
|
|
|
var list = await _expectOutAppService.GetListByPackingCodeAsync(packingCode).ConfigureAwait(false); |
|
|
|
list = list.Where(p => p.JobNumber != jobNumber).ToList(); |
|
|
|
if (list.Any()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"任务号【{list.First().JobNumber}】的任务,已占用【{packingCode}】箱码的库存。"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* 客户说整单完成后才回传 |
|
|
|
dto.RecommendFromQty = detail.Qty; |
|
|
|
dto.RecommendToQty = detail.Qty; |
|
|
|
dto.HandledFromQty = detail.Qty; |
|
|
|
dto.HandledToQty = detail.Qty; |
|
|
|
*/ |
|
|
|
//dto.RecommendFromQty = detail.Qty;
|
|
|
|
//dto.RecommendToQty = detail.Qty;
|
|
|
|
//dto.HandledFromQty = detail.Qty;
|
|
|
|
//dto.HandledToQty = detail.Qty;
|
|
|
|
private async Task RemoveExpectOutAsync(InjectionIssueJob injectionIssueJob, |
|
|
|
InjectionIssueJobDetailDTO injectionIssueJobDetailDto, |
|
|
|
decimal handledToQty) |
|
|
|
{ |
|
|
|
await _expectOutAppService.RemoveByNumberAndInventoryAsync(injectionIssueJob.Number, |
|
|
|
injectionIssueJobDetailDto.ItemCode, |
|
|
|
injectionIssueJobDetailDto.HandledToLocationCode, injectionIssueJobDetailDto.HandledToPackingCode, |
|
|
|
injectionIssueJobDetailDto.Status, injectionIssueJobDetailDto.HandledToLot, |
|
|
|
handledToQty).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
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);
|
|
|
|
_logger.LogInformation($"{flag}接收到立体库确认单据内容:" + json + "立体库任务完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
errors.Add("立体库确认单据里无数据! \n"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
ret = new ReusltObject |
|
|
|
{ |
|
|
|
Code = int.Parse(GaoTongResultStatus.Failure), |
|
|
|
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), |
|
|
|
Message = ex.Message, |
|
|
|
Data = json |
|
|
|
}; |
|
|
|
await unitOfWork.RollbackAsync(); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
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 |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|