Beispiel #1
0
        public async Task <List <ApplyProcess> > GetApplyLogByOrderSnAsync(string order_sn)
        {
            string             sql            = g_sqlMaker.Select <t_apply_log>().Where("order_sn", "=", "@order_sn").ToSQL();
            List <t_apply_log> apply_log_list = await g_dbHelper.QueryListAsync <t_apply_log>(sql, new { order_sn });

            IPositionServer     positionServer = new PositionServerImpl(g_dbHelper, g_logServer);
            IUserServer         userServer     = new UserServerImpl(g_dbHelper, g_logServer);
            List <ApplyProcess> apply_list     = new List <ApplyProcess>();

            foreach (var item in apply_log_list)
            {
                t_position position_model = await positionServer.GetPosition(s => new { s.position_name }, item.position_id);

                t_user user_model = await userServer.GetUserById(s => new { s.real_name }, item.user_id);

                apply_list.Add(new ApplyProcess
                {
                    audit_status  = item.apply_status,
                    audit_time    = item.add_time.Value.ToString("yyyy-MM-dd hh:mm"),
                    remark        = item.remark,
                    position_name = position_model.position_name,
                    auditer       = user_model.real_name
                });
            }

            return(apply_list);
        }
Beispiel #2
0
        public async Task <IActionResult> GetUserInfo()
        {
            reqmodel reqmodel = await RequestPackingAsync();

            IUserServer userServer = new UserServerImpl(g_dbHelper, g_logServer);

            return(await userServer.GetUserInfoAsync(reqmodel));
        }
        /// <summary>
        /// @xis 验证
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private async Task <bool> Verify(HttpContext context)
        {
            //路径验证
            if (context.GetEndpoint() == null)
            {
                Result res = new Result
                {
                    code   = ErrorCodeConst.ERROR_600,
                    status = ErrorCodeConst.ERROR_400
                };
                await context.Response.WriteBodyAsync(res);

                return(false);
            }

            //身份验证
            LoginResult user = await context.Request.GetUserAsync();

            if (!await IDentityVerify(context, user))
            {
                Result res = new Result
                {
                    code   = ErrorCodeConst.ERROR_1001,
                    status = ErrorCodeConst.ERROR_401
                };
                await context.Response.WriteBodyAsync(res);

                return(false);
            }

            //不需要验证用户
            if (user == null || user.user_id == 1)
            {
                return(true);
            }

            //token 续期
            IUserServer userServer = new UserServerImpl();
            await userServer.TokenRenewalAsync(user.token, user);

            //验证权限
            if (!await PrivilegeVerify(context, user))
            {
                Result res = new Result
                {
                    code   = ErrorCodeConst.ERROR_1035,
                    status = ErrorCodeConst.ERROR_400
                };
                await context.Response.WriteBodyAsync(res);

                return(false);
            }

            return(true);
        }
Beispiel #4
0
        public async Task <IActionResult> Login([FromBody] LoginModel model)
        {
            if (!ModelState.IsValid)
            {
                return(GetModelErrorCode());
            }
            reqmodel <LoginModel> reqmodel = await RequestPackingAsync(model);

            IUserServer userServer = new UserServerImpl(g_dbHelper, g_logServer);

            return(await userServer.LoginAsync(reqmodel));
        }
        /// <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);
        }
Beispiel #6
0
        public async Task <List <ApplyProcess> > GetApplyLogByOrderSnAsync(EnumOrderType _ot, string order_sn, int _depart, int _start_position)
        {
            string             sql            = g_sqlMaker.Select <t_apply_log>().Where("order_sn", "=", "@order_sn").ToSQL();
            List <t_apply_log> apply_log_list = await g_dbHelper.QueryListAsync <t_apply_log>(sql, new { order_sn });

            IPositionServer     positionServer  = new PositionServerImpl(g_dbHelper, g_logServer);
            IUserServer         userServer      = new UserServerImpl(g_dbHelper, g_logServer);
            List <ApplyProcess> apply_list      = new List <ApplyProcess>();
            IEnumerable <int>   apply_proc_list = GetApplyList(_ot, _depart, _start_position);

            foreach (var item in apply_proc_list)
            {
                t_apply_log apply_log_model = apply_log_list.FirstOrDefault(f => f.position_id == item);
                t_position  position_model  = await positionServer.GetPosition(s => new { s.position_name }, item);

                if (apply_log_model != null)
                {
                    t_user user_model = await userServer.GetUserById(s => new { s.real_name }, apply_log_model.user_id);

                    apply_list.Add(new ApplyProcess
                    {
                        audit_status      = apply_log_model.apply_status,
                        audit_status_desc = ((EnumAuditStatus)apply_log_model.apply_status).GetDesc(),
                        audit_time        = apply_log_model.add_time.Value.ToString("yyyy-MM-dd hh:mm") ?? "",
                        remark            = apply_log_model.remark,
                        position_name     = position_model.position_name,
                        auditer           = user_model.real_name,
                    });
                }
                else
                {
                    apply_list.Add(new ApplyProcess
                    {
                        position_name = position_model.position_name
                    });
                }
            }

            return(apply_list);
        }
        /// <summary>
        /// @xis 获取入库单详情
        /// </summary>
        /// <param name="reqmodel"></param>
        /// <returns></returns>
        public async Task <Result> GetStockInDetailAsync(reqmodel <StockInDetailModel> reqmodel)
        {
            Result <StockInDetailResult> result = new Result <StockInDetailResult> {
                code = ErrorCodeConst.ERROR_100, status = ErrorCodeConst.ERROR_403
            };
            t_stock_in stock_in_model = await GetStockInByOrderSn(f => new
            {
                f.in_user_id,
                f.department_id,
                f.add_time,
                f.apply_status,
                f.position_id,
                f.order_sn
            }, reqmodel.Data.order_sn);

            if (stock_in_model == null)
            {
                result.code = ErrorCodeConst.ERROR_1038;
                return(result);
            }

            IUserServer       userServer       = new UserServerImpl(g_dbHelper, g_logServer);
            IDepartmentServer departmentServer = new DepartmentServerImpl(g_dbHelper, g_logServer);
            IAuditServer      auditServer      = new AuditServerImpl(g_dbHelper, g_logServer);

            t_user user_model = await userServer.GetUserById(s => new { s.real_name, s.job_number }, stock_in_model.in_user_id);

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

            result.data = new StockInDetailResult
            {
                add_time          = stock_in_model.add_time.Value.ToString("yyyy-MM-dd hh:mm:ss") ?? "",
                applyer           = user_model.real_name,
                apply_status      = stock_in_model.apply_status,
                apply_status_desc = ((EnumApplyStatus)stock_in_model.apply_status).GetDesc(),
                audit_step_index  = auditServer.GetApplyIndex(EnumOrderType.IN, stock_in_model.department_id, stock_in_model.position_id, stock_in_model.apply_process),
                job_number        = user_model.job_number,
                order_sn          = stock_in_model.order_sn,
                depart_name       = depart_model.department_name,
                audit_list        = await auditServer.GetApplyedLogByOrderSnAsync(EnumOrderType.IN, stock_in_model.order_sn, stock_in_model.department_id, stock_in_model.position_id),
                products          = new List <StockInProductResult>()
            };

            //获取入库的库存信息
            List <t_stock_in_detail> stock_detail_list = await GetStockDetailsByOrderSn(f => new t_stock_in_detail {
            }, stock_in_model.order_sn);

            IFactoryServer factoryServer = new FactoryServerImpl(g_dbHelper, g_logServer);

            foreach (var item in stock_detail_list)
            {
                result.data.products.Add(new StockInProductResult
                {
                    batch_number    = item.batch_number,
                    expiration_date = item.expiration_date,
                    factory_id      = item.factory_id,
                    instructions    = item.instructions,
                    material_number = item.material_number,
                    model_number    = item.model_number,
                    package_size    = item.package_size,
                    product_name    = item.product_name,
                    report_card_url = item.report_card_url,
                    retest_date     = item.retest_date,
                    spare_parts     = item.spare_parts,
                    unit_name       = item.unit_name,
                    quantity        = item.quantity,
                    unit_price      = item.unit_price,
                    factory_name    = (await factoryServer.GetFactoryById(f => new { f.factory_name }, item.factory_id)).factory_name
                });
            }
            result.code   = ErrorCodeConst.ERROR_200;
            result.status = ErrorCodeConst.ERROR_200;
            return(result);
        }