@@ -28,7 +28,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
/// <returns></returns> | |||
public async Task<PageUtil> GetBatchingList(BatchingListQuery dto) | |||
{ | |||
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; | |||
#region 查询条件 | |||
List<IConditionalModel> conModels = new List<IConditionalModel>(); | |||
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 }); | |||
} | |||
if (!string.IsNullOrEmpty(groupId)) | |||
{ | |||
conModels.Add(new ConditionalModel() { FieldName = "a.GroupId", ConditionalType = ConditionalType.Equal, FieldValue = groupId }); | |||
} | |||
if (dto.Price != null) | |||
{ | |||
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; | |||
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)) | |||
.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) | |||
.WhereIF(dto.CreateAt.HasValue, a => SqlFunc.DateIsSame(a.CreateAt, Convert.ToDateTime(dto.CreateAt), DateType.Day)) | |||
.OrderBy((a, b, c) => a.CreateAt, OrderByType.Desc) | |||
@@ -259,7 +254,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
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) | |||
{ | |||
@@ -302,8 +297,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
} | |||
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) | |||
{ | |||
throw Oops.Oh("物料类型已存在"); | |||
@@ -348,8 +342,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
} | |||
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) | |||
{ | |||
throw Oops.Oh("物料单位已存在"); | |||
@@ -382,12 +375,5 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
} | |||
} | |||
#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> | |||
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) | |||
{ | |||
throw Oops.Oh("商品单位已存在"); | |||
@@ -282,7 +281,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
_db.Ado.BeginTran(); | |||
try | |||
{ | |||
string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; | |||
var sortMax = _db.Queryable<BPA_Bom>().Max(x => x.Sort); | |||
BPA_Bom newbPA_BOM = new BPA_Bom | |||
{ | |||
@@ -293,7 +291,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
Id = Guid.NewGuid().ToString(), | |||
CreateAt = DateTime.Now, | |||
Status = CommonStatus.ENABLE, | |||
GroupId = groupId | |||
}; | |||
//添加配方 | |||
var res = _db.Insertable(newbPA_BOM).CallEntityMethod(m => m.Create()).ExecuteCommand(); | |||
@@ -14,6 +14,7 @@ using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Security.Cryptography; | |||
using System.Text; | |||
using System.Text.RegularExpressions; | |||
using System.Threading.Tasks; | |||
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 }); | |||
} | |||
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) | |||
.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); | |||
@@ -129,9 +130,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
public async Task<dynamic> GetGoodsTypeTree() | |||
{ | |||
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)) | |||
.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 | |||
{ | |||
key = u.Id, | |||
@@ -1,5 +1,6 @@ | |||
using BPA.SAAS.Manage.Application.Org.Dtos.Organize; | |||
using BPA.SAAS.Manage.Application.Org.Interface; | |||
using BPA.SAAS.Manage.Comm.Const; | |||
using BPA.SAAS.Manage.Comm.Enum; | |||
using BPA.SAAS.Manage.Comm.Util; | |||
using BPA.SAAS.Manage.Core.Base; | |||
@@ -134,9 +135,9 @@ namespace BPA.SAAS.Manage.Application.Org.Services | |||
public async Task<dynamic> GetOrgTree() | |||
{ | |||
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)) | |||
.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 | |||
{ | |||
key = u.Id, | |||
@@ -8,7 +8,7 @@ using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Core.DataBase | |||
{ | |||
[SugarTable("BPA_batchinguint")] | |||
[SugarTable("bpa_batchinguint")] | |||
public class BPA_BatchingUint : IBaseEntity, IGroupId | |||
{ | |||
/// <summary> | |||
@@ -35,6 +35,14 @@ namespace BPA.SAAS.Manage.Core | |||
SqlSugarScope sqlSugar = new SqlSugarScope(configConnection, | |||
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) => | |||
{ | |||
//新增添加加盟商id赋值 | |||
@@ -52,14 +60,14 @@ namespace BPA.SAAS.Manage.Core | |||
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}】,参数:【{string.Join(",", pars.Select(t => t.Value))}】"); | |||