diff --git a/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs b/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs index 9d5c4e11..6b3e8192 100644 --- a/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs +++ b/Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs @@ -1,4 +1,6 @@ -namespace Tiobon.Core.Api.Controllers; +using Newtonsoft.Json.Linq; + +namespace Tiobon.Core.Api.Controllers; /// /// 人员群组(Controller) @@ -19,5 +21,5 @@ public class Ghra_StaffGroupController : BaseController> GetStaffInfoColumnData() => await _service.GetStaffInfoColumnData(); [HttpPost, Route("GetStaffGroupInfoByID/{Id}")] - public async Task>> GetStaffGroupInfoByID(long Id, string BaseDate) => await _service.GetStaffGroupInfoByID(Id,BaseDate); + public async Task>> GetStaffGroupInfoByID(long Id, [FromBody] JObject FBody) => await _service.GetStaffGroupInfoByID(Id, FBody); } \ No newline at end of file diff --git a/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs b/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs index f01ed104..bddd0c9d 100644 --- a/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs +++ b/Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs @@ -1,4 +1,5 @@ -using Tiobon.Core.IServices.BASE; +using Newtonsoft.Json.Linq; +using Tiobon.Core.IServices.BASE; using Tiobon.Core.Model; using Tiobon.Core.Model.Models; @@ -10,6 +11,6 @@ namespace Tiobon.Core.IServices public interface IGhra_StaffGroupServices :IBaseServices { Task> GetStaffInfoColumnData(); - Task>> GetStaffGroupInfoByID(long Id, string BaseDate); + Task>> GetStaffGroupInfoByID(long Id, JObject FBody); } } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs b/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs index 2e83c39c..08dc3b38 100644 --- a/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs +++ b/Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs @@ -51,6 +51,7 @@ namespace Tiobon.Core.Services public override async Task Update(long Id, EditGhra_StaffGroupInput editModel) { await _StaffGroupDetailServices.Delete(x => x.StaffGroupID == Id); + editModel.StaffGroupDetail.ForEach(x => { x.StaffGroupID = Id; @@ -59,6 +60,25 @@ namespace Tiobon.Core.Services return await base.Update(Id, editModel); } + public override async Task DeleteById1(object id) + { + var entity = await BaseDal.QueryById(id); + BasePoco ent = entity as BasePoco; + ent.IsEnable = 0; + HttpRequest request = UserContext.Context.Request; + var api = request.Path.ObjToString().TrimEnd('/').ToLower(); + var ip = GetUserIp(UserContext.Context); + string sql = @$"update Ghra_StaffGroupDetail + set IsEnable=0, + UpdateBy={App.User.ID.ToString()}, + UpdateIP={ip}, + UpdateProg={api}, + UpdateTime=GETDATE() + where StaffGroupID={id.ToString()} + and IsEnable= 1"; + + return await BaseDal.Update(entity); + } public override async Task> QueryForm(QueryForm body) { @@ -148,9 +168,10 @@ namespace Tiobon.Core.Services return ServiceResult.OprateSuccess("查询成功!", result); } - public async Task>> GetStaffGroupInfoByID(long Id,string BaseDate) + public async Task>> GetStaffGroupInfoByID(long Id,JObject FBody) { string LangID = App.User.GetLangId().ToString(); + string BaseDate = FBody["BaseDate"]?.Value() ?? DateTime.Now.ToString("yyyy-MM-dd"); if (LangID == "0") LangID = "1"; string sql = @$"select case when Operator not in ('IsNull','NotNull') then iif(IsChangeColumn = 1,'b.','a.')+StaffField + case when Operator = 'Equal' @@ -230,17 +251,18 @@ namespace Tiobon.Core.Services ; if ( !staffInfoColumns.Any(x => x.StaffInfoColumnNo == dr["ColumnNo"].ToString())) { staffInfoColumns.Add(staffInfo); - SqlStr += ","+dr["SqlStr"].ToString()+ $" [{dr["ColumnNo"].ToString()}] "; + SqlStr += ","+dr["SqlStr"].ToString(); } } string StaffSql = @$"select a.StaffID,a.StaffNo,a.StaffName, dbo.FA_StaffInfoRepItemStaffInfo(a.StaffID,null,{LangID},'DeptFullPateName') DeptFullPateName - from Ghra_Staff a inner join (select * from Ghra_StaffChange where IsEnable=1 and ChangeDate= [dbo].[FLatestStaffChangeDate](StaffID,{(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")}) )b + {SqlStr} + from Ghra_Staff a inner join (select * from Ghra_StaffChange where IsEnable=1 and ChangeDate= [dbo].[FLatestStaffChangeDate](StaffID,'{BaseDate}') )b on a.StaffID = b.StaffID where a.IsEnable=1 - and a.InDate <= {(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")} - and (a.OutDate is null or a.OutDate>= {(string.IsNullOrEmpty(BaseDate) ? "getdate()" : "'" + BaseDate + "'")} ) " + and a.InDate <= '{BaseDate}' + and (a.OutDate is null or a.OutDate>= '{BaseDate}' ) " + WhereSQL; DataTable staffTable = await Db.Ado.GetDataTableAsync(StaffSql);