You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
712 lines
26 KiB
712 lines
26 KiB
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
using Volo.Abp.AutoMapper;
|
|
|
|
namespace Win_in.Sfs.Wms.Pda.Controllers.Inventories;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using AutoMapper;
|
|
using Castle.Components.DictionaryAdapter;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Application.Dtos;
|
|
using Volo.Abp.AspNetCore.Mvc;
|
|
using Win_in.Sfs.Basedata.Application.Contracts;
|
|
using Win_in.Sfs.Shared.Domain;
|
|
using Win_in.Sfs.Shared.Domain.Shared;
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
|
|
using Win_in.Sfs.Wms.Pda.Controllers.BaseDatas.Dtos;
|
|
using Win_in.Sfs.Wms.Pda.Models;
|
|
|
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route($"{PdaHostConst.ROOT_ROUTE}inventory/balances")]
|
|
public class BalanceController : AbpController
|
|
{
|
|
private readonly IBalanceAppService _balanceAppService;
|
|
private readonly IItemBasicAppService _itemBasicAppService;
|
|
private readonly ILocationAppService _locationAppService;
|
|
private readonly IExpectOutAppService _expectOutAppService;
|
|
private readonly IProductionLineItemAppService _productionLineItemAppService;
|
|
private IMapper _mapper;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="balanceAppService"></param>
|
|
/// <param name="itemBasicAppService"></param>
|
|
/// <param name="locationAppService"></param>
|
|
/// <param name="expectOutAppService"></param>
|
|
public BalanceController(
|
|
IBalanceAppService balanceAppService,
|
|
IItemBasicAppService itemBasicAppService,
|
|
ILocationAppService locationAppService, IExpectOutAppService expectOutAppService, IProductionLineItemAppService productionLineItemAppService)
|
|
{
|
|
this._balanceAppService = balanceAppService;
|
|
this._locationAppService = locationAppService;
|
|
_expectOutAppService = expectOutAppService;
|
|
_productionLineItemAppService = productionLineItemAppService;
|
|
this._itemBasicAppService = itemBasicAppService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据库位获取零件信息
|
|
/// </summary>
|
|
/// <param name="locationCode"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("get-item-by-location")]
|
|
public virtual async Task<List<ItemBasicDTO>> GetItemBasicListByLocationCodeAsync(string locationCode)
|
|
{
|
|
var input = new SfsInventoryRequestInputBase { Condition = new Condition { Filters = new List<Filter>() } };
|
|
|
|
if (!string.IsNullOrWhiteSpace(locationCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("LocationCode", locationCode));
|
|
}
|
|
|
|
var list = await _balanceAppService.GetAllListByFilterAsync(input).ConfigureAwait(false);
|
|
|
|
var partCodes = list.Select(p => p.ItemCode).Distinct().ToList();
|
|
|
|
var itemInput = new SfsBaseDataRequestInputBase();
|
|
if (partCodes.Count > 0)
|
|
{
|
|
var partCodesStr = JsonSerializer.Serialize(partCodes);
|
|
itemInput.Condition.Filters.Add(
|
|
new Filter
|
|
{
|
|
Action = EnumFilterAction.In.ToString(),
|
|
Column = "Code",
|
|
Logic = EnumFilterLogic.And.ToString(),
|
|
Value = partCodesStr
|
|
});
|
|
}
|
|
|
|
var itemBaseList = await _itemBasicAppService.GetAllListByFilterAsync(itemInput).ConfigureAwait(false);
|
|
|
|
return new List<ItemBasicDTO>(itemBaseList);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取【库存】根据【库位】和【物品】
|
|
/// </summary>
|
|
/// <param name="locationCode"></param>
|
|
/// <param name="itemCode"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("get-by-location-and-item")]
|
|
public virtual async Task<List<BalanceDTO>> GetListByLocationCodeAndItemCodeAsync(string locationCode, string itemCode)
|
|
{
|
|
return await _balanceAppService.GetListByLocationCodeAndItemCodeAsync(locationCode, itemCode).ConfigureAwait(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 【获取】【库存余额】根据【箱码】
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("get-by-packing-code")]
|
|
public virtual async Task<BalanceDTO> GetByPackingCode(string packingCode)
|
|
{
|
|
return await _balanceAppService.GetByPackingCodeAsync(packingCode).ConfigureAwait(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 库存列表
|
|
/// </summary>
|
|
/// <param name="itemCode"></param>
|
|
/// <param name="locationCode"></param>
|
|
/// <param name="packingCode"></param>
|
|
/// <param name="containerCode"></param>
|
|
/// <param name="inventoryStatus"></param>
|
|
/// <param name="locationType"></param>
|
|
/// <param name="isEnablePick"></param>
|
|
/// <param name="pageSize"></param>
|
|
/// <param name="pageIndex"></param>
|
|
/// <param name="sortBy"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("")]
|
|
public virtual async Task<PagedResultDto<BalanceDTO>> GetListAsync(
|
|
string itemCode,
|
|
string locationCode,
|
|
string packingCode,
|
|
string containerCode,
|
|
EnumInventoryStatus? inventoryStatus,
|
|
EnumLocationType? locationType,
|
|
bool? isEnablePick,
|
|
int pageSize,
|
|
int pageIndex,
|
|
string sortBy)
|
|
{
|
|
var input = new SfsInventoryRequestInputBase
|
|
{
|
|
MaxResultCount = pageSize,
|
|
SkipCount = (pageIndex - 1) * pageSize,
|
|
Sorting = sortBy,
|
|
Condition = new Condition { Filters = new List<Filter>() }
|
|
};
|
|
if (!string.IsNullOrWhiteSpace(itemCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ItemCode", itemCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(locationCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("LocationCode", locationCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(packingCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("PackingCode", packingCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(containerCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ContainerCode", containerCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(inventoryStatus.ToString()))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("Status", inventoryStatus.ToString()));
|
|
}
|
|
|
|
var balanceDTOs = await _balanceAppService.GetPagedListByFilterAsync(input, false).ConfigureAwait(false);
|
|
|
|
return balanceDTOs;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 条件筛选获取列表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("filter")]
|
|
public virtual async Task<PagedResultDto<BalanceDTO>> GetListOnFilterAsync(SfsInventoryRequestInputBase input)
|
|
{
|
|
return await _balanceAppService.GetPagedListByFilterAsync(input, false).ConfigureAwait(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发料执行时查询
|
|
/// </summary>
|
|
/// <param name="listInput"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("by-issue")]
|
|
public async Task<PagedResultDto<BalanceDTO>> GetListForIssueAsync(BalanceListByIssueInput listInput)
|
|
{
|
|
var input = new BalanceByIssueRequestInput
|
|
{
|
|
MaxResultCount = listInput.pageSize,
|
|
SkipCount = (listInput.pageIndex - 1) * listInput.pageSize,
|
|
Sorting = listInput.sortBy,
|
|
Condition = new Condition { Filters = new List<Filter>() }
|
|
};
|
|
if (!string.IsNullOrWhiteSpace(listInput.itemCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ItemCode", listInput.itemCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.locationCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("LocationCode", listInput.locationCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.packingCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("PackingCode", listInput.packingCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.containerCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ContainerCode", listInput.containerCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.inventoryStatus.ToString()))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("Status", listInput.inventoryStatus.ToString()));
|
|
}
|
|
|
|
input.IsEnablePick = listInput.isEnablePick;
|
|
input.LocationTypes = listInput.locationTypes;
|
|
var balanceDTOs = await _balanceAppService.GetListByLocationTypeAsync(input).ConfigureAwait(false);
|
|
|
|
return balanceDTOs;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询库存余额 根据 物品 库位 库位类型 库存状态 批次
|
|
/// </summary>
|
|
/// <param name="listInput"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("by-balances-request-many-parameter")]
|
|
public async Task<PagedResultDto<BalanceDTO>> GetListByLocationTypeAndInventoryStatusAsync(
|
|
BalanceListByIssueInputByInventoryStatusAndLocationType listInput)
|
|
{
|
|
var input = new SfsInventoryRequestInputBase
|
|
{
|
|
MaxResultCount = listInput.pageSize,
|
|
SkipCount = (listInput.pageIndex - 1) * listInput.pageSize,
|
|
Sorting = listInput.sortBy,
|
|
Condition = new Condition { Filters = new List<Filter>() }
|
|
};
|
|
if (!string.IsNullOrWhiteSpace(listInput.itemCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ItemCode", listInput.itemCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.locationCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("LocationCode", listInput.locationCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.lot))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("Lot", listInput.lot));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.packingCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("PackingCode", listInput.packingCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.containerCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ContainerCode", listInput.containerCode));
|
|
}
|
|
|
|
if (listInput.locationTypes != null && listInput.locationTypes.Any())
|
|
{
|
|
var locationCodes = (await _locationAppService.GetListByTypesAsync(listInput.locationTypes).ConfigureAwait(false))
|
|
.Select(t => t.Code).ToList();
|
|
|
|
if (locationCodes.Any())
|
|
{
|
|
input.Condition.Filters.Add(
|
|
new Filter("LocationCode", JsonSerializer.Serialize(locationCodes), "In"));
|
|
}
|
|
}
|
|
|
|
if (listInput.inventoryStatuses != null && listInput.inventoryStatuses.Any())
|
|
{
|
|
input.Condition.Filters.Add(
|
|
new Filter("Status", JsonSerializer.Serialize(listInput.inventoryStatuses), "In"));
|
|
}
|
|
|
|
var balanceDTOs = await _balanceAppService.GetPagedListByFilterAsync(input, false).ConfigureAwait(false);
|
|
|
|
return balanceDTOs;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询库存余额 根据 物品 库位 库位类型 库存状态 批次
|
|
/// </summary>
|
|
/// <param name="listInput"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("get-fuzzy-by-balances-request-many-parameter")]
|
|
public async Task<PagedResultDto<BalanceDTO>> GetFuzzyListByLocationTypeAndInventoryStatusAsync(
|
|
BalanceListByIssueInputByInventoryStatusAndLocationType listInput)
|
|
{
|
|
var input = new SfsInventoryRequestInputBase
|
|
{
|
|
MaxResultCount = listInput.pageSize,
|
|
SkipCount = (listInput.pageIndex - 1) * listInput.pageSize,
|
|
Sorting = listInput.sortBy,
|
|
Condition = new Condition { Filters = new List<Filter>() }
|
|
};
|
|
if (!string.IsNullOrWhiteSpace(listInput.itemCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ItemCode", listInput.itemCode, EnumFilterAction.Like.ToString()));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.locationCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("LocationCode", listInput.locationCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.lot))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("Lot", listInput.lot));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.packingCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("PackingCode", listInput.packingCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(listInput.containerCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ContainerCode", listInput.containerCode));
|
|
}
|
|
|
|
if (listInput.locationTypes != null && listInput.locationTypes.Any())
|
|
{
|
|
var locationCodes = (await _locationAppService.GetListByTypesAsync(listInput.locationTypes).ConfigureAwait(false))
|
|
.Select(t => t.Code).ToList();
|
|
|
|
if (locationCodes.Any())
|
|
{
|
|
input.Condition.Filters.Add(
|
|
new Filter("LocationCode", JsonSerializer.Serialize(locationCodes), "In"));
|
|
}
|
|
}
|
|
|
|
if (listInput.inventoryStatuses != null && listInput.inventoryStatuses.Any())
|
|
{
|
|
input.Condition.Filters.Add(
|
|
new Filter("Status", JsonSerializer.Serialize(listInput.inventoryStatuses), "In"));
|
|
}
|
|
|
|
var balanceDTOs = await _balanceAppService.GetPagedListByFilterAsync(input, false).ConfigureAwait(false);
|
|
|
|
return balanceDTOs;
|
|
}
|
|
/// <summary>
|
|
/// 根据零件获取库位信息
|
|
/// </summary>
|
|
/// <param name="itemCode"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("get-location-by-item")]
|
|
public virtual async Task<List<LocationDTO>> GetLocationsOfItemAsync(string itemCode)
|
|
{
|
|
var input = new SfsInventoryRequestInputBase { Condition = new Condition { Filters = new List<Filter>() } };
|
|
if (!string.IsNullOrWhiteSpace(itemCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ItemCode", itemCode));
|
|
}
|
|
|
|
var list = await _balanceAppService.GetAllListByFilterAsync(input).ConfigureAwait(false);
|
|
|
|
var locationCodes = list.Select(p => p.LocationCode).Distinct().ToList();
|
|
|
|
var locInput = new SfsBaseDataRequestInputBase();
|
|
if (locationCodes.Count > 0)
|
|
{
|
|
var locationCodesStr = JsonSerializer.Serialize(locationCodes);
|
|
locInput.Condition.Filters.Add(
|
|
new Filter
|
|
{
|
|
Action = EnumFilterAction.In.ToString(),
|
|
Column = "Code",
|
|
Logic = EnumFilterLogic.And.ToString(),
|
|
Value = locationCodesStr
|
|
});
|
|
}
|
|
|
|
var locationList = await _locationAppService.GetAllListByFilterAsync(locInput).ConfigureAwait(false);
|
|
|
|
return new List<LocationDTO>(locationList);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 条件筛选获取统计
|
|
/// </summary>
|
|
/// <param name="itemCode"></param>
|
|
/// <param name="locationCode"></param>
|
|
/// <param name="packingCode"></param>
|
|
/// <param name="containerCode"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("summary")]
|
|
public virtual async Task<ListResultDto<BalanceSummaryDTO>> GetSummaryAsync(
|
|
string itemCode,
|
|
string locationCode,
|
|
string packingCode,
|
|
string containerCode)
|
|
{
|
|
var input = new SfsInventoryRequestInputBase { Condition = new Condition { Filters = new List<Filter>() } };
|
|
if (!string.IsNullOrWhiteSpace(itemCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ItemCode", itemCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(locationCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("LocationCode", locationCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(packingCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("PackingCode", packingCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(containerCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ContainerCode", containerCode));
|
|
}
|
|
|
|
var list = await _balanceAppService.GetSummaryAsync(input).ConfigureAwait(false);
|
|
return new ListResultDto<BalanceSummaryDTO>(list);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改批次
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="batchInput"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("update-batch")]
|
|
public virtual async Task UpdateBatchAsync(Guid id, [FromBody] BatchInput batchInput)
|
|
{
|
|
await _balanceAppService.UpdateBatchAsync(
|
|
id,
|
|
batchInput.Lot,
|
|
batchInput.SupplierBatch,
|
|
batchInput.ArriveDate,
|
|
batchInput.ProduceDate,
|
|
batchInput.ExpireDate).ConfigureAwait(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改库存状态
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="newStatus"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("update-status")]
|
|
public virtual async Task UpdateStatusAsync(Guid id, [FromBody] EnumInventoryStatus newStatus)
|
|
{
|
|
await _balanceAppService.UpdateStatusAsync(id, newStatus).ConfigureAwait(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取线边库库存(箱码为空)
|
|
/// </summary>
|
|
/// <param name="itemCode"></param>
|
|
/// <param name="locationCode"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("get-wip-list")]
|
|
public virtual async Task<PagedResultDto<BalanceDTO>> GetWipListAsync(
|
|
string itemCode,
|
|
string locationCode)
|
|
{
|
|
var input = new SfsInventoryRequestInputBase { Condition = new Condition { Filters = new List<Filter>() } };
|
|
if (!string.IsNullOrWhiteSpace(itemCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("ItemCode", itemCode));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(locationCode))
|
|
{
|
|
input.Condition.Filters.Add(new Filter("LocationCode", locationCode));
|
|
}
|
|
|
|
input.Condition.Filters.Add(new Filter("PackingCode", ""));
|
|
input.Condition.Filters.Add(new Filter("Lot", ""));
|
|
var balanceDTOs = await _balanceAppService.GetPagedListByFilterAsync(input, false).ConfigureAwait(false);
|
|
return balanceDTOs;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询库存余额 根据 物品 库位 库位类型 库存状态 批次 并且没有被预计出 占用
|
|
/// </summary>
|
|
/// <param name="listInput"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("by-balances-request-many-parameter-not-in-expect-out")]
|
|
public async Task<PagedResultDto<BalanceDTO>> GetListByLocationTypeAndInventoryStatusAndNotExpectOutAsync(
|
|
BalanceListByIssueInputByInventoryStatusAndLocationType listInput)
|
|
{
|
|
var expectOut = await _expectOutAppService.GetListByPackingCodeAsync(listInput.packingCode).ConfigureAwait(false);
|
|
|
|
if (expectOut==null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (expectOut != null && expectOut.Any())
|
|
{
|
|
throw new UserFriendlyException($"箱码为 {listInput.packingCode} 已被任务{expectOut[0].JobNumber}使用");
|
|
}
|
|
|
|
var input = new SfsInventoryRequestInputBase()
|
|
{
|
|
MaxResultCount = listInput.pageSize,
|
|
SkipCount = (listInput.pageIndex - 1) * listInput.pageSize,
|
|
Sorting = listInput.sortBy,
|
|
Condition = new Condition { Filters = new List<Filter>() }
|
|
};
|
|
if (!string.IsNullOrWhiteSpace(listInput.itemCode))
|
|
input.Condition.Filters.Add(new Filter("ItemCode", listInput.itemCode));
|
|
if (!string.IsNullOrWhiteSpace(listInput.locationCode))
|
|
input.Condition.Filters.Add(new Filter("LocationCode", listInput.locationCode));
|
|
if (!string.IsNullOrWhiteSpace(listInput.lot)) input.Condition.Filters.Add(new Filter("Lot", listInput.lot));
|
|
if (!string.IsNullOrWhiteSpace(listInput.packingCode))
|
|
input.Condition.Filters.Add(new Filter("PackingCode", listInput.packingCode));
|
|
if (!string.IsNullOrWhiteSpace(listInput.containerCode))
|
|
input.Condition.Filters.Add(new Filter("ContainerCode", listInput.containerCode));
|
|
|
|
if (listInput.locationTypes != null && listInput.locationTypes.Any())
|
|
{
|
|
var locationCodes = (await this._locationAppService.GetListByTypesAsync(listInput.locationTypes).ConfigureAwait(false))
|
|
.Select(t => t.Code).ToList();
|
|
|
|
if (locationCodes.Any())
|
|
input.Condition.Filters.Add(
|
|
new Filter("LocationCode", JsonConvert.SerializeObject(locationCodes), "In"));
|
|
}
|
|
|
|
if (listInput.inventoryStatuses != null && listInput.inventoryStatuses.Any())
|
|
input.Condition.Filters.Add(
|
|
new Filter("Status", JsonConvert.SerializeObject(listInput.inventoryStatuses), "In"));
|
|
|
|
return await this._balanceAppService.GetPagedListByFilterAsync(input, false).ConfigureAwait(false);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="itemCode"></param>
|
|
/// <param name="productLine"></param>
|
|
/// <param name="isPackingCode"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("get-recommend-balance")]
|
|
public async Task<List<SortBalance>> GetRecommendBalance(string itemCode,string productLine,bool isPackingCode)
|
|
{
|
|
var productionLineItemDto = await _productionLineItemAppService.GetByProductLineCodeAndItemCodeAsync(productLine, itemCode).ConfigureAwait(false);
|
|
|
|
if (productionLineItemDto != null )
|
|
{
|
|
var locationList = new List<string>();
|
|
if (productionLineItemDto.RawLocationCodeListJson != null &&
|
|
productionLineItemDto.RawLocationCodeListJson.Length > 0)
|
|
{
|
|
var temp = JsonSerializer.Deserialize<List<string>>(productionLineItemDto.RawLocationCodeListJson);
|
|
locationList.AddRange(temp);
|
|
}
|
|
|
|
if (productionLineItemDto.ProductLocationCodeListJson != null &&
|
|
productionLineItemDto.ProductLocationCodeListJson.Length > 0)
|
|
{
|
|
var temp = JsonSerializer.Deserialize<List<string>>(productionLineItemDto.ProductLocationCodeListJson);
|
|
locationList.AddRange(temp);
|
|
}
|
|
|
|
//获取可用库存
|
|
var input = new RecommendBalanceRequestInput
|
|
{
|
|
ItemCode = itemCode,
|
|
Qty = decimal.MaxValue,
|
|
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
|
|
Locations = locationList,
|
|
IsPackingCode = isPackingCode
|
|
};
|
|
|
|
var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false);
|
|
return await SortByFifoAsync(usableList).ConfigureAwait(false);
|
|
}
|
|
else
|
|
{
|
|
throw new UserFriendlyException($"未找到生产线【{productLine}】零件【{itemCode}】关系");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="itemCode"></param>
|
|
/// <param name="locationCode"></param>
|
|
/// <param name="locationCodeList"></param>
|
|
/// <param name="isPackingCode"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("get-recommend-balance-by-locations")]
|
|
public async Task<List<SortBalance>> GetRecommendBalanceByLocation(string itemCode,List<string> locationCodeList, bool isPackingCode)
|
|
{
|
|
//获取可用库存
|
|
var input = new RecommendBalanceRequestInput
|
|
{
|
|
ItemCode = itemCode,
|
|
Qty = decimal.MaxValue,
|
|
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
|
|
Locations = locationCodeList,
|
|
IsPackingCode = isPackingCode
|
|
};
|
|
|
|
var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false);
|
|
return await SortByFifoAsync(usableList).ConfigureAwait(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序规则 1.批次正序 2.底层 3.到货日期正序 4.数量倒序(整箱优先) 5.库位正序 6.箱码正序
|
|
/// </summary>
|
|
/// <param name="balances"></param>
|
|
/// <returns></returns>
|
|
private async Task<List<SortBalance>> SortByFifoAsync(List<BalanceDTO> balances)
|
|
{
|
|
var sortBalances = new List<SortBalance>();
|
|
var config = new MapperConfiguration(cfg =>
|
|
{
|
|
cfg.CreateMap<BalanceDTO, SortBalance>()
|
|
.Ignore(x => x.LocationRow);
|
|
});
|
|
_mapper = new Mapper(config);
|
|
|
|
var resultBalances = _mapper.Map<List<BalanceDTO>, List<SortBalance>>(balances);
|
|
foreach (var resultBalance in resultBalances)
|
|
{
|
|
var locationDto = await _locationAppService.GetByCodeAsync(resultBalance.LocationCode).ConfigureAwait(false);
|
|
resultBalance.LocationRow = locationDto.RowCode;
|
|
}
|
|
|
|
resultBalances
|
|
.OrderBy(p => p.Lot)
|
|
.ThenBy(p => p.LocationRow)
|
|
.ThenBy(p => p.PutInTime)
|
|
.ThenBy(p => p.Qty)//2023-9-14 苑静雯 从小数开始发料
|
|
.ThenBy(p => p.LocationCode)
|
|
.ThenBy(p => p.PackingCode)
|
|
.ToList();
|
|
|
|
return resultBalances;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class SortBalance : BalanceDTO
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public int LocationRow { get; set; }
|
|
}
|
|
|
|
/*
|
|
/// <summary>
|
|
/// 查询库余额
|
|
/// </summary>
|
|
/// <param name="listInput"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("get-list-balance-by-input")]
|
|
public async Task<PagedResultDto<BalanceDTO>> GetListBalanceByInputAsync(List<EnumLocationType> enumLocationTypes)
|
|
{
|
|
var sfsInventoryRequestInputBase= new BalanceRequestInput
|
|
{
|
|
MaxResultCount =list.pageSize,
|
|
SkipCount = (listInput.pageIndex - 1) * listInput.pageSize,
|
|
Sorting = listInput.sortBy,
|
|
Condition = new Condition()
|
|
{
|
|
Filters = new List<Filter>()
|
|
}
|
|
}
|
|
|
|
var balanceDTOs = await _balanceAppService.GetListAsync();
|
|
|
|
return balanceDTOs;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取可以上架的库存状态
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
[HttpGet("allow-putaway-inventory-status")]
|
|
public virtual async Task<List<EnumInventoryStatus>> GetAllowPutawayInventoryStatusAsync()
|
|
{
|
|
return await _balanceAppService .GetAllowPutawayInventoryStatusAsync();
|
|
}
|
|
*/
|
|
}
|
|
|