/// <summary> /// 个人设置邮箱 /// </summary> /// <param name="requestObject"></param> /// <param name="UserID"></param> /// <returns></returns> public async Task <ResponseObject <TSMUserAccountEmail, bool> > ModifyEmailAsync(RequestObject <TSMUserAccountEmail> requestObject, int UserID) { try { if (requestObject.PostData == null) { return(ResponseUtil <TSMUserAccountEmail, bool> .FailResult(requestObject, false, "PostData不能为null")); } var entity = requestObject.PostData; var enditModel = await _db.Instance.Queryable <TSMUserAccountDbModel>().Where(p => p.ID == UserID).FirstAsync(); enditModel.EmailAccount = entity.Email; _db.Instance.Updateable <TSMUserAccountDbModel>(enditModel).UpdateColumns(p => new { p.EmailAccount }).ExecuteCommand(); return(ResponseUtil <TSMUserAccountEmail, bool> .SuccessResult(requestObject, true)); } catch (Exception ex) { //返回查询异常结果 return(ResponseUtil <TSMUserAccountEmail, bool> .FailResult(requestObject, false, ex.Message)); } }
/// <summary> /// 根据角色ID 获取菜单树 /// </summary> /// <param name="requestObject"></param> /// <returns></returns> public async Task <ResponseObject <TRolePermissionsModel, List <MenuViewModel> > > LoadMenuByRoles(RequestObject <TRolePermissionsModel> requestObject) { try { List <MenuViewModel> queryData = null;//查询结果集对象 List <TButtonsModel> buttonsModels = _db.Instance.Queryable <TButtonsModel>().ToList(); RefAsync <int> totalNumber = -1;//总记录数 var query = _db.Instance.Queryable <TRolePermissionsModel, TRolesModel, TPMMenusDbModel>( (t, t0, t2) => new object[] { JoinType.Inner, t.RoleId == t0.Id, JoinType.Inner, t.MenuId == t2.Id }); if (requestObject.QueryConditions == null || requestObject.QueryConditions.Count() == 0) { ResponseUtil <TRolePermissionsModel, List <MenuViewModel> > .FailResult(requestObject, null, "查询条件必须含有roleid"); } else { if (!requestObject.QueryConditions.Any(p => p.Column.ToLower() == "roleid")) { ResponseUtil <TRolePermissionsModel, List <MenuViewModel> > .FailResult(requestObject, null, "查询条件必须含有roleid"); } else { var expressionList = SqlSugarUtil.GetQueryExpressions(requestObject.QueryConditions); expressionList.ForEach(p => query.Where($"t.{p}")); } } //获取菜单 var memu = query.Select((t, t0, t2) => new { buttons = t.ButtonIds, memu = t2 }).ToList(); var menuDictoray = memu.ToDictionary(p => p.memu.Id, p => p.buttons); List <int> allMenuIDS = new List <int>(); foreach (var item in memu) { var ids = item.memu.LogicPath.Split('.').Select(p => Convert.ToInt32(p)).ToList(); allMenuIDS.AddRange(ids); } allMenuIDS = allMenuIDS.Distinct().ToList(); var allDisplayNodes = await _db.Instance.Queryable <TPMMenusDbModel>().Where(p => allMenuIDS.Contains(p.Id) && p.Status == true).ToListAsync(); //所有需要展示的菜单 var data = GetMenuTree(allDisplayNodes, menuDictoray, buttonsModels, -1); return(ResponseUtil <TRolePermissionsModel, List <MenuViewModel> > .SuccessResult(requestObject, data, totalNumber)); } catch (Exception ex) { return(ResponseUtil <TRolePermissionsModel, List <MenuViewModel> > .FailResult(requestObject, null, ex.Message)); } }
public async Task <ResponseObject <string> > ExportBomTemplate() { try { CurrentUser currentUser = TokenManager.GetCurentUserbyToken(HttpContext.Request.Headers); var result = await _service.ExportBomTemplate(359, currentUser); //return result; ExportTemplateVM <TMMBOMDetailQueryExcelModel> model = new ExportTemplateVM <TMMBOMDetailQueryExcelModel>(); model.Entitys = result.Data.TMMBOMDetailQueryExcelList == null ? new List <TMMBOMDetailQueryExcelModel>() : result.Data.TMMBOMDetailQueryExcelList; model.Columns = new List <string>() { "ItemName", "MaterialName", "PartName", "LengthValue", "WidthValue", "NumValue", "WideValue", "LossValue", "SingleValue" }; model.Titles = new List <string>() { "ItemName", "MaterialName", "PartName", "LengthValue", "WidthValue", "NumValue", "WideValue", "LossValue", "SingleValue" }; model.HeaderText = "BOM模板"; model.TableName = "BOM模板"; model.FillRow = 6; model.Path = Path.Combine(AppContext.BaseDirectory, "Template", "ExportBomTemplate.xlsx"); Stream stream = ExcelHelp.ExportExcelByTemplate <TMMBOMDetailQueryExcelModel>(model); string fileName = "生产单模板-有配色方案.xlsx"; Dictionary <string, string> headsSend = new Dictionary <string, string>(); headsSend.Add(TokenConfig.Instace.TokenKey, Request.Headers[TokenConfig.Instace.TokenKey]); var filePath = RestfulApiClient.UploadFile(RestfulApiClient.UplaodUrl, "api/files/upload", headsSend, stream, fileName); return(ResponseUtil <string> .SuccessResult(filePath.ToString())); } catch (Exception ex) { return(ResponseUtil <string> .FailResult(null, ex.ToString())); } }
/// <summary> /// 删除T_DataDicMain数据,通过主表主键删除主从数据,批量删除 /// </summary> /// <param name="requestObject">响应结果对象</param> /// <returns></returns> public async Task <ResponseObject <int[], bool> > DeleteAsync(RequestObject <int[]> requestObject) { var currDb = _db.Instance;//事务需要使用同一个 SqlSugarClient对象实例 try { //开启事务 currDb.BeginTran(); //删除明细信息 var detailFlag = await currDb.Deleteable <TDataDicDetailModel>().In(p => p.KeyId, requestObject.PostData).ExecuteCommandAsync() > 0; //删除主表信息 var mainFlag = await currDb.Deleteable <TDataDicMainModel>().In(requestObject.PostData).ExecuteCommandAsync() > 0; //提交事务 currDb.CommitTran(); //返回执行结果 if (mainFlag && detailFlag) { return(ResponseUtil <int[], bool> .SuccessResult(requestObject, true)); } return(ResponseUtil <int[], bool> .FailResult(requestObject, false, "删除数据失败!")); } catch (Exception ex) { //回滚事务 currDb.RollbackTran(); //返回异常结果 return(ResponseUtil <int[], bool> .FailResult(requestObject, false, ex.Message)); } }
/// <summary> /// 修改T_DataDicMain数据 /// </summary> /// <param name="requestObject">Put请求参数</param> /// <returns>返回响应结果对象,包括响应代码,修改操作结果</returns> public async Task <ResponseObject <TDataDicMainModel, bool> > PutAsync(RequestObject <TDataDicMainModel> requestObject) { var currDb = _db.Instance;//事务需要使用同一个 SqlSugarClient对象实例 try { if (requestObject.PostData == null) { return(ResponseUtil <TDataDicMainModel, bool> .FailResult(requestObject, false, "PostData不能为null")); } //开启事务 currDb.BeginTran(); //修改主表信息 var mainFlag = await currDb.Updateable(requestObject.PostData).ExecuteCommandAsync() > 0; //修改明细信息 var detailFlag = await currDb.Updateable(requestObject.PostData.ChildList).ExecuteCommandAsync() > 0; //提交事务 currDb.CommitTran(); //返回执行结果 if (mainFlag && detailFlag) { return(ResponseUtil <TDataDicMainModel, bool> .SuccessResult(requestObject, true)); } return(ResponseUtil <TDataDicMainModel, bool> .FailResult(requestObject, false, "修改数据失败!")); } catch (Exception ex) { //回滚事务 currDb.RollbackTran(); //返回异常结果 return(ResponseUtil <TDataDicMainModel, bool> .FailResult(requestObject, false, ex.Message)); } }
/// <summary> /// 新增T_Tenants数据 /// </summary> /// <param name="requestObject">返回响应结果对象,包括响应代码,新增操作结果</param> /// <returns></returns> public async Task <ResponseObject <TTenantsModel, bool> > PostAsync(RequestObject <TTenantsModel> requestObject) { try { //如果没有新增数据,返回错误信息 if (requestObject.PostData == null && requestObject.PostDataList == null) { return(ResponseUtil <TTenantsModel, bool> .FailResult(requestObject, false, "PostData,PostDataList不能都为null")); } var result = false; //批量新增的优先级高于单条数据新增,且只会执行一个新增操作 if (requestObject.PostDataList != null && requestObject.PostDataList.Count > 1) { result = await _db.Instance.Insertable(requestObject.PostDataList).ExecuteCommandAsync() > 0; } else { result = await _db.Instance.Insertable(requestObject.PostData).ExecuteCommandAsync() > 0; } //返回执行结果 if (result) { return(ResponseUtil <TTenantsModel, bool> .SuccessResult(requestObject, true)); } return(ResponseUtil <TTenantsModel, bool> .FailResult(requestObject, false, "新增数据失败!")); } catch (Exception ex) { //返回异常结果 return(ResponseUtil <TTenantsModel, bool> .FailResult(requestObject, false, ex.Message)); } }
/// <summary> /// 发送忘记密码短信验证码 /// </summary> /// <param name="requestObject"></param> /// <returns></returns> public ResponseObject <string> SendForgetVerificationCode(RequestObject <VerificationInputModel> requestObject) { string result = string.Empty; if (requestObject.PostData == null) { return(ResponseUtil <string> .FailResult("PostData不能都为null")); } List <SingleReceiverMessage> messageList = new List <SingleReceiverMessage>(); string templateId = @"595c42190cf847caadb0822b3685bcb6"; string randCode = RandCodeCreate.GenerateRandomOnlyNumber(6); result = randCode; string[] templateParas = { randCode }; SingleReceiverMessage singleReceiverMessage = new SingleReceiverMessage(requestObject.PostData.Mobile, templateId, templateParas); messageList.Add(singleReceiverMessage); //发送短信 Task.Factory.StartNew(() => { try { HuaWeiShortMessageProvider.SendDiffContentMessages(messageList); } catch { } }); //写 登陆状态到redis var redis = CacheFactory.Instance(CacheType.Redis); string redisKey = string.Format(CacheKeyString.ForgetMsgCode, requestObject.PostData.Mobile); redis.AddOrUpdateKey <string>(redisKey, result, 300); return(ResponseUtil <string> .SuccessResult("发送成功")); }
/// <summary> /// 出库单审核 /// </summary> /// <param name="requestObject"></param> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <bool> > AuditAsync(RequestPut <TWMProductionAduit> requestObject, CurrentUser currentUser) { try { _db.Instance.BeginTran(); //更新审核状态 var result = await _db.Instance.Updateable <TWMProductionWhMainDbModel>() .SetColumns(p => new TWMProductionWhMainDbModel { AuditStatus = requestObject.PostData.AuditStatus, AuditId = currentUser.UserID, AuditTime = DateTime.Now }) .Where(p => p.ID == requestObject.PostData.ID && (p.AuditStatus == 0 || p.AuditStatus == 1)) .ExecuteCommandAsync() > 0; //审核通过后统计当前入库单的数量和金额 if (result && requestObject.PostData.AuditStatus == 2) { OtherWhCountAsync(requestObject.PostData.ID, currentUser); } _db.Instance.CommitTran(); return(result ? ResponseUtil <bool> .SuccessResult(true) : ResponseUtil <bool> .FailResult(false, "审核数据失败,该数据可能已审核!")); } catch (Exception ex) { _db.Instance.RollbackTran(); return(ResponseUtil <bool> .FailResult(false, $"审核数据发生异常{Environment.NewLine} {ex.Message}")); } }
/// <summary> /// 获取当前月份销售订单统计信息 /// </summary> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <List <SalesmanAmountCountModel> > > GetSalesmanAmountCount(CurrentUser currentUser) { try { var result = await _db.Instance.Queryable <TSSMSalesOrderMainDbModel, TSMUserAccountDbModel>( (t, t0) => new object[] { JoinType.Left, t.SalesmanId == t0.ID }) .Where((t, t0) => t.CompanyId == currentUser.CompanyID && t.OrderDate >= Convert.ToDateTime($"{DateTime.Now.ToString("yyyy-MM")}-01") && t.OrderDate < Convert.ToDateTime($"{DateTime.Now.AddMonths(1).ToString("yyyy-MM")}-01")) .GroupBy((t, t0) => t0.AccountName) .Select((t, t0) => new SalesmanAmountCountModel { Value = SqlFunc.AggregateSum(t.SalesAmount), Name = t0.AccountName }) .ToListAsync(); return(ResponseUtil <List <SalesmanAmountCountModel> > .SuccessResult(result)); } catch (Exception ex) { return(ResponseUtil <List <SalesmanAmountCountModel> > .FailResult(null, $"统计当月销售订单信息发生异常{System.Environment.NewLine}{ex.Message}")); } }
/// <summary> /// 获取T_BM_CustomerContact数据 /// </summary> /// <param name="requestObject">Get请求参数</param> /// <returns>返回响应结果对象,包括响应代码,查询操作结果</returns> public async Task <ResponseObject <List <TBMCustomerContactQueryModel> > > GetDetailListAsync(int requestObject) { try { //查询结果集对象 List <TBMCustomerContactQueryModel> queryData = null; //总记录数 RefAsync <int> totalNumber = -1; var query = _db.Instance.Queryable <TBMCustomerContactDbModel>(); //执行查询 queryData = await query.Select((t) => new TBMCustomerContactQueryModel { ID = t.ID, CustomerId = t.CustomerId, ContactName = t.ContactName, ContactNumber = t.ContactNumber, Priority = t.Priority, }) .Where(t => t.CustomerId == requestObject) .ToListAsync(); //返回执行结果 return(ResponseUtil <List <TBMCustomerContactQueryModel> > .SuccessResult(queryData, totalNumber)); } catch (Exception ex) { //返回查询异常结果 return(ResponseUtil <List <TBMCustomerContactQueryModel> > .FailResult(null, ex.Message)); } }
/// <summary> /// 获取销售订单金额统计信息 /// </summary> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <SalesAmountCountModel> > GetSalesAmountCount(CurrentUser currentUser) { try { var today = await _db.Instance.Queryable <TSSMSalesOrderMainDbModel>() .Where(p => p.CompanyId == currentUser.CompanyID && p.OrderDate == Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")) ) .SumAsync(p => p.SalesAmount); var month = await _db.Instance.Queryable <TSSMSalesOrderMainDbModel>() .Where(p => p.CompanyId == currentUser.CompanyID && p.OrderDate >= Convert.ToDateTime($"{DateTime.Now.ToString("yyyy-MM")}-01") && p.OrderDate < Convert.ToDateTime($"{DateTime.Now.AddMonths(1).ToString("yyyy-MM")}-01")) .SumAsync(p => p.SalesAmount); var model = new SalesAmountCountModel { xAxisData = new string[] { "今日", "本月" }, SeriesData = new string[] { today.ToString(), month.ToString() } }; return(ResponseUtil <SalesAmountCountModel> .SuccessResult(model)); } catch (Exception ex) { return(ResponseUtil <SalesAmountCountModel> .FailResult(null, $"统计销售订单金额发生异常{System.Environment.NewLine} {ex.Message}")); } }
/// <summary> /// 盘盈入库单审核 /// </summary> /// <param name="request"></param> /// <param name="current"></param> /// <returns></returns> public async Task <ResponseObject <bool> > ProfitAuditAsync(RequestPut <TWMProfitMainAuditModel> request, CurrentUser current) { try { var flag = await _db.Instance.Updateable <TWMProfitMainDbModel>() .SetColumns(p => new TWMProfitMainDbModel { AuditId = current.UserID, AuditStatus = request.PostData.AuditStatus, AuditTime = DateTime.Now }) .Where(p => p.ID == request.PostData.ID && p.AuditStatus != 2) .ExecuteCommandAsync() > 0; if (flag && request.PostData.AuditStatus == 2) { ProfitCountAsync(request.PostData.ID); } return(flag ? ResponseUtil <bool> .SuccessResult(true) : ResponseUtil <bool> .FailResult(false, "审核数据失败,该数据可能已审核")); } catch (Exception ex) { return(ResponseUtil <bool> .FailResult(false, $"审核盘盈入库单发生异常{Environment.NewLine}{ex.Message}")); } }
public async Task <ResponseObject <TPSMPurchaseOrderMainQueryModel> > GetWholeMainData(int requestObject, CurrentUser currentUser) { try { RequestGet requestGet = new RequestGet() { IsPaging = false, QueryConditions = new List <QueryCondition>() { new QueryCondition() { Column = "ID", Condition = ConditionEnum.Equal, Content = requestObject.ToString() } } }; var mainModel = await GetMainListAsync(requestGet, currentUser); TPSMPurchaseOrderMainQueryModel tPSMPurchaseOrderMainQueryModel = mainModel.Data.FirstOrDefault(); var deatailModel = await GetDetialList(requestObject, currentUser); tPSMPurchaseOrderMainQueryModel.ChildList = deatailModel.Data; return(ResponseUtil <TPSMPurchaseOrderMainQueryModel> .SuccessResult(tPSMPurchaseOrderMainQueryModel)); } catch (Exception ex) { return(ResponseUtil <TPSMPurchaseOrderMainQueryModel> .FailResult(null, ex.Message)); } }
/// <summary> /// 删除数据 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="requestObject"></param> /// <returns></returns> private async Task <ResponseObject <T, bool> > DeleteAsync <T>(RequestObject <T> requestObject) { try { //删除主表信息 var ids = requestObject.PostData as int[]; if (ids == null) { ids = new int[] { requestObject.PostData.ObjToInt() }; } var result = await _db.Instance.Deleteable <TSMUserInfoDbModel>().In(ids).ExecuteCommandAsync() > 0; //返回执行结果 if (result) { return(ResponseUtil <T, bool> .SuccessResult(requestObject, true)); } return(ResponseUtil <T, bool> .FailResult(requestObject, false, "删除数据失败!")); } catch (Exception ex) { //返回异常结果 return(ResponseUtil <T, bool> .FailResult(requestObject, false, ex.Message)); } }
/// <summary> /// 删除T_PM_SeedUsers数据 /// </summary> /// <param name="requestObject"></param> /// <returns></returns> public async Task <ResponseObject <bool> > DeleteAsync(RequestDelete <DeleteModel> requestObject) { try { //执行结果 var result = false; //没有删除数据,返回错误信息 if (requestObject.PostData == null && requestObject.PostDataList == null) { return(ResponseUtil <bool> .FailResult(false, "PostData、PostDataList不能都为null")); } //批量删除的优先级高于单记录删除 if (requestObject.PostDataList != null && requestObject.PostDataList.Count > 0) { //批量删除 var ids = requestObject.PostDataList.Select(p => p.ID); result = await _db.Instance.Deleteable <TPMSeedUsersDbModel>().In(ids).ExecuteCommandAsync() > 0; } else { //单记录删除 result = await _db.Instance.Deleteable <TPMSeedUsersDbModel>().In(requestObject.PostData.ID).ExecuteCommandAsync() > 0; } //返回执行结果 return(result ? ResponseUtil <bool> .SuccessResult(true) : ResponseUtil <bool> .FailResult(false, "删除数据失败!")); } catch (Exception ex) { //返回异常结果 return(ResponseUtil <bool> .FailResult(false, ex.Message)); } }
/// <summary> /// 获取T_WM_ProductionDetail数据 /// </summary> /// <param name="requestObject">Get请求参数</param> /// <returns>返回响应结果对象,包括响应代码,查询操作结果</returns> public async Task <ResponseObject <List <TWMProductionDetailQueryModel> > > GetDetailListAsync(int requestObject) { try { //查询结果集对象 List <TWMProductionDetailQueryModel> queryData = null; //总记录数 RefAsync <int> totalNumber = -1; var query = _db.Instance.Queryable <TWMProductionDetailDbModel>(); //执行查询 queryData = await query.Select((t) => new TWMProductionDetailQueryModel { ID = t.ID, MainId = t.MainId, MaterialId = t.MaterialId, WarehouseId = t.WarehouseId, ActualNum = t.ActualNum, UnitPrice = t.UnitPrice, Amount = t.Amount, Remark = t.Remark, }) .Where(t => t.MainId == requestObject) .ToListAsync(); //返回执行结果 return(ResponseUtil <List <TWMProductionDetailQueryModel> > .SuccessResult(queryData, totalNumber)); } catch (Exception ex) { //返回查询异常结果 return(ResponseUtil <List <TWMProductionDetailQueryModel> > .FailResult(null, ex.Message)); } }
/// <summary> /// 删除T_TenantPermissions数据 /// </summary> /// <param name="requestObject"></param> /// <returns></returns> public async Task <ResponseObject <TTenantPermissionsModel, bool> > DeleteAsync(RequestObject <TTenantPermissionsModel> requestObject) { try { //执行结果 var result = false; //没有删除数据,返回错误信息 if (requestObject.PostDataList == null && requestObject.PostData == null) { return(ResponseUtil <TTenantPermissionsModel, bool> .FailResult(requestObject, false, "PostData,PostDataList不能都为null")); } //批量删除的优先级高于单记录删除 if (requestObject.PostDataList != null && requestObject.PostDataList.Count > 0) { //批量删除 result = await _db.Instance.Deleteable(requestObject.PostDataList).ExecuteCommandAsync() > 0; } else { //单记录删除 result = await _db.Instance.Deleteable(requestObject.PostData).ExecuteCommandAsync() > 0; } //返回执行结果 if (result) { return(ResponseUtil <TTenantPermissionsModel, bool> .SuccessResult(requestObject, true)); } return(ResponseUtil <TTenantPermissionsModel, bool> .FailResult(requestObject, false, "删除数据失败!")); } catch (Exception ex) { //返回异常结果 return(ResponseUtil <TTenantPermissionsModel, bool> .FailResult(requestObject, false, ex.Message)); } }
/// <summary> /// 采购供应商 /// </summary> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <List <PurchaseSupplierModel> > > GetSupplier(CurrentUser currentUser) { try { var result = await _db.Instance.Queryable <TPSMPurchaseOrderDetailDbModel, TPSMPurchaseOrderMainDbModel, TBMSupplierFileDbModel>( (t1, t2, t3) => new object[] { JoinType.Left, t1.MainId == t2.ID, JoinType.Left, t1.SupplierId == t3.ID, }) .Where((t1, t2, t3) => t2.CompanyId == currentUser.CompanyID && !SqlFunc.IsNullOrEmpty(t3.SupplierName)) .GroupBy((t1, t2, t3) => new { t1.SupplierId }) .Select((t1, t2, t3) => new PurchaseSupplierModel { Value = Convert.ToInt32(t1.SupplierId), Name = t3.SupplierName }) .ToListAsync(); return(ResponseUtil <List <PurchaseSupplierModel> > .SuccessResult(result)); } catch (Exception ex) { return(ResponseUtil <List <PurchaseSupplierModel> > .FailResult(null, $"采购供应商发生异常{System.Environment.NewLine}{ex.Message}")); } }
/// <summary> /// 获取供应商采购金额分析 /// </summary> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <List <PurchaseSupplierAmountCountModel> > > GetPurchaseSupplierAmountCount(CurrentUser currentUser) { try { var today = await _db.Instance.Queryable <TPSMPurchaseOrderDetailDbModel, TPSMPurchaseOrderMainDbModel, TBMSupplierFileDbModel>( (t1, t2, t3) => new object[] { JoinType.Left, t1.MainId == t2.ID, JoinType.Left, t1.SupplierId == t3.ID } ).Where((t1, t2, t3) => t2.CompanyId == currentUser.CompanyID && t2.OrderDate >= Convert.ToDateTime($"{DateTime.Now.ToString("yyyy-MM")}-01") && t2.OrderDate < Convert.ToDateTime($"{DateTime.Now.AddMonths(1).ToString("yyyy-MM")}-01") ) .GroupBy((t1, t2, t3) => t3.SupplierName) .Where((t1, t2, t3) => !SqlFunc.IsNullOrEmpty(t3.SupplierName)) .Select((t1, t2, t3) => new PurchaseSupplierAmountCountModel { Value = SqlFunc.AggregateSum(t1.PurchaseAmount), Name = t3.SupplierName }) .ToListAsync(); return(ResponseUtil <List <PurchaseSupplierAmountCountModel> > .SuccessResult(today)); } catch (Exception ex) { return(ResponseUtil <List <PurchaseSupplierAmountCountModel> > .FailResult(null, $"统计采购订单金额发生异常{System.Environment.NewLine} {ex.Message}")); } }
/// <summary> /// 采购业务员 /// </summary> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <List <PurchaseBuyerModel> > > GetSaleMan(CurrentUser currentUser) { try { var result = await _db.Instance.Queryable <TPSMPurchaseOrderMainDbModel, TSMUserAccountDbModel>( (t1, t2) => new object[] { JoinType.Left, t1.BuyerId == t2.ID, }) .Where((t1, t2) => t1.CompanyId == currentUser.CompanyID && !SqlFunc.IsNullOrEmpty(t2.AccountName) ) .GroupBy((t1, t2) => new { t1.BuyerId }) .Select((t1, t2) => new PurchaseBuyerModel { Value = t1.BuyerId, Name = t2.AccountName }) .ToListAsync(); return(ResponseUtil <List <PurchaseBuyerModel> > .SuccessResult(result)); } catch (Exception ex) { return(ResponseUtil <List <PurchaseBuyerModel> > .FailResult(null, $"采购业务员发生异常{System.Environment.NewLine}{ex.Message}")); } }
/// <summary> /// 新增T_Templates数据 /// </summary> /// <param name="requestObject">返回响应结果对象,包括响应代码,新增操作结果</param> /// <returns></returns> public async Task <ResponseObject <TTemplatesModel, bool> > PostAsync(RequestObject <TTemplatesModel> requestObject) { try { //如果没有新增数据,返回错误信息 if (requestObject.PostData == null && requestObject.PostDataList == null) { return(ResponseUtil <TTemplatesModel, bool> .FailResult(requestObject, false, "PostData,PostDataList不能都为null")); } var result = false; result = await _db.Instance.Insertable(requestObject.PostData).ExecuteCommandIdentityIntoEntityAsync(); if (result && requestObject.PostData.isDefault) { _db.Instance.Updateable <TTemplatesModel>() .Where(p => p.Id != requestObject.PostData.Id) .SetColumns(p => p.isDefault == false) .ExecuteCommand(); } //返回执行结果 if (result) { return(ResponseUtil <TTemplatesModel, bool> .SuccessResult(requestObject, true)); } return(ResponseUtil <TTemplatesModel, bool> .FailResult(requestObject, false, "新增数据失败!")); } catch (Exception ex) { //返回异常结果 return(ResponseUtil <TTemplatesModel, bool> .FailResult(requestObject, false, ex.Message)); } }
/// <summary> /// 新增T_PM_DictionaryInitInfo数据 /// </summary> /// <param name="requestObject">返回响应结果对象,包括响应代码,新增操作结果</param> /// <returns></returns> public async Task <ResponseObject <bool> > PostAsync(RequestPost <TPMDictionaryInitInfoAddModel> requestObject) { try { //如果没有新增数据,返回错误信息 if (requestObject.PostData == null && requestObject.PostDataList == null) { return(ResponseUtil <bool> .FailResult(false, "PostData,PostDataList不能都为null")); } var result = false; //批量新增的优先级高于单条数据新增,且只会执行一个新增操作 if (requestObject.PostDataList != null && requestObject.PostDataList.Count > 0) { var addList = _mapper.Map <List <TPMDictionaryInitInfoAddModel>, List <TPMDictionaryInitInfoDbModel> >(requestObject.PostDataList); result = await _db.Instance.Insertable(addList).ExecuteCommandAsync() > 0; } else { var addModel = _mapper.Map <TPMDictionaryInitInfoDbModel>(requestObject.PostData); result = await _db.Instance.Insertable(addModel).ExecuteCommandAsync() > 0; } //返回执行结果 return(result ? ResponseUtil <bool> .SuccessResult(true) : ResponseUtil <bool> .FailResult(false, "新增数据失败!")); } catch (Exception ex) { //返回异常结果 return(ResponseUtil <bool> .FailResult(false, ex.Message)); } }
/// <summary> /// 款型分布 /// </summary> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <List <SalesPackageAmountCountModel> > > GetSalePackageCount(CurrentUser currentUser) { try { var result = await _db.Instance.Queryable <TSSMSalesOrderDetailDbModel, TSSMSalesOrderMainDbModel, TBMMaterialFileDbModel, TBMPackageDbModel>( (t1, t2, t3, t4) => new object[] { JoinType.Left, t1.MainId == t2.ID, JoinType.Left, t1.MaterialId == t3.ID, JoinType.Left, t3.PackageID == t4.ID }) .Where((t1, t2, t3, t4) => t2.CompanyId == currentUser.CompanyID && t2.OrderDate >= Convert.ToDateTime($"{DateTime.Now.ToString("yyyy-MM")}-01") && t2.OrderDate < Convert.ToDateTime($"{DateTime.Now.AddMonths(1).ToString("yyyy-MM")}-01") && t3.PackageID != null) .GroupBy((t1, t2, t3, t4) => new { t4.DicValue }) .Select((t1, t2, t3, t4) => new SalesPackageAmountCountModel { Value = SqlFunc.AggregateSum(t1.SalesNum), Name = t4.DicValue }) .ToListAsync(); return(ResponseUtil <List <SalesPackageAmountCountModel> > .SuccessResult(result)); } catch (Exception ex) { return(ResponseUtil <List <SalesPackageAmountCountModel> > .FailResult(null, $"款型分布发生异常{System.Environment.NewLine}{ex.Message}")); } }
/// <summary> /// 获取T_TenantPermissions数据 /// </summary> /// <param name="requestObject">返回响应结果对象,包括响应代码,查询操作结果</param> /// <returns></returns> public async Task <ResponseObject <TTenantPermissionsModel, List <TTenantPermissionsModel> > > GetAsync(RequestObject <TTenantPermissionsModel> requestObject) { try { List <TTenantPermissionsModel> queryData = null; //查询结果集对象 RefAsync <int> totalNumber = -1; //总记录数 var query = _db.Instance.Queryable <TTenantPermissionsModel, TTenantsModel, TPMMenusDbModel, TUsersModel, TSMCompanyDbModel>( (t, t0, t2, t3, t4) => new object[] { JoinType.Left, t.TenantId == t0.ID, JoinType.Left, t.MenuId == t2.Id, JoinType.Left, t.CreateId == t3.Id, JoinType.Left, t0.ID == t4.CompanyInfoId }); //查询条件 if (requestObject.QueryConditions != null && requestObject.QueryConditions.Count > 0) { var expressionList = SqlSugarUtil.GetQueryExpressions(requestObject.QueryConditions); expressionList.ForEach(p => query.Where($"t.{p}")); } //排序条件 if (requestObject.OrderByConditions != null && requestObject.OrderByConditions.Count > 0) { requestObject.OrderByConditions.ForEach(p => query.OrderBy($"{p.Column} {p.Condition}")); } //设置多表查询返回实体类 query.Select((t, t0, t2, t3, t4) => new TTenantPermissionsModel { Id = t.Id, TenantId = t.TenantId, TTenantsTenantName = t4.CompanyName, MenuId = t.MenuId, TMenusMenuName = t2.MenuName, ButtonIds = t.ButtonIds, CreateTime = t.CreateTime, CreateId = t.CreateId, TUsersUserName = t3.UserName, MenuParentId = t2.ParentID }); //执行查询 if (requestObject.IsPaging) { queryData = await query.ToPageListAsync(requestObject.PageIndex, requestObject.PageSize, totalNumber); } else { queryData = await query.ToListAsync(); } //返回执行结果 return(ResponseUtil <TTenantPermissionsModel, List <TTenantPermissionsModel> > .SuccessResult(requestObject, queryData, totalNumber)); } catch (Exception ex) { //返回查询异常结果 return(ResponseUtil <TTenantPermissionsModel, List <TTenantPermissionsModel> > .FailResult(requestObject, null, ex.Message)); } }
/// <summary> /// 获取所有已有订单的客户信息 /// </summary> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <List <SalesCustomerModel> > > GetCustomers(CurrentUser currentUser) { try { var result = await _db.Instance.Queryable <TSSMSalesOrderMainDbModel, TBMCustomerFileDbModel>( (t, t0) => new object[] { JoinType.Left, t.CustomerId == t0.ID }) .Where((t, t0) => t.CompanyId == currentUser.CompanyID) .GroupBy((t, t0) => new { t0.ID, t0.CustomerName }) .Select((t, t0) => new SalesCustomerModel { ID = t0.ID, CustomerName = t0.CustomerName }) .ToListAsync(); return(ResponseUtil <List <SalesCustomerModel> > .SuccessResult(result)); } catch (Exception ex) { return(ResponseUtil <List <SalesCustomerModel> > .FailResult(null, $"获取客户信息发生异常{System.Environment.NewLine}{ex.Message}")); } }
/// <summary> /// 获取T_WM_InventoryDetail数据 /// </summary> /// <param name="requestObject">Get请求参数</param> /// <returns>返回响应结果对象,包括响应代码,查询操作结果</returns> public async Task <ResponseObject <List <TWMInventoryDetailQueryModel> > > GetDetailListAsync(int requestObject) { try { //查询结果集对象 List <TWMInventoryDetailQueryModel> queryData = null; //总记录数 RefAsync <int> totalNumber = -1; var query = _db.Instance.Queryable <TWMInventoryDetailDbModel, TBMMaterialFileDbModel, TBMDictionaryDbModel, TBMDictionaryDbModel, TBMDictionaryDbModel, TBMDictionaryDbModel, TBMWarehouseFileDbModel>( (t, t0, t1, t2, t3, t4, t5) => new object[] { JoinType.Left, t.MaterialId == t0.ID, JoinType.Left, t0.MaterialTypeId == t1.ID, JoinType.Left, t0.ColorId == t2.ID, JoinType.Left, t0.BaseUnitId == t3.ID, JoinType.Left, t0.WarehouseUnitId == t4.ID, JoinType.Left, t.WarehouseId == t5.ID } ); //执行查询 queryData = await query.Select( (t, t0, t1, t2, t3, t4, t5) => new TWMInventoryDetailQueryModel { ID = t.ID, MainId = t.MainId, MaterialId = t.MaterialId, MaterialCode = t0.MaterialCode, MaterialName = t0.MaterialName, MaterialTypeId = t0.MaterialTypeId, MaterialTypeName = t1.DicValue, ColorId = t0.ColorId, ColorName = t2.DicValue, Spec = t0.Spec, BaseUnitId = t0.BaseUnitId, BaseUnitName = t3.DicValue, WarehouseUnitId = t0.WarehouseUnitId, WarehouseUnitName = SqlFunc.IsNullOrEmpty(t4.ID) ? t3.DicValue : t4.DicValue, WarehouseRate = t0.WarehouseRate, WarehouseId = t.WarehouseId, WarehouseName = t5.WarehouseName, AccountNum = t.AccountNum, ActualNum = t.ActualNum, ProfitNum = t.ProfitNum, DeficitNum = t.DeficitNum, Remark = t.Remark, }) .Where(t => t.MainId == requestObject) .ToListAsync(); //返回执行结果 return(ResponseUtil <List <TWMInventoryDetailQueryModel> > .SuccessResult(queryData, queryData.Count())); } catch (Exception ex) { //返回查询异常结果 return(ResponseUtil <List <TWMInventoryDetailQueryModel> > .FailResult(null, ex.Message)); } }
/// <summary> /// 修改T_PM_SeedUsers数据 /// </summary> /// <param name="requestObject">返回响应结果对象,包括响应代码,修改操作结果</param> /// <returns></returns> public async Task <ResponseObject <bool> > PutAsync(RequestPut <TPMSeedUsersEditModel> requestObject) { try { //执行结果 var result = false; //没有修改信息,返回错误信息 if (requestObject.PostDataList == null && requestObject.PostData == null) { return(ResponseUtil <bool> .FailResult(false, "PostData,PostDataList不能都为null")); } //批量更新优先级高于单记录更新 if (requestObject.PostDataList != null && requestObject.PostDataList.Count > 0) { //批量更新 var editList = _mapper.Map <List <TPMSeedUsersEditModel>, List <TPMSeedUsersDbModel> >(requestObject.PostDataList); result = await _db.Instance.Updateable(editList).ExecuteCommandAsync() > 0; } else { //单记录更新 var editModel = _mapper.Map <TPMSeedUsersDbModel>(requestObject.PostData); result = await _db.Instance.Updateable(editModel).ExecuteCommandAsync() > 0; } //返回执行结果 return(result ? ResponseUtil <bool> .SuccessResult(true) : ResponseUtil <bool> .FailResult(false, "修改数据失败!")); } catch (Exception ex) { //返回异常结果 return(ResponseUtil <bool> .FailResult(false, ex.Message)); } }
/// <summary> /// 盘点单审核 /// </summary> /// <param name="request"></param> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <bool> > InventoryAuditAsync(RequestPut <TWMInventoryAuditModel> request, CurrentUser currentUser) { try { var flag = await _db.Instance.Updateable <TWMInventoryMainDbModel>() .SetColumns(p => new TWMInventoryMainDbModel { AuditId = currentUser.UserID, AuditStatus = request.PostData.AuditStatus, AuditTime = DateTime.Now }) .Where(p => p.ID == request.PostData.ID && (SqlFunc.IsNullOrEmpty(p.AuditStatus) || p.AuditStatus != 2)) .ExecuteCommandAsync() > 0; //盘点单审核通过后,生成盘盈入库单或盘亏入库单 if (flag && request.PostData.AuditStatus == 2) { CreateProfitOrDeficitOrder(request.PostData.ID, currentUser); } return(flag ? ResponseUtil <bool> .SuccessResult(true) : ResponseUtil <bool> .FailResult(false, "审核数据失败,该数据可能已审核")); } catch (Exception ex) { return(ResponseUtil <bool> .FailResult(false, $"审核数据发生异常{Environment.NewLine}{ex.Message}")); } }
/// <summary> /// 审核 /// </summary> /// <param name="requestObject"></param> /// <param name="currentUser"></param> /// <returns></returns> public async Task <ResponseObject <bool> > AuditAsync(RequestPut <AuditModel> requestObject, CurrentUser currentUser) { try { _db.Instance.BeginTran(); //更新审核状态 var result = await _db.Instance.Updateable <TMMPickApplyMainDbModel>() .SetColumns(p => new TMMPickApplyMainDbModel { AuditStatus = requestObject.PostData.AuditStatus, AuditId = currentUser.UserID, AuditTime = DateTime.Now }) .Where(p => p.ID == requestObject.PostData.ID && (p.AuditStatus == 0 || p.AuditStatus == 1)) .ExecuteCommandAsync() > 0; if (result) { var m = _db.Instance.Updateable <TMMPickApplyDetailDbModel>().SetColumns(p => new TMMPickApplyDetailDbModel() { TransNum = p.ApplyNum }).Where(p => p.MainId == requestObject.PostData.ID); m.ExecuteCommand(); } _db.Instance.CommitTran(); return(result ? ResponseUtil <bool> .SuccessResult(true) : ResponseUtil <bool> .FailResult(false, "审核数据失败,该数据可能已审核!")); } catch (Exception ex) { _db.Instance.RollbackTran(); return(ResponseUtil <bool> .FailResult(false, $"审核数据发生异常{Environment.NewLine} {ex.Message}")); } }
/// <summary> /// 删除配色项目,单个节点 /// </summary> /// <param name="requestDelete"></param> /// <returns></returns> public async Task <ResponseObject <bool> > DeleteAsync(RequestDelete <DeleteModel> requestDelete) { try { //如果没有新增数据,返回错误信息 if (requestDelete.PostData == null) { return(ResponseUtil <bool> .FailResult(false, "PostData至少包含一条数据")); } #region 先注释 ////删除包型的配色项目 则删除 //var thisModel = _db.Instance.Queryable<TMMColorItemDbModel>().Where(p => p.ID == requestDelete.PostData.ID).First(); //if (thisModel != null) //{ // //含有这个包型 和 配色项目的BOM // List<int> ColorSolutionIds = _db.Instance.Queryable<TMMBOMMainDbModel, TMMBOMDetailDbModel>((t, t1) => new object[] { JoinType.Inner, t.ID == t1.MainId }) // .Where((t, t1) => t.PackageId == thisModel.PackageId && t1.ItemId == thisModel.ItemId).Select((t, t1) => t.ID).Distinct().ToList(); // if (ColorSolutionIds.Count() > 0) // { // bool isExis = _db.Instance.Queryable<TMMProductionOrderDetailDbModel, TMMProductionOrderMainDbModel>((t, t1) => new object[] { // JoinType.Inner,t.MainId==t1.ID}).Any((t, t1) => t1.DeleteFlag == false && // SqlFunc.IsNull(t1.MRPStatus, false) == false && // ColorSolutionIds.Contains(t.ColorSolutionId.Value) // ); // 是否存在没有算料的生成单 // if (isExis) // { // throw new Exception("存在使用此配色项目的生产单,还没有进行算料,请将生产单算料,或者删除生产"); // } // } // //删除此包型所有的配色项目 // var deleteColorSolution= _db.Instance.Deleteable<TMMColorSolutionDetailDbModel>().Where(p => p.ItemId == thisModel.ItemId && // SqlFunc.Subqueryable<TMMColorSolutionMainDbModel>().Where(p1 => p1.ID == p.MainId && p1.PackageId == thisModel.PackageId).Any()); // //删除BOM // _db.Instance.Deleteable<TMMBOMDetailDbModel>().Where(p => p.ItemId == thisModel.ItemId && SqlFunc.Subqueryable<TMMBOMMainDbModel>(). // Where(p1 => p1.ID == p.MainId && p1.PackageId == thisModel.PackageId).Any()); //} #endregion var result = await _db.Instance.Deleteable <TMMColorItemDbModel>() .Where(p => p.ID == requestDelete.PostData.ID) .ExecuteCommandAsync() > 0; //返回执行结果 return(result ? ResponseUtil <bool> .SuccessResult(true) : ResponseUtil <bool> .FailResult(false, "删除数据失败!")); } catch (Exception ex) { //返回异常结果 return(ResponseUtil <bool> .FailResult(false, ex.Message)); } }