From a407d85032a312cd93513d24e1bd34219e3aa3c9 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期四, 12 六月 2025 16:00:12 +0800 Subject: [PATCH] 增强任务命令以处理火警报警情况 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs | 126 ++++++++++++++++++++++++++++++++++------- 1 files changed, 103 insertions(+), 23 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs index ee18736..71e0481 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/BaseServices/ServiceBase.cs @@ -60,6 +60,73 @@ } + //protected string ValidatePageOptions(PageDataOptions options) + //{ + // options = options ?? new PageDataOptions(); + // string where = ""; + // List<SearchParameters> searchParametersList = new List<SearchParameters>(); + // if (options.Filter != null && options.Filter.Count > 0) + // { + // searchParametersList.AddRange(options.Filter); + // } + // else if (!string.IsNullOrEmpty(options.Wheres)) + // { + // try + // { + // searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>(); + // options.Filter = searchParametersList; + // } + // catch { } + // } + // QueryRelativeList?.Invoke(searchParametersList); + + // for (int i = 0; i < searchParametersList.Count; i++) + // { + // if (string.IsNullOrEmpty(searchParametersList[i].Value)) + // { + // continue; + // } + + // PropertyInfo property = TProperties.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} like '%{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; + //} + protected string ValidatePageOptions(PageDataOptions options) { options = options ?? new PageDataOptions(); @@ -91,38 +158,48 @@ if (property == null) continue; - List<(bool, string, object)> results = property.ValidationValueForDbType(searchParametersList[i].Value.Split(',')).ToList(); - if (results == null || results.Count() == 0) + (bool, string, object) result = property.ValidationVal(searchParametersList[i].Value); + if (!result.Item1) { 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} like '%{results[j].Item3}%'"; - } - else - { - where += $"{searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{results[j].Item3}'"; - } - if (j == results.Count() - 1) + LinqExpressionType expressionType = searchParametersList[i].DisplayType.GetLinqCondition(); + if (expressionType == LinqExpressionType.Equal) + { + if (string.IsNullOrEmpty(where)) { - where += ")"; + // 閽堝瀛楃涓茬被鍨嬬殑瀛楁浣跨敤妯$硦鏌ヨ + //where += $"{searchParametersList[i].Name} like '%{searchParametersList[i].Value}%'"; + if (searchParametersList[i].Value.ToLower() == "true" || searchParametersList[i].Value.ToLower() == "false") + { + where += $" {searchParametersList[i].Name} = '{searchParametersList[i].Value.ToLower()}'"; + } + else + { + where += $"{searchParametersList[i].Name} like '%{searchParametersList[i].Value}%'"; + } } else { - where += " or "; + // 閽堝甯冨皵绫诲瀷瀛楁杩涜绮剧‘鏌ヨ + if (searchParametersList[i].Value.ToLower() == "true" || searchParametersList[i].Value.ToLower() == "false") + { + where += $" and {searchParametersList[i].Name} = '{searchParametersList[i].Value.ToLower()}'"; + } + else + { + where += $" and {searchParametersList[i].Name} like '%{searchParametersList[i].Value}%'"; + } } } - if (i < searchParametersList.Count - 1) - where += " and "; + else + { + if (string.IsNullOrEmpty(where)) + where += $"{searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{searchParametersList[i].Value}'"; + else + where += $" and {searchParametersList[i].Name} {searchParametersList[i].DisplayType} '{searchParametersList[i].Value}'"; + } } return where; } @@ -225,7 +302,10 @@ { return WebResponseContent.Instance.Error("浼犲弬閿欒,鍙傛暟涓嶈兘涓虹┖"); } - string validResult = typeof(TEntity).ValidateDicInEntity(saveModel.MainData, true, TProperties); + + var x = saveModel.MainData; + + string validResult = typeof(TEntity).ValidateDicInEntity(x, true, TProperties); if (!string.IsNullOrEmpty(validResult)) { -- Gitblit v1.9.3