public async Task <IActionResult> DeleteDepartment([FromBody] int id) { reqmodel <int> reqmodel = await RequestPackingAsync(id); IDepartmentServer departmentServer = new DepartmentServerImpl(g_dbHelper, g_logServer); return(await departmentServer.DeleteDepartment(reqmodel)); }
public async Task <IActionResult> AddDepartment([FromBody] AddDepartmentModel model) { if (!ModelState.IsValid) { return(GetModelErrorCode()); } reqmodel <AddDepartmentModel> reqmodel = await RequestPackingAsync(model); IDepartmentServer departmentServer = new DepartmentServerImpl(g_dbHelper, g_logServer); return(await departmentServer.AddDepartment(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); }
public async Task <IActionResult> GetAllDepartmentDeps() { IDepartmentServer departmentServer = new DepartmentServerImpl(g_dbHelper, g_logServer); return(await departmentServer.GetAllDepartmentDeps()); }
/// <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); }
/// <summary> /// @xis 登录 2020-3-25 07:52:00 /// </summary> /// <param name="reqmodel"></param> /// <returns></returns> public async Task <Result> LoginAsync(reqmodel <LoginModel> reqmodel) { const string modelname = "UserServerImpl.LoginAsync"; Result <LoginResult> result = new Result <LoginResult> { status = ErrorCodeConst.ERROR_403, code = ErrorCodeConst.ERROR_100 }; string sql_user_select = g_sqlMaker.Select <t_user>(s => new { s.id, s.user_name, s.real_name, s.salt, s.log_pwd, s.position_id }) .Where($"user_name", "=", "@user_name") .And("state", "=", "@state") .ToSQL(); t_user user = await g_dbHelper.QueryAsync <t_user>(sql_user_select, new { reqmodel.Data.user_name, state = (int)EnumState.Normal }); if (user == null) { g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name}" }, EnumLogType.Debug); result.code = ErrorCodeConst.ERROR_1004; return(result); } string pwd = EncPassword(user.id, reqmodel.Data.password, user.salt); if (user.log_pwd != pwd) { g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name}" }, EnumLogType.Debug); result.code = ErrorCodeConst.ERROR_1004; return(result); } //获取职位信息 IPositionServer positionServer = new PositionServerImpl(g_dbHelper, g_logServer); t_position position_model = await positionServer.GetPosition(s => new { s.id, s.position_name, s.department_id }, user.position_id); if (position_model == null) { g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name},获取职位信息失败" }, EnumLogType.Debug); result.code = ErrorCodeConst.ERROR_1022; return(result); } //获取部门信息 IDepartmentServer departmentServer = new DepartmentServerImpl(g_dbHelper, g_logServer); t_department depart_model = await departmentServer.GetDepartment(s => new { s.id, s.department_name }, position_model.department_id); if (depart_model == null) { g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name},获取部门信息失败" }, EnumLogType.Debug); result.code = ErrorCodeConst.ERROR_1022; return(result); } //token string token = Common.AESEncrypt(Common.MakeMd5(Common.MakeGuid()), Common.MakeGuid()); LoginResult login_info = new LoginResult { user_id = user.id, user_name = user.user_name, avatar = user.avatar, real_name = user.real_name, department_id = depart_model.id, department_name = depart_model.department_name, position_id = position_model.id, position_name = position_model.position_name, token = token }; bool login_flag = await TokenRenewalAsync(token, login_info); if (!login_flag) { g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name},存Redis失败" }, EnumLogType.Debug); result.code = ErrorCodeConst.ERROR_1022; return(result); } result.data = login_info; result.status = ErrorCodeConst.ERROR_200; result.code = ErrorCodeConst.ERROR_1008; return(result); }