@@ -28,7 +28,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<PageUtil> GetBatchingList(BatchingListQuery dto) | public async Task<PageUtil> GetBatchingList(BatchingListQuery dto) | ||||
{ | { | ||||
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; | |||||
#region 查询条件 | #region 查询条件 | ||||
List<IConditionalModel> conModels = new List<IConditionalModel>(); | List<IConditionalModel> conModels = new List<IConditionalModel>(); | ||||
if (!string.IsNullOrEmpty(dto.Name))//物料名称 | if (!string.IsNullOrEmpty(dto.Name))//物料名称 | ||||
@@ -59,10 +58,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
{ | { | ||||
conModels.Add(new ConditionalModel() { FieldName = "a.Status", ConditionalType = ConditionalType.Equal, FieldValue = dto.Status }); | conModels.Add(new ConditionalModel() { FieldName = "a.Status", ConditionalType = ConditionalType.Equal, FieldValue = dto.Status }); | ||||
} | } | ||||
if (!string.IsNullOrEmpty(groupId)) | |||||
{ | |||||
conModels.Add(new ConditionalModel() { FieldName = "a.GroupId", ConditionalType = ConditionalType.Equal, FieldValue = groupId }); | |||||
} | |||||
if (dto.Price != null) | if (dto.Price != null) | ||||
{ | { | ||||
conModels.Add(new ConditionalModel() { FieldName = "a.Price", ConditionalType = ConditionalType.Equal, FieldValue = dto.Price.ToString() }); | conModels.Add(new ConditionalModel() { FieldName = "a.Price", ConditionalType = ConditionalType.Equal, FieldValue = dto.Price.ToString() }); | ||||
@@ -75,7 +70,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
RefAsync<int> total = 0; | RefAsync<int> total = 0; | ||||
var res =await _db.Queryable<BPA_Batching, BPA_BatchingType, BPA_BatchingUint>((a, b, c) => | var res =await _db.Queryable<BPA_Batching, BPA_BatchingType, BPA_BatchingUint>((a, b, c) => | ||||
new JoinQueryInfos(JoinType.Inner, a.TypeID == b.Id, JoinType.Inner, a.StockUint == c.Id)) | new JoinQueryInfos(JoinType.Inner, a.TypeID == b.Id, JoinType.Inner, a.StockUint == c.Id)) | ||||
.Where((a, b, c) => a.IsDeleted == 0 && b.IsDeleted == 0 && c.IsDeleted == 0) | |||||
//.Where((a, b, c) => a.IsDeleted == 0 && b.IsDeleted == 0 && c.IsDeleted == 0) | |||||
.Where(conModels) | .Where(conModels) | ||||
.WhereIF(dto.CreateAt.HasValue, a => SqlFunc.DateIsSame(a.CreateAt, Convert.ToDateTime(dto.CreateAt), DateType.Day)) | .WhereIF(dto.CreateAt.HasValue, a => SqlFunc.DateIsSame(a.CreateAt, Convert.ToDateTime(dto.CreateAt), DateType.Day)) | ||||
.OrderBy((a, b, c) => a.CreateAt, OrderByType.Desc) | .OrderBy((a, b, c) => a.CreateAt, OrderByType.Desc) | ||||
@@ -259,7 +254,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
try | try | ||||
{ | { | ||||
// 查询数据库中是否存在未删除的活动信息 | // 查询数据库中是否存在未删除的活动信息 | ||||
var resEntitites = _db.Queryable<BPA_Batching>().Where(x => x.IsDeleted == 0 && x.Id == dto.Id).First(); | |||||
var resEntitites = _db.Queryable<BPA_Batching>().Where(x => x.Id == dto.Id).First(); | |||||
if (resEntitites != null) | if (resEntitites != null) | ||||
{ | { | ||||
@@ -302,8 +297,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
} | } | ||||
public async Task<bool> AddBatchingType(BatchingTypeDto dto) | public async Task<bool> AddBatchingType(BatchingTypeDto dto) | ||||
{ | { | ||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
var productCode = _db.Queryable<BPA_BatchingType>().Where(x => x.IsDeleted == 0 && x.GroupId == groupId && x.Name== dto.Name).ToList(); | |||||
var productCode = _db.Queryable<BPA_BatchingType>().Where(x => x.Name== dto.Name).ToList(); | |||||
if (productCode.Count() > 0) | if (productCode.Count() > 0) | ||||
{ | { | ||||
throw Oops.Oh("物料类型已存在"); | throw Oops.Oh("物料类型已存在"); | ||||
@@ -348,8 +342,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
} | } | ||||
public async Task<bool> AddBatchingUint(BatchingUintDto dto) | public async Task<bool> AddBatchingUint(BatchingUintDto dto) | ||||
{ | { | ||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
var productCode = _db.Queryable<BPA_BatchingUint>().Where(x => x.IsDeleted == 0 && x.GroupId == groupId && x.Name == dto.Name).ToList(); | |||||
var productCode = _db.Queryable<BPA_BatchingUint>().Where(x => x.Name == dto.Name).ToList(); | |||||
if (productCode.Count() > 0) | if (productCode.Count() > 0) | ||||
{ | { | ||||
throw Oops.Oh("物料单位已存在"); | throw Oops.Oh("物料单位已存在"); | ||||
@@ -382,12 +375,5 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
} | } | ||||
} | } | ||||
#endregion | #endregion | ||||
private string GetNumber2(int Length = 10) | |||||
{ | |||||
byte[] buffer = Guid.NewGuid().ToByteArray(); | |||||
var ram = BitConverter.ToInt64(buffer, 0); | |||||
var str = string.Format("{0}", ram.ToString().Substring(0, Length)); | |||||
return str; | |||||
} | |||||
} | } | ||||
} | } |
@@ -214,8 +214,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<bool> AddGoodsUint(GoodsUintDto dto) | public async Task<bool> AddGoodsUint(GoodsUintDto dto) | ||||
{ | { | ||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
var productCode = _db.Queryable<BPA_GoodsUint>().Where(x => x.GroupId == groupId && x.Name == dto.Name).ToList(); | |||||
var productCode = _db.Queryable<BPA_GoodsUint>().Where(x =>x.Name == dto.Name).ToList(); | |||||
if (productCode.Count() > 0) | if (productCode.Count() > 0) | ||||
{ | { | ||||
throw Oops.Oh("商品单位已存在"); | throw Oops.Oh("商品单位已存在"); | ||||
@@ -282,7 +281,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
_db.Ado.BeginTran(); | _db.Ado.BeginTran(); | ||||
try | try | ||||
{ | { | ||||
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; | |||||
var sortMax = _db.Queryable<BPA_Bom>().Max(x => x.Sort); | var sortMax = _db.Queryable<BPA_Bom>().Max(x => x.Sort); | ||||
BPA_Bom newbPA_BOM = new BPA_Bom | BPA_Bom newbPA_BOM = new BPA_Bom | ||||
{ | { | ||||
@@ -293,7 +291,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
Id = Guid.NewGuid().ToString(), | Id = Guid.NewGuid().ToString(), | ||||
CreateAt = DateTime.Now, | CreateAt = DateTime.Now, | ||||
Status = CommonStatus.ENABLE, | Status = CommonStatus.ENABLE, | ||||
GroupId = groupId | |||||
}; | }; | ||||
//添加配方 | //添加配方 | ||||
var res = _db.Insertable(newbPA_BOM).CallEntityMethod(m => m.Create()).ExecuteCommand(); | var res = _db.Insertable(newbPA_BOM).CallEntityMethod(m => m.Create()).ExecuteCommand(); | ||||
@@ -14,6 +14,7 @@ using System.Collections.Generic; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Security.Cryptography; | using System.Security.Cryptography; | ||||
using System.Text; | using System.Text; | ||||
using System.Text.RegularExpressions; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
namespace BPA.SAAS.Manage.Application.DataBase.Services | namespace BPA.SAAS.Manage.Application.DataBase.Services | ||||
@@ -42,9 +43,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
{ | { | ||||
conModels.Add(new ConditionalModel() { FieldName = "Status", ConditionalType = ConditionalType.Equal, FieldValue = dto.Status }); | conModels.Add(new ConditionalModel() { FieldName = "Status", ConditionalType = ConditionalType.Equal, FieldValue = dto.Status }); | ||||
} | } | ||||
int total = new RefAsync<int>(); | int total = new RefAsync<int>(); | ||||
var res =await _db.Queryable<BPA_GoodsType>().Where(it => it.IsDeleted == 0) | |||||
var res =await _db.Queryable<BPA_GoodsType>().Where(it => it.IsDeleted == 0 && it.GroupId== groupId) | |||||
.Where(conModels) | .Where(conModels) | ||||
.OrderBy(a => a.CreateAt, OrderByType.Desc) | .OrderBy(a => a.CreateAt, OrderByType.Desc) | ||||
.Select(it => new GoodsTypeTree() { Id = it.Id, Name = it.Name, Pid = it.Pid,Sort=it.Sort,Remark=it.Remark,Status=it.Status }).ToTreeAsync(it => it.Children, it => it.Pid, 0); | .Select(it => new GoodsTypeTree() { Id = it.Id, Name = it.Name, Pid = it.Pid,Sort=it.Sort,Remark=it.Remark,Status=it.Status }).ToTreeAsync(it => it.Children, it => it.Pid, 0); | ||||
@@ -129,9 +130,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
public async Task<dynamic> GetGoodsTypeTree() | public async Task<dynamic> GetGoodsTypeTree() | ||||
{ | { | ||||
var dataScopeList = new List<string>(); | var dataScopeList = new List<string>(); | ||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
var orgs = await _db.Queryable<BPA_GoodsType>().WhereIF(dataScopeList.Count > 0, u => dataScopeList.Contains(u.Id)) | var orgs = await _db.Queryable<BPA_GoodsType>().WhereIF(dataScopeList.Count > 0, u => dataScopeList.Contains(u.Id)) | ||||
.Where(u => u.Status == CommonStatus.ENABLE && u.IsDeleted==0).OrderBy(u => u.Sort) | |||||
.Where(u => u.Status == CommonStatus.ENABLE && u.IsDeleted==0 && u.GroupId == groupId).OrderBy(u => u.Sort) | |||||
.Select(u => new OrgTreeNode | .Select(u => new OrgTreeNode | ||||
{ | { | ||||
key = u.Id, | key = u.Id, | ||||
@@ -1,5 +1,6 @@ | |||||
using BPA.SAAS.Manage.Application.Org.Dtos.Organize; | using BPA.SAAS.Manage.Application.Org.Dtos.Organize; | ||||
using BPA.SAAS.Manage.Application.Org.Interface; | using BPA.SAAS.Manage.Application.Org.Interface; | ||||
using BPA.SAAS.Manage.Comm.Const; | |||||
using BPA.SAAS.Manage.Comm.Enum; | using BPA.SAAS.Manage.Comm.Enum; | ||||
using BPA.SAAS.Manage.Comm.Util; | using BPA.SAAS.Manage.Comm.Util; | ||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
@@ -134,9 +135,9 @@ namespace BPA.SAAS.Manage.Application.Org.Services | |||||
public async Task<dynamic> GetOrgTree() | public async Task<dynamic> GetOrgTree() | ||||
{ | { | ||||
var dataScopeList = new List<string>(); | var dataScopeList = new List<string>(); | ||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
var orgs = await _db.Queryable<BPA_Organize>().WhereIF(dataScopeList.Count > 0, u => dataScopeList.Contains(u.Id)) | var orgs = await _db.Queryable<BPA_Organize>().WhereIF(dataScopeList.Count > 0, u => dataScopeList.Contains(u.Id)) | ||||
.Where(u => u.Status == CommonStatus.ENABLE).OrderBy(u => u.Sort) | |||||
.Where(u => u.Status == CommonStatus.ENABLE && u.GroupId== groupId).OrderBy(u => u.Sort) | |||||
.Select(u => new OrgTreeNode | .Select(u => new OrgTreeNode | ||||
{ | { | ||||
key = u.Id, | key = u.Id, | ||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Core.DataBase | namespace BPA.SAAS.Manage.Core.DataBase | ||||
{ | { | ||||
[SugarTable("BPA_batchinguint")] | |||||
[SugarTable("bpa_batchinguint")] | |||||
public class BPA_BatchingUint : IBaseEntity, IGroupId | public class BPA_BatchingUint : IBaseEntity, IGroupId | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
@@ -35,6 +35,14 @@ namespace BPA.SAAS.Manage.Core | |||||
SqlSugarScope sqlSugar = new SqlSugarScope(configConnection, | SqlSugarScope sqlSugar = new SqlSugarScope(configConnection, | ||||
db => | db => | ||||
{ | { | ||||
db.QueryFilter.AddTableFilter<IDeleted>(it => it.IsDeleted == 0); | |||||
//db.QueryFilter.AddTableFilter<IStatus>(it => it.Status == 0); | |||||
if (!IsSuperAdmin()) | |||||
{ | |||||
//非管理员账户过滤加盟商数据 | |||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
db.QueryFilter.AddTableFilter<IGroupId>(it => it.GroupId == groupId); | |||||
} | |||||
db.Aop.DataExecuting = (oldValue, entityInfo) => | db.Aop.DataExecuting = (oldValue, entityInfo) => | ||||
{ | { | ||||
//新增添加加盟商id赋值 | //新增添加加盟商id赋值 | ||||
@@ -52,14 +60,14 @@ namespace BPA.SAAS.Manage.Core | |||||
db.Aop.OnLogExecuting = (sql, pars) => | db.Aop.OnLogExecuting = (sql, pars) => | ||||
{ | { | ||||
//过滤已删除数据 | //过滤已删除数据 | ||||
db.QueryFilter.AddTableFilter<IDeleted>(it => it.IsDeleted == 0); | |||||
//db.QueryFilter.AddTableFilter<IStatus>(it => it.Status == 0); | |||||
if (!IsSuperAdmin()) | |||||
{ | |||||
//非管理员账户过滤加盟商数据 | |||||
var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
db.QueryFilter.AddTableFilter<IGroupId>(it => it.GroupId == groupId); | |||||
} | |||||
//db.QueryFilter.AddTableFilter<IDeleted>(it => it.IsDeleted == 0); | |||||
////db.QueryFilter.AddTableFilter<IStatus>(it => it.Status == 0); | |||||
//if (!IsSuperAdmin()) | |||||
//{ | |||||
// //非管理员账户过滤加盟商数据 | |||||
// var groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value; | |||||
// db.QueryFilter.AddTableFilter<IGroupId>(it => it.GroupId == groupId); | |||||
//} | |||||
//Console.WriteLine(sql);//输出sql | //Console.WriteLine(sql);//输出sql | ||||
Console.WriteLine($"当前SQL语句:【{sql}】,参数:【{string.Join(",", pars.Select(t => t.Value))}】"); | Console.WriteLine($"当前SQL语句:【{sql}】,参数:【{string.Join(",", pars.Select(t => t.Value))}】"); | ||||