From 76b713e64a4c424c8fdfd85494cc3e5fa7c02b30 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 27 Sep 2024 15:05:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B2=E5=B8=88=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HttpContextUser/AspNetUser.cs | 2 +- Tiobon.Core.Common/HttpContextUser/IUser.cs | 2 +- Tiobon.Core.Model/Base/BasePoco.cs | 2 +- Tiobon.Core.Model/ViewModels/Menu.cs | 2 +- Tiobon.Core.Services/BASE/BaseServices.cs | 18 +- Tiobon.Core.Services/CommonServices.cs | 324 ++++++++++++++++-- 6 files changed, 316 insertions(+), 34 deletions(-) diff --git a/Tiobon.Core.Common/HttpContextUser/AspNetUser.cs b/Tiobon.Core.Common/HttpContextUser/AspNetUser.cs index aee26e77..29f23cd7 100644 --- a/Tiobon.Core.Common/HttpContextUser/AspNetUser.cs +++ b/Tiobon.Core.Common/HttpContextUser/AspNetUser.cs @@ -42,7 +42,7 @@ public class AspNetUser : IUser return ""; } - public long ID => GetClaimValueByType("jti").FirstOrDefault().ObjToLong(); + public int ID => GetClaimValueByType("jti").FirstOrDefault().ObjToInt(); public long TenantId => GetClaimValueByType("TenantId").FirstOrDefault().ObjToLong(); public bool IsAuthenticated() diff --git a/Tiobon.Core.Common/HttpContextUser/IUser.cs b/Tiobon.Core.Common/HttpContextUser/IUser.cs index a54e0945..0cc39f49 100644 --- a/Tiobon.Core.Common/HttpContextUser/IUser.cs +++ b/Tiobon.Core.Common/HttpContextUser/IUser.cs @@ -6,7 +6,7 @@ namespace Tiobon.Core.Common.HttpContextUser; public interface IUser { string Name { get; } - long ID { get; } + int ID { get; } long TenantId { get; } bool IsAuthenticated(); IEnumerable GetClaimsIdentity(); diff --git a/Tiobon.Core.Model/Base/BasePoco.cs b/Tiobon.Core.Model/Base/BasePoco.cs index ff2d1f95..ec5f4143 100644 --- a/Tiobon.Core.Model/Base/BasePoco.cs +++ b/Tiobon.Core.Model/Base/BasePoco.cs @@ -33,7 +33,7 @@ public class BasePoco1 : IBaseDeleteFilter /// 创建人 /// [Display(Name = "创建人"), SugarColumn(IsOnlyIgnoreUpdate = true)] - public long? CreateBy { get; set; } + public int? CreateBy { get; set; } /// /// 创建时间 diff --git a/Tiobon.Core.Model/ViewModels/Menu.cs b/Tiobon.Core.Model/ViewModels/Menu.cs index 71be8cae..63615be7 100644 --- a/Tiobon.Core.Model/ViewModels/Menu.cs +++ b/Tiobon.Core.Model/ViewModels/Menu.cs @@ -208,7 +208,7 @@ public class FlowReturn public List DT_PageMutiMsg { get; set; } = new List(); public JM_PageFormActionsT1 JM_PageFormActionsT1 { get; set; } = new JM_PageFormActionsT1(); public FlowJM_TableColumnT1 JM_TableColumnT1 { get; set; } = new FlowJM_TableColumnT1(); - public DataTable DT_TableDataT1 { get; set; } + public object DT_TableDataT1 { get; set; } } diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index f5858c6f..34d8c3ac 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -179,17 +179,17 @@ public class BaseServices : IBaseServ #region JM_PageFormActionsT1 dynamic JM_PageFormActionsT1 = new ExpandoObject(); - var toolbars = await _caching.GetAsync>(body.menuName + "FormToolbar"); - if (toolbars == null || (toolbars != null && !toolbars.Any())) - { - sql = @$"SELECT field fnKey, [dbo].[FLangKeyToValue] (mkey, {body.langId}, label) fnTitle, icon + //var toolbars = await _caching.GetAsync>(body.menuName + "FormToolbar"); + //if (toolbars == null || (toolbars != null && !toolbars.Any())) + //{ + + // if (toolbars.Any()) + // await _caching.SetAsync(body.menuName + "FormToolbar", toolbars); + //} + sql = @$"SELECT field fnKey, [dbo].[FLangKeyToValue] (mkey, {body.langId}, label) fnTitle, icon FROM Ghrs_PageSettingEdit WHERE IsEnable = 1 AND pageNo = '{body.menuName}' AND elementType = 'FnKey'"; - toolbars = await Db.Ado.SqlQueryAsync(sql); - if (toolbars.Any()) - await _caching.SetAsync(body.menuName + "FormToolbar", toolbars); - } - + var toolbars = await Db.Ado.SqlQueryAsync(sql); JM_PageFormActionsT1.Toolbar = toolbars; #endregion diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index d5a7847e..99225c37 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -1149,8 +1149,7 @@ public partial class CommonServices : BaseServices>, ICommon position = "left" }); break; - case "F_Training_Demand_ToConfirm": - case "F_TeacherManageWaitConfirm": + case "F_Training_Demand_ToConfirm": toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault(); @@ -1193,6 +1192,34 @@ public partial class CommonServices : BaseServices>, ICommon toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "CopyYN").FirstOrDefault(); if (toolbar != null) toolbar.fnKey = "TBD4YN"; break; + case "F_TeacherManageWaitConfirm": + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD1YN"; } + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "UpdateYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD2YN"; } + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "DetailYN").FirstOrDefault(); + if (toolbar != null) { toolbar.fnKey = "TBD3YN"; } + toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "CopyYN").FirstOrDefault(); + if (toolbar != null) toolbar.fnKey = "TBD4YN"; + result.JM_PageControlT1.Toolbar.Insert(0, new Toolbar() + { + display = true, + fnKey = "TBD7YN", + fnTitle = "拒绝", + fnType = "table", + icon = "ess-icon-reject", + position = "left" + }); + result.JM_PageControlT1.Toolbar.Insert(0, new Toolbar() + { + display = true, + fnKey = "TBD6YN", + fnTitle = "同意", + fnType = "table", + icon = "ess-icon-approval", + position = "left" + }); + break; } #endregion @@ -1938,6 +1965,7 @@ public partial class CommonServices : BaseServices>, ICommon WHERE WorkID = @ID -- 根据流程单号读取 END END"; + flowReturn.DT_TableDataT1 = await Db.Ado.GetDataTableAsync(sql); break; case "F_ESS_TrainRequestApply": sql = @$"DECLARE @@ -2133,6 +2161,7 @@ public partial class CommonServices : BaseServices>, ICommon WHERE WorkID = @ID -- 根据流程单号读取 END END"; + flowReturn.DT_TableDataT1 = await Db.Ado.GetDataTableAsync(sql); break; case "F_ESS_TrainRequestPersonalApply": sql = @$"DECLARE @@ -2332,13 +2361,221 @@ public partial class CommonServices : BaseServices>, ICommon WHERE WorkID = @ID -- 根据流程单号读取 END END"; + flowReturn.DT_TableDataT1 = await Db.Ado.GetDataTableAsync(sql); + break; + + case "F_ESS_TrainTeacherApply": + sql = @$"DECLARE + @SQL NVARCHAR (MAX) = '', + @FlowID INT = {param.jsonParam.FlowID}, + @langId INT = {param.langId}, + @DoType NVARCHAR (MAX) = '{param.doType}', + @SQL2 NVARCHAR (MAX) = '', + @JsonString NVARCHAR (MAX) = '', + @JsonString1 NVARCHAR (MAX) = '', + @JsonString2 NVARCHAR (MAX) = '', + @ID INT = '{param.id}', + @userId INT = {param.userId} + + BEGIN + IF @DoType IN ('Update', 'Copy') -- 读取修改 + BEGIN + SELECT a.Id, + a.CreateBy, + a.CreateTime, + a.CreateProg, + a.CreateIP, + a.UpdateBy, + a.UpdateTime, + a.UpdateProg, + a.UpdateIP, + a.OperateLogID, + a.CourseSource, + a.RequestNo, + a.CourseName, + a.CourseId, + a.YearMonth, + a.RequestSource, + a.DeptId, + a.ApplicantId, + a.RequestNum, + a.TrainStaffId, + a.TrainClass, + a.TrainLevel, + a.InOrOut, + a.TeacherClass, + a.Reason, + a.PerCapitaBudget, + a.TotalBudget, + a.SponsorId, + a.Status, + a.RemarkSz, + a.IsDefault, + a.IsEnable, + a.WorkID, + a.WorkNo, + a.ToDoType, + a.BatchSID, + a.WorkState, + a.ShiftID, + a.ConfirmUserID, + a.ConfirmTime, + a.ConfirmComment, + a.AgreeUserId, + a.AgreeTime, + a.AgreeReason, + a.RefuseUserId, + a.RefuseTime, + a.RefuseReason, + a.Reverse1, + a.Reverse2, + a.Reverse3, + a.Reverse4, + a.Reverse5, + a.Reverse6, + a.Reverse7, + a.Reverse8, + a.Reverse9, + a.Reverse10, + a.ReverseI1, + a.ReverseI2, + isnull + ( + (SELECT CASE + WHEN @langId = 1 THEN UserName + ELSE UserEname + END + FROM Ghrs_User kk + WHERE kk.UserId = a.CreateBy), + '') + + ' ' + + [dbo].[FLangKeyToValue] + ('GHR_Common_000078', @langId, '于 ') + + ' ' + + CONVERT (NVARCHAR (16), CreateTime, 121) + + ' ' + + [dbo].[FLangKeyToValue] + ('GHR_Common_000079', @langId, ' 创建') CreateDataInfo, + isnull + ( + (SELECT CASE + WHEN @langId = 1 THEN UserName + ELSE UserEname + END + FROM Ghrs_User kk + WHERE kk.UserId = a.UpdateBy), + '') + + ' ' + + [dbo].[FLangKeyToValue] + ('GHR_Common_000078', @langId, '于') + + ' ' + + CONVERT (NVARCHAR (16), UpdateTime, 121) + + ' ' + + [dbo].[FLangKeyToValue] + ('GHR_Common_000080', @langId, ' 最后修改') UpdateDataInfo + FROM Ghre_Request a + WHERE a.Id = @ID + END + + IF @DoType = 'Insert' -- 空白新增 + BEGIN + SELECT (SELECT UserStaffID + FROM dbo.Ghrs_User + WHERE UserId = @userId) CreateBy, + NULL SchoolId, + (SELECT DeptID + FROM Ghra_Staff + WHERE StaffID = (SELECT UserStaffID + FROM dbo.Ghrs_User + WHERE UserId = @userId)) DeptID, + NULL StaffId, + NULL TeacherType, + NULL TeacherNo, + NULL TeacherName, + NULL PhotoUrl, + NULL Gender, + NULL Email, + NULL Mobile, + NULL TeacherLevel, + NULL Price, + NULL SkillPoints, + NULL ApplyReason, + 'Wait' Status, + 0 IsDefault, + 0 Id, + NULL RemarkSz + END + + IF @DoType = 'ReApply' -- ReApply:重新发起 + BEGIN + SELECT Id, + CreateBy, + CreateTime, + CreateProg, + CreateIP, + UpdateBy, + UpdateTime, + UpdateProg, + UpdateIP, + OperateLogID, + SchoolId, + DeptID, + StaffId, + TeacherType, + TeacherNo, + TeacherName, + PhotoUrl, + Gender, + Email, + Mobile, + TeacherLevel, + Price, + SkillPoints, + RemarkSz, + IsDefault, + IsEnable, + WorkID, + WorkNo, + ToDoType, + BatchSID, + WorkState, + ShiftID, + ConfirmUserID, + ConfirmTime, + ConfirmComment, + AgreeUserId, + AgreeTime, + AgreeReason, + RefuseUserId, + RefuseTime, + RefuseReason, + Reverse1, + Reverse2, + Reverse3, + Reverse4, + Reverse5, + Reverse6, + Reverse7, + Reverse8, + Reverse9, + Reverse10, + ReverseI1, + ReverseI2, + Status, + Id1, + ApplyReason + FROM Ghre_Teacher + WHERE WorkID = @ID -- 根据流程单号读取 + END + END"; + var data = await Db.Ado.SqlQueryAsync(sql); + data.ForEach(x => x.TeacherAttachments = new List()); + flowReturn.DT_TableDataT1 = data; break; } #endregion - - flowReturn.DT_TableDataT1 = await Db.Ado.GetDataTableAsync(sql); #endregion return new ServiceResult() { Success = true, Message = "查询成功", result = flowReturn }; @@ -2380,6 +2617,7 @@ public partial class CommonServices : BaseServices>, ICommon sql = $"SELECT FlowID FROM Ghrs_Menu b WHERE b.Menuno = '{param.menuName}' AND b.IsEnable = 1"; @FlowID = await Db.Ado.GetIntAsync(sql); + long id = 0; switch (param.menuName) { @@ -2398,7 +2636,16 @@ public partial class CommonServices : BaseServices>, ICommon dict.SponsorId = GetStaffId(); dict.RequestNo = await GenerateContinuousSequence("Ghre_Request", "RequestNo", "R"); - var id = await Db.Insertable(dict).ExecuteReturnSnowflakeIdAsync(); + id = await Db.Insertable(dict).ExecuteReturnSnowflakeIdAsync(); + + #region 根据参数 处理数据默认状态 + var config = await Db.Queryable().FirstAsync(x => x.ConfigCode == "ESS_Request_Apply_Status"); + if (config != null) + { + sql = $"UPDATE Ghre_Request SET Status='{config.ConfigValue}' WHERE Id ='{id}'"; + await Db.Ado.ExecuteCommandAsync(sql); + } + #endregion sql = $"SELECT ISNULL(MAX(id)+1,1) FROM Ghre_Request WHERE Id !='{id}'"; var id1 = await Db.Ado.GetLongAsync(sql); @@ -2408,28 +2655,41 @@ public partial class CommonServices : BaseServices>, ICommon id = id1; #endregion - #region 生成流程数据 - sql = @$"DECLARE @return_value int; + break; + } + #endregion - DECLARE @ErrorMsg nvarchar(2000); + break; + case "F_ESS_TrainTeacherApply": - SET @ErrorMsg = NULL; + #region 写入数据,并判断是否有错误 + switch (param.doType) + { + case "Apply": + case "BatchApply": - EXEC @return_value = GHR30.dbo.[PT_GHR30_FlowApply] - @ID = {id}, - @FlowID = {@FlowID}, - @UserID = {param.userId}, - @LangID = {param.langId}, - @ErrorMsg = @ErrorMsg out; + #region 写入数据,并判断是否有错误 + string json = param.jsonParam.ToString(); + var dict = JsonHelper.JsonToObj(json); - SELECT @ErrorMsg as N'@ErrorMsg', @return_value as N'@Return Value';"; + id = await Db.Insertable(dict).ExecuteReturnSnowflakeIdAsync(); - var message = await Db.Ado.GetStringAsync(sql); + #region 根据参数 处理数据默认状态 + var config = await Db.Queryable().FirstAsync(x => x.ConfigCode == "ESS_Teacher_Apply_Status"); + if (config != null) + { + sql = $"UPDATE Ghre_Teacher SET Status='{config.ConfigValue}' WHERE Id ='{id}'"; + await Db.Ado.ExecuteCommandAsync(sql); + } + #endregion - if (message.IsNotEmptyOrNull()) - return new ServiceResult() { Success = false, Message = message }; + sql = $"SELECT ISNULL(MAX(id)+1,1) FROM Ghre_Teacher WHERE Id !='{id}'"; + var id1 = await Db.Ado.GetLongAsync(sql); + sql = $"UPDATE Ghre_Teacher SET Id={id1} WHERE Id ='{id}'"; + await Db.Ado.ExecuteCommandAsync(sql); - #endregion + id = id1; + #endregion break; } @@ -2438,11 +2698,33 @@ public partial class CommonServices : BaseServices>, ICommon break; } + #region 生成流程数据 + sql = @$"DECLARE @return_value int; + + DECLARE @ErrorMsg nvarchar(2000); + + SET @ErrorMsg = NULL; + + EXEC @return_value = GHR30.dbo.[PT_GHR30_FlowApply] + @ID = {id}, + @FlowID = {@FlowID}, + @UserID = {param.userId}, + @LangID = {param.langId}, + @ErrorMsg = @ErrorMsg out; + + SELECT @ErrorMsg as N'@ErrorMsg', @return_value as N'@Return Value';"; + + var message = await Db.Ado.GetStringAsync(sql); + + if (message.IsNotEmptyOrNull()) + return new ServiceResult() { Success = false, Message = message }; + + #endregion + return new ServiceResult() { Success = true, Message = "提交成功" }; } #endregion - #region MyRegion public int? GetStaffId() {