/// <summary> /// 获取库存信息 /// </summary> /// <param name="manufacturersCodeList">商品编码数据</param> /// <param name="pageSize">每页获取条数</param> /// <param name="pageNum">获取页码</param> /// <returns></returns> public List <ErpInventoryList> GetXLMInventory(List <string> manufacturersCodeList, TotalHeader header) { try { DateTime date = DateTime.Parse(DateTime.Now.ToShortDateString()); var sqlWhere = string.Join("','", manufacturersCodeList); var sql = string.Format(@"select c.PlatformMerchantCode,b.ProductName,a.BarCode,b.ProductUnit as Unit,a.Inventory from XM_XLMInventory a join XM_Product b on a.ManufacturersCode = b.ManufacturersCode join XM_ProductDetails c on c.ProductId = b.Id where c.PlatformMerchantCode in ('{0}') and b.IsEnable = 0 and c.IsEnable = 0 and a.CreateDate > '{1}'", sqlWhere, date.ToString());//从喜临门当日库存获取信息的sql语句 var dt = SqlDataHelper.GetDatatableBySql(sql); var ErpInventoryList = CurUtilManager.ToEntity <ErpInventoryList>(dt); #region 如果喜临门当日库存中没有这些商品库存,就到库存管理中寻找 var ids = getWarehouseIds(); var sqlwehereids = string.Join(",", ids); var sql1 = string.Format(@" select c.PlatformMerchantCode,b.ProductName,null as BarCode,b.ProductUnit as Unit,a.CanOrderCount as Inventory from XM_InventoryInfo a join XM_Product b on a.PlatformMerchantCode = b.ManufacturersCode join XM_ProductDetails c on c.ProductId = b.Id where c.PlatformMerchantCode in ('{0}') and c.PlatformMerchantCode and a.WfId in ({1}) not in( select c.PlatformMerchantCode from XM_XLMInventory a join XM_Product b on a.ManufacturersCode = b.ManufacturersCode left join XM_ProductDetails c on c.ProductId = b.Id where b.IsEnable = 0 and c.IsEnable = 0) and b.IsEnable = 0 and c.IsEnable = 0", sqlWhere, sqlwehereids);//从库存管理获取信息的sql语句 var dt1 = SqlDataHelper.GetDatatableBySql(sql1); var ErpInventoryList1 = CurUtilManager.ToEntity <ErpInventoryList>(dt1); #endregion var ErpInventoryAllList = ErpInventoryList.Concat(ErpInventoryList1).Distinct().ToList(); #region 判断传入的商品编号是否都找得到对应的商品信息 var ErpPlatformMerchantCodeList = ErpInventoryAllList.Select(m => m.PlatformMerchantCode).ToList(); var ExceptList = manufacturersCodeList.Except(ErpPlatformMerchantCodeList).ToList(); if (ExceptList.Count > 0) { header.IsSuccess = false; header.Message = string.Format("这些商品编号{0}在ERP中无法找到对应的库存信息", string.Join(",", ExceptList)); } #endregion return(ErpInventoryList.Concat(ErpInventoryList1).Distinct().ToList()); } catch (Exception ex) { return(null); } }
/// <summary> /// 获取库存信息 /// </summary> /// <param name="manufacturersCodeList">商品编码数据</param> /// <param name="pageSize">每页获取条数</param> /// <param name="pageNum">获取页码</param> /// <returns></returns> public List <ErpProductList> GetXMProduct(List <string> manufacturersCodeList, TotalHeader header) { var sqlWhere = string.Join("','", manufacturersCodeList); var sqlProduct = string.Format(@"select a.PlatformMerchantCode,a.Saleprice,b.ProductName,b.ProductUnit,b.ProductWeight from dbo.XM_ProductDetails a join dbo.XM_Product b on a.ProductId = b.Id where a.PlatformMerchantCode in ('{0}') and b.IsEnable = 0 and a.IsEnable = 0", sqlWhere); //查询语句 var sqlComProduct = string.Format(@"select a.PlatformMerchantCode,a.Saleprice,b.ProductName,b.ProductWeight from dbo.XM_CombinationDetails a join dbo.XM_Combination b on a.ProductId = b.ID where a.PlatformMerchantCode in ('{0}') and b.IsEnabled = 0 and a.IsEnable = 0", sqlWhere); //查询语句 var dtProduct = SqlDataHelper.GetDatatableBySql(sqlProduct); var dtComProduct = SqlDataHelper.GetDatatableBySql(sqlComProduct); var dtProductList = CurUtilManager.ToEntity <ErpProductList>(dtProduct); var dtComProductList = CurUtilManager.ToEntity <ErpProductList>(dtComProduct); dtComProductList.AsParallel().ForAll(m => { GetProductChild(m); }); var ErpProductList = dtProductList.Concat(dtComProductList); #region 判断传入的商品编号是否都找得到对应的商品信息 var ErpPlatformMerchantCodeList = ErpProductList.Select(m => m.PlatformMerchantCode).ToList(); var ExceptList = manufacturersCodeList.Except(ErpPlatformMerchantCodeList).ToList(); if (ExceptList.Count > 0) { header.IsSuccess = false; header.Message = string.Format("这些商品编号{0}在ERP中无法找到对应的商品信息", string.Join(",", ExceptList)); } #endregion return(ErpProductList.ToList()); }