From 6ad4a82247449c6c1d037241a33c641823cdc56c Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Wed, 2 Apr 2025 15:05:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EESS=E7=AB=AF=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E9=97=AE=E5=8D=B7=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20=E5=9F=B9=E8=AE=AD=E8=AE=B0=E5=BD=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=88=97=E5=86=BB=E7=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Model/ViewModels/Menu.cs | 16 +++++- Tiobon.Core.Services/CommonServices.cs | 38 ++++++++++++- .../Ghra/Ghra_TitleServices.cs | 29 ++++++++-- .../Ghre/Ghre_SurveyServices.cs | 54 ++++++++++++++++--- 4 files changed, 124 insertions(+), 13 deletions(-) diff --git a/Tiobon.Core.Model/ViewModels/Menu.cs b/Tiobon.Core.Model/ViewModels/Menu.cs index 07c7ce4b..0414390d 100644 --- a/Tiobon.Core.Model/ViewModels/Menu.cs +++ b/Tiobon.Core.Model/ViewModels/Menu.cs @@ -1,4 +1,6 @@ -namespace Tiobon.Core.Model; +using Newtonsoft.Json.Linq; + +namespace Tiobon.Core.Model; public class MenuParam { @@ -36,6 +38,16 @@ public class ModuleParam public string timestamp { get; set; } public string token { get; set; } public ModulejsonParam jsonParam { get; set; } + + private JObject _jsonParam; + public JObject jsonParam1 + { + get { return _jsonParam; } + set + { + _jsonParam = value; + } + } } public class ModulejsonParam { @@ -100,6 +112,7 @@ public class TableColumn public int width { get; set; } public string align { get; set; } public string fixed1 { get; set; } + public bool? @fixed { get; set; } public bool? editable { get; set; } public bool? searchable { get; set; } public bool? searchRequired { get; set; } @@ -147,6 +160,7 @@ public class TableColumn1 public string filterable { get; set; } public int width { get; set; } public string align { get; set; } + public bool? @fixed { get; set; } public string fixed1 { get; set; } public string editable { get; set; } public string searchable { get; set; } diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index d30e9a1d..9750c527 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using SqlSugar.Extensions; using System.Text.RegularExpressions; namespace Tiobon.Core.Services; @@ -784,7 +785,7 @@ public partial class CommonServices : BaseServices>, ICommon sql = @"select pageColumnID,elementType, field,label,meky, multipleSelect, dataType, required, palceholder, dataSourceType,dataSource, sortable, sortOrder, - defaultHidden, ConfigIsShow, filterable, width,align, fixed,editable, searchable, + defaultHidden, ConfigIsShow, filterable, width,align,fixed fixed1,editable, searchable, searchRequired,searchColumnSeq, multipleSearchValue, maxTagCount, selfDefine, selectUI, isPrimaryKey,isSorted,isHidden,isSearched,sortNo, ( select ParaDetailNo operator, @@ -805,6 +806,7 @@ public partial class CommonServices : BaseServices>, ICommon result.JM_TableColumnT1.TableColumn = result.JM_TableColumnT1.TableColumn.Where(x => x.field != "DetailYN" && x.field != "Muti").ToList(); result.JM_TableColumnT1.TableColumn.ForEach(x => { + if (x.fixed1.IsNotEmptyOrNull()) x.@fixed = x.fixed1.ObjToBool(); if (!string.IsNullOrWhiteSpace(x.searchOperator1)) x.searchOperator = JsonConvert.DeserializeObject>(x.searchOperator1); x.searchOperator1 = null; @@ -2383,6 +2385,40 @@ public partial class CommonServices : BaseServices>, ICommon sort = column.SortNo; result.JM_TableColumnT1.TableColumn = result.JM_TableColumnT1.TableColumn.Where(x => x.field != "Title_A01").ToList(); var titles = await Db.Queryable().OrderBy(x => x.SortNo).ToListAsync(); + if (param.jsonParam1 != null) + foreach (JProperty jProperty in param.jsonParam1.Properties()) + { + var name = jProperty.Name; + var value = jProperty.Value.ToString(); + if (name == "page" || name == "pageSize") + continue; + if (value.IsNotEmptyOrNull()) + { + var jsonParam = JsonHelper.JsonToObj(value); + + switch (name) + { + case "TitleId": + switch (jsonParam.operationKey) + { + case "Include": + if (jsonParam.columnValue != null) + titles = titles.Where(x => x.TitleID == jsonParam.columnValue.ObjToInt()).ToList(); + break; + case "NotInclude": + if (jsonParam.columnValue != null) + titles = titles.Where(x => x.TitleID != jsonParam.columnValue.ObjToInt()).ToList(); + break; + default: + break; + } + break; + + default: + break; + } + } + } index = 0; titles.ForEach(x => { diff --git a/Tiobon.Core.Services/Ghra/Ghra_TitleServices.cs b/Tiobon.Core.Services/Ghra/Ghra_TitleServices.cs index 62f516f0..53626057 100644 --- a/Tiobon.Core.Services/Ghra/Ghra_TitleServices.cs +++ b/Tiobon.Core.Services/Ghra/Ghra_TitleServices.cs @@ -1,4 +1,7 @@ -namespace Tiobon.Core.Services; +using Tiobon.Core.Common; +using static StackExchange.Redis.Role; + +namespace Tiobon.Core.Services; /// /// 岗位 (服务) @@ -28,7 +31,6 @@ public class Ghra_TitleServices : BaseServices(); if (string.IsNullOrWhiteSpace(filter.orderBy)) filter.orderBy = "Type ASC"; @@ -52,6 +54,7 @@ public class Ghra_TitleServices : BaseServices>(x.GradeId); }); + var titles = await Db.Queryable().OrderBy(x => x.SortNo).ToListAsync(); #region 处理查询条件 //Expression> whereExpression = new Expression>(); @@ -117,10 +120,12 @@ public class Ghra_TitleServices : BaseServices x.TitleIds.Contains(jsonParam.columnValue.ObjToInt())).ToList(); + titles = titles.Where(x => x.TitleID == jsonParam.columnValue.ObjToInt()).ToList(); break; case "NotInclude": if (jsonParam.columnValue != null) rules = rules.Where(x => !x.TitleIds.Contains(jsonParam.columnValue.ObjToInt())).ToList(); + titles = titles.Where(x => x.TitleID != jsonParam.columnValue.ObjToInt()).ToList(); break; case "IsNull": rules = rules.Where(x => x.TitleIds.Count == 0).ToList(); @@ -187,6 +192,22 @@ public class Ghra_TitleServices : BaseServices x.CourseId != jsonParam.columnValue.ObjToLong()).ToList(); sql += $" AND Id !={jsonParam.columnValue}"; + break; + case "EqualAny":// + if (jsonParam.columnValue != null) + { + var ids1 = JsonHelper.JsonToObj>(jsonParam.columnValue.ToString()); + + sql += $" AND Id IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))})"; + } + break; + case "NotEqualAny":// + if (jsonParam.columnValue != null) + { + var ids1 = JsonHelper.JsonToObj>(jsonParam.columnValue.ToString()); + + sql += $" AND ( Id NOT IN ({string.Join(",", ids1.Select(id => "'" + id + "'"))}) OR {name} IS NULL)"; + } break; default: break; @@ -212,7 +233,8 @@ public class Ghra_TitleServices : BaseServices(filter.pageNum, totalCount, filter.pageSize, list); @@ -220,7 +242,6 @@ public class Ghra_TitleServices : BaseServices().OrderBy(x => x.SortNo).ToListAsync(); var dict = new Dictionary>(); diff --git a/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs b/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs index 00823910..37631363 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs @@ -1,4 +1,5 @@ -using MathNet.Numerics.Distributions; +using Google.Protobuf.WellKnownTypes; +using MathNet.Numerics.Distributions; using Tiobon.Core.Common; namespace Tiobon.Core.Services; @@ -231,6 +232,14 @@ public class Ghre_SurveyServices : BaseServices x.SurveyQuestionId == question.Id).Select(x => x.OptionContent).ToList(); + + if (question.Options.Where(x => question.Value1.Contains(x.OptionNo) && x.IsOther == true).Any()) + question.Options.ForEach(o => + { + if (question.Value1.Contains(o.OptionNo) && o.IsOther == true) + o.OtherContent = recordOptions.Where(x => x.SurveyQuestionId == question.Id && x.SurveyQuestionOptionId == o.Id) + .Select(x => x.Reverse1).FirstOrDefault() ?? ""; + }); break; case "Single": @@ -238,8 +247,13 @@ public class Ghre_SurveyServices : BaseServices x.SurveyQuestionId == question.Id).Select(x => x.OptionContent).Any() ? recordOptions.Where(x => x.SurveyQuestionId == question.Id).Select(x => x.OptionContent).FirstOrDefault() : ""; - + question.Value = recordOptions.Where(x => x.SurveyQuestionId == question.Id).Select(x => x.OptionContent).FirstOrDefault() ?? ""; + if (question.Options.Where(x => x.OptionNo == question.Value && x.IsOther == true).Any()) + question.Options.ForEach(o => + { + if (o.OptionNo == question.Value && o.IsOther == true) + o.OtherContent = recordOptions.Where(x => x.SurveyQuestionId == question.Id).Select(x => x.Reverse1).FirstOrDefault() ?? ""; + }); break; default: @@ -314,19 +328,45 @@ public class Ghre_SurveyServices : BaseServices x.OptionNo == question.Value1[j]).FirstOrDefault()?.Id; + + var questionOption1 = question.Options.Where(x => x.OptionNo == question.Value1[j]).FirstOrDefault(); + + option1.SurveyQuestionOptionId = questionOption1?.Id; option1.OptionContent = question.Value1[j]; + + if (questionOption1.IsOther == true) + option1.Reverse1 = questionOption1.OtherContent; await Db.Insertable(option1).ExecuteReturnSnowflakeIdAsync(); } break; case "Single": - case "ShortAnswer": case "SingleScore": + var option = new Ghre_SurveyRecordOption() + { + SurveyId = id, + SurveyRecordId = recordId, + SurveyRecordDetailId = recordDetailId, + SurveyQuestionId = question.Id, + //SurveyQuestionOptionId = x.Id, + StaffId = App.User.StaffId, + Score = 0 + }; + var questionOption = question.Options.Where(x => x.OptionNo == question.Value).FirstOrDefault(); + + option.SurveyQuestionOptionId = questionOption?.Id; + option.OptionContent = question.Value; + if (questionOption.IsOther == true) + option.Reverse1 = questionOption.OtherContent; + await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync(); + + break; + case "Rate": case "Scale": - var option = new Ghre_SurveyRecordOption() + case "ShortAnswer": + option = new Ghre_SurveyRecordOption() { SurveyId = id, SurveyRecordId = recordId, @@ -336,7 +376,7 @@ public class Ghre_SurveyServices : BaseServices x.OptionNo == question.Value).FirstOrDefault()?.Id; + option.OptionContent = question.Value; await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync();