22
schangxiang@126.com
2025-05-04 bdc6a6c9ac65dfad871ea65de4836f8e27b72427
22
已添加13个文件
已修改10个文件
1285 ■■■■■ 文件已修改
Weben_CMS专用代码生成器/CommonDLL/CmsQueryExtensions.dll 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/CmsQueryExtensions.csproj 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/CmsQueryExtensions.sln 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Attribute/HighSearchRangeAttribute.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Attribute/NoAutoQueryAttribute.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Entity/FunReturnResultModel.cs 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Entity/GlobalVars.cs 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Entity/HighSearchModel.cs 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Entity/SearchFilterModeEnum.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/PredicateExtensions/ClassHelper.cs 187 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/PredicateExtensions/PredicateExtensions.cs 223 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/PredicateExtensions/WhereHelper.cs 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/WhereConditionsExtensions.cs 248 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Application.Contracts/CMS.Plugin.HIAWms.Application.Contracts.csproj 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Application.Contracts/Dtos/WmsMaterials/GetWmsMaterialsInput.cs 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Application/CMS.Plugin.HIAWms.Application.csproj 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsMaterialAppService.cs 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Domain/CMS.Plugin.HIAWms.Domain.csproj 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Domain/WmsMaterials/IWmsMaterialRepository.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/CMS.Plugin.HIAWms.EntityFrameworkCore.csproj 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsMaterialRepository.cs 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms/CMS.Plugin.HIAWms.csproj 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMS专用代码生成器/Weben_CMS_TemplateDemo/web/src/widgets/HIAWms/Views/Pages/WmsMaterial/WmsMaterial.tsx 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Weben_CMSרÓôúÂëÉú³ÉÆ÷/CommonDLL/CmsQueryExtensions.dll
Binary files differ
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/CmsQueryExtensions.csproj
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
</Project>
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/CmsQueryExtensions.sln
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CmsQueryExtensions", "CmsQueryExtensions.csproj", "{D2B006DA-D473-4E98-A588-C1F52945A027}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {D2B006DA-D473-4E98-A588-C1F52945A027}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {D2B006DA-D473-4E98-A588-C1F52945A027}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {D2B006DA-D473-4E98-A588-C1F52945A027}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {D2B006DA-D473-4E98-A588-C1F52945A027}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {912E75B5-EC51-46E7-B058-838F9373EC2E}
    EndGlobalSection
EndGlobal
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Attribute/HighSearchRangeAttribute.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
using System;
namespace CmsQueryExtensions.Extension
{
    /// <summary>
    /// é«˜çº§æŸ¥è¯¢èŒƒå›´æŸ¥è¯¢ç‰¹æ€§
    /// </summary>
    public class HighSearchRangeAttribute : Attribute
    {
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Attribute/NoAutoQueryAttribute.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
using System;
namespace CmsQueryExtensions.Extension
{
    /// <summary>
    /// ä¸è‡ªåŠ¨æŸ¥è¯¢ç‰¹æ€§
    /// ç”¨äºŽä¸éœ€è¦è‡ªåŠ¨åˆ†è§£æŸ¥è¯¢çš„å­—æ®µ
    /// </summary>
    public class NoAutoQueryAttribute : Attribute
    {
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Entity/FunReturnResultModel.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,47 @@
namespace CmsQueryExtensions.Extension
{
    /// <summary>
    /// æ–¹æ³•返回实体类
    /// </summary>
    public class FunReturnResultModel
    {
        public FunReturnResultModel()
        {
            this.IsSuccess = false;
        }
        /// <summary>
        ///  æ‰§è¡Œæ˜¯å¦æˆåŠŸ
        /// </summary>
        public bool IsSuccess { get; set; }
        /// <summary>
        /// é”™è¯¯ä¿¡æ¯
        /// </summary>
        public string ErrMsg { get; set; }
    }
    /// <summary>
    /// æ–¹æ³•返回实体类
    /// </summary>
    public class FunReturnResultModel<T>
    {
        /// <summary>
        ///  æ‰§è¡Œæ˜¯å¦æˆåŠŸ
        /// </summary>
        public bool IsSuccess { get; set; }
        /// <summary>
        /// é”™è¯¯ä¿¡æ¯
        /// </summary>
        public string ErrMsg { get; set; }
        /// <summary>
        /// è¿”回数据
        /// </summary>
        public T data { get; set; }
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Entity/GlobalVars.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
namespace CmsQueryExtensions.Extension
{
    /// <summary>
    /// ç³»ç»Ÿé€šç”¨çš„常量
    /// </summary>
    public static class SystemCommonVar
    {
        /// <summary>
        /// é€šç”¨çš„æŸ¥è¯¢å­—符串
        /// </summary>
        public const string searchVal = "searchVal";
        /// <summary>
        /// é«˜çº§æŸ¥è¯¢çš„后缀名
        /// </summary>
        public const string highSearchModeSuffix = "_FilterMode";
        /// <summary>
        /// é€šç”¨çš„æŸ¥è¯¢å­—符串的配置模式
        /// </summary>
        public const string searchVal_FilterMode = searchVal + highSearchModeSuffix;
        /// <summary>
        /// å­æœç´¢ç»„件传递的属性名
        /// </summary>
        public const string searchFormInputAttrs = "searchFormInputAttrs";
        /// <summary>
        /// é€šç”¨çš„æŸ¥è¯¢å‚数类的父类中的字段
        /// </summary>
        public const string commnParamFatherPros = "SortField|SortOrder|DescStr|PageNo|PageSize|page|pageSize|" + searchVal + "|" + searchVal_FilterMode + "|" + searchFormInputAttrs;
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Entity/HighSearchModel.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,30 @@
namespace CmsQueryExtensions.Extension
{
    /// <summary>
    /// é«˜çº§æŸ¥è¯¢å®žä½“
    /// </summary>
    public class HighSearchModel
    {
        public string fieldName { get; set; }
        public string fieldValue { get; set; }
        /// <summary>
        /// ç­›é€‰æ¨¡å¼
        /// </summary>
        public SearchFilterModeEnum filterMode { get; set; }
    }
    /// <summary>
    /// é«˜çº§æ—¥æœŸèŒƒå›´æŸ¥è¯¢å®žä½“
    /// </summary>
    public class HighSearchForDateTimeRangeModel
    {
        public string fieldName { get; set; }
        public string start_fieldValue { get; set; }
        public string end_fieldValue { get; set; }
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/Entity/SearchFilterModeEnum.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
namespace CmsQueryExtensions.Extension
{
    /// <summary>
    /// é€šç”¨æŸ¥è¯¢é…ç½®æ¨¡å¼
    /// </summary>
    public enum SearchFilterModeEnum
    {
        ä¸ç­›é€‰ = 0,
        æ¨¡ç³ŠæŸ¥è¯¢ = 1,
        ç²¾å‡†æŸ¥è¯¢ = 2,
        å¤§äºŽç­‰äºŽ = 3,
        å°äºŽç­‰äºŽ = 4,
        å¤§äºŽ = 5,
        å°äºŽ = 6,
        ä¸ç­‰äºŽ = 7
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/PredicateExtensions/ClassHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,187 @@
using System.Reflection;
namespace CmsQueryExtensions.Extension
{
    /// <summary>
    /// ç±»å¸®åŠ©
    /// </summary>
    public class ClassHelper
    {
        /// <summary>
        /// å®žä½“互转
        /// </summary>
        /// <typeparam name="T">新转换的实体</typeparam>
        /// <typeparam name="S">要转换的实体</typeparam>
        /// <param name="s"></param>
        /// <returns></returns>
        public static T RotationMapping<T, S>(S s)
        {
            T target = Activator.CreateInstance<T>();
            var originalObj = s.GetType();
            var targetObj = typeof(T);
            foreach (PropertyInfo original in originalObj.GetProperties())
            {
                foreach (PropertyInfo t in targetObj.GetProperties())
                {
                    if (t.Name == original.Name)
                    {
                        t.SetValue(target, original.GetValue(s, null), null);
                    }
                }
            }
            return target;
        }
        /// <summary>
        /// èŽ·å–å±žæ€§å¯¹è±¡åˆ—è¡¨
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="proName"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static PropertyInfo[] GetPropertyInfoList<T>(T t)
        {
            var pros = typeof(T).GetProperties();
            return pros;
        }
        /// <summary>
        /// èŽ·å–å±žæ€§å¯¹è±¡
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="proName"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static PropertyInfo GetPropertyInfo<T>(T t, string proName, out string errMsg)
        {
            errMsg = "";
            var pro = typeof(T).GetProperty(proName);
            if (pro == null)
            {
                errMsg = "属性名'" + proName + "'不存在类'" + typeof(T).Name + "'中";
                return null;
            }
            return pro;
        }
        /// <summary>
        /// èŽ·å–å±žæ€§çš„å€¼
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="proName"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static string GetPropertyValue<T>(T t, string proName, out string errMsg)
        {
            var pro = GetPropertyInfo(t, proName, out errMsg);
            if (!string.IsNullOrEmpty(errMsg))
            {
                return string.Empty;
            }
            var pro_value = pro.GetValue(t, null);
            var str = pro_value == null ? string.Empty : Convert.ToString(pro_value);
            return str;
        }
        /// <summary>
        /// èŽ·å–å±žæ€§çš„å€¼
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="proName"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static object GetPropertyValueForReObject<T>(T t, string proName, out string errMsg)
        {
            var pro = GetPropertyInfo(t, proName, out errMsg);
            if (!string.IsNullOrEmpty(errMsg))
            {
                return null;
            }
            var pro_value = pro.GetValue(t, null);
            var str = pro_value == null ? null : (pro_value);
            return str;
        }
        /// <summary>
        /// é€šè¿‡å±žæ€§å¯¹è±¡èŽ·å–å±žæ€§çš„å€¼
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static string GetPropertyValueByObject<T>(T t, PropertyInfo pro)
        {
            var pro_value = pro.GetValue(t, null);
            var str = pro_value == null ? string.Empty : Convert.ToString(pro_value);
            return str;
        }
        /// <summary>
        /// é€šè¿‡å±žæ€§å¯¹è±¡èŽ·å–å±žæ€§çš„å€¼
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static object GetPropertyValue<T>(T t, PropertyInfo pro)
        {
            var pro_value = pro.GetValue(t, null);
            return pro_value;
        }
        /// <summary>
        /// èŽ·å–ç‰¹æ€§ã€é«˜çº§æŸ¥è¯¢èŒƒå›´æŸ¥è¯¢ç‰¹æ€§ã€‘
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static object[] GetHighSearchRangeAttributeByPro(PropertyInfo pro)
        {
            object[] Attributes = pro.GetCustomAttributes(typeof(HighSearchRangeAttribute), false);
            return Attributes;
        }
        /// <summary>
        /// èŽ·å–ç‰¹æ€§ã€ä¸è‡ªåŠ¨æŸ¥è¯¢ç‰¹æ€§ã€‘
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static bool IsExistNoAutoQueryAttribute(PropertyInfo pro)
        {
            object[] attributes = pro.GetCustomAttributes(typeof(NoAutoQueryAttribute), false);
            if (attributes.Length > 0)
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// èŽ·å–å±žæ€§çš„å€¼
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="proName"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static List<string> GetPropertyValueForList<T>(T t, string proName, out string errMsg)
        {
            var pro = GetPropertyInfo(t, proName, out errMsg);
            if (!string.IsNullOrEmpty(errMsg))
            {
                return null;
            }
            var pro_value = pro.GetValue(t, null);
            var list = pro_value == null ? null : (List<string>)pro_value;
            return list;
        }
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/PredicateExtensions/PredicateExtensions.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,223 @@
using System.Linq.Expressions;
namespace CmsQueryExtensions.Extension
{
    internal class ParameterRebinder : ExpressionVisitor
    {
        private readonly Dictionary<ParameterExpression, ParameterExpression> map;
        public ParameterRebinder(Dictionary<ParameterExpression, ParameterExpression> map)
        {
            this.map = map ?? new Dictionary<ParameterExpression, ParameterExpression>();
        }
        public static Expression ReplaceParameters(Dictionary<ParameterExpression, ParameterExpression> map, Expression exp)
        {
            return new ParameterRebinder(map).Visit(exp);
        }
        protected override Expression VisitParameter(ParameterExpression p)
        {
            ParameterExpression replacement;
            if (map.TryGetValue(p, out replacement))
            {
                p = replacement;
            }
            return base.VisitParameter(p);
        }
    }
    internal static class PredicateExtensions
    {
        public static Expression<Func<T, bool>> True<T>() { return f => true; }
        public static Expression<Func<T, bool>> False<T>() { return f => false; }
        public static Expression<T> Compose<T>(this Expression<T> first, Expression<T> second, Func<Expression, Expression, Expression> merge)
        {
            // build parameter map (from parameters of second to parameters of first)
            var map = first.Parameters.Select((f, i) => new { f, s = second.Parameters[i] }).ToDictionary(p => p.s, p => p.f);
            // replace parameters in the second lambda expression with parameters from the first
            var secondBody = ParameterRebinder.ReplaceParameters(map, second.Body);
            // apply composition of lambda expression bodies to parameters from the first expression
            return Expression.Lambda<T>(merge(first.Body, secondBody), first.Parameters);
        }
        public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
        {
            return first.Compose(second, Expression.And);
        }
        public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
        {
            return first.Compose(second, Expression.Or);
        }
        /// <summary>
        /// æ‹¼æŽ¥æˆ c.Name.contains("1111")||c.Name.Contains("2222")||c.Name.Contains("3333")) å½¢å¼
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="options"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> GetConditionExpression<T>(string[] options, string fieldName)
        {
            ParameterExpression left = Expression.Parameter(typeof(T), "c");//c=>
            Expression expression = Expression.Constant(false);
            foreach (var optionName in options)
            {
                Expression right = Expression.Call
                       (
                          Expression.Property(left, typeof(T).GetProperty(fieldName)),  //c.DataSourceName
                          typeof(string).GetMethod("Contains", new Type[] { typeof(string) }),// åå°„使用.Contains()方法
                          Expression.Constant(optionName)           // .Contains(optionName)
                       );
                expression = Expression.Or(right, expression);//c.DataSourceName.contain("") || c.DataSourceName.contain("")
            }
            Expression<Func<T, bool>> finalExpression
                = Expression.Lambda<Func<T, bool>>(expression, new ParameterExpression[] { left });
            return finalExpression;
        }
        /// <summary>
        /// (模糊查询)拼接成 c.Name.contains("1111")||c.Code.Contains("1111")||c.Address.Contains("1111")) å½¢å¼
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="options"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> GetConditionExpressionForFuzzyQuery<T>(string[] fieldNames, string fieldValue)
        {
            try
            {
                ParameterExpression left = Expression.Parameter(typeof(T), "c");//c=>
                Expression expression = Expression.Constant(false);
                foreach (var fieldName in fieldNames)
                {
                    try
                    {
                        Expression right = Expression.Call
                           (
                              Expression.Property(left, typeof(T).GetProperty(fieldName)),  //c.DataSourceName
                              typeof(string).GetMethod("Contains", new Type[] { typeof(string) }),// åå°„使用.Contains()方法
                              Expression.Constant(fieldValue)           // .Contains(fieldValue)
                           );
                        expression = Expression.Or(right, expression);//c.AAA.contain("") || c.BBB.contain("")
                    }
                    catch (Exception ex)
                    {
                        throw new Exception($"参数{fieldName}匹配关键字查询时失败:" + ex.Message);
                    }
                }
                Expression<Func<T, bool>> finalExpression
                    = Expression.Lambda<Func<T, bool>>(expression, new ParameterExpression[] { left });
                return finalExpression;
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// ï¼ˆç²¾å‡†æŸ¥è¯¢ï¼‰æ‹¼æŽ¥æˆ c.Name.equals("1111")||c.Code.equals("1111")||c.Address.equals("1111")) å½¢å¼
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="options"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> GetConditionExpressionForPreciseQuery<T>(string[] fieldNames, string fieldValue)
        {
            ParameterExpression left = Expression.Parameter(typeof(T), "c");//c=>
            Expression expression = Expression.Constant(false);
            foreach (var fieldName in fieldNames)
            {
                Expression right = Expression.Call
                       (
                          Expression.Property(left, typeof(T).GetProperty(fieldName)),  //c.DataSourceName
                          typeof(string).GetMethod("Equals", new Type[] { typeof(string) }),// åå°„使用.Equals()方法
                          Expression.Constant(fieldValue)           // .Equals(fieldValue)
                       );
                expression = Expression.Or(right, expression);//c.AAA.equals("") || c.BBB.equals("")
            }
            Expression<Func<T, bool>> finalExpression
                = Expression.Lambda<Func<T, bool>>(expression, new ParameterExpression[] { left });
            return finalExpression;
        }
        public static Expression<Func<T, bool>> GetConditionExpressionForHighFieldByAnd<T>(List<HighSearchModel> hsmList)
        {
            var whereHelper = new WhereHelper<T>();
            foreach (var field in hsmList)
            {
                switch (field.filterMode)
                {
                    case SearchFilterModeEnum.不等于:
                        whereHelper.NotEqual(field.fieldName, field.fieldValue);
                        break;
                    case SearchFilterModeEnum.大于:
                        whereHelper.GreaterThan(field.fieldName, field.fieldValue);
                        break;
                    case SearchFilterModeEnum.大于等于:
                        whereHelper.GreaterThanOrEqual(field.fieldName, field.fieldValue);
                        break;
                    case SearchFilterModeEnum.小于:
                        whereHelper.LessThan(field.fieldName, field.fieldValue);
                        break;
                    case SearchFilterModeEnum.小于等于:
                        whereHelper.LessThanOrEqual(field.fieldName, field.fieldValue);
                        break;
                    case SearchFilterModeEnum.模糊查询:
                        whereHelper.Contains(field.fieldName, field.fieldValue);
                        break;
                    case SearchFilterModeEnum.精准查询:
                        whereHelper.Equal(field.fieldName, field.fieldValue);
                        break;
                }
            }
            Expression<Func<T, bool>> finalExpression
                = Expression.Lambda<Func<T, bool>>(whereHelper.filter, new ParameterExpression[] { whereHelper.param });
            return finalExpression;
        }
        public static Expression<Func<T, bool>> GetConditionExpressionForHighFieldByAnd<T>(List<HighSearchForDateTimeRangeModel> hsmForDatetimeList)
        {
            var whereHelper = new WhereHelper<T>();
            foreach (var field in hsmForDatetimeList)
            {
                whereHelper.GreaterThanOrEqual(field.fieldName, field.start_fieldValue);
                whereHelper.LessThanOrEqual(field.fieldName, field.end_fieldValue);
            }
            Expression<Func<T, bool>> finalExpression
                = Expression.Lambda<Func<T, bool>>(whereHelper.filter, new ParameterExpression[] { whereHelper.param });
            return finalExpression;
        }
        /// <summary>
        /// æ—¥æœŸèŒƒå›´OR连接
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="hsmForDatetimeList"></param>
        /// <returns></returns>
        public static Expression<Func<T, bool>> GetConditionExpressionForHighDateTimeRangeFieldByOr<T>(List<HighSearchForDateTimeRangeModel> hsmForDatetimeList)
        {
            Expression<Func<T, bool>> finalExpression = null;
            var whereHelper = new WhereHelper<T>();
            foreach (var field in hsmForDatetimeList)
            {
                whereHelper.GreaterThanOrEqual(field.fieldName, field.start_fieldValue);
                whereHelper.LessThanOrEqual(field.fieldName, field.end_fieldValue);
                finalExpression
                = Expression.Lambda<Func<T, bool>>(whereHelper.filter, new ParameterExpression[] { whereHelper.param });
                finalExpression = finalExpression.Or(finalExpression);
            }
            return finalExpression;
        }
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/PredicateExtensions/WhereHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,177 @@
using System;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Reflection;
namespace CmsQueryExtensions.Extension
{
    public class WhereHelper<T>
    //where T : class
    {
        public ParameterExpression param;
        public BinaryExpression filter;
        private MemberExpression common_left;
        private UnaryExpression common_right;
        public WhereHelper()
        {
            param = Expression.Parameter(typeof(T), "c");//构建 c=> ç»“æž„
            //1==1
            Expression left = Expression.Constant(1);
            filter = Expression.Equal(left, left);//构建出 c=> 1=1
        }
        public Expression<Func<T, bool>> GetExpression()
        {
            return Expression.Lambda<Func<T, bool>>(filter, param);
        }
        private void CommonLeftRight(string propertyName, object value)
        {
            common_left = Expression.Property(param, typeof(T).GetProperty(propertyName));//构建构建c.{propertyName}的结构
            var member = Expression.Property(param, propertyName);
            var propertyType = ((PropertyInfo)member.Member).PropertyType;
            var converter = TypeDescriptor.GetConverter(propertyType); // 1
            if (!converter.CanConvertFrom(typeof(string))) // 2
                throw new NotSupportedException();
            var propertyValue = converter.ConvertFromInvariantString(value.ToString()); // 3
            var constant = Expression.Constant(propertyValue);
            common_right = Expression.Convert(constant, propertyType); // 4
            // common_right = Expression.Constant(value, value.GetType());//构建一个常量,值是  value
        }
        /// <summary>
        /// ç­‰äºŽ =
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public void Equal(string propertyName, object value)
        {
            CommonLeftRight(propertyName, value);
            Expression result = Expression.Equal(common_left, common_right);
            filter = Expression.And(filter, result);
        }
        /// <summary>
        /// ä¸ç­‰äºŽ <>
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public void NotEqual(string propertyName, object value)
        {
            CommonLeftRight(propertyName, value);
            Expression result = Expression.NotEqual(common_left, common_right);
            filter = Expression.And(filter, result);
        }
        /// <summary>
        /// å¤§äºŽ >
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public void GreaterThan(string propertyName, object value)
        {
            CommonLeftRight(propertyName, value);
            Expression result = Expression.GreaterThan(common_left, common_right);
            filter = Expression.And(filter, result);
        }
        /// <summary>
        /// å¤§äºŽç­‰äºŽ >=
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public void GreaterThanOrEqual(string propertyName, object value)
        {
            CommonLeftRight(propertyName, value);
            Expression result = Expression.GreaterThanOrEqual(common_left, common_right);
            filter = Expression.And(filter, result);
        }
        /// <summary>
        /// å°äºŽ <
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public void LessThan(string propertyName, object value)
        {
            CommonLeftRight(propertyName, value);
            Expression result = Expression.LessThan(common_left, common_right);
            filter = Expression.And(filter, result);
        }
        /// <summary>
        /// å°äºŽç­‰äºŽ <=
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public void LessThanOrEqual(string propertyName, object value)
        {
            CommonLeftRight(propertyName, value);
            Expression result = Expression.LessThanOrEqual(common_left, common_right);
            filter = Expression.And(filter, result);
        }
        /// <summary>
        /// åŒ…含 LIKE
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public void Contains(string propertyName, string value)
        {
            Expression left = Expression.Property(param, typeof(T).GetProperty(propertyName));
            Expression right = Expression.Constant(value, value.GetType());
            Expression result = Expression.Call(left, typeof(string).GetMethod("Contains", new Type[] { typeof(string) }), right);
            filter = Expression.And(filter, result);
        }
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/queryExtensions/CmsQueryExtensions/Extension/DynamicSearchParameters/WhereConditionsExtensions.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,248 @@
using System.Linq.Expressions;
using System.Reflection;
namespace CmsQueryExtensions.Extension
{
    /// <summary>
    /// ç”ŸæˆWhere条件扩展
    /// </summary>
    public class WhereConditionsExtensions
    {
        public static FunReturnResultModel<Expression<Func<T, bool>>> GetWhereConditions<T, TParam>(TParam param)
        {
            FunReturnResultModel<Expression<Func<T, bool>>> result = new FunReturnResultModel<Expression<Func<T, bool>>>();
            try
            {
                Expression<Func<T, bool>> conditions = PredicateExtensions.True<T>();
                var errMsg = "";
                #region 1、通用查询searchVal
                //判断通用查询searchVal
                var pro_value_searchVal = ClassHelper.GetPropertyValue<TParam>(param, SystemCommonVar.searchVal, out errMsg);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    result.IsSuccess = false;
                    result.ErrMsg = errMsg;
                    return result;
                }
                if (!string.IsNullOrEmpty(pro_value_searchVal))
                {//表示 é€šç”¨æŸ¥è¯¢searchVal不为空,需要查询
                    var pro_value_searchValMode = ClassHelper.GetPropertyValue<TParam>(param, SystemCommonVar.searchVal_FilterMode, out errMsg);
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        result.IsSuccess = false;
                        result.ErrMsg = errMsg;
                        return result;
                    }
                    var pro_value_searchFormInputAttrs = ClassHelper.GetPropertyValueForList<TParam>(param, SystemCommonVar.searchFormInputAttrs, out errMsg);
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        result.IsSuccess = false;
                        result.ErrMsg = errMsg;
                        return result;
                    }
                    if (pro_value_searchFormInputAttrs != null && pro_value_searchFormInputAttrs.Count > 0)
                    {
                        var i_pro_value_searchValMode = Convert.ToInt32(((SearchFilterModeEnum)Enum.Parse(typeof(SearchFilterModeEnum), pro_value_searchValMode)));
                        if (i_pro_value_searchValMode == Convert.ToInt32(SearchFilterModeEnum.模糊查询))
                        {//模糊查询
                            try
                            {
                                var new_conditions = PredicateExtensions.GetConditionExpressionForFuzzyQuery<T>(pro_value_searchFormInputAttrs.ToArray(), pro_value_searchVal);
                                conditions = conditions.And(new_conditions);
                            }
                            catch (Exception ex)
                            {
                                result.data = null;
                                result.IsSuccess = false;
                                result.ErrMsg = ex.Message;
                                return result;
                            }
                        }
                        else if (i_pro_value_searchValMode == Convert.ToInt32(SearchFilterModeEnum.精准查询))
                        {//精准查询
                            var new_conditions = PredicateExtensions.GetConditionExpressionForPreciseQuery<T>(pro_value_searchFormInputAttrs.ToArray(), pro_value_searchVal);
                            conditions = conditions.And(new_conditions);
                            /*
                          pro_value_searchFormInputAttrs.ForEach(x =>
                          {
                            if (!string.IsNullOrEmpty(x))
                            {
                                var myParam = Expression.Parameter(typeof(T));
                                var condition =
Expression.Lambda<Func<T, bool>>(
    Expression.Equal(
        Expression.Property(myParam, x),
        Expression.Constant(pro_value_searchVal, typeof(string))
    ),
    myParam
); // for LINQ to SQl/Entities skip Compile() call
                                conditions = conditions.And(condition);
                        }
                        });
                             //*/
                        }
                        else
                        {
                            result.IsSuccess = false;
                            result.ErrMsg = "通用查询配置不正确";
                            return result;
                        }
                    }
                }
                #endregion
                #region 2、高级查询
                var high_pros = FilterHigh_pros<TParam>(param);
                List<HighSearchForDateTimeRangeModel> hsmForDatetimeList = new List<HighSearchForDateTimeRangeModel>();
                List<HighSearchModel> hsmList = GetHighSearchModelList<TParam>(param, high_pros, ref hsmForDatetimeList);
                if (hsmList.Count > 0)
                {
                    var high_conditions = PredicateExtensions.GetConditionExpressionForHighFieldByAnd<T>(hsmList);
                    conditions = conditions.And(high_conditions);
                }
                if (hsmForDatetimeList.Count > 0)
                {
                    var high_conditions = PredicateExtensions.GetConditionExpressionForHighFieldByAnd<T>(hsmForDatetimeList);
                    conditions = conditions.And(high_conditions);
                }
                #endregion
                result.data = conditions;
                result.IsSuccess = true;
                return result;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// è¿‡æ»¤æŽ‰Mode后缀的属性 å’Œä¸€äº›ç‰¹æ®Šå±žæ€§çš„,如DateTimeRange
        /// </summary>
        /// <typeparam name="TParam"></typeparam>
        /// <param name="param"></param>
        /// <param name="high_pros"></param>
        /// <returns></returns>
        private static List<HighSearchModel> GetHighSearchModelList<TParam>(TParam param, List<PropertyInfo> high_pros, ref List<HighSearchForDateTimeRangeModel> hsmForDatetimeList)
        {
            List<HighSearchModel> hsmList = new List<HighSearchModel>();
            string errMsg = "";
            SearchFilterModeEnum _svmEnum = default(SearchFilterModeEnum);
            var hsmValue = "";
            var pro_value = "";
            foreach (var pro in high_pros)
            {
                if (!pro.Name.Contains(SystemCommonVar.highSearchModeSuffix))
                {//不是Mode后缀的字段
                 //判断是不是有特性特性的值
                    var _highSearchRangeAttribute = ClassHelper.GetHighSearchRangeAttributeByPro(pro);
                    if (_highSearchRangeAttribute.Length > 0)
                    {
                        object v = ClassHelper.GetPropertyValue<TParam>(param, pro);
                        if (v == null)
                        {
                            continue;
                        }
                        List<string> arr_value = v as List<string>;
                        if (arr_value.Count < 2)
                        {
                            continue;
                        }
                        //string[] arr_value = (string[])v;
                        //string[] arr_value = Convert.ToString(v).Split(',');
                        hsmForDatetimeList.Add(new HighSearchForDateTimeRangeModel()
                        {
                            fieldName = pro.Name,
                            start_fieldValue = arr_value[0],
                            end_fieldValue = arr_value[1]
                        });
                        continue;
                    }
                    pro_value = ClassHelper.GetPropertyValueByObject<TParam>(param, pro);
                    if (string.IsNullOrEmpty(pro_value))
                    {
                        continue;
                    }
                    if (!ClassHelper.IsExistNoAutoQueryAttribute(pro))
                    {
                        //查找是相应Mode后缀的字段的值
                        try
                        {
                            //修复查询异常bug ã€Editby shaocx,2025-05-03】
                            SearchFilterModeEnum? _svmEnum_obj = null;
                            _svmEnum_obj = (SearchFilterModeEnum?)ClassHelper.GetPropertyValueForReObject<TParam>(param, pro.Name + SystemCommonVar.highSearchModeSuffix, out errMsg);
                            if (_svmEnum_obj != null) { _svmEnum = _svmEnum_obj.Value; }
                            else
                            {
                                _svmEnum = SearchFilterModeEnum.不筛选;
                            }
                        }
                        catch (Exception ex)
                        {
                            //处理异常信息 ã€Editby shaocx,2025-05-03】
                            _svmEnum = SearchFilterModeEnum.不筛选;
                        }
                        //if (!string.IsNullOrEmpty(errMsg))
                        //{
                        //    throw new Exception(errMsg);
                        //}
                        //if (hsmValue == "0" || string.IsNullOrEmpty(hsmValue))
                        //{
                        //    continue;
                        //}
                        //_svmEnum = (SearchFilterModeEnum)Enum.Parse(typeof(SearchFilterModeEnum), hsmValue);
                        if (_svmEnum == SearchFilterModeEnum.不筛选)
                        {
                            continue;
                        }
                        hsmList.Add(new HighSearchModel()
                        {
                            fieldName = pro.Name,
                            fieldValue = pro_value,
                            filterMode = _svmEnum
                        });
                    }
                }
            }
            return hsmList;
        }
        /// <summary>
        /// è¿‡æ»¤ä¸€äº›ä¸éœ€è¦çš„字段,如Page、PageSize等
        /// </summary>
        /// <typeparam name="TParam"></typeparam>
        /// <param name="param"></param>
        /// <returns></returns>
        private static List<PropertyInfo> FilterHigh_pros<TParam>(TParam param)
        {
            var all_high_pros = ClassHelper.GetPropertyInfoList<TParam>(param);
            var high_pros = new List<PropertyInfo>();
            //排除不用的
            for (int i = 0; i < all_high_pros.Length; i++)
            {
                if (!SystemCommonVar.commnParamFatherPros.Contains(all_high_pros[i].Name))
                {
                    high_pros.Add(all_high_pros[i]);
                }
            }
            return high_pros;
        }
    }
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Application.Contracts/CMS.Plugin.HIAWms.Application.Contracts.csproj
@@ -18,4 +18,10 @@
        <ProjectReference Include="..\CMS.Plugin.HIAWms.Domain.Shared\CMS.Plugin.HIAWms.Domain.Shared.csproj" />
    </ItemGroup>
    <ItemGroup>
      <Reference Include="CmsQueryExtensions">
        <HintPath>..\..\..\..\CommonDLL\CmsQueryExtensions.dll</HintPath>
      </Reference>
    </ItemGroup>
</Project>
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Application.Contracts/Dtos/WmsMaterials/GetWmsMaterialsInput.cs
@@ -1,4 +1,5 @@
using CMS.Plugin.HIAWms.Domain.Shared.Enums;
using CmsQueryExtensions.Extension;
using Volo.Abp.Application.Dtos;
namespace CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsMaterials;
@@ -8,10 +9,45 @@
/// </summary>
public class GetWmsMaterialsInput : ExtensiblePagedAndSortedResultRequestDto
{
    ///// <summary>
    ///// Gets or sets the filter.
    ///// </summary>
    //public string Filter { get; set; }
    #region å…³é”®å­—查询
    /// <summary>
    /// Gets or sets the filter.
    /// å…³é”®å­—模糊查询(注意是小写!)
    /// </summary>
    public string Filter { get; set; }
    public string searchVal { get; set; }
    /// <summary>
    /// é€šç”¨æŸ¥è¯¢é…ç½® (1:模糊查询 , 2:精准查询)(注意是小写!)
    /// </summary>
    public SearchFilterModeEnum searchVal_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// å­æœç´¢ç»„件传递的通用查询配置的属性名(注意是小写!)
    /// </summary>
    [NoAutoQuery]
    public string str_searchFormInputAttrs { get; set; }
    /// <summary>
    /// å­æœç´¢ç»„件传递的通用查询配置的属性名(注意是小写!)
    /// </summary>
    public List<string> searchFormInputAttrs
    {
        get
        {
            if (!string.IsNullOrEmpty(str_searchFormInputAttrs))
            {
                return str_searchFormInputAttrs.Split(',').ToList();
            }
            return new List<string>();
        }
    }
    #endregion
    /// <summary>
    /// Gets or sets the name.
@@ -31,12 +67,12 @@
    /// <summary>
    /// é‡‡è´­ç±»åž‹ï¼ˆæžšä¸¾å€¼ï¼‰
    /// </summary>
    public PurchaseTypeEnum PurchaseType { get; set; }
    public PurchaseTypeEnum? PurchaseType { get; set; }
    /// <summary>
    /// ç‰©æ–™ç±»åž‹ï¼ˆæžšä¸¾å€¼ï¼‰
    /// </summary>
    public MaterialTypeEnum MaterialType { get; set; }
    public MaterialTypeEnum? MaterialType { get; set; }
    /// <summary>
    /// ä¸»å•位(如:kg、m、个)
@@ -51,12 +87,12 @@
    /// <summary>
    /// å¤–径(单位:mm)
    /// </summary>
    public decimal OuterDiameter { get; set; }
    public decimal? OuterDiameter { get; set; }
    /// <summary>
    /// å£åŽšï¼ˆå•ä½ï¼šmm)
    /// </summary>
    public decimal WallThickness { get; set; }
    public decimal? WallThickness { get; set; }
    /// <summary>
    /// æè´¨ï¼ˆå¦‚:304不锈钢)
@@ -66,12 +102,12 @@
    /// <summary>
    /// é•¿åº¦ï¼ˆå•位:m)
    /// </summary>
    public decimal Length { get; set; }
    public decimal? Length { get; set; }
    /// <summary>
    /// æ˜¯å¦ä¸ºä¸»æ”¯ç®¡ï¼ˆtrue: ä¸»æ”¯ç®¡, false: éžä¸»æ”¯ç®¡ï¼‰
    /// </summary>
    public YesNoEnum IsMainBranch { get; set; }
    public YesNoEnum? IsMainBranch { get; set; }
    /// <summary>
    /// ç”Ÿäº§å·¥åŽ‚
@@ -82,4 +118,76 @@
    /// è¯ä¹¦ç¼–号(如:压力容器认证)
    /// </summary>
    public string Certification { get; set; }
    #region æŸ¥è¯¢ç­›é€‰æ¡ä»¶
    /// <summary>
    /// Gets or sets the name.
    /// </summary>
    public SearchFilterModeEnum Name_FilterMode { get; set; } = SearchFilterModeEnum.精准查询;
    /// <summary>
    /// ç‰©æ–™ç¼–码(唯一标识)
    /// </summary>
    public SearchFilterModeEnum MaterialCode_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// ç‰©æ–™åç§°
    /// </summary>
    public SearchFilterModeEnum MaterialName_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// é‡‡è´­ç±»åž‹ï¼ˆæžšä¸¾å€¼ï¼‰
    /// </summary>
    public SearchFilterModeEnum PurchaseType_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// ç‰©æ–™ç±»åž‹ï¼ˆæžšä¸¾å€¼ï¼‰
    /// </summary>
    public SearchFilterModeEnum MaterialType_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// ä¸»å•位(如:kg、m、个)
    /// </summary>
    public SearchFilterModeEnum PrimaryUnit_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// è§„æ ¼/标准(如:GB/T 8163-2018)
    /// </summary>
    public SearchFilterModeEnum Standard_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// å¤–径(单位:mm)
    /// </summary>
    public SearchFilterModeEnum OuterDiameter_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// å£åŽšï¼ˆå•ä½ï¼šmm)
    /// </summary>
    public SearchFilterModeEnum WallThickness_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// æè´¨ï¼ˆå¦‚:304不锈钢)
    /// </summary>
    public SearchFilterModeEnum MaterialQuality_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// é•¿åº¦ï¼ˆå•位:m)
    /// </summary>
    public SearchFilterModeEnum Length_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// æ˜¯å¦ä¸ºä¸»æ”¯ç®¡ï¼ˆtrue: ä¸»æ”¯ç®¡, false: éžä¸»æ”¯ç®¡ï¼‰
    /// </summary>
    public SearchFilterModeEnum IsMainBranch_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// ç”Ÿäº§å·¥åŽ‚
    /// </summary>
    public SearchFilterModeEnum Factory_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    /// <summary>
    /// è¯ä¹¦ç¼–号(如:压力容器认证)
    /// </summary>
    public SearchFilterModeEnum Certification_FilterMode { get; set; } = SearchFilterModeEnum.模糊查询;
    #endregion
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Application/CMS.Plugin.HIAWms.Application.csproj
@@ -18,4 +18,10 @@
        <ProjectReference Include="..\CMS.Plugin.HIAWms.Domain\CMS.Plugin.HIAWms.Domain.csproj" />
    </ItemGroup>
    <ItemGroup>
      <Reference Include="CmsQueryExtensions">
        <HintPath>..\..\..\..\CommonDLL\CmsQueryExtensions.dll</HintPath>
      </Reference>
    </ItemGroup>
</Project>
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsMaterialAppService.cs
@@ -4,6 +4,8 @@
using CMS.Plugin.HIAWms.Domain.Shared.Util;
using CMS.Plugin.HIAWms.Domain.Shared.WmsMaterials;
using CMS.Plugin.HIAWms.Domain.WmsMaterials;
using CmsQueryExtensions.Extension;
using System.Linq.Expressions;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
@@ -42,15 +44,44 @@
            input.Sorting = nameof(WmsMaterial.Sort);
        }
        #region åŠ¨æ€æž„é€ æŸ¥è¯¢æ¡ä»¶
        //动态构造查询条件
        var whereConditions = DynamicGetQueryParams(input);
        #endregion
        var specification = new WmsMaterialSpecification(input.Name);
        var material = ObjectMapper.Map<GetWmsMaterialsInput, WmsMaterial>(input);
        var count = await _wmsmaterialRepository.GetCountAsync(material,input.Filter, specification);
        var count = await _wmsmaterialRepository.GetCountAsync(material, whereConditions, specification);
        var list = await _wmsmaterialRepository.GetListAsync(material,input.Sorting, input.MaxResultCount,  input.SkipCount, input.Filter, specification);
        var list = await _wmsmaterialRepository.GetListAsync(material, whereConditions,input.Sorting, input.MaxResultCount,  input.SkipCount,  specification);
        return new PagedResultDto<WmsMaterialDto>(count, ObjectMapper.Map<List<WmsMaterial>, List<WmsMaterialDto>>(list));
    }
    /// <summary>
    /// åŠ¨æ€æž„é€ æŸ¥è¯¢æ¡ä»¶
    /// </summary>
    /// <param name="input">输入参数</param>
    /// <returns></returns>
    private FunReturnResultModel<Expression<Func<WmsMaterial, bool>>> DynamicGetQueryParams(GetWmsMaterialsInput input)
    {
        //动态构造查询条件
        var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsMaterial, GetWmsMaterialsInput>(input);
        if (!whereConditions.IsSuccess)
        {
            throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg);
        }
        //也可再次自定义构建查询条件
        Expression<Func<WmsMaterial, bool>> extendExpression = a => a.IsDeleted == false;
        // ä½¿ç”¨ System.Linq.PredicateBuilder çš„ And
        var pres = (System.Linq.Expressions.Expression<Func<WmsMaterial, bool>>)(whereConditions.data);
        whereConditions.data = System.Linq.PredicateBuilder.And(pres, extendExpression);
        return whereConditions;
    }
    /// <inheritdoc />
    public virtual async Task<WmsMaterialDto> CreateAsync(WmsMaterialCreateDto input)
    {
@@ -166,7 +197,7 @@
    /// <inheritdoc />
    public virtual async Task AdjustSortAsync(Guid id, int sort)
    {
        var list = await _wmsmaterialRepository.GetListAsync(null, nameof(WmsMaterial.Sort));
        var list = await _wmsmaterialRepository.GetListAsync(null,null, nameof(WmsMaterial.Sort));
        if (list != null && list.Any())
        {
            var initSort = 1;
@@ -320,10 +351,17 @@
            input.Sorting = nameof(WmsMaterial.Sort);
        }
        #region åŠ¨æ€æž„é€ æŸ¥è¯¢æ¡ä»¶
        //动态构造查询条件
        var whereConditions = DynamicGetQueryParams(input);
        #endregion
        var specification = new WmsMaterialSpecification(input.Name);
        var material = ObjectMapper.Map<GetWmsMaterialsInput, WmsMaterial>(input);
        var list = await _wmsmaterialRepository.GetListAsync(material,input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification, includeDetails: true);
        var list = await _wmsmaterialRepository.GetListAsync(material, whereConditions,input.Sorting, input.MaxResultCount, input.SkipCount,  specification, includeDetails: true);
        var result = ObjectMapper.Map<List<WmsMaterial>, List<WmsMaterialDto>>(list);
        var sheets = new Dictionary<string, object>
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Domain/CMS.Plugin.HIAWms.Domain.csproj
@@ -18,4 +18,10 @@
        <ProjectReference Include="..\CMS.Plugin.HIAWms.Domain.Shared\CMS.Plugin.HIAWms.Domain.Shared.csproj" />
    </ItemGroup>
    <ItemGroup>
      <Reference Include="CmsQueryExtensions">
        <HintPath>..\..\..\..\CommonDLL\CmsQueryExtensions.dll</HintPath>
      </Reference>
    </ItemGroup>
</Project>
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.Domain/WmsMaterials/IWmsMaterialRepository.cs
@@ -1,3 +1,5 @@
using CmsQueryExtensions.Extension;
using System.Linq.Expressions;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Specifications;
@@ -41,7 +43,7 @@
    /// <param name="includeDetails">if set to <c>true</c> [include details].</param>
    /// <param name="cancellationToken">The cancellation token.</param>
    /// <returns></returns>
    Task<List<WmsMaterial>> GetListAsync(WmsMaterial material, string sorting = null, int maxResultCount = int.MaxValue,  int skipCount = 0, string filter = null, Specification<WmsMaterial> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default);
    Task<List<WmsMaterial>> GetListAsync(WmsMaterial material, FunReturnResultModel<Expression<Func<WmsMaterial, bool>>> whereConditions, string sorting = null, int maxResultCount = int.MaxValue,  int skipCount = 0, Specification<WmsMaterial> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default);
    /// <summary>
    /// Gets the count asynchronous.
@@ -50,5 +52,5 @@
    /// <param name="specification">The specification.</param>
    /// <param name="cancellationToken">The cancellation token.</param>
    /// <returns></returns>
    Task<long> GetCountAsync(WmsMaterial material, string filter = null, Specification<WmsMaterial> specification = null, CancellationToken cancellationToken = default);
    Task<long> GetCountAsync(WmsMaterial material, FunReturnResultModel<Expression<Func<WmsMaterial, bool>>> whereConditions, Specification<WmsMaterial> specification = null, CancellationToken cancellationToken = default);
}
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/CMS.Plugin.HIAWms.EntityFrameworkCore.csproj
@@ -16,4 +16,10 @@
        <ProjectReference Include="..\CMS.Plugin.HIAWms.Domain\CMS.Plugin.HIAWms.Domain.csproj" />
    </ItemGroup>
    <ItemGroup>
      <Reference Include="CmsQueryExtensions">
        <HintPath>..\..\..\..\CommonDLL\CmsQueryExtensions.dll</HintPath>
      </Reference>
    </ItemGroup>
</Project>
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsMaterialRepository.cs
@@ -4,10 +4,12 @@
using System.Linq.Expressions;
using CMS.Plugin.HIAWms.Domain.WmsMaterials;
using CMS.Plugin.HIAWms.EntityFrameworkCore.Extensions;
using CmsQueryExtensions.Extension;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Specifications;
namespace CMS.Plugin.HIAWms.EntityFrameworkCore.Repositories;
@@ -55,17 +57,18 @@
    }
    /// <inheritdoc />
    public async Task<List<WmsMaterial>> GetListAsync(WmsMaterial? material, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<WmsMaterial> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default)
    public async Task<List<WmsMaterial>> GetListAsync(WmsMaterial? material, FunReturnResultModel<Expression<Func<WmsMaterial, bool>>> whereConditions, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0,  Specification<WmsMaterial> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default)
    {
        specification ??= new WmsMaterialSpecification();
        return await (await GetDbSetAsync())
            .IncludeDetails(includeDetails)
            .Where(specification.ToExpression())
            .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.MaterialCode.Contains(filter))
            .WhereIf(!string.IsNullOrEmpty(material.MaterialName), u => u.MaterialName.Contains(material.MaterialName))
            .WhereIf(!string.IsNullOrEmpty(material.MaterialCode), u => u.MaterialName.Contains(material.MaterialCode))
            .WhereIf(material.MaterialType > 0, u => u.MaterialType == material.MaterialType)
            .WhereIf(material.PurchaseType > 0, u => u.PurchaseType == material.PurchaseType)
            .WhereIf(whereConditions != null, whereConditions.data)
            //.WhereIf(!filter.IsNullOrWhiteSpace(), u => u.MaterialCode.Contains(filter))
            //.WhereIf(!string.IsNullOrEmpty(material.MaterialName), u => u.MaterialName.Contains(material.MaterialName))
            //.WhereIf(!string.IsNullOrEmpty(material.MaterialCode), u => u.MaterialName.Contains(material.MaterialCode))
            //.WhereIf(material.MaterialType > 0, u => u.MaterialType == material.MaterialType)
            //.WhereIf(material.PurchaseType > 0, u => u.PurchaseType == material.PurchaseType)
            .Where(x => !x.IsDeleted)
            .OrderBy(sorting.IsNullOrEmpty() ? nameof(WmsMaterial.Sort) : sorting)
            .PageBy(skipCount, maxResultCount)
@@ -80,20 +83,22 @@
    /// <param name="specification"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    public async Task<long> GetCountAsync(WmsMaterial? material, string filter = null, Specification<WmsMaterial> specification = null, CancellationToken cancellationToken = default)
    public async Task<long> GetCountAsync(WmsMaterial? material, FunReturnResultModel<Expression<Func<WmsMaterial, bool>>> whereConditions, Specification<WmsMaterial> specification = null, CancellationToken cancellationToken = default)
    {
        specification ??= new WmsMaterialSpecification();
        return await (await GetQueryableAsync())
            .Where(specification.ToExpression())
            .WhereIf(!string.IsNullOrEmpty(material.MaterialName), u => u.MaterialName.Contains(material.MaterialName))
            .WhereIf(!string.IsNullOrEmpty(material.MaterialCode), u => u.MaterialName.Contains(material.MaterialCode))
            .WhereIf(material.MaterialType > 0, u => u.MaterialType == material.MaterialType)
            .WhereIf(material.PurchaseType > 0, u => u.PurchaseType == material.PurchaseType)
            .WhereIf(whereConditions != null, whereConditions.data)
            //.WhereIf(!string.IsNullOrEmpty(material.MaterialName), u => u.MaterialName.Contains(material.MaterialName))
            //.WhereIf(!string.IsNullOrEmpty(material.MaterialCode), u => u.MaterialName.Contains(material.MaterialCode))
            //.WhereIf(material.MaterialType > 0, u => u.MaterialType == material.MaterialType)
            //.WhereIf(material.PurchaseType > 0, u => u.PurchaseType == material.PurchaseType)
            .Where(x => !x.IsDeleted)
            .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.MaterialCode.Contains(filter))
            //.WhereIf(!filter.IsNullOrWhiteSpace(), u => u.MaterialCode.Contains(filter))
            .CountAsync(cancellationToken: GetCancellationToken(cancellationToken));
    }
    /// <inheritdoc />
    public override async Task<IQueryable<WmsMaterial>> WithDetailsAsync()
    {
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/server/src/CMS.Plugin.HIAWms/CMS.Plugin.HIAWms.csproj
@@ -56,6 +56,12 @@
    </ItemGroup>
    <ItemGroup>
      <Reference Include="CmsQueryExtensions">
        <HintPath>..\..\..\..\CommonDLL\CmsQueryExtensions.dll</HintPath>
      </Reference>
    </ItemGroup>
    <ItemGroup>
      <Resource Include="Flows\50001_1.pfd">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Resource>
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Weben_CMS_TemplateDemo/web/src/widgets/HIAWms/Views/Pages/WmsMaterial/WmsMaterial.tsx
@@ -66,9 +66,16 @@
   const wmsMaterialQueryDrawerRef=ref(null);
    // æ–°å¢žçš„æŸ¥è¯¢æ¡ä»¶
    const queryForm = ref({
      filter: '',
      searchVal: '',
      str_searchFormInputAttrs:[]
    })
    //定义整体模糊查询的列数组(注意:必须大小写跟后端的实体类属性名一致,否则会导致匹配不对的问题)
    const _searchFormInputAttrs = ref([
      'MaterialCode',
      'MaterialName',
      'Remark'
    ]);
    const searchFormInputAttrs_Placeholder = ref('请输入物料编码/物料名称/备注');
    
    // åŠ¨æ€æžšä¸¾é€‰é¡¹
@@ -109,10 +116,11 @@
    })
    // å®šä¹‰å“åº”式查询数据
    const _curHighQueryData = ref({ filter: '' });
    const _curHighQueryData = ref({ searchVal: '',str_searchFormInputAttrs:[] });
    // æ–°ç‰ˆçš„æŸ¥è¯¢æ–¹æ³•(主页面中的按钮【查询】)
    const handleQueryForMain = async () => {
      _curHighQueryData.value.filter = queryForm.value.filter;
      _curHighQueryData.value.searchVal = queryForm.value.searchVal;
      _curHighQueryData.value.str_searchFormInputAttrs = _searchFormInputAttrs.value;
      tableRef.value.getList(_curHighQueryData.value)
    }
    // æ–°ç‰ˆçš„æŸ¥è¯¢æ–¹æ³•(高级查询中的按钮【查询】)
@@ -123,7 +131,8 @@
    }
    // æ–°ç‰ˆçš„æŸ¥è¯¢é‡ç½®
    const resetQuery = () => {
      queryForm.value.filter = ''
      queryForm.value.searchVal = ''
      queryForm.value.str_searchFormInputAttrs=_searchFormInputAttrs.value;
    }
     //新版的导出方法
     const handleExport=()=>{
@@ -139,7 +148,8 @@
    //保存查询值
    const commonSaveCurHighQueryData=(filteredData={})=>{
      _curHighQueryData.value = { ..._curHighQueryData.value, ...filteredData };
      _curHighQueryData.value.filter = queryForm.value.filter
      _curHighQueryData.value.searchVal = queryForm.value.searchVal
      _curHighQueryData.value.str_searchFormInputAttrs =_searchFormInputAttrs.value;
    }
     //获取高级查询弹出框的查询值
     const commonGetHighQueryForm=(extraParams={})=>{
@@ -151,7 +161,8 @@
        )
      )
      //组合模糊查询
      filteredData.filter = queryForm.value.filter
      filteredData.searchVal = queryForm.value.searchVal
      filteredData.str_searchFormInputAttrs =_searchFormInputAttrs.value;
      return filteredData;
    }
   
@@ -274,8 +285,8 @@
            <ElFormItem style={{ marginTop: '15px' }}>
              <ElFormItem label="关键字">
                <ElInput
                  v-model={queryForm.value.filter}
                  placeholder="请输入关键字搜索"
                  v-model={queryForm.value.searchVal}
                  placeholder={searchFormInputAttrs_Placeholder.value}
                  clearable
                  class={styles.formItem}
                />