| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Abp.Extensions;
- using IwbZero.AppServiceBase;
- using ShwasherSys.Common.Dto;
- using ShwasherSys.Lambda;
- namespace ShwasherSys.Common
- {
- public static class ProductModelSearch
- {
- /// <summary>
- /// model 查询条件分割后是否有多个
- /// </summary>
- /// <param name="searchDto"></param>
- /// <returns>true:有多个</returns>
- public static bool CheckModelGreaterOneFilter(MultiSearchDto searchDto,ref object kw)
- {
- bool result = false;
- object keyWords = searchDto.KeyWords;
- if (searchDto.KeyField == "model")
- {
- var arrModels = (keyWords + "").Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- result = arrModels.Length > 1;
- kw = result?arrModels[0]: kw;
- }
- return result;
- }
- /// <summary>
- /// model 查询条件分割后是否有多个
- /// </summary>
- /// <param name="searchDto"></param>
- /// <returns>true:有多个</returns>
- public static bool CheckModelGreaterOneFilter(MultiSearchDto searchDto)
- {
- bool result = false;
- object keyWords = searchDto.KeyWords;
- if (searchDto.KeyField == "model")
- {
- var arrModels = (keyWords + "").Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- result = arrModels.Length > 1;
- }
- return result;
- }
- /// <summary>
- /// 获取产品规格的正则表达式
- /// </summary>
- /// <param name="searchList"></param>
- /// <returns></returns>
- public static string GetModelGreaterOneReg(List<MultiSearchDto> searchList)
- {
- string result = "";
- if (searchList != null && searchList.Count > 0)
- {
- foreach (var o in searchList)
- {
- if (o.KeyWords.IsNullOrEmpty())
- continue;
- object keyWords = o.KeyWords;
- if (ProductModelSearch.CheckModelGreaterOneFilter(o))
- {
- result = GetModelGreaterOneReg(o);
- }
- }
- }
-
- return result;
- }
- /// <summary>
- /// 获取产品规格的正则表达式
- /// </summary>
- /// <param name="searchList"></param>
- /// <returns></returns>
- public static string GetModelGreaterOneReg(List<MultiSearchDtoExt> searchList)
- {
- string result = "";
- if (searchList != null && searchList.Count > 0)
- {
- foreach (var o in searchList)
- {
- if (o.KeyWords.IsNullOrEmpty())
- continue;
- object keyWords = o.KeyWords;
- if (ProductModelSearch.CheckModelGreaterOneFilter(o))
- {
- result = GetModelGreaterOneReg(o);
- }
- }
- }
- return result;
- }
- public static string GetModelGreaterOneReg(MultiSearchDto searchDto)
- {
- string result = "";
- object keyWords = searchDto.KeyWords;
- if (searchDto.KeyField == "model")
- {
- var arrModels = (keyWords + "").Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- foreach (var item in arrModels)
- {
- result += ".*" + item;
- }
- }
- return result;
- }
-
- public static void AddModelFilterToLamb(this List<LambdaObject> objList,MultiSearchDto searchDto)
- {
- object keyWords = searchDto.KeyWords;
- if (searchDto.KeyField == "model")
- {
- //modelQuery = keyWords+"";
- var arrModels = (keyWords + "").Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- if (arrModels.Length > 0)
- {
- foreach (var arrModel in arrModels)
- {
- objList.Add(new LambdaObject
- {
- FieldType = (LambdaFieldType)searchDto.FieldType,
- FieldName = searchDto.KeyField,
- FieldValue = arrModel,
- ExpType = (LambdaExpType)searchDto.ExpType,
- });
- }
- }
- }
- }
- }
- }
|