|
|
@ -103,30 +103,67 @@ public class SparePartIssueJobAppService |
|
|
|
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 sparePartIssueJobDtos = await base.CreateManyAsync(inputs).ConfigureAwait(false); |
|
|
|
foreach (var sparePartIssueJobDto in sparePartIssueJobDtos) |
|
|
|
var assembleIssueJobDtos = await base.CreateManyAsync(inputs).ConfigureAwait(false); |
|
|
|
foreach (var assembleIssueJobDto in assembleIssueJobDtos) |
|
|
|
{ |
|
|
|
await DoingDimensionalStorehouseAsync(sparePartIssueJobDto).ConfigureAwait(false); |
|
|
|
await DoingDimensionalStorehouseAsync(assembleIssueJobDto).ConfigureAwait(false); |
|
|
|
var firstDetail = assembleIssueJobDto.Details.First(); |
|
|
|
await DoingAgvAsync(assembleIssueJobDto, firstDetail.RecommendFromLocationCode, firstDetail.RecommendToLocationCode).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
return sparePartIssueJobDtos; |
|
|
|
return assembleIssueJobDtos; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("")] |
|
|
|
public override async Task<SparePartIssueJobDTO> CreateAsync(SparePartIssueJobEditInput 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 sparePartIssueJobDto = await base.CreateAsync(input).ConfigureAwait(false); |
|
|
|
await DoingDimensionalStorehouseAsync(sparePartIssueJobDto).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 sparePartIssueJobDto; |
|
|
|
return assembleIssueJobDto; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("invalid")] |
|
|
|
public override async Task CancelAsync(Guid id) |
|
|
|
{ |
|
|
@ -139,7 +176,9 @@ public class SparePartIssueJobAppService |
|
|
|
if (sparePartJob.JobStatus == EnumJobStatus.Open || |
|
|
|
sparePartJob.JobStatus == EnumJobStatus.Partial || |
|
|
|
sparePartJob.JobStatus == EnumJobStatus.Wait|| |
|
|
|
sparePartJob.JobStatus == EnumJobStatus.Doing) |
|
|
|
sparePartJob.JobStatus == EnumJobStatus.Doing|| |
|
|
|
sparePartJob.JobStatus == EnumJobStatus.WaitAgv) |
|
|
|
|
|
|
|
{ |
|
|
|
await _expectOutAppService.RemoveByNumberAsync(sparePartJob.Number).ConfigureAwait(false); |
|
|
|
await _transferLibRequestAppService.CancelByCallRequestNumberAsync(sparePartJob.SparePartRequestNumber) |
|
|
@ -154,7 +193,11 @@ public class SparePartIssueJobAppService |
|
|
|
$"{EnumJobStatus.Open.GetDisplayName()}、" + |
|
|
|
$"{EnumJobStatus.Partial.GetDisplayName()}、" + |
|
|
|
$"{EnumJobStatus.Doing.GetDisplayName()}、" + |
|
|
|
$"{EnumJobStatus.Wait.GetDisplayName()}"); |
|
|
|
$"{EnumJobStatus.Wait.GetDisplayName()}"+ |
|
|
|
$"{EnumJobStatus.WaitAgv.GetDisplayName()}" |
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -455,8 +498,54 @@ public class SparePartIssueJobAppService |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 立库
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调用立体库
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="SparePartIssueJobDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task DoingDimensionalStorehouseAsync(SparePartIssueJobDTO SparePartIssueJobDto) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = SparePartIssueJobDto.Details.FirstOrDefault(); |
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
{ |
|
|
|
//TODO 立体库
|
|
|
|
var ret = await SyncIssueJobStereoAsync(new List<SparePartIssueJobDTO> { SparePartIssueJobDto }, |
|
|
|
jobDetailInputdetail.RecommendToLocationCode, SparePartIssueJobDto.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(SparePartIssueJobEditInput 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>
|
|
|
@ -464,27 +553,29 @@ public class SparePartIssueJobAppService |
|
|
|
/// <param name="pLoc"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("sync-issue-job-stereo")] |
|
|
|
public async Task<ReusltObject> SyncIssueJobStereoAsync(List<SparePartIssueJobDTO> input, string pLoc) |
|
|
|
public async Task<ReusltObject> SyncIssueJobStereoAsync(List<SparePartIssueJobDTO> input, string pLoc, Guid uid) |
|
|
|
{ |
|
|
|
var ret = new ReusltObject(); |
|
|
|
ret.Code = 1; |
|
|
|
ret.Code = 0; |
|
|
|
ret.Message = "操作成功"; |
|
|
|
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.SparePartRequestNumber, |
|
|
|
TaskNo = job.Number |
|
|
|
}); |
|
|
|
} |
|
|
@ -501,6 +592,27 @@ public class SparePartIssueJobAppService |
|
|
|
_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; |
|
|
@ -517,13 +629,16 @@ public class SparePartIssueJobAppService |
|
|
|
|
|
|
|
var client = new IssueJobToRestoClient(_options.Value.Address, httpclient, _options.Value.Path); |
|
|
|
ret = await client.SyncIssueJobStereoAsync(main).ConfigureAwait(false); |
|
|
|
|
|
|
|
_logger.LogInformation($"标志{flag}调用高通WMS:返回值{JsonSerializer.Serialize(ret)}"); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
ret = new ReusltObject(); |
|
|
|
ret.Code = -1; |
|
|
|
ret.Code = 1; |
|
|
|
ret.Message = ex.Message; |
|
|
|
ret.OperateTime = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
await unitOfWork.RollbackAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
@ -532,11 +647,19 @@ public class SparePartIssueJobAppService |
|
|
|
[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"), 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) |
|
|
@ -544,36 +667,102 @@ public class SparePartIssueJobAppService |
|
|
|
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(); |
|
|
|
if (entities.Count == 0) |
|
|
|
{ |
|
|
|
errors.Add($"任务号{string.Join(",", numbers)}不存在!"); |
|
|
|
} |
|
|
|
|
|
|
|
var dtos = ObjectMapper.Map<List<SparePartIssueJob>, List<SparePartIssueJobDTO>>(entities); |
|
|
|
if (input.Jobs.Count == entities.Count) |
|
|
|
|
|
|
|
|
|
|
|
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<SparePartIssueJobDetailDTO>(); |
|
|
|
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 SparePartIssueJobDetailDTO(); |
|
|
|
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 |
|
|
@ -585,8 +774,12 @@ public class SparePartIssueJobAppService |
|
|
|
{ |
|
|
|
ret = new ReusltObject |
|
|
|
{ |
|
|
|
Code = 2, OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), Message = ex.Message |
|
|
|
Code = int.Parse(GaoTongResultStatus.Failure), |
|
|
|
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), |
|
|
|
Message = ex.Message, |
|
|
|
Data = json |
|
|
|
}; |
|
|
|
await unitOfWork.RollbackAsync(); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
@ -594,9 +787,10 @@ public class SparePartIssueJobAppService |
|
|
|
{ |
|
|
|
ret = new ReusltObject |
|
|
|
{ |
|
|
|
Code = 2, |
|
|
|
Code = int.Parse(GaoTongResultStatus.Failure), |
|
|
|
OperateTime = DateTime.Now.ToString("yyyy-MM-dd"), |
|
|
|
Message = string.Join(",", errors.ToArray()) |
|
|
|
Message = string.Join(",", errors.ToArray()), |
|
|
|
Data = json |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
@ -605,176 +799,6 @@ public class SparePartIssueJobAppService |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 私有
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建补料记录实体
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sparePartIssueJobDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<SparePartIssueNoteEditInput> BuildSparePartIssueNoteAsync(SparePartIssueJobDTO sparePartIssueJobDto) |
|
|
|
{ |
|
|
|
var sparePartIssueNoteCreateInput = |
|
|
|
ObjectMapper.Map<SparePartIssueJobDTO, SparePartIssueNoteEditInput>(sparePartIssueJobDto); |
|
|
|
sparePartIssueNoteCreateInput.JobNumber = sparePartIssueJobDto.Number; |
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
|
|
|
|
return sparePartIssueNoteCreateInput; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断是不是在最底层 如果不是则把状态变更为待库移 并把库移推荐的From和To赋值
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckMinRowAndSetStatusAsync(SparePartIssueJobEditInput input) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = input.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)
|
|
|
|
//{
|
|
|
|
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; |
|
|
|
//}
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断是不是在立体库
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckDimensionalStorehouseAsync(SparePartIssueJobEditInput input) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = input.Details.FirstOrDefault(); |
|
|
|
|
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
{ |
|
|
|
input.JobStatus = EnumJobStatus.Wait; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调用立体库
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sparePartIssueJobDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task DoingDimensionalStorehouseAsync(SparePartIssueJobDTO sparePartIssueJobDto) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = sparePartIssueJobDto.Details.FirstOrDefault(); |
|
|
|
|
|
|
|
var loctionDto = await _locationAppService.GetByCodeAsync(jobDetailInputdetail.RecommendFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
if (loctionDto.Type == EnumLocationType.DimensionalStorehouse) |
|
|
|
{ |
|
|
|
//TODO 立体库
|
|
|
|
var ret = await SyncIssueJobStereoAsync(new List<SparePartIssueJobDTO> { sparePartIssueJobDto }, |
|
|
|
loctionDto.Code).ConfigureAwait(false); |
|
|
|
if (ret.Code != 1) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"调用立体库不成功!原因:{ret.Message}"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改当前任务状态 和 该任务的请求状态
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sparePartIssueJob"></param>
|
|
|
|
/// <param name="sparePartIssueJobDetailDto"></param>
|
|
|
|
/// <param name="handledToQty"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
private async Task UpdateRequestAndjobStatusDoneAsync(SparePartIssueJob sparePartIssueJob, |
|
|
|
SparePartIssueJobDetailDTO sparePartIssueJobDetailDto, decimal handledToQty) |
|
|
|
{ |
|
|
|
if (sparePartIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None |
|
|
|
or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中
|
|
|
|
{ |
|
|
|
throw new UserFriendlyException( |
|
|
|
$"任务状态错误:编号为【{sparePartIssueJob.Number}】的任务状态为【{sparePartIssueJob.JobStatus.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
|
|
|
|
sparePartIssueJob.JobStatus = EnumJobStatus.Done; |
|
|
|
|
|
|
|
await RemoveExpectOutAsync(sparePartIssueJob, sparePartIssueJobDetailDto, handledToQty).ConfigureAwait(false); |
|
|
|
|
|
|
|
//await _expectOutAppService.RemoveByNumberAsync(sparePartIssueJob.Number).ConfigureAwait(false);
|
|
|
|
|
|
|
|
await SparePartIssueRequestAppService.UpdateStatusCompletedAsync(sparePartIssueJob.SparePartRequestNumber) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <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}】箱码的库存。"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task RemoveExpectOutAsync(SparePartIssueJob sparePartIssueJob, |
|
|
|
SparePartIssueJobDetailDTO sparePartIssueJobDetailDto, |
|
|
|
decimal handledToQty) |
|
|
|
{ |
|
|
|
await _expectOutAppService.RemoveByNumberAndInventoryAsync(sparePartIssueJob.Number, |
|
|
|
sparePartIssueJobDetailDto.ItemCode, |
|
|
|
sparePartIssueJobDetailDto.HandledToLocationCode, sparePartIssueJobDetailDto.HandledToPackingCode, |
|
|
|
sparePartIssueJobDetailDto.Status, sparePartIssueJobDetailDto.HandledToLot, |
|
|
|
handledToQty).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Agv
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -867,12 +891,12 @@ public class SparePartIssueJobAppService |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Agv 回调 接口
|
|
|
|
/// Agv 执行完发料回调接口
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("call-back-agv")] |
|
|
|
public async Task<AgvResultObject> CallBackAgvAsync(AgvRequestDto request) |
|
|
|
public async Task<AgvResultObject> CallBackAgvIssueAsync(AgvRequestDto request) |
|
|
|
{ |
|
|
|
var entity = await _repository.FindAsync(p => p.Number == request.Data.First().OrderNum).ConfigureAwait(false); |
|
|
|
var dto = ObjectMapper.Map<SparePartIssueJob, SparePartIssueJobDTO>(entity); |
|
|
@ -972,46 +996,29 @@ public class SparePartIssueJobAppService |
|
|
|
|
|
|
|
foreach (var detail in notes) |
|
|
|
{ |
|
|
|
TransferNoteEditInput transfer = new TransferNoteEditInput(); |
|
|
|
var transfer = new TransferNoteEditInput(); |
|
|
|
transfer.CallJobNumber = detail.OrderNum; |
|
|
|
transfer.Type = EnumTransSubType.Agv_Return_SparePart.ToString(); |
|
|
|
transfer.Type = EnumTransSubType.Transfer_WIP.ToString(); |
|
|
|
transfer.Worker = "Agv"; |
|
|
|
transfer.UseOnTheWayLocation = false; |
|
|
|
List<TransferNoteDetailInput> transferNoteDetailInputs = new List<TransferNoteDetailInput>(); |
|
|
|
TransferNoteDetailInput detailInput = new TransferNoteDetailInput(); |
|
|
|
var fromloc = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); |
|
|
|
if (fromloc == null) |
|
|
|
{ |
|
|
|
errors.Add($"来源起始点{detail.BeginPosition}没查到"); |
|
|
|
} |
|
|
|
LocationDTO fromlocation = null; |
|
|
|
if (fromloc != null) |
|
|
|
{ |
|
|
|
fromlocation = await _locationAppService.GetByCodeAsync(fromloc.LocationCode).ConfigureAwait(false); |
|
|
|
} |
|
|
|
if (fromlocation == null) |
|
|
|
{ |
|
|
|
errors.Add($"来源起始点{detail.BeginPosition}库位没查到"); |
|
|
|
} |
|
|
|
var toloc = await _postionLocationAppService.GetByCodeAsync(detail.EndPosition) |
|
|
|
.ConfigureAwait(false); |
|
|
|
if (toloc == null) |
|
|
|
{ |
|
|
|
errors.Add($"结束点{detail.EndPosition}没查到"); |
|
|
|
} |
|
|
|
LocationDTO tolocation = null; |
|
|
|
if (toloc != null) |
|
|
|
transfer.Confirmed = true; |
|
|
|
var detailInput = new TransferNoteDetailInput(); |
|
|
|
|
|
|
|
var fromPosition = await _postionLocationAppService.GetByCodeAsync(detail.BeginPosition).ConfigureAwait(false); |
|
|
|
if (fromPosition == null) |
|
|
|
{ |
|
|
|
tolocation = await _locationAppService.GetByCodeAsync(toloc.LocationCode).ConfigureAwait(false); |
|
|
|
errors.Add($"未查询到工位{detail.BeginPosition}关联的库位"); |
|
|
|
} |
|
|
|
if (tolocation == null) |
|
|
|
var fromLocationDto = await _locationAppService.GetByCodeAsync(fromPosition.LocationCode).ConfigureAwait(false); |
|
|
|
var tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); |
|
|
|
if (tolocationDto != null) |
|
|
|
{ |
|
|
|
errors.Add($"结束点{detail.EndPosition}库位没查到"); |
|
|
|
tolocationDto = await _locationAppService.GetByCodeAsync(detail.EndPosition).ConfigureAwait(false); |
|
|
|
} |
|
|
|
var item = await _itemBasicAppService.GetByCodeAsync(detail.MatCode).ConfigureAwait(false); |
|
|
|
if (item == null) |
|
|
|
{ |
|
|
|
errors.Add($"零件号{detail.MatCode}的零件不存在!"); |
|
|
|
errors.Add($"ERP料号{detail.MatCode}不存在!"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -1029,27 +1036,26 @@ public class SparePartIssueJobAppService |
|
|
|
Message = string.Join(",", errors.ToArray()) |
|
|
|
}; |
|
|
|
} |
|
|
|
detailInput.ToLocationCode = tolocation.Code; |
|
|
|
detailInput.ToLocationGroup = tolocation.LocationGroupCode; |
|
|
|
detailInput.ToLocationArea = tolocation.AreaCode; |
|
|
|
detailInput.ToLocationErpCode = tolocation.ErpLocationCode; |
|
|
|
detailInput.ToWarehouseCode = tolocation.WarehouseCode; |
|
|
|
detailInput.FromStatus = tolocation.DefaultInventoryStatus; |
|
|
|
|
|
|
|
|
|
|
|
detailInput.ToLocationCode = tolocationDto.Code; |
|
|
|
detailInput.ToLocationGroup = tolocationDto.LocationGroupCode; |
|
|
|
detailInput.ToLocationArea = tolocationDto.AreaCode; |
|
|
|
detailInput.ToLocationErpCode = tolocationDto.ErpLocationCode; |
|
|
|
detailInput.ToWarehouseCode = tolocationDto.WarehouseCode; |
|
|
|
|
|
|
|
detailInput.FromLocationCode = fromLocationDto.Code; |
|
|
|
detailInput.FromLocationGroup = fromLocationDto.LocationGroupCode; |
|
|
|
detailInput.FromLocationArea = fromLocationDto.AreaCode; |
|
|
|
detailInput.FromLocationErpCode = fromLocationDto.ErpLocationCode; |
|
|
|
detailInput.FromWarehouseCode = fromLocationDto.WarehouseCode; |
|
|
|
|
|
|
|
detailInput.Qty = detail.MatQty; |
|
|
|
detailInput.ToLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty; |
|
|
|
detailInput.ToLot = detail.BatchAttr07; |
|
|
|
detailInput.ToPackingCode = detail.PakingCode; |
|
|
|
detailInput.FromWarehouseCode = fromlocation.WarehouseCode; |
|
|
|
detailInput.FromLocationCode = fromlocation.Code; |
|
|
|
detailInput.FromLocationGroup = fromlocation.LocationGroupCode; |
|
|
|
detailInput.FromLocationArea = fromlocation.AreaCode; |
|
|
|
detailInput.FromLocationErpCode = fromlocation.ErpLocationCode; |
|
|
|
detailInput.ToStatus = fromlocation.DefaultInventoryStatus; |
|
|
|
detailInput.Qty = detail.MatQty; |
|
|
|
detailInput.FromLot = !string.IsNullOrEmpty(detail.BatchAttr07) ? detail.BatchAttr07 : string.Empty; |
|
|
|
detailInput.FromLot = detail.BatchAttr07; |
|
|
|
detailInput.FromPackingCode = detail.PakingCode; |
|
|
|
detailInput.FromStatus = EnumInventoryStatus.OK; |
|
|
|
detailInput.ToStatus = EnumInventoryStatus.OK; |
|
|
|
detailInput.Remark = "AGV反库"; |
|
|
|
|
|
|
|
transfer.Details.Add(detailInput); |
|
|
|
|
|
|
@ -1178,4 +1184,139 @@ public class SparePartIssueJobAppService |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 私有
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建补料记录实体
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sparePartIssueJobDto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<SparePartIssueNoteEditInput> BuildSparePartIssueNoteAsync(SparePartIssueJobDTO sparePartIssueJobDto) |
|
|
|
{ |
|
|
|
var sparePartIssueNoteCreateInput = |
|
|
|
ObjectMapper.Map<SparePartIssueJobDTO, SparePartIssueNoteEditInput>(sparePartIssueJobDto); |
|
|
|
sparePartIssueNoteCreateInput.JobNumber = sparePartIssueJobDto.Number; |
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
|
|
|
|
return sparePartIssueNoteCreateInput; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断是不是在最底层 如果不是则把状态变更为待库移 并把库移推荐的From和To赋值
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task CheckMinRowAndSetStatusAsync(SparePartIssueJobEditInput input) |
|
|
|
{ |
|
|
|
var jobDetailInputdetail = input.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)
|
|
|
|
//{
|
|
|
|
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; |
|
|
|
//}
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改当前任务状态 和 该任务的请求状态
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sparePartIssueJob"></param>
|
|
|
|
/// <param name="sparePartIssueJobDetailDto"></param>
|
|
|
|
/// <param name="handledToQty"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
private async Task UpdateRequestAndjobStatusDoneAsync(SparePartIssueJob sparePartIssueJob, |
|
|
|
SparePartIssueJobDetailDTO sparePartIssueJobDetailDto, decimal handledToQty) |
|
|
|
{ |
|
|
|
if (sparePartIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None |
|
|
|
or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中
|
|
|
|
{ |
|
|
|
throw new UserFriendlyException( |
|
|
|
$"任务状态错误:编号为【{sparePartIssueJob.Number}】的任务状态为【{sparePartIssueJob.JobStatus.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
|
|
|
|
sparePartIssueJob.JobStatus = EnumJobStatus.Done; |
|
|
|
|
|
|
|
await RemoveExpectOutAsync(sparePartIssueJob, sparePartIssueJobDetailDto, handledToQty).ConfigureAwait(false); |
|
|
|
|
|
|
|
//await _expectOutAppService.RemoveByNumberAsync(sparePartIssueJob.Number).ConfigureAwait(false);
|
|
|
|
|
|
|
|
await SparePartIssueRequestAppService.UpdateStatusCompletedAsync(sparePartIssueJob.SparePartRequestNumber) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <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}】箱码的库存。"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task RemoveExpectOutAsync(SparePartIssueJob sparePartIssueJob, |
|
|
|
SparePartIssueJobDetailDTO sparePartIssueJobDetailDto, |
|
|
|
decimal handledToQty) |
|
|
|
{ |
|
|
|
await _expectOutAppService.RemoveByNumberAndInventoryAsync(sparePartIssueJob.Number, |
|
|
|
sparePartIssueJobDetailDto.ItemCode, |
|
|
|
sparePartIssueJobDetailDto.HandledToLocationCode, sparePartIssueJobDetailDto.HandledToPackingCode, |
|
|
|
sparePartIssueJobDetailDto.Status, sparePartIssueJobDetailDto.HandledToLot, |
|
|
|
handledToQty).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
} |
|
|
|