From 733e63cb362f17aea4a1020654fa348a0d0c1f06 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 24 二月 2025 00:08:59 +0800
Subject: [PATCH] 优化入库逻辑,优化直接出库逻辑,优化移库任务逻辑
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs | 134 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 134 insertions(+), 0 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs"
new file mode 100644
index 0000000..5cc9914
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseModels/PageDataOptions.cs"
@@ -0,0 +1,134 @@
+锘縰sing SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
+using WIDESEA_Core.Utilities;
+
+namespace WIDESEA_Core
+{
+ public class PageDataOptions
+ {
+ public int Page { get; set; }
+ public int Rows { get; set; }
+ public int Total { get; set; }
+ public string TableName { get; set; }
+ public string Sort { get; set; }
+ /// <summary>
+ /// 鎺掑簭鏂瑰紡
+ /// </summary>
+ public string Order { get; set; }
+ public string Wheres { get; set; }
+ public bool Export { get; set; }
+ public object Value { get; set; }
+ /// <summary>
+ /// 鏌ヨ鏉′欢
+ /// </summary>
+ public List<SearchParameters> Filter { get; set; }
+
+ public string ValidatePageOptions(PropertyInfo[] entityProperties)
+ {
+ string where = string.Empty;
+ List<SearchParameters> searchParametersList = new List<SearchParameters>();
+ if (this.Filter != null && this.Filter.Count > 0)
+ {
+ searchParametersList.AddRange(Filter);
+ }
+ else if (!string.IsNullOrEmpty(Wheres))
+ {
+ try
+ {
+ searchParametersList = Wheres.DeserializeObject<List<SearchParameters>>();
+ Filter = searchParametersList;
+ }
+ catch { }
+ }
+ for (int i = 0; i < searchParametersList.Count; i++)
+ {
+ if (string.IsNullOrEmpty(searchParametersList[i].Value))
+ {
+ continue;
+ }
+
+ PropertyInfo? property = entityProperties.Where(c => c.Name.ToUpper() == searchParametersList[i].Name.ToUpper()).FirstOrDefault();
+
+ if (property == null) continue;
+
+ List<(bool, string, object)> results = property.ValidationValueForDbType(searchParametersList[i].Value.Split(',')).ToList();
+ if (results == null || results.Count() == 0)
+ {
+ continue;
+ }
+ for (int j = 0; j < results.Count(); j++)
+ {
+ if (j == 0)
+ {
+ where += "(";
+ }
+ LinqExpressionType expressionType = searchParametersList[i].DisplayType.GetLinqCondition();
+ if (expressionType == LinqExpressionType.Equal)
+ {
+ where += $"{searchParametersList[i].Name} = '{results[j].Item3}'";
+ }
+ else if (expressionType == LinqExpressionType.Contains)
+ {
+ where += $"{searchParametersList[i].Name} {searchParametersList[i].DisplayType} '%{results[j].Item3}%'";
+ }
+ else
+ {
+ where += $"{searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{results[j].Item3}'";
+ }
+
+ if (j == results.Count() - 1)
+ {
+ where += ")";
+ }
+ else
+ {
+ where += " or ";
+ }
+ }
+ if (i < searchParametersList.Count - 1)
+ where += " and ";
+ }
+ return where;
+ }
+
+
+ public Dictionary<string, OrderByType> GetPageDataSort(PropertyInfo[] propertyInfo)
+ {
+ if (!string.IsNullOrEmpty(Sort))
+ {
+ if (Sort.Contains(","))
+ {
+ List<string> sortArr = Sort.Split(",").Where(x => propertyInfo.Any(p => p.Name == x)).ToList();
+ Dictionary<string, OrderByType> sortDic = new Dictionary<string, OrderByType>();
+ foreach (var item in sortArr)
+ {
+ sortDic[item] = Order?.ToLower() == OrderByType.Asc.ToString().ToLower() ? OrderByType.Asc : OrderByType.Desc;
+ }
+ return sortDic;
+ }
+ else if (propertyInfo.Any(x => x.Name == Sort.FirstLetterToLower() || x.Name == Sort.FirstLetterToUpper()))
+ {
+ return new Dictionary<string, OrderByType> {
+ {
+ Sort,Order?.ToLower() == OrderByType.Asc.ToString().ToLower() ? OrderByType.Asc : OrderByType.Desc
+ } };
+ }
+ }
+ return new Dictionary<string, OrderByType> { { "CreateDate", Order?.ToLower() == OrderByType.Asc.ToString().ToLower() ? OrderByType.Asc : OrderByType.Desc } };
+ }
+ }
+ public class SearchParameters
+ {
+ public string Name { get; set; }
+ public string Value { get; set; }
+ //鏌ヨ绫诲瀷锛歀inqExpressionType
+ public string DisplayType { get; set; }
+ }
+}
--
Gitblit v1.9.3