public async Task <IActionResult> DeleteFactory([FromBody] int id)
        {
            reqmodel <int> reqmodel = await RequestPackingAsync(id);

            IFactoryServer factoryServer = new FactoryServerImpl(g_dbHelper, g_logServer);

            return(await factoryServer.DeleteFactory(reqmodel));
        }
        //[Privilege("searchfactorydrop")]
        public async Task <IActionResult> SearchFactoryByPaginer([FromQuery] SearchFactoryModel model)
        {
            reqmodel <SearchFactoryModel> reqmodel = await RequestPackingAsync(model);

            IFactoryServer factoryServer = new FactoryServerImpl(g_dbHelper, g_logServer);

            return(await factoryServer.SearchFactoryByPaginer(reqmodel));
        }
        public async Task <IActionResult> AddFactory([FromBody] AddFactoryModel model)
        {
            if (!ModelState.IsValid)
            {
                return(GetModelErrorCode());
            }
            reqmodel <AddFactoryModel> reqmodel = await RequestPackingAsync(model);

            IFactoryServer factoryServer = new FactoryServerImpl(g_dbHelper, g_logServer);

            return(await factoryServer.AddFactory(reqmodel));
        }
示例#4
0
        /// <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);
        }
示例#5
0
        /// <summary>
        /// @xis 添加库存
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <SVResult <int> > AddStock(t_stock model)
        {
            SVResult <int> res = new SVResult <int> {
                state = false
            };

            string sql_insert = g_sqlMaker.Insert <t_stock>(i => new
            {
                i.batch_number,
                i.expiration_date,
                i.factory_id,
                i.freeze_quantity,
                i.instructions,
                i.material_number,
                i.model_number,
                i.package_size,
                i.product_name,
                i.quantity,
                i.remark,
                i.report_card_url,
                i.retest_date,
                i.spare_parts,
                i.state,
                i.status,
                i.unit_price,
                i.util_name
            }).ToSQL();

            //验证
            if (string.IsNullOrWhiteSpace(model.product_name))
            {
                res.code = ErrorCodeConst.ERROR_1044;
                return(res);
            }

            if (model.product_name.Length > 30)
            {
                res.code = ErrorCodeConst.ERROR_1046;
                return(res);
            }

            if (model.factory_id <= 0)
            {
                res.code = ErrorCodeConst.ERROR_1045;
                return(res);
            }
            IFactoryServer factoryServer = new FactoryServerImpl(g_dbHelper, g_logServer);
            t_factory      factory_model = await factoryServer.GetFactoryByIdEnable(g => new { g.id }, model.factory_id);

            if (factory_model == null)
            {
                res.code = ErrorCodeConst.ERROR_1045;
                return(res);
            }

            int id = await g_dbHelper.ExecScalarAsync <int>(sql_insert, model);

            if (id <= 0)
            {
                res.code = ErrorCodeConst.ERROR_1018;
                return(res);
            }
            res.data  = id;
            res.state = true;
            return(res);
        }