Browse Source

提交

dev_DY_CC
赵新宇 6 months ago
parent
commit
17d245e0a6
  1. 175
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/UnplannedIssueJobs/UnplannedIssueJobAppService.cs

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

@ -641,18 +641,179 @@ public class UnplannedIssueJobAppService
{
var job = await _repository.GetAsync(id).ConfigureAwait(false);
//var facQuery=job.FacDetails.GroupBy(p => new { p.ItemCode }).Select(p=>new {ItemCode= p.Key.ItemCode,Qty= p.Sum(itm=>itm.RecommendQty) });
var query = dto.Details.GroupBy(p => new { p.ItemCode })
.Select(p => new { p.Key.ItemCode, Qty = p.Sum(itm => itm.HandledQty) });
//var errorQuery = from itm in facQuery join itm1 in query on itm.ItemCode equals itm1.ItemCode where itm1.Qty > itm.Qty select itm.ItemCode ;
//var errorList = errorQuery.ToList();
var sumqty = query.FirstOrDefault().Qty;
if (job.Qty < sumqty)
if (dto.Details.Count > 0)
{
throw new UserFriendlyException("零件实际数量不能大于需求数量!");
var query = dto.Details.GroupBy(p => new { p.ItemCode })
.Select(p => new { p.Key.ItemCode, Qty = p.Sum(itm => itm.HandledQty) });
var sumQty = query.FirstOrDefault().Qty;
if (job.Qty < sumQty)
{
throw new UserFriendlyException("零件实际数量不能大于需求数量!");
}
if (dto.FacDetails != null || dto.FacDetails.Count == 0)
{
var locationCodes = await _locationAppService
.GetListByErpLocationCodes(new StringList(job.FromErpLocationCode))
.ConfigureAwait(false); //获取存放库位
if (locationCodes.Count == 0)
{
throw new UserFriendlyException("ERP库位没有对应WMS库位!");
}
var first = locationCodes.FirstOrDefault();
var locationDto = await _locationAppService.GetByCodeAsync(first.Code).ConfigureAwait(false);
var input = new RecommendBalanceRequestInput();
switch (locationDto.Type)
{
case EnumLocationType.RAW:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = true
};
break;
case EnumLocationType.FG:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = false
};
break;
case EnumLocationType.DimensionalStorehouse:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = false
};
break;
case EnumLocationType.CUST:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = false
};
break;
case EnumLocationType.KittingWip:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = false
};
break;
case EnumLocationType.OUTSIDE:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = false
};
break;
case EnumLocationType.SEMI:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = false
};
break;
case EnumLocationType.WIP:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = false
};
break;
case EnumLocationType.THIRDPARTY:
input = new RecommendBalanceRequestInput
{
ItemCode = job.ItemCode,
Qty = sumQty,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations = locationCodes.Select(p => p.Code).ToList(),
IsPackingCode = false
};
break;
}
var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false); //获取推荐库存
usableList = usableList.Where(p => p.Qty > 0).ToList();
usableList = usableList
.OrderBy(p => p.Lot)
.ThenBy(p => p.PutInTime)
.ThenBy(p => p.Qty) //2023-9-14 苑静雯 从小数开始发料
.ThenBy(p => p.LocationCode)
.ThenBy(p => p.PackingCode)
.ToList();
var avbQty= usableList.Sum(p => p.Qty);
if (usableList.Count == 0)
{
throw new UserFriendlyException("库存不够!");
}
else
{
if (avbQty < sumQty)
{
throw new UserFriendlyException("库存不够!");
}
}
}
}
var handleDto = new UnplannedIssueJobDTO();
//using (var uow = _unitOfWorkManager.Begin())
//{

Loading…
Cancel
Save