コード例 #1
0
        /// <summary>
        /// 注意:此方法是服务自动调用,WEB页面请用Declare
        /// </summary>
        public void AutoDeclare(DateTime endTime, ref StringBuilder failMessage)
        {
            var canUseWarehouses = WMSSao.GetAllCanUseWarehouseDics();

            foreach (var warehouseInfo in canUseWarehouses)
            {
                Guid warehouseId = warehouseInfo.Key;
                if (warehouseId != Guid.Empty)
                {
                    //获取该仓库下的全部进货申报数据
                    var data = WMSSao.GetStockDeclareDtos(warehouseId, new List <Guid>());
                    if (data == null || data.Count == 0)
                    {
                        failMessage.AppendLine(warehouseInfo.Value + "没有可生成的数据!");
                        continue;
                    }
                    var purchasingSets      = _purchaseSet.GetPurchaseSetListByWarehouseId(warehouseId);
                    var realGoodsInfos      = _goodsCenterSao.GetStockDeclareGridList(data.Keys.ToList()).ToDictionary(k => k.RealGoodsId, v => v);
                    var purchasingGoodsDics = _purchasingDetailManager.GetStockDeclarePursingGoodsDicsWithFiliale(warehouseId, new List <Guid>(),
                                                                                                                  new[] { PurchasingState.NoSubmit, PurchasingState.Purchasing, PurchasingState.PartComplete, PurchasingState.StockIn, PurchasingState.WaitingAudit, PurchasingState.Refusing }, data.Keys.ToList());
                    var details = GetDataList(warehouseId, data, purchasingGoodsDics, realGoodsInfos, purchasingSets);
                    if (details.Count == 0)
                    {
                        failMessage.AppendLine(warehouseInfo.Value + "没有可生成的数据!");
                        continue;
                    }
                    failMessage.AppendLine(warehouseInfo.Value + "开始生成采购单!");
                    BuilderPurchasing(details, purchasingSets, warehouseId, null, "进货申报服务", ref failMessage);
                    failMessage.AppendLine(warehouseInfo.Value + "结束生成采购单!");
                }
            }
        }
コード例 #2
0
        protected void GridRGGoodsDemand_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            var datasource = new List <StockDeclareDTO>();

            if (Page.IsPostBack)
            {
                if (!e.IsFromDetailTable)
                {
                    var purchasingSets = CompanyId != Guid.Empty
                        ? _purchaseSet.GetPurchaseSetListByWarehouseIdAndCompanyId(WarehouseId, CompanyId) :
                                         _purchaseSet.GetPurchaseSetListByWarehouseId(WarehouseId);
                    if (purchasingSets == null || purchasingSets.Count == 0)
                    {
                        RAM.Alert("该仓库未找到对应的采购设置商品!");
                        RGGoodsDemand.DataSource = new List <StockDeclareDTO>();
                        return;
                    }

                    var dics = WMSSao.GetStockDeclareDtos(WarehouseId, new List <Guid>());
                    if (!string.IsNullOrWhiteSpace(TextBoxKeys.Text))
                    {
                        var realGoodsIds = _goodsCenterSao.GetRealGoodsIdListByGoodsNameOrCode(TextBoxKeys.Text);
                        if (realGoodsIds.Count > 0)
                        {
                            dics = dics.Where(act => realGoodsIds.Contains(act.Key)).ToDictionary(k => k.Key, v => v.Value);
                        }
                    }
                    var realGoodsInfos      = _goodsCenterSao.GetStockDeclareGridList(dics.Keys.ToList()).ToDictionary(k => k.RealGoodsId, v => v);
                    var purchasingGoodsDics = _purchasingDetail.GetStockDeclarePursingGoodsDicsWithFiliale(WarehouseId, dics.Values.SelectMany(ent => ent).Select(ent => ent.FilialeId),
                                                                                                           new[] { PurchasingState.NoSubmit, PurchasingState.Purchasing, PurchasingState.PartComplete, PurchasingState.StockIn, PurchasingState.WaitingAudit, PurchasingState.Refusing },
                                                                                                           dics.Keys.ToList());
                    List <StockDeclareDTO> data;
                    StockDeclareDtos = GetDataList(dics, purchasingGoodsDics, realGoodsInfos, purchasingSets, out data);
                    datasource.AddRange(data);
                }
                else //加载对应物流公司申报数
                {
                    datasource = GetDataList(StockDeclareDtos);
                }
            }
            RGGoodsDemand.DataSource = datasource.OrderBy(w => w.GoodsName).ThenBy(w => w.Sku).ToList();
        }