diff --git a/B3ButcherManageToSale/TypeIOCs/ForecastButcherInfo.cs b/B3ButcherManageToSale/TypeIOCs/ForecastButcherInfo.cs index 10af4cb..33c9c5e 100644 --- a/B3ButcherManageToSale/TypeIOCs/ForecastButcherInfo.cs +++ b/B3ButcherManageToSale/TypeIOCs/ForecastButcherInfo.cs @@ -22,10 +22,10 @@ namespace BWP.B3ButcherManageToSale.TypeIOCs { public List Invoke(IDmoContext context, ButcherForecast dmo) { - var orderInfo = GetSaleOrderInfo(context.Session, dmo); + var saleOutStoreInfo = GetSaleOutStoreInfo(context.Session, dmo); var avgWeightList = GetAllProductAvgWeightSet(context.Session); var result = new List(); - foreach (var item in orderInfo) + foreach (var item in saleOutStoreInfo) { var first = avgWeightList.FirstOrDefault(x => x.Item2 == item.Item1); var detail = new ButcherForecast_Detail(); @@ -33,7 +33,7 @@ namespace BWP.B3ButcherManageToSale.TypeIOCs detail.NeedNumber = item.Item2; if (first != null) { - detail.ProductAvgWeightSet_ID = first.Item2; + detail.ProductAvgWeightSet_ID = first.Item1; detail.AvgWeight = first.Item3; if (detail.AvgWeight != 0) { @@ -49,15 +49,16 @@ namespace BWP.B3ButcherManageToSale.TypeIOCs return result; } - List>> GetSaleOrderInfo(IDmoSession session, ButcherForecast dmo) + List>> GetSaleOutStoreInfo(IDmoSession session, ButcherForecast dmo) { - var main = new JoinAlias("_main", typeof(Order)); - var detail = new JoinAlias(typeof(Order_Detail)); + var main = new JoinAlias("_main", typeof(SaleOutStore)); + var detail = new JoinAlias(typeof(SaleOutStore_Detail)); var query = new DQueryDom(main); - query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "Order_ID")); + query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); query.Columns.Add(DQSelectColumn.Field("SaleGoods_ID", detail)); query.Columns.Add(DQSelectColumn.Sum(detail, "Number")); - query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("AccountingUnit_ID", dmo.AccountingUnit_ID), DQCondition.EQ(DQExpression.Snippet("cast(_main.LoadTime as date)"), DQExpression.Value(dmo.SendDate)), DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNotNull(DQExpression.Field(detail, "Number")))); + query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("AccountingUnit_ID", dmo.AccountingUnit_ID), DQCondition.EQ(DQExpression.Snippet("cast(_main.LoadTime as date)"), DQExpression.Value(dmo.SendDate)), DQCondition.EQ("BillState", 单据状态.未审核), DQCondition.IsNotNull(DQExpression.Field(detail, "Number")))); + query.Where.Conditions.Add(DQCondition.EQ("Store_ID", dmo.Store_ID)); query.GroupBy.Expressions.Add(DQExpression.Field(detail, "SaleGoods_ID")); return query.EExecuteList>(session); }