Exemple #1
0
        public static void InsertProductInStore(ProductInStore dmo)
        {
            var query = new DQueryDom(new JoinAlias(typeof(ProductInStore)));

            query.Columns.Add(DQSelectColumn.Field("DeviceId"));
            query.Where.Conditions.Add(DQCondition.EQ("InStoreDate", dmo.InStoreDate));
            var deviceIds = query.EExecuteList <string>();

            if (deviceIds.Contains(dmo.DeviceId))
            {
                return;
            }
            using (var context = new TransactionContext())
            {
                foreach (var d in dmo.Details)
                {
                    d.Price          = 0;
                    d.Money          = 0;
                    d.ProductionDate = GetProductPlanDate(d.ProductPlan_ID);
                }
                var bl = BIFactory.Create <IProductInStoreBL>(context);
                //dmo.BillState = 单据状态.已审核;
                dmo.IsHandsetSend = true;
                bl.Insert(dmo);
                if (new B3ButcheryConfig().DoCheckCreatedInStore.Value)
                {
                    bl.Check(dmo);
                }
                context.Commit();
            }
        }
Exemple #2
0
        private static IEnumerable <WordPair> SelectProductLinkTemplate(ChoiceBoxArgument argu)
        {
            var main  = new JoinAlias(typeof(ProductLinkTemplate));
            var query = new DQueryDom(main);

            query.Columns.Add(DQSelectColumn.Field("ID"));
            query.Columns.Add(DQSelectColumn.Field("Name"));
            if (!string.IsNullOrEmpty(argu.CodeArgument))
            {
                var accDep = argu.CodeArgument.Split(new[] { '|' }).ToArray();
                query.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", accDep[0]));
                var id            = GetDepartment(Convert.ToInt64(accDep[1]));
                var field         = string.Format("Department_TreeDeep{0}ID", id);
                var deptCondition = B3ButcheryUtil.部门或上级部门条件(Convert.ToInt64(accDep[1]));
                query.Where.Conditions.Add(DQCondition.Or(DQCondition.EQ(main, field, accDep[1]), deptCondition));
            }
            if (!string.IsNullOrEmpty(argu.InputArgument))
            {
                IList <IDQExpression> conditions = new List <IDQExpression>();
                conditions.Add(DQCondition.Like("Name", argu.InputArgument));
                conditions.Add(DQCondition.Like("Spell", argu.InputArgument));
                query.Where.Conditions.Add(DQCondition.Or(conditions));
            }
            return(query.EExecuteList <long, string>().Select(x => new WordPair(x.Item2, x.Item1.ToString(CultureInfo.InvariantCulture))));
        }
Exemple #3
0
        public static List <ProductPlanInfo> GetProductPlanInfo(long[] id)
        {
            if (id.Length == 0)
            {
                return(new List <ProductPlanInfo>());
            }
            var query = new DQueryDom(new JoinAlias(typeof(ProductPlan)));

            query.Columns.Add(DQSelectColumn.Field("ID"));
            query.Columns.Add(DQSelectColumn.Field("PlanNumber"));
            query.Columns.Add(DQSelectColumn.Field("Date"));
            query.Columns.Add(DQSelectColumn.Field("RowVersion"));
            query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), id.Select(x => DQExpression.Value(x)).ToArray()));
            query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
            var result = query.EExecuteList <long, string, DateTime, int>();
            var rst    = new List <ProductPlanInfo>();

            foreach (var item in result)
            {
                rst.Add(new ProductPlanInfo {
                    ID = item.Item1, PlanNumber = item.Item2, PlanDate = item.Item3, RowVersion = item.Item4
                });
            }
            return(rst);
        }
Exemple #4
0
        private List <long> FindNeedNullifyBillIDs(DateTime date)
        {
            var dom = new DQueryDom(new JoinAlias(typeof(ProductNotice)));

            dom.Columns.Add(DQSelectColumn.Field("ID"));
            dom.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.未审核));
            dom.Where.Conditions.Add(DQCondition.LessThan("Date", date));
            return(dom.EExecuteList <long>());
        }
Exemple #5
0
        public static IList <EntityRowVersion> GetRowVersion(long?accountingUnit)
        {
            var query = new DQueryDom(new JoinAlias(typeof(ProductPlan)));

            query.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", accountingUnit));
            query.Columns.Add(DQSelectColumn.Field("ID"));
            query.Columns.Add(DQSelectColumn.Field("RowVersion"));
            query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
            query.Where.Conditions.Add(DQCondition.And(DQCondition.Between("Date", DateTime.Today.AddDays(-3), DateTime.Today.AddDays(1)), DQCondition.EQ("BillState", 单据状态.已审核)));
            return(query.EExecuteList <long, int>().Select(x => new EntityRowVersion(x.Item1, x.Item2)).ToList());
        }
Exemple #6
0
        public static IList <EntityRowVersion> GetRowVersion(long?accountingUnit)
        {
            var query = new DQueryDom(new JoinAlias(typeof(ProductInStoreTemplate)));

            query.Where.Conditions.Add(DQCondition.EQ("AccountingUnit_ID", accountingUnit));
            query.Columns.Add(DQSelectColumn.Field("ID"));
            query.Columns.Add(DQSelectColumn.Field("RowVersion"));
            query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
            query.Where.Conditions.Add(DQCondition.EQ("Stopped", false));
            return(query.EExecuteList <long, int>().Select(x => new EntityRowVersion(x.Item1, x.Item2)).ToList());
        }
Exemple #7
0
        private List <Tuple <long, string> > GetShiftInfo()
        {
            var query = new DQueryDom(new JoinAlias(typeof(ProductShift)));

            query.Columns.Add(DQSelectColumn.Field("ID"));
            query.Columns.Add(DQSelectColumn.Field("Name"));

            query.Where.Conditions.Add(DQCondition.EQ("Stopped", false));
            query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID));
            OrganizationUtil.AddOrganizationLimit(query, typeof(ProductShift));
            return(query.EExecuteList <long, string>());
        }
Exemple #8
0
        public static void GetPlanNumber(ProductPlan dmo)
        {
            var query = new DQueryDom(new JoinAlias(typeof(ProductPlan)));

            query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("PlanNumber", dmo.PlanNumber),
                                                       DQCondition.EQ("PlanNumbers", true)));
            query.Columns.Add(DQSelectColumn.Field("ID"));
            var result = query.EExecuteList <long>();

            if (result.Count != 0)
            {
                throw new Exception("此计划号已经完毕,不能重复做");
            }
        }
Exemple #9
0
        private static IEnumerable <WordPair> SelectGoodsBrand(ChoiceBoxArgument argu)
        {
            var query = new DQueryDom(new JoinAlias(typeof(Goods)));

            query.Range = SelectRange.Top(30);
            query.Columns.Add(DQSelectColumn.Field("Brand"));
            query.GroupBy.Expressions.Add(DQExpression.Field("Brand"));
            if (!string.IsNullOrEmpty(argu.InputArgument))
            {
                query.Where.Conditions.Add(DQCondition.Like("Brand", argu.InputArgument));
            }
            return(query.EExecuteList <string>().Select((l)
                                                        => new WordPair(l, l)));
        }
Exemple #10
0
        private List <Tuple <long, string> > GetBaseInfo <T>(Action <DQueryDom> action = null)
        {
            var query = new DQueryDom(new JoinAlias(typeof(T)));

            query.Columns.Add(DQSelectColumn.Field("ID"));
            query.Columns.Add(DQSelectColumn.Field("Name"));

            query.Where.Conditions.Add(DQCondition.EQ("Stopped", false));
            query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID));
            OrganizationUtil.AddOrganizationLimit(query, typeof(T));
            if (action != null)
            {
                action(query);
            }
            return(query.EExecuteList <long, string>());
        }
Exemple #11
0
        public static bool TryGetID <TDmo>(ExecelImportColumn col, Row row, string fieldsName, ref long dmoID)
        {
            string name = default(string);

            if (!col.TryGetValue(row, ref name))
            {
                return(false);
            }

            var logicName = DFInfo.Get(typeof(TDmo)).LogicName;

            if (dmoID > 0)
            {
                var verifyNameQuery = new DQueryDom(new JoinAlias(typeof(TDmo)));
                verifyNameQuery.Columns.Add(DQSelectColumn.Field(fieldsName));
                verifyNameQuery.Where.Conditions.Add(DQCondition.EQ("ID", dmoID));
                verifyNameQuery.Range = SelectRange.Top(1);

                var verifyName = (string)verifyNameQuery.EExecuteScalar <string>();

                if (verifyName != name)
                {
                    throw new Exception(string.Format("{0}字段{4}:{1}和已得到ID:{2}上的名称:{3}不一致", logicName, name, dmoID, verifyName, fieldsName));
                }
                return(false);
            }

            var query = new DQueryDom(new JoinAlias(typeof(TDmo)));

            if (TypeUtil.IsWithinDomain <TDmo>())
            {
                query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID));
            }
            query.Where.Conditions.Add(DQCondition.EQ(fieldsName, name));
            query.Range = SelectRange.Top(2);
            query.Columns.Add(DQSelectColumn.Field("ID"));
            var result = query.EExecuteList <long>();

            if (result.Count == 0)
            {
                throw new Exception(string.Format("未能发现字段{2}为{0}的{1}", name, logicName, fieldsName));
            }

            dmoID = result[0];
            return(true);
        }
Exemple #12
0
        public static List <RpcEasyProductInStore> GetProductInStoreList()
        {
            var query = new DQueryDom(new JoinAlias(typeof(ProductInStore)));

            query.Columns.Add(DQSelectColumn.Field("ID"));
            query.Columns.Add(DQSelectColumn.Field("InStoreDate"));
            query.Where.Conditions.Add(DQCondition.EQ("BillState", 单据状态.未审核));
            OrganizationUtil.AddOrganizationLimit(query, typeof(ProductInStore));
            OrganizationUtil.AddOrganizationLimit <Store>(query, "Store_ID");
            query.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("InStoreDate")));
            try
            {
                return(query.EExecuteList <long, DateTime>().Select(x => new RpcEasyProductInStore(x.Item1, x.Item2)).ToList());
            }
            catch (Exception)
            {
                return(new List <RpcEasyProductInStore>());
            }
        }
Exemple #13
0
        public static List <RpcEasyProductInStore_Detail> GetRpcEasyProductInStoreDetailById(long id)
        {
            var ris       = new JoinAlias(typeof(ProductInStore));
            var risDetail = new JoinAlias(typeof(ProductInStore_Detail));
            var query     = new DQueryDom(ris);

            query.From.AddJoin(JoinType.Left, new DQDmoSource(risDetail), DQCondition.EQ(ris, "ID", risDetail, "ProductInStore_ID"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Name", risDetail));
            query.Columns.Add(DQSelectColumn.Field("Number", risDetail));
            query.Columns.Add(DQSelectColumn.Field("SecondNumber", risDetail));
            query.Columns.Add(DQSelectColumn.Field("ID", risDetail));
            query.Columns.Add(DQSelectColumn.Field("ProductInStore_ID", risDetail));
            query.Where.Conditions.Add(DQCondition.EQ("ID", id));
            try
            {
                return(query.EExecuteList <string, object, Money <decimal>?, long?, long?>().Select(x => new RpcEasyProductInStore_Detail(x.Item1, x.Item2, x.Item3, x.Item4, x.Item5)).ToList());
            }
            catch (Exception)
            {
                return(new List <RpcEasyProductInStore_Detail>());
            }
        }
Exemple #14
0
        static void LoadDetail(ProductInStore dmo)
        {
            if (dmo.ProductInStoreTemplate_ID == null)
            {
                throw new ArgumentException("请先选择成品入库模板");
            }
            dmo.Details.Clear();
            var query = new DQueryDom(new JoinAlias(typeof(ProductInStoreTemplate_GoodsDetail)));

            query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Code"));
            query.Columns.Add(DQSelectColumn.Field("Goods_MainUnitRatio"));
            query.Columns.Add(DQSelectColumn.Field("Goods_SecondUnitRatio"));
            query.Where.Conditions.Add(DQCondition.EQ("ProductInStoreTemplate_ID", dmo.ProductInStoreTemplate_ID));
            query.EExecuteList <long, string, string>().Select(x => new ProductInStore_Detail {
                ProductInStore_ID = dmo.ID, Goods_ID = x.Item1, Goods_Name = x.Item2, Goods_Code = x.Item3
            }).EAddToCollection(dmo.Details);
            dmo.Details.Clear();
            using (var context = new TransactionContext())
            {
                using (var reader = context.Session.ExecuteReader(query))
                {
                    while (reader.Read())
                    {
                        var detail = new ProductInStore_Detail
                        {
                            Goods_ID              = (long)reader[0],
                            Goods_Name            = (string)reader[1],
                            Goods_Code            = (string)reader[2],
                            Goods_MainUnitRatio   = (Money <decimal>?)reader[3],
                            Goods_SecondUnitRatio = (Money <decimal>?)reader[4]
                        };
                        dmo.Details.Add(detail);
                    }
                }
            }
        }
Exemple #15
0
        static void LoadDetail(ProductNotice dmo)
        {
            dmo.Details.Clear();
            var query = new DQueryDom(new JoinAlias(typeof(ProductNotice_Detail)));

            query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
            query.Columns.Add(DQSelectColumn.Field("Goods_Code"));
            query.Where.Conditions.Add(DQCondition.EQ("ProductNotice_ID", dmo.ID));
            var list = query.EExecuteList <long, string, string>().Select(x => new ProductNotice_Detail {
                ProductNotice_ID = dmo.ID, Goods_ID = x.Item1, Goods_Name = x.Item2, Goods_Code = x.Item3
            });
            var removeDetail = dmo.Details.Where(detail => list.All(x => x.Goods_ID != detail.Goods_ID)).ToList();

            foreach (var remove in removeDetail)
            {
                dmo.Details.Remove(remove);
            }
            foreach (var add in list.Where(add => dmo.Details.All(x => x.Goods_ID != add.Goods_ID)))
            {
                dmo.Details.Add(add);
            }
        }
Exemple #16
0
        private static IEnumerable <WordPair> SelectGoodsWithSpec(ChoiceBoxArgument argu, bool OnlyAvailable)
        {
            var query = new DQueryDom(new JoinAlias(typeof(Goods)));

            query.Range = SelectRange.Top(30);
            query.Columns.Add(DQSelectColumn.Field("Name"));
            query.Columns.Add(DQSelectColumn.Field("Code"));
            query.Columns.Add(DQSelectColumn.Field("ID"));
            if (OnlyAvailable)
            {
                query.Where.Conditions.Add(DQCondition.EQ("Stopped", false));
            }
            if (!string.IsNullOrEmpty(argu.InputArgument))
            {
                IList <IDQExpression> conditions = new List <IDQExpression>();
                conditions.Add(DQCondition.Like("Name", argu.InputArgument));
                conditions.Add(DQCondition.Like("Spell", argu.InputArgument));
                conditions.Add(DQCondition.Like("Code", argu.InputArgument));
                query.Where.Conditions.Add(DQCondition.Or(conditions));
            }
            return(query.EExecuteList <string, string, long>().Select((l)
                                                                      => new WordPair(string.Concat(l.Item1, string.Concat("(", l.Item2, ")")), l.Item3.ToString())));
        }
Exemple #17
0
        internal static void Register()
        {
            ChoiceBoxSettings.Register(B3ButcheryDataSource.生产班组, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <BO.ProductShift>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });
            ChoiceBoxSettings.Register(B3ButcheryDataSource.生产线, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <BO.ProductLine>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });
            ChoiceBoxSettings.Register(B3ButcheryDataSource.车间品类, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <WorkshopCategory>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });
            ChoiceBoxSettings.Register(B3ButcheryDataSource.类别分类, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <CategoryClassification>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });
            ChoiceBoxSettings.Register(B3ButcheryDataSource.存货类别, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <GoodsCategory>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.计数名称, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <CalculateGoods>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.计数分类, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <CalculateCatalog>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });
            ChoiceBoxSettings.Register(B3ButcheryDataSource.速冻库, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <FrozenStore>(argu)
                {
                }.GetData());
            });
            ChoiceBoxSettings.Register(B3ButcheryDataSource.生产线全部, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <BO.ProductLine>(argu)
                {
                    OnlyAvailable = false
                }.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.计划号, argu =>
            {
                var main    = new JoinAlias(typeof(ProductPlan));
                var query   = new DQueryDom(main);
                query.Range = SelectRange.Top(60);
                query.Columns.Add(DQSelectColumn.Field("PlanNumber"));
                query.Columns.Add(DQSelectColumn.Field("ID"));
                query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("BillState", 单据状态.已审核),
                                                           DQCondition.EQ(main, "Domain_ID", DomainContext.Current.ID),
                                                           DQCondition.EQ("PlanNumbers", false)));
                if (!string.IsNullOrEmpty(argu.InputArgument))
                {
                    query.Where.Conditions.Add(DQCondition.Like("PlanNumber", argu.InputArgument));
                }
                if (!string.IsNullOrEmpty(argu.CodeArgument))
                {
                    query.Where.Conditions.Add(DQCondition.EQ("Date", DateTime.Parse(argu.CodeArgument)));
                }
                query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
                return(query.EExecuteList <string, long>().Select(x => new WordPair(x.Item1, x.Item2.ToString())));
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.货位, (argu) =>
            {
                if (string.IsNullOrEmpty(argu.CodeArgument))
                {
                    return(EnumerableUtil.Null <WordPair>());
                }

                var query = new DQueryDom(new JoinAlias(typeof(CargoSpace)));
                if (!string.IsNullOrEmpty(argu.CodeArgument))
                {
                    var ss = argu.CodeArgument.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    query.Where.Conditions.EFieldInList("Store_ID", ss);
                }

                query.Columns.Add(DQSelectColumn.Field("Name"));
                query.Columns.Add(DQSelectColumn.Field("ID"));
                query.OrderBy.Expressions.Add(
                    DQOrderByExpression.Create("ID"));
                if (!string.IsNullOrEmpty(argu.InputArgument))
                {
                    query.Where.Conditions.Add(DQCondition.Like("Name", argu.InputArgument));
                }
                return(ChoiceBoxQueryHelper.GetData(query));
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.生产环节, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <ProductLinks>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.生产环节全部, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <ProductLinks>(argu)
                {
                    OnlyAvailable = false
                }.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.屠宰分割入库类型, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <InStoreType>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.屠宰分割入库类型全部, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <InStoreType>(argu)
                {
                    OnlyAvailable = false
                }.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.存货带编号, (argu) =>
            {
                return(SelectGoodsWithSpec(argu, true));
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.存货带编号全部, (argu) =>
            {
                return(SelectGoodsWithSpec(argu, false));
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.存货品牌, (argu) =>
            {
                return(SelectGoodsBrand(argu));
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.成品入库模板, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <ProductInStoreTemplate>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });
            ChoiceBoxSettings.Register(B3ButcheryDataSource.生产环节模板, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <ProductLinkTemplate>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });
            ChoiceBoxSettings.Register(B3ButcheryDataSource.生产环节模板会计单位部门条件, SelectProductLinkTemplate);

            ChoiceBoxSettings.Register(B3ButcheryDataSource.生产通知单ID, (argu) =>
            {
                var queryHelper = new DomainChoiceBoxQueryHelper <ProductNotice>(argu)
                {
                    OnlyAvailable = false
                };
                queryHelper.AddSelectedField("ID");
                queryHelper.SearchFields.Add("ID");
                return(queryHelper.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.销售地区, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <ISaleZone>(argu)
                {
                    OnlyAvailable = true
                }.GetData());
            });

            ChoiceBoxSettings.Register(B3ButcheryDataSource.销售地区全部, (argu) =>
            {
                return(new DomainChoiceBoxQueryHelper <ISaleZone>(argu)
                {
                    OnlyAvailable = false
                }.GetData());
            });
        }