diff --git a/Dlhis.Jinko.Face.sln b/Dlhis.Jinko.Face.sln index 977580ec..ec9870dc 100644 --- a/Dlhis.Jinko.Face.sln +++ b/Dlhis.Jinko.Face.sln @@ -21,8 +21,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scheduled", "Scheduled", "{ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Basic", "Src\Dlhis.Basic\Dlhis.Basic.csproj", "{D1F81CB7-F3EF-4196-A751-468248368020}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.User", "Src\Dlhis.User\Dlhis.User.csproj", "{9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Sys", "Src\Dlhis.Sys\Dlhis.Sys.csproj", "{925048C9-5940-4B51-8480-4DC908C754A1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Sys.Api", "Src\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj", "{85A345C7-913E-4C1B-BE1C-600DE408A02F}" @@ -77,10 +75,6 @@ Global {D1F81CB7-F3EF-4196-A751-468248368020}.Debug|Any CPU.Build.0 = Debug|Any CPU {D1F81CB7-F3EF-4196-A751-468248368020}.Release|Any CPU.ActiveCfg = Release|Any CPU {D1F81CB7-F3EF-4196-A751-468248368020}.Release|Any CPU.Build.0 = Release|Any CPU - {9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0}.Release|Any CPU.Build.0 = Release|Any CPU {925048C9-5940-4B51-8480-4DC908C754A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {925048C9-5940-4B51-8480-4DC908C754A1}.Debug|Any CPU.Build.0 = Debug|Any CPU {925048C9-5940-4B51-8480-4DC908C754A1}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -138,7 +132,6 @@ Global {4C1FADD9-8AFB-4087-9E52-EE6D6523ED38} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} {FD8D38C5-0827-49D1-A0BA-7707FBFDA2EC} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} {D1F81CB7-F3EF-4196-A751-468248368020} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} - {9F9BC299-3CDD-4CCE-80CA-5FE57332B1F0} = {57074FD8-1A2F-40C7-8476-001778A3F65D} {925048C9-5940-4B51-8480-4DC908C754A1} = {57074FD8-1A2F-40C7-8476-001778A3F65D} {85A345C7-913E-4C1B-BE1C-600DE408A02F} = {57074FD8-1A2F-40C7-8476-001778A3F65D} {1F337648-8A22-4601-A842-0F634FBA2825} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} diff --git a/Src/Dlhis.Middle/Api/FaceBearerTokenHandler.cs b/Src/Dlhis.Middle/Api/FaceBearerTokenHandler.cs new file mode 100644 index 00000000..a0e806ff --- /dev/null +++ b/Src/Dlhis.Middle/Api/FaceBearerTokenHandler.cs @@ -0,0 +1,37 @@ +using System.Text; +using Dlhis.Middle.Response; +using Kurisu.AspNetCore.UnifyResultAndValidation; +using Kurisu.RemoteCall.Abstractions; +using Microsoft.Extensions.Caching.Memory; +using Newtonsoft.Json; + +namespace Dlhis.Middle.Api +{ + public class FaceBearerTokenHandler : IAuthTokenHandler + { + /// + public string GetToken(IServiceProvider serviceProvider) + { + var cache = serviceProvider.GetService(); + if (cache.TryGetValue("token", out string token)) return "Bearer " + token; + + var httpClient = serviceProvider.GetService().CreateClient("face"); + var hostName = serviceProvider.GetService().GetSection("HostName").Value; + + var tokenResponse = httpClient.PostAsync($"https://{hostName}/api/user/oauth2/clientgrant", new StringContent(JsonConvert.SerializeObject(new + { + ClientId = "e509c2aaa98e300c", + ClientSecret = "6184d8979fc48105" + }), Encoding.UTF8, "application/json")).GetAwaiter().GetResult(); + + var tokenJson = tokenResponse.Content.ReadAsStringAsync().GetAwaiter().GetResult(); + var tokenInfo = JsonConvert.DeserializeObject>(tokenJson); + + token = tokenInfo.Data.AccessToken; + + cache.Set("token", token, TimeSpan.FromSeconds(tokenInfo.Data.Expires)); + + return token; + } + } +} \ No newline at end of file diff --git a/Src/Dlhis.Middle/Api/IAssignmentDeviceTaskApi.cs b/Src/Dlhis.Middle/Api/IAssignmentDeviceTaskApi.cs new file mode 100644 index 00000000..8c856a82 --- /dev/null +++ b/Src/Dlhis.Middle/Api/IAssignmentDeviceTaskApi.cs @@ -0,0 +1,14 @@ +using Dlhis.Middle.Request; +using Dlhis.Middle.Response; +using Kurisu.AspNetCore.UnifyResultAndValidation; +using Kurisu.RemoteCall.Attributes; + +namespace Dlhis.Middle.Api; + +[EnableRemoteClient(Name = "face-service", BaseUrl = "${Authority}")] +public interface IAssignmentDeviceTaskApi +{ + [Auth(TokenHandler = typeof(FaceBearerTokenHandler))] + [Post("/api/scheduled/assignments/deviceTasks")] + Task>> DeviceGetTasksAsync(DeviceTaskGetRequest request); +} \ No newline at end of file diff --git a/Src/Dlhis.Middle/Api/ICanteenApi.cs b/Src/Dlhis.Middle/Api/ICanteenApi.cs new file mode 100644 index 00000000..a48aa144 --- /dev/null +++ b/Src/Dlhis.Middle/Api/ICanteenApi.cs @@ -0,0 +1,15 @@ +using Dlhis.Middle.Request; +using Dlhis.Middle.Response; +using Kurisu.AspNetCore.UnifyResultAndValidation; +using Kurisu.RemoteCall.Attributes; + +namespace Dlhis.Middle.Api; + +[EnableRemoteClient(Name = "face-service", BaseUrl = "${Authority}")] +public interface ICanteenApi +{ + + [Auth(TokenHandler = typeof(FaceBearerTokenHandler))] + [Post("/api/canteen/orders")] + Task> AddAsync(OrderAddRequest request); +} \ No newline at end of file diff --git a/Src/Dlhis.Middle/Controllers/AssignmentsController.cs b/Src/Dlhis.Middle/Controllers/AssignmentsController.cs new file mode 100644 index 00000000..86107959 --- /dev/null +++ b/Src/Dlhis.Middle/Controllers/AssignmentsController.cs @@ -0,0 +1,76 @@ +using Dlhis.Entity.Device.Enums; +using Dlhis.Middle.Api; +using Dlhis.Middle.Request; +using Dlhis.Middle.Response; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; +using Kurisu.AspNetCore.UnifyResultAndValidation; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.WebUtilities; +using Newtonsoft.Json.Linq; + +namespace Dlhis.Middle.Controllers; + +/// +/// 任务分配 +/// +[Route("api/scheduled/[controller]")] +[ApiController] +public class AssignmentsController : ControllerBase +{ + private readonly IAssignmentDeviceTaskApi _assignmentDeviceTaskApi; + private readonly string _internalIp; + + public AssignmentsController(IAssignmentDeviceTaskApi assignmentDeviceTaskApi, IConfiguration configuration) + { + _assignmentDeviceTaskApi = assignmentDeviceTaskApi; + _internalIp = configuration.GetSection("InternalIP").Value; + } + + /// + /// 获取设备任务(按设备) + /// + /// + [IgnoreTenant] + [HttpGet("deviceTasks")] + public async Task>> DeviceGetTasksGetAsync([FromQuery] DeviceTaskGetRequest request) + { + var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request); + foreach (var data in result.Data) + { + foreach (var task in data.Tasks.Where(x => x.Type != DeviceTaskEnumType.Delete)) + { + var currentUser = JObject.FromObject(task.Info).ToObject(); + var token = QueryHelpers.ParseQuery(currentUser.Face).First().Value; + currentUser.Face = $"http://{_internalIp}/api/basic/gainfos/face?token=" + token; + + task.Info = currentUser; + } + } + + return result; + } + + /// + /// 获取设备任务(按设备) + /// + /// + [HttpPost("deviceTasks")] + [IgnoreTenant] + public async Task>> DeviceGetTasksPostAsync(DeviceTaskGetRequest request) + { + var result = await _assignmentDeviceTaskApi.DeviceGetTasksAsync(request); + foreach (var data in result.Data) + { + foreach (var task in data.Tasks.Where(x => x.Type != DeviceTaskEnumType.Delete)) + { + var currentUser = JObject.FromObject(task.Info).ToObject(); + var token = QueryHelpers.ParseQuery(currentUser.Face).First().Value; + currentUser.Face = $"http://{_internalIp}/api/basic/gainfos/face?token=" + token; + + task.Info = currentUser; + } + } + + return result; + } +} \ No newline at end of file diff --git a/Src/Dlhis.Middle/Controllers/GainfosController.cs b/Src/Dlhis.Middle/Controllers/GainfosController.cs new file mode 100644 index 00000000..dc60ef38 --- /dev/null +++ b/Src/Dlhis.Middle/Controllers/GainfosController.cs @@ -0,0 +1,52 @@ +using Dlhis.Middle.Filters; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.Middle.Controllers; + +/// +/// sap档案表 +/// +[Route("api/basic/[controller]")] +[ApiController] +public class GainfosController : ControllerBase +{ + private readonly IHttpClientFactory _httpClientFactory; + private readonly IConfiguration _configuration; + + public GainfosController(IHttpClientFactory httpClientFactory, IConfiguration configuration) + { + _httpClientFactory = httpClientFactory; + _configuration = configuration; + } + + /// + /// 通过token获取人脸照片,失效或者找不到返回HttpStatus404状态码 + /// + /// + /// + [NotFound] + [AllowAnonymous] + [HttpGet("face")] + public async Task GetFaceAsync(string token) + { + var hostName = _configuration.GetSection("HostName").Value; + var httpClient = _httpClientFactory.CreateClient(); + + try + { + var faceBytes = await httpClient.GetByteArrayAsync($"https://{hostName}/api/basic/gainfos/face?token={token}"); + + if (faceBytes.Length == 0) + { + return new NotFoundResult(); + } + + return new FileContentResult(faceBytes, "image/png"); + } + catch (Exception) + { + return new NotFoundResult(); + } + } +} \ No newline at end of file diff --git a/Src/Dlhis.Middle/Controllers/OrdersController.cs b/Src/Dlhis.Middle/Controllers/OrdersController.cs index cadefa56..0813c676 100644 --- a/Src/Dlhis.Middle/Controllers/OrdersController.cs +++ b/Src/Dlhis.Middle/Controllers/OrdersController.cs @@ -1,9 +1,8 @@ -using Dlhis.Middle.Request; +using Dlhis.Middle.Api; +using Dlhis.Middle.Request; using Dlhis.Middle.Response; -using Dlhis.Middle.Services; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Kurisu.AspNetCore.UnifyResultAndValidation; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Dlhis.Middle.Controllers; @@ -15,11 +14,11 @@ namespace Dlhis.Middle.Controllers; [ApiController] public class OrdersController : ControllerBase { - private readonly IOrderService _orderService; + private readonly ICanteenApi _canteenApi; - public OrdersController(IOrderService orderService) + public OrdersController(ICanteenApi canteenApi) { - _orderService = orderService; + _canteenApi = canteenApi; } /// @@ -31,6 +30,6 @@ public class OrdersController : ControllerBase [IgnoreTenant] public async Task> AddAsync(OrderAddRequest request) { - return await _orderService.AddAsync(request); + return await _canteenApi.AddAsync(request); } } \ No newline at end of file diff --git a/Src/Dlhis.Middle/Dlhis.Middle.csproj b/Src/Dlhis.Middle/Dlhis.Middle.csproj index 1b0aef9f..accf19a9 100644 --- a/Src/Dlhis.Middle/Dlhis.Middle.csproj +++ b/Src/Dlhis.Middle/Dlhis.Middle.csproj @@ -17,6 +17,7 @@ + diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/TaskCombineDto.cs b/Src/Dlhis.Middle/Dto/TaskCombineDto.cs similarity index 90% rename from Src/Dlhis.ScheduledTask/TaskAssignment/Response/TaskCombineDto.cs rename to Src/Dlhis.Middle/Dto/TaskCombineDto.cs index 6b1526c8..92119602 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/TaskCombineDto.cs +++ b/Src/Dlhis.Middle/Dto/TaskCombineDto.cs @@ -1,7 +1,7 @@ using Dlhis.Entity.Device.Enums; using Kurisu.AspNetCore.Utils.Extensions; -namespace Dlhis.ScheduledTask.TaskAssignment.Response; +namespace Dlhis.Middle.Dto; public class TaskCombineDto { diff --git a/Src/Dlhis.Middle/Filters/NotFoundAttribute.cs b/Src/Dlhis.Middle/Filters/NotFoundAttribute.cs new file mode 100644 index 00000000..015f49f9 --- /dev/null +++ b/Src/Dlhis.Middle/Filters/NotFoundAttribute.cs @@ -0,0 +1,30 @@ +using Kurisu.AspNetCore.UnifyResultAndValidation; +using Kurisu.AspNetCore.UnifyResultAndValidation.Abstractions; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; + +namespace Dlhis.Middle.Filters; + +[AttributeUsage(AttributeTargets.Method)] +public class NotFoundAttribute : Attribute, IAsyncResultFilter +{ + public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) + { + if (context.Result is ObjectResult result) + { + var type = result.Value?.GetType(); + if (type.IsGenericType && type.IsAssignableTo(typeof(IApiResult))) + { + var apiResult = result.Value as DefaultApiResult; + + if (apiResult.Data is ProblemDetails _) + { + context.Result = new NotFoundResult(); + //context.HttpContext.Response + } + } + } + + await next(); + } +} diff --git a/Src/Dlhis.Middle/Program.cs b/Src/Dlhis.Middle/Program.cs index d57384c4..30cb0fdd 100644 --- a/Src/Dlhis.Middle/Program.cs +++ b/Src/Dlhis.Middle/Program.cs @@ -1,5 +1,6 @@ using Dlhis.Middle.Services; using Dlhis.Middle.Services.Implements; +using Kurisu.AspNetCore; using Kurisu.AspNetCore.Startup; using Microsoft.IdentityModel.Logging; @@ -23,6 +24,8 @@ public class Startup : DefaultStartup public override void ConfigureServices(IServiceCollection services) { base.ConfigureServices(services); + + services.AddRemoteCall(App.ActiveTypes); services.AddHttpClient("face").ConfigurePrimaryHttpMessageHandler(() => { var handler = new HttpClientHandler diff --git a/Src/Dlhis.Middle/Request/DeviceTaskGetRequest.cs b/Src/Dlhis.Middle/Request/DeviceTaskGetRequest.cs new file mode 100644 index 00000000..f065e67a --- /dev/null +++ b/Src/Dlhis.Middle/Request/DeviceTaskGetRequest.cs @@ -0,0 +1,42 @@ +using System.ComponentModel.DataAnnotations; +using Dlhis.Entity.Device.Enums; +using Kurisu.AspNetCore.DataAccess.Dto; +using Kurisu.AspNetCore.Utils.Extensions; + +namespace Dlhis.Middle.Request; + +public class DeviceTaskGetRequest : PageDto, IValidatableObject +{ + /// + /// 品牌 + /// + public string Brand { get; set; } + + /// + /// 设备号 + /// + public string DeviceUniqueNo { get; set; } + + /// + /// 任务类型 + /// + public List Types { get; set; } + + /// + /// 获取处理中的任务 + /// + public bool IsProcess { get; set; } = false; + + /// + /// 厂区 + /// + public string Factory { get; set; } + + public IEnumerable Validate(ValidationContext validationContext) + { + if (Brand.IsEmpty() && DeviceUniqueNo.IsEmpty() && Factory.IsEmpty()) + { + yield return new ValidationResult("设备品牌,设备号和厂区不能都为空", new[] { nameof(Brand), nameof(DeviceUniqueNo), nameof(Factory) }); + } + } +} \ No newline at end of file diff --git a/Src/Dlhis.Middle/Response/DeviceTaskToDeviceResponse.cs b/Src/Dlhis.Middle/Response/DeviceTaskToDeviceResponse.cs new file mode 100644 index 00000000..9980ab39 --- /dev/null +++ b/Src/Dlhis.Middle/Response/DeviceTaskToDeviceResponse.cs @@ -0,0 +1,29 @@ +using Dlhis.Middle.Dto; + +namespace Dlhis.Middle.Response; + +/// +/// 设备任务 +/// +public class DeviceTaskToDeviceByDeviceResponse +{ + /// + /// 品牌 + /// + public string Brand { get; set; } + + /// + /// 设备唯一号 + /// + public string DeviceUniqueNo { get; set; } + + /// + /// 设备信息 + /// + public object DeviceInfo { get; set; } + + /// + /// 任务 + /// + public List Tasks { get; set; } +} diff --git a/Src/Dlhis.Middle/Response/UploadRecordToDeviceResponse.cs b/Src/Dlhis.Middle/Response/UploadRecordToDeviceResponse.cs new file mode 100644 index 00000000..7c9ca6dc --- /dev/null +++ b/Src/Dlhis.Middle/Response/UploadRecordToDeviceResponse.cs @@ -0,0 +1,8 @@ +using Kurisu.AspNetCore.CustomClass; + +namespace Dlhis.Middle.Response; + +public class UploadRecordToDeviceResponse +{ + public DateTimePeriod DateTimePeriod { get; set; } +} diff --git a/Src/Dlhis.Middle/Response/UserToDeviceResponse.cs b/Src/Dlhis.Middle/Response/UserToDeviceResponse.cs new file mode 100644 index 00000000..8e143a4b --- /dev/null +++ b/Src/Dlhis.Middle/Response/UserToDeviceResponse.cs @@ -0,0 +1,71 @@ +using Kurisu.AspNetCore.CustomClass; + +namespace Dlhis.Middle.Response; + +public class UserToDeviceResponse +{ + /// + /// 人员唯一id + /// + public long UserId { get; set; } + + /// + /// 人员档案号 + /// + public string UserNo { get; set; } + + /// + /// 老系统档案号 + /// + public string OldUserNo { get; set; } + + /// + /// 人员学工号 + /// + public string UserCode { get; set; } + + /// + /// 人员名称 + /// + public string UserName { get; set; } + + /// + /// 部门号 + /// + public string DepartmentNo { get; set; } + + /// + /// 部门名称 + /// + public string DepartmentName { get; set; } + + /// + /// 卡号 + /// + public string CardNo { get; set; } + + /// + /// 人脸 + /// + public string Face { get; set; } + + /// + /// 有效日期范围 + /// + public DatePeriod ValidDatePeriod { get; set; } + + /// + /// 控制门[1,2,3....] + /// + public List Doors { get; set; } + + /// + /// 时段[1,2,3....] + /// + public List TimePeriods { get; set; } + + /// + /// 假期计划id + /// + public int Schedule { get; set; } +} \ No newline at end of file diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/ScheduleDto.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Dto/ScheduleDto.cs similarity index 84% rename from Src/Dlhis.ScheduledTask/TaskAssignment/Response/ScheduleDto.cs rename to Src/Dlhis.ScheduledTask/TaskAssignment/Dto/ScheduleDto.cs index 357d80ca..4e9bcd1a 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/ScheduleDto.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Dto/ScheduleDto.cs @@ -1,6 +1,6 @@ using Kurisu.AspNetCore.CustomClass; -namespace Dlhis.ScheduledTask.TaskAssignment.Response; +namespace Dlhis.ScheduledTask.TaskAssignment.Dto; public class ScheduleDto { diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Dto/TaskCombineDto.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Dto/TaskCombineDto.cs new file mode 100644 index 00000000..944cb431 --- /dev/null +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Dto/TaskCombineDto.cs @@ -0,0 +1,27 @@ +using Dlhis.Entity.Device.Enums; +using Kurisu.AspNetCore.Utils.Extensions; + +namespace Dlhis.ScheduledTask.TaskAssignment.Dto; + +public class TaskCombineDto +{ + /// + /// 任务id + /// + public long TaskId { get; set; } + + /// + /// 任务类型 + /// + public DeviceTaskEnumType Type { get; set; } + + /// + /// 任务类型描述 + /// + public string TypeDesc => Type.GetDescription(); + + /// + /// 下发信息 + /// + public object Info { get; set; } +} diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskToDeviceResponse.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskToDeviceResponse.cs index 5c9846e8..2ce0d786 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskToDeviceResponse.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/DeviceTaskToDeviceResponse.cs @@ -1,4 +1,6 @@ -namespace Dlhis.ScheduledTask.TaskAssignment.Response; +using Dlhis.ScheduledTask.TaskAssignment.Dto; + +namespace Dlhis.ScheduledTask.TaskAssignment.Response; /// /// 设备任务 diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/ScheduleToDeviceResponse.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/ScheduleToDeviceResponse.cs index 4f8515b1..24a9062d 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/ScheduleToDeviceResponse.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/ScheduleToDeviceResponse.cs @@ -1,4 +1,6 @@ -namespace Dlhis.ScheduledTask.TaskAssignment.Response; +using Dlhis.ScheduledTask.TaskAssignment.Dto; + +namespace Dlhis.ScheduledTask.TaskAssignment.Response; public class ScheduleToDeviceResponse { diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/UserToDeviceResponse.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/UserToDeviceResponse.cs index 7a6254c6..ee84c43e 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Response/UserToDeviceResponse.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Response/UserToDeviceResponse.cs @@ -14,6 +14,11 @@ public class UserToDeviceResponse /// public string UserNo { get; set; } + /// + /// 老系统档案号 + /// + public string OldUserNo { get; set; } + /// /// 人员学工号 /// diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs index e12e1230..b3764a68 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs @@ -51,7 +51,7 @@ public class AssignmentService : IAssignmentService var dc = x.Key.DeviceConnectionInfo ?? "{}"; var func = x.Key.FuncStr ?? "[]"; - var jobj = new JObject + var jObj = new JObject { { "connectionInfo", JToken.Parse(dc) }, { "function", JArray.Parse(func) } @@ -61,7 +61,7 @@ public class AssignmentService : IAssignmentService { Brand = b, DeviceUniqueNo = d, - DeviceInfo = jobj, + DeviceInfo = jObj, Tasks = x.Select(item => { var key = $"face:{item.UserCode}"; @@ -83,7 +83,7 @@ public class AssignmentService : IAssignmentService { dto.Info = new UserToDeviceResponse { - UserId = item.UserId.HasValue ? item.UserId.Value : 0, + UserId = item.UserId ?? 0, UserNo = item.UserNo, UserCode = item.UserCode, UserName = item.UserName, diff --git a/Src/Dlhis.User/Identity/Controllers/OAuth2Controller.cs b/Src/Dlhis.Sys/Identity/Controllers/OAuth2Controller.cs similarity index 94% rename from Src/Dlhis.User/Identity/Controllers/OAuth2Controller.cs rename to Src/Dlhis.Sys/Identity/Controllers/OAuth2Controller.cs index e76e48dd..d3e80a82 100644 --- a/Src/Dlhis.User/Identity/Controllers/OAuth2Controller.cs +++ b/Src/Dlhis.Sys/Identity/Controllers/OAuth2Controller.cs @@ -1,11 +1,11 @@ using System.Text; -using Dlhis.User.Identity.Request; +using Dlhis.Sys.Identity.Request; using Kurisu.AspNetCore.Authentication.Options; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; -namespace Dlhis.User.Identity.Controllers; +namespace Dlhis.Sys.Identity.Controllers; /// /// OAuth2认证 diff --git a/Src/Dlhis.User/Identity/Request/ClientGrantRequest.cs b/Src/Dlhis.Sys/Identity/Request/ClientGrantRequest.cs similarity index 80% rename from Src/Dlhis.User/Identity/Request/ClientGrantRequest.cs rename to Src/Dlhis.Sys/Identity/Request/ClientGrantRequest.cs index 7fa40825..b91e5398 100644 --- a/Src/Dlhis.User/Identity/Request/ClientGrantRequest.cs +++ b/Src/Dlhis.Sys/Identity/Request/ClientGrantRequest.cs @@ -1,4 +1,4 @@ -namespace Dlhis.User.Identity.Request; +namespace Dlhis.Sys.Identity.Request; public class ClientGrantRequest { diff --git a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs index 1cc4da2d..7b1aef8b 100644 --- a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs +++ b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs @@ -91,30 +91,30 @@ public class MenuService : IMenuService .Select(x => x.Code) .ToListAsync(); - var menus = await GetListAsync(PlatformEnumType.PCAdmin); - - foreach (var menu in menus) - { - RecursionHandler(menu, permissionCodes, permissionCodes.Contains(menu.Code)); - } + // var menus = await GetListAsync(PlatformEnumType.PCAdmin); + // + // foreach (var menu in menus) + // { + // RecursionHandler(menu, permissionCodes, permissionCodes.Contains(menu.Code)); + // } return permissionCodes; - static bool RecursionHandler(MenuResponse current, List innerPermissions, bool add) - { - if (add) innerPermissions.Add(current.Code); - - foreach (var menu in current.Items) - { - var currentAdd = RecursionHandler(menu, innerPermissions, add || innerPermissions.Contains(menu.Code)); - if (currentAdd && !innerPermissions.Contains(current.Code)) - { - innerPermissions.Add(current.Code); - } - } - - return add; - } + // static bool RecursionHandler(MenuResponse current, List innerPermissions, bool add) + // { + // if (add) innerPermissions.Add(current.Code); + // + // foreach (var menu in current.Items) + // { + // var currentAdd = RecursionHandler(menu, innerPermissions, add || innerPermissions.Contains(menu.Code)); + // if (currentAdd && !innerPermissions.Contains(current.Code)) + // { + // innerPermissions.Add(current.Code); + // } + // } + // + // return add; + // } } public async Task> GetAllAssignmentPermissionsAsync() diff --git a/Src/Dlhis.User/Packs/OAuth2HttpClientPack.cs b/Src/Dlhis.Sys/Packs/OAuth2HttpClientPack.cs similarity index 96% rename from Src/Dlhis.User/Packs/OAuth2HttpClientPack.cs rename to Src/Dlhis.Sys/Packs/OAuth2HttpClientPack.cs index c630707c..2b7e7a7a 100644 --- a/Src/Dlhis.User/Packs/OAuth2HttpClientPack.cs +++ b/Src/Dlhis.Sys/Packs/OAuth2HttpClientPack.cs @@ -1,6 +1,6 @@ using Kurisu.AspNetCore.Startup; -namespace Dlhis.User.Packs; +namespace Dlhis.Sys.Packs; public class OAuth2HttpClientPack : BaseAppPack { diff --git a/Src/Dlhis.User/Dlhis.User.csproj b/Src/Dlhis.User/Dlhis.User.csproj deleted file mode 100644 index 6a45a927..00000000 --- a/Src/Dlhis.User/Dlhis.User.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - net6.0 - disable - enable - Linux - ..\.. - True - - - - - - - - - - - - - diff --git a/Src/Dlhis.User/Dockerfile b/Src/Dlhis.User/Dockerfile deleted file mode 100644 index 75d24763..00000000 --- a/Src/Dlhis.User/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -#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. - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY ["Src/Dlhis.User/Dlhis.User.csproj", "Src/Dlhis.User/"] -RUN dotnet restore "Src/Dlhis.User/Dlhis.User.csproj" -COPY . . -WORKDIR "/src/Src/Dlhis.User" -RUN dotnet build "Dlhis.User.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "Dlhis.User.csproj" -c Release -o /app/publish /p:UseAppHost=false - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Dlhis.User.dll"] \ No newline at end of file diff --git a/Src/Dlhis.User/Program.cs b/Src/Dlhis.User/Program.cs deleted file mode 100644 index 57ceb571..00000000 --- a/Src/Dlhis.User/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Kurisu.AspNetCore.Startup; -using Microsoft.IdentityModel.Logging; - -namespace Dlhis.User -{ - class Program - { - static void Main(string[] args) - { - KurisuHost.Run(args); - } - } - - public class Startup : DefaultStartup - { - public Startup(IConfiguration configuration) : base(configuration) - { - IdentityModelEventSource.ShowPII = true; - } - } -} \ No newline at end of file diff --git a/Src/Dlhis.User/Properties/launchSettings.json b/Src/Dlhis.User/Properties/launchSettings.json deleted file mode 100644 index 8bf84199..00000000 --- a/Src/Dlhis.User/Properties/launchSettings.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "profiles": { - "Dlhis.User": { - "commandName": "Project", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "dotnetRunMessages": true, - "applicationUrl": "http://localhost:5004" - }, - "Docker": { - "commandName": "Docker", - "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", - "environmentVariables": { - "ASPNETCORE_URLS": "http://+:80" - }, - "publishAllPorts": true - } - }, - "$schema": "https://json.schemastore.org/launchsettings.json" -} \ No newline at end of file diff --git a/Src/Dlhis.User/appsettings.Development.json b/Src/Dlhis.User/appsettings.Development.json deleted file mode 100644 index 20ab3f6d..00000000 --- a/Src/Dlhis.User/appsettings.Development.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "InternalRequest": { - "CommonRequestUrl": "http://localhost:5001" - }, - "SwaggerOptions": { - "Enable": true, - "Authority": "https://yikatong.isawesome.cn/oauth2", - "ClientId": "4fb184324eac4180", - "ClientSecret": "8ac8f235152f1524", - "Scopes": { - "openid": "openid", - "profile": "profile", - "yikatong": "yikatong" - } - }, - "IdentityServerOptions": { - "Authority": "https://yikatong.isawesome.cn/oauth2", - "RequireHttpsMetadata": true, - "Issuer": "identity.isawesome.cn", - "Audience": "", - "Pat": { - "Enable": false, - "Scheme": "token", - "ClientId": "reference", - "ClientSecret": "123456" - } - } -} diff --git a/Src/Dlhis.User/appsettings.json b/Src/Dlhis.User/appsettings.json deleted file mode 100644 index 6a7495bd..00000000 --- a/Src/Dlhis.User/appsettings.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*", - - "SqlSugarOptions": { - "DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=identity;charset=utf8mb4;", - "SlaveConnectionString": [], - "Timeout": 30, - "SlowSqlTime": 1, - "EnableSqlLog": false - }, - "SwaggerOptions": { - "Enable": true, - "Authority": "http://identity.oauth.svc.cluster.local", - "ClientId": "4fb184324eac4180", - "ClientSecret": "8ac8f235152f1524", - "Scopes": { - "openid": "openid", - "profile": "profile", - "yikatong": "yikatong" - } - }, - "IdentityServerOptions": { - "Authority": "http://identity.oauth.svc.cluster.local", - "RequireHttpsMetadata": false, - "Issuer": "identity.isawesome.cn", - "Audience": "", - "Pat": { - "Enable": false, - "Scheme": "token", - "ClientId": "reference", - "ClientSecret": "123456" - } - }, - "Serilog": { - "MinimumLevel": { - "Default": "Information", - "Override": { - "System": "Warning", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "WriteTo": [ - { - "Name": "Async", - "Args": { - "configure": [ - { - "Name": "Console", - "Args": { - "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}" - } - } - ] - } - } - ] - } -}