fix 设备数据和人员数据修改
This commit is contained in:
@@ -165,7 +165,10 @@ public class GainfosController : ControllerBase
|
|||||||
[HttpGet("weeknumber")]
|
[HttpGet("weeknumber")]
|
||||||
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync([FromQuery] WeekNumberRequest request)
|
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync([FromQuery] WeekNumberRequest request)
|
||||||
{
|
{
|
||||||
return await _gainfoService.GetWeekNumberAsync(request);
|
// 从请求头中获取 Token
|
||||||
|
string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
|
||||||
|
|
||||||
|
return await _gainfoService.GetWeekNumberAsync(request,token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -175,7 +178,10 @@ public class GainfosController : ControllerBase
|
|||||||
[HttpGet("weeknumberdimission")]
|
[HttpGet("weeknumberdimission")]
|
||||||
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request)
|
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request)
|
||||||
{
|
{
|
||||||
return await _gainfoService.GetDimissionWeekNumberAsync(request);
|
// 从请求头中获取 Token
|
||||||
|
string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
|
||||||
|
|
||||||
|
return await _gainfoService.GetDimissionWeekNumberAsync(request,token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -183,9 +189,12 @@ public class GainfosController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("gainfonumbers")]
|
[HttpGet("gainfonumbers")]
|
||||||
public async Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync(string Werks)
|
public async Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync()
|
||||||
{
|
{
|
||||||
return await _gainfoService.GetGainfoNumbersAsync(Werks);
|
// 从请求头中获取 Token
|
||||||
|
string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
|
||||||
|
|
||||||
|
return await _gainfoService.GetGainfoNumbersAsync(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ public interface IGainfoService : IScopeDependency
|
|||||||
|
|
||||||
Task<GainfoDetailResponse> GetGainfoDetailTaskAsync(GainfoDetailRequest request);
|
Task<GainfoDetailResponse> GetGainfoDetailTaskAsync(GainfoDetailRequest request);
|
||||||
|
|
||||||
Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync(WeekNumberRequest request);
|
Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync(WeekNumberRequest request, string token);
|
||||||
|
|
||||||
Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request);
|
Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request, string token);
|
||||||
|
|
||||||
Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync(string Werks);
|
Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync(string token);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using Kurisu.SqlSugar.Services;
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.DataProtection;
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
|
||||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||||
|
|
||||||
@@ -377,8 +378,10 @@ public class GainfoService : IGainfoService
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync(WeekNumberRequest request)
|
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync(WeekNumberRequest request, string token)
|
||||||
{
|
{
|
||||||
|
var werks = GetClaimValueFromToken(token, "tenant");
|
||||||
|
|
||||||
//获取近7天并转化为"yyyy-MM-dd"集合
|
//获取近7天并转化为"yyyy-MM-dd"集合
|
||||||
DateTime currentDate = DateTime.Now;
|
DateTime currentDate = DateTime.Now;
|
||||||
List<string> times = new List<string>();
|
List<string> times = new List<string>();
|
||||||
@@ -399,7 +402,7 @@ public class GainfoService : IGainfoService
|
|||||||
.LeftJoin<PositionEntity>((ga, de, type, posi) => ga.Position == posi.Name)
|
.LeftJoin<PositionEntity>((ga, de, type, posi) => ga.Position == posi.Name)
|
||||||
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
|
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
|
||||||
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
|
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
|
||||||
.Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time)
|
.Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time && ga.Werks == werks)
|
||||||
.Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse
|
.Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse
|
||||||
{
|
{
|
||||||
No = ga.No,
|
No = ga.No,
|
||||||
@@ -432,8 +435,10 @@ public class GainfoService : IGainfoService
|
|||||||
return dic;
|
return dic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request)
|
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync(WeekNumberRequest request, string token)
|
||||||
{
|
{
|
||||||
|
var werks = GetClaimValueFromToken(token, "tenant");
|
||||||
|
|
||||||
//获取近7天并转化为"yyyy-MM-dd"集合
|
//获取近7天并转化为"yyyy-MM-dd"集合
|
||||||
DateTime currentDate = DateTime.Now;
|
DateTime currentDate = DateTime.Now;
|
||||||
List<string> times = new List<string>();
|
List<string> times = new List<string>();
|
||||||
@@ -453,7 +458,7 @@ public class GainfoService : IGainfoService
|
|||||||
.LeftJoin<PositionEntity>((ga, de, type, posi) => ga.Position == posi.Name)
|
.LeftJoin<PositionEntity>((ga, de, type, posi) => ga.Position == posi.Name)
|
||||||
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
|
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
|
||||||
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
|
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
|
||||||
.Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time)
|
.Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time && ga.Werks == werks)
|
||||||
.Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse
|
.Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse
|
||||||
{
|
{
|
||||||
No = ga.No,
|
No = ga.No,
|
||||||
@@ -483,16 +488,18 @@ public class GainfoService : IGainfoService
|
|||||||
return dic;
|
return dic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync(string Werks)
|
public async Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync(string token)
|
||||||
{
|
{
|
||||||
|
var werks = GetClaimValueFromToken(token, "tenant");
|
||||||
|
|
||||||
//在职人数
|
//在职人数
|
||||||
var onlineNumber = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
var onlineNumber = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||||
.Where(ga => ga.Werks == Werks)
|
.Where(ga => ga.Werks == werks)
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
|
|
||||||
//离职人数
|
//离职人数
|
||||||
var offlineNumber = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave)
|
var offlineNumber = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave)
|
||||||
.Where(ga => ga.Werks == Werks)
|
.Where(ga => ga.Werks == werks)
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
|
|
||||||
//考勤总人数
|
//考勤总人数
|
||||||
@@ -545,4 +552,31 @@ public class GainfoService : IGainfoService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解析token
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <param name="claimType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="Exception"></exception>
|
||||||
|
private string GetClaimValueFromToken(string token, string claimType)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
var jsonToken = handler.ReadToken(token) as JwtSecurityToken;
|
||||||
|
|
||||||
|
if (jsonToken == null)
|
||||||
|
throw new Exception("Invalid JWT Token");
|
||||||
|
|
||||||
|
var claimValue = jsonToken.Claims.FirstOrDefault(c => c.Type == claimType)?.Value;
|
||||||
|
|
||||||
|
return claimValue;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user