From f37485e8f904f1ff1be5613acc6543191e2b4386 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 26 Jul 2024 13:16:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=85=E9=80=89=E4=BF=AE=E8=A7=84=E5=88=99?= =?UTF-8?q?=20=20=E5=8E=82=E5=8C=BA/=E5=91=98=E5=B7=A5/=E9=83=A8=E9=97=A8/?= =?UTF-8?q?=E5=B2=97=E4=BD=8D/=E8=AF=BE=E7=A8=8B/=E5=8E=82=E5=8C=BA=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=9A=E9=80=89=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Services/BASE/BaseServices.cs | 56 +------------------ .../Ghre/Ghre_StudyRuleServices.cs | 53 ++++++------------ 2 files changed, 17 insertions(+), 92 deletions(-) diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index 92f16b3d..7671e9a9 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -762,61 +762,7 @@ public class BaseServices : IBaseServ if (name == "page" || name == "pageSize" || !properties.Any(x => x.Name == name)) continue; if (!string.IsNullOrWhiteSpace(value)) - { - var jsonParam = JsonHelper.JsonToObj(value); - - switch (jsonParam.operationKey) - { - case "Include": - conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'"; - break; - case "NotInclude": - conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'"; - break; - case "IsNull": - conditions += $" AND {name} IS NULL"; - break; - case "NotNull": - conditions += $" AND {name} IS NOT NULL"; - break; - case "Equal": - conditions += $" AND {name} ='{jsonParam.columnValue}'"; - break; - case "NotEqual": - conditions += $" AND {name} !='{jsonParam.columnValue}'"; - break; - case "GreaterOrEqual"://大于等于 - conditions += $" AND {name} >='{jsonParam.columnValue}'"; - break; - case "Greater"://大于 - conditions += $" AND {name} >'{jsonParam.columnValue}'"; - break; - case "LessOrEqual"://小于等于 - conditions += $" AND {name} <='{jsonParam.columnValue}'"; - break; - case "Less"://小于 - conditions += $" AND {name} <'{jsonParam.columnValue}'"; - break; - case "EqualAny":// - if (jsonParam.columnValue != null) - { - var ids = JsonHelper.JsonToObj>(jsonParam.columnValue.ToString()); - - conditions += $" AND {name} IN ({string.Join(",", ids.Select(id => "'" + id + "'"))})"; - } - break; - case "NotEqualAny":// - if (jsonParam.columnValue != null) - { - var ids = JsonHelper.JsonToObj>(jsonParam.columnValue.ToString()); - - conditions += $" AND {name} NOT IN ({string.Join(",", ids.Select(id => "'" + id + "'"))})"; - } - break; - default: - break; - } - } + conditions = DealConditions(conditions, name, value); } sql += conditions; diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs index 6da7b797..5b4312e1 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs @@ -67,53 +67,32 @@ public class Ghre_StudyRuleServices : BaseServices(value); - // conditions += $" AND (Date BETWEEN '{jsonParam.columnValue[0]}' AND '{jsonParam.columnValue[1]}')"; - - // continue; - //} - if (!string.IsNullOrWhiteSpace(value)) + if (name == "StaffId") { - var jsonParam = JsonConvert.DeserializeObject(value); + var jsonParam = JsonHelper.JsonToObj(value); + var ids1 = JsonHelper.JsonToObj>(jsonParam.columnValue.ToString()); + if (ids1 is null) + continue; + string sql1 = $"SELECT DISTINCT B.Id from Ghre_StudyRuleStaff A join Ghre_StudyRule B ON A.StudyRuleId = B.ID WHERE B.IsEnable=1 AND A.StaffId IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))})"; + ids1 = await Db.Ado.SqlQueryAsync(sql1); switch (jsonParam.operationKey) { - case "Include": - conditions += $" AND {name} LIKE '%{jsonParam.columnValue}%'"; - break; - case "NotInclude": - conditions += $" AND {name} NOT LIKE '%{jsonParam.columnValue}%'"; - break; - case "IsNull": - conditions += $" AND {name} IS NULL"; - break; - case "NotNull": - conditions += $" AND {name} IS NOT NULL"; - break; - case "Equal": - conditions += $" AND {name} ='{jsonParam.columnValue}'"; - break; - case "NotEqual": - conditions += $" AND {name} !='{jsonParam.columnValue}'"; + case "EqualAny":// + conditions += $" AND Id IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))})"; break; - case "GreaterOrEqual"://大于等于 - conditions += $" AND {name} >='{jsonParam.columnValue}'"; - break; - case "Greater"://大于 - conditions += $" AND {name} >'{jsonParam.columnValue}'"; - break; - case "LessOrEqual"://小于等于 - conditions += $" AND {name} <='{jsonParam.columnValue}'"; - break; - case "Less"://小于 - conditions += $" AND {name} <'{jsonParam.columnValue}'"; + case "NotEqualAny":// + conditions += $" AND Id NOT IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))})"; + break; default: break; } + + continue; } + if (!string.IsNullOrWhiteSpace(value)) + conditions = DealConditions(conditions, name, value); } sql += conditions;