feat 餐补接收

This commit is contained in:
2024-03-14 16:35:38 +08:00
parent d17b20365a
commit 16be030748
15 changed files with 411 additions and 3 deletions

View File

@@ -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}

View File

@@ -0,0 +1,60 @@
using Dlhis.Entity.Basic.Enums;
using Kurisu.SqlSugar;
using SqlSugar;
using SqlSugar.DbConvert;
namespace Dlhis.Entity.Basic.Entity;
/// <summary>
/// 餐补记录
/// </summary>
[SugarTable(TableName = "MealSupplementRecord", TableDescription = "餐补记录")]
public class MealSupplementRecordEntity : SugarBaseEntity
{
/// <summary>
/// 唯一号
/// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = "唯一号", UniqueGroupNameList = new[] { "idx_MealSupplementRecord_UniqueId" })]
public string UniqueId { get; set; }
/// <summary>
/// 工号
/// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = "工号")]
public string Code { get; set; }
/// <summary>
/// 考勤日期
/// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = "考勤日期")]
public DateTime Date { get; set; }
/// <summary>
/// 工作地
/// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = "工作地")]
public string Workplace { get; set; }
/// <summary>
/// 厂区
/// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = "厂区")]
public string Factory { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 餐补
/// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = "餐补")]
public decimal Amount { get; set; }
/// <summary>
/// 餐补状态
/// </summary>
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
public MealSupplementStatusEnumtype Status { get; set; }
}

View File

@@ -0,0 +1,29 @@
using System.ComponentModel;
namespace Dlhis.Entity.Basic.Enums;
/// <summary>
/// 餐补状态
/// </summary>
[Description("餐补状态")]
public enum MealSupplementStatusEnumtype
{
/// <summary>
/// 待核算
/// </summary>
[Description("待核算")]
Wait = 0,
/// <summary>
/// 成功
/// </summary>
[Description("成功")]
Sucess = 1,
/// <summary>
/// 处理异常
/// </summary>
[Description("处理异常")]
Error = 99
}

View File

@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Kurisu.AspNetCore" Version="0.7.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
</ItemGroup>
<ItemGroup>
<Folder Include="MealSupplement\Response\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
</ItemGroup>
</Project>

View File

@@ -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"]

View File

@@ -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<MealSupplementMessage>
{
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<IDbContext>();
var existsIds = await db.Queryable<MealSupplementRecordEntity>().Select(x => x.UniqueId).ToListAsync();
var items = message.Items.Where(x => !existsIds.Contains(x.UniqueId)).ToList();
var entities = items.Adapt<List<MealSupplementRecordEntity>>();
await db.InsertAsync(entities);
}
}
}
public class MealSupplementMessage : IAsyncChannelMessage
{
public List<MealSupplementReceiveReuqest> Items { get; set; }
}

View File

@@ -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;
}
/// <summary>
/// 接受餐补
/// </summary>
/// <returns></returns>
[HttpPost("receive")]
public async Task DoSupplements(List<MealSupplementReceiveReuqest> reuqests)
{
await _mealSupplementService.DoSupplementsAsync(reuqests);
}
}

View File

@@ -0,0 +1,45 @@
using System.ComponentModel.DataAnnotations;
namespace Dlhis.External.MealSupplement.Request;
public class MealSupplementReceiveReuqest
{
/// <summary>
/// 唯一号
/// </summary>
[Required(ErrorMessage = "唯一号必填")]
public string UniqueId { get; set; }
/// <summary>
/// 工号
/// </summary>
[Required(ErrorMessage = "工号必填")]
public string Code { get; set; }
/// <summary>
/// 考勤日期
/// </summary>
public DateTime Date { get; set; }
/// <summary>
/// 工作地
/// </summary>
[Required(ErrorMessage = "工作地")]
public string Workplace { get; set; }
/// <summary>
/// 厂区
/// </summary>
[Required(ErrorMessage = "厂区")]
public string Factory { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 餐补
/// </summary>
public decimal Amount { get; set; }
}

View File

@@ -0,0 +1,8 @@
using Dlhis.External.MealSupplement.Request;
namespace Dlhis.External.MealSupplement.Services;
public interface IMealSupplementService : IScopeDependency
{
Task DoSupplementsAsync(List<MealSupplementReceiveReuqest> reuqests);
}

View File

@@ -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<MealSupplementReceiveReuqest> reuqests)
{
await _eventBus.PublishAsync(new MealSupplementMessage { Items = reuqests });
}
}

View File

@@ -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<Startup>(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();
}
}

View File

@@ -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"
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -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
}
}
]
}
}
]
}
}

View File

@@ -7,7 +7,7 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Request;
public class DeviceTaskAssignmentRequest : PageDto
{
/// <summary>
/// 设备类型
/// 设备类型 DeviceTypeEnumType
/// </summary>
[EnumDataType(typeof(DeviceTypeEnumType))]
public DeviceTypeEnumType? Type { get; set; }
@@ -20,7 +20,7 @@ public class DeviceTaskAssignmentRequest : PageDto
public DeviceTaskEnumType? TaskType { get; set; }
/// <summary>
/// 任务下发状态
/// 任务下发状态 DeviceTaskStatusEnumType
/// </summary>
[EnumDataType(typeof(DeviceTaskStatusEnumType))]
public DeviceTaskStatusEnumType? Status { get; set; }