diff --git a/Dlhis.Jinko.Face.sln b/Dlhis.Jinko.Face.sln index 3a2f5093..8ab23f97 100644 --- a/Dlhis.Jinko.Face.sln +++ b/Dlhis.Jinko.Face.sln @@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.InfoCheck.Api", "Src\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Jip.Api", "Src\Dlhis.Jip.Api\Dlhis.Jip.Api.csproj", "{841B7B43-5394-413F-9D68-A07EBDD6D4CD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Dh.Api", "Src\Dlhis.Dh.Api\Dlhis.Dh.Api.csproj", "{E673CA04-3567-4E03-9A86-994F50291ACC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -111,6 +113,10 @@ Global {841B7B43-5394-413F-9D68-A07EBDD6D4CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {841B7B43-5394-413F-9D68-A07EBDD6D4CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {841B7B43-5394-413F-9D68-A07EBDD6D4CD}.Release|Any CPU.Build.0 = Release|Any CPU + {E673CA04-3567-4E03-9A86-994F50291ACC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E673CA04-3567-4E03-9A86-994F50291ACC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E673CA04-3567-4E03-9A86-994F50291ACC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E673CA04-3567-4E03-9A86-994F50291ACC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -127,6 +133,7 @@ Global {4D656761-8CE7-4316-A3DF-8C1722D69CCE} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} {A501D16E-638F-4156-989C-2BACCC2FAC2B} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} {841B7B43-5394-413F-9D68-A07EBDD6D4CD} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} + {E673CA04-3567-4E03-9A86-994F50291ACC} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0} diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs index 4fc51e33..46ccebb6 100644 --- a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs +++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs @@ -2,6 +2,8 @@ using Dlhis.Basic.Appointment.Response; using Dlhis.Basic.Organization.Request; using Dlhis.Basic.Organization.Services; +using Dlhis.Dh.Api; +using Dlhis.Dh.Api.Requests; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; @@ -24,16 +26,22 @@ public class AppointmentService : IAppointmentService private readonly IDbContext _dbContext; private readonly IDataProtectionProvider _dataProtectionProvider; private readonly ICurrentUser _currentUser; + private readonly IDhApi _dhApi; + private readonly ILogger _logger; private readonly IGainfoFaceService _gainfoFaceService; public AppointmentService(IDbContext dbContext, IDataProtectionProvider dataProtectionProvider, ICurrentUser currentUser, - IGainfoFaceService gainfoFaceService) + IDhApi dhApi, + IGainfoFaceService gainfoFaceService, + ILogger logger) { _dbContext = dbContext; _dataProtectionProvider = dataProtectionProvider; _currentUser = currentUser; + _dhApi = dhApi; + _logger = logger; _gainfoFaceService = gainfoFaceService; } @@ -44,7 +52,11 @@ public class AppointmentService : IAppointmentService return await _dbContext.Queryable() .WhereIF(request.SearchDateTimePeriod.HasValue(), x => x.Date >= request.SearchDateTimePeriod.Start && x.Date <= request.SearchDateTimePeriod.End) - .WhereIF(request.Search.IsPresent(), x => x.Code == request.Search) + .WhereIF(request.Search.IsPresent(), x => x.Code == request.Search || + SqlFunc.Subqueryable() + .Where(p => p.No != x.No) + .Where(p => p.IdNo == request.Search || p.Name == request.Search).Any() + ) .Where(x => x.Factory == factory) .Select() .ToPageListAsync(request); @@ -94,6 +106,19 @@ public class AppointmentService : IAppointmentService detail.ArrivedTime = DateTime.Now; await _dbContext.UpdateAsync(detail); + + try + { + await _dhApi.SendFaceAsync(new FaceRequest + { + IdNo = detail.IdNo, + Face = request.Base64Image + }); + } + catch (Exception e) + { + _logger.LogError(e, "上传face数据到大华失败:{msg}", e.Message); + } } public async Task GenerateTaskAndUpdateFaceAsync(long detailId, string base64, DeviceTaskEnumType deviceTaskType) diff --git a/Src/Dlhis.Basic/Dlhis.Basic.csproj b/Src/Dlhis.Basic/Dlhis.Basic.csproj index 35ddb2dd..eb9f5b54 100644 --- a/Src/Dlhis.Basic/Dlhis.Basic.csproj +++ b/Src/Dlhis.Basic/Dlhis.Basic.csproj @@ -26,6 +26,7 @@ + diff --git a/Src/Dlhis.Basic/Dockerfile b/Src/Dlhis.Basic/Dockerfile index 27321d53..163112c5 100644 --- a/Src/Dlhis.Basic/Dockerfile +++ b/Src/Dlhis.Basic/Dockerfile @@ -1,27 +1,33 @@ -#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. +# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器,以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。 +# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时 FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 80 + +# 此阶段用于生成服务项目 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["Src/Dlhis.Basic/Dlhis.Basic.csproj", "Src/Dlhis.Basic/"] +COPY ["Src/Dlhis.Dh.Api/Dlhis.Dh.Api.csproj", "Src/Dlhis.Dh.Api/"] COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"] COPY ["Src/Dlhis.DataPermission.Model/Dlhis.DataPermission.Model.csproj", "Src/Dlhis.DataPermission.Model/"] COPY ["Src/Dlhis.InfoCheck.Api/Dlhis.InfoCheck.Api.csproj", "Src/Dlhis.InfoCheck.Api/"] -COPY ["Src/Dlhis.Scheduled.Api/Dlhis.Scheduled.Api.csproj", "Src/Dlhis.Scheduled.Api/"] +COPY ["Src/Dlhis.Jip.Api/Dlhis.Jip.Api.csproj", "Src/Dlhis.Jip.Api/"] COPY ["Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj", "Src/Dlhis.Sys.Api/"] -RUN dotnet restore "./Src/Dlhis.Basic/./Dlhis.Basic.csproj" +RUN dotnet restore "./Src/Dlhis.Basic/Dlhis.Basic.csproj" COPY . . WORKDIR "/src/Src/Dlhis.Basic" RUN dotnet build "./Dlhis.Basic.csproj" -c $BUILD_CONFIGURATION -o /app/build +# 此阶段用于发布要复制到最终阶段的服务项目 FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "./Dlhis.Basic.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +# 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值) FROM base AS final WORKDIR /app COPY --from=publish /app/publish . diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs index 1801ea53..822ca79d 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoPermissionsController.cs @@ -23,17 +23,6 @@ public class GainfoPermissionsController : ControllerBase _gainfoPermissions = gainfoPermissions; } - /// - /// 根据用户查看餐饮点 - /// - /// - /// - [HttpGet("placesByGainfo")] - public async Task> GetPlaceByGainfoAsync([FromQuery] DeviceAssRequest request) - { - return await _gainfoPermissions.GetPlaceByGainfoAsync(request); - } - /// /// 根据档案号 设备组查询设备 /// @@ -57,16 +46,6 @@ public class GainfoPermissionsController : ControllerBase return await _gainfoPermissions.GetAssignDeviceCodesAsync(request); } - /// - /// 当前绑定的设备组信息 - /// - /// - [HttpGet("assignGroups")] - public async Task> GetAssignGroupAsync(string userNo) - { - return await _gainfoPermissions.GetAssignGroupAsync(userNo); - } - /// /// 权限重置 /// diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoPermissionService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoPermissionService.cs index 03ce1e5b..c5b15bb0 100644 --- a/Src/Dlhis.Basic/Organization/Services/IGainfoPermissionService.cs +++ b/Src/Dlhis.Basic/Organization/Services/IGainfoPermissionService.cs @@ -9,13 +9,9 @@ namespace Dlhis.Basic.Organization.Services; public interface IGainfoPermissionService : IScopeDependency { - Task> GetPlaceByGainfoAsync(DeviceAssRequest request); - Task> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode); Task> GetAssignDeviceCodesAsync(DeviceAssRequest request); - Task> GetAssignGroupAsync(string userNo); - Task ResetPermissionsAsync(string userNo, DeviceTaskEnumType type, List deviceCodes); } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissionService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissionService.cs index 4867ada3..0a65dcd7 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissionService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoPermissionService.cs @@ -29,44 +29,6 @@ public class GainfoPermissionService : IGainfoPermissionService _dbContext = dbContext; } - public async Task> GetPlaceByGainfoAsync(DeviceAssRequest request) - { - var gainfo = await _gainfoStore.Queryable() - .Where(x => x.No == request.UserNo) - .SingleAsync(); - - if (gainfo == null) - { - return new Pagination(); - } - - //用户所有deviceCode权限 - var deviceCodes = await _devicePermissionAnalyzeService.GetAssignDeviceCodesAsync(gainfo.Code); - - return await _dbContext.Queryable() - .LeftJoin((x, dr) => x.UniqueNo == dr.DeviceUniqueNo) - .LeftJoin((x, dr, place) => dr.BusinessPlaceCode == place.Code) - .LeftJoin((x, dr, place, ps) => place.Code == ps.PlaceCode) - .LeftJoin((x, dr, place, ps, s) => s.Code == ps.ShiftCode) - .Where(x => x.Type == DeviceTypeEnumType.Meal) - .Where(x => deviceCodes.Contains(x.Code)) - .Where((x, dr) => dr.BusinessPlaceCode.HasValue) - .Select((x, dr, place, ps, s) => new BusinessPlaceResponse - { - Id = place.Id, - Code = place.Code, - Status = place.Status, - Name = place.Name, - Catalog = place.Catalog, - CustomCode = place.CustomCode, - Source = place.Source, - - ShiftCode = s.Code, - ShiftName = s.Name - }) - .Distinct() - .ToPageListAsync(request); - } public async Task> GetDevicesUnderGroupByUserNoAsync(string userNo, Guid deviceGroupCode) { @@ -129,6 +91,7 @@ public class GainfoPermissionService : IGainfoPermissionService var page = await _dbContext.Queryable() .LeftJoin((d, dr) => d.UniqueNo == dr.DeviceUniqueNo) .WhereIF(request.DeviceType.HasValue, d => d.Type == request.DeviceType) + .WhereIF(request.Search.IsPresent(), d => d.UniqueNo == request.Search) .Where(d => codes.Contains(d.Code)) .Select((d, dr) => new GainfoDevicePermissionResponse { Factory = d.TenantId }, true) .ToPageListAsync(request); @@ -239,21 +202,4 @@ public class GainfoPermissionService : IGainfoPermissionService var deleteCount = type == DeviceTaskEnumType.Delete ? tasks.Count : 0; return new DevicePermissionAssignResponse(addCount, deleteCount); } - - - public async Task> GetAssignGroupAsync(string userNo) - { - //(DeviceAssignmentTypeEnumType.Group, AssignTypeEnumType.User, userNo - var groups = await _devicePermissionAnalyzeService.GetAssignmentsAsync(new DeviceGetAssignmentsRequest - { - UniqueType = DeviceAssignmentTypeEnumType.Group, - AssignType = AssignTypeEnumType.User, - AssignValue = userNo - }); - - return await _dbContext.Queryable() - .Where(x => groups.Contains(x.Code)) - .Select() - .ToListAsync(); - } } \ No newline at end of file diff --git a/Src/Dlhis.Dh.Api/Dlhis.Dh.Api.csproj b/Src/Dlhis.Dh.Api/Dlhis.Dh.Api.csproj new file mode 100644 index 00000000..b41f2841 --- /dev/null +++ b/Src/Dlhis.Dh.Api/Dlhis.Dh.Api.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + disable + + + + + + + diff --git a/Src/Dlhis.Dh.Api/IDhApi.cs b/Src/Dlhis.Dh.Api/IDhApi.cs new file mode 100644 index 00000000..b6f97acd --- /dev/null +++ b/Src/Dlhis.Dh.Api/IDhApi.cs @@ -0,0 +1,13 @@ +using Dlhis.Dh.Api.Requests; +using Dlhis.Dh.Api.ResultHandlers; +using Kurisu.RemoteCall.Attributes; + +namespace Dlhis.Dh.Api; + +[EnableRemoteClient(Name = "dh-service", BaseUrl = "https://10.32.0.100")] +public interface IDhApi +{ + [Post("/evo-apigw/evo-visitor/1.0.0/card/visitor/custom-face")] + [RequestResultHandler(typeof(DhResultHandler))] + Task SendFaceAsync(FaceRequest request); +} \ No newline at end of file diff --git a/Src/Dlhis.Dh.Api/Requests/FaceRequest.cs b/Src/Dlhis.Dh.Api/Requests/FaceRequest.cs new file mode 100644 index 00000000..0ed7760a --- /dev/null +++ b/Src/Dlhis.Dh.Api/Requests/FaceRequest.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json; + +namespace Dlhis.Dh.Api.Requests; + +public class FaceRequest +{ + [JsonProperty("v_certificateNumber")] + public string IdNo { get; set; } + + public string Face { get; set; } + + [JsonProperty("faceFile")] + public string FaceFile => "data:image/jpeg;base64," + Face; +} \ No newline at end of file diff --git a/Src/Dlhis.Dh.Api/ResultHandlers/DhResultHandler.cs b/Src/Dlhis.Dh.Api/ResultHandlers/DhResultHandler.cs new file mode 100644 index 00000000..515f127f --- /dev/null +++ b/Src/Dlhis.Dh.Api/ResultHandlers/DhResultHandler.cs @@ -0,0 +1,43 @@ +using System.Net; +using Kurisu.RemoteCall.Abstractions; +using Mapster; +using Newtonsoft.Json; + +namespace Dlhis.Dh.Api.ResultHandlers; + +public class DhResultHandler : IRemoteCallResultHandler +{ + /// + public TResult Handle(HttpStatusCode statusCode, string responseBody) + { + var apiResult = JsonConvert.DeserializeObject(responseBody)!; + + var isSuccessStatusCode = ((int)statusCode >= 200) && ((int)statusCode <= 299); + if (!isSuccessStatusCode || apiResult.Success == false) + { + if (!string.IsNullOrEmpty(apiResult.ErrMsg)) + { + throw new Exception(apiResult.ErrMsg); + } + + throw new HttpRequestException(statusCode + " " + (int)statusCode); + } + + return responseBody.Adapt(); + } +} + +public class DhResponse +{ + public bool Success { get; set; } + + public string Code { get; set; } + + public string ErrMsg { get; set; } +} + +// { +// "success": true, +// "code": "0", +// "errMsg": "请求成功" +// } \ No newline at end of file diff --git a/Src/Dlhis.Entity/Sys/Enums/AssignTypeEnumType.cs b/Src/Dlhis.Entity/Sys/Enums/AssignTypeEnumType.cs index 7b96e746..8a9dba9f 100644 --- a/Src/Dlhis.Entity/Sys/Enums/AssignTypeEnumType.cs +++ b/Src/Dlhis.Entity/Sys/Enums/AssignTypeEnumType.cs @@ -35,6 +35,6 @@ public enum AssignTypeEnumType /// /// 租户/基地 /// - [Description("租户/基地")] + [Description("厂区")] Tenant = 5 } \ No newline at end of file diff --git a/Src/Dlhis.Middle/Apis/Handlers/HealthzClientHandler.cs b/Src/Dlhis.Middle/Apis/Handlers/HealthzClientHandler.cs index 9cffe733..ccef750e 100644 --- a/Src/Dlhis.Middle/Apis/Handlers/HealthzClientHandler.cs +++ b/Src/Dlhis.Middle/Apis/Handlers/HealthzClientHandler.cs @@ -1,4 +1,7 @@ +using System.Net; using Kurisu.RemoteCall.Abstractions; +using Polly; +using Polly.Extensions.Http; namespace Dlhis.Middle.Apis.Handlers; @@ -8,16 +11,24 @@ public class HealthzClientHandler : IHttpRemoteCallPolicyHandler public IHttpClientBuilder ConfigureHttpClient(IHttpClientBuilder builder) { builder.ConfigureHttpClient(client => { client.Timeout = TimeSpan.FromSeconds(10); }).ConfigurePrimaryHttpMessageHandler(() => - { - var handler = new HttpClientHandler { - ClientCertificateOptions = ClientCertificateOption.Manual, - ServerCertificateCustomValidationCallback = (_, _, _, _) => true - }; + var handler = new HttpClientHandler + { + ClientCertificateOptions = ClientCertificateOption.Manual, + ServerCertificateCustomValidationCallback = (_, _, _, _) => true + }; + + return handler; + }) + //.SetHandlerLifetime(TimeSpan.FromMinutes(5)) + .AddPolicyHandler( + HttpPolicyExtensions + .HandleTransientHttpError() + .OrResult(x => x.StatusCode != HttpStatusCode.OK) + //.OrResult(msg => msg.StatusCode != HttpStatusCode.OK) + .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))) + ); - return handler; - }); - return builder; } } \ No newline at end of file diff --git a/Src/Dlhis.Middle/Dlhis.Middle.csproj b/Src/Dlhis.Middle/Dlhis.Middle.csproj index 07f7413e..ce0a4696 100644 --- a/Src/Dlhis.Middle/Dlhis.Middle.csproj +++ b/Src/Dlhis.Middle/Dlhis.Middle.csproj @@ -19,6 +19,7 @@ + diff --git a/Src/Dlhis.Middle/Packs/SqlSugarPack.cs b/Src/Dlhis.Middle/Packs/SqlSugarPack.cs index b9c95a03..06656513 100644 --- a/Src/Dlhis.Middle/Packs/SqlSugarPack.cs +++ b/Src/Dlhis.Middle/Packs/SqlSugarPack.cs @@ -1,136 +1,13 @@ -using Dlhis.Middle.Entities; -using Kurisu.AspNetCore.Authentication.Abstractions; -using Kurisu.AspNetCore.DataAccess.Entity; -using Kurisu.AspNetCore.DataAccess.SqlSugar.Attributes; -using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; -using Kurisu.AspNetCore.DataAccess.SqlSugar.Options; -using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions; using Kurisu.AspNetCore.Startup; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Options; using SqlSugar; namespace Dlhis.Middle.Packs; public class SqlSugarPack : BaseAppPack { - private const string _infoTemplate = "ExecuteCommand[{ms}] Timeout[{timeout}] \r\n {sql}"; - public override void ConfigureServices(IServiceCollection services) { - services.AddSqlSugar(); - services.Replace(ServiceDescriptor.Scoped(typeof(ISqlSugarClient), sp => - { - var options = sp.GetService>().Value; - var logger = sp.GetService>(); - var currentUser = sp.GetService(); - var sugarOptions = sp.GetService(); - - var configs = new List - { - new() - { - ConfigId = "db-main", - - ConnectionString = options.DefaultConnectionString, - DbType = DbType.Sqlite, - InitKeyType = InitKeyType.Attribute, - IsAutoCloseConnection = true, - - MoreSettings = new ConnMoreSettings - { - DisableNvarchar = true, - }, - ConfigureExternalServices = new ConfigureExternalServices - { - EntityService = (c, p) => - { - if (!p.IsPrimarykey && c.PropertyType.IsGenericType && c.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>) - || (!p.IsPrimarykey && p.PropertyInfo.PropertyType == typeof(string))) - { - p.IsNullable = true; - } - } - } - } - }; - - ISqlSugarClient db = new SqlSugarClient(configs); - - db.Ado.CommandTimeOut = options.Timeout; - - db.Aop.OnLogExecuted = (sql, parameters) => - { - var ms = db.Ado.SqlExecutionTime.Milliseconds; - - //警告慢sql - if (ms >= options.SlowSqlTime * 1000) - logger.LogWarning(message: _infoTemplate, ms, options.Timeout, sql); - - if (options.EnableSqlLog) - { - sql = UtilMethods.GetSqlString(DbType.MySql, sql, parameters); - logger.LogInformation(message: _infoTemplate, ms, options.Timeout, sql); - } - }; - - //软删除 - db.QueryFilter.AddTableFilter(x => x.IsDeleted == false); - - - //增删改 - db.Aop.DataExecuting = (oldValue, model) => - { - if (sugarOptions.IgnoreTenant == false //启用租户 - && currentUser != null //用户信息存在 - && model.PropertyName == nameof(ITenantId.TenantId) //当前为租户字段 - && typeof(ITenantId).IsAssignableFrom(model.EntityValue.GetType())) //继承ITenantId - { - var tenant = currentUser.GetStringTenantId(); - model.SetValue(tenant); - } - - //处理人员和时间字段 - switch (model.OperationType) - { - case DataFilterType.InsertByObject: - { - if (model.IsAnyAttribute()) - { - model.SetValue(DateTime.Now); - } - - if (currentUser != null && model.IsAnyAttribute()) - { - if ((int)model.EntityColumnInfo.PropertyInfo.GetValue(model.EntityValue) == 0) - { - model.SetValue(currentUser.GetStringSubjectId()); - } - } - - break; - } - case DataFilterType.UpdateByObject: - { - if (model.IsAnyAttribute()) - { - model.SetValue(DateTime.Now); - } - - if (currentUser != null && model.IsAnyAttribute()) - { - if ((int)model.EntityColumnInfo.PropertyInfo.GetValue(model.EntityValue) == 0) - { - model.SetValue(currentUser.GetStringSubjectId()); - } - } - - break; - } - } - }; - - return db; - })); + services.AddSqlSugar(DbType.Sqlite); } } \ No newline at end of file diff --git a/Src/Dlhis.Middle/Program.cs b/Src/Dlhis.Middle/Program.cs index b07548a2..8d787f49 100644 --- a/Src/Dlhis.Middle/Program.cs +++ b/Src/Dlhis.Middle/Program.cs @@ -2,6 +2,7 @@ using Dlhis.Middle.BackgroundServices; using Dlhis.Middle.Entities; using Dlhis.Middle.Services; using Kurisu.AspNetCore; +using Kurisu.AspNetCore.Authentication.Extensions; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; using Kurisu.AspNetCore.Startup; using Microsoft.IdentityModel.Logging; @@ -32,6 +33,7 @@ public class Startup : DefaultStartup services.AddRemoteCall(App.ActiveTypes); services.AddMemoryCache(); + services.AddUserInfo(); } /// diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs index 64f60b9f..df2acb6a 100644 --- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs +++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs @@ -157,20 +157,22 @@ public class DeviceUploadLogService : IDeviceUploadLogService .LeftJoin((os, x) => os.Code == x.UserUniqueNo) .LeftJoin((os, x, device) => x.DeviceUniqueNo == device.UniqueNo) .LeftJoin((os, x, device, ga) => os.Code == ga.Code) - .LeftJoin((os, x, device, ga, gasap) => gasap.Code == os.SapCode) - .WhereIF(request.Search.IsPresent(), (os, x, device, ga, gasap) => + .LeftJoin((os, x, device, ga, gaSap) => gaSap.Code == os.SapCode) + .WhereIF(request.SearchDateTimePeriod.HasValue(), (os, x) => x.RaiseDateTime >= request.SearchDateTimePeriod.Start + && x.RaiseDateTime <= request.SearchDateTimePeriod.End) + .WhereIF(request.Search.IsPresent(), (os, x, device, ga, gaSap) => x.UserUniqueNo == request.Search || x.DeviceUniqueNo == request.Search || os.Supplier == request.Search || os.SapCode == request.Search - ).OrderBy((os, x, device, ga, gasap) => x.ModifiedTime, OrderByType.Desc) - .Select((os, x, device, ga, gasap) => new DeviceUploadLogResponse + ).OrderBy((os, x, device, ga, gaSap) => x.ModifiedTime, OrderByType.Desc) + .Select((os, x, device, ga, gaSap) => new DeviceUploadLogResponse { Id = x.Id, OriginUserUniqueNo = x.UserUniqueNo, OutsourceSupplier = os.Supplier, SapUserCode = os.SapCode, - SapUserName = gasap.Name, + SapUserName = gaSap.Name, DeviceUniqueNo = x.DeviceUniqueNo, RaiseDateTime = x.RaiseDateTime, CreateTime = x.CreateTime, @@ -198,7 +200,8 @@ public class DeviceUploadLogService : IDeviceUploadLogService .LeftJoin((x, device, ga) => x.UserUniqueNo == ga.Code) .LeftJoin((x, device, ga, os) => x.UserUniqueNo == os.Code) .LeftJoin((x, device, ga, os, gasap) => gasap.Code == os.SapCode) - .WhereIF(request.SearchDateTimePeriod.HasValue(), x => x.RaiseDateTime >= request.SearchDateTimePeriod.Start && x.RaiseDateTime <= request.SearchDateTimePeriod.End) + .WhereIF(request.SearchDateTimePeriod.HasValue(), x => x.RaiseDateTime >= request.SearchDateTimePeriod.Start + && x.RaiseDateTime <= request.SearchDateTimePeriod.End) .Where((x, device) => x.Type == type && !SqlFunc.IsNullOrEmpty(x.UserUniqueNo)) .WhereIF(request.Sync.HasValue, x => x.Sync == request.Sync) .WhereIF(request.IsOutsource.HasValue && request.IsOutsource.Value,