|
|
@ -136,6 +136,16 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task SetEntityPropertiesAsync(UnplannedIssueRequest entity) |
|
|
|
{ |
|
|
|
var userName = CurrentUser.GetUserName_New(); |
|
|
@ -274,13 +284,6 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 用来重写 导入数据时可以加工数据
|
|
|
|
/// </summary>
|
|
|
@ -290,71 +293,39 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
{ |
|
|
|
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); |
|
|
|
|
|
|
|
foreach (var unplannedIssueRequest in addList) |
|
|
|
foreach (var unplannedReceiptRequest in addList) |
|
|
|
{ |
|
|
|
if(unplannedIssueRequest.UnplannedIssueType != EnumUnplannedIssueType.Wip&& unplannedIssueRequest.UnplannedIssueType != EnumUnplannedIssueType.Raw) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"【{unplannedIssueRequest.UnplannedIssueType}】领料类型," + |
|
|
|
$"不是{EnumUnplannedIssueType.Wip.GetDisplayName()}" + |
|
|
|
$"或{EnumUnplannedIssueType.Raw.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
await SetRequestAutoPropertiesAsync(unplannedIssueRequest).ConfigureAwait(false); |
|
|
|
await SetEntityPropertiesAsync(unplannedIssueRequest).ConfigureAwait(false); |
|
|
|
List<UnplannedIssueRequestDetail> newDetails = new List<UnplannedIssueRequestDetail>(); |
|
|
|
foreach (var detail in unplannedIssueRequest.Details) |
|
|
|
//if (unplannedReceiptRequest.UnplannedIssueType != EnumUnplannedIssueType.Wip && unplannedReceiptRequest.UnplannedIssueType != EnumUnplannedIssueType.Raw)
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException($"【{unplannedReceiptRequest.UnplannedIssueType}】退料料类型," +
|
|
|
|
// $"不是{EnumUnplannedReceiptType.Wip.GetDisplayName()}" +
|
|
|
|
// $"或{EnumUnplannedReceiptType.Raw.GetDisplayName()}】");
|
|
|
|
//}
|
|
|
|
await SetRequestAutoPropertiesAsync(unplannedReceiptRequest).ConfigureAwait(false); |
|
|
|
await SetEntityPropertiesAsync(unplannedReceiptRequest).ConfigureAwait(false); |
|
|
|
|
|
|
|
foreach (var detail in unplannedReceiptRequest.Details) |
|
|
|
{ |
|
|
|
//需要复制一个这个方法 去掉区域参数 换成库位参数
|
|
|
|
RecommendBalanceRequestInput input = new RecommendBalanceRequestInput(); |
|
|
|
if (unplannedIssueRequest.UnplannedIssueType == EnumUnplannedIssueType.Raw) |
|
|
|
{ |
|
|
|
var locationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); |
|
|
|
if (locationDto.Type != EnumLocationType.RAW && locationDto.Type != EnumLocationType.SEMI && locationDto.Type != EnumLocationType.FG) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"【{detail.LocationCode}】库位类型错误," + |
|
|
|
$"不是{EnumLocationType.RAW.GetDisplayName()}" + |
|
|
|
$"或{EnumLocationType.SEMI.GetDisplayName()}" + |
|
|
|
$"或{EnumLocationType.FG.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
// unplannedIssueRequest.DirectCreateNote = false;
|
|
|
|
input.IsPackingCode = true;//只查询带箱码的推荐
|
|
|
|
} |
|
|
|
if (unplannedIssueRequest.UnplannedIssueType == EnumUnplannedIssueType.Wip) |
|
|
|
{ |
|
|
|
var locationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); |
|
|
|
if (locationDto.Type != EnumLocationType.WIP) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"【{detail.LocationCode}】库位类型错误," + |
|
|
|
$"不是{EnumLocationType.WIP.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
input.ItemCode = detail.ItemCode; |
|
|
|
input.Locations = new List<string>() { detail.LocationCode }; |
|
|
|
input.Qty = detail.Qty; |
|
|
|
input.Statuses = new List<EnumInventoryStatus> { EnumInventoryStatus.OK }; |
|
|
|
var balanceLst = await _balanceAppService.GetRecommendBalancesByLocationsAsync(input).ConfigureAwait(false); |
|
|
|
if (balanceLst.Count == 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"无推荐库存零件号:{input.ItemCode}库位{input.Locations[0]}!"); |
|
|
|
} |
|
|
|
var sumQty = balanceLst.Sum(itm => itm.Qty); |
|
|
|
if (detail.Qty > sumQty) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"库存数量不足!"); |
|
|
|
} |
|
|
|
foreach (var balance in balanceLst) |
|
|
|
{ |
|
|
|
var newDetail = CreateNewDetail(detail, balance); |
|
|
|
await SetDetailPropertiesAsync(newDetail, unplannedIssueRequest.UnplannedIssueType).ConfigureAwait(false); |
|
|
|
newDetails.Add(newDetail); |
|
|
|
} |
|
|
|
await SetDetailPropertiesAsync(detail).ConfigureAwait(false); |
|
|
|
} |
|
|
|
unplannedIssueRequest.Details.Clear();//删除所有明细}
|
|
|
|
unplannedIssueRequest.Details.AddRange(newDetails);//按推荐添加
|
|
|
|
} |
|
|
|
|
|
|
|
return dictionary; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建明细
|
|
|
|
/// </summary>
|
|
|
@ -413,29 +384,29 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
detail.LocationArea = location.AreaCode; |
|
|
|
detail.LocationCode = location.Code; |
|
|
|
} |
|
|
|
string packingcode = string.Empty; |
|
|
|
if(type!= EnumUnplannedIssueType.Wip) |
|
|
|
{ |
|
|
|
packingcode = detail.PackingCode; |
|
|
|
} |
|
|
|
var balance = await _balanceAppService.GetByItemLocationAndPackingAsync( |
|
|
|
packingcode, |
|
|
|
detail.ItemCode, |
|
|
|
detail.LocationCode).ConfigureAwait(false); |
|
|
|
//string packingcode = string.Empty;
|
|
|
|
//if(type!= EnumUnplannedIssueType.Wip)
|
|
|
|
//{
|
|
|
|
// packingcode = detail.PackingCode;
|
|
|
|
//}
|
|
|
|
//var balance = await _balanceAppService.GetByItemLocationAndPackingAsync(
|
|
|
|
// packingcode,
|
|
|
|
// detail.ItemCode,
|
|
|
|
// detail.LocationCode).ConfigureAwait(false);
|
|
|
|
|
|
|
|
if (balance != null) |
|
|
|
{ |
|
|
|
detail.SupplierBatch = balance.SupplierBatch; |
|
|
|
detail.ArriveDate = balance.ArriveDate; |
|
|
|
detail.ProduceDate = balance.ProduceDate; |
|
|
|
detail.ExpireDate = balance.ExpireDate; |
|
|
|
|
|
|
|
detail.Lot = balance.Lot; |
|
|
|
detail.ContainerCode = balance.ContainerCode; |
|
|
|
detail.PackingCode = balance.PackingCode; |
|
|
|
detail.Qty = detail.Qty; |
|
|
|
detail.Status = balance.Status; |
|
|
|
} |
|
|
|
//if (balance != null)
|
|
|
|
//{
|
|
|
|
// detail.SupplierBatch = balance.SupplierBatch;
|
|
|
|
// detail.ArriveDate = balance.ArriveDate;
|
|
|
|
// detail.ProduceDate = balance.ProduceDate;
|
|
|
|
// detail.ExpireDate = balance.ExpireDate;
|
|
|
|
|
|
|
|
// detail.Lot = balance.Lot;
|
|
|
|
// detail.ContainerCode = balance.ContainerCode;
|
|
|
|
// detail.PackingCode = balance.PackingCode;
|
|
|
|
// detail.Qty = detail.Qty;
|
|
|
|
// detail.Status = balance.Status;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//if (!string.IsNullOrEmpty(detail))
|
|
|
|
//{
|
|
|
@ -483,33 +454,7 @@ public class UnplannedIssueRequestForDongyangAppService : UnplannedIssueRequestA |
|
|
|
//}
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 赋值主记录
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
//private async Task SetEntityPropertiesAsync(UnplannedIssueRequest entity)
|
|
|
|
//{
|
|
|
|
// var userName = CurrentUser.GetUserName_New();
|
|
|
|
// var name = CurrentUser.GetName();
|
|
|
|
// if (userName != null)
|
|
|
|
// {
|
|
|
|
// var department = await _departmentApp.GetByUsernameAsync(userName).ConfigureAwait(false);
|
|
|
|
|
|
|
|
// if (department != null)
|
|
|
|
// {
|
|
|
|
// entity.DeptCode = department.Code;
|
|
|
|
// entity.DeptName = department.Name;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// entity.Worker = name;
|
|
|
|
// entity.CreatorId = CurrentUser.Id;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// entity.BuildDate = DateTime.Now;
|
|
|
|
|
|
|
|
// await SetRequestAutoPropertiesAsync(entity).ConfigureAwait(false);
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 赋值业务事务
|
|
|
|