diff --git a/Dlhis.Jinko.Face.sln b/Dlhis.Jinko.Face.sln index cf2e3f24..5425d10b 100644 --- a/Dlhis.Jinko.Face.sln +++ b/Dlhis.Jinko.Face.sln @@ -31,7 +31,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Sys.Api", "Src\Dlhis. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Basic.Api", "Src\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj", "{1F337648-8A22-4601-A842-0F634FBA2825}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gateway", "Src\Gateway\Gateway.csproj", "{00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gateway", "Src\Gateway\Gateway.csproj", "{00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{489252FB-A44B-46EE-B065-21CDCB724441}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.External", "Src\Dlhis.External\Dlhis.External.csproj", "{8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -83,6 +87,10 @@ Global {00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {00DE1D49-8F1F-4EAA-B06F-CDE0EFAA03D3}.Release|Any CPU.Build.0 = Release|Any CPU + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -97,6 +105,7 @@ Global {8317C526-3523-4195-9B19-2F17CFD71927} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B} {85A345C7-913E-4C1B-BE1C-600DE408A02F} = {57074FD8-1A2F-40C7-8476-001778A3F65D} {1F337648-8A22-4601-A842-0F634FBA2825} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A} + {8472596E-0DE7-4A17-93D6-F0FC7D44FDF5} = {489252FB-A44B-46EE-B065-21CDCB724441} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0} diff --git a/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs new file mode 100644 index 00000000..94e5fa7e --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Entity/MealSupplementRecordEntity.cs @@ -0,0 +1,60 @@ +using Dlhis.Entity.Basic.Enums; +using Kurisu.SqlSugar; +using SqlSugar; +using SqlSugar.DbConvert; + +namespace Dlhis.Entity.Basic.Entity; + +/// +/// 餐补记录 +/// +[SugarTable(TableName = "MealSupplementRecord", TableDescription = "餐补记录")] +public class MealSupplementRecordEntity : SugarBaseEntity +{ + /// + /// 唯一号 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "唯一号", UniqueGroupNameList = new[] { "idx_MealSupplementRecord_UniqueId" })] + public string UniqueId { get; set; } + + /// + /// 工号 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "工号")] + public string Code { get; set; } + + /// + /// 考勤日期 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "考勤日期")] + public DateTime Date { get; set; } + + /// + /// 工作地 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "工作地")] + public string Workplace { get; set; } + + /// + /// 厂区 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "厂区")] + public string Factory { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 餐补 + /// + [SugarColumn(IsNullable = false, ColumnDescription = "餐补")] + public decimal Amount { get; set; } + + /// + /// 餐补状态 + /// + [SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public MealSupplementStatusEnumtype Status { get; set; } +} diff --git a/Src/Dlhis.Entity/Basic/Enums/MealSupplementStatusEnumtype.cs b/Src/Dlhis.Entity/Basic/Enums/MealSupplementStatusEnumtype.cs new file mode 100644 index 00000000..6de28a57 --- /dev/null +++ b/Src/Dlhis.Entity/Basic/Enums/MealSupplementStatusEnumtype.cs @@ -0,0 +1,29 @@ +using System.ComponentModel; + +namespace Dlhis.Entity.Basic.Enums; + +/// +/// 餐补状态 +/// +[Description("餐补状态")] +public enum MealSupplementStatusEnumtype +{ + /// + /// 待核算 + /// + [Description("待核算")] + Wait = 0, + + + /// + /// 成功 + /// + [Description("成功")] + Sucess = 1, + + /// + /// 处理异常 + /// + [Description("处理异常")] + Error = 99 +} diff --git a/Src/Dlhis.External/Dlhis.External.csproj b/Src/Dlhis.External/Dlhis.External.csproj new file mode 100644 index 00000000..e89418db --- /dev/null +++ b/Src/Dlhis.External/Dlhis.External.csproj @@ -0,0 +1,24 @@ + + + + net6.0 + disable + enable + Linux + ..\.. + + + + + + + + + + + + + + + + diff --git a/Src/Dlhis.External/Dockerfile b/Src/Dlhis.External/Dockerfile new file mode 100644 index 00000000..8a640cee --- /dev/null +++ b/Src/Dlhis.External/Dockerfile @@ -0,0 +1,24 @@ +#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 +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["Src/Dlhis.External/Dlhis.External.csproj", "Src/Dlhis.External/"] +COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"] +RUN dotnet restore "./Src/Dlhis.External/./Dlhis.External.csproj" +COPY . . +WORKDIR "/src/Src/Dlhis.External" +RUN dotnet build "./Dlhis.External.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./Dlhis.External.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Dlhis.External.dll"] \ No newline at end of file diff --git a/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs b/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs new file mode 100644 index 00000000..25622039 --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Channel/MealSupplementHandler.cs @@ -0,0 +1,37 @@ +using Dlhis.Entity.Basic.Entity; +using Dlhis.External.MealSupplement.Request; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.AspNetCore.EventBus.Abstractions.Handler; +using Kurisu.SqlSugar.Services; +using Mapster; + +namespace Dlhis.External.MealSupplement.Channel; + +public class MealSupplementHandler : IAsyncChannelHandler +{ + private readonly IServiceProvider _serviceProvider; + + public MealSupplementHandler(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + public async Task InvokeAsync(MealSupplementMessage message) + { + using (var scope = _serviceProvider.CreateScope()) + { + var db = scope.ServiceProvider.GetService(); + + var existsIds = await db.Queryable().Select(x => x.UniqueId).ToListAsync(); + var items = message.Items.Where(x => !existsIds.Contains(x.UniqueId)).ToList(); + + var entities = items.Adapt>(); + await db.InsertAsync(entities); + } + } +} + +public class MealSupplementMessage : IAsyncChannelMessage +{ + public List Items { get; set; } +} diff --git a/Src/Dlhis.External/MealSupplement/Controller/MealSupplementsController.cs b/Src/Dlhis.External/MealSupplement/Controller/MealSupplementsController.cs new file mode 100644 index 00000000..5f0d9b6c --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Controller/MealSupplementsController.cs @@ -0,0 +1,27 @@ +using Dlhis.External.MealSupplement.Request; +using Dlhis.External.MealSupplement.Services; +using Microsoft.AspNetCore.Mvc; + +namespace Dlhis.External.MealSupplement.Controller; + +[Route("api/[controller]")] +[ApiController] +public class MealSupplementsController : ControllerBase +{ + private readonly IMealSupplementService _mealSupplementService; + + public MealSupplementsController(IMealSupplementService mealSupplementService) + { + _mealSupplementService = mealSupplementService; + } + + /// + /// 接受餐补 + /// + /// + [HttpPost("receive")] + public async Task DoSupplements(List reuqests) + { + await _mealSupplementService.DoSupplementsAsync(reuqests); + } +} diff --git a/Src/Dlhis.External/MealSupplement/Request/MealSupplementReceiveReuqest.cs b/Src/Dlhis.External/MealSupplement/Request/MealSupplementReceiveReuqest.cs new file mode 100644 index 00000000..c9bdc4de --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Request/MealSupplementReceiveReuqest.cs @@ -0,0 +1,45 @@ +using System.ComponentModel.DataAnnotations; + +namespace Dlhis.External.MealSupplement.Request; + +public class MealSupplementReceiveReuqest +{ + /// + /// 唯一号 + /// + [Required(ErrorMessage = "唯一号必填")] + public string UniqueId { get; set; } + + /// + /// 工号 + /// + [Required(ErrorMessage = "工号必填")] + public string Code { get; set; } + + /// + /// 考勤日期 + /// + public DateTime Date { get; set; } + + /// + /// 工作地 + /// + [Required(ErrorMessage = "工作地")] + public string Workplace { get; set; } + + /// + /// 厂区 + /// + [Required(ErrorMessage = "厂区")] + public string Factory { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 餐补 + /// + public decimal Amount { get; set; } +} diff --git a/Src/Dlhis.External/MealSupplement/Services/IMealSupplementService.cs b/Src/Dlhis.External/MealSupplement/Services/IMealSupplementService.cs new file mode 100644 index 00000000..9c186dca --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Services/IMealSupplementService.cs @@ -0,0 +1,8 @@ +using Dlhis.External.MealSupplement.Request; + +namespace Dlhis.External.MealSupplement.Services; + +public interface IMealSupplementService : IScopeDependency +{ + Task DoSupplementsAsync(List reuqests); +} diff --git a/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs new file mode 100644 index 00000000..9f0a22ca --- /dev/null +++ b/Src/Dlhis.External/MealSupplement/Services/Implements/MealSupplementService.cs @@ -0,0 +1,23 @@ +using Dlhis.External.MealSupplement.Channel; +using Dlhis.External.MealSupplement.Request; +using Kurisu.AspNetCore.EventBus.Abstractions; +using Kurisu.SqlSugar.Services; + +namespace Dlhis.External.MealSupplement.Services.Implements; + +public class MealSupplementService : IMealSupplementService +{ + private readonly IEventBus _eventBus; + private readonly IDbContext _dbContext; + + public MealSupplementService(IEventBus eventBus , IDbContext dbContext) + { + _eventBus = eventBus; + _dbContext = dbContext; + } + + public async Task DoSupplementsAsync(List reuqests) + { + await _eventBus.PublishAsync(new MealSupplementMessage { Items = reuqests }); + } +} diff --git a/Src/Dlhis.External/Program.cs b/Src/Dlhis.External/Program.cs new file mode 100644 index 00000000..8ed604e2 --- /dev/null +++ b/Src/Dlhis.External/Program.cs @@ -0,0 +1,29 @@ +using Kurisu.AspNetCore.EventBus.Extensions; +using Kurisu.AspNetCore.Startup; +using Kurisu.SqlSugar.Extensions; +using Kurisu.Startup; +using Microsoft.IdentityModel.Logging; + +class Program +{ + static void Main(string[] args) + { + KurisuHost.Run(true, args); + } +} + +public class Startup : DefaultStartup +{ + public Startup(IConfiguration configuration) : base(configuration) + { + IdentityModelEventSource.ShowPII = true; + } + + public override void ConfigureServices(IServiceCollection services) + { + base.ConfigureServices(services); + + services.AddSqlSugar(); + services.AddEventBus(); + } +} \ No newline at end of file diff --git a/Src/Dlhis.External/Properties/launchSettings.json b/Src/Dlhis.External/Properties/launchSettings.json new file mode 100644 index 00000000..a31280e1 --- /dev/null +++ b/Src/Dlhis.External/Properties/launchSettings.json @@ -0,0 +1,13 @@ +{ + "profiles": { + "Dlhis.External": { + "commandName": "Project", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5020" + } + }, + "$schema": "https://json.schemastore.org/launchsettings.json" +} \ No newline at end of file diff --git a/Src/Dlhis.External/appsettings.Development.json b/Src/Dlhis.External/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/Src/Dlhis.External/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Src/Dlhis.External/appsettings.json b/Src/Dlhis.External/appsettings.json new file mode 100644 index 00000000..1b75d34f --- /dev/null +++ b/Src/Dlhis.External/appsettings.json @@ -0,0 +1,72 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "SqlSugarOptions": { + "DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;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}" + } + }, + { + "Name": "MySQL", + "Args": { + "connectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=log;charset=utf8mb4;", + "tableName": "Logs", + "autoCreateSqlTable": true + } + } + ] + } + } + ] + } +} diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs index fee03043..d6c88730 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Request/DeviceTaskAssignmentRequest.cs @@ -7,7 +7,7 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Request; public class DeviceTaskAssignmentRequest : PageDto { /// - /// 设备类型 + /// 设备类型 DeviceTypeEnumType /// [EnumDataType(typeof(DeviceTypeEnumType))] public DeviceTypeEnumType? Type { get; set; } @@ -20,7 +20,7 @@ public class DeviceTaskAssignmentRequest : PageDto public DeviceTaskEnumType? TaskType { get; set; } /// - /// 任务下发状态 + /// 任务下发状态 DeviceTaskStatusEnumType /// [EnumDataType(typeof(DeviceTaskStatusEnumType))] public DeviceTaskStatusEnumType? Status { get; set; }