using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; using Opsoft.Data; using Opsoft.NetCore.O3App.Domain; using Opsoft.NetCore.O3App.Domain.Interface; using Opsoft.NetCore.O3App.Domain.UnitOfWork.WMS.IRepositories; using Opsoft.NetCore.O3App.Domain.UnitOfWork.WMS.IServices; using Opsoft.NetCore.O3App.Shared; using System.Collections.Generic; using System.Threading.Tasks; namespace Opsoft.NetCore.O3App.Services.WMS { [MapTo(typeof(ISTKInventoryService), ServiceLifetime.Transient)] public class STKInventoryService : ServiceBase, ISTKInventoryService { //private readonly ISelBillRepository _selBillRepository; public STKInventoryService(ISTKInventoryRepository repository) : base(repository) { Init(repository); } /// /// 库存信息查询 /// /// /// public async Task> QueryInventory(JObject paramaters) { #region 参数验证 if (!paramaters.ContainsKey("scanType")) { throw new O3AppException("【查询类型】传参类型错误,未定义", 400); } //判断查询类型 if (!int.TryParse(paramaters["scanType"].ToStringEx(), out int scanType)) { throw new O3AppException("【查询类型】传参类型错误,值设定有误", 400); } //scanType:1=条码 2=库存 if (scanType == 1) { if (!paramaters.ContainsKey("barCodeNum")) { throw new O3AppException("【条码】传参类型错误,未定义", 400); } if (string.IsNullOrEmpty(paramaters["barCodeNum"].ToStringEx())) { throw new O3AppException("【条码】传参类型错误,值不能为空", 400); } } else { //判断库存参数是否有误 if (!paramaters.ContainsKey("count") || !paramaters.ContainsKey("itemNumber") || !paramaters.ContainsKey("itemName") || !paramaters.ContainsKey("stockData") || !paramaters.ContainsKey("lot")) { throw new O3AppException("传参信息错误,存在未定义的参数", 400); } } #endregion return await (repository as ISTKInventoryRepository).QueryInventory(paramaters); } } }