refactor 警告/提醒处理
This commit is contained in:
@@ -376,13 +376,13 @@ public class DeviceService : IDeviceService
|
|||||||
.Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
|
.Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
|
||||||
.Select((x, d) => new
|
.Select((x, d) => new
|
||||||
{
|
{
|
||||||
UniqueNo = d.UniqueNo,
|
d.UniqueNo,
|
||||||
d.HeartbeatInterval,
|
d.HeartbeatInterval,
|
||||||
x.LastHeartbeatTime
|
x.LastHeartbeatTime
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var OnlineDevices = deviceRegistries
|
var onlineDevices = deviceRegistries
|
||||||
.Where(x =>
|
.Where(x =>
|
||||||
{
|
{
|
||||||
if (x.HeartbeatInterval <= 0)
|
if (x.HeartbeatInterval <= 0)
|
||||||
@@ -395,11 +395,11 @@ public class DeviceService : IDeviceService
|
|||||||
})
|
})
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
{
|
{
|
||||||
UniqueNo = x.UniqueNo,
|
x.UniqueNo,
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
var onlineUniqueNos = new List<string>();
|
var onlineUniqueNos = new List<string>();
|
||||||
OnlineDevices.ForEach(x => onlineUniqueNos.Add(x.UniqueNo));
|
onlineDevices.ForEach(x => onlineUniqueNos.Add(x.UniqueNo));
|
||||||
|
|
||||||
var offUniqueNos = deviceUniqueNos.Except(onlineUniqueNos).ToList();
|
var offUniqueNos = deviceUniqueNos.Except(onlineUniqueNos).ToList();
|
||||||
var list = devices.Where(x => offUniqueNos.Contains(x.UniqueNo)).ToList();
|
var list = devices.Where(x => offUniqueNos.Contains(x.UniqueNo)).ToList();
|
||||||
@@ -518,7 +518,7 @@ public class DeviceService : IDeviceService
|
|||||||
{
|
{
|
||||||
//获取近30天并转化为"yyyy-MM-dd"集合
|
//获取近30天并转化为"yyyy-MM-dd"集合
|
||||||
DateTime currentDate = DateTime.Now;
|
DateTime currentDate = DateTime.Now;
|
||||||
List<string> times = new List<string>();
|
var times = new List<string>();
|
||||||
for (int i = 0; i < 30; i++)
|
for (int i = 0; i < 30; i++)
|
||||||
{
|
{
|
||||||
DateTime date = currentDate.AddDays(-i);
|
DateTime date = currentDate.AddDays(-i);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class DishesCategoryService : IDishesCategoryService
|
|||||||
public DishesCategoryService(IDbContext dbContext, IBusinessPlacePermissionsService businessPlacePermissionsService)
|
public DishesCategoryService(IDbContext dbContext, IBusinessPlacePermissionsService businessPlacePermissionsService)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
|
_businessPlacePermissionsService = businessPlacePermissionsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<DishesCategoryTreeResponse>> TreeAsync(Guid businessPlaceCode)
|
public async Task<List<DishesCategoryTreeResponse>> TreeAsync(Guid businessPlaceCode)
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ public class GainfoPermissions : IGainfoPermissions
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Guid> RecursionGetNext(DeviceGroupEntity current, List<DeviceGroupEntity> deviceGroups)
|
private static IEnumerable<Guid> RecursionGetNext(DeviceGroupEntity current, List<DeviceGroupEntity> deviceGroups)
|
||||||
{
|
{
|
||||||
var next = deviceGroups.Where(x => x.PCode == current.Code).ToList();
|
var next = deviceGroups.Where(x => x.PCode == current.Code).ToList();
|
||||||
foreach (var item in next)
|
foreach (var item in next)
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Kurisu.AspNetCore;
|
using Kurisu.AspNetCore;
|
||||||
using Kurisu.AspNetCore.Startup;
|
using Kurisu.AspNetCore.Startup;
|
||||||
using Kurisu.Core.DataAccess.Entity;
|
|
||||||
using Kurisu.SqlSugar.Extensions;
|
using Kurisu.SqlSugar.Extensions;
|
||||||
using Kurisu.SqlSugar.Services;
|
using Kurisu.SqlSugar.Services;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
namespace Dlhis.Basic.Packs;
|
namespace Dlhis.Basic.Packs;
|
||||||
@@ -22,7 +19,7 @@ public class SqlSugarPack : BaseAppPack
|
|||||||
|
|
||||||
return new List<ConnectionConfig>
|
return new List<ConnectionConfig>
|
||||||
{
|
{
|
||||||
new ConnectionConfig
|
new()
|
||||||
{
|
{
|
||||||
ConfigId = "face",
|
ConfigId = "face",
|
||||||
|
|
||||||
@@ -36,7 +33,7 @@ public class SqlSugarPack : BaseAppPack
|
|||||||
DisableNvarchar = true,
|
DisableNvarchar = true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new ConnectionConfig
|
new()
|
||||||
{
|
{
|
||||||
ConfigId = "log",
|
ConfigId = "log",
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class SummaryService : ISummaryService
|
|||||||
|
|
||||||
//获取近30天并转化为"yyyy-MM-dd"集合
|
//获取近30天并转化为"yyyy-MM-dd"集合
|
||||||
DateTime currentDate = DateTime.Now;
|
DateTime currentDate = DateTime.Now;
|
||||||
List<string> times = new List<string>();
|
var times = new List<string>();
|
||||||
for (int i = 0; i < 30; i++)
|
for (int i = 0; i < 30; i++)
|
||||||
{
|
{
|
||||||
DateTime date = currentDate.AddDays(-i);
|
DateTime date = currentDate.AddDays(-i);
|
||||||
@@ -125,7 +125,7 @@ public class SummaryService : ISummaryService
|
|||||||
public async Task<DoorDataResponse> GetDoorDataAsync()
|
public async Task<DoorDataResponse> GetDoorDataAsync()
|
||||||
{
|
{
|
||||||
var res = new DoorDataResponse();
|
var res = new DoorDataResponse();
|
||||||
List<GainfoEntity> workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).ToListAsync();
|
var workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).ToListAsync();
|
||||||
var leaveGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave).ToListAsync();
|
var leaveGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave).ToListAsync();
|
||||||
res.Employed = workingGainfos.Count;
|
res.Employed = workingGainfos.Count;
|
||||||
res.Unemployed = leaveGainfos.Count;
|
res.Unemployed = leaveGainfos.Count;
|
||||||
@@ -134,8 +134,8 @@ public class SummaryService : ISummaryService
|
|||||||
var unemployedTrend = new List<TrendDto>();
|
var unemployedTrend = new List<TrendDto>();
|
||||||
|
|
||||||
//获取近7天并转化为"yyyy-MM-dd"集合
|
//获取近7天并转化为"yyyy-MM-dd"集合
|
||||||
DateTime currentDate = DateTime.Now;
|
var currentDate = DateTime.Now;
|
||||||
List<string> times = new List<string>();
|
var times = new List<string>();
|
||||||
for (int i = 0; i < 7; i++)
|
for (int i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
DateTime date = currentDate.AddDays(-i);
|
DateTime date = currentDate.AddDays(-i);
|
||||||
|
|||||||
@@ -404,19 +404,18 @@ public class BalanceService : IBalanceService
|
|||||||
var lst = new List<BalanceRecordAnalysisRespones>();
|
var lst = new List<BalanceRecordAnalysisRespones>();
|
||||||
foreach (var first in pageinfo.GroupBy(record => record.CostDateTime.ToString("yyyy-MM-dd")))
|
foreach (var first in pageinfo.GroupBy(record => record.CostDateTime.ToString("yyyy-MM-dd")))
|
||||||
{
|
{
|
||||||
var obj = new BalanceRecordAnalysisRespones()
|
var obj = new BalanceRecordAnalysisRespones
|
||||||
{
|
{
|
||||||
CostDate = DateOnly.FromDateTime(Convert.ToDateTime(first.Key)),
|
CostDate = DateOnly.FromDateTime(Convert.ToDateTime(first.Key)),
|
||||||
|
//每个餐次人数
|
||||||
|
BreakfastNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Select(x => x.UserNo).Distinct().Count(),
|
||||||
|
LunchNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count(),
|
||||||
|
DinnerNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count(),
|
||||||
|
LateNightNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Select(x => x.UserNo).Distinct().Count(),
|
||||||
|
|
||||||
|
TotalNumberOfPeople = first.Where(x => x.CostDate.ToString("yyyy-MM-dd") == first.Key).Select(x => x.UserNo).Distinct().Count()
|
||||||
};
|
};
|
||||||
|
|
||||||
//每个餐次人数
|
|
||||||
obj.BreakfastNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Select(x => x.UserNo).Distinct().Count();
|
|
||||||
obj.LunchNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count();
|
|
||||||
obj.DinnerNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count();
|
|
||||||
obj.LateNightNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Select(x => x.UserNo).Distinct().Count();
|
|
||||||
|
|
||||||
obj.TotalNumberOfPeople = first.Where(x => x.CostDate.ToString("yyyy-MM-dd") == first.Key).Select(x => x.UserNo).Distinct().Count();
|
|
||||||
|
|
||||||
lst.Add(obj);
|
lst.Add(obj);
|
||||||
}
|
}
|
||||||
// 分页操作
|
// 分页操作
|
||||||
@@ -624,7 +623,7 @@ public class BalanceService : IBalanceService
|
|||||||
/// <param name="bs"></param>
|
/// <param name="bs"></param>
|
||||||
/// <param name="userCode"></param>
|
/// <param name="userCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private int SameDay(List<BalanceRecordEntity> bs, string userCode)
|
private static int SameDay(List<BalanceRecordEntity> bs, string userCode)
|
||||||
{
|
{
|
||||||
var time = DateTime.Now.ToString("yyyy-MM-dd");
|
var time = DateTime.Now.ToString("yyyy-MM-dd");
|
||||||
var b = userCode.IsEmpty();
|
var b = userCode.IsEmpty();
|
||||||
@@ -858,13 +857,13 @@ public class BalanceService : IBalanceService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private List<string> GetMonthsOfYear()
|
private List<string> GetMonthsOfYear()
|
||||||
{
|
{
|
||||||
List<string> months = new List<string>();
|
var months = new List<string>();
|
||||||
// 获取当前年份
|
// 获取当前年份
|
||||||
int year = DateTime.Now.Year;
|
int year = DateTime.Now.Year;
|
||||||
// 遍历12个月份并添加到列表中
|
// 遍历12个月份并添加到列表中
|
||||||
for (int month = 1; month <= 12; month++)
|
for (int month = 1; month <= 12; month++)
|
||||||
{
|
{
|
||||||
DateTime monthDate = new DateTime(year, month, 1);
|
var monthDate = new DateTime(year, month, 1);
|
||||||
months.Add(monthDate.ToString("yyyy-MM"));
|
months.Add(monthDate.ToString("yyyy-MM"));
|
||||||
}
|
}
|
||||||
return months;
|
return months;
|
||||||
@@ -876,15 +875,15 @@ public class BalanceService : IBalanceService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private List<string> GetDaysOfMonth()
|
private List<string> GetDaysOfMonth()
|
||||||
{
|
{
|
||||||
List<string> days = new List<string>();
|
var days = new List<string>();
|
||||||
|
|
||||||
// 获取当前年份和月份
|
// 获取当前年份和月份
|
||||||
int year = DateTime.Now.Year;
|
int year = DateTime.Now.Year;
|
||||||
int month = DateTime.Now.Month;
|
int month = DateTime.Now.Month;
|
||||||
|
|
||||||
// 获取当前月份的第一天和最后一天
|
// 获取当前月份的第一天和最后一天
|
||||||
DateTime firstDayOfMonth = new DateTime(year, month, 1);
|
var firstDayOfMonth = new DateTime(year, month, 1);
|
||||||
DateTime lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);
|
var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);
|
||||||
|
|
||||||
// 遍历当前月的所有日期并添加到列表中
|
// 遍历当前月的所有日期并添加到列表中
|
||||||
for (DateTime date = firstDayOfMonth; date <= lastDayOfMonth; date = date.AddDays(1))
|
for (DateTime date = firstDayOfMonth; date <= lastDayOfMonth; date = date.AddDays(1))
|
||||||
@@ -909,7 +908,7 @@ public class BalanceService : IBalanceService
|
|||||||
}
|
}
|
||||||
catch (Exception ex) when (ex is VersionExceptions)
|
catch (Exception ex) when (ex is VersionExceptions)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, ex.Message);
|
_logger.LogWarning(ex, "{message}", ex.Message);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,9 +56,8 @@ public abstract class BaseOrderService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备并发更新 需要抛出VersionExceptions
|
/// 设备并发更新 需要抛出VersionExceptions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="func"></param>
|
/// <param name="func"></param>
|
||||||
/// <param name="retry">并发冲突处理次数</param>
|
/// <param name="retry"></param>
|
||||||
/// <param name="errorMessage"></param>
|
/// <param name="errorMessage"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="UserFriendlyException"></exception>
|
/// <exception cref="UserFriendlyException"></exception>
|
||||||
@@ -73,7 +72,7 @@ public abstract class BaseOrderService
|
|||||||
}
|
}
|
||||||
catch (Exception ex) when (ex is VersionExceptions)
|
catch (Exception ex) when (ex is VersionExceptions)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, ex.Message);
|
_logger.LogWarning(ex, "{message}", ex.Message);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Dlhis.Common.FileOperation.Controllers;
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class ApkFileController : ControllerBase
|
public class ApkFileController : ControllerBase
|
||||||
{
|
{
|
||||||
private IApkFIileService _apkFIileService;
|
private readonly IApkFIileService _apkFIileService;
|
||||||
|
|
||||||
public ApkFileController(IApkFIileService apkFIileService)
|
public ApkFileController(IApkFIileService apkFIileService)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ namespace Dlhis.Common.FileOperation.Response
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// url
|
/// url
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Url { get; set; }
|
public string Url { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Dlhis.Common.FileOperation.Configurations;
|
using Dlhis.Common.FileOperation.Configurations;
|
||||||
using Dlhis.Common.FileOperation.Request;
|
using Dlhis.Common.FileOperation.Request;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Minio;
|
using Minio;
|
||||||
using Minio.DataModel.Args;
|
using Minio.DataModel.Args;
|
||||||
@@ -81,7 +82,7 @@ public class MinioService : IMinioService
|
|||||||
{
|
{
|
||||||
string fileName = request.formFile.FileName;
|
string fileName = request.formFile.FileName;
|
||||||
|
|
||||||
using (MemoryStream filestream = new MemoryStream())
|
using (var filestream = new MemoryStream())
|
||||||
{
|
{
|
||||||
await request.formFile.CopyToAsync(filestream);
|
await request.formFile.CopyToAsync(filestream);
|
||||||
filestream.Position = 0;
|
filestream.Position = 0;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class SqlSugarPack : BaseAppPack
|
|||||||
var configuration = sp.GetService<IConfiguration>();
|
var configuration = sp.GetService<IConfiguration>();
|
||||||
return new List<ConnectionConfig>
|
return new List<ConnectionConfig>
|
||||||
{
|
{
|
||||||
new ConnectionConfig
|
new()
|
||||||
{
|
{
|
||||||
ConfigId = "face",
|
ConfigId = "face",
|
||||||
ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value,
|
ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value,
|
||||||
@@ -28,7 +28,7 @@ public class SqlSugarPack : BaseAppPack
|
|||||||
DisableNvarchar = true,
|
DisableNvarchar = true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new ConnectionConfig
|
new()
|
||||||
{
|
{
|
||||||
ConfigId = "log",
|
ConfigId = "log",
|
||||||
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
|
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
|
||||||
|
|||||||
@@ -18,16 +18,14 @@ public class MealSupplementHandler : IAsyncChannelHandler<MealSupplementMessage>
|
|||||||
|
|
||||||
public async Task InvokeAsync(MealSupplementMessage message)
|
public async Task InvokeAsync(MealSupplementMessage message)
|
||||||
{
|
{
|
||||||
using (var scope = _serviceProvider.CreateScope())
|
using var scope = _serviceProvider.CreateScope();
|
||||||
{
|
var db = scope.ServiceProvider.GetService<IDbContext>();
|
||||||
var db = scope.ServiceProvider.GetService<IDbContext>();
|
|
||||||
|
|
||||||
var existsIds = await db.Queryable<MealSupplementRecordEntity>().Select(x => x.UniqueId).ToListAsync();
|
var existsIds = await db.Queryable<MealSupplementRecordEntity>().Select(x => x.UniqueId).ToListAsync();
|
||||||
var items = message.Items.Where(x => !existsIds.Contains(x.UniqueId)).ToList();
|
var items = message.Items.Where(x => !existsIds.Contains(x.UniqueId)).ToList();
|
||||||
|
|
||||||
var entities = items.Adapt<List<MealSupplementRecordEntity>>();
|
var entities = items.Adapt<List<MealSupplementRecordEntity>>();
|
||||||
await db.InsertAsync(entities);
|
await db.InsertAsync(entities);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,10 @@ namespace Dlhis.ScheduledTask.CommonJobs;
|
|||||||
public class HeartbeatJob
|
public class HeartbeatJob
|
||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
private readonly ILogger<HeartbeatJob> _logger;
|
|
||||||
|
|
||||||
public HeartbeatJob(IDbContext dbContext, ILogger<HeartbeatJob> logger)
|
public HeartbeatJob(IDbContext dbContext)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RunAsync()
|
public async Task RunAsync()
|
||||||
@@ -38,7 +36,7 @@ public class HeartbeatJob
|
|||||||
await _dbContext.Updateable<DeviceRegistryEntity>().SetColumns(x => x.LastHeartbeatTime == DateTime.Now)
|
await _dbContext.Updateable<DeviceRegistryEntity>().SetColumns(x => x.LastHeartbeatTime == DateTime.Now)
|
||||||
.Where(x => x.DeviceUniqueNo == device.UniqueNo).ExecuteCommandAsync();
|
.Where(x => x.DeviceUniqueNo == device.UniqueNo).ExecuteCommandAsync();
|
||||||
|
|
||||||
// _logger.LogInformation("心跳设备成功:{no}", device.UniqueNo);
|
// _logger.LogInformation("心跳设备成功:{no}", device.UniqueNo);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,121 +1,121 @@
|
|||||||
using Dlhis.Entity.Basic.Entity;
|
//using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Sys.Entities;
|
//using Dlhis.Entity.Sys.Entities;
|
||||||
using Kurisu.AspNetCore.Authentication.Options;
|
//using Kurisu.AspNetCore.Authentication.Options;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
//using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
using Kurisu.Core.DataAccess.Entity;
|
//using Kurisu.Core.DataAccess.Entity;
|
||||||
using Kurisu.SqlSugar.Services;
|
//using Kurisu.SqlSugar.Services;
|
||||||
using Microsoft.AspNetCore.Identity;
|
//using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.Options;
|
//using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Dlhis.ScheduledTask.CommonJobs
|
//namespace Dlhis.ScheduledTask.CommonJobs
|
||||||
{
|
//{
|
||||||
public class TempCreateUserJob
|
// public class TempCreateUserJob
|
||||||
{
|
// {
|
||||||
private readonly IDbContext _dbContext;
|
// private readonly IDbContext _dbContext;
|
||||||
private readonly ILogger<TempCreateUserJob> _logger;
|
// private readonly ILogger<TempCreateUserJob> _logger;
|
||||||
private readonly IdentityServerOptions _identityServerOptions;
|
// private readonly IdentityServerOptions _identityServerOptions;
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
// private readonly IHttpClientFactory _httpClientFactory;
|
||||||
|
|
||||||
public TempCreateUserJob(
|
// public TempCreateUserJob(
|
||||||
IDbContext dbContext,
|
// IDbContext dbContext,
|
||||||
ILogger<TempCreateUserJob> logger,
|
// ILogger<TempCreateUserJob> logger,
|
||||||
IOptions<IdentityServerOptions> options,
|
// IOptions<IdentityServerOptions> options,
|
||||||
IHttpClientFactory httpClientFactory)
|
// IHttpClientFactory httpClientFactory)
|
||||||
{
|
// {
|
||||||
_dbContext = dbContext;
|
// _dbContext = dbContext;
|
||||||
_logger = logger;
|
// _logger = logger;
|
||||||
_httpClientFactory = httpClientFactory;
|
// _httpClientFactory = httpClientFactory;
|
||||||
_identityServerOptions = options.Value;
|
// _identityServerOptions = options.Value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task RunAsync()
|
// public async Task RunAsync()
|
||||||
{
|
// {
|
||||||
_dbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
|
// _dbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
|
|
||||||
//var identityDbContext = _dbContext.ChangeDb("identity");
|
// //var identityDbContext = _dbContext.ChangeDb("identity");
|
||||||
|
|
||||||
////HST0001
|
// ////HST0001
|
||||||
//var users = await identityDbContext.Queryable<UserEntity>().Where(x => x.UserName != "HST0001")
|
// //var users = await identityDbContext.Queryable<UserEntity>().Where(x => x.UserName != "HST0001")
|
||||||
// .Where(x => x.Id > 21)
|
// // .Where(x => x.Id > 21)
|
||||||
// .ToListAsync();
|
// // .ToListAsync();
|
||||||
|
|
||||||
//var gainfos = await _dbContext.Queryable<GainfoEntity>().ToListAsync();
|
// //var gainfos = await _dbContext.Queryable<GainfoEntity>().ToListAsync();
|
||||||
|
|
||||||
//var hasher = new PasswordHasher<UserEntity>();
|
// //var hasher = new PasswordHasher<UserEntity>();
|
||||||
//foreach (var user in users)
|
// //foreach (var user in users)
|
||||||
//{
|
// //{
|
||||||
// var gainfo = gainfos.FirstOrDefault(x => x.Code == user.UserName);
|
// // var gainfo = gainfos.FirstOrDefault(x => x.Code == user.UserName);
|
||||||
// if (gainfo != null && gainfo.IdNo.IsPresent())
|
// // if (gainfo != null && gainfo.IdNo.IsPresent())
|
||||||
// {
|
// // {
|
||||||
// var password = gainfo.IdNo.TakeLast(6).Join("");
|
// // var password = gainfo.IdNo.TakeLast(6).Join("");
|
||||||
// password = hasher.HashPassword(user, password);
|
// // password = hasher.HashPassword(user, password);
|
||||||
// user.PasswordHash = password;
|
// // user.PasswordHash = password;
|
||||||
// await identityDbContext.UpdateAsync(user);
|
// // await identityDbContext.UpdateAsync(user);
|
||||||
// }
|
// // }
|
||||||
//}
|
// //}
|
||||||
|
|
||||||
//var userNames = await identityDbContext.Queryable<UserEntity>().Select(x => x.UserName).ToListAsync();
|
// //var userNames = await identityDbContext.Queryable<UserEntity>().Select(x => x.UserName).ToListAsync();
|
||||||
//var newUser = await _dbContext.Queryable<GainfoEntity>()
|
// //var newUser = await _dbContext.Queryable<GainfoEntity>()
|
||||||
// .Where(x => !string.IsNullOrEmpty(x.Code))
|
// // .Where(x => !string.IsNullOrEmpty(x.Code))
|
||||||
// .Where(x => !userNames.Contains(x.Code))
|
// // .Where(x => !userNames.Contains(x.Code))
|
||||||
// .Select(x => new
|
// // .Select(x => new
|
||||||
// {
|
// // {
|
||||||
// x.Code,
|
// // x.Code,
|
||||||
// x.Factory,
|
// // x.Factory,
|
||||||
// x.Name,
|
// // x.Name,
|
||||||
// })
|
// // })
|
||||||
// .ToListAsync();
|
// // .ToListAsync();
|
||||||
|
|
||||||
//var httpClient = _httpClientFactory.CreateClient();
|
// //var httpClient = _httpClientFactory.CreateClient();
|
||||||
//httpClient.BaseAddress = new Uri(_identityServerOptions.Authority);
|
// //httpClient.BaseAddress = new Uri(_identityServerOptions.Authority);
|
||||||
|
|
||||||
//var hasher = new PasswordHasher<UserEntity>();
|
// //var hasher = new PasswordHasher<UserEntity>();
|
||||||
//foreach (var item in newUser)
|
// //foreach (var item in newUser)
|
||||||
//{
|
// //{
|
||||||
// var userName = item.Code;
|
// // var userName = item.Code;
|
||||||
// var password = item.Code;
|
// // var password = item.Code;
|
||||||
// var factory = item.Factory;
|
// // var factory = item.Factory;
|
||||||
|
|
||||||
// if (password.Length > 6)
|
// // if (password.Length > 6)
|
||||||
// {
|
// // {
|
||||||
// password = string.Join("", password.TakeLast(6));
|
// // password = string.Join("", password.TakeLast(6));
|
||||||
// }
|
// // }
|
||||||
// else
|
// // else
|
||||||
// {
|
// // {
|
||||||
// password = password.PadLeft(6, '0');
|
// // password = password.PadLeft(6, '0');
|
||||||
// }
|
// // }
|
||||||
// var user = new UserEntity
|
// // var user = new UserEntity
|
||||||
// {
|
// // {
|
||||||
// UserName = userName,
|
// // UserName = userName,
|
||||||
// NormalizedUserName = userName.ToUpper(),
|
// // NormalizedUserName = userName.ToUpper(),
|
||||||
// ConcurrencyStamp = Guid.NewGuid().ToString(),
|
// // ConcurrencyStamp = Guid.NewGuid().ToString(),
|
||||||
// SecurityStamp = Guid.NewGuid().ToString(),
|
// // SecurityStamp = Guid.NewGuid().ToString(),
|
||||||
// };
|
// // };
|
||||||
|
|
||||||
// password = hasher.HashPassword(user, password);
|
// // password = hasher.HashPassword(user, password);
|
||||||
// user.PasswordHash = password;
|
// // user.PasswordHash = password;
|
||||||
// var id = (int)await identityDbContext.InsertReturnIdentityAsync(user);
|
// // var id = (int)await identityDbContext.InsertReturnIdentityAsync(user);
|
||||||
|
|
||||||
// await identityDbContext.InsertAsync(new UserTenantEntity() { UserId = id, TenantCode = factory });
|
// // await identityDbContext.InsertAsync(new UserTenantEntity() { UserId = id, TenantCode = factory });
|
||||||
// await identityDbContext.InsertAsync(new List<UserClaimEntity>
|
// // await identityDbContext.InsertAsync(new List<UserClaimEntity>
|
||||||
// {
|
// // {
|
||||||
// new UserClaimEntity{ UserId = id , ClaimType ="preferred_username", ClaimValue = item.Name},
|
// // new UserClaimEntity{ UserId = id , ClaimType ="preferred_username", ClaimValue = item.Name},
|
||||||
// new UserClaimEntity{ UserId = id , ClaimType ="jinko-code", ClaimValue = item.Code},
|
// // new UserClaimEntity{ UserId = id , ClaimType ="jinko-code", ClaimValue = item.Code},
|
||||||
// });
|
// // });
|
||||||
//}
|
// //}
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
_logger.LogError(ex, "创建用户失败:{message}", ex.Message);
|
// _logger.LogError(ex, "创建用户失败:{message}", ex.Message);
|
||||||
}
|
// }
|
||||||
finally
|
// finally
|
||||||
{
|
// {
|
||||||
_dbContext.Client.QueryFilter.Restore();
|
// _dbContext.Client.QueryFilter.Restore();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ public class JobPack : BaseAppPack
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
RecurringJob.AddOrUpdate<TempCreateUserJob>("TempCreateUser", s => s.RunAsync(), "0 0 5 * * ?", new RecurringJobOptions
|
//RecurringJob.AddOrUpdate<TempCreateUserJob>("TempCreateUser", s => s.RunAsync(), "0 0 5 * * ?", new RecurringJobOptions
|
||||||
{
|
//{
|
||||||
TimeZone = TimeZoneInfo.Local
|
// TimeZone = TimeZoneInfo.Local
|
||||||
});
|
//});
|
||||||
|
|
||||||
//删除前三天前的日志
|
//删除前三天前的日志
|
||||||
RecurringJob.AddOrUpdate<DelApiLogTaskJob>("DelApiLogTask", s => s.RunAsync(), "0 0 */7 * *", new RecurringJobOptions
|
RecurringJob.AddOrUpdate<DelApiLogTaskJob>("DelApiLogTask", s => s.RunAsync(), "0 0 */7 * *", new RecurringJobOptions
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class SqlSugarPack : BaseAppPack
|
|||||||
|
|
||||||
return new List<ConnectionConfig>
|
return new List<ConnectionConfig>
|
||||||
{
|
{
|
||||||
new ConnectionConfig
|
new()
|
||||||
{
|
{
|
||||||
ConfigId = "identity",
|
ConfigId = "identity",
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@ public class SqlSugarPack : BaseAppPack
|
|||||||
DisableNvarchar = true,
|
DisableNvarchar = true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new ConnectionConfig
|
new()
|
||||||
{
|
{
|
||||||
ConfigId = "log",
|
ConfigId = "log",
|
||||||
|
|
||||||
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
|
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class SapPersonComparer : IEqualityComparer<SapPersonItem>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private string SubString(string s, int len)
|
private static string SubString(string s, int len)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(s))
|
if (string.IsNullOrWhiteSpace(s))
|
||||||
{
|
{
|
||||||
@@ -87,7 +87,7 @@ public class SapPersonComparer : IEqualityComparer<SapPersonItem>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private DateTime? SafeParseDate(string str)
|
private static DateTime? SafeParseDate(string str)
|
||||||
{
|
{
|
||||||
if (str == "0000-00-00" || str == "0001-01-01" || str == "1900-01-01")
|
if (str == "0000-00-00" || str == "0001-01-01" || str == "1900-01-01")
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class SyncPersonJob
|
|||||||
|
|
||||||
foreach (var searchCodes in chunks)
|
foreach (var searchCodes in chunks)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("SAP分批处理Chunk数量:{count}", searchCodes.Count());
|
_logger.LogInformation("SAP分批处理Chunk数量:{count}", searchCodes.Length);
|
||||||
var existsWorkCodes = dbContext.Queryable<GainfoSapEntity>()
|
var existsWorkCodes = dbContext.Queryable<GainfoSapEntity>()
|
||||||
.Where(x => searchCodes.Contains(x.ename))
|
.Where(x => searchCodes.Contains(x.ename))
|
||||||
.Select(x => x.ename)
|
.Select(x => x.ename)
|
||||||
@@ -390,7 +390,7 @@ public class SyncPersonJob
|
|||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@@ -398,14 +398,14 @@ public class SyncPersonJob
|
|||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetNative(string idno)
|
private static string GetNative(string idno)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(idno) || idno.Length < 6) return null;
|
if (string.IsNullOrWhiteSpace(idno) || idno.Length < 6) return null;
|
||||||
idno = idno.TrimStart();
|
idno = idno.TrimStart();
|
||||||
return idno.Substring(0, 6);
|
return idno.Substring(0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTime? SafeParseDate(string str)
|
private static DateTime? SafeParseDate(string str)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(str))
|
if (string.IsNullOrEmpty(str))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -210,12 +210,12 @@ public class AssignmentService : IAssignmentService
|
|||||||
Enable = true,
|
Enable = true,
|
||||||
Sections = new List<TimePeriodWeekDaySection>()
|
Sections = new List<TimePeriodWeekDaySection>()
|
||||||
{
|
{
|
||||||
new TimePeriodWeekDaySection()
|
new()
|
||||||
{
|
{
|
||||||
DayOfWeek= DayOfWeek.Monday,
|
DayOfWeek= DayOfWeek.Monday,
|
||||||
TimePeriods = new List<TimePeriod>()
|
TimePeriods = new List<TimePeriod>()
|
||||||
{
|
{
|
||||||
new TimePeriod
|
new()
|
||||||
{
|
{
|
||||||
Start = TimeOnly.Parse("08:00:00"),
|
Start = TimeOnly.Parse("08:00:00"),
|
||||||
End = TimeOnly.Parse("17:30:00"),
|
End = TimeOnly.Parse("17:30:00"),
|
||||||
@@ -236,7 +236,7 @@ public class AssignmentService : IAssignmentService
|
|||||||
Name = "计划的一部分",
|
Name = "计划的一部分",
|
||||||
Schedules = new List<ScheduleDto>
|
Schedules = new List<ScheduleDto>
|
||||||
{
|
{
|
||||||
new ScheduleDto
|
new()
|
||||||
{
|
{
|
||||||
Name = "国庆节",
|
Name = "国庆节",
|
||||||
DateTimePeriod = new DateTimePeriod
|
DateTimePeriod = new DateTimePeriod
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class RoleService : IRoleService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task CheckDuplicateNameAsync(IDbContext db, RoleSaveRequest request)
|
private static async Task CheckDuplicateNameAsync(IDbContext db, RoleSaveRequest request)
|
||||||
{
|
{
|
||||||
var exists = await db.Queryable<RoleEntity>()
|
var exists = await db.Queryable<RoleEntity>()
|
||||||
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
.WhereIF(request.Id.HasValue, x => x.Id != request.Id)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class TenantService : ITenantService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void RecursionGetNext(TenantTreeResponse current, List<TenantTreeResponse> data)
|
private static void RecursionGetNext(TenantTreeResponse current, List<TenantTreeResponse> data)
|
||||||
{
|
{
|
||||||
var next = data.Where(x => x.PCode == current.Code).ToList();
|
var next = data.Where(x => x.PCode == current.Code).ToList();
|
||||||
current.Next = next;
|
current.Next = next;
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public class MenuService : IMenuService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void RecursionGetNext(MenuResponse current, List<MenuResponse> menus)
|
private static void RecursionGetNext(MenuResponse current, List<MenuResponse> menus)
|
||||||
{
|
{
|
||||||
var nextMenus = menus.Where(x => x.PCode == current.Code).ToList();
|
var nextMenus = menus.Where(x => x.PCode == current.Code).ToList();
|
||||||
current.Items = nextMenus;
|
current.Items = nextMenus;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class Startup
|
|||||||
services.AddOcelot();
|
services.AddOcelot();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(c =>
|
app.UseSwaggerUI(c =>
|
||||||
|
|||||||
Reference in New Issue
Block a user