群组作废时同步作废明细数据

master
孤兰 2 months ago
parent f55d2f95a1
commit 9a0a87f326
  1. 6
      Tiobon.Core.Api/Controllers/Ghra/Ghra_StaffGroupController.cs
  2. 5
      Tiobon.Core.IServices/Ghra/IGhra_StaffGroupServices.cs
  3. 32
      Tiobon.Core.Services/Ghra/Ghra_StaffGroupServices.cs

@ -1,4 +1,6 @@
namespace Tiobon.Core.Api.Controllers;
using Newtonsoft.Json.Linq;
namespace Tiobon.Core.Api.Controllers;
/// <summary>
/// 人员群组(Controller)
@ -19,5 +21,5 @@ public class Ghra_StaffGroupController : BaseController<IGhra_StaffGroupServices
[HttpPost, Route("GetStaffInfoColumnData")]
public async Task<ServiceResult<object>> GetStaffInfoColumnData() => await _service.GetStaffInfoColumnData();
[HttpPost, Route("GetStaffGroupInfoByID/{Id}")]
public async Task<ServiceResult<Dictionary<string, object>>> GetStaffGroupInfoByID(long Id, string BaseDate) => await _service.GetStaffGroupInfoByID(Id,BaseDate);
public async Task<ServiceResult<Dictionary<string, object>>> GetStaffGroupInfoByID(long Id, [FromBody] JObject FBody) => await _service.GetStaffGroupInfoByID(Id, FBody);
}

@ -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<Ghra_StaffGroup, Ghra_StaffGroupDto, InsertGhra_StaffGroupInput, EditGhra_StaffGroupInput>
{
Task<ServiceResult<object>> GetStaffInfoColumnData();
Task<ServiceResult<Dictionary<string, object>>> GetStaffGroupInfoByID(long Id, string BaseDate);
Task<ServiceResult<Dictionary<string, object>>> GetStaffGroupInfoByID(long Id, JObject FBody);
}
}

@ -51,6 +51,7 @@ namespace Tiobon.Core.Services
public override async Task<bool> 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<bool> 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<ServiceFormResult<Ghra_StaffGroupDto>> QueryForm(QueryForm body)
{
@ -148,9 +168,10 @@ namespace Tiobon.Core.Services
return ServiceResult<object>.OprateSuccess("查询成功!", result);
}
public async Task<ServiceResult<Dictionary<string, object>>> GetStaffGroupInfoByID(long Id,string BaseDate)
public async Task<ServiceResult<Dictionary<string, object>>> GetStaffGroupInfoByID(long Id,JObject FBody)
{
string LangID = App.User.GetLangId().ToString();
string BaseDate = FBody["BaseDate"]?.Value<string>() ?? 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);

Loading…
Cancel
Save