From 01ee01d139a8ea9369fda84baee41d5ee9e7e437 Mon Sep 17 00:00:00 2001
From: zhangxiaofeng <1939543722@qq.com>
Date: Fri, 13 Sep 2024 11:06:42 +0800
Subject: [PATCH 01/12] =?UTF-8?q?AspNetUser=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DS.Module.Core/Extensions/Extensions.cs | 17 +
.../DS.Module.SqlSugar/SqlsugarHelper.cs | 2 +-
.../DS.Module.SqlSugar/SqlsugarInstall.cs | 4 +-
.../DS.Module.UserModule/AspNetUser.cs | 447 ++----------------
ds-wms-service/DS.Module.UserModule/IUser.cs | 35 +-
.../Code/Method/CodeFormCopyService.cs | 2 +-
.../Code/Method/CodeFormSetService.cs | 2 +-
.../Code/Method/CodeQuerySetService.cs | 2 +-
.../DS.WMS.Core/Sys/Method/CommonService.cs | 14 +-
.../TaskPlat/Method/TaskManageService.cs | 12 +
10 files changed, 92 insertions(+), 445 deletions(-)
diff --git a/ds-wms-service/DS.Module.Core/Extensions/Extensions.cs b/ds-wms-service/DS.Module.Core/Extensions/Extensions.cs
index 21a43ec7..894c5286 100644
--- a/ds-wms-service/DS.Module.Core/Extensions/Extensions.cs
+++ b/ds-wms-service/DS.Module.Core/Extensions/Extensions.cs
@@ -158,6 +158,23 @@ public static partial class Extensions
return reval;
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static long ObjToLong(this object thisValue)
+ {
+ long reval = 0;
+ if (thisValue == null) return 0;
+ if (thisValue != DBNull.Value && long.TryParse(thisValue.ToString(), out reval))
+ {
+ return reval;
+ }
+
+ return reval;
+ }
+
///
///
///
diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs
index c3a1be1e..a684bb0c 100644
--- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs
@@ -56,7 +56,7 @@ namespace DS.Module.SqlSugar
{
var orgId = ((dynamic)entityInfo.EntityValue).OrgId;
if (orgId == null || orgId == 0)
- entityInfo.SetValue(user.GetOrgId());
+ entityInfo.SetValue(user.OrgId);
}
if (entityInfo.PropertyName == "CreateBy")
diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
index 34265a63..49aa37b0 100644
--- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
@@ -189,7 +189,7 @@ public static class SqlsugarInstall
{
var orgId = ((dynamic)entityInfo.EntityValue).OrgId;
if (orgId == null || orgId == 0)
- entityInfo.SetValue(user.GetOrgId());
+ entityInfo.SetValue(user.OrgId);
}
if (entityInfo.PropertyName == "CreateBy")
@@ -273,7 +273,7 @@ public static class SqlsugarInstall
};
//全局过滤租户
- dbProvider.QueryFilter.AddTableFilter(m => m.TenantId == user.GetTenantId());
+ dbProvider.QueryFilter.AddTableFilter(m => m.TenantId == long.Parse(user.TenantId));
//全局过滤机构Id
dbProvider.QueryFilter.AddTableFilter(m => m.OrgId == user.OrgId);
//全局软删除过滤
diff --git a/ds-wms-service/DS.Module.UserModule/AspNetUser.cs b/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
index 52d73534..6576a630 100644
--- a/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
+++ b/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
@@ -1,7 +1,5 @@
-using DS.Module.Core;
-using DS.Module.Core.Extensions;
+using DS.Module.Core.Extensions;
using Microsoft.AspNetCore.Http;
-using Newtonsoft.Json;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
@@ -16,439 +14,76 @@ public class AspNetUser : IUser
_accessor = accessor;
}
- public UserInfo UserInfo => GetUserInfo();
+ public string UserId => GetClaimValueByType("jti").FirstOrDefault() ?? "90001";
+ public string UserName => GetClaimValueByType("UserName").FirstOrDefault() ?? "IUser获取UserName意外为空";
+ public string TenantId => GetClaimValueByType("TenantId").FirstOrDefault() ?? "90002";
+ public string TenantName => GetClaimValueByType("TenantName").FirstOrDefault() ?? "IUser获取TenantName意外为空";
+ public long OrgId => GetClaimValueByType("OrgId").FirstOrDefault()?.ObjToLong() ?? 90003;
- //public string GetToken()
- //{
- // return _accessor.HttpContext?.Request?.Headers["Authorization"].ToString().Replace("Bearer ", "");
- //}
- //public string UserId => GetClaimValueByType("jti").FirstOrDefault().ObjToString();
- private string _userId;
- public string UserId
- {
- get
- {
- if (_userId == null)
- {
- var claimValue = GetClaimValueByType("jti").FirstOrDefault();
- _userId = claimValue != null ? claimValue.ObjToString() : GetUserId().ToString();
- }
- return _userId;
- }
- set
- {
- _userId = value;
- }
- }
- private string _userName;
- public string UserName
+ public List GetClaimValueByType(string claimType)
{
- get
- {
- if (_userName == null)
- {
- var claimValue = GetClaimValueByType("UserName").FirstOrDefault();
- _userName = claimValue != null ? claimValue.ObjToString() : "管理员";
- }
- return _userName;
- }
- set
- {
- _userName = value;
- }
+ return Claims.Where(x => x.Type == claimType).Select(x => x.Value).ToList();
}
- private string _tenantName;
- public string TenantName
+
+ private List? _claims;
+ public List Claims
{
get
{
- if (_tenantName == null)
+ if (_claims == null || _claims.Count == 0)
{
- var claimValue = GetClaimValueByType("TenantName").FirstOrDefault();
- _tenantName = claimValue != null ? claimValue.ObjToString() : "系统租户";
+ _claims = GetClaimsIdentity().ToList();
}
- return _tenantName;
- }
- set
- {
- _tenantName = value;
+ return _claims;
}
}
- public long GetTenantId()
- {
- var token = GetToken();
- if (string.IsNullOrEmpty(token))
- {
- return 2;
- }
-
- var jwtHandler = new JwtSecurityTokenHandler();
- if (!jwtHandler.CanReadToken(token))
- {
- return 3;
- }
-
- JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
- var tenantIdClaim = jwtToken.Claims.FirstOrDefault(x => x.Type == "TenantId");
- return tenantIdClaim != null ? Convert.ToInt64(tenantIdClaim.Value) : 4;
- }
-
- //public long GetTenantId()
- //{
- // // return _accessor.HttpContext?.Request?.Headers["Authorization"].ToString().Replace("Bearer ", "");
- // var tenantId = String.Empty;
- // var token = _accessor.HttpContext?.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last()
- // ?? _accessor.HttpContext?.Request.Headers["X-Token"].FirstOrDefault()
- // ?? _accessor.HttpContext?.Request.Query["Token"].FirstOrDefault()
- // ?? _accessor.HttpContext?.Request.Cookies["Token"];
- // // token校验
- // var jwtHandler = new JwtSecurityTokenHandler();
- // if (!token.IsNullOrEmpty() && jwtHandler.CanReadToken(token))
- // {
- // JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
-
- // tenantId = jwtToken.Claims.First(x => x.Type == "TenantId").Value;
- // }
-
- // return Convert.ToInt64(tenantId);
- //}
-
- public long GetOrgId()
+ IEnumerable GetClaimsIdentity()
{
- //if (_orgId == 0)
- //{
- // var claimValue = GetClaimValueByType("OrgId").FirstOrDefault();
- // _orgId = claimValue != null ? long.Parse(claimValue) : 0;
- //}
- //return _orgId;
+ if (_accessor.HttpContext == null) return ArraySegment.Empty;
- var token = GetToken();
- if (string.IsNullOrEmpty(token))
+ if (!IsAuthenticated())
{
- return 5;
- }
+ var token = GetToken();
- var jwtHandler = new JwtSecurityTokenHandler();
- if (!jwtHandler.CanReadToken(token))
- {
- return 6;
- }
-
- JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
- var orgIdClaim = jwtToken.Claims.FirstOrDefault(x => x.Type == "OrgId");
-
- return orgIdClaim != null ? Convert.ToInt64(orgIdClaim.Value) : 7;
- }
-
- public long GetUserId()
- {
- var token = GetToken();
- if (string.IsNullOrEmpty(token))
- {
- return 8;
- }
-
- var jwtHandler = new JwtSecurityTokenHandler();
- if (!jwtHandler.CanReadToken(token))
- {
- return 9;
- }
-
- JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
- var userIdClaim = jwtToken.Claims.FirstOrDefault(x => x.Type == "jti");
-
- return userIdClaim != null ? Convert.ToInt64(userIdClaim.Value) : 10;
- }
-
- //public long GetOrgId()
- //{
- // // return _accessor.HttpContext?.Request?.Headers["Authorization"].ToString().Replace("Bearer ", "");
- // var orgId = String.Empty;
- // var token = _accessor.HttpContext?.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last()
- // ?? _accessor.HttpContext?.Request.Headers["X-Token"].FirstOrDefault()
- // ?? _accessor.HttpContext?.Request.Query["Token"].FirstOrDefault()
- // ?? _accessor.HttpContext?.Request.Cookies["Token"];
- // // token校验
- // var jwtHandler = new JwtSecurityTokenHandler();
- // if (!token.IsNullOrEmpty() && jwtHandler.CanReadToken(token))
- // {
- // JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
-
- // orgId = jwtToken.Claims.First(x => x.Type == "OrgId").Value;
- // }
- // return Convert.ToInt64(orgId);
- //}
-
- //public string GetCompanyId()
- //{
- // // return _accessor.HttpContext?.Request?.Headers["Authorization"].ToString().Replace("Bearer ", "");
- // var companyId = String.Empty;
- // var token = _accessor.HttpContext?.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last()
- // ?? _accessor.HttpContext?.Request.Headers["X-Token"].FirstOrDefault()
- // ?? _accessor.HttpContext?.Request.Query["Token"].FirstOrDefault()
- // ?? _accessor.HttpContext?.Request.Cookies["Token"];
- // // token校验
- // var jwtHandler = new JwtSecurityTokenHandler();
- // if (!token.IsNullOrEmpty() && jwtHandler.CanReadToken(token))
- // {
- // JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
-
- // companyId = jwtToken.Claims.First(x => x.Type == "OrgId").Value;
- // }
- // return companyId;
- //}
-
- public string GetCompanyId()
- {
- var token = GetToken();
- if (string.IsNullOrEmpty(token))
- {
- return string.Empty;
- }
-
- var jwtHandler = new JwtSecurityTokenHandler();
- if (!jwtHandler.CanReadToken(token))
- {
- return string.Empty;
- }
-
- JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
- var companyIdClaim = jwtToken.Claims.FirstOrDefault(x => x.Type == "OrgId");
-
- return companyIdClaim?.Value ?? "0000000001";
- }
-
- //public string TenantId => GetClaimValueByType("TenantId").FirstOrDefault().ObjToString();
- private string _tenantId;
-
- public string TenantId
- {
- get
- {
- if (_tenantId == null)
+ var jwtHandler = new JwtSecurityTokenHandler();
+ if (token.IsNotEmptyOrNull() && jwtHandler.CanReadToken(token))
{
- var tenantIdClaim = GetClaimValueByType("TenantId").FirstOrDefault();
- _tenantId = tenantIdClaim != null ? tenantIdClaim.ObjToString() : GetTenantId().ToString();
+ JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
+ return jwtToken.Claims;
}
- return _tenantId;
- }
- set
- {
- _tenantId = value;
}
- }
- // public string CompanyId => GetClaimValueByType("CompanyId").FirstOrDefault().ObjToString();
- private string _companyId;
+ var claims = _accessor.HttpContext.User.Claims.ToList() ?? [];
- public string CompanyId
- {
- get
- {
- if (_companyId == null)
- {
- var companyIdClaim = GetClaimValueByType("CompanyId").FirstOrDefault();
- _companyId = companyIdClaim != null ? companyIdClaim.ObjToString() : "东胜软件";
- }
- return _companyId;
- }
- set
- {
- _companyId = value;
- }
- }
-
- // public string OrgId => GetClaimValueByType("OrgId").FirstOrDefault().ObjToString();
- private long _orgId;
-
- public long OrgId
- {
- get
- {
- if (_orgId == 0)
- {
- var orgIdClaim = GetClaimValueByType("OrgId").FirstOrDefault();
- _orgId = orgIdClaim != null ? long.Parse(orgIdClaim) : GetOrgId();
- }
- return _orgId;
- }
- set
- {
- _orgId = value;
- }
+ // 如果有从Claims中获取HttpHeader的需求,把这里放开
+ //var headers = _accessor.HttpContext.Request.Headers;
+ //foreach (var header in headers)
+ //{
+ // claims.Add(new Claim(header.Key, header.Value));
+ //}
+ return claims;
}
-
- public UserInfo GetUserInfo()
+ public bool IsAuthenticated()
{
- var user = _accessor.HttpContext?.User;
- if (user == null || !user.Claims.Any())
- {
- return null;
- // return GetDefaultUserInfo();
- }
-
- var token = GetToken();
- if (string.IsNullOrEmpty(token))
- {
- return null;
- // return GetDefaultUserInfo();
- }
-
- var jwtHandler = new JwtSecurityTokenHandler();
- if (!jwtHandler.CanReadToken(token))
- {
- return null;
- // return GetDefaultUserInfo();
- }
-
- JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
- var userInfoJson = jwtToken.Claims.First().Value;
- var userInfo = JsonConvert.DeserializeObject(userInfoJson);
-
- return userInfo ?? null;
+ return _accessor.HttpContext?.User?.Identity?.IsAuthenticated ?? false;
}
-
public string GetToken()
{
- if (_accessor == null || _accessor.HttpContext == null)
- {
- return "东胜软件";
- }
-
- var request = _accessor.HttpContext.Request;
-
- var authorizationHeader = request.Headers["Authorization"].FirstOrDefault();
- if (!string.IsNullOrEmpty(authorizationHeader))
+ var token = _accessor.HttpContext?.Request?.Headers["Authorization"].ObjToString().Replace("Bearer ", "");
+ if (!string.IsNullOrWhiteSpace(token))
{
- return authorizationHeader.Split(" ").Last();
+ return token;
}
+ return "IUser通过GetToken()获取Token意外为空";
- return request.Headers["X-Token"].FirstOrDefault()
- ?? request.Query["Token"].FirstOrDefault()
- ?? request.Cookies["Token"]
- ?? "东胜软件";
+ //有需要再返回
+ //return _accessor.HttpContext?.Request.Headers["X-Token"].FirstOrDefault()
+ // ?? _accessor.HttpContext?.Request.Query["Token"].FirstOrDefault()
+ // ?? _accessor.HttpContext?.Request.Cookies["Token"]
+ // ?? "东胜软件";
}
-
- #region 优化前
-
- //public string GetToken()
- //{
- // var headers = _accessor.HttpContext?.Request?.Headers;
- // if (headers != null && headers.ContainsKey("Authorization"))
- // {
- // return headers["Authorization"].ToString().Replace("Bearer ", "");
- // }
- // return null;
- //}
- //public UserInfo GetUserInfo()
- //{
- // if (_accessor.HttpContext.User.Claims == null)
- // {
- // return new UserInfo()
- // {
- // CompanyId = "1",
- // CompanyName = "初始化",
- // Token = "初始化",
- // UserCode = "初始化",
- // UserId = "00000000",
- // UserName = "初始化",
- // };
- // }
-
- // //var json = _accessor.HttpContext.User.Claims;
- // //获取上传token,可自定义扩展
- // var httphedad = _accessor.HttpContext.Request;
- // var token = httphedad.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last()
- // ?? httphedad.Headers["X-Token"].FirstOrDefault()
- // ?? httphedad.Query["Token"].FirstOrDefault()
- // ?? httphedad.Cookies["Token"];
- // // token校验
- // var jwtHandler = new JwtSecurityTokenHandler();
- // var userInfo = new UserInfo();
- // if (!token.IsNullOrEmpty() && jwtHandler.CanReadToken(token))
- // {
- // JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
- // var UserId = jwtToken.Claims.First().Value;
- // // userInfo = db.Queryable()
- // // .Where(a =>
- // // a.Deleted == false && a.Id == user.Id)
- // // .Select(a => new UserInfo
- // // {
- // // UserId = a.Id, UserCode = a.UserCode, UserName = a.NickName,
- // // // OrgId = a.OrgId.ToString(), CompanyName = a.CustomerName
- // // }).First();
- // // var t1 = JsonConvert.DeserializeObject(temp);
- // userInfo = JsonConvert.DeserializeObject(jwtToken.Claims.First().Value);
- // }
-
- // return userInfo;
- //}
-
- //public IEnumerable GetClaimsIdentity()
- //{
- // var claims = _accessor.HttpContext.User.Claims.ToList();
- // var headers = _accessor.HttpContext.Request.Headers;
- // foreach (var header in headers)
- // {
- // claims.Add(new Claim(header.Key, header.Value));
- // }
- // return claims;
- //}
-
- #endregion 优化前
-
- ///
- /// 保持在请求上下文中的所有声明 不为空
- ///
- ///
- public IEnumerable GetClaimsIdentity()
- {
- var claims = new List();
- var user = _accessor.HttpContext?.User;
- if (user != null)
- {
- claims.AddRange(user.Claims);
- }
-
- var headers = _accessor.HttpContext?.Request?.Headers;
- if (headers != null)
- {
- foreach (var header in headers)
- {
- foreach (var value in header.Value)
- {
- if (!string.IsNullOrEmpty(value))
- {
- claims.Add(new Claim(header.Key, value));
- }
- }
- }
- }
-
- return claims;
- }
-
- #region 键值对获取相应的内容 如果内容不存在则返回默认值 GetClaimValueByType
-
- ///
- /// 键值对获取相应的内容 如果内容不存在则返回默认值
- ///
- ///
- ///
- public List GetClaimValueByType(string ClaimType)
- {
- var claimsIdentity = GetClaimsIdentity();
- // if (claimsIdentity == null || !claimsIdentity.Any(item => item.Type == ClaimType))
- // {
- // return new List { "jti", "TenantId", "CompanyId", "OrgId" }; // 返回包含默认参数的列表
- // }
-
- return claimsIdentity.Where(item => item.Type == ClaimType).Select(item => item.Value).ToList();
- }
-
- #endregion 键值对获取相应的内容 如果内容不存在则返回默认值 GetClaimValueByType
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.Module.UserModule/IUser.cs b/ds-wms-service/DS.Module.UserModule/IUser.cs
index 931cc274..ed231f8b 100644
--- a/ds-wms-service/DS.Module.UserModule/IUser.cs
+++ b/ds-wms-service/DS.Module.UserModule/IUser.cs
@@ -1,5 +1,4 @@
-using DS.Module.Core;
-
+
namespace DS.Module.UserModule;
///
@@ -7,57 +6,41 @@ namespace DS.Module.UserModule;
///
public interface IUser
{
- ///
- /// 获取用户信息
- ///
- UserInfo UserInfo { get; }
-
///
/// 获取用户ID
///
string UserId { get; }
-
///
/// 获取用户名称
///
string UserName { get; }
- ///
- /// 获取公司ID
- ///
- string CompanyId { get; }
///
/// 租户ID
///
string TenantId { get; }
-
///
/// 租户名称
///
string TenantName { get; }
+
///
/// 机构ID
///
long OrgId { get; }
///
- /// 获取机构ID
- ///
- long GetOrgId();
-
- ///
- /// 获取公司ID
+ /// 返回Token
///
- string GetCompanyId();
+ string GetToken();
///
- /// 获取租户ID
+ /// 根据Claim类型返回Claim的值
///
- long GetTenantId();
-
+ List GetClaimValueByType(string claimType);
+
///
- /// 获取Token
+ /// 返回当前用户是否已经过认证
///
- ///
- string GetToken();
+ bool IsAuthenticated();
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormCopyService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormCopyService.cs
index a183b957..a6271c2d 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormCopyService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormCopyService.cs
@@ -64,7 +64,7 @@ public class CodeFormCopyService : IFormCopyService
if (req.Id == 0)
{
if (tenantDb.Queryable()
- .Where(x => x.OrgId == user.GetOrgId() && x.PermissionId == req.PermissionId && x.CreateBy == long.Parse(user.UserId)).Any())
+ .Where(x => x.OrgId == user.OrgId && x.PermissionId == req.PermissionId && x.CreateBy == long.Parse(user.UserId)).Any())
{
return DataResult.Failed("表单复制字段设置已存在!", MultiLanguageConst.FormCopyExist);
}
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormSetService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormSetService.cs
index 87882597..f1df413a 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormSetService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeFormSetService.cs
@@ -65,7 +65,7 @@ public class CodeFormSetService : IFormSetService
if (req.Id == 0)
{
if (tenantDb.Queryable()
- .Where(x => x.OrgId == user.GetOrgId() && x.PermissionId == req.PermissionId && x.FormNo == req.FormNo).Any())
+ .Where(x => x.OrgId == user.OrgId && x.PermissionId == req.PermissionId && x.FormNo == req.FormNo).Any())
{
return DataResult.Failed("表单设置已存在!", MultiLanguageConst.FormSetExist);
}
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeQuerySetService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeQuerySetService.cs
index f22e17f8..eba2ac4e 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeQuerySetService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeQuerySetService.cs
@@ -65,7 +65,7 @@ public class CodeQuerySetService : IQuerySetService
if (req.Id == 0)
{
if (tenantDb.Queryable()
- .Where(x => x.OrgId == user.GetOrgId() && x.PermissionId == req.PermissionId && x.TagNo == req.TagNo).Any())
+ .Where(x => x.OrgId == user.OrgId && x.PermissionId == req.PermissionId && x.TagNo == req.TagNo).Any())
{
return DataResult.Failed("查询条件设置已存在!", MultiLanguageConst.QuerySetExist);
}
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs
index aee297a0..3b0eed1c 100644
--- a/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs
+++ b/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs
@@ -104,7 +104,7 @@ public class CommonService : ICommonService
public DataResult GetUserInfo()
{
var userId = long.Parse(user.UserId);
- var tenantId = user.GetTenantId();
+ var tenantId = long.Parse(user.TenantId);
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = user.UserId,
@@ -292,7 +292,7 @@ public class CommonService : ICommonService
}
var userId = long.Parse(user.UserId);
- var tenantId = user.GetTenantId();
+ var tenantId = long.Parse(user.TenantId);
var tokenModel = new JwtHelper.JwtTokenModel
{
@@ -507,7 +507,7 @@ public class CommonService : ICommonService
public async Task> GetClientUserInfo()
{
var userId = long.Parse(user.UserId);
- var tenantId = user.GetTenantId();
+ var tenantId = long.Parse(user.TenantId);
//取第一个机构
var orgRelations = await db.Queryable().Filter(null, true)
.LeftJoin((a, b) => a.OrgId == b.Id)
@@ -526,7 +526,7 @@ public class CommonService : ICommonService
{
Uid = user.UserId,
Name = userInfo.UserName,
- OrgId = user.GetOrgId().ToString(),
+ OrgId = user.OrgId.ToString(),
TenantId = tenantId.ToString(),
TenantName = tenant.Name
};
@@ -544,7 +544,7 @@ public class CommonService : ICommonService
// ClientId = a.ClientId,
IsUseSystem = a.IsUseSystem,
RefreshToken = refreshToken,
- OrgId = user.GetOrgId().ToString(),
+ OrgId = user.OrgId.ToString(),
Tel = a.Tel,
Email = a.Email,
Phone = a.Phone,
@@ -575,7 +575,7 @@ public class CommonService : ICommonService
public DataResult ChangeOrg(string id)
{
var userId = user.UserId;
- var tenantId = user.GetTenantId();
+ var tenantId = long.Parse(user.TenantId);
var sysUser = db.Queryable().First(x => x.Id == long.Parse(userId));
if (sysUser.IsNull())
{
@@ -614,7 +614,7 @@ public class CommonService : ICommonService
public async Task>> GetClientUserPermissionByToken()
{
List list = new List();
- _logger.LogInformation("GetClientUserPermissionByToken临时日志:user.UserId={userId},user.TenantId={TenantId},user.GetTenantId={GetTenantId}", user.UserId, user.TenantId, user.GetTenantId());
+ _logger.LogInformation("GetClientUserPermissionByToken临时日志:user.UserId={userId},user.TenantId={TenantId}", user.UserId, user.TenantId);
var userId = long.Parse(user.UserId);
diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
index e3917e52..b68d7cc9 100644
--- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
+++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
@@ -3099,7 +3099,19 @@ namespace DS.WMS.Core.TaskPlat.Method
///
public async Task TestTaskFlow(string taskType, long taskId, int testType)
{
+
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
+
+
+ // 人员信息测试用
+ var a1 = user.UserId;
+ var b1 = user.UserName;
+ var c1 = user.TenantId;
+ var d1 = user.TenantName;
+ var e1 = user.OrgId;
+ var sql = tenantDb.Queryable().Where(x => x.Id > 232).ToSqlString();
+
+
var t11 = tenantDb.ContextID;
switch (testType)
{
From 8bc2067ef967b16fffbfc2495881ad5e4cebd5ba Mon Sep 17 00:00:00 2001
From: zhangxiaofeng <1939543722@qq.com>
Date: Fri, 13 Sep 2024 13:31:32 +0800
Subject: [PATCH 02/12] =?UTF-8?q?ApiUserFilter=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DS.Module.Core/Filters/ApiUserFilter.cs | 34 +++++++++++++------
.../DS.Module.UserModule/AspNetUser.cs | 14 ++++----
ds-wms-service/DS.Module.UserModule/IUser.cs | 2 +-
.../TaskPlat/Method/TaskManageService.cs | 16 ++++-----
4 files changed, 40 insertions(+), 26 deletions(-)
diff --git a/ds-wms-service/DS.Module.Core/Filters/ApiUserFilter.cs b/ds-wms-service/DS.Module.Core/Filters/ApiUserFilter.cs
index a664f443..522ee333 100644
--- a/ds-wms-service/DS.Module.Core/Filters/ApiUserFilter.cs
+++ b/ds-wms-service/DS.Module.Core/Filters/ApiUserFilter.cs
@@ -57,17 +57,31 @@ namespace DS.Module.Core.Filters
if (user != null && tenant != null)
{
- ClaimsIdentity identity = new ClaimsIdentity("AuthenticationTypes.Federation");
- identity.AddClaims(new List
+ // 认证方式1:生成Token赋值到httpContext.Headers["Authorization"]
+ var tokenModel = new JwtHelper.JwtTokenModel
{
- new Claim(JwtRegisteredClaimNames.Jti, user.Id.ToString()),
- new Claim("UserName", user.UserName),
- new Claim("TenantId", user.TenantId.ToString()),
- new Claim("TenantName", tenant.Name),
- new Claim("OrgId", user.DefaultOrgId.ToString()),
- });
- ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(identity);
- httpContext.User = claimsPrincipal;
+ Uid = user!.Id.ToString(),
+ Name = user.UserName,
+ OrgId = user.DefaultOrgId.ToString(),
+ TenantId = user.TenantId.ToString(),
+ TenantName = tenant!.Name,
+ };
+ var token = JwtHelper.Encrypt(tokenModel, false, true);
+
+ httpContext!.Request.Headers["Authorization"] = "Bearer " + token;
+
+ // 认证方式2:生成ClaimsIdentity赋值到httpContext.User
+ //ClaimsIdentity identity = new ClaimsIdentity("AuthenticationTypes.Federation");
+ //identity.AddClaims(new List
+ //{
+ // new Claim(JwtRegisteredClaimNames.Jti, user.Id.ToString()),
+ // new Claim("UserName", user.UserName),
+ // new Claim("TenantId", user.TenantId.ToString()),
+ // new Claim("TenantName", tenant.Name),
+ // new Claim("OrgId", user.DefaultOrgId.ToString()),
+ //});
+ //ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(identity);
+ //httpContext.User = claimsPrincipal;
return next();
}
}
diff --git a/ds-wms-service/DS.Module.UserModule/AspNetUser.cs b/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
index 6576a630..9f42c0f4 100644
--- a/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
+++ b/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
@@ -14,18 +14,18 @@ public class AspNetUser : IUser
_accessor = accessor;
}
- public string UserId => GetClaimValueByType("jti").FirstOrDefault() ?? "90001";
- public string UserName => GetClaimValueByType("UserName").FirstOrDefault() ?? "IUser获取UserName意外为空";
- public string TenantId => GetClaimValueByType("TenantId").FirstOrDefault() ?? "90002";
- public string TenantName => GetClaimValueByType("TenantName").FirstOrDefault() ?? "IUser获取TenantName意外为空";
- public long OrgId => GetClaimValueByType("OrgId").FirstOrDefault()?.ObjToLong() ?? 90003;
+ public string UserId => GetClaimValueByType("jti") ?? "90001";
+ public string UserName => GetClaimValueByType("UserName") ?? "IUser获取UserName意外为空";
+ public string TenantId => GetClaimValueByType("TenantId") ?? "90002";
+ public string TenantName => GetClaimValueByType("TenantName") ?? "IUser获取TenantName意外为空";
+ public long OrgId => GetClaimValueByType("OrgId")?.ObjToLong() ?? 90003;
- public List GetClaimValueByType(string claimType)
+ public string? GetClaimValueByType(string claimType)
{
- return Claims.Where(x => x.Type == claimType).Select(x => x.Value).ToList();
+ return Claims.Where(x => x.Type == claimType).Select(x => x.Value).FirstOrDefault();
}
private List? _claims;
diff --git a/ds-wms-service/DS.Module.UserModule/IUser.cs b/ds-wms-service/DS.Module.UserModule/IUser.cs
index ed231f8b..fc97627f 100644
--- a/ds-wms-service/DS.Module.UserModule/IUser.cs
+++ b/ds-wms-service/DS.Module.UserModule/IUser.cs
@@ -37,7 +37,7 @@ public interface IUser
///
/// 根据Claim类型返回Claim的值
///
- List GetClaimValueByType(string claimType);
+ string? GetClaimValueByType(string claimType);
///
/// 返回当前用户是否已经过认证
diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
index b68d7cc9..00f5d2d5 100644
--- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
+++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
@@ -260,14 +260,14 @@ namespace DS.WMS.Core.TaskPlat.Method
logger.LogInformation("批次={no} 接收到创建任务报文 报文={msg}", batchNo, JsonConvert.SerializeObject(info));
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
- //var sql = tenantDb.Queryable().Where(x => x.Id > 232 ).ToSqlString();
-
- //var a = user.UserId;
- //var aa = user.TenantId;
- //var a343 = user.GetTenantId();
- //var sfdfd = user.TenantName;
- //var b = user.GetOrgId();
- //var b232 = user.OrgId;
+
+ // 人员信息测试用
+ //var a1 = user.UserId;
+ //var b1 = user.UserName;
+ //var c1 = user.TenantId;
+ //var d1 = user.TenantName;
+ //var e1 = user.OrgId;
+ //var sql = tenantDb.Queryable().Where(x => x.Id > 232).ToSqlString();
TaskBaseInfo taskInfo = null;
From 20fcfca0e2da5278fe97c3146f8ff5b3491539fb Mon Sep 17 00:00:00 2001
From: cjy
Date: Fri, 13 Sep 2024 14:44:22 +0800
Subject: [PATCH 03/12] =?UTF-8?q?=E6=8D=A2Token=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DS.Module.UserModule/AspNetUser.cs | 35 ++++++-------------
.../DS.Module.UserModule/UserModuleInstall.cs | 1 +
.../Code/Method/CodeSequenceService.cs | 2 +-
3 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/ds-wms-service/DS.Module.UserModule/AspNetUser.cs b/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
index 9f42c0f4..b2af5b7d 100644
--- a/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
+++ b/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
@@ -33,39 +33,26 @@ public class AspNetUser : IUser
{
get
{
- if (_claims == null || _claims.Count == 0)
- {
- _claims = GetClaimsIdentity().ToList();
- }
- return _claims;
+ return GetClaimsIdentity().ToList();
}
}
IEnumerable GetClaimsIdentity()
{
if (_accessor.HttpContext == null) return ArraySegment.Empty;
+
+ var token = GetToken();
- if (!IsAuthenticated())
+ var jwtHandler = new JwtSecurityTokenHandler();
+ if (token.IsNotEmptyOrNull() && jwtHandler.CanReadToken(token))
{
- var token = GetToken();
-
- var jwtHandler = new JwtSecurityTokenHandler();
- if (token.IsNotEmptyOrNull() && jwtHandler.CanReadToken(token))
- {
- JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
- return jwtToken.Claims;
- }
+ JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
+ return jwtToken.Claims;
+ }
+ else
+ {
+ return ArraySegment.Empty;
}
-
- var claims = _accessor.HttpContext.User.Claims.ToList() ?? [];
-
- // 如果有从Claims中获取HttpHeader的需求,把这里放开
- //var headers = _accessor.HttpContext.Request.Headers;
- //foreach (var header in headers)
- //{
- // claims.Add(new Claim(header.Key, header.Value));
- //}
- return claims;
}
public bool IsAuthenticated()
{
diff --git a/ds-wms-service/DS.Module.UserModule/UserModuleInstall.cs b/ds-wms-service/DS.Module.UserModule/UserModuleInstall.cs
index 1a7cb518..9ed07247 100644
--- a/ds-wms-service/DS.Module.UserModule/UserModuleInstall.cs
+++ b/ds-wms-service/DS.Module.UserModule/UserModuleInstall.cs
@@ -17,6 +17,7 @@ public static class UserModuleInstall
if (services == null) throw new ArgumentNullException(nameof(services));
services.AddSingleton();
+ //services.AddTransient();
services.AddScoped();
}
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceService.cs
index d83570fb..62ba96da 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceService.cs
@@ -57,7 +57,7 @@ public class CodeSequenceService : ICodeSequenceService
if (req.Id == 0)
{
- if (tenantDb.Queryable().Where(x => x.PermissionId == req.PermissionId && x.OrderNo == req.OrderNo).Any())
+ if (tenantDb.Queryable().Where(x => x.PermissionId == req.PermissionId && x.SequenceName == req.SequenceName).Any())
{
return DataResult.Failed("基础编码已存在!", MultiLanguageConst.SequenceExist);
}
From afb69390af50a98fc876a5b62d625722a2f69cf0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?=
Date: Fri, 13 Sep 2024 14:50:31 +0800
Subject: [PATCH 04/12] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E6=9F=A5=E8=AF=A2bug=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs | 5 ++++-
.../Properties/PublishProfiles/FolderProfile1.pubxml.user | 2 +-
ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs
index 509178e6..135bceef 100644
--- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs
+++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs
@@ -276,12 +276,13 @@ public class ClientInfoService : ServiceBase, IClientInfoService
if (request.OtherQueryCondition?.ClientTag != null)
{
var props = Array.FindAll(request.OtherQueryCondition.ClientTag.GetType().GetProperties(), x => x.Name.StartsWith("Is") && x.PropertyType == typeof(bool));
+ List list = [];
foreach (var prop in props)
{
object val = prop.Get(request.OtherQueryCondition.ClientTag);
if (val != null && val is bool value && value)
{
- whereList.Add(new ConditionalModel
+ list.Add(new ConditionalModel
{
ConditionalType = ConditionalType.Equal,
FieldName = "ct." + prop.Name,
@@ -289,6 +290,8 @@ public class ClientInfoService : ServiceBase, IClientInfoService
});
}
}
+
+ query = query.Where(list);
}
var result = await query.Select((c, c1, c2, ct) => new ClientInfoRes
diff --git a/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user b/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user
index cc12734c..e0b095ab 100644
--- a/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user
+++ b/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user
@@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<_PublishTargetUrl>D:\Publish\DS8\FeeApi
- True|2024-09-13T02:44:56.1241214Z||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||;True|2024-07-01T15:49:58.9266967+08:00||;True|2024-07-01T14:35:48.1117178+08:00||;True|2024-07-01T11:41:52.2969338+08:00||;True|2024-07-01T11:13:02.6561160+08:00||;True|2024-06-28T15:28:43.1470725+08:00||;True|2024-06-28T15:16:20.1999596+08:00||;True|2024-06-28T15:14:56.2534743+08:00||;True|2024-06-28T15:02:41.3033806+08:00||;True|2024-06-28T13:37:28.2462742+08:00||;True|2024-06-28T11:06:30.7400535+08:00||;True|2024-06-26T15:24:17.1939896+08:00||;True|2024-06-26T14:33:06.3530466+08:00||;True|2024-06-26T09:45:24.4055568+08:00||;True|2024-06-25T15:45:57.6052473+08:00||;True|2024-06-25T10:17:17.7408916+08:00||;False|2024-06-25T10:16:23.5639654+08:00||;False|2024-06-25T10:15:28.3857721+08:00||;False|2024-06-25T10:10:59.5536995+08:00||;False|2024-06-25T10:07:10.4050937+08:00||;True|2024-06-24T15:22:18.2672769+08:00||;True|2024-06-24T15:01:04.8153621+08:00||;False|2024-06-24T15:00:29.9618848+08:00||;True|2024-06-24T14:07:19.9401637+08:00||;False|2024-06-24T14:06:36.1250570+08:00||;True|2024-06-21T15:13:57.4273503+08:00||;True|2024-06-21T15:04:37.8218608+08:00||;True|2024-06-21T14:12:48.0266638+08:00||;True|2024-06-21T13:52:30.0950155+08:00||;True|2024-06-20T11:02:42.9508506+08:00||;True|2024-06-19T11:43:01.1899282+08:00||;True|2024-06-19T11:23:01.2938141+08:00||;True|2024-06-18T08:51:21.6222152+08:00||;True|2024-06-17T09:20:35.0804494+08:00||;True|2024-06-17T08:41:58.1319484+08:00||;True|2024-06-17T08:38:09.0137102+08:00||;True|2024-06-14T15:19:45.7395180+08:00||;True|2024-06-14T14:38:49.7094421+08:00||;True|2024-06-14T14:27:39.2815370+08:00||;True|2024-06-14T09:42:21.5397525+08:00||;True|2024-06-13T16:03:39.8475642+08:00||;True|2024-06-13T14:12:10.1725629+08:00||;True|2024-06-13T10:46:52.6971321+08:00||;True|2024-06-11T17:03:44.8328978+08:00||;True|2024-06-06T17:41:51.1810315+08:00||;True|2024-06-06T10:57:27.8273617+08:00||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;
+ True|2024-09-13T06:31:12.4598160Z||;True|2024-09-13T10:44:56.1241214+08:00||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||;True|2024-07-01T15:49:58.9266967+08:00||;True|2024-07-01T14:35:48.1117178+08:00||;True|2024-07-01T11:41:52.2969338+08:00||;True|2024-07-01T11:13:02.6561160+08:00||;True|2024-06-28T15:28:43.1470725+08:00||;True|2024-06-28T15:16:20.1999596+08:00||;True|2024-06-28T15:14:56.2534743+08:00||;True|2024-06-28T15:02:41.3033806+08:00||;True|2024-06-28T13:37:28.2462742+08:00||;True|2024-06-28T11:06:30.7400535+08:00||;True|2024-06-26T15:24:17.1939896+08:00||;True|2024-06-26T14:33:06.3530466+08:00||;True|2024-06-26T09:45:24.4055568+08:00||;True|2024-06-25T15:45:57.6052473+08:00||;True|2024-06-25T10:17:17.7408916+08:00||;False|2024-06-25T10:16:23.5639654+08:00||;False|2024-06-25T10:15:28.3857721+08:00||;False|2024-06-25T10:10:59.5536995+08:00||;False|2024-06-25T10:07:10.4050937+08:00||;True|2024-06-24T15:22:18.2672769+08:00||;True|2024-06-24T15:01:04.8153621+08:00||;False|2024-06-24T15:00:29.9618848+08:00||;True|2024-06-24T14:07:19.9401637+08:00||;False|2024-06-24T14:06:36.1250570+08:00||;True|2024-06-21T15:13:57.4273503+08:00||;True|2024-06-21T15:04:37.8218608+08:00||;True|2024-06-21T14:12:48.0266638+08:00||;True|2024-06-21T13:52:30.0950155+08:00||;True|2024-06-20T11:02:42.9508506+08:00||;True|2024-06-19T11:43:01.1899282+08:00||;True|2024-06-19T11:23:01.2938141+08:00||;True|2024-06-18T08:51:21.6222152+08:00||;True|2024-06-17T09:20:35.0804494+08:00||;True|2024-06-17T08:41:58.1319484+08:00||;True|2024-06-17T08:38:09.0137102+08:00||;True|2024-06-14T15:19:45.7395180+08:00||;True|2024-06-14T14:38:49.7094421+08:00||;True|2024-06-14T14:27:39.2815370+08:00||;True|2024-06-14T09:42:21.5397525+08:00||;True|2024-06-13T16:03:39.8475642+08:00||;True|2024-06-13T14:12:10.1725629+08:00||;True|2024-06-13T10:46:52.6971321+08:00||;True|2024-06-11T17:03:44.8328978+08:00||;True|2024-06-06T17:41:51.1810315+08:00||;True|2024-06-06T10:57:27.8273617+08:00||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user
index da141c5a..fb7be066 100644
--- a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user
+++ b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user
@@ -1,7 +1,7 @@
- E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml
+ D:\Source\Repos\DS8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml
MvcControllerEmptyScaffolder
root/Common/MVC/Controller
From 42663775609ac8701278ad8be960796c588d1a2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?=
Date: Fri, 13 Sep 2024 14:54:00 +0800
Subject: [PATCH 05/12] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8bug?=
=?UTF-8?q?=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs
index 135bceef..6a0eb122 100644
--- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs
+++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs
@@ -275,6 +275,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
if (request.OtherQueryCondition?.ClientTag != null)
{
+ //合并到主查询条件
var props = Array.FindAll(request.OtherQueryCondition.ClientTag.GetType().GetProperties(), x => x.Name.StartsWith("Is") && x.PropertyType == typeof(bool));
List list = [];
foreach (var prop in props)
From 1d38ef64899f77f2b658c759639933c98603d7ba Mon Sep 17 00:00:00 2001
From: cjy
Date: Fri, 13 Sep 2024 15:04:28 +0800
Subject: [PATCH 06/12] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DS.WMS.Core/Code/Method/CodeDataRuleService.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeDataRuleService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeDataRuleService.cs
index e3aac2c2..67e1cae3 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeDataRuleService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeDataRuleService.cs
@@ -137,7 +137,7 @@ namespace DS.WMS.Core.Code.Method
return await Task.FromResult(DataResult.Failed("权限复制人员不能为空!"));
}
- if (db.Queryable().Where(x=> !req.CopyUserIds.Contains(x.Id)).Any()) {
+ if (db.Queryable().Where(x=> req.CopyUserIds.Contains(x.Id)).Count() == 0) {
return await Task.FromResult(DataResult.Failed("请检查复制人员信息!"));
}
@@ -165,6 +165,7 @@ namespace DS.WMS.Core.Code.Method
{
UserId = userInfo.Id,
UserName = userInfo.UserName,
+ TemplateName = rule.TemplateName,
VisibleTemplateId = rule.VisibleTemplateId,
VisibleRuleScope = rule.VisibleRuleScope,
VisibleRuleScopeName = rule.VisibleRuleScopeName,
@@ -257,6 +258,7 @@ namespace DS.WMS.Core.Code.Method
{
UserId = userInfo.Id,
UserName = userInfo.UserName,
+ TemplateName = currentTemplate.TemplateName,
VisibleTemplateId = currentTemplate.Id,
VisibleRuleScope = currentTemplate.RuleScope,
VisibleRuleScopeName = currentTemplate.RuleScopeName,
@@ -363,6 +365,7 @@ namespace DS.WMS.Core.Code.Method
{
UserId = userInfo.Id,
UserName = userInfo.UserName,
+ TemplateName = currentTemplate.TemplateName,
OperateTemplateId = currentTemplate.Id,
OperateRuleScope = currentTemplate.RuleScope,
OperateRuleScopeName = currentTemplate.RuleScopeName,
From b5b9d8f91d9c245c9542609e8396350be17c541e Mon Sep 17 00:00:00 2001
From: cjy
Date: Fri, 13 Sep 2024 15:16:22 +0800
Subject: [PATCH 07/12] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?=
=?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DS.WMS.Core/Code/Method/DataRuleTemplateService.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs
index c3469b9e..1790a474 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs
@@ -93,7 +93,7 @@ namespace DS.WMS.Core.Code.Method
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = await tenantDb.Queryable()
- .Where(x => x.Id == long.Parse(id) && x.Status == StatusEnum.Enable)
+ .Where(x => x.Id == long.Parse(id))
.Select()
.FirstAsync();
return await Task.FromResult(DataResult.Success(data, MultiLanguageConst.DataQuerySuccess));
From 723233cf955e911ec22cdd13422e3f99aefffb36 Mon Sep 17 00:00:00 2001
From: zhangxiaofeng <1939543722@qq.com>
Date: Fri, 13 Sep 2024 15:21:04 +0800
Subject: [PATCH 08/12] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8F=B0=E4=BB=BB?=
=?UTF-8?q?=E5=8A=A1=E8=BD=AC=E4=BA=A4=E6=97=B6=EF=BC=8C=E6=9B=B4=E6=96=B0?=
=?UTF-8?q?FlowInstance=E3=80=81BusinessTask?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TaskPlat/Method/TaskManageBaseService.cs | 42 +++++++++++++++++--
.../TaskPlat/Method/TaskManageService.cs | 6 +++
.../DS.WMS.MainApi/DS.WMS.MainApi.csproj.user | 2 +-
3 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs
index 269956ad..b7196c7d 100644
--- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs
+++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs
@@ -7,9 +7,11 @@ using DS.Module.DjyServiceStatus;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
+using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Map.Dtos;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
+using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity;
@@ -97,6 +99,8 @@ namespace DS.WMS.Core.TaskPlat.Method
//任务不考虑OrgId,这里去掉
tenantDb.QueryFilter.Clear();
+ var masterDb = serviceProvider.GetRequiredService();
+
try
{
var taskList = await tenantDb.Queryable().Where(x => taskIds.Contains(x.Id)).ToListAsync(x => new
@@ -137,8 +141,12 @@ namespace DS.WMS.Core.TaskPlat.Method
});
allocationList.AddRange(allots);
}
+ // 用于更新工作流的任务
+ var userIdStr = string.Join(',', userInfo.Select(x => x.RecvUserId));
+ var businessIdList = taskList.Where(x => x.OUT_BS_NO != null && x.OUT_BS_NO != 0).Select(x => x.OUT_BS_NO).Distinct().ToList();
- await tenantDb.Ado.BeginTranAsync();
+ //await tenantDb.Ado.BeginTranAsync();
+ await tenantDb.AsTenant().BeginTranAsync();
var idList = await tenantDb.Queryable().Where(x => taskIdList.Contains(x.TaskId)).Select(x => x.Id).ToListAsync();
await tenantDb.Deleteable(x => idList.Contains(x.Id)).ExecuteCommandAsync();
@@ -149,12 +157,40 @@ namespace DS.WMS.Core.TaskPlat.Method
.SetColumns(x => x.IS_PUBLIC == 0)
.Where(x => taskIdList.Contains(x.Id))
.ExecuteCommandAsync();
+ foreach (var item in taskList)
+ {
+ if (item.OUT_BS_NO is not null or 0 && Enum.TryParse(typeof(TaskBaseTypeEnum), item.TASK_TYPE, out object? taskType))
+ {
+ await tenantDb.Updateable()
+ .SetColumns(x => x.RecvUsers == userIdStr)
+ .Where(x => x.BusinessId == item.OUT_BS_NO && x.TaskType == (TaskBaseTypeEnum)taskType)
+ .ExecuteCommandAsync();
+
+ var id = await masterDb.Queryable()
+ .ClearFilter(typeof(ITenantId))
+ .Where(y => y.BusinessId == item.OUT_BS_NO && y.AuditType == (TaskBaseTypeEnum)taskType)
+ .OrderByDescending(y => y.Id)
+ .Select(y => y.Id)
+ .FirstAsync();
+ if (id != 0)
+ {
+ await masterDb.Updateable()
+ .SetColumns(x => x.MakerList == userIdStr)
+ .Where(x => x.Id == id)
+ .ExecuteCommandAsync();
+ }
+ }
+ }
- await tenantDb.Ado.CommitTranAsync();
+
+
+ //await tenantDb.Ado.CommitTranAsync();
+ await tenantDb.AsTenant().CommitTranAsync();
}
catch (Exception)
{
- await tenantDb.Ado.RollbackTranAsync();
+ //await tenantDb.Ado.RollbackTranAsync();
+ await tenantDb.AsTenant().RollbackTranAsync();
throw;
}
}
diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
index e3917e52..07de76ba 100644
--- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
+++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs
@@ -2613,6 +2613,12 @@ namespace DS.WMS.Core.TaskPlat.Method
portLoadTaskIdList = temp.Select(x => x.TASK_ID).ToArray();
}
}
+ //// 下属任务统计
+ //var underTaskQueryable = tenantDb.Queryable()
+ // .LeftJoin((t, a) => t.Id == a.TaskId)
+ // .LeftJoin((t, a, s) => t.OUT_BS_NO == s.Id);
+
+
//任务列表分组统计
var queryable = tenantDb.Queryable()
diff --git a/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user b/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user
index 996c16b7..f2a959bf 100644
--- a/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user
+++ b/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user
@@ -1,6 +1,6 @@
- D:\Code\DS\ds8-solution-pro\ds-wms-service\DS.WMS.MainApi\Properties\PublishProfiles\FolderProfile.pubxml
+ D:\Code\ds8-solution-pro\ds-wms-service\DS.WMS.MainApi\Properties\PublishProfiles\FolderProfile.pubxml
\ No newline at end of file
From 3fd63b3dc6cdeade6b06aa9447e8247bcdaf4c61 Mon Sep 17 00:00:00 2001
From: cjy
Date: Fri, 13 Sep 2024 15:57:05 +0800
Subject: [PATCH 09/12] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?=
=?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=A4=8D=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Interface/IDataRuleTemplateService.cs | 8 ++++++++
.../Code/Method/DataRuleTemplateService.cs | 20 +++++++++++++++++++
.../CodeDataRuleTemplateController.cs | 13 ++++++++++++
3 files changed, 41 insertions(+)
diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/IDataRuleTemplateService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/IDataRuleTemplateService.cs
index ebb70279..88fc6e38 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Interface/IDataRuleTemplateService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Interface/IDataRuleTemplateService.cs
@@ -44,4 +44,12 @@ public interface IDataRuleTemplateService
///
Task>> GetDataRuleTemplateSelectList(string id, string ruleType);
+
+ ///
+ /// 数据权限模板复制
+ ///
+ ///
+ ///
+
+ public Task BatchCopyDataRuleTemplate(IdModel req);
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs
index 1790a474..431eade7 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/DataRuleTemplateService.cs
@@ -127,5 +127,25 @@ namespace DS.WMS.Core.Code.Method
}
return await Task.FromResult(DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess));
}
+
+ public async Task BatchCopyDataRuleTemplate(IdModel req)
+ {
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+ var list = await tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id)).ToListAsync();
+ var newList = new List();
+ if (list.Count > 0)
+ {
+ foreach (var item in list) {
+
+ var temp = item.Adapt();
+ temp.Id = 0;
+ temp.TemplateName = item.TemplateName +"-复制";
+ newList.Add(temp);
+ }
+
+ await tenantDb.Insertable(newList).ExecuteCommandAsync();
+ }
+ return await Task.FromResult(DataResult.Successed("复制成功!", MultiLanguageConst.DataCopySuccess));
+ }
}
}
diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleTemplateController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleTemplateController.cs
index 3f2d3304..f8b3a916 100644
--- a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleTemplateController.cs
+++ b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeDataRuleTemplateController.cs
@@ -87,4 +87,17 @@ public class CodeDataRuleTemplateController : ApiController
var res =await _invokeService.BatchDelDataRuleTemplate(req);
return res;
}
+
+ ///
+ /// 批量复制
+ ///
+ /// Ids
+ ///
+ [HttpPost]
+ [Route("BatchCopyDataRuleTemplate")]
+ public async Task BatchCopyDataRuleTemplate([FromBody] IdModel req)
+ {
+ var res = await _invokeService.BatchCopyDataRuleTemplate(req);
+ return res;
+ }
}
\ No newline at end of file
From ff0a271a64e9a034566ba5b74e9fe1d58294b8b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?=
Date: Fri, 13 Sep 2024 16:03:01 +0800
Subject: [PATCH 10/12] =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E9=A9=B3=E5=9B=9E=E6=97=B6=E6=9B=B4=E6=96=B0=E9=A9=B3=E5=9B=9E?=
=?UTF-8?q?=E7=90=86=E7=94=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DS.WMS.Core/Fee/Dtos/ReportContext.cs | 48 +++++++
.../Fee/Interface/IFeeRecordService.cs | 5 +-
.../Fee/Interface/IReportProvider.cs | 17 +++
.../Fee/Method/FeeRecordService.cs | 115 +++-------------
.../ReportProviders/CostAccountingReport.cs | 123 ++++++++++++++++++
.../Op/Method/TaskInteraction/TaskService.cs | 14 +-
.../Controllers/FeeRecordController.cs | 11 +-
7 files changed, 227 insertions(+), 106 deletions(-)
create mode 100644 ds-wms-service/DS.WMS.Core/Fee/Dtos/ReportContext.cs
create mode 100644 ds-wms-service/DS.WMS.Core/Fee/Interface/IReportProvider.cs
create mode 100644 ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/CostAccountingReport.cs
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Dtos/ReportContext.cs b/ds-wms-service/DS.WMS.Core/Fee/Dtos/ReportContext.cs
new file mode 100644
index 00000000..68cecea5
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Fee/Dtos/ReportContext.cs
@@ -0,0 +1,48 @@
+using DS.Module.Core;
+using DS.Module.UserModule;
+using DS.WMS.Core.Op.Entity;
+using SqlSugar;
+
+namespace DS.WMS.Core.Fee.Dtos
+{
+ ///
+ /// 报表生成上下文
+ ///
+ public class ReportContext
+ {
+ ///
+ /// 服务提供程序
+ ///
+ public IServiceProvider ServiceProvider { get; internal set; }
+
+ ///
+ /// 获取主库访问对象
+ ///
+ public ISqlSugarClient Db { get; internal set; }
+
+ ///
+ /// 获取租户库访问对象
+ ///
+ public ISqlSugarClient TenantDb { get; internal set; }
+
+ ///
+ /// 请求用户
+ ///
+ public IUser User { get; internal set; }
+
+ ///
+ /// 操作结果,用于记录错误信息
+ ///
+ public DataResult? ErrorResult { get; set; }
+
+ ///
+ /// 业务类型
+ ///
+ public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
+
+ ///
+ /// 业务ID
+ ///
+ public long[] Ids { get; set; } = [];
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeRecordService.cs b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeRecordService.cs
index 0c3b8950..57b0dee0 100644
--- a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeRecordService.cs
+++ b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeRecordService.cs
@@ -96,12 +96,13 @@ public interface IFeeRecordService
Task WriteBackStatusAsync(long businessId, BusinessType businessType);
///
- /// 获取费用核算单打印信息
+ /// 获取费用打印信息
///
+ /// 数据提供程序
/// 业务类型
/// 费用记录ID
///
- Task> GetPrintInfoAsync(BusinessType businessType, params long[] idArray);
+ Task> GetPrintInfoAsync(string providerName, BusinessType businessType, params long[] idArray);
///
/// 设置发票启用状态
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Interface/IReportProvider.cs b/ds-wms-service/DS.WMS.Core/Fee/Interface/IReportProvider.cs
new file mode 100644
index 00000000..81f69d00
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Fee/Interface/IReportProvider.cs
@@ -0,0 +1,17 @@
+using DS.WMS.Core.Fee.Dtos;
+
+namespace DS.WMS.Core.Fee.Interface
+{
+ ///
+ /// 用于输出报表的数据提供程序
+ ///
+ public interface IReportProvider
+ {
+ ///
+ /// 返回所需的JSON格式的数据
+ ///
+ /// 报表输出上下文
+ ///
+ Task GetDataAsync(ReportContext context);
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
index e1cb5cb2..09e3a304 100644
--- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
+++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
@@ -222,7 +222,7 @@ namespace DS.WMS.Core.Fee.Method
item.Quantity = ctn == null ? 0 : ctn.CtnNum.GetValueOrDefault();
break;
}
- }
+ }
//计算税费
item.SetTax();
@@ -927,110 +927,33 @@ namespace DS.WMS.Core.Fee.Method
}
///
- /// 获取费用核算单打印信息
+ /// 获取费用打印信息
///
+ ///
/// 业务类型
/// 费用记录ID
///
- public async Task> GetPrintInfoAsync(BusinessType businessType, params long[] idArray)
- {
- CostAccountingForm form = null;
- switch (businessType)
- {
- case BusinessType.OceanShippingExport:
- form = await GetOceanShippingExportAsync(idArray);
- break;
- case BusinessType.OceanShippingImport:
-
- break;
- default:
- return DataResult.Failed(string.Format(
- MultiLanguageConst.BusinessNotSupported, businessType.GetDescription()));
- }
-
- if (form != null)
- {
- long UserId = long.Parse(User.UserId);
- form.Creator = Db.Queryable().Where(x => x.Id == UserId).Select(x => x.UserName).First();
-
- form.ReceivableRMB = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
- form.PayableRMB = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
- form.ReceivableUSD = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
- form.PayableUSD = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
- form.ReceivableOther = form.Details.FindAll(x => x.Type == FeeType.Receivable && (x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
- form.PayableOther = form.Details.FindAll(x => x.Type == FeeType.Payable && (x.Currency == FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
-
- //获取美元汇率
- var fees = new List {
- new FeeRecord { Currency = FeeCurrency.USD_CODE, FeeType = FeeType.Receivable },
- new FeeRecord { Currency = FeeCurrency.USD_CODE, FeeType = FeeType.Payable }
- };
- await FetchExchangeRateAsync(fees);
- form.ExchangeRate = fees[0].ExchangeRate.HasValue ? fees[0].ExchangeRate.Value : 1;
- form.TotalReceivable = Math.Round(form.ReceivableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.ReceivableRMB + form.ReceivableOther;
- form.TotalPayable = Math.Round(form.PayableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.PayableRMB + form.PayableOther;
- }
-
- return DataResult.Success(form);
- }
-
- //获取海运出口打印数据
- async Task GetOceanShippingExportAsync(params long[] idArray)
+ public async Task> GetPrintInfoAsync(string providerName, BusinessType businessType, params long[] idArray)
{
- CostAccountingForm form = null;
- var list = await TenantDb.Queryable().InnerJoin((x, y) => x.BusinessId == y.Id)
- .Where((x, y) => idArray.Contains(x.Id)
- //&& x.FeeStatus == FeeStatus.SettlementCompleted
- ).Select((x, y) => new
- {
- x.FeeType,
- x.FeeName,
- x.Currency,
- x.ExchangeRate,
- x.Amount,
- x.CustomerName,
- y.CustomerNo, //业务编号
- y.AccountDate, //会计期间
- y.ETA,
- y.ETD,
- y.Voyno,
- y.MBLNO,
- y.Carrier,
- y.LoadPort,
- y.DischargePort,
- y.CntrTotal, //Volume
- y.IssueType //放单方式
- }).ToListAsync();
-
- if (list.Count == 0)
- return form;
+ Type type = Type.GetType(providerName, false);
+ if (type == null)
+ return DataResult.Failed("未能找到数据提供程序");
- var item = list[0];
- form = new CostAccountingForm
+ var provider = Fasterflect.ConstructorExtensions.CreateInstance(type) as IReportProvider;
+ var context = new ReportContext
{
- BusinessNo = item.CustomerNo,
- AccountingPeriod = item.AccountDate,
- ETA = item.ETA,
- ETD = item.ETD,
- Voy = item.Voyno,
- MBLNo = item.MBLNO,
- Carrier = item.Carrier,
- POL = item.LoadPort,
- POD = item.DischargePort,
- Volume = item.CntrTotal,
- ReleaseType = item.IssueType,
- PrintTime = DateTime.Now,
- Details = list.Select(x => new CostAccountingDetail
- {
- Amount = x.Amount,
- Currency = x.Currency,
- CustomerName = x.CustomerName,
- FeeName = x.FeeName,
- Type = x.FeeType
- }).ToList()
+ BusinessType = businessType,
+ Ids = idArray,
+ Db = Db,
+ TenantDb = TenantDb,
+ User = User,
+ ServiceProvider = ServiceProvider
};
+ var data = provider.GetDataAsync(context);
+ if (context.ErrorResult == null)
+ return DataResult.Success(data);
- return form;
+ return DataResult.Failed(context.ErrorResult.Message, context.ErrorResult.MultiCode);
}
///
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/CostAccountingReport.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/CostAccountingReport.cs
new file mode 100644
index 00000000..da389dca
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Fee/Method/ReportProviders/CostAccountingReport.cs
@@ -0,0 +1,123 @@
+using DS.Module.Core;
+using DS.WMS.Core.Fee.Dtos;
+using DS.WMS.Core.Fee.Entity;
+using DS.WMS.Core.Fee.Interface;
+using DS.WMS.Core.Op.Entity;
+using DS.WMS.Core.Sys.Entity;
+using Masuit.Tools.Systems;
+using Microsoft.Extensions.DependencyInjection;
+using SqlSugar;
+
+namespace DS.WMS.Core.Fee.Method.ReportProviders
+{
+ ///
+ /// 费用核算单
+ ///
+ public class CostAccountingReport : IReportProvider
+ {
+ public async Task GetDataAsync(ReportContext context)
+ {
+ CostAccountingForm? form = null;
+ switch (context.BusinessType)
+ {
+ case BusinessType.OceanShippingExport:
+ form = await GetOceanShippingExportAsync(context.TenantDb, context.Ids);
+ break;
+ case BusinessType.OceanShippingImport:
+
+ break;
+ default:
+ context.ErrorResult = DataResult.Failed(string.Format(MultiLanguageConst.GetDescription(
+ MultiLanguageConst.BusinessNotSupported), context.BusinessType.GetDescription()));
+ break;
+ }
+
+ if (form != null)
+ {
+ long UserId = long.Parse(context.User.UserId);
+ form.Creator = context.Db.Queryable().Where(x => x.Id == UserId).Select(x => x.UserName).First();
+
+ form.ReceivableRMB = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
+ form.PayableRMB = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
+ form.ReceivableUSD = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
+ form.PayableUSD = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
+ form.ReceivableOther = form.Details.FindAll(x => x.Type == FeeType.Receivable && (x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
+ form.PayableOther = form.Details.FindAll(x => x.Type == FeeType.Payable && (x.Currency == FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
+
+ //获取美元汇率
+ var currencyService = context.ServiceProvider.GetRequiredService();
+ var exchange = new ExchangeRate
+ {
+ CurrencyFrom = FeeCurrency.USD_CODE,
+ CurrencyTo = FeeCurrency.RMB_CODE
+ };
+ exchange = (await currencyService.GetExchangeRateAsync(exchange))?.Data;
+
+ form.ExchangeRate = exchange.Rate;
+ form.TotalReceivable = Math.Round(form.ReceivableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.ReceivableRMB + form.ReceivableOther;
+ form.TotalPayable = Math.Round(form.PayableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.PayableRMB + form.PayableOther;
+ }
+
+ return form;
+ }
+
+ //获取海运出口打印数据
+ static async Task GetOceanShippingExportAsync(ISqlSugarClient tenantDb, params long[] idArray)
+ {
+ CostAccountingForm form = null;
+ var list = await tenantDb.Queryable().InnerJoin((x, y) => x.BusinessId == y.Id)
+ .Where((x, y) => idArray.Contains(x.Id)
+ //&& x.FeeStatus == FeeStatus.SettlementCompleted
+ ).Select((x, y) => new
+ {
+ x.FeeType,
+ x.FeeName,
+ x.Currency,
+ x.ExchangeRate,
+ x.Amount,
+ x.CustomerName,
+ y.CustomerNo, //业务编号
+ y.AccountDate, //会计期间
+ y.ETA,
+ y.ETD,
+ y.Voyno,
+ y.MBLNO,
+ y.Carrier,
+ y.LoadPort,
+ y.DischargePort,
+ y.CntrTotal, //Volume
+ y.IssueType //放单方式
+ }).ToListAsync();
+
+ if (list.Count == 0)
+ return form;
+
+ var item = list[0];
+ form = new CostAccountingForm
+ {
+ BusinessNo = item.CustomerNo,
+ AccountingPeriod = item.AccountDate,
+ ETA = item.ETA,
+ ETD = item.ETD,
+ Voy = item.Voyno,
+ MBLNo = item.MBLNO,
+ Carrier = item.Carrier,
+ POL = item.LoadPort,
+ POD = item.DischargePort,
+ Volume = item.CntrTotal,
+ ReleaseType = item.IssueType,
+ PrintTime = DateTime.Now,
+ Details = list.Select(x => new CostAccountingDetail
+ {
+ Amount = x.Amount,
+ Currency = x.Currency,
+ CustomerName = x.CustomerName,
+ FeeName = x.FeeName,
+ Type = x.FeeType
+ }).ToList()
+ };
+
+ return form;
+ }
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs
index c7757341..78dba382 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs
@@ -463,7 +463,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
{
BusinessTask task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
if (task == null)
- return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
+ return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
if (task.TaskStatus == TaskStatusEnum.Complete)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
//if (task.TaskStatus == TaskStatusEnum.Cancel)
@@ -869,16 +869,20 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (callback.FlowStatus == FlowStatusEnum.Reject)
{
var task = await GetQuery(callback.BusinessId, callback.BusinessType, callback.AuditType.Value).FirstAsync();
- //创建驳回任务以进行通知
- await CreateTaskAsync(new TaskCreationRequest
+ var request = new TaskCreationRequest
{
BusinessId = callback.BusinessId,
BusinessType = callback.BusinessType,
TaskTypeName = GetRejectedType(callback.AuditType.Value).ToString(),
RecvUserIdList = [task.CreateBy] //通知任务发起人
- });
+ };
+ //创建驳回任务以进行通知
+ await CreateTaskAsync(request);
+
+ //更新任务描述为驳回原因
+ await SetTaskBaseDescription(callback.BusinessId, request.TaskType, callback.RejectReason);
- remark += ";驳回理由:" + callback.RejectReason;
+ remark += ";驳回原因:" + callback.RejectReason;
}
long userId = long.Parse(User.UserId);
diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeRecordController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeRecordController.cs
index cdc86f1c..f73793fc 100644
--- a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeRecordController.cs
+++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeRecordController.cs
@@ -3,6 +3,7 @@ using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
+using DS.WMS.Core.Fee.Method.ReportProviders;
using DS.WMS.Core.Op.Entity;
using Microsoft.AspNetCore.Mvc;
@@ -204,12 +205,16 @@ namespace DS.WMS.FeeApi.Controllers
/// 费用记录ID
///
[HttpPost, Route("GetPrintInfo")]
- public async Task> GetPrintInfoAsync(IdModel model)
+ public async Task> GetPrintInfoAsync(IdModel model)
{
if (model == null || model.Ids?.Length == 0)
- return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
+ return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
- return await _feeService.GetPrintInfoAsync((BusinessType)model.BusinessType.Value, model.Ids);
+ string providerName = model.Value?.ToString();
+ if (string.IsNullOrEmpty(providerName))
+ providerName = typeof(CostAccountingReport).AssemblyQualifiedName;
+
+ return await _feeService.GetPrintInfoAsync(providerName, (BusinessType)model.BusinessType.Value, model.Ids);
}
///
From db284882610298c26f4f913eba789b6c1269a16a Mon Sep 17 00:00:00 2001
From: zhangxiaofeng <1939543722@qq.com>
Date: Fri, 13 Sep 2024 17:19:55 +0800
Subject: [PATCH 11/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=BB=E5=BA=93SqlSu?=
=?UTF-8?q?garScope=E5=AF=B9IUser=E7=9A=84=E5=8F=96=E5=80=BC=E6=96=B9?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs | 6 +++---
ds-wms-service/DS.Module.UserModule/AspNetUser.cs | 6 +++++-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
index 49aa37b0..1035c738 100644
--- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
@@ -85,8 +85,8 @@ public static class SqlsugarInstall
// }
// });
//}
- var httpContextAccessor = services.GetService();
- var user = services.GetService();
+ //var httpContextAccessor = services.GetService();
+ //var user = services.GetService();
//if (user.IsNullOrEmpty())
//{
// user = new AspNetUser(httpContextAccessor)
@@ -110,7 +110,7 @@ public static class SqlsugarInstall
var dbProvider = db.GetConnectionScope((string)c.ConfigId);
- // var user = services.GetService();
+ var user = services.GetService();
//单例参数配置,所有上下文生效
dbProvider.Ado.CommandTimeOut = 30;
dbProvider.Aop.OnLogExecuting = (sql, pars) =>
diff --git a/ds-wms-service/DS.Module.UserModule/AspNetUser.cs b/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
index b2af5b7d..7df89035 100644
--- a/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
+++ b/ds-wms-service/DS.Module.UserModule/AspNetUser.cs
@@ -33,7 +33,11 @@ public class AspNetUser : IUser
{
get
{
- return GetClaimsIdentity().ToList();
+ if (_claims == null || _claims.Count == 0)
+ {
+ _claims = GetClaimsIdentity().ToList();
+ }
+ return _claims;
}
}
From 7ecddd6698e2eb91eff3c0eea67fa1636011a8aa Mon Sep 17 00:00:00 2001
From: cjy
Date: Fri, 13 Sep 2024 17:24:35 +0800
Subject: [PATCH 12/12] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D?=
=?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E5=8F=AF=E8=A7=86=E6=9D=83=E9=99=90?=
=?UTF-8?q?=E8=8C=83=E5=9B=B4=20=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DS.WMS.Core/Sys/Method/CommonService.cs | 28 +++++++++++++------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs
index aee297a0..6aeeee64 100644
--- a/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs
+++ b/ds-wms-service/DS.WMS.Core/Sys/Method/CommonService.cs
@@ -1447,7 +1447,7 @@ public class CommonService : ICommonService
var userInfo = db.Queryable().First(x => x.Id == long.Parse(user.UserId));
if (userInfo.UserType == 0)
{
- return db.Queryable(); //超级管理员特权
+ return tenantDb.Queryable(); //超级管理员特权
}
var moduleName = typeof(T).Name.ToLower();
@@ -1461,18 +1461,18 @@ public class CommonService : ICommonService
if ((long)rule.VisibleTemplateId == 0)
{
- return db.Queryable();
+ return tenantDb.Queryable();
}
var ruleInfo = tenantDb.Queryable().First(x => x.Id == (long)rule.VisibleTemplateId);
if (ruleInfo.DataRules.IsNull())
{
- return db.Queryable();
+ return tenantDb.Queryable();
}
if (ruleInfo.RuleScope == "all")
{
- return db.Queryable().ClearFilter();
+ return tenantDb.Queryable().ClearFilter();
}
if (ruleInfo.RuleScope == "none")
{
@@ -1488,18 +1488,30 @@ public class CommonService : ICommonService
}
if (ruleInfo.RuleScope == "self_dept")
{
+ if (String.IsNullOrEmpty(userInfo.DeptName))
+ {
+ SqlSugar.Check.ExceptionEasy("NO Operation", "当前员工没有默认归属部门!");
+ }
var deptUsers = db.Queryable().Where(x => x.DeptId == userInfo.DeptId).Select(x => x.Id).ToList();
ruleInfo.DataRules = ruleInfo.DataRules.Replace(DataRuleConst.LoginDept, string.Join(",", deptUsers));
}
if (ruleInfo.RuleScope == "select_org")
{
- var orgUsers = db.Queryable().Where(x => x.DefaultOrgId == userInfo.DefaultOrgId).Select(x => x.Id).ToList();
- ruleInfo.DataRules = ruleInfo.DataRules.Replace(DataRuleConst.LoginDept, string.Join(",", orgUsers));
+ //var orgUsers = db.Queryable().Where(x => x.DefaultOrgId == userInfo.DefaultOrgId).Select(x => x.Id).ToList();
+ //ruleInfo.DataRules = ruleInfo.DataRules.Replace(DataRuleConst.LoginDept, string.Join(",", orgUsers));
var conditions1 = ruleInfo.DataRules.ConvertSqlSugarExpression();
var conditionalModels1 =
db.ConfigQuery.Context.Utilities.JsonToConditionalModels(
JsonConvert.SerializeObject(conditions1));
- return db.Queryable().ClearFilter().Where(conditionalModels1);
+ return tenantDb.Queryable().ClearFilter().Where(conditionalModels1);
+ }
+ if (ruleInfo.RuleScope == "select_user")
+ {
+ var conditions2 = ruleInfo.DataRules.ConvertSqlSugarExpression();
+ var conditionalModels2 =
+ db.ConfigQuery.Context.Utilities.JsonToConditionalModels(
+ JsonConvert.SerializeObject(conditions2));
+ return tenantDb.Queryable().ClearFilter().Where(conditionalModels2);
}
#endregion
@@ -1509,7 +1521,7 @@ public class CommonService : ICommonService
var conditionalModels =
db.ConfigQuery.Context.Utilities.JsonToConditionalModels(
JsonConvert.SerializeObject(conditions));
- return db.Queryable().Where(conditionalModels);
+ return tenantDb.Queryable().Where(conditionalModels);
}
#region 获取数据库表及字段属性