Пример #1
0
        /// <summary>
        /// @xis 待入库列表
        /// </summary>
        /// <param name="reqmodel"></param>
        /// <returns></returns>
        public async Task <Result> SearchStockPaginerAsync(reqmodel <SearchStockPreModel> reqmodel)
        {
            Result <PaginerData <SearchStockPrePaginerResult> > result = new Result <PaginerData <SearchStockPrePaginerResult> > {
                status = ErrorCodeConst.ERROR_200, code = ErrorCodeConst.ERROR_200
            };

            IWhere <t_stock>       stock_data_mkr      = g_sqlMaker.Select <t_stock>(s => new { s.id, s.product_name }).Where();
            IWhere <t_stockin_pre> stock_pre_data_mkr  = g_sqlMaker.Select <t_stockin_pre>(s => new { s.id, s.stock_id, s.quantity }).Where();
            IWhere <t_stockin_pre> stock_pre_total_mkr = g_sqlMaker.Select <t_stockin_pre>().Count().Where();
            //模糊查询产品
            List <t_stock> stock_list = new List <t_stock>();

            if (!string.IsNullOrWhiteSpace(reqmodel.Data.name))
            {
                stock_data_mkr      = stock_data_mkr.And("product_name", "like", "@product_name");
                stock_pre_data_mkr  = stock_pre_data_mkr.And("stock_id", "in", "@stock_id");
                stock_pre_total_mkr = stock_pre_total_mkr.And("stock_id", "in", "@stock_id");

                stock_list = await g_dbHelper.QueryListAsync <t_stock>(stock_data_mkr.ToSQL(), new { product_name = $"%{reqmodel.Data.name}%" });
            }

            //查询待入库
            string stock_pre_data_sql           = stock_pre_data_mkr.OrderByDesc("add_time").Pager(reqmodel.Data.page_index, reqmodel.Data.page_size).ToSQL();
            List <t_stockin_pre> stock_pre_list = await g_dbHelper.QueryListAsync <t_stockin_pre>(stock_pre_data_sql, new { stock_id = stock_list.Select(s => s.id) });

            int total = await g_dbHelper.QueryAsync <int>(stock_pre_total_mkr.ToSQL(), new { stock_id = stock_list.Select(s => s.id) });

            if (string.IsNullOrWhiteSpace(reqmodel.Data.name) && stock_pre_list.Count > 0)
            {
                stock_list = await g_dbHelper.QueryListAsync <t_stock>(stock_data_mkr.And("id", "in", "@stock_id").ToSQL(), new { stock_id = stock_pre_list.Select(s => s.stock_id) });
            }
            List <SearchStockPrePaginerResult> search_list = new List <SearchStockPrePaginerResult>();

            foreach (var item in stock_pre_list)
            {
                t_stock stock = stock_list.First(f => f.id == item.stock_id);
                search_list.Add(new SearchStockPrePaginerResult
                {
                    id           = item.id,
                    stock_id     = item.stock_id,
                    quantity     = item.quantity,
                    product_name = stock.product_name,
                });
            }
            PaginerData <SearchStockPrePaginerResult> paginer = new PaginerData <SearchStockPrePaginerResult>
            {
                page_index = reqmodel.Data.page_index,
                page_size  = reqmodel.Data.page_size,
                Data       = search_list,
                total      = total
            };

            result.data = paginer;
            return(result);
        }
Пример #2
0
        /// <summary>
        /// @xis 搜索入库单
        /// </summary>
        /// <param name="reqmodel"></param>
        /// <returns></returns>
        public async Task <Result> SearchStockInPaginerAsync(reqmodel <SearchStockInModel> reqmodel)
        {
            PaginerData <t_stock_in> order_list = await GetStockHasByVagueOrderSn(s => new
            {
                s.in_user_id,
                s.order_sn,
                s.add_time,
                s.apply_process,
                s.apply_status,
                s.department_id,
                s.position_id
            }, reqmodel.Data.order_sn, reqmodel.User.position_id, reqmodel.Data.page_index, reqmodel.Data.page_size);

            Result <PaginerData <SearchStockInResult> > result = new Result <PaginerData <SearchStockInResult> > {
                status = ErrorCodeConst.ERROR_200, code = ErrorCodeConst.ERROR_200
            };
            PaginerData <SearchStockInResult> result_paginer = new PaginerData <SearchStockInResult> {
                page_index = order_list.page_index, page_size = order_list.page_size, total = order_list.total, Data = new List <SearchStockInResult>()
            };
            IAuditServer      auditServer      = new AuditServerImpl(g_dbHelper, g_logServer);
            IUserServer       userServer       = new UserServerImpl(g_dbHelper, g_logServer);
            IDepartmentServer departmentServer = new DepartmentServerImpl(g_dbHelper, g_logServer);

            foreach (var item in order_list.Data)
            {
                t_user user_model = await userServer.GetUserById(s => new { s.real_name, s.job_number }, item.in_user_id);

                t_department depart_model = await departmentServer.GetDepartment(s => new { s.department_name }, item.department_id);

                result_paginer.Data.Add(new SearchStockInResult
                {
                    add_time          = item.add_time.Value.ToString("yyyy-MM-dd hh:mm:ss"),
                    applyer           = user_model.real_name,
                    apply_status      = item.apply_status,
                    apply_status_desc = ((EnumApplyStatus)item.apply_status).GetDesc(),
                    job_number        = user_model.job_number,
                    order_sn          = item.order_sn,
                    depart_name       = depart_model.department_name,
                    audit_list        = await auditServer.GetApplyLogByOrderSnAsync(EnumOrderType.IN, item.order_sn, item.department_id, item.position_id),
                    audit_step_index  = auditServer.GetApplyIndex(EnumOrderType.IN, item.department_id, item.position_id, item.apply_process),//获取审批到第几步
                    op_audit          = (auditServer.GetNextApplyer(EnumOrderType.IN, item.department_id, item.apply_process) == reqmodel.User.position_id) && item.apply_status == (int)EnumApplyStatus.Progress
                });
            }
            result.data = result_paginer;
            return(result);
        }
Пример #3
0
        /// <summary>
        /// @xis 模糊查询入库单
        /// </summary>
        /// <param name="selector">列选择器</param>
        /// <param name="order_sn">订单号</param>
        /// <param name="position_id">职位id</param>
        /// <param name="page_index">页码</param>
        /// <param name="page_size">数量</param>
        /// <returns></returns>
        public async Task <PaginerData <t_stock_in> > GetStockHasByVagueOrderSn(Func <t_stock_in, dynamic> selector, string order_sn, int position_id, int page_index, int page_size = 15)
        {
            ISelect <t_stock_in> select       = g_sqlMaker.Select(selector);
            ISelect <t_stock_in> select_count = g_sqlMaker.Select <t_stock_in>(null);
            IWhere <t_stock_in>  where_data;
            IWhere <t_stock_in>  where_count;

            if (!string.IsNullOrWhiteSpace(order_sn))
            {
                where_data  = select.Where("order_sn", "like", "@order_sn");
                where_count = select_count.Count().Where("order_sn", "like", "@order_sn");
            }
            else
            {
                where_data  = select.Where();
                where_count = select_count.Count().Where();
            }
            string sql_data = where_data
                              .And("position_id", "in", "@position_ids")
                              .And("status", "=", "@status")
                              .OrderByDesc("add_time")
                              .Pager(page_index, page_size)
                              .ToSQL();

            string sql_count = where_count
                               .And("status", "=", "@status")
                               .ToSQL();

            IPositionServer positionServer = new PositionServerImpl(g_dbHelper, g_logServer);
            List <int>      position_ids   = (await positionServer.GetSubordinatePositions(s => new { s.id }, position_id)).Select(s => s.id).ToList();

            position_ids.Insert(0, position_id);
            PaginerData <t_stock_in> paginer_data = new PaginerData <t_stock_in>
            {
                Data       = await g_dbHelper.QueryListAsync <t_stock_in>(sql_data, new { order_sn = $"%{order_sn}%", position_ids = position_ids, status = (int)EnumStatus.Enable, state = (int)EnumState.Normal }),
                page_index = page_index,
                page_size  = page_size,
                total      = await g_dbHelper.QueryAsync <int>(sql_count, new { order_sn = $"%{order_sn}%", status = (int)EnumStatus.Enable, state = (int)EnumState.Normal })
            };

            return(paginer_data);
        }
Пример #4
0
        /// <summary>
        /// @xis 名称模糊查询供货商
        /// </summary>
        /// <param name="selector"></param>
        /// <param name="name"></param>
        /// <param name="page_index"></param>
        /// <param name="page_size"></param>
        /// <returns></returns>
        public async Task <PaginerData <SearchFactoryResult> > SearchFactoryByVagueName(string name, int page_index, int page_size = 15)
        {
            IWhere <t_factory> where_data  = g_sqlMaker.Select <t_factory>(s => new { s.id, s.factory_name, s.factory_person_name, s.factory_tel }).Where();
            IWhere <t_factory> where_count = g_sqlMaker.Select <t_factory>().Count().Where();

            if (!string.IsNullOrWhiteSpace(name))
            {
                where_data.And("name", "like", "@name");
                where_count.And("name", "like", "@name");
            }

            where_data.And("status", "=", "@status").And("state", "=", "@state").OrderByDesc("add_time").Pager(page_index, page_size);
            where_count.And("status", "=", "@status").And("state", "=", "@state");
            List <t_factory> data_list = await g_dbHelper.QueryListAsync <t_factory>(where_data.ToSQL(), new { factory_name = $"%{name}%", status = (int)EnumStatus.Enable, state = (int)EnumState.Normal });

            int total = await g_dbHelper.QueryAsync <int>(where_count.ToSQL(), new { factory_name = $"%{name}%", status = (int)EnumStatus.Enable, state = (int)EnumState.Normal });

            List <SearchFactoryResult> list = new List <SearchFactoryResult>();

            foreach (var item in data_list)
            {
                list.Add(new SearchFactoryResult
                {
                    id                  = item.id,
                    factory_name        = item.factory_name,
                    factory_person_name = item.factory_person_name,
                    factory_tel         = item.factory_tel
                });
            }
            PaginerData <SearchFactoryResult> paginer_data = new PaginerData <SearchFactoryResult>
            {
                Data       = list,
                page_index = page_index,
                page_size  = page_size,
                total      = total
            };

            return(paginer_data);
        }
Пример #5
0
        public async Task <PaginerData <StockPaginerResult> > GetStockPaginer(string name, int page_index, int page_size)
        {
            IWhere <t_stock> where_data  = g_sqlMaker.Select <t_stock>(s => new { s.product_name }).Distinct().Where();
            IWhere <t_stock> where_total = g_sqlMaker.Select <t_stock>(null).Count("DISTINCT product_name").Where();

            if (!string.IsNullOrWhiteSpace(name))
            {
                where_data  = where_data.And("product_name", "like", "@product_name");
                where_total = where_total.And("product_name", "like", "@product_name");
            }

            string sql_data  = where_data.Pager(page_index, page_size).ToSQL();
            string sql_total = where_total.ToSQL();
            List <StockPaginerResult> list      = new List <StockPaginerResult>();
            List <string>             name_list = await g_dbHelper.QueryListAsync <string>(sql_data, new { product_name = $"%{name?.Trim()}%" });

            string         sql       = "select product_name, sum(quantity) as quantity from t_stock where product_name in @product_name group by product_name";
            List <t_stock> data_list = await g_dbHelper.QueryListAsync <t_stock>(sql, new { product_name = name_list });

            foreach (var item in data_list)
            {
                list.Add(new StockPaginerResult
                {
                    name       = item.product_name,
                    quantility = item.quantity
                });
            }
            PaginerData <StockPaginerResult> paginer = new PaginerData <StockPaginerResult>
            {
                page_index = page_index,
                page_size  = page_size,
                total      = await g_dbHelper.QueryAsync <int>(sql_total, new { product_name = $"%{name?.Trim()}%" }),
                Data       = list
            };

            return(paginer);
        }