¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | <ImplicitUsings>enable</ImplicitUsings> |
| | | <Nullable>enable</Nullable> |
| | | </PropertyGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | 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 |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | |
| | | namespace CmsQueryExtensions.Extension |
| | | { |
| | | /// <summary> |
| | | /// é«çº§æ¥è¯¢èå´æ¥è¯¢ç¹æ§ |
| | | /// </summary> |
| | | public class HighSearchRangeAttribute : Attribute |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | |
| | | namespace CmsQueryExtensions.Extension |
| | | { |
| | | /// <summary> |
| | | /// ä¸èªå¨æ¥è¯¢ç¹æ§ |
| | | /// ç¨äºä¸éè¦èªå¨åè§£æ¥è¯¢çåæ®µ |
| | | /// </summary> |
| | | public class NoAutoQueryAttribute : Attribute |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CmsQueryExtensions.Extension |
| | | { |
| | | /// <summary> |
| | | /// éç¨æ¥è¯¢é
ç½®æ¨¡å¼ |
| | | /// </summary> |
| | | public enum SearchFilterModeEnum |
| | | { |
| | | ä¸çé = 0, |
| | | æ¨¡ç³æ¥è¯¢ = 1, |
| | | ç²¾åæ¥è¯¢ = 2, |
| | | 大äºçäº = 3, |
| | | å°äºçäº = 4, |
| | | å¤§äº = 5, |
| | | å°äº = 6, |
| | | ä¸çäº = 7 |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | <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> |
| | |
| | | using CMS.Plugin.HIAWms.Domain.Shared.Enums; |
| | | using CmsQueryExtensions.Extension; |
| | | using Volo.Abp.Application.Dtos; |
| | | |
| | | namespace CMS.Plugin.HIAWms.Application.Contracts.Dtos.WmsMaterials; |
| | |
| | | /// </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. |
| | |
| | | /// <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ãä¸ªï¼ |
| | |
| | | /// <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ä¸éé¢ï¼ |
| | |
| | | /// <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> |
| | | /// ç产工å |
| | |
| | | /// è¯ä¹¦ç¼å·ï¼å¦ï¼åå容å¨è®¤è¯ï¼ |
| | | /// </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 |
| | | } |
| | |
| | | <ProjectReference Include="..\CMS.Plugin.HIAWms.Domain\CMS.Plugin.HIAWms.Domain.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Reference Include="CmsQueryExtensions"> |
| | | <HintPath>..\..\..\..\CommonDLL\CmsQueryExtensions.dll</HintPath> |
| | | </Reference> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
| | |
| | | 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; |
| | |
| | | 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) |
| | | { |
| | |
| | | /// <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; |
| | |
| | | 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> |
| | |
| | | <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> |
| | |
| | | using CmsQueryExtensions.Extension; |
| | | using System.Linq.Expressions; |
| | | using Volo.Abp.Domain.Repositories; |
| | | using Volo.Abp.Specifications; |
| | | |
| | |
| | | /// <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. |
| | |
| | | /// <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); |
| | | } |
| | |
| | | <ProjectReference Include="..\CMS.Plugin.HIAWms.Domain\CMS.Plugin.HIAWms.Domain.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Reference Include="CmsQueryExtensions"> |
| | | <HintPath>..\..\..\..\CommonDLL\CmsQueryExtensions.dll</HintPath> |
| | | </Reference> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
| | |
| | | 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; |
| | | |
| | |
| | | } |
| | | |
| | | /// <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) |
| | |
| | | /// <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() |
| | | { |
| | |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Reference Include="CmsQueryExtensions"> |
| | | <HintPath>..\..\..\..\CommonDLL\CmsQueryExtensions.dll</HintPath> |
| | | </Reference> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Resource Include="Flows\50001_1.pfd"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </Resource> |
| | |
| | | const wmsMaterialQueryDrawerRef=ref(null); |
| | | // æ°å¢çæ¥è¯¢æ¡ä»¶ |
| | | const queryForm = ref({ |
| | | filter: '', |
| | | searchVal: '', |
| | | str_searchFormInputAttrs:[] |
| | | }) |
| | | |
| | | //å®ä¹æ´ä½æ¨¡ç³æ¥è¯¢çåæ°ç»(注æï¼å¿
须大å°åè·å端çå®ä½ç±»å±æ§åä¸è´ï¼å¦åä¼å¯¼è´å¹é
ä¸å¯¹çé®é¢) |
| | | const _searchFormInputAttrs = ref([ |
| | | 'MaterialCode', |
| | | 'MaterialName', |
| | | 'Remark' |
| | | ]); |
| | | const searchFormInputAttrs_Placeholder = ref('请è¾å
¥ç©æç¼ç /ç©æåç§°/夿³¨'); |
| | | |
| | | |
| | | // 卿æä¸¾é项 |
| | |
| | | }) |
| | | |
| | | // å®ä¹ååºå¼æ¥è¯¢æ°æ® |
| | | 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) |
| | | } |
| | | // æ°ççæ¥è¯¢æ¹æ³ï¼é«çº§æ¥è¯¢ä¸çæé®ãæ¥è¯¢ãï¼ |
| | |
| | | } |
| | | // æ°ççæ¥è¯¢éç½® |
| | | const resetQuery = () => { |
| | | queryForm.value.filter = '' |
| | | queryForm.value.searchVal = '' |
| | | queryForm.value.str_searchFormInputAttrs=_searchFormInputAttrs.value; |
| | | } |
| | | //æ°ççå¯¼åºæ¹æ³ |
| | | const handleExport=()=>{ |
| | |
| | | //ä¿åæ¥è¯¢å¼ |
| | | 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={})=>{ |
| | |
| | | ) |
| | | ) |
| | | //ç»åæ¨¡ç³æ¥è¯¢ |
| | | filteredData.filter = queryForm.value.filter |
| | | filteredData.searchVal = queryForm.value.searchVal |
| | | filteredData.str_searchFormInputAttrs =_searchFormInputAttrs.value; |
| | | return filteredData; |
| | | } |
| | | |
| | |
| | | <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} |
| | | /> |