示例#1
0
        protected DQueryDom GetQueryDom()
        {
            var items = GetAllItems();

            main = new JoinAlias(typeof(ProductOutTemp));
            var query = new DQueryDom(main);

            ProductOutTemp.Register(query, dateInput.Date);
            var frozen = new JoinAlias("tempFrozen", typeof(FrozenOutTemp));

            var frozenNum = new JoinAlias("tempFrozenAllNumber", typeof(FrozeTemp));

            FrozenOutTemp.Register(query, dateInput.Value);
            FrozenOutTemp.AddJoin(query, frozen);

            FrozeTemp.Register(query, dateInput.Value);
            FrozeTemp.AddJoin(query, frozenNum);

            var 速冻出库重量Exp = DQExpression.Field(frozenNum, "AllNumber");
            var 产出重量Exp   = DQExpression.Field(main, "Number");
            var 速冻出库袋数Exp = DQExpression.Field(frozenNum, "AllSecondNumber2");
            var 产出袋数Exp   = DQExpression.Field(main, "SecondNumber2");

            foreach (ListItem item in items)
            {
                var field = item.Value;
                if (field.StartsWith("_"))
                {
                    field = field.Substring(4);
                }

                switch (item.Text)
                {
                case "会计单位":
                case "部门":
                case "经办人":
                case "产出品名":
                case "速冻出库品名":
                case "产出数量":
                case "产出辅数量":
                    query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(main, field), item.Text));
                    query.GroupBy.Expressions.Add(DQExpression.Field(main, field));
                    break;

                case "速冻出库数量":
                    query.Columns.Add(DQSelectColumn.Create(速冻出库重量Exp, item.Text));
                    query.GroupBy.Expressions.Add(速冻出库重量Exp);
                    break;

                case "速冻出库辅数量":
                    query.Columns.Add(DQSelectColumn.Create(速冻出库袋数Exp, item.Text));
                    query.GroupBy.Expressions.Add(速冻出库袋数Exp);
                    break;

                case "包装品名":
                    query.Columns.Add(DQSelectColumn.Create(DQExpression.Field(frozen, field), item.Text));
                    query.GroupBy.Expressions.Add(DQExpression.Field(frozen, field));
                    break;

                case "包装数量":
                case "包装辅数量":
                    query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.Field(frozen, field)), item.Text));
                    detailSumIndex.Add(query.Columns.Count - 1);
                    break;

                case "速冻库差异数量":

                    query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(产出重量Exp, 速冻出库重量Exp), item.Text));
                    //query.GroupBy.Expressions.Add(DQExpression.Subtract(产出重量Exp, 速冻出库重量Exp));
                    break;

                case "速冻库差异辅数量II":

                    query.Columns.Add(DQSelectColumn.Create(DQExpression.Subtract(产出袋数Exp, 速冻出库袋数Exp), item.Text));
                    //query.GroupBy.Expressions.Add(DQExpression.Subtract(产出袋数Exp, 速冻出库袋数Exp));
                    break;

                case "对比值":

                    var 对比值Exp = DQExpression.Divide(速冻出库重量Exp, DQExpression.NullIfZero(产出重量Exp));

                    query.Columns.Add(DQSelectColumn.Create(对比值Exp, item.Text));
                    break;
                }
            }



            return(query);
        }