From 6d2d62d62886edc9ebd3c0c17ebbd433bf9c7e63 Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 10:12:04 +0800
Subject: [PATCH 001/146] =?UTF-8?q?feat=20=E8=8E=B7=E5=8F=96api=E6=97=A5?=
=?UTF-8?q?=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Device/Controllers/DevicesController.cs | 13 +++-
.../Device/Request/ApiLogRequest.cs | 14 +++++
.../Device/Response/ApiLogResponse.cs | 49 +++++++++++++++
.../Device/Response/RecentNumberResponse.cs | 9 +++
.../Device/Services/IDeviceService.cs | 5 +-
.../Services/Implements/DeviceService.cs | 35 +++++++++--
Src/Dlhis.Basic/Program.cs | 4 +-
Src/Dlhis.Basic/appsettings.json | 1 +
Src/Dlhis.Entity/Basic/Entity/ApiLogEntity.cs | 61 +++++++++++++++++++
.../Basic/Enums/ApiLogEnumType.cs | 24 ++++++++
.../Controllers/DeviceUploadLogsController.cs | 4 +-
.../Services/IDeviceUploadLogService.cs | 4 +-
.../Implements/DeviceUploadLogService.cs | 8 ++-
13 files changed, 220 insertions(+), 11 deletions(-)
create mode 100644 Src/Dlhis.Basic/Device/Request/ApiLogRequest.cs
create mode 100644 Src/Dlhis.Basic/Device/Response/ApiLogResponse.cs
create mode 100644 Src/Dlhis.Basic/Device/Response/RecentNumberResponse.cs
create mode 100644 Src/Dlhis.Entity/Basic/Entity/ApiLogEntity.cs
create mode 100644 Src/Dlhis.Entity/Basic/Enums/ApiLogEnumType.cs
diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
index 74e3ca8b..accdbbb3 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
@@ -1,6 +1,7 @@
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
using Dlhis.Basic.Device.Services;
+using Dlhis.Entity.Basic.Entity;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -198,8 +199,18 @@ public class DevicesController : ControllerBase
///
///
[HttpGet("recentnumbers")]
- public async Task> GetRecentNumbersAsync()
+ public async Task> GetRecentNumbersAsync()
{
return await _deviceService.GetRecentNumbersAsync();
}
+
+ ///
+ /// 获取api日志
+ ///
+ ///
+ [HttpGet("logs")]
+ public async Task> GetLogsAsync([FromQuery]ApiLogRequest request)
+ {
+ return await _deviceService.GetLogsAsync(request);
+ }
}
diff --git a/Src/Dlhis.Basic/Device/Request/ApiLogRequest.cs b/Src/Dlhis.Basic/Device/Request/ApiLogRequest.cs
new file mode 100644
index 00000000..484b5983
--- /dev/null
+++ b/Src/Dlhis.Basic/Device/Request/ApiLogRequest.cs
@@ -0,0 +1,14 @@
+using Dlhis.Entity.Basic.Enums;
+using Kurisu.Core.DataAccess.Dto;
+using System.ComponentModel.DataAnnotations;
+
+namespace Dlhis.Basic.Device.Request
+{
+ public class ApiLogRequest :PageDto
+ {
+ public string message { get; set; }
+
+ [EnumDataType(typeof(ApiLogEnumType)),]
+ public ApiLogEnumType? Type { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Basic/Device/Response/ApiLogResponse.cs b/Src/Dlhis.Basic/Device/Response/ApiLogResponse.cs
new file mode 100644
index 00000000..f2a3f501
--- /dev/null
+++ b/Src/Dlhis.Basic/Device/Response/ApiLogResponse.cs
@@ -0,0 +1,49 @@
+using SqlSugar;
+
+namespace Dlhis.Basic.Device.Response
+{
+ public class ApiLogResponse
+ {
+ ///
+ /// 时间
+ ///
+ [SugarColumn(ColumnDescription = "时间")]
+ public string Timestamp { get; set; }
+
+ ///
+ /// 级别
+ ///
+ [SugarColumn(ColumnDescription = "级别")]
+ public string Level { get; set; }
+
+ ///
+ /// 模板
+ ///
+ [SugarColumn(ColumnDescription = "模板")]
+ public string Template { get; set; }
+
+ ///
+ /// 消息内容
+ ///
+ [SugarColumn(ColumnDescription = "消息内容")]
+ public string Message { get; set; }
+
+ ///
+ /// 异常内容
+ ///
+ [SugarColumn(ColumnDescription = "异常内容")]
+ public string Exception { get; set; }
+
+ ///
+ /// 属性
+ ///
+ [SugarColumn(ColumnDescription = "属性")]
+ public string Properties { get; set; }
+
+ ///
+ /// 时间
+ ///
+ [SugarColumn(ColumnDescription = "时间")]
+ public DateTime _ts { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Basic/Device/Response/RecentNumberResponse.cs b/Src/Dlhis.Basic/Device/Response/RecentNumberResponse.cs
new file mode 100644
index 00000000..ce0de9ea
--- /dev/null
+++ b/Src/Dlhis.Basic/Device/Response/RecentNumberResponse.cs
@@ -0,0 +1,9 @@
+namespace Dlhis.Basic.Device.Response
+{
+ public class RecentNumberResponse
+ {
+ public string Date { get; set; }
+
+ public int Num { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
index 745702d4..889fb755 100644
--- a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
@@ -1,5 +1,6 @@
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
+using Dlhis.Entity.Basic.Entity;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Mvc;
@@ -23,5 +24,7 @@ public interface IDeviceService : IScopeDependency
Task> GetAttendanceOfflineAsync(DeviceOnlineAndofflineRequest request);
- Task> GetRecentNumbersAsync();
+ Task> GetRecentNumbersAsync();
+
+ Task> GetLogsAsync(ApiLogRequest request);
}
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
index 28b2f66c..fe0257a7 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
@@ -3,6 +3,7 @@ using Dlhis.Basic.Device.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
+using Kurisu.AspNetCore.Scope;
using Kurisu.AspNetCore.UnifyResultAndValidation;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
@@ -246,7 +247,7 @@ public class DeviceService : IDeviceService
return page;
}
- public async Task> GetRecentNumbersAsync()
+ public async Task> GetRecentNumbersAsync()
{
//获取近30天并转化为"yyyy-MM-dd"集合
DateTime currentDate = DateTime.Now;
@@ -260,13 +261,39 @@ public class DeviceService : IDeviceService
var devices = await _dbContext.Queryable().ToListAsync();
- var dic = new Dictionary();
+ var list = new List();
times.ForEach(time =>
{
var count = devices.Where(x => x.CreateTime.ToString("yyyy-MM-dd") == time).Count();
- dic[time] = count;
+ var res = new RecentNumberResponse
+ {
+ Date = time,
+ Num = count,
+ };
+ list.Add(res);
+ });
+ return list;
+ }
+
+ public async Task> GetLogsAsync(ApiLogRequest request)
+ {
+ var level = request.Type.ToString();
+ return await Scoped.Request.Value.CreateAsync(async (sp) =>
+ {
+ var configuration = sp.GetService();
+ var logConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value;
+
+ //todo 切换连接字符串
+ var dbContext = sp.GetService();
+ dbContext.Client.CurrentConnectionConfig.ConnectionString = logConnectionString;
+ var logs = await dbContext.Queryable()
+ .WhereIF(!request.message.IsEmpty(), x => x.Message.Contains(request.message))
+ .WhereIF(!level.IsEmpty(),x => x.Level == level)
+ .Select()
+ .ToPageListAsync(request);
+ return logs;
+
});
- return dic;
}
}
diff --git a/Src/Dlhis.Basic/Program.cs b/Src/Dlhis.Basic/Program.cs
index 48192332..0ebc0761 100644
--- a/Src/Dlhis.Basic/Program.cs
+++ b/Src/Dlhis.Basic/Program.cs
@@ -24,9 +24,9 @@ public class Startup : DefaultStartup
base.ConfigureServices(services);
//todo
- var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
+ /*var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
services.AddDataProtection()
.SetApplicationName("basic")
- .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
+ .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");*/
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/appsettings.json b/Src/Dlhis.Basic/appsettings.json
index 6c35cbca..f40f7fef 100644
--- a/Src/Dlhis.Basic/appsettings.json
+++ b/Src/Dlhis.Basic/appsettings.json
@@ -18,6 +18,7 @@
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
"SlaveConnectionString": [],
"FaceConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=face;charset=utf8mb4;",
+ "LogConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=log;charset=utf8mb4;",
"Timeout": 30,
"SlowSqlTime": 1,
"EnableSqlLog": false
diff --git a/Src/Dlhis.Entity/Basic/Entity/ApiLogEntity.cs b/Src/Dlhis.Entity/Basic/Entity/ApiLogEntity.cs
new file mode 100644
index 00000000..889cbd8c
--- /dev/null
+++ b/Src/Dlhis.Entity/Basic/Entity/ApiLogEntity.cs
@@ -0,0 +1,61 @@
+using Kurisu.Core.DataAccess.Entity;
+using Kurisu.SqlSugar;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Dlhis.Entity.Basic.Entity
+{
+ ///
+ /// api日志表
+ ///
+ [SugarTable(TableName = "Logs", TableDescription = "api日志表")]
+ public class ApiLogEntity
+ {
+ ///
+ /// 时间
+ ///
+ [SugarColumn(ColumnDescription = "时间")]
+ public string Timestamp { get; set; }
+
+ ///
+ /// 级别
+ ///
+ [SugarColumn(ColumnDescription = "级别")]
+ public string Level { get; set; }
+
+ ///
+ /// 模板
+ ///
+ [SugarColumn(ColumnDescription = "模板")]
+ public string Template { get; set; }
+
+ ///
+ /// 消息内容
+ ///
+ [SugarColumn(ColumnDescription = "消息内容")]
+ public string Message { get; set; }
+
+ ///
+ /// 异常内容
+ ///
+ [SugarColumn(ColumnDescription = "异常内容")]
+ public string Exception { get; set; }
+
+ ///
+ /// 属性
+ ///
+ [SugarColumn(ColumnDescription = "属性")]
+ public string Properties { get; set; }
+
+ ///
+ /// 时间
+ ///
+ [SugarColumn(ColumnDescription = "时间")]
+ public DateTime _ts { get; set; }
+
+ }
+}
diff --git a/Src/Dlhis.Entity/Basic/Enums/ApiLogEnumType.cs b/Src/Dlhis.Entity/Basic/Enums/ApiLogEnumType.cs
new file mode 100644
index 00000000..a65befdd
--- /dev/null
+++ b/Src/Dlhis.Entity/Basic/Enums/ApiLogEnumType.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Dlhis.Entity.Basic.Enums
+{
+ ///
+ /// api日志状态
+ ///
+ [Description("api日志状态")]
+ public enum ApiLogEnumType
+ {
+ Information = 1,
+
+ Warning = 2,
+
+ Error = 3,
+
+ Fatal = 4,
+ }
+}
diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Controllers/DeviceUploadLogsController.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Controllers/DeviceUploadLogsController.cs
index b9e57664..7a487c2d 100644
--- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Controllers/DeviceUploadLogsController.cs
+++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Controllers/DeviceUploadLogsController.cs
@@ -1,4 +1,5 @@
-using Dlhis.ScheduledTask.DeviceUploadLog.Request;
+using Dlhis.Entity.Basic.Entity;
+using Dlhis.ScheduledTask.DeviceUploadLog.Request;
using Dlhis.ScheduledTask.DeviceUploadLog.Response;
using Dlhis.ScheduledTask.DeviceUploadLog.Services;
using Kurisu.Core.DataAccess.Dto;
@@ -54,4 +55,5 @@ public class DeviceUploadLogsController : ControllerBase
{
await _deviceUploadLogService.UploadLogsAsync(requests);
}
+
}
diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/IDeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/IDeviceUploadLogService.cs
index 8a6285e2..fa2fed08 100644
--- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/IDeviceUploadLogService.cs
+++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/IDeviceUploadLogService.cs
@@ -1,4 +1,5 @@
-using Dlhis.ScheduledTask.DeviceUploadLog.Request;
+using Dlhis.Entity.Basic.Entity;
+using Dlhis.ScheduledTask.DeviceUploadLog.Request;
using Dlhis.ScheduledTask.DeviceUploadLog.Response;
using Kurisu.Core.DataAccess.Dto;
@@ -11,4 +12,5 @@ public interface IDeviceUploadLogService : IScopeDependency
Task UploadLogAsync(DeviceUploadLogUploadRequest request);
Task UploadLogsAsync(List requests);
+
}
diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
index e479e4df..0577b046 100644
--- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
+++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
@@ -1,13 +1,18 @@
-using System.Linq.Expressions;
+using System.Configuration;
+using System.Linq.Expressions;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
using Dlhis.ScheduledTask.DeviceUploadLog.Response;
+using Kurisu.AspNetCore.Scope;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
using Kurisu.SqlSugar.Attributes;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
+using Microsoft.AspNetCore.DataProtection;
+using Microsoft.AspNetCore.Mvc;
+using NetTaste;
using SqlSugar;
namespace Dlhis.ScheduledTask.DeviceUploadLog.Services.Implements;
@@ -101,4 +106,5 @@ public class DeviceUploadLogService : IDeviceUploadLogService
await _dbContext.InsertAsync(records);
}
+
}
From 951e1659f9e0d0136aea91da9b0d7d198b0867d2 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 13:11:17 +0800
Subject: [PATCH 002/146] =?UTF-8?q?feat=20=E8=A7=92=E8=89=B2=E7=AE=A1?=
=?UTF-8?q?=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.Entity/Sys/Entities/RoleEntity.cs | 2 +-
.../Sys/Entities/UserRoleEntity.cs | 13 ++
.../Identity/Controllers/RolesController.cs | 52 +++++-
.../Identity/Request/AssignRoleRequest.cs | 8 +
.../Identity/Request/RoleRemoveRequest.cs | 6 +
.../Identity/Request/RoleSaveRequest.cs | 11 ++
.../Identity/Services/IRoleService.cs | 8 +
.../Services/Implements/RoleService.cs | 157 +++++++++++++++++-
8 files changed, 247 insertions(+), 10 deletions(-)
create mode 100644 Src/Dlhis.Entity/Sys/Entities/UserRoleEntity.cs
create mode 100644 Src/Dlhis.Sys/Identity/Request/AssignRoleRequest.cs
create mode 100644 Src/Dlhis.Sys/Identity/Request/RoleRemoveRequest.cs
create mode 100644 Src/Dlhis.Sys/Identity/Request/RoleSaveRequest.cs
diff --git a/Src/Dlhis.Entity/Sys/Entities/RoleEntity.cs b/Src/Dlhis.Entity/Sys/Entities/RoleEntity.cs
index 610770db..f9a7afa6 100644
--- a/Src/Dlhis.Entity/Sys/Entities/RoleEntity.cs
+++ b/Src/Dlhis.Entity/Sys/Entities/RoleEntity.cs
@@ -17,5 +17,5 @@ public class RoleEntity
public string NormalizedName { get; set; }
- public string ConcurrencyStamp { get; set; }
+ public Guid ConcurrencyStamp { get; set; }
}
diff --git a/Src/Dlhis.Entity/Sys/Entities/UserRoleEntity.cs b/Src/Dlhis.Entity/Sys/Entities/UserRoleEntity.cs
new file mode 100644
index 00000000..8fe6a3cf
--- /dev/null
+++ b/Src/Dlhis.Entity/Sys/Entities/UserRoleEntity.cs
@@ -0,0 +1,13 @@
+using Microsoft.Extensions.DependencyInjection;
+using SqlSugar;
+
+namespace Dlhis.Entity.Sys.Entities;
+
+[SkipScan]
+[SugarTable(TableName = "UserRoles")]
+public class UserRoleEntity
+{
+ public int UserId { get; set; }
+
+ public int RoleId { get; set; }
+}
diff --git a/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs b/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
index ae0ba399..8fa618fc 100644
--- a/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
+++ b/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
@@ -10,7 +10,7 @@ namespace Dlhis.Sys.Identity.Controllers;
///
/// 角色
///
-[Authorize(Roles = "admin")]
+[Authorize]
[Route("api/[controller]")]
[ApiController]
public class RolesController : ControllerBase
@@ -27,9 +27,55 @@ public class RolesController : ControllerBase
///
///
///
- [HttpGet]
- public async Task> GetPageAsync(RolePageRequest request)
+ [Authorize(Roles = "admin")]
+ [HttpGet("page")]
+ public async Task> GetPageAsync([FromQuery] RolePageRequest request)
{
return await _roleService.GetPageAsync(request);
}
+
+ ///
+ /// 分配角色
+ ///
+ ///
+ ///
+ [Authorize(Roles = "admin")]
+ [HttpPost("assign")]
+ public async Task AssignRole(AssignRoleRequest request)
+ {
+ await _roleService.AssignRoleAsync(request);
+ }
+
+ ///
+ /// 保存角色
+ ///
+ ///
+ [Authorize(Roles = "admin")]
+ [HttpPost("save")]
+ public async Task SaveRole(RoleSaveRequest request)
+ {
+ await _roleService.SaveRoleAsync(request);
+ }
+
+ ///
+ /// 移除角色
+ ///
+ ///
+ ///
+ [Authorize(Roles = "admin")]
+ [HttpPost("delete")]
+ public async Task RemoveRole(RoleRemoveRequest request)
+ {
+ await _roleService.RemoveRoleAsync(request);
+ }
+
+ ///
+ /// 我的角色
+ ///
+ ///
+ [HttpGet("my")]
+ public async Task GetMyRoleAsync()
+ {
+ return await _roleService.GetMyRoleAsync();
+ }
}
diff --git a/Src/Dlhis.Sys/Identity/Request/AssignRoleRequest.cs b/Src/Dlhis.Sys/Identity/Request/AssignRoleRequest.cs
new file mode 100644
index 00000000..c66d25c5
--- /dev/null
+++ b/Src/Dlhis.Sys/Identity/Request/AssignRoleRequest.cs
@@ -0,0 +1,8 @@
+namespace Dlhis.Sys.Identity.Request;
+
+public class AssignRoleRequest
+{
+ public int UserId { get; set; }
+
+ public int? RoleId { get; set; }
+}
diff --git a/Src/Dlhis.Sys/Identity/Request/RoleRemoveRequest.cs b/Src/Dlhis.Sys/Identity/Request/RoleRemoveRequest.cs
new file mode 100644
index 00000000..ade423a8
--- /dev/null
+++ b/Src/Dlhis.Sys/Identity/Request/RoleRemoveRequest.cs
@@ -0,0 +1,6 @@
+namespace Dlhis.Sys.Identity.Request;
+
+public class RoleRemoveRequest
+{
+ public int Id { get; set; }
+}
diff --git a/Src/Dlhis.Sys/Identity/Request/RoleSaveRequest.cs b/Src/Dlhis.Sys/Identity/Request/RoleSaveRequest.cs
new file mode 100644
index 00000000..843bc8c5
--- /dev/null
+++ b/Src/Dlhis.Sys/Identity/Request/RoleSaveRequest.cs
@@ -0,0 +1,11 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Dlhis.Sys.Identity.Request;
+
+public class RoleSaveRequest
+{
+ public int? Id { get; set; }
+
+ [Required(ErrorMessage = "角色名不能为空")]
+ public string Name { get; set; }
+}
diff --git a/Src/Dlhis.Sys/Identity/Services/IRoleService.cs b/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
index 41af7fd6..eb101cc1 100644
--- a/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
@@ -7,4 +7,12 @@ namespace Dlhis.User.Identity.Services;
public interface IRoleService : IScopeDependency
{
Task> GetPageAsync(RolePageRequest request);
+
+ Task SaveRoleAsync(RoleSaveRequest request);
+
+ Task GetMyRoleAsync();
+
+ Task RemoveRoleAsync(RoleRemoveRequest request);
+
+ Task AssignRoleAsync(AssignRoleRequest request);
}
diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
index 8768d181..399b1d7f 100644
--- a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
@@ -2,8 +2,11 @@
using Dlhis.Sys.Identity.Request;
using Dlhis.Sys.Identity.Response;
using Dlhis.User.Identity.Services;
+using Kurisu.AspNetCore.Scope;
+using Kurisu.AspNetCore.UnifyResultAndValidation;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
+using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
@@ -11,20 +14,162 @@ namespace Dlhis.Sys.Identity.Services.Implements;
public class RoleService : IRoleService
{
- private readonly IDbContext _dbContext;
+ private readonly IConfiguration _configuration;
+ private readonly ICurrentUser _currentUser;
- public RoleService(IDbContext dbContext, IConfiguration configuration)
+ public RoleService(IConfiguration configuration, ICurrentUser currentUser)
{
- var identityConnection = configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value;
- dbContext.Client.CurrentConnectionConfig.ConnectionString = identityConnection;
- _dbContext = dbContext;
+ _configuration = configuration;
+ _currentUser = currentUser;
}
public async Task> GetPageAsync(RolePageRequest request)
{
- return await _dbContext.Queryable()
+ return await Scoped.Request.Value.CreateAsync(async sp =>
+ {
+ var dbContext = sp.GetService();
+ var identityConnection = _configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value;
+ dbContext.Client.CurrentConnectionConfig.ConnectionString = identityConnection;
+
+
+ return await dbContext.Queryable()
.WhereIF(request.Search.IsPresent(), x => x.Name.Contains(request.Search) || x.NormalizedName.Contains(request.Search))
.Select()
.ToPageListAsync(request);
+ });
+ }
+
+ public async Task GetMyRoleAsync()
+ {
+ var userId = _currentUser.GetIntSubjectId();
+
+ return await Scoped.Request.Value.CreateAsync(async sp =>
+ {
+ var dbContext = sp.GetService();
+ var identityConnection = _configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value;
+ dbContext.Client.CurrentConnectionConfig.ConnectionString = identityConnection;
+
+
+ return await dbContext.Queryable()
+ .LeftJoin((x, r) => x.RoleId == r.Id)
+ .Where(x => x.UserId == userId)
+ .Select((x, r) => new RoleRespone
+ {
+ Id = r.Id,
+ Name = r.Name,
+ NormalizedName = r.NormalizedName,
+ })
+ .FirstAsync();
+ });
+ }
+
+ public async Task SaveRoleAsync(RoleSaveRequest request)
+ {
+ await Scoped.Request.Value.CreateAsync(async sp =>
+ {
+ var dbContext = sp.GetService();
+ var identityConnection = _configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value;
+ dbContext.Client.CurrentConnectionConfig.ConnectionString = identityConnection;
+
+
+ await CheckDuplicateNameAsync(dbContext, request);
+
+ if (!request.Id.HasValue)
+ {
+ await dbContext.InsertAsync(new RoleEntity
+ {
+ Name = request.Name,
+ NormalizedName = request.Name.ToUpperInvariant(),
+ ConcurrencyStamp = Guid.NewGuid(),
+ });
+ }
+ else
+ {
+ var entity = await dbContext.Queryable().Where(x => x.Id == request.Id).FirstAsync();
+ entity.ThrowIfNull("角色不存在");
+
+ entity.Name = request.Name;
+ entity.NormalizedName = request.Name.ToUpperInvariant();
+ entity.ConcurrencyStamp = Guid.NewGuid();
+
+ await dbContext.UpdateAsync(entity);
+ }
+ });
+ }
+
+
+ private async Task CheckDuplicateNameAsync(IDbContext db, RoleSaveRequest request)
+ {
+ var exists = await db.Queryable()
+ .WhereIF(request.Id.HasValue, x => x.Id != request.Id)
+ .Where(x => x.Name == request.Name)
+ .AnyAsync();
+
+ exists.ThrowIfTrue($"重复角色名称{request.Name}");
+ }
+
+ public async Task AssignRoleAsync(AssignRoleRequest request)
+ {
+ var myUserId = _currentUser.GetIntSubjectId();
+
+ await Scoped.Request.Value.CreateAsync(async sp =>
+ {
+ //不能被其他人修改
+ if (request.UserId == 1 && request.UserId != myUserId)
+ {
+ throw new UserFriendlyException("无法修改admin角色");
+ }
+
+ var dbContext = sp.GetService();
+ var identityConnection = _configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value;
+ dbContext.Client.CurrentConnectionConfig.ConnectionString = identityConnection;
+
+ var existsUser = await dbContext.Queryable().Where(x => x.Id == request.UserId).AnyAsync();
+ existsUser.ThrowIfFalse("分配的用户不存在");
+
+ var userRole = await dbContext.Queryable().Where(x => x.UserId == request.UserId).FirstAsync();
+
+ if (request.RoleId.HasValue)
+ {
+ var existsRole = await dbContext.Queryable().Where(x => x.Id == request.RoleId).AnyAsync();
+ existsUser.ThrowIfFalse("分配的角色不存在");
+
+ if (userRole == null)
+ {
+ await dbContext.InsertAsync(new UserRoleEntity
+ {
+ UserId = request.UserId,
+ RoleId = request.RoleId.Value,
+ });
+ }
+ else
+ {
+ await dbContext.Updateable()
+ .SetColumns(x => x.RoleId == request.RoleId)
+ .Where(x => x.UserId == request.UserId)
+ .ExecuteCommandAsync();
+ }
+ }
+ else
+ {
+ await dbContext.DeleteReallyAsync(userRole);
+ }
+ });
+ }
+
+ public async Task RemoveRoleAsync(RoleRemoveRequest request)
+ {
+ await Scoped.Request.Value.CreateAsync(async sp =>
+ {
+ var dbContext = sp.GetService();
+ var identityConnection = _configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value;
+ dbContext.Client.CurrentConnectionConfig.ConnectionString = identityConnection;
+
+ var role = await dbContext.Queryable().FirstAsync(x => x.Id == request.Id);
+ role.ThrowIfNull("角色不存在");
+
+ //删除角色,自动删除UserRoles对应关系
+ await dbContext.DeleteReallyAsync(role);
+ });
}
}
From e55a6793a74910b7ff25115418538e9815903b8d Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 14:01:19 +0800
Subject: [PATCH 003/146] =?UTF-8?q?fix=20=E8=90=A5=E4=B8=9A=E7=82=B9?=
=?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=9E=9A=E4=B8=BE=E5=92=8C=E8=80=83=E5=8B=A4?=
=?UTF-8?q?summary?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.Basic/Dlhis.Basic.csproj | 4 +
.../Controllers/SummariesController.cs | 29 +++++
Src/Dlhis.Basic/Summary/Dto/TrendDto.cs | 8 ++
.../Response/AttendanceDetailSummary.cs | 21 ++++
.../Response/AttendanceDeviceSummary.cs | 26 +++++
.../Response/AttendanceSummaryResponse.cs | 9 ++
.../Summary/Response/GainfoTrendResponse.cs | 10 ++
.../Summary/Services/ISummaryService.cs | 8 ++
.../Services/Implements/SummaryService.cs | 106 ++++++++++++++++++
.../CanteenBusinessPlaceCatalogEnumType.cs | 7 +-
10 files changed, 227 insertions(+), 1 deletion(-)
create mode 100644 Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs
create mode 100644 Src/Dlhis.Basic/Summary/Dto/TrendDto.cs
create mode 100644 Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs
create mode 100644 Src/Dlhis.Basic/Summary/Response/AttendanceDeviceSummary.cs
create mode 100644 Src/Dlhis.Basic/Summary/Response/AttendanceSummaryResponse.cs
create mode 100644 Src/Dlhis.Basic/Summary/Response/GainfoTrendResponse.cs
create mode 100644 Src/Dlhis.Basic/Summary/Services/ISummaryService.cs
create mode 100644 Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs
diff --git a/Src/Dlhis.Basic/Dlhis.Basic.csproj b/Src/Dlhis.Basic/Dlhis.Basic.csproj
index 6dc23042..1b0c0da7 100644
--- a/Src/Dlhis.Basic/Dlhis.Basic.csproj
+++ b/Src/Dlhis.Basic/Dlhis.Basic.csproj
@@ -28,4 +28,8 @@
+
+
+
+
diff --git a/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs b/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs
new file mode 100644
index 00000000..0f7f9fb0
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs
@@ -0,0 +1,29 @@
+using Dlhis.Basic.Summary.Response;
+using Dlhis.Basic.Summary.Services;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Dlhis.Basic.Summary.Controllers;
+
+[Authorize]
+[Route("api/[controller]")]
+[ApiController]
+public class SummariesController : ControllerBase
+{
+ private readonly ISummaryService _summaryService;
+
+ public SummariesController(ISummaryService summaryService)
+ {
+ _summaryService = summaryService;
+ }
+
+ ///
+ /// 考勤首页
+ ///
+ ///
+ [HttpGet("attendance-summary")]
+ public async Task GetKaoQingSummary()
+ {
+ return await _summaryService.GetAttendanceSummaryAsync();
+ }
+}
diff --git a/Src/Dlhis.Basic/Summary/Dto/TrendDto.cs b/Src/Dlhis.Basic/Summary/Dto/TrendDto.cs
new file mode 100644
index 00000000..2d2d046d
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Dto/TrendDto.cs
@@ -0,0 +1,8 @@
+namespace Dlhis.Basic.Summary.Dto;
+
+public class TrendDto
+{
+ public DateTime Date { get; set; }
+
+ public int Count { get; set; }
+}
diff --git a/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs b/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs
new file mode 100644
index 00000000..f4f9c24a
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs
@@ -0,0 +1,21 @@
+using Dlhis.Basic.Summary.Dto;
+
+namespace Dlhis.Basic.Summary.Response;
+
+public class AttendanceDetailSummary
+{
+ ///
+ /// 在职人数
+ ///
+ public int Employed { get; set; }
+
+ ///
+ /// 非在职人数
+ ///
+ public int Unemployed { get; set; }
+
+ ///
+ /// 人员趋势 7天
+ ///
+ public GainfoTrendResponse GainfoTrend { get; set; }
+}
diff --git a/Src/Dlhis.Basic/Summary/Response/AttendanceDeviceSummary.cs b/Src/Dlhis.Basic/Summary/Response/AttendanceDeviceSummary.cs
new file mode 100644
index 00000000..c0ebc007
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Response/AttendanceDeviceSummary.cs
@@ -0,0 +1,26 @@
+using Dlhis.Basic.Summary.Dto;
+
+namespace Dlhis.Basic.Summary.Response;
+
+public class AttendanceDeviceSummary
+{
+ ///
+ /// 总数
+ ///
+ public int Total { get; set; }
+
+ ///
+ /// 在线数
+ ///
+ public int OnlineCount { get; set; }
+
+ ///
+ /// 启用数
+ ///
+ public int EnableCount { get; set; }
+
+ ///
+ /// 新增设备趋势 30天内
+ ///
+ public List Trend { get; set; }
+}
diff --git a/Src/Dlhis.Basic/Summary/Response/AttendanceSummaryResponse.cs b/Src/Dlhis.Basic/Summary/Response/AttendanceSummaryResponse.cs
new file mode 100644
index 00000000..ab930d60
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Response/AttendanceSummaryResponse.cs
@@ -0,0 +1,9 @@
+namespace Dlhis.Basic.Summary.Response
+{
+ public class AttendanceSummaryResponse
+ {
+ public AttendanceDeviceSummary DeviceSummary { get; set; }
+
+ public AttendanceDetailSummary AttendanceDetailSummary { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Basic/Summary/Response/GainfoTrendResponse.cs b/Src/Dlhis.Basic/Summary/Response/GainfoTrendResponse.cs
new file mode 100644
index 00000000..4050c983
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Response/GainfoTrendResponse.cs
@@ -0,0 +1,10 @@
+using Dlhis.Basic.Summary.Dto;
+
+namespace Dlhis.Basic.Summary.Response
+{
+ public class GainfoTrendResponse
+ {
+ public List EmployedTrend { get; set; }
+ public List UnemployedTrend { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs b/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs
new file mode 100644
index 00000000..775379d2
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs
@@ -0,0 +1,8 @@
+using Dlhis.Basic.Summary.Response;
+
+namespace Dlhis.Basic.Summary.Services;
+
+public interface ISummaryService : IScopeDependency
+{
+ Task GetAttendanceSummaryAsync();
+}
diff --git a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs
new file mode 100644
index 00000000..ad4f3e1e
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs
@@ -0,0 +1,106 @@
+using Dlhis.Basic.Organization.Services;
+using Dlhis.Basic.Summary.Dto;
+using Dlhis.Basic.Summary.Response;
+using Dlhis.Entity.Basic.Entity;
+using Dlhis.Entity.Basic.Enums;
+using Dlhis.Entity.Device.Entities;
+using Kurisu.SqlSugar.Services;
+
+namespace Dlhis.Basic.Summary.Services.Implements;
+
+public class SummaryService : ISummaryService
+{
+ private readonly IDbContext _dbContext;
+ private readonly IGainfoStore _gainfoStore;
+
+ public SummaryService(IDbContext dbContext, IGainfoStore gainfoStore)
+ {
+ _dbContext = dbContext;
+ _gainfoStore = gainfoStore;
+ }
+
+ public async Task GetAttendanceSummaryAsync()
+ {
+ var now = DateTime.Now;
+
+ var currentDay = DateTime.Today.AddDays(1).AddSeconds(-1);
+ var before30Day = DateTime.Today.AddDays(-29);
+ var before7Day = DateTime.Today.AddDays(-6);
+
+ var devices = await _dbContext.Queryable().ToListAsync();
+ var deviceUniqueNos = devices.Select(x => x.UniqueNo).ToList();
+
+ var deviceRegistries = await _dbContext.Queryable()
+ .LeftJoin((x, d) => x.DeviceUniqueNo == d.UniqueNo)
+ .Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
+ .Select((x, d) => new
+ {
+ d.HeartbeatInterval,
+ x.LastHeartbeatTime
+ })
+ .ToListAsync();
+
+ var workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).ToListAsync();
+ var leaveGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave).ToListAsync();
+
+ return new AttendanceSummaryResponse
+ {
+ DeviceSummary = new AttendanceDeviceSummary
+ {
+ Total = devices.Count,
+ EnableCount = devices.Where(x => x.Enable).Count(),
+ OnlineCount = deviceRegistries.Where(x =>
+ {
+ if (x.HeartbeatInterval <= 0)
+ {
+ return false;
+ }
+
+ return x.LastHeartbeatTime.AddSeconds(x.HeartbeatInterval * 3) >= now;
+
+ }).Count(),
+ Trend = FixTrend(devices.Where(x => x.CreateTime >= before30Day && x.CreateTime <= currentDay)
+ .GroupBy(x => x.CreateTime.Date)
+ .Select(x => new TrendDto { Date = x.Key, Count = x.Count() }), before30Day, currentDay)
+ },
+ AttendanceDetailSummary = new AttendanceDetailSummary
+ {
+ Employed = workingGainfos.Count,
+ Unemployed = leaveGainfos.Count,
+ GainfoTrend = new GainfoTrendResponse
+ {
+ EmployedTrend = FixTrend(workingGainfos.Where(x => x.CreateTime >= before7Day && x.CreateTime <= currentDay)
+ .GroupBy(x => x.CreateTime.Date)
+ .Select(x => new TrendDto { Date = x.Key, Count = x.Count() }), before7Day, currentDay),
+ UnemployedTrend = FixTrend(leaveGainfos.Where(x => x.CreateTime >= before7Day && x.CreateTime <= currentDay)
+ .GroupBy(x => x.CreateTime.Date)
+ .Select(x => new TrendDto { Date = x.Key, Count = x.Count() }), before7Day, currentDay),
+ }
+ }
+ };
+ }
+
+ private static List FixTrend(IEnumerable dtos, DateTime start, DateTime end)
+ {
+ var result = dtos.ToList();
+
+ start = start.Date;
+ end = end.Date;
+
+ var currentDate = start;
+ while (currentDate <= end)
+ {
+ if (result.Any(x => x.Date == currentDate))
+ {
+ currentDate = currentDate.AddDays(1);
+ continue;
+ }
+
+ result.Add(new TrendDto { Date = currentDate, Count = 0 });
+
+ currentDate = currentDate.AddDays(1);
+ }
+
+ return result;
+ }
+}
diff --git a/Src/Dlhis.Entity/Canteen/Enums/CanteenBusinessPlaceCatalogEnumType.cs b/Src/Dlhis.Entity/Canteen/Enums/CanteenBusinessPlaceCatalogEnumType.cs
index 9f0c4f97..80724371 100644
--- a/Src/Dlhis.Entity/Canteen/Enums/CanteenBusinessPlaceCatalogEnumType.cs
+++ b/Src/Dlhis.Entity/Canteen/Enums/CanteenBusinessPlaceCatalogEnumType.cs
@@ -20,10 +20,15 @@ public enum CanteenBusinessPlaceCatalogEnumType
[Description("食堂")]
Cafeteria = 2,
-
///
/// 超市
///
[Description("超市")]
Supermarket = 3,
+
+ ///
+ /// 水吧
+ ///
+ [Description("水吧")]
+ Bar = 4,
}
\ No newline at end of file
From b5d6ec8366c8ccbfaf3a9929afd386ad4bc017ce Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 14:04:01 +0800
Subject: [PATCH 004/146] =?UTF-8?q?feat=20=E6=9F=A5=E8=AF=A2=E6=B6=88?=
=?UTF-8?q?=E8=B4=B9=E6=9C=BA=E6=80=BB=E6=95=B0=E3=80=81=E7=A6=BB=E7=BA=BF?=
=?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=95=B0=E9=87=8F=E3=80=81=E8=90=A5=E4=B8=9A?=
=?UTF-8?q?=E7=82=B9=E6=95=B0=E9=87=8F=E3=80=81=E5=8F=AF=E6=B6=88=E8=B4=B9?=
=?UTF-8?q?=E4=BA=BA=E6=95=B0=E3=80=81=E4=BA=BA=E5=9D=87=E6=97=A5=E6=B6=88?=
=?UTF-8?q?=E8=B4=B9=E9=A2=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Device/Response/ApiLogResponse.cs | 7 ----
.../Device/Services/IDeviceService.cs | 1 +
.../Order/Controllers/BalancesController.cs | 10 +++++
.../Order/Response/ConsumeNumberResponse.cs | 30 +++++++++++++++
.../Order/Services/IBalanceService.cs | 2 +
.../Services/Implements/BalanceService.cs | 38 +++++++++++++++++++
6 files changed, 81 insertions(+), 7 deletions(-)
create mode 100644 Src/Dlhis.Canteen/Order/Response/ConsumeNumberResponse.cs
diff --git a/Src/Dlhis.Basic/Device/Response/ApiLogResponse.cs b/Src/Dlhis.Basic/Device/Response/ApiLogResponse.cs
index f2a3f501..3d51efae 100644
--- a/Src/Dlhis.Basic/Device/Response/ApiLogResponse.cs
+++ b/Src/Dlhis.Basic/Device/Response/ApiLogResponse.cs
@@ -7,43 +7,36 @@ namespace Dlhis.Basic.Device.Response
///
/// 时间
///
- [SugarColumn(ColumnDescription = "时间")]
public string Timestamp { get; set; }
///
/// 级别
///
- [SugarColumn(ColumnDescription = "级别")]
public string Level { get; set; }
///
/// 模板
///
- [SugarColumn(ColumnDescription = "模板")]
public string Template { get; set; }
///
/// 消息内容
///
- [SugarColumn(ColumnDescription = "消息内容")]
public string Message { get; set; }
///
/// 异常内容
///
- [SugarColumn(ColumnDescription = "异常内容")]
public string Exception { get; set; }
///
/// 属性
///
- [SugarColumn(ColumnDescription = "属性")]
public string Properties { get; set; }
///
/// 时间
///
- [SugarColumn(ColumnDescription = "时间")]
public DateTime _ts { get; set; }
}
}
diff --git a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
index 889fb755..8af87410 100644
--- a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
@@ -27,4 +27,5 @@ public interface IDeviceService : IScopeDependency
Task> GetRecentNumbersAsync();
Task> GetLogsAsync(ApiLogRequest request);
+
}
diff --git a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
index c2fbc53b..608fbfbc 100644
--- a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
+++ b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
@@ -132,4 +132,14 @@ public class BalancesController : ControllerBase
{
return await _balanceService.BalanceRecordAnalysisAsync(request);
}
+
+ ///
+ /// 获取消费机总数、离线设备数量、营业点数量、可消费人数、人均日消费额
+ ///
+ ///
+ [HttpGet("consumenumbers")]
+ public async Task GetConsumeNumberAsync()
+ {
+ return await _balanceService.GetConsumeNumberAsync();
+ }
}
diff --git a/Src/Dlhis.Canteen/Order/Response/ConsumeNumberResponse.cs b/Src/Dlhis.Canteen/Order/Response/ConsumeNumberResponse.cs
new file mode 100644
index 00000000..609b1a68
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Response/ConsumeNumberResponse.cs
@@ -0,0 +1,30 @@
+namespace Dlhis.Canteen.Order.Response
+{
+ public class ConsumeNumberResponse
+ {
+ ///
+ /// 消费机总数
+ ///
+ public int Total { get; set; }
+
+ ///
+ /// 消费机离线数
+ ///
+ public int OffNumber { get; set; }
+
+ ///
+ /// 营业点总数
+ ///
+ public int PlaceNumber { get; set; }
+
+ ///
+ /// 可消费人数
+ ///
+ public int ConsumerableNumber { get; set; }
+
+ ///
+ /// 人均日消费额
+ ///
+ public int DailyNumber { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
index 8a12f2c4..6c78934d 100644
--- a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
@@ -23,4 +23,6 @@ public interface IBalanceService : IScopeDependency
Task> BalanceRecordSummaryByTidAsync(BalanceRecordSummaryRequest request);
Task> BalanceRecordAnalysisAsync(BalanceRecordAnalysisRequest request);
+
+ Task GetConsumeNumberAsync();
}
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index eb6d36e4..256e9caf 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -547,6 +547,44 @@ public class BalanceService : IBalanceService
}, 5);
}
+ public async Task GetConsumeNumberAsync()
+ {
+ var devices = await _dbContext.Queryable()
+ .Where(x => x.Type == DeviceTypeEnumType.Meal)
+ .ToListAsync();
+
+ var offCount = devices.Where(x => x.Enable == false).Count();
+
+ var places = await _dbContext.Queryable()
+ .ToListAsync();
+
+ var time = DateTime.Now.ToString("yyyy-MM-dd");
+ //所有消费数据
+ var bs = await _dbContext.Queryable()
+ .Where(x => x.Type == BalanceRecordTypeEnumType.Out)
+ .ToListAsync();
+ //可消费人数
+ var consumerable = bs.Select(x => x.UserCode).Distinct().Count();
+
+ //当日消费数据
+ var monthbs = bs
+ .Where(x => x.CostDateTime.ToString("yyyy-MM-dd") == time);
+ //当日消费额
+ var monthlySpending = monthbs.Sum(x => x.Amount);
+ //当日消费人数
+ var monthlyCount = monthbs.Select(x => x.UserCode).Distinct().Count();
+ var res = new ConsumeNumberResponse
+ {
+ Total = devices.Count(),
+ OffNumber = offCount,
+ PlaceNumber = places.Count(),
+ ConsumerableNumber = consumerable,
+ DailyNumber = monthlyCount != 0 ? (int)Math.Ceiling(monthlySpending / monthlyCount) : 0
+ };
+ return res;
+
+ }
+
//************************************************************** help methods ******************************************************************
From 170b6a1202886f1ad3d24cbe7580ad37ec960883 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 14:30:03 +0800
Subject: [PATCH 005/146] =?UTF-8?q?feat=20=E5=88=9B=E5=BB=BA=E7=B3=BB?=
=?UTF-8?q?=E7=BB=9F=E9=BB=98=E8=AE=A4=E5=88=86=E7=BB=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/GainfosController.cs | 6 +-
.../Response/GainfoPageResponse.cs | 8 +-
.../Services/Implements/GainfoService.cs | 6 +-
Src/Dlhis.Basic/Packs/SqlSugarPack.cs | 14 +-
.../Basic/Entity/GainfoGroupEntity.cs | 25 ++-
.../Device/Entities/DeviceGroupEntity.cs | 1 -
.../CommonJobs/CreateDefinitelyGroupJob.cs | 163 ++++++++++++++++++
Src/Dlhis.ScheduledTask/Packs/JobPack.cs | 9 +-
8 files changed, 212 insertions(+), 20 deletions(-)
create mode 100644 Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
index b6c09d43..33e9307f 100644
--- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
+++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
@@ -2,12 +2,10 @@
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Response;
using Dlhis.Basic.Organization.Services;
-using Dlhis.Entity.Basic.Entity;
using Kurisu.AspNetCore.MVC;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using Org.BouncyCastle.Asn1.Ocsp;
namespace Dlhis.Basic.MealUser.Controllers;
@@ -142,7 +140,7 @@ public class GainfosController : ControllerBase
///
///
///
- [HttpGet("gainfolist")]
+ [HttpGet("list")]
public async Task> GetGainfoListTaskAsync([FromQuery]GainfoListRequest request)
{
return await _gainfoService.GetGainfoListTaskAsync(request);
@@ -152,7 +150,7 @@ public class GainfosController : ControllerBase
///
///
///
- [HttpGet("gainfodetail")]
+ [HttpGet("detail")]
public async Task GetGainfoDetailTaskAsync([FromQuery] GainfoDetailRequest request)
{
return await _gainfoService.GetGainfoDetailTaskAsync(request);
diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
index df112cee..cb3c563c 100644
--- a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
+++ b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
@@ -1,4 +1,7 @@
-namespace Dlhis.Basic.Organization.Response;
+using Dlhis.Entity.Basic.Enums;
+using Kurisu.AspNetCore.Utils.Extensions;
+
+namespace Dlhis.Basic.Organization.Response;
public class GainfoPageResponse
{
@@ -52,7 +55,8 @@ public class GainfoPageResponse
///
/// 性别
///
- public string Gender { get; set; }
+ public GenderEnumType Gender { get; set; }
+ public string GenderDesc => Gender.GetDescription();
///
/// 生日
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index ce14552e..78753d46 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -53,9 +53,9 @@ public class GainfoService : IGainfoService
var tenant = _currentUser.GetStringTenantId();
var page = await _gainfoStore.Queryable(request.Status)
- .WhereIF(request.DepartmentNos?.Any() == true, gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
+ .WhereIF(request.DepartmentNos.IsPresent(), gainfo => request.DepartmentNos.Contains(gainfo.DepartmentNo))
.WhereIF(request.Search.IsPresent(), gainfo =>
- gainfo.Name.Contains(request.Search)
+ gainfo.Name.Contains(request.Search)
|| gainfo.Code.Contains(request.Search))
.Where(gainfo => gainfo.Werks == tenant)
.Select()
@@ -561,7 +561,7 @@ public class GainfoService : IGainfoService
///
private async Task> GetRecursionDepartmentNosAsync(List departmentNos)
{
- if (departmentNos == null || departmentNos.Count == 0)
+ if (departmentNos.IsEmpty())
{
return new List();
}
diff --git a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
index f481ce85..d4467cae 100644
--- a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
+++ b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
@@ -17,14 +17,14 @@ public class SqlSugarPack : BaseAppPack
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
- //using var scope = app.ApplicationServices.CreateScope();
- //var db = scope.ServiceProvider.GetService();
- //var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false))
- // .Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
- // .ToArray();
+ using var scope = app.ApplicationServices.CreateScope();
+ var db = scope.ServiceProvider.GetService();
+ var tables = App.ActiveTyps.Where(x => x.IsDefined(typeof(SugarTable), false))
+ .Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
+ .ToArray();
- //db.DbMaintenance.CreateDatabase();
- //db.CodeFirst.InitTables(tables);
+ db.DbMaintenance.CreateDatabase();
+ db.CodeFirst.InitTables(tables);
//using var scopeFace = app.ApplicationServices.CreateScope();
//var dbFace = scopeFace.ServiceProvider.GetService();
diff --git a/Src/Dlhis.Entity/Basic/Entity/GainfoGroupEntity.cs b/Src/Dlhis.Entity/Basic/Entity/GainfoGroupEntity.cs
index 2243b9e5..b7e533c0 100644
--- a/Src/Dlhis.Entity/Basic/Entity/GainfoGroupEntity.cs
+++ b/Src/Dlhis.Entity/Basic/Entity/GainfoGroupEntity.cs
@@ -1,4 +1,5 @@
-using Kurisu.SqlSugar;
+using Kurisu.Core.DataAccess.Entity;
+using Kurisu.SqlSugar;
using SqlSugar;
namespace Dlhis.Entity.Basic.Entity;
@@ -7,8 +8,13 @@ namespace Dlhis.Entity.Basic.Entity;
/// 档案组
///
[SugarTable(TableName = "GainfoGroup", TableDescription = "档案组")]
-public class GainfoGroupEntity : SugarBaseEntity
+public class GainfoGroupEntity : SugarBaseEntity, ITenantId
{
+ ///
+ /// 父级Code
+ ///
+ public Guid? PCode { get; set; }
+
///
/// 分组code
///
@@ -26,4 +32,19 @@ public class GainfoGroupEntity : SugarBaseEntity
///
[SugarColumn(ColumnDescription = "备注")]
public string Remark { get; set; }
+
+ ///
+ /// 是否默认分组
+ ///
+ [SugarColumn(ColumnDescription = "是否默认分组")]
+ public bool IsDefault { get; set; }
+
+ ///
+ /// 是否可编辑
+ ///
+ [SugarColumn(ColumnDescription = "是否可编辑")]
+ public bool Editable { get; set; }
+
+
+ public string TenantId { get; set; }
}
diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
index 3c06d72e..6d037b6a 100644
--- a/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
+++ b/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
@@ -12,7 +12,6 @@ namespace Dlhis.Entity.Device.Entities;
[SugarTable(TableName = "DeviceGroup", TableDescription = "设备组")]
public class DeviceGroupEntity : SugarBaseEntity, ITenantId, ISoftDeleted
{
-
///
/// 设备组功能类型
///
diff --git a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
new file mode 100644
index 00000000..9390c884
--- /dev/null
+++ b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
@@ -0,0 +1,163 @@
+using Dlhis.Entity.Basic.Entity;
+using Dlhis.Entity.Device.Entities;
+using Dlhis.Entity.Device.Enums;
+using Dlhis.Sys.Api;
+using Kurisu.Core.DataAccess.Entity;
+using Kurisu.SqlSugar.Services;
+
+namespace Dlhis.ScheduledTask.CommonJobs;
+
+public class CreateDefinitelyGroupJob
+{
+ private readonly ILogger _logger;
+ private readonly ITenantApi _tenantApi;
+ private readonly IDbContext _dbContext;
+
+ public CreateDefinitelyGroupJob(ILogger logger, ITenantApi tenantApi, IDbContext dbContext)
+ {
+ _logger = logger;
+ _tenantApi = tenantApi;
+ _dbContext = dbContext;
+ }
+
+ public async Task RunAsync()
+ {
+ _dbContext.Client.QueryFilter.ClearAndBackup();
+ try
+ {
+ var tenantResult = await _tenantApi.GetTenantsInternalAsync();
+ var tenants = tenantResult.Data;
+
+ foreach (var tenant in tenants)
+ {
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.IsDefault))
+ {
+
+ var customGroup = new GainfoGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Name = "*自定义人员分组",
+ IsDefault = true,
+ Editable = false,
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code
+ };
+ await _dbContext.InsertAsync(customGroup);
+
+
+ var groups = new[] { "*督查组", "*X3及以上领导组", "*外派人员组" };
+ foreach (var group in groups)
+ {
+ var grp = new GainfoGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Name = group,
+ IsDefault = false,
+ Editable = false,
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code
+ };
+
+ await _dbContext.InsertAsync(grp);
+ }
+ }
+
+ //**************************************************************************************************************/
+
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.Name == "*通用考勤设备组"))
+ {
+ await _dbContext.InsertAsync(new DeviceGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Type = DeviceTypeEnumType.Attendance,
+ Name = "*通用考勤设备组",
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code,
+ });
+ }
+
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.Name == "*专用考勤设备组"))
+ {
+ await _dbContext.InsertAsync(new DeviceGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Type = DeviceTypeEnumType.Attendance,
+ Name = "*专用考勤设备组",
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code,
+ });
+ }
+
+ //**************************************************************************************************************/
+
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code)
+ .Where(x => x.Type == DeviceTypeEnumType.Door)
+ .AnyAsync(x => x.Name == "*通用考勤设备组")
+ )
+ {
+ await _dbContext.InsertAsync(new DeviceGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Type = DeviceTypeEnumType.Door,
+ Name = "*非公共区域",
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code,
+ });
+ }
+
+ if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code)
+ .Where(x => x.Type == DeviceTypeEnumType.Door)
+ .AnyAsync(x => x.Name == "*专用考勤设备组")
+ )
+ {
+ await _dbContext.InsertAsync(new DeviceGroupEntity
+ {
+ PCode = null,
+ Code = Guid.NewGuid(),
+ Type = DeviceTypeEnumType.Door,
+ Name = "*公共区域",
+
+ CreatedBy = 1,
+ CreateTime = DateTime.Now,
+ ModifiedBy = 1,
+ ModifiedTime = DateTime.Now,
+ TenantId = tenant.Code,
+ });
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "自动创建系统分组失败:{message}", ex.Message);
+ }
+ finally
+ {
+ _dbContext.Client.QueryFilter.Restore();
+ }
+ }
+}
diff --git a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
index 49f75fff..ec5b214d 100644
--- a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
+++ b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
@@ -1,4 +1,5 @@
-using Dlhis.ScheduledTask.SyncSapInfo.Job;
+using Dlhis.ScheduledTask.CommonJobs;
+using Dlhis.ScheduledTask.SyncSapInfo.Job;
using Dlhis.ScheduledTask.TaskAssignment.Job;
using Hangfire;
using Kurisu.AspNetCore.Startup;
@@ -32,5 +33,11 @@ public class JobPack : BaseAppPack
{
TimeZone = TimeZoneInfo.Local
});
+
+ //创建系统默认分组
+ RecurringJob.AddOrUpdate("CreateDefinitelyGroup", s => s.RunAsync(), "0 0 5 * * ?", new RecurringJobOptions
+ {
+ TimeZone = TimeZoneInfo.Local
+ });
}
}
From 1ccacdf04d87793079bd52050b7e86dfe98e4aae Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 14:46:43 +0800
Subject: [PATCH 006/146] =?UTF-8?q?fix=20=E6=9B=B4=E6=96=B0=E6=B3=A8?=
=?UTF-8?q?=E9=87=8A=E5=92=8Crole-list?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Identity/Controllers/RolesController.cs | 11 +++++++
.../Identity/Response/RoleRespone.cs | 5 +++
.../Identity/Response/UserResponse.cs | 33 +++++++++++++++++++
.../Identity/Services/IRoleService.cs | 2 ++
.../Services/Implements/RoleService.cs | 16 +++++++++
5 files changed, 67 insertions(+)
diff --git a/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs b/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
index 8fa618fc..0924f7c3 100644
--- a/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
+++ b/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
@@ -34,6 +34,17 @@ public class RolesController : ControllerBase
return await _roleService.GetPageAsync(request);
}
+ ///
+ /// 角色列表
+ ///
+ ///
+ [Authorize(Roles = "admin")]
+ [HttpGet("list")]
+ public async Task> GetListAsync()
+ {
+ return await _roleService.GetListAsync();
+ }
+
///
/// 分配角色
///
diff --git a/Src/Dlhis.Sys/Identity/Response/RoleRespone.cs b/Src/Dlhis.Sys/Identity/Response/RoleRespone.cs
index 0b233448..03cd8c23 100644
--- a/Src/Dlhis.Sys/Identity/Response/RoleRespone.cs
+++ b/Src/Dlhis.Sys/Identity/Response/RoleRespone.cs
@@ -7,4 +7,9 @@ public class RoleRespone
public string Name { get; set; }
public string NormalizedName { get; set; }
+
+ ///
+ /// 是否可编辑
+ ///
+ public bool Editable => Id > 5;
}
diff --git a/Src/Dlhis.Sys/Identity/Response/UserResponse.cs b/Src/Dlhis.Sys/Identity/Response/UserResponse.cs
index d11dec11..45ff5c74 100644
--- a/Src/Dlhis.Sys/Identity/Response/UserResponse.cs
+++ b/Src/Dlhis.Sys/Identity/Response/UserResponse.cs
@@ -4,25 +4,58 @@ public class UserResponse
{
public int Id { get; set; }
+ ///
+ /// 账号名称
+ ///
public string UserName { get; set; }
+ ///
+ /// 规范化账号名称
+ ///
public string NormalizedUserName { get; set; }
+ ///
+ /// 邮件
+ ///
public string Email { get; set; }
+ ///
+ /// 规范化邮件
+ ///
public string NormalizedEmail { get; set; }
+ ///
+ /// 邮件是否已确认
+ ///
public bool EmailConfirmed { get; set; }
+ ///
+ /// 手机号
+ ///
public string PhoneNumber { get; set; }
+ ///
+ /// 手机号是否已确认
+ ///
public bool PhoneNumberConfirmed { get; set; }
+ ///
+ /// 是否开启双因素认证
+ ///
public bool TwoFactorEnabled { get; set; }
+ ///
+ /// 账号锁定结束时间
+ ///
public DateTime? LockoutEnd { get; set; }
+ ///
+ /// 是否开启账号锁定功能
+ ///
public bool LockoutEnabled { get; set; }
+ ///
+ /// 登陆失败次数
+ ///
public int AccessFailedCount { get; set; }
}
diff --git a/Src/Dlhis.Sys/Identity/Services/IRoleService.cs b/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
index eb101cc1..3b789429 100644
--- a/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
@@ -8,6 +8,8 @@ public interface IRoleService : IScopeDependency
{
Task> GetPageAsync(RolePageRequest request);
+ Task> GetListAsync();
+
Task SaveRoleAsync(RoleSaveRequest request);
Task GetMyRoleAsync();
diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
index 399b1d7f..38cd025a 100644
--- a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
@@ -9,6 +9,7 @@ using Kurisu.Core.DataAccess.Dto;
using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
+using Org.BouncyCastle.Asn1.Ocsp;
namespace Dlhis.Sys.Identity.Services.Implements;
@@ -172,4 +173,19 @@ public class RoleService : IRoleService
await dbContext.DeleteReallyAsync(role);
});
}
+
+ public async Task> GetListAsync()
+ {
+ return await Scoped.Request.Value.CreateAsync(async sp =>
+ {
+ var dbContext = sp.GetService();
+ var identityConnection = _configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value;
+ dbContext.Client.CurrentConnectionConfig.ConnectionString = identityConnection;
+
+
+ return await dbContext.Queryable()
+ .Select()
+ .ToListAsync();
+ });
+ }
}
From 9f5c2398329285b35b6b3a6b6140aed476b80d9a Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 15:00:21 +0800
Subject: [PATCH 007/146] =?UTF-8?q?fix=20=E8=80=83=E5=8B=A4=E4=BB=BB?=
=?UTF-8?q?=E5=8A=A1=E7=94=9F=E6=88=90=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.ScheduledTask/Packs/JobPack.cs | 2 ++
.../TaskAssignment/Job/CreateGetAttendanceJob.cs | 9 ++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
index ec5b214d..5bccbd46 100644
--- a/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
+++ b/Src/Dlhis.ScheduledTask/Packs/JobPack.cs
@@ -24,11 +24,13 @@ public class JobPack : BaseAppPack
TimeZone = TimeZoneInfo.Local
});
+ //创建设备同步时间任务
RecurringJob.AddOrUpdate("SyncServerDateTime", s => s.RunAsync(), "0 0 0/1 * * ?", new RecurringJobOptions
{
TimeZone = TimeZoneInfo.Local
});
+ //创建设备获取考勤的任务
RecurringJob.AddOrUpdate("CreateGetAttendance", s => s.RunAsync(), "0 0/1 * * * ?", new RecurringJobOptions
{
TimeZone = TimeZoneInfo.Local
diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs
index 90a1703a..2e57474d 100644
--- a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs
+++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs
@@ -23,16 +23,19 @@ public class CreateGetAttendanceJob
_dbContext.Client.QueryFilter.ClearAndBackup();
try
{
- var devices = await _dbContext.Queryable().Where(x => x.Enable).ToListAsync();
- devices = devices.Where(x => x.Funcs.Contains(DeviceFuncEnumType.Attendance)).ToList();
+ var devices = await _dbContext.Queryable()
+ .Where(x => x.Enable)
+ .Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance))
+ .ToListAsync();
var ds = devices.Select(x => x.UniqueNo).ToList();
- var b = await _dbContext.Queryable()
+ var b = await _dbContext.Queryable()
.Where(x => ds.Contains(x.DeviceUniqueNo))
.Where(x => x.Type == DeviceTaskEnumType.UploadRecord)
.Where(x => x.Status == DeviceTaskStatusEnumType.Process)
.AnyAsync();
+
if (b)
{
return;
From a08b08fbc159cf23f86c0f6cef2ed4b889a73824 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 15:00:51 +0800
Subject: [PATCH 008/146] =?UTF-8?q?fix=20=E8=AE=BE=E5=A4=87,=E8=AE=BE?=
=?UTF-8?q?=E5=A4=87=E5=88=86=E7=BB=84=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/DeviceGroupsController.cs | 6 +++--
.../Device/Request/DeviceGroupPageRequest.cs | 7 ++++-
.../Device/Request/DeviceGroupSaveRequest.cs | 3 +--
.../Response/DeviceGroupPageResponse.cs | 26 ++++++++++++++++++-
.../Response/DeviceUnderGroupResponse.cs | 10 ++++++-
.../Device/Services/IDeviceGroupService.cs | 3 ++-
.../Services/Implements/DeviceGroupService.cs | 18 ++++++++++++-
Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs | 7 +++++
.../Device/Enums/DeviceTypeEnumType.cs | 6 -----
9 files changed, 71 insertions(+), 15 deletions(-)
diff --git a/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs b/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs
index bba3ae80..c05c41ba 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DeviceGroupsController.cs
@@ -1,6 +1,7 @@
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
using Dlhis.Basic.Device.Services;
+using Dlhis.Entity.Device.Enums;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -37,11 +38,12 @@ public class DeviceGroupsController : ControllerBase
/// 获取设备组树
///
/// 是否显示设备
+ /// 分组类型
///
[HttpGet("tree")]
- public async Task> GetTreeAsync(bool showDevices)
+ public async Task> GetTreeAsync(bool showDevices, DeviceTypeEnumType? type)
{
- return await _deviceGroupService.GetTreeAsync(showDevices);
+ return await _deviceGroupService.GetTreeAsync(showDevices, type);
}
///
diff --git a/Src/Dlhis.Basic/Device/Request/DeviceGroupPageRequest.cs b/Src/Dlhis.Basic/Device/Request/DeviceGroupPageRequest.cs
index 419810f2..aee1a3d9 100644
--- a/Src/Dlhis.Basic/Device/Request/DeviceGroupPageRequest.cs
+++ b/Src/Dlhis.Basic/Device/Request/DeviceGroupPageRequest.cs
@@ -1,7 +1,12 @@
-using Kurisu.Core.DataAccess.Dto;
+using Dlhis.Entity.Device.Enums;
+using Kurisu.Core.DataAccess.Dto;
namespace Dlhis.Basic.Device.Request;
public class DeviceGroupPageRequest : PageDto
{
+ ///
+ /// 分组类型
+ ///
+ public DeviceTypeEnumType? Type { get; set; }
}
diff --git a/Src/Dlhis.Basic/Device/Request/DeviceGroupSaveRequest.cs b/Src/Dlhis.Basic/Device/Request/DeviceGroupSaveRequest.cs
index 35240dac..9cbf1ee9 100644
--- a/Src/Dlhis.Basic/Device/Request/DeviceGroupSaveRequest.cs
+++ b/Src/Dlhis.Basic/Device/Request/DeviceGroupSaveRequest.cs
@@ -21,7 +21,6 @@ public class DeviceGroupSaveRequest
///
/// 分类类型 DeviceTypeEnumType
///
- [Required(ErrorMessage = "分类不能为空")]
[EnumDataType(typeof(DeviceTypeEnumType))]
- public DeviceTypeEnumType Type { get; set; }
+ public DeviceTypeEnumType? Type { get; set; }
}
diff --git a/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs b/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs
index 446557ed..8d81e4a4 100644
--- a/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs
+++ b/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs
@@ -1,4 +1,7 @@
-namespace Dlhis.Basic.Device.Response;
+using Dlhis.Entity.Device.Enums;
+using Kurisu.AspNetCore.Utils.Extensions;
+
+namespace Dlhis.Basic.Device.Response;
public class DeviceGroupPageResponse
{
@@ -11,4 +14,25 @@ public class DeviceGroupPageResponse
/// 设备组名称
///
public string Name { get; set; }
+
+ ///
+ /// 分组类型
+ ///
+ public DeviceTypeEnumType? Type { get; set; }
+
+ ///
+ /// 分组类型描述
+ ///
+ public string TypeDesc
+ {
+ get
+ {
+ if (!Type.HasValue)
+ {
+ return string.Empty;
+ }
+
+ return Type.Value.GetDescription();
+ }
+ }
}
diff --git a/Src/Dlhis.Basic/Device/Response/DeviceUnderGroupResponse.cs b/Src/Dlhis.Basic/Device/Response/DeviceUnderGroupResponse.cs
index 806a7d9b..c9d59404 100644
--- a/Src/Dlhis.Basic/Device/Response/DeviceUnderGroupResponse.cs
+++ b/Src/Dlhis.Basic/Device/Response/DeviceUnderGroupResponse.cs
@@ -1,4 +1,6 @@
-namespace Dlhis.Basic.Device.Response;
+using Dlhis.Entity.Device.Enums;
+
+namespace Dlhis.Basic.Device.Response;
public class DeviceUnderGroupResponse
{
@@ -14,6 +16,12 @@ public class DeviceUnderGroupResponse
///
public string Brand { get; set; }
+ ///
+ /// 设备类型
+ ///
+ public DeviceTypeEnumType Type { get; set; }
+
+
///
/// 是否启用
///
diff --git a/Src/Dlhis.Basic/Device/Services/IDeviceGroupService.cs b/Src/Dlhis.Basic/Device/Services/IDeviceGroupService.cs
index e759376e..13368b4f 100644
--- a/Src/Dlhis.Basic/Device/Services/IDeviceGroupService.cs
+++ b/Src/Dlhis.Basic/Device/Services/IDeviceGroupService.cs
@@ -1,5 +1,6 @@
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
+using Dlhis.Entity.Device.Enums;
using Kurisu.Core.DataAccess.Dto;
namespace Dlhis.Basic.Device.Services;
@@ -8,7 +9,7 @@ public interface IDeviceGroupService : IScopeDependency
{
Task> GetPageAsync(DeviceGroupPageRequest request);
- Task> GetTreeAsync(bool showDevices);
+ Task> GetTreeAsync(bool showDevices, DeviceTypeEnumType? type);
Task SaveAsync(DeviceGroupSaveRequest request);
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
index 3047dc21..04722357 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
@@ -2,6 +2,7 @@
using Dlhis.Basic.Device.Response;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
+using Dlhis.Entity.Device.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
using Kurisu.SqlSugar.Attributes;
@@ -26,13 +27,15 @@ public class DeviceGroupService : IDeviceGroupService
{
return await _dbContext.Queryable()
.WhereIF(request.Search.IsPresent(), x => x.Name.Contains(request.Search))
+ .WhereIF(request.Type.HasValue, x => x.Type == request.Type)
.Select()
.ToPageListAsync(request);
}
- public async Task> GetTreeAsync(bool showDevices)
+ public async Task> GetTreeAsync(bool showDevices, DeviceTypeEnumType? type)
{
var deviceGroups = await _dbContext.Queryable()
+ .WhereIF(type.HasValue, x => x.Type == type)
.Select()
.ToListAsync();
@@ -61,6 +64,18 @@ public class DeviceGroupService : IDeviceGroupService
{
var entity = await _dbContext.Queryable().Where(x => x.Id == request.Id).FirstAsync();
entity.ThrowIfNull("设备组不存在,无法更新");
+
+ var nextDevices = await GetDevicesAsync(entity.Code);
+ if (!entity.Type.HasValue)
+ {
+ (request.Type.HasValue && nextDevices.Any(x => x.Type != request.Type)).ThrowIfTrue($"分组设备存在非{request.Type.Value.GetDescription()}类型的设备设备");
+ }
+ else
+ {
+ (request.Type.HasValue && request.Type != entity.Type && nextDevices.Any()).ThrowIfTrue("分组设备类型不匹配,无法修改类型");
+ }
+
+
await _dbContext.UpdateAsync(entity);
}
}
@@ -73,6 +88,7 @@ public class DeviceGroupService : IDeviceGroupService
await _dbContext.DeleteAsync(deviceGroup);
}
+
[Transactional]
public async Task AssignDevicesAsync(DeviceAssignRequest request)
{
diff --git a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
index 6c24630f..6bde31c3 100644
--- a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
+++ b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
@@ -84,5 +84,12 @@ public class DeviceEntity : SugarBaseEntity, ITenantId
[SugarColumn(ColumnDataType = "bit", ColumnDescription = "是否启用")]
public bool Enable { get; set; }
+
+ ///
+ /// 是否作为考勤设备
+ ///
+ [SugarColumn(ColumnDataType = "bit", ColumnDescription = "是否作为考勤设备")]
+ public bool AsAttendance { get; set; }
+
public string TenantId { get; set; }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Entity/Device/Enums/DeviceTypeEnumType.cs b/Src/Dlhis.Entity/Device/Enums/DeviceTypeEnumType.cs
index 230e6e17..48c2ec70 100644
--- a/Src/Dlhis.Entity/Device/Enums/DeviceTypeEnumType.cs
+++ b/Src/Dlhis.Entity/Device/Enums/DeviceTypeEnumType.cs
@@ -25,10 +25,4 @@ public enum DeviceTypeEnumType
///
[Description("考勤")]
Attendance = 3,
-
- ///
- /// 门禁并作为考勤
- ///
- [Description("门禁并作为考勤")]
- DoorAndAttendance = 4,
}
From 2d1678de9f6b5e6bf480d7bfb5d2d48e817d055b Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 15:03:31 +0800
Subject: [PATCH 009/146] =?UTF-8?q?fix=20=E4=BD=9C=E4=B8=BA=E8=80=83?=
=?UTF-8?q?=E5=8B=A4=E8=AE=BE=E5=A4=87=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Device/Request/DeviceSaveRequest.cs | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/Src/Dlhis.Basic/Device/Request/DeviceSaveRequest.cs b/Src/Dlhis.Basic/Device/Request/DeviceSaveRequest.cs
index 10b3a65b..96bd0278 100644
--- a/Src/Dlhis.Basic/Device/Request/DeviceSaveRequest.cs
+++ b/Src/Dlhis.Basic/Device/Request/DeviceSaveRequest.cs
@@ -1,9 +1,10 @@
using System.ComponentModel.DataAnnotations;
using Dlhis.Entity.Device.Enums;
+using Kurisu.AspNetCore.Utils.Extensions;
namespace Dlhis.Basic.Device.Request;
-public class DeviceSaveRequest
+public class DeviceSaveRequest : IValidatableObject
{
public long? Id { get; set; }
@@ -70,4 +71,17 @@ public class DeviceSaveRequest
/// 是否启用
///
public bool Enable { get; set; }
+
+ ///
+ /// 是否作为考勤设备
+ ///
+ public bool AsAttendance { get; set; }
+
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ if (Type != DeviceTypeEnumType.Door && AsAttendance)
+ {
+ yield return new ValidationResult($"{DeviceTypeEnumType.Door.GetDescription()}才可设置作为考勤设备", new[] { nameof(AsAttendance) });
+ }
+ }
}
From 40b8e1af6866199a7346b59f4d4f9e130d2de7df Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 15:12:31 +0800
Subject: [PATCH 010/146] =?UTF-8?q?feat=20=E6=97=A5/=E6=9C=88=E6=B6=88?=
=?UTF-8?q?=E8=B4=B9=E8=B5=B0=E5=8A=BF=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Order/Controllers/BalancesController.cs | 20 ++++
.../Order/Request/ConsumptionTrendRequest.cs | 12 +++
.../Response/ConsumptionTrendResponse.cs | 20 ++++
.../Order/Services/IBalanceService.cs | 5 +
.../Services/Implements/BalanceService.cs | 100 ++++++++++++++++++
.../Canteen/Enums/ConsumptionTrendEnumType.cs | 24 +++++
6 files changed, 181 insertions(+)
create mode 100644 Src/Dlhis.Canteen/Order/Request/ConsumptionTrendRequest.cs
create mode 100644 Src/Dlhis.Canteen/Order/Response/ConsumptionTrendResponse.cs
create mode 100644 Src/Dlhis.Entity/Canteen/Enums/ConsumptionTrendEnumType.cs
diff --git a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
index 608fbfbc..8ed0dd64 100644
--- a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
+++ b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
@@ -142,4 +142,24 @@ public class BalancesController : ControllerBase
{
return await _balanceService.GetConsumeNumberAsync();
}
+
+ ///
+ /// 消费走势
+ ///
+ ///
+ [HttpGet("consumptiontrends")]
+ public async Task> GetConsumptionTrendsAsync([FromQuery] ConsumptionTrendRequest request)
+ {
+ return await _balanceService.GetConsumptionTrendsAsync(request);
+ }
+
+ ///
+ /// 餐补走势
+ ///
+ ///
+ [HttpGet("supplementtrend")]
+ public async Task> GetSupplementTrendsAsync([FromQuery] ConsumptionTrendRequest request)
+ {
+ return await _balanceService.GetSupplementTrendsAsync(request);
+ }
}
diff --git a/Src/Dlhis.Canteen/Order/Request/ConsumptionTrendRequest.cs b/Src/Dlhis.Canteen/Order/Request/ConsumptionTrendRequest.cs
new file mode 100644
index 00000000..7f223506
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Request/ConsumptionTrendRequest.cs
@@ -0,0 +1,12 @@
+using Dlhis.Entity.Canteen.Enums;
+using System.ComponentModel.DataAnnotations;
+
+namespace Dlhis.Canteen.Order.Request
+{
+ public class ConsumptionTrendRequest
+ {
+ [Required]
+ [EnumDataType(typeof(ConsumptionTrendEnumType))]
+ public ConsumptionTrendEnumType Type { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Order/Response/ConsumptionTrendResponse.cs b/Src/Dlhis.Canteen/Order/Response/ConsumptionTrendResponse.cs
new file mode 100644
index 00000000..b490dd19
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Response/ConsumptionTrendResponse.cs
@@ -0,0 +1,20 @@
+namespace Dlhis.Canteen.Order.Response
+{
+ public class ConsumptionTrendResponse
+ {
+ ///
+ /// 时间
+ ///
+ public string DateTime { get; set; }
+
+ ///
+ /// 当日/月消费总额
+ ///
+ public decimal CurrentAmount { get; set; }
+
+ ///
+ /// 消费总额
+ ///
+ public decimal TotalAmount { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
index 6c78934d..8ba54785 100644
--- a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
@@ -1,6 +1,7 @@
using Dlhis.Canteen.Order.Request;
using Dlhis.Canteen.Order.Response;
using Kurisu.Core.DataAccess.Dto;
+using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Canteen.Order.Services;
@@ -25,4 +26,8 @@ public interface IBalanceService : IScopeDependency
Task> BalanceRecordAnalysisAsync(BalanceRecordAnalysisRequest request);
Task GetConsumeNumberAsync();
+
+ Task> GetConsumptionTrendsAsync(ConsumptionTrendRequest request);
+
+ Task> GetSupplementTrendsAsync(ConsumptionTrendRequest request);
}
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index 256e9caf..08f58d1b 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -13,7 +13,9 @@ using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Attributes;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
+using Microsoft.AspNetCore.Mvc;
using SqlSugar;
+using System.Globalization;
namespace Dlhis.Canteen.Order.Services.Implements;
@@ -584,6 +586,104 @@ public class BalanceService : IBalanceService
return res;
}
+ public async Task> GetConsumptionTrendsAsync(ConsumptionTrendRequest request)
+ {
+ var bs = await _dbContext.Queryable()
+ .Where(x => x.Type == BalanceRecordTypeEnumType.Out)
+ .ToListAsync();
+ //消费总额
+ var totalAmount = Math.Round(Math.Abs(bs.Sum(x => x.Amount)), 2);
+
+ var list = new List();
+ if (request.Type == ConsumptionTrendEnumType.Month)
+ {
+ //月与总额对比
+ var months = GetMonthsOfYear();
+
+ foreach (var month in months)
+ {
+ var currentAmount = Math.Round(Math.Abs(bs.Where(x => x.CostDateTime.ToString("yyyy-MM") == month)
+ .Sum(x => x.Amount)), 2);
+
+ var res = new ConsumptionTrendResponse
+ {
+ DateTime = month,
+ CurrentAmount = currentAmount,
+ TotalAmount = totalAmount
+ };
+ list.Add(res);
+ }
+ }
+ else
+ {
+ //日与总额对比
+ var days = GetDaysOfMonth();
+
+ foreach (var day in days)
+ {
+ var currentAmount = Math.Round(Math.Abs(bs.Where(x => x.CostDateTime.ToString("yyyy-MM-dd") == day)
+ .Sum(x => x.Amount)), 2);
+
+ var res = new ConsumptionTrendResponse
+ {
+ DateTime = day,
+ CurrentAmount = currentAmount,
+ TotalAmount = totalAmount
+ };
+ list.Add(res);
+ }
+ }
+ return list;
+ }
+
+ public async Task> GetSupplementTrendsAsync(ConsumptionTrendRequest request)
+ {
+ //todo
+ return new List();
+ }
+
+ ///
+ /// 获取当前年所有月
+ ///
+ ///
+ private List GetMonthsOfYear()
+ {
+ List months = new List();
+ // 获取当前年份
+ int year = DateTime.Now.Year;
+ // 遍历12个月份并添加到列表中
+ for (int month = 1; month <= 12; month++)
+ {
+ DateTime monthDate = new DateTime(year, month, 1);
+ months.Add(monthDate.ToString("yyyy-MM"));
+ }
+ return months;
+ }
+
+ ///
+ /// 获取当前月所有天
+ ///
+ ///
+ private List GetDaysOfMonth()
+ {
+ List days = new List();
+
+ // 获取当前年份和月份
+ int year = DateTime.Now.Year;
+ int month = DateTime.Now.Month;
+
+ // 获取当前月份的第一天和最后一天
+ DateTime firstDayOfMonth = new DateTime(year, month, 1);
+ DateTime lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);
+
+ // 遍历当前月的所有日期并添加到列表中
+ for (DateTime date = firstDayOfMonth; date <= lastDayOfMonth; date = date.AddDays(1))
+ {
+ days.Add(date.ToString("yyyy-MM-dd"));
+ }
+
+ return days;
+ }
//************************************************************** help methods ******************************************************************
diff --git a/Src/Dlhis.Entity/Canteen/Enums/ConsumptionTrendEnumType.cs b/Src/Dlhis.Entity/Canteen/Enums/ConsumptionTrendEnumType.cs
new file mode 100644
index 00000000..e8573b48
--- /dev/null
+++ b/Src/Dlhis.Entity/Canteen/Enums/ConsumptionTrendEnumType.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Dlhis.Entity.Canteen.Enums
+{
+ public enum ConsumptionTrendEnumType
+ {
+ ///
+ /// 日
+ ///
+ [Description("日")]
+ Day = 1,
+
+ ///
+ /// 月
+ ///
+ [Description("月")]
+ Month = 2,
+ }
+}
From 82f942ed134eae315c4c23277dd5c07ad7dbf539 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 15:32:24 +0800
Subject: [PATCH 011/146] =?UTF-8?q?fix=20role,user=E6=9F=A5=E7=9C=8B;=20?=
=?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Device/Response/DevicePageResponse.cs | 15 ++++++
.../Services/Implements/DeviceService.cs | 47 ++++++++++++++++++-
.../Identity/Controllers/RolesController.cs | 4 +-
.../Identity/Response/UserResponse.cs | 6 +++
.../Identity/Services/IRoleService.cs | 2 +-
.../Services/Implements/RoleService.cs | 6 +--
.../Services/Implements/UserService.cs | 10 ++--
7 files changed, 78 insertions(+), 12 deletions(-)
diff --git a/Src/Dlhis.Basic/Device/Response/DevicePageResponse.cs b/Src/Dlhis.Basic/Device/Response/DevicePageResponse.cs
index 448e34e9..d9d47179 100644
--- a/Src/Dlhis.Basic/Device/Response/DevicePageResponse.cs
+++ b/Src/Dlhis.Basic/Device/Response/DevicePageResponse.cs
@@ -84,4 +84,19 @@ public class DevicePageResponse
/// 是否启用
///
public bool Enable { get; set; }
+
+ ///
+ /// 是否在线
+ ///
+ public bool IsOnline { get; set; }
+
+ ///
+ /// 消费总额
+ ///
+ public decimal Amount { get; set; }
+
+ ///
+ /// 消费人次
+ ///
+ public int UserCount { get; set; }
}
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
index fe0257a7..8a7e9bb3 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
@@ -1,6 +1,8 @@
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
using Dlhis.Entity.Basic.Entity;
+using Dlhis.Entity.Canteen.Entities;
+using Dlhis.Entity.Canteen.Enums;
using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
using Kurisu.AspNetCore.Scope;
@@ -11,7 +13,6 @@ using Kurisu.SqlSugar.Attributes;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
using Mapster;
-using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -40,9 +41,51 @@ public class DeviceService : IDeviceService
}, true)
.ToPageListAsync(request);
+ var now = DateTime.Now;
+ var deviceUniqueNos = page.Data.Select(x => x.UniqueNo).ToList();
+
+ var balanceRecords = await _dbContext.Queryable().Where(x => x.Type == BalanceRecordTypeEnumType.Out)
+ .Where(x => deviceUniqueNos.Contains(x.DeviceInfo))
+ .ToListAsync();
+
+ var deviceRegistries = await _dbContext.Queryable()
+ .LeftJoin((x, d) => x.DeviceUniqueNo == d.UniqueNo)
+ .Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
+ .Select((x, d) => new
+ {
+ d.HeartbeatInterval,
+ x.LastHeartbeatTime,
+ x.DeviceUniqueNo,
+ })
+ .ToListAsync();
+
+ page.Data.ForEach(device =>
+ {
+ device.Amount = balanceRecords.Sum(x => x.Amount);
+ device.UserCount = balanceRecords.DistinctBy(x => x.UserCode).Count();
+
+ var r = deviceRegistries.FirstOrDefault(x => x.DeviceUniqueNo == device.UniqueNo);
+ if (r == null)
+ {
+ device.IsOnline = false;
+ }
+ else
+ {
+ if (r.HeartbeatInterval <= 0)
+ {
+ device.IsOnline = true;
+ }
+ else
+ {
+ device.IsOnline = r.LastHeartbeatTime.AddSeconds(r.HeartbeatInterval * 3) >= now;
+ }
+ }
+ });
+
return page;
}
+
[Transactional]
public async Task SaveAsync(DeviceSaveRequest request)
{
@@ -288,7 +331,7 @@ public class DeviceService : IDeviceService
dbContext.Client.CurrentConnectionConfig.ConnectionString = logConnectionString;
var logs = await dbContext.Queryable()
.WhereIF(!request.message.IsEmpty(), x => x.Message.Contains(request.message))
- .WhereIF(!level.IsEmpty(),x => x.Level == level)
+ .WhereIF(!level.IsEmpty(), x => x.Level == level)
.Select()
.ToPageListAsync(request);
return logs;
diff --git a/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs b/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
index 0924f7c3..cd65a44d 100644
--- a/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
+++ b/Src/Dlhis.Sys/Identity/Controllers/RolesController.cs
@@ -85,8 +85,8 @@ public class RolesController : ControllerBase
///
///
[HttpGet("my")]
- public async Task GetMyRoleAsync()
+ public async Task GetMyRoleAsync(int? userId)
{
- return await _roleService.GetMyRoleAsync();
+ return await _roleService.GetMyRoleAsync(userId);
}
}
diff --git a/Src/Dlhis.Sys/Identity/Response/UserResponse.cs b/Src/Dlhis.Sys/Identity/Response/UserResponse.cs
index 45ff5c74..15c1fe33 100644
--- a/Src/Dlhis.Sys/Identity/Response/UserResponse.cs
+++ b/Src/Dlhis.Sys/Identity/Response/UserResponse.cs
@@ -58,4 +58,10 @@ public class UserResponse
/// 登陆失败次数
///
public int AccessFailedCount { get; set; }
+
+
+ ///
+ /// 角色
+ ///
+ public string Role { get; set; }
}
diff --git a/Src/Dlhis.Sys/Identity/Services/IRoleService.cs b/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
index 3b789429..8b02ba23 100644
--- a/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/IRoleService.cs
@@ -12,7 +12,7 @@ public interface IRoleService : IScopeDependency
Task SaveRoleAsync(RoleSaveRequest request);
- Task GetMyRoleAsync();
+ Task GetMyRoleAsync(int? userId);
Task RemoveRoleAsync(RoleRemoveRequest request);
diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
index 38cd025a..2702f1a2 100644
--- a/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/Implements/RoleService.cs
@@ -9,7 +9,6 @@ using Kurisu.Core.DataAccess.Dto;
using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
-using Org.BouncyCastle.Asn1.Ocsp;
namespace Dlhis.Sys.Identity.Services.Implements;
@@ -40,9 +39,9 @@ public class RoleService : IRoleService
});
}
- public async Task GetMyRoleAsync()
+ public async Task GetMyRoleAsync(int? userId)
{
- var userId = _currentUser.GetIntSubjectId();
+ userId ??= _currentUser.GetIntSubjectId();
return await Scoped.Request.Value.CreateAsync(async sp =>
{
@@ -50,7 +49,6 @@ public class RoleService : IRoleService
var identityConnection = _configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value;
dbContext.Client.CurrentConnectionConfig.ConnectionString = identityConnection;
-
return await dbContext.Queryable()
.LeftJoin((x, r) => x.RoleId == r.Id)
.Where(x => x.UserId == userId)
diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
index f27e0528..63a9b19f 100644
--- a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
@@ -1,5 +1,4 @@
-using System.Configuration;
-using Dlhis.Entity.Sys.Entities;
+using Dlhis.Entity.Sys.Entities;
using Dlhis.Sys.Identity.Request;
using Dlhis.Sys.Identity.Response;
using Kurisu.AspNetCore.Utils.Extensions;
@@ -23,13 +22,18 @@ public class UserService : IUserService
public async Task> GetPageAsync(UserPageRequest request)
{
return await _dbContext.Queryable()
+ .LeftJoin((x, ur) => x.Id == ur.UserId)
+ .LeftJoin((x, ur, r) => ur.RoleId == r.Id)
.WhereIF(request.Search.IsPresent(), x => x.UserName.Contains(request.Search)
|| x.NormalizedUserName.Contains(request.Search)
|| x.Email.Contains(request.Search)
|| x.NormalizedEmail.Contains(request.Search)
|| x.PhoneNumber.Contains(request.Search)
)
- .Select()
+ .Select((x, ur, r) => new UserResponse
+ {
+ Id = x.Id
+ }, true)
.ToPageListAsync(request);
}
From f4acba8c6b428ce44fd19e23c73acb17b2e3496e Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 16:02:19 +0800
Subject: [PATCH 012/146] =?UTF-8?q?fix=20=E7=A7=BB=E9=99=A4=E6=97=A0?=
=?UTF-8?q?=E7=94=A8=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/GainfosController.cs | 54 +-----------
.../Organization/Request/GainfoSaveRequest.cs | 5 --
.../Response/GainfoDetailResponse.cs | 5 --
.../Response/GainfoListResponse.cs | 87 +++++++++----------
.../Response/GainfoPageResponse.cs | 5 --
.../Organization/Services/IGainfoService.cs | 8 --
.../Services/Implements/GainfoService.cs | 48 +---------
Src/Dlhis.Basic/Packs/SqlSugarPack.cs | 3 +-
Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs | 6 --
9 files changed, 44 insertions(+), 177 deletions(-)
diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
index 33e9307f..39d3405f 100644
--- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
+++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
@@ -141,7 +141,7 @@ public class GainfosController : ControllerBase
///
///
[HttpGet("list")]
- public async Task> GetGainfoListTaskAsync([FromQuery]GainfoListRequest request)
+ public async Task> GetGainfoListTaskAsync([FromQuery] GainfoListRequest request)
{
return await _gainfoService.GetGainfoListTaskAsync(request);
}
@@ -155,57 +155,5 @@ public class GainfosController : ControllerBase
{
return await _gainfoService.GetGainfoDetailTaskAsync(request);
}
-
- ///
- /// 获取近七天入职人数及列表
- ///
- ///
- [HttpGet("weeknumber")]
- public async Task>> GetWeekNumberAsync([FromQuery] WeekNumberRequest request)
- {
- // 从请求头中获取 Token
- string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
-
- return await _gainfoService.GetWeekNumberAsync(request,token);
- }
-
- ///
- /// 获取近七天离职人数及列表
- ///
- ///
- [HttpGet("weeknumberdimission")]
- public async Task>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request)
- {
- // 从请求头中获取 Token
- string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
-
- return await _gainfoService.GetDimissionWeekNumberAsync(request,token);
- }
-
- ///
- /// 获取基地在职、离职、考勤数
- ///
- ///
- [HttpGet("gainfonumbers")]
- public async Task GetGainfoNumbersAsync()
- {
- // 从请求头中获取 Token
- string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
-
- return await _gainfoService.GetGainfoNumbersAsync(token);
- }
-
- ///
- /// 获取本基地管理员列表
- ///
- ///
- ///
- [HttpGet("administrator")]
- public async Task> GetAdministratorAsync([FromQuery] WeekNumberRequest request)
- {
- // 从请求头中获取 Token
- string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
- return await _gainfoService.GetAdministratorAsync(request,token);
- }
}
diff --git a/Src/Dlhis.Basic/Organization/Request/GainfoSaveRequest.cs b/Src/Dlhis.Basic/Organization/Request/GainfoSaveRequest.cs
index 54f41fe3..838f621c 100644
--- a/Src/Dlhis.Basic/Organization/Request/GainfoSaveRequest.cs
+++ b/Src/Dlhis.Basic/Organization/Request/GainfoSaveRequest.cs
@@ -110,11 +110,6 @@ public class GainfoSaveRequest : IValidatableObject
///
public string Werks { get; set; }
- ///
- /// 在职状态
- ///
- public string Employed { get; set; }
-
public IEnumerable Validate(ValidationContext validationContext)
{
if (GainfoStatus.HasValue && GainfoStatus == GainfoStatusEnumType.Leave)
diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoDetailResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoDetailResponse.cs
index a2472cfe..565d53dc 100644
--- a/Src/Dlhis.Basic/Organization/Response/GainfoDetailResponse.cs
+++ b/Src/Dlhis.Basic/Organization/Response/GainfoDetailResponse.cs
@@ -105,10 +105,5 @@ namespace Dlhis.Basic.Organization.Response
/// 民族代码
///
public string NationName { get; set; }
-
- ///
- /// 是否在职
- ///
- public bool IsActive { get; set; }
}
}
diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoListResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoListResponse.cs
index a826eec0..8e7c6789 100644
--- a/Src/Dlhis.Basic/Organization/Response/GainfoListResponse.cs
+++ b/Src/Dlhis.Basic/Organization/Response/GainfoListResponse.cs
@@ -1,60 +1,51 @@
using Dlhis.Entity.Basic.Enums;
-using SqlSugar;
-using SqlSugar.DbConvert;
-namespace Dlhis.Basic.Organization.Response
+namespace Dlhis.Basic.Organization.Response;
+
+public class GainfoListResponse
{
- public class GainfoListResponse
- {
- ///
- /// 档案号
- ///
- public string No { get; set; }
+ ///
+ /// 档案号
+ ///
+ public string No { get; set; }
- ///
- /// 姓名
- ///
- public string Name { get; set; }
+ ///
+ /// 姓名
+ ///
+ public string Name { get; set; }
- ///
- /// 学工号
- ///
- public string Code { get; set; }
+ ///
+ /// 学工号
+ ///
+ public string Code { get; set; }
- ///
- /// 身份证号
- ///
- public string IdNo { get; set; }
+ ///
+ /// 身份证号
+ ///
+ public string IdNo { get; set; }
- ///
- /// 性别
- ///
- public GenderEnumType Gender { get; set; }
+ ///
+ /// 性别
+ ///
+ public GenderEnumType Gender { get; set; }
- ///
- /// 手机号码
- ///
- public string Phone { get; set; }
+ ///
+ /// 手机号码
+ ///
+ public string Phone { get; set; }
- ///
- /// 部门编码
- ///
- public string DepartmentNo { get; set; }
+ ///
+ /// 部门编码
+ ///
+ public string DepartmentNo { get; set; }
- ///
- /// 部门名称
- ///
- public string DepartmentName { get; set; }
+ ///
+ /// 部门名称
+ ///
+ public string DepartmentName { get; set; }
- ///
- /// 身份证地址
- ///
- public string Address { get; set; }
-
- ///
- /// 在职状态
- ///
- public string Employed { get; set; }
-
- }
+ ///
+ /// 身份证地址
+ ///
+ public string Address { get; set; }
}
diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
index cb3c563c..4b8faadd 100644
--- a/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
+++ b/Src/Dlhis.Basic/Organization/Response/GainfoPageResponse.cs
@@ -112,9 +112,4 @@ public class GainfoPageResponse
/// 人事范围
///
public string Werks { get; set; }
-
- ///
- /// 在职状态
- ///
- public string Employed { get; set; }
}
diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
index 7bb8f0fc..7372f48d 100644
--- a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
@@ -31,12 +31,4 @@ public interface IGainfoService : IScopeDependency
Task> GetGainfoListTaskAsync(GainfoListRequest request);
Task GetGainfoDetailTaskAsync(GainfoDetailRequest request);
-
- Task>> GetWeekNumberAsync(WeekNumberRequest request, string token);
-
- Task>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request, string token);
-
- Task GetGainfoNumbersAsync(string token);
-
- Task> GetAdministratorAsync(WeekNumberRequest request,string token);
}
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index 78753d46..f21150bd 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -333,10 +333,10 @@ public class GainfoService : IGainfoService
DepartmentNo = de.No,
DepartmentName = de.Name,
Address = ga.Address,
- Employed = ga.Employed
}).ToPageListAsync(request);
return page;
}
+
///
/// 档案详情
///
@@ -373,8 +373,8 @@ public class GainfoService : IGainfoService
Marital = ga.Marital,
CountryName = type2.Display,
NationName = type3.Display,
- IsActive = ga.Employed == "Active" ? true : false,
}).FirstAsync();
+
return info;
}
@@ -425,11 +425,8 @@ public class GainfoService : IGainfoService
Marital = ga.Marital,
CountryName = type2.Display,
NationName = type3.Display,
- IsActive = ga.Employed == "Active" ? true : false,
}).ToPageListAsync(request);
- //var infos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
- // .Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time)
- // .ToPageListAsync(request);
+
dic[time] = infos;
}
return dic;
@@ -481,7 +478,6 @@ public class GainfoService : IGainfoService
Marital = ga.Marital,
CountryName = type2.Display,
NationName = type3.Display,
- IsActive = ga.Employed == "Active" ? true : false,
}).ToPageListAsync(request);
dic[time] = infos;
}
@@ -514,44 +510,6 @@ public class GainfoService : IGainfoService
return res;
}
- public async Task> GetAdministratorAsync( WeekNumberRequest request, string token)
- {
- var werks = GetClaimValueFromToken(token, "tenant");
- var info = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
- .LeftJoin((ga, de) => ga.DepartmentNo == de.No)
- .LeftJoin((ga, de, type) => ga.Native == type.Code && type.Type == "native")
- .LeftJoin((ga, de, type, posi) => ga.Position == posi.Name)
- .LeftJoin((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
- .LeftJoin((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
- .Where(ga => ga.Werks == werks && ga.IdentityUserId != 0)
- .Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse
- {
- No = ga.No,
- SapNo = ga.SapNo,
- Name = ga.Name,
- Code = ga.Code,
- DepartmentName = de.Name,
- IdClass = ga.IdClass,
- IdNo = ga.IdNo,
- Gender = ga.Gender,
- NativeName = type.Display,
- Address = ga.Address,
- Birthday = ga.Birthday,
- Phone = ga.Phone,
- Position = ga.Position,
- Grade = posi.Grade,
- Degree = ga.Degree,
- Werks = ga.Werks,
- CostId = ga.CostId,
- Marital = ga.Marital,
- CountryName = type2.Display,
- NationName = type3.Display,
- IsActive = ga.Employed == "Active" ? true : false,
- }).ToPageListAsync(request);
-
- return info;
- }
-
//-------------------------------------------help methods ------------------------------------------------
///
diff --git a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
index d4467cae..86dc45aa 100644
--- a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
+++ b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
@@ -1,5 +1,4 @@
-using Dlhis.Entity.Basic.Entity;
-using Kurisu.AspNetCore;
+using Kurisu.AspNetCore;
using Kurisu.AspNetCore.Startup;
using Kurisu.SqlSugar.Extensions;
using SqlSugar;
diff --git a/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs b/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs
index 1ddbe206..66ff9e59 100644
--- a/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs
+++ b/Src/Dlhis.Entity/Basic/Entity/GainfoEntity.cs
@@ -148,12 +148,6 @@ public class GainfoEntity : SugarBaseEntity
///
public string CostId { get; set; }
- ///
- /// 在职状态
- ///
- [SugarColumn(ColumnDescription = "在职状态")]
- public string Employed { get; set; }
-
///
/// 身份认证用户Id
///
From d3c8c211bfa192d12fff1eb155159fab638f6ee0 Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 16:24:16 +0800
Subject: [PATCH 013/146] =?UTF-8?q?feat=20=E7=94=B5=E5=AD=90=E9=A4=90?=
=?UTF-8?q?=E5=88=B8=E7=94=B3=E8=AF=B7/=E4=BD=BF=E7=94=A8=E8=AE=B0?=
=?UTF-8?q?=E5=BD=95=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Order/Controllers/BalancesController.cs | 22 ++++
.../Request/OaEMealVoucherDetailRequest.cs | 12 +++
.../Order/Request/OaEMealVoucherRequest.cs | 14 +++
.../Response/OaEMealVoucherDetailResponse.cs | 65 ++++++++++++
.../Order/Response/OaEMealVoucherResponse.cs | 100 ++++++++++++++++++
.../Order/Services/IBalanceService.cs | 4 +
.../Services/Implements/BalanceService.cs | 19 ++++
7 files changed, 236 insertions(+)
create mode 100644 Src/Dlhis.Canteen/Order/Request/OaEMealVoucherDetailRequest.cs
create mode 100644 Src/Dlhis.Canteen/Order/Request/OaEMealVoucherRequest.cs
create mode 100644 Src/Dlhis.Canteen/Order/Response/OaEMealVoucherDetailResponse.cs
create mode 100644 Src/Dlhis.Canteen/Order/Response/OaEMealVoucherResponse.cs
diff --git a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
index 8ed0dd64..8c306db1 100644
--- a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
+++ b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
@@ -162,4 +162,26 @@ public class BalancesController : ControllerBase
{
return await _balanceService.GetSupplementTrendsAsync(request);
}
+
+ ///
+ /// 电子餐券申请记录查询
+ ///
+ ///
+ [HttpGet("oaemealvoucher")]
+ public async Task> GetOaEMealVoucherAsync([FromQuery] OaEMealVoucherRequest request)
+ {
+ return await _balanceService.GetOaEMealVoucherAsync(request);
+ }
+
+ ///
+ /// 电子餐券使用记录查询
+ ///
+ ///
+ ///
+ [HttpGet("oaemealvoucherdetail")]
+ public async Task> GetOaEMealVoucherDetailAsync([FromQuery] OaEMealVoucherDetailRequest request)
+ {
+ return await _balanceService.GetOaEMealVoucherDetailAsync(request);
+ }
+
}
diff --git a/Src/Dlhis.Canteen/Order/Request/OaEMealVoucherDetailRequest.cs b/Src/Dlhis.Canteen/Order/Request/OaEMealVoucherDetailRequest.cs
new file mode 100644
index 00000000..1a4d504b
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Request/OaEMealVoucherDetailRequest.cs
@@ -0,0 +1,12 @@
+using Kurisu.Core.DataAccess.Dto;
+
+namespace Dlhis.Canteen.Order.Request
+{
+ public class OaEMealVoucherDetailRequest : PageDto
+ {
+ ///
+ /// 餐券id
+ ///
+ public long OaEMealVoucherId { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Order/Request/OaEMealVoucherRequest.cs b/Src/Dlhis.Canteen/Order/Request/OaEMealVoucherRequest.cs
new file mode 100644
index 00000000..a77865a7
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Request/OaEMealVoucherRequest.cs
@@ -0,0 +1,14 @@
+using Dlhis.Entity.Canteen.Enums;
+using Kurisu.Core.DataAccess.Dto;
+using System.ComponentModel.DataAnnotations;
+
+namespace Dlhis.Canteen.Order.Request
+{
+ public class OaEMealVoucherRequest : PageDto
+ {
+ ///
+ /// 用户学工号
+ ///
+ public string UserCode { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Order/Response/OaEMealVoucherDetailResponse.cs b/Src/Dlhis.Canteen/Order/Response/OaEMealVoucherDetailResponse.cs
new file mode 100644
index 00000000..d57c1e7e
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Response/OaEMealVoucherDetailResponse.cs
@@ -0,0 +1,65 @@
+using SqlSugar;
+
+namespace Dlhis.Canteen.Order.Response
+{
+ public class OaEMealVoucherDetailResponse
+ {
+ public long Id { get; set; }
+
+ public long VoucherId { get; set; }
+
+ public int Sequence { get; set; }
+
+ public string DinnerType { get; set; }
+
+ ///
+ /// 身份证
+ ///
+ public string IdNo { get; set; }
+
+ ///
+ /// 用餐人
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 手机号
+ ///
+ public string Phone { get; set; }
+
+ ///
+ /// 就餐开始
+ ///
+ public DateTime Start { get; set; }
+
+ ///
+ /// 就餐结束
+ ///
+ public DateTime End { get; set; }
+
+ ///
+ /// 就餐天数
+ ///
+ public int Days { get; set; }
+
+ ///
+ /// 金额
+ ///
+ public decimal Amount { get; set; }
+
+ ///
+ /// 二维码
+ ///
+ public string QrCode { get; set; }
+
+ ///
+ /// 状态
+ ///
+ public string Status { get; set; }
+
+ ///
+ /// 信息
+ ///
+ public string Message { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Order/Response/OaEMealVoucherResponse.cs b/Src/Dlhis.Canteen/Order/Response/OaEMealVoucherResponse.cs
new file mode 100644
index 00000000..32ceaeb3
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Response/OaEMealVoucherResponse.cs
@@ -0,0 +1,100 @@
+using SqlSugar;
+
+namespace Dlhis.Canteen.Order.Response
+{
+ public class OaEMealVoucherResponse
+ {
+ public long Id { get; set; }
+
+ ///
+ /// 标题
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// 申请人工号
+ ///
+ public string UserCode { get; set; }
+
+ ///
+ /// 申请人名称
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 基地代码
+ ///
+ public string TenantId { get; set; }
+
+ ///
+ /// 基地名称
+ ///
+ public string TenantName { get; set; }
+
+ ///
+ /// 成本中心
+ ///
+ public string CostId { get; set; }
+
+ ///
+ /// 成本中心名称
+ ///
+ public string CostName { get; set; }
+
+ ///
+ /// 来宾公司
+ ///
+ public string Company { get; set; }
+
+ ///
+ /// 联系人
+ ///
+ public string Phone { get; set; }
+
+ ///
+ /// 来宾人数
+ ///
+ public int Num { get; set; }
+
+ ///
+ /// 就餐食堂
+ ///
+ public string Canteen { get; set; }
+
+ ///
+ /// 就餐事由
+ ///
+ public string Reason { get; set; }
+
+ ///
+ /// 就餐次
+ ///
+ public string CanteenShift { get; set; }
+
+ ///
+ /// oa流程id
+ ///
+ public string OaId { get; set; }
+
+ ///
+ /// 部门号
+ ///
+ public string DepartmentNo { get; set; }
+
+ ///
+ /// 部门名称
+ ///
+ public string DepartmentName { get; set; }
+
+
+ ///
+ /// 申请日期
+ ///
+ public DateTime LogDate { get; set; }
+
+ ///
+ /// 数据创建时间
+ ///
+ public DateTime CreateTime { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
index 8ba54785..1c02cd6f 100644
--- a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
@@ -30,4 +30,8 @@ public interface IBalanceService : IScopeDependency
Task> GetConsumptionTrendsAsync(ConsumptionTrendRequest request);
Task> GetSupplementTrendsAsync(ConsumptionTrendRequest request);
+
+ Task> GetOaEMealVoucherAsync([FromQuery] OaEMealVoucherRequest request);
+
+ Task> GetOaEMealVoucherDetailAsync([FromQuery] OaEMealVoucherDetailRequest request);
}
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index 08f58d1b..9a3f88b0 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -642,6 +642,25 @@ public class BalanceService : IBalanceService
return new List();
}
+ public async Task> GetOaEMealVoucherAsync(OaEMealVoucherRequest request)
+ {
+ var page = await _dbContext.Queryable()
+ .Where(x => x.UserCode == request.UserCode)
+ .Select()
+ .ToPageListAsync(request);
+ return page;
+ }
+
+ public async Task> GetOaEMealVoucherDetailAsync(OaEMealVoucherDetailRequest request)
+ {
+ var page = await _dbContext.Queryable()
+ .Where(x => x.VoucherId == request.OaEMealVoucherId)
+ .Select()
+ .ToPageListAsync(request);
+
+ return page;
+ }
+
///
/// 获取当前年所有月
///
From 2a21e6bd5b42268f841c685c1c1e65ba91ff4628 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 16:36:43 +0800
Subject: [PATCH 014/146] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E4=BB=BB?=
=?UTF-8?q?=E5=8A=A1=E7=94=9F=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs | 3 +--
.../TaskAssignment/Job/CreateGetAttendanceJob.cs | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs b/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs
index 4bf792b5..9cdb0089 100644
--- a/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs
+++ b/Src/Dlhis.ScheduledTask/SyncSapInfo/Job/SyncPersonJob.cs
@@ -123,10 +123,10 @@ public class SyncPersonJob
//CarNo
Remark = item.remark,
Werks = item.WERKS,
- Employed = item.isowner,
};
await _dbContext.InsertAsync(info);
}
+
private async Task UpdatePerson(GainfoSapEntity item)
{
var gainfo = await _dbContext.Queryable().Where(x => x.IdNo == item.idno).FirstAsync();
@@ -138,7 +138,6 @@ public class SyncPersonJob
Position = item.web,
Phone = item.phone,
DepartmentNo = item.appellation,
- Employed = item.isowner,
Remark = item.remark,
Degree = item.email,
Werks = item.WERKS
diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs
index 2e57474d..34c614ae 100644
--- a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs
+++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetAttendanceJob.cs
@@ -33,7 +33,7 @@ public class CreateGetAttendanceJob
var b = await _dbContext.Queryable()
.Where(x => ds.Contains(x.DeviceUniqueNo))
.Where(x => x.Type == DeviceTaskEnumType.UploadRecord)
- .Where(x => x.Status == DeviceTaskStatusEnumType.Process)
+ .Where(x => x.Status == DeviceTaskStatusEnumType.Process || x.Status == DeviceTaskStatusEnumType.Wait)
.AnyAsync();
if (b)
From 77d3207bb48d3c2ed9b6c823d2d2b8378283dcf8 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 16:37:35 +0800
Subject: [PATCH 015/146] =?UTF-8?q?fix=20=E8=8E=B7=E5=8F=96=E8=80=83?=
=?UTF-8?q?=E5=8B=A4=E4=BA=BA=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Summary/Response/AttendanceDetailSummary.cs | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs b/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs
index f4f9c24a..a013bb6a 100644
--- a/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs
+++ b/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs
@@ -1,9 +1,12 @@
-using Dlhis.Basic.Summary.Dto;
-
-namespace Dlhis.Basic.Summary.Response;
+namespace Dlhis.Basic.Summary.Response;
public class AttendanceDetailSummary
{
+ ///
+ /// 考勤总人数
+ ///
+ public int Total => Employed + Unemployed;
+
///
/// 在职人数
///
From e3710ad0a5ed73d97b2869e683f41353d714a175 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 16:37:52 +0800
Subject: [PATCH 016/146] =?UTF-8?q?feat=20=E6=89=B9=E9=87=8F=E4=B8=8A?=
=?UTF-8?q?=E4=BC=A0=E4=BA=BA=E8=84=B8=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/GainfosController.cs | 11 +++++
.../Organization/Services/IGainfoService.cs | 3 +-
.../Services/Implements/GainfoService.cs | 48 +++++++++++++++++++
3 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
index 39d3405f..e577baaa 100644
--- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
+++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
@@ -100,6 +100,17 @@ public class GainfosController : ControllerBase
await _gainfoService.UploadFaceAsync(request);
}
+ ///
+ /// 批量上传人脸照片
+ ///
+ ///
+ ///
+ [HttpPost("faces")]
+ public async Task UploadFaceAsync(List request)
+ {
+ await _gainfoService.UploadFacesAsync(request);
+ }
+
///
/// 通过token获取人脸照片,失效或者找不到返回HttpStatus404状态码
///
diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
index 7372f48d..768aa36b 100644
--- a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
@@ -1,6 +1,5 @@
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Response;
-using Dlhis.Entity.Basic.Entity;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Mvc;
@@ -22,6 +21,8 @@ public interface IGainfoService : IScopeDependency
Task UploadFaceAsync(GainfoUploadFaceRequest request);
+ Task UploadFacesAsync(List request);
+
Task GetFaceAsync(string token);
Task GetFaceByUserCodeAsync(string userCode);
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index f21150bd..bfc6e493 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -255,6 +255,54 @@ public class GainfoService : IGainfoService
});
}
+ public async Task UploadFacesAsync(List requests)
+ {
+ foreach (var request in requests)
+ {
+ var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.No == request.UserNo).FirstAsync();
+ gainfo ??= await _gainfoStore.Queryable(GainfoStatusEnumType.External).Where(x => x.No == request.UserNo).FirstAsync();
+
+ gainfo.ThrowIfNull("人员档案信息不存在");
+
+ await Scoped.Request.Value.CreateAsync(async (sp) =>
+ {
+ var configuration = sp.GetService();
+ var faceConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value;
+
+ var dbContext = sp.GetService();
+ //todo 切换连接字符串
+ dbContext.Client.CurrentConnectionConfig.ConnectionString = faceConnectionString;
+ var face = await dbContext.Queryable().Where(x => x.UserCode == gainfo.Code).SingleAsync();
+
+ var taskType = face == null ? DeviceTaskEnumType.Add : DeviceTaskEnumType.Update;
+ if (face == null)
+ {
+ face = new GainfoFaceEntity
+ {
+ UserCode = gainfo.Code,
+ Face = request.Face
+ };
+
+ await dbContext.InsertAsync(face);
+ }
+ else
+ {
+ if (face.Face == request.Face)
+ {
+ _logger.LogWarning("相同的人脸照片更新忽略");
+ return;
+ }
+
+ face.Face = request.Face;
+ await dbContext.UpdateAsync(face);
+ }
+
+ //生成任务
+ await _devicePermissionService.GenerateDeviceTasksAsync(gainfo.No, taskType);
+ });
+ }
+ }
+
public async Task GetFaceByUserCodeAsync(string userCode)
From 0296f670e9bc15c526ce5c2c6b62a39534c1afd6 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 16:46:07 +0800
Subject: [PATCH 017/146] =?UTF-8?q?fix=20=E6=81=A2=E5=A4=8Dredis=E8=BF=9E?=
=?UTF-8?q?=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.Basic/Program.cs | 4 ++--
Src/Dlhis.ScheduledTask/Program.cs | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Src/Dlhis.Basic/Program.cs b/Src/Dlhis.Basic/Program.cs
index 0ebc0761..966be9f0 100644
--- a/Src/Dlhis.Basic/Program.cs
+++ b/Src/Dlhis.Basic/Program.cs
@@ -24,9 +24,9 @@ public class Startup : DefaultStartup
base.ConfigureServices(services);
//todo
- /*var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
+ var redis = ConnectionMultiplexer.Connect($"192.168.199.30:30115,defaultDatabase:1,password=dlhis123");
services.AddDataProtection()
.SetApplicationName("basic")
- .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");*/
+ .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/Program.cs b/Src/Dlhis.ScheduledTask/Program.cs
index 1060cca9..aad2b382 100644
--- a/Src/Dlhis.ScheduledTask/Program.cs
+++ b/Src/Dlhis.ScheduledTask/Program.cs
@@ -26,11 +26,11 @@ public class Startup : DefaultStartup
services.AddSingleton(sp =>
{
- return ConnectionMultiplexer.Connect("10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
+ return ConnectionMultiplexer.Connect("192.168.199.30:30115,defaultDatabase:1,password=dlhis123");
});
//todo
- var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
+ var redis = ConnectionMultiplexer.Connect($"192.168.199.30:30115,defaultDatabase:1,password=dlhis123");
services.AddDataProtection()
.SetApplicationName("basic")
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
From 78b92ab2231b26cc7f8c50f7f95f65c638f98c82 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 17:10:09 +0800
Subject: [PATCH 018/146] =?UTF-8?q?fix=20=E9=85=8D=E7=BD=AEtenant=20api=20?=
=?UTF-8?q?=E5=9C=B0=E5=9D=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.ScheduledTask/appsettings.json | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Src/Dlhis.ScheduledTask/appsettings.json b/Src/Dlhis.ScheduledTask/appsettings.json
index 3ba4c3a5..28bddadf 100644
--- a/Src/Dlhis.ScheduledTask/appsettings.json
+++ b/Src/Dlhis.ScheduledTask/appsettings.json
@@ -5,6 +5,9 @@
"Microsoft.AspNetCore": "Warning"
}
},
+ "InternalRequest": {
+ "SysRequestUrl": "http://sys"
+ },
"SqlSugarOptions": {
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
"SlaveConnectionString": [],
From 4bd0c2403d78d3b5ba44d99b9683c5ca4b91079e Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 17:43:33 +0800
Subject: [PATCH 019/146] =?UTF-8?q?fix=20=E8=AE=BE=E5=A4=87=E7=BB=84?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA,=E4=BF=9D=E5=AD=98?=
=?UTF-8?q?=E6=8E=A7=E5=88=B6editable?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Response/DeviceGroupTreeResponse.cs | 26 ++++++++++++++++++-
.../Services/Implements/DeviceGroupService.cs | 6 +++--
.../Device/Entities/DeviceGroupEntity.cs | 7 +++++
.../CommonJobs/CreateDefinitelyGroupJob.cs | 8 +++++-
4 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs b/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs
index 6e9588ea..54d2c7fc 100644
--- a/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs
+++ b/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs
@@ -1,4 +1,7 @@
-namespace Dlhis.Basic.Device.Response;
+using Dlhis.Entity.Device.Enums;
+using Kurisu.AspNetCore.Utils.Extensions;
+
+namespace Dlhis.Basic.Device.Response;
public class DeviceGroupTreeResponse
{
@@ -17,6 +20,27 @@ public class DeviceGroupTreeResponse
///
public string Name { get; set; }
+ ///
+ /// 设备组类型
+ ///
+ public DeviceTypeEnumType? Type { get; set; }
+
+ ///
+ /// 分组类型描述
+ ///
+ public string TypeDesc
+ {
+ get
+ {
+ if (!Type.HasValue)
+ {
+ return string.Empty;
+ }
+
+ return Type.Value.GetDescription();
+ }
+ }
+
///
/// 下级
///
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
index 04722357..3047a115 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceGroupService.cs
@@ -56,8 +56,9 @@ public class DeviceGroupService : IDeviceGroupService
if (!request.Id.HasValue)
{
var entity = request.Adapt();
-
+ entity.Editable = true;
entity.Code = Guid.NewGuid();
+
await _dbContext.InsertAsync(entity);
}
else
@@ -65,6 +66,8 @@ public class DeviceGroupService : IDeviceGroupService
var entity = await _dbContext.Queryable().Where(x => x.Id == request.Id).FirstAsync();
entity.ThrowIfNull("设备组不存在,无法更新");
+ entity.Editable.ThrowIfFalse("不可编辑当前组");
+
var nextDevices = await GetDevicesAsync(entity.Code);
if (!entity.Type.HasValue)
{
@@ -75,7 +78,6 @@ public class DeviceGroupService : IDeviceGroupService
(request.Type.HasValue && request.Type != entity.Type && nextDevices.Any()).ThrowIfTrue("分组设备类型不匹配,无法修改类型");
}
-
await _dbContext.UpdateAsync(entity);
}
}
diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
index 6d037b6a..b3f44bb9 100644
--- a/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
+++ b/Src/Dlhis.Entity/Device/Entities/DeviceGroupEntity.cs
@@ -37,6 +37,13 @@ public class DeviceGroupEntity : SugarBaseEntity, ITenantId, ISoftDeleted
public string Name { get; set; }
+ ///
+ /// 是否可编辑
+ ///
+ [SugarColumn(ColumnDescription = "是否可编辑")]
+ public bool Editable { get; set; }
+
+
public string TenantId { get; set; }
diff --git a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
index 9390c884..7b8549a8 100644
--- a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
+++ b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
@@ -4,6 +4,7 @@ using Dlhis.Entity.Device.Enums;
using Dlhis.Sys.Api;
using Kurisu.Core.DataAccess.Entity;
using Kurisu.SqlSugar.Services;
+using Newtonsoft.Json;
namespace Dlhis.ScheduledTask.CommonJobs;
@@ -28,11 +29,12 @@ public class CreateDefinitelyGroupJob
var tenantResult = await _tenantApi.GetTenantsInternalAsync();
var tenants = tenantResult.Data;
+ _logger.LogInformation("获取基地信息:{json}", JsonConvert.SerializeObject(tenants));
+
foreach (var tenant in tenants)
{
if (!await _dbContext.Queryable().Where(x => x.TenantId == tenant.Code).AnyAsync(x => x.IsDefault))
{
-
var customGroup = new GainfoGroupEntity
{
PCode = null,
@@ -82,6 +84,7 @@ public class CreateDefinitelyGroupJob
Code = Guid.NewGuid(),
Type = DeviceTypeEnumType.Attendance,
Name = "*通用考勤设备组",
+ Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
@@ -99,6 +102,7 @@ public class CreateDefinitelyGroupJob
Code = Guid.NewGuid(),
Type = DeviceTypeEnumType.Attendance,
Name = "*专用考勤设备组",
+ Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
@@ -121,6 +125,7 @@ public class CreateDefinitelyGroupJob
Code = Guid.NewGuid(),
Type = DeviceTypeEnumType.Door,
Name = "*非公共区域",
+ Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
@@ -141,6 +146,7 @@ public class CreateDefinitelyGroupJob
Code = Guid.NewGuid(),
Type = DeviceTypeEnumType.Door,
Name = "*公共区域",
+ Editable = false,
CreatedBy = 1,
CreateTime = DateTime.Now,
From 0143b2aba1e8d6aa787f8643757fa5b5d91465c3 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 17:53:06 +0800
Subject: [PATCH 020/146] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E8=B0=83?=
=?UTF-8?q?=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs | 5 +++++
.../CommonJobs/CreateDefinitelyGroupJob.cs | 4 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs b/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs
index 8d81e4a4..941a4487 100644
--- a/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs
+++ b/Src/Dlhis.Basic/Device/Response/DeviceGroupPageResponse.cs
@@ -20,6 +20,11 @@ public class DeviceGroupPageResponse
///
public DeviceTypeEnumType? Type { get; set; }
+ ///
+ /// 是否可编辑
+ ///
+ public bool Editable { get; set; }
+
///
/// 分组类型描述
///
diff --git a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
index 7b8549a8..0bdda3ff 100644
--- a/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
+++ b/Src/Dlhis.ScheduledTask/CommonJobs/CreateDefinitelyGroupJob.cs
@@ -14,11 +14,13 @@ public class CreateDefinitelyGroupJob
private readonly ITenantApi _tenantApi;
private readonly IDbContext _dbContext;
- public CreateDefinitelyGroupJob(ILogger logger, ITenantApi tenantApi, IDbContext dbContext)
+ public CreateDefinitelyGroupJob(ILogger logger, ITenantApi tenantApi, IDbContext dbContext, ISqlSugarOptionsService sqlSugarOptionsService)
{
_logger = logger;
_tenantApi = tenantApi;
_dbContext = dbContext;
+
+ sqlSugarOptionsService.IgnoreTenant = true;
}
public async Task RunAsync()
From fd5dda33ab6c090eadc47d33b227541ff79b45cd Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 17:56:36 +0800
Subject: [PATCH 021/146] =?UTF-8?q?fix=20=E4=BF=AE=E6=94=B9apk=E5=AE=9E?=
=?UTF-8?q?=E4=BD=93=E7=9A=84name=E4=B8=BAstring?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.Basic/Program.cs | 4 ++--
Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs | 2 ++
Src/Dlhis.Common/Request/ApkRequest.cs | 2 +-
Src/Dlhis.Entity/Common/ApkFileEntity.cs | 2 +-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Src/Dlhis.Basic/Program.cs b/Src/Dlhis.Basic/Program.cs
index 0ebc0761..48192332 100644
--- a/Src/Dlhis.Basic/Program.cs
+++ b/Src/Dlhis.Basic/Program.cs
@@ -24,9 +24,9 @@ public class Startup : DefaultStartup
base.ConfigureServices(services);
//todo
- /*var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
+ var redis = ConnectionMultiplexer.Connect($"10.27.21.15:30050,defaultDatabase:1,password=dlhis123");
services.AddDataProtection()
.SetApplicationName("basic")
- .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");*/
+ .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
index f0cd8c8f..b3d1e7f0 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
@@ -59,6 +59,8 @@ public class OrderService : IOrderService
.AnyAsync();
canteenUserExists.ThrowIfFalse($"就餐用户{request.UserUniqueNo}不存在,无法操作");
+
+
//消费
if (request.Type == BalanceRecordTypeEnumType.Out)
{
diff --git a/Src/Dlhis.Common/Request/ApkRequest.cs b/Src/Dlhis.Common/Request/ApkRequest.cs
index 3665dafb..af368cce 100644
--- a/Src/Dlhis.Common/Request/ApkRequest.cs
+++ b/Src/Dlhis.Common/Request/ApkRequest.cs
@@ -15,7 +15,7 @@
///
/// 版本名称
///
- public int VersionName { get; set; }
+ public string VersionName { get; set; }
///
/// 修改信息
diff --git a/Src/Dlhis.Entity/Common/ApkFileEntity.cs b/Src/Dlhis.Entity/Common/ApkFileEntity.cs
index 7a6c7ce2..da72752e 100644
--- a/Src/Dlhis.Entity/Common/ApkFileEntity.cs
+++ b/Src/Dlhis.Entity/Common/ApkFileEntity.cs
@@ -36,7 +36,7 @@ public class ApkFileEntity : SugarBaseEntity
/// 版本名称
///
[SugarColumn(ColumnDescription = "版本名称")]
- public int VersionName { get; set; }
+ public string VersionName { get; set; }
///
/// 修改信息
From 4ee5703b65b8a4423d6f4f7982514897598602da Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 18:12:28 +0800
Subject: [PATCH 022/146] =?UTF-8?q?fix=20=E5=B0=B1=E9=A4=90=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Dlis.Jinko.Yikatong.sln | 7 ++++++
Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj | 13 ++++++++++
Src/Dlhis.Basic.Api/IDevicePermissionApi.cs | 11 ++++++++
.../DevicePermissionsController.cs | 13 ++++++++++
.../Response/DeviceGroupTreeResponse.cs | 3 +++
.../Services/IDevicePermissionService.cs | 8 ++++++
.../Implements/DevicePermissionService.cs | 15 +++++++++--
Src/Dlhis.Canteen/Dlhis.Canteen.csproj | 1 +
.../Order/Controllers/OrdersController.cs | 1 -
.../Order/Services/Implements/OrderService.cs | 18 +++++++++++--
.../appsettings.Development.json | 3 ++-
Src/Dlhis.Canteen/appsettings.json | 3 ++-
.../Basic/Entity/BusinessPlaceGroupEntity.cs | 25 +++++++++++++++++++
.../BusinessPlaceGroupRelationshipEntity.cs | 16 ++++++++++++
14 files changed, 130 insertions(+), 7 deletions(-)
create mode 100644 Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj
create mode 100644 Src/Dlhis.Basic.Api/IDevicePermissionApi.cs
create mode 100644 Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupEntity.cs
create mode 100644 Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupRelationshipEntity.cs
diff --git a/Dlis.Jinko.Yikatong.sln b/Dlis.Jinko.Yikatong.sln
index 254bd420..ff1fecaa 100644
--- a/Dlis.Jinko.Yikatong.sln
+++ b/Dlis.Jinko.Yikatong.sln
@@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Canteen", "Src\Dlhis.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Sys.Api", "Src\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj", "{85A345C7-913E-4C1B-BE1C-600DE408A02F}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Basic.Api", "Src\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj", "{1F337648-8A22-4601-A842-0F634FBA2825}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -71,6 +73,10 @@ Global
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85A345C7-913E-4C1B-BE1C-600DE408A02F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1F337648-8A22-4601-A842-0F634FBA2825}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1F337648-8A22-4601-A842-0F634FBA2825}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1F337648-8A22-4601-A842-0F634FBA2825}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1F337648-8A22-4601-A842-0F634FBA2825}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -84,6 +90,7 @@ Global
{925048C9-5940-4B51-8480-4DC908C754A1} = {57074FD8-1A2F-40C7-8476-001778A3F65D}
{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}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0}
diff --git a/Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj b/Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj
new file mode 100644
index 00000000..e41324f5
--- /dev/null
+++ b/Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Src/Dlhis.Basic.Api/IDevicePermissionApi.cs b/Src/Dlhis.Basic.Api/IDevicePermissionApi.cs
new file mode 100644
index 00000000..0792994e
--- /dev/null
+++ b/Src/Dlhis.Basic.Api/IDevicePermissionApi.cs
@@ -0,0 +1,11 @@
+using Kurisu.Core.Result;
+using Kurisu.RemoteCall.Attributes;
+
+namespace Dlhis.Basic.Api;
+
+[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
+public interface IDevicePermissionApi
+{
+ [Get("/api/devicepermissions/canteen/uniqueNos")]
+ Task>> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo);
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicePermissionsController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicePermissionsController.cs
index b0ecaf24..ad89e286 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DevicePermissionsController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DevicePermissionsController.cs
@@ -4,6 +4,7 @@ using Dlhis.Basic.Device.Services;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Org.BouncyCastle.Asn1.Ocsp;
namespace Dlhis.Basic.Device.Controllers;
@@ -51,4 +52,16 @@ public class DevicePermissionsController : ControllerBase
{
return await _devicePermissionService.GetAssigmentByCodeAsync(request);
}
+
+
+ ///
+ /// 就餐设备唯一号权限
+ ///
+ ///
+ ///
+ [HttpGet("canteen/uniqueNos")]
+ public async Task> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo)
+ {
+ return await _devicePermissionService.GetCanteenDeviceUniqueNosByUserNoAsync(userNo);
+ }
}
diff --git a/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs b/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs
index 54d2c7fc..9a1e26de 100644
--- a/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs
+++ b/Src/Dlhis.Basic/Device/Response/DeviceGroupTreeResponse.cs
@@ -5,6 +5,9 @@ namespace Dlhis.Basic.Device.Response;
public class DeviceGroupTreeResponse
{
+ public long Id { get; set; }
+
+
///
/// 上级分组code
///
diff --git a/Src/Dlhis.Basic/Device/Services/IDevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/IDevicePermissionService.cs
index 040d00ac..ef313da0 100644
--- a/Src/Dlhis.Basic/Device/Services/IDevicePermissionService.cs
+++ b/Src/Dlhis.Basic/Device/Services/IDevicePermissionService.cs
@@ -50,6 +50,14 @@ public interface IDevicePermissionService : IScopeDependency
///
Task> GetAssignDeviceCodesAsync(string userNo);
+
+ ///
+ /// 获取就餐权限唯一号
+ ///
+ ///
+ ///
+ Task> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo);
+
///
/// 获取用户权限设备
///
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs
index 1fbc6c88..e0c3d564 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DevicePermissionService.cs
@@ -198,6 +198,17 @@ public class DevicePermissionService : IDevicePermissionService
}
+ public async Task> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo)
+ {
+ var all = await GetAssignDeviceCodesAsync(userNo);
+
+ return await _dbContext.Queryable().Where(x => x.Type == DeviceTypeEnumType.Meal)
+ .Where(x => all.Contains(x.Code))
+ .Select(x => x.UniqueNo)
+ .ToListAsync();
+ }
+
+
///
/// 获取用户所有设备权限
///
@@ -340,7 +351,7 @@ public class DevicePermissionService : IDevicePermissionService
var devices = await _dbContext.Queryable().ToListAsync();
- if(ggs != null && ggs.Count > 0)
+ if (ggs != null && ggs.Count > 0)
{
foreach (var gid in ggs)
{
@@ -351,7 +362,7 @@ public class DevicePermissionService : IDevicePermissionService
gds.AddRange(ds);
}
}
-
+
var dds = gds.Distinct().ToList();
var lst = devices.Where(x => dds.Contains(x.Code))
.Select(x => new AssigmentByCodeResponse
diff --git a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
index 36fc7e42..36b6a9be 100644
--- a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
+++ b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
@@ -17,6 +17,7 @@
+
diff --git a/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs b/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs
index 3e8f30e5..86e9a5c6 100644
--- a/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs
+++ b/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs
@@ -43,5 +43,4 @@ public class OrdersController : ControllerBase
{
return await _orderService.AddAsync(request);
}
-
}
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
index b3d1e7f0..dedd2a4e 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
@@ -1,10 +1,12 @@
-using Dlhis.Canteen.Order.Request;
+using Dlhis.Basic.Api;
+using Dlhis.Canteen.Order.Request;
using Dlhis.Canteen.Order.Response;
using Dlhis.Canteen.Setting.Services;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities;
using Dlhis.Entity.Canteen.Enums;
using Dlhis.Entity.Device.Entities;
+using Dlhis.Entity.Sys.Entities;
using Kurisu.AspNetCore.UnifyResultAndValidation;
using Kurisu.AspNetCore.Utils;
using Kurisu.AspNetCore.Utils.Extensions;
@@ -22,14 +24,17 @@ public class OrderService : IOrderService
{
private readonly IDbContext _dbContext;
private readonly ICanteenSettingService _canteenSettingService;
+ private readonly IDevicePermissionApi _devicePermissionApi;
private readonly ILogger _logger;
public OrderService(IDbContext dbContext,
ICanteenSettingService canteenSettingService,
+ IDevicePermissionApi devicePermissionApi,
ILogger logger)
{
_dbContext = dbContext;
_canteenSettingService = canteenSettingService;
+ _devicePermissionApi = devicePermissionApi;
_logger = logger;
}
@@ -42,6 +47,14 @@ public class OrderService : IOrderService
return page;
}
+ private async Task CheckPAsync(string userNo, string deviceUniqueNo)
+ {
+ var uniqueNosResult = await _devicePermissionApi.GetCanteenDeviceUniqueNosByUserNoAsync(userNo);
+ var uniqueNos = uniqueNosResult.Data;
+
+ uniqueNos.Contains(deviceUniqueNo).ThrowIfFalse("无消费权限");
+ }
+
[IgnoreTenant]
public async Task AddAsync(OrderAddRequest request)
{
@@ -59,7 +72,8 @@ public class OrderService : IOrderService
.AnyAsync();
canteenUserExists.ThrowIfFalse($"就餐用户{request.UserUniqueNo}不存在,无法操作");
-
+ //消费权限控制
+ await CheckPAsync(gainfo.No, request.DeviceUniqueNo);
//消费
if (request.Type == BalanceRecordTypeEnumType.Out)
diff --git a/Src/Dlhis.Canteen/appsettings.Development.json b/Src/Dlhis.Canteen/appsettings.Development.json
index 20ab3f6d..69b2958a 100644
--- a/Src/Dlhis.Canteen/appsettings.Development.json
+++ b/Src/Dlhis.Canteen/appsettings.Development.json
@@ -6,7 +6,8 @@
}
},
"InternalRequest": {
- "CommonRequestUrl": "http://localhost:5001"
+ "CommonRequestUrl": "http://localhost:5001",
+ "BasicRequestUrl": "http://localhost:5002"
},
"SwaggerOptions": {
"Enable": true,
diff --git a/Src/Dlhis.Canteen/appsettings.json b/Src/Dlhis.Canteen/appsettings.json
index d322419a..7ea06e04 100644
--- a/Src/Dlhis.Canteen/appsettings.json
+++ b/Src/Dlhis.Canteen/appsettings.json
@@ -7,7 +7,8 @@
},
"AllowedHosts": "*",
"InternalRequest": {
- "CommonRequestUrl": "http://common"
+ "CommonRequestUrl": "http://common",
+ "BasicRequestUrl": "http://basic"
},
"SqlSugarOptions": {
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
diff --git a/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupEntity.cs b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupEntity.cs
new file mode 100644
index 00000000..fdb19b6c
--- /dev/null
+++ b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupEntity.cs
@@ -0,0 +1,25 @@
+using Kurisu.Core.DataAccess.Entity;
+using Kurisu.SqlSugar;
+using SqlSugar;
+
+namespace Dlhis.Entity.Basic.Entity;
+
+///
+/// 营业点分组
+///
+[SugarTable(TableName = "BusinessPlaceGroup", TableDescription = "营业点分组")]
+public class BusinessPlaceGroupEntity : SugarBaseEntity, ITenantId
+{
+ public Guid? PCode { get; set; }
+
+ public Guid Code { get; set; }
+
+ [SugarColumn(ColumnDescription = "名称")]
+ public string Name { get; set; }
+
+
+ [SugarColumn(ColumnDescription = "备注")]
+ public string Remark { get; set; }
+
+ public string TenantId { get; set; }
+}
diff --git a/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupRelationshipEntity.cs b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupRelationshipEntity.cs
new file mode 100644
index 00000000..49a36419
--- /dev/null
+++ b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceGroupRelationshipEntity.cs
@@ -0,0 +1,16 @@
+using Kurisu.Core.DataAccess.Entity;
+using Kurisu.SqlSugar;
+using SqlSugar;
+
+namespace Dlhis.Entity.Basic.Entity;
+
+
+[SugarTable(TableName = "BusinessPlaceGroupRelationship", TableDescription = "营业点分组")]
+public class BusinessPlaceGroupRelationshipEntity : SugarBaseEntity, ITenantId
+{
+ public Guid BusinessPlaceGroupCode { get; set; }
+
+ public Guid BusinessPlaceCode { get; set; }
+
+ public string TenantId { get; set; }
+}
From 83704bb0171ef921a394362f81ad08ecd17ada09 Mon Sep 17 00:00:00 2001
From: liguoyang
Date: Thu, 22 Feb 2024 18:13:49 +0800
Subject: [PATCH 023/146] fix dockerfile
---
Src/Dlhis.Canteen/Dlhis.Canteen.csproj | 1 +
Src/Dlhis.Canteen/Dockerfile | 1 +
2 files changed, 2 insertions(+)
diff --git a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
index 36b6a9be..9e21386c 100644
--- a/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
+++ b/Src/Dlhis.Canteen/Dlhis.Canteen.csproj
@@ -37,6 +37,7 @@
+
diff --git a/Src/Dlhis.Canteen/Dockerfile b/Src/Dlhis.Canteen/Dockerfile
index b148099c..5e510329 100644
--- a/Src/Dlhis.Canteen/Dockerfile
+++ b/Src/Dlhis.Canteen/Dockerfile
@@ -7,6 +7,7 @@ EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Src/Dlhis.Canteen/Dlhis.Canteen.csproj", "Src/Dlhis.Canteen/"]
+COPY ["Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj", "Src/Dlhis.Basic.Api/"]
COPY ["Src/Dlhis.Common.Api/Dlhis.Common.Api.csproj", "Src/Dlhis.Common.Api/"]
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
RUN dotnet restore "Src/Dlhis.Canteen/Dlhis.Canteen.csproj"
From cd5f7e115a097d19b783037f15f46c2010561ab0 Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 18:16:44 +0800
Subject: [PATCH 024/146] =?UTF-8?q?fix=20=E4=BF=AE=E6=94=B9vername?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FileOperation/Services/Implements/ApkFIileService.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
index 28726ace..8978cfb6 100644
--- a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
@@ -44,6 +44,7 @@ public class ApkFIileService : IApkFIileService
Url = fileUrl,
VersionCode = request.VersionCode,
UpdateMessage = request.UpdateMessage,
+ VersionName = request.VersionName,
};
await _dbContext.InsertAsync(info);
}
From f3b17dc6b82409dbe9b14ed0f156a41e2a02ed6e Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 18:25:19 +0800
Subject: [PATCH 025/146] =?UTF-8?q?fix=20=E5=88=A0=E9=99=A4url=E5=88=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/ApkFileController.cs | 31 -----
.../Services/IApkFIileService.cs | 14 ---
.../Services/Implements/ApkFIileService.cs | 110 ------------------
Src/Dlhis.Entity/Common/ApkFileEntity.cs | 6 -
4 files changed, 161 deletions(-)
diff --git a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
index 7646dd3e..b2c442aa 100644
--- a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
+++ b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
@@ -46,40 +46,9 @@ public class ApkFileController : ControllerBase
}
- ///
- /// 本地文件上传
- ///
- ///
- ///
- [HttpPost("local")]
- [RequestSizeLimit(100_000_0000)]
- public async Task FormLocalFileUpload([FromForm] ApkRequest request)
- {
- return await _apkFIileService.FormLocalFileUpload(request);
- }
- ///
- /// 查看最新版本
- ///
- ///
- ///
- [HttpGet("lastfile")]
- public async Task LatestFile(string fileName)
- {
- return await _apkFIileService.LatestFile(fileName);
- }
- ///
- /// 本地文件下载
- ///
- ///
- ///
- [HttpGet("local")]
- public IActionResult FormLocalDownloadFile(string fileName)
- {
- return _apkFIileService.FormLocalDownloadFile(fileName);
- }
}
diff --git a/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
index f9f29d73..ff5a079b 100644
--- a/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
@@ -21,21 +21,7 @@ public interface IApkFIileService : IScopeDependency
///
Task RequestDownloadFile(string fileName);
- ///
- /// 本地上传
- ///
- ///
- ///
- Task FormLocalFileUpload(ApkRequest request);
- Task LatestFile(string fileName);
-
- ///
- /// 本地下载
- ///
- ///
- ///
- IActionResult FormLocalDownloadFile(string fileName);
}
diff --git a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
index 8978cfb6..ffe86e6b 100644
--- a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
@@ -41,7 +41,6 @@ public class ApkFIileService : IApkFIileService
var info = new ApkFileEntity
{
Name = fileName,
- Url = fileUrl,
VersionCode = request.VersionCode,
UpdateMessage = request.UpdateMessage,
VersionName = request.VersionName,
@@ -50,7 +49,6 @@ public class ApkFIileService : IApkFIileService
}
else
{
- entity.Url = fileUrl;
entity.VersionCode = request.VersionCode;
entity.UpdateMessage = request.UpdateMessage;
await _dbContext.UpdateAsync(entity);
@@ -69,116 +67,8 @@ public class ApkFIileService : IApkFIileService
return await _minioService.MinloDownloadLinkAsync(fileName);
}
- ///
- /// 本地文件上传
- ///
- ///
- ///
- public async Task FormLocalFileUpload(ApkRequest request)
- {
- //上传
- var completeFilePath = FormSingleFileUpload(request.formFile);
- if (completeFilePath == "No file uploaded" || completeFilePath.IsEmpty())
- {
- return null;
- }
- //更新数据库
- var fileName = request.formFile.FileName;
- var entity = await _dbContext.Queryable().Where(x => x.Name == fileName).FirstAsync();
- if (entity == null)
- {
- var info = new ApkFileEntity
- {
- Name = fileName,
- Url = completeFilePath,
- VersionCode = request.VersionCode,
- VersionName = request.VersionName,
- UpdateMessage = request.UpdateMessage,
- };
- await _dbContext.InsertAsync(info);
- }
- else
- {
- entity.Url = completeFilePath;
- entity.VersionCode = request.VersionCode;
- entity.UpdateMessage = request.UpdateMessage;
- entity.VersionName = request.VersionName;
- await _dbContext.UpdateAsync(entity);
- }
- var newEntity = await _dbContext.Queryable().Where(x => x.Name == fileName).FirstAsync();
- var res = newEntity.Adapt();
- return res;
-
- }
- public string FormSingleFileUpload(IFormFile formFile)
- {
- try
- {
- var filePath = "C:\\apk\\";
-
- // 创建存储文件夹
- if (!Directory.Exists(filePath))
- {
- Directory.CreateDirectory(filePath);
- }
-
- if (formFile != null && formFile.Length > 0)
- {
- // 保存的文件名称
- var saveName = Path.GetFileName(formFile.FileName);
-
- // 文件保存
- using (var fs = File.Create(Path.Combine(filePath, saveName)))
- {
- formFile.CopyTo(fs);
- fs.Flush();
- }
-
- // 完整的文件路径
- var completeFilePath = Path.Combine(filePath, saveName);
- return completeFilePath;
- }
- else
- {
- return "No file uploaded";
- }
- }
- catch (Exception)
- {
- return null;
- throw;
- }
- }
-
- ///
- /// 返回最新版本信息
- ///
- ///
- ///
- public async Task LatestFile(string fileName)
- {
- var info = await _dbContext.Queryable()
- .Where(x => x.Name == fileName)
- .OrderByDescending(x => x.VersionCode)
- .FirstAsync();
- info.ThrowIfNull($"没有{fileName}信息");
- var res = info.Adapt();
- return res;
- }
- ///
- /// 本地下载
- ///
- ///
- ///
- public IActionResult FormLocalDownloadFile(string fileName)
- {
-
- var Path = "C:\\apk\\";
- var filePath = Path + fileName;
- return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName };
- }
}
diff --git a/Src/Dlhis.Entity/Common/ApkFileEntity.cs b/Src/Dlhis.Entity/Common/ApkFileEntity.cs
index da72752e..cf1735ec 100644
--- a/Src/Dlhis.Entity/Common/ApkFileEntity.cs
+++ b/Src/Dlhis.Entity/Common/ApkFileEntity.cs
@@ -20,12 +20,6 @@ public class ApkFileEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "文件名称")]
public string Name { get; set; }
- ///
- /// 地址
- ///
- [SugarColumn(ColumnDescription = "地址")]
- public string Url { get; set; }
-
///
/// 版本号
///
From bbe5939887e29eb8d4f3a378b8b2c523492dd66d Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 18:30:58 +0800
Subject: [PATCH 026/146] fix xiugai
---
Src/Dlhis.Common/Services/Implements/ApkFIileService.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs b/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs
index bdd03d8f..03848263 100644
--- a/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs
+++ b/Src/Dlhis.Common/Services/Implements/ApkFIileService.cs
@@ -39,7 +39,7 @@ public class ApkFIileService : IApkFIileService
var info = new ApkFileEntity
{
Name = fileName,
- Url = fileUrl,
+ //Url = fileUrl,
VersionCode = request.VersionCode,
UpdateMessage = request.UpdateMessage,
};
@@ -47,7 +47,7 @@ public class ApkFIileService : IApkFIileService
}
else
{
- entity.Url = fileUrl;
+ //entity.Url = fileUrl;
entity.VersionCode = request.VersionCode;
entity.UpdateMessage = request.UpdateMessage;
await _dbContext.UpdateAsync(entity);
@@ -87,7 +87,7 @@ public class ApkFIileService : IApkFIileService
var info = new ApkFileEntity
{
Name = fileName,
- Url = completeFilePath,
+ //Url = completeFilePath,
VersionCode = request.VersionCode,
VersionName = request.VersionName,
UpdateMessage = request.UpdateMessage,
@@ -96,7 +96,7 @@ public class ApkFIileService : IApkFIileService
}
else
{
- entity.Url = completeFilePath;
+ //entity.Url = completeFilePath;
entity.VersionCode = request.VersionCode;
entity.VersionName = request.VersionName;
entity.UpdateMessage = request.UpdateMessage;
From 9f83188819f6c2ffe25f891a8b4ff2b766866b4e Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Thu, 22 Feb 2024 19:15:47 +0800
Subject: [PATCH 027/146] =?UTF-8?q?fix=20=E4=BF=AE=E6=94=B9apk=E5=A4=A7?=
=?UTF-8?q?=E5=B0=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Order/Services/Implements/OrderService.cs | 32 +++++++++++++++----
.../Controllers/ApkFileController.cs | 2 ++
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
index dedd2a4e..baa80576 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
@@ -58,13 +58,33 @@ public class OrderService : IOrderService
[IgnoreTenant]
public async Task AddAsync(OrderAddRequest request)
{
- //尝试匹配userId
- _ = long.TryParse(request.UserUniqueNo, out var userId);
-
- //根据档案号
+ var card = string.Empty;
+ long userId = 0;
+ if (request.Source == BalanceRecordSourceEnumType.Card)
+ {
+ card = request.UserUniqueNo;
+ }
+ else
+ {
+ _ = long.TryParse(request.UserUniqueNo, out userId);
+ }
var gainfo = await _dbContext.Queryable()
- .Where(x => x.No == request.UserUniqueNo || x.Code == request.UserUniqueNo || x.Id == userId)
- .FirstAsync();
+ .Where(x => x.No == request.UserUniqueNo || x.Code == request.UserUniqueNo || x.Id == userId|| x.CardNo == card)
+ .FirstAsync();
+
+
+ // ....
+ {
+ ////尝试匹配userId
+ //_ = long.TryParse(request.UserUniqueNo, out var userId);
+
+ ////根据档案号
+ //var gainfo = await _dbContext.Queryable()
+ // .Where(x => x.No == request.UserUniqueNo || x.Code == request.UserUniqueNo || x.Id == userId)
+ // .FirstAsync();
+ }
+
+
gainfo.ThrowIfNull($"用户{request.UserUniqueNo}不存在,无法操作");
var canteenUserExists = await _dbContext.Queryable()
diff --git a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
index b2c442aa..06d16288 100644
--- a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
+++ b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
@@ -29,6 +29,8 @@ public class ApkFileController : ControllerBase
///
///
[HttpPost("minlo")]
+ [DisableRequestSizeLimit]
+ [RequestSizeLimit(300000000)]
public async Task FormSingleFileUpload([FromForm] ApkRequest request)
{
return await _apkFIileService.FormSingleFileUpload(request);
From 89f2f7b9918cac3cfec927654b843c1091ffd1b2 Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Fri, 23 Feb 2024 09:29:10 +0800
Subject: [PATCH 028/146] =?UTF-8?q?fix=20=E4=BF=AE=E6=94=B9=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FileOperation/Controllers/ApkFileController.cs | 14 +++++++++++---
.../FileOperation/Response/ApkFileResponse.cs | 2 +-
.../FileOperation/Services/IApkFIileService.cs | 3 +++
.../Services/Implements/ApkFIileService.cs | 10 ++++++++++
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
index 06d16288..accb0bba 100644
--- a/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
+++ b/Src/Dlhis.Common/FileOperation/Controllers/ApkFileController.cs
@@ -29,8 +29,7 @@ public class ApkFileController : ControllerBase
///
///
[HttpPost("minlo")]
- [DisableRequestSizeLimit]
- [RequestSizeLimit(300000000)]
+ [RequestSizeLimit(300_000_000)]
public async Task FormSingleFileUpload([FromForm] ApkRequest request)
{
return await _apkFIileService.FormSingleFileUpload(request);
@@ -47,7 +46,16 @@ public class ApkFileController : ControllerBase
return await _apkFIileService.RequestDownloadFile(fileName);
}
-
+ ///
+ /// 获取最新版本
+ ///
+ ///
+ ///
+ [HttpGet("lastverison")]
+ public async Task GetLastVersionAsync(string fileName)
+ {
+ return await _apkFIileService.GetLastVersionAsync(fileName);
+ }
diff --git a/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs b/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs
index 886ca16a..7198cf6b 100644
--- a/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs
+++ b/Src/Dlhis.Common/FileOperation/Response/ApkFileResponse.cs
@@ -17,7 +17,7 @@ namespace Dlhis.Common.FileOperation.Response
///
/// 版本名称
///
- public int VersionName { get; set; }
+ public string VersionName { get; set; }
///
/// 修改信息
diff --git a/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
index ff5a079b..0f8afb8a 100644
--- a/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/IApkFIileService.cs
@@ -22,6 +22,9 @@ public interface IApkFIileService : IScopeDependency
Task RequestDownloadFile(string fileName);
+ Task GetLastVersionAsync(string fileName);
+
+
}
diff --git a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
index ffe86e6b..202dd65f 100644
--- a/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
+++ b/Src/Dlhis.Common/FileOperation/Services/Implements/ApkFIileService.cs
@@ -51,6 +51,7 @@ public class ApkFIileService : IApkFIileService
{
entity.VersionCode = request.VersionCode;
entity.UpdateMessage = request.UpdateMessage;
+ entity.VersionName = request.VersionName;
await _dbContext.UpdateAsync(entity);
}
var newEntity = await _dbContext.Queryable().Where(x => x.Name == fileName).FirstAsync();
@@ -58,6 +59,15 @@ public class ApkFIileService : IApkFIileService
return res;
}
+ public async Task GetLastVersionAsync(string fileName)
+ {
+ var info = await _dbContext.Queryable()
+ .Where(x => x.Name == fileName)
+ .Select()
+ .FirstAsync();
+ return info;
+ }
+
///
/// 文件下载
///
From e7a4075b7811fb4ded3f2b8058331fa54c903624 Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Fri, 23 Feb 2024 10:09:22 +0800
Subject: [PATCH 029/146] =?UTF-8?q?fix=20=E6=B7=BB=E5=8A=A0=E8=B0=83?=
=?UTF-8?q?=E7=94=A8api=E6=9D=83=E9=99=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Src/Dlhis.Basic.Api/IDevicePermissionApi.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/Dlhis.Basic.Api/IDevicePermissionApi.cs b/Src/Dlhis.Basic.Api/IDevicePermissionApi.cs
index 0792994e..feeb452e 100644
--- a/Src/Dlhis.Basic.Api/IDevicePermissionApi.cs
+++ b/Src/Dlhis.Basic.Api/IDevicePermissionApi.cs
@@ -6,6 +6,7 @@ namespace Dlhis.Basic.Api;
[EnableRemoteClient(Name = "basic-service", BaseUrl = "${InternalRequest:BasicRequestUrl}")]
public interface IDevicePermissionApi
{
+ [Auth]
[Get("/api/devicepermissions/canteen/uniqueNos")]
Task>> GetCanteenDeviceUniqueNosByUserNoAsync(string userNo);
}
\ No newline at end of file
From cbb26575ac4a66dfcd9344b64a8695486ff699f6 Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Fri, 23 Feb 2024 11:06:54 +0800
Subject: [PATCH 030/146] =?UTF-8?q?fix=20=E5=90=88=E5=B9=B6=E9=A4=90?=
=?UTF-8?q?=E9=A5=AE=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Order/Controllers/BalancesController.cs | 20 ++-----------------
.../Order/Response/ConsumeNumberResponse.cs | 10 ++++++++++
.../Order/Services/IBalanceService.cs | 3 +--
.../Services/Implements/BalanceService.cs | 18 +++++++++--------
4 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
index 8c306db1..3015ff75 100644
--- a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
+++ b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs
@@ -143,25 +143,9 @@ public class BalancesController : ControllerBase
return await _balanceService.GetConsumeNumberAsync();
}
- ///
- /// 消费走势
- ///
- ///
- [HttpGet("consumptiontrends")]
- public async Task> GetConsumptionTrendsAsync([FromQuery] ConsumptionTrendRequest request)
- {
- return await _balanceService.GetConsumptionTrendsAsync(request);
- }
- ///
- /// 餐补走势
- ///
- ///
- [HttpGet("supplementtrend")]
- public async Task> GetSupplementTrendsAsync([FromQuery] ConsumptionTrendRequest request)
- {
- return await _balanceService.GetSupplementTrendsAsync(request);
- }
+
+
///
/// 电子餐券申请记录查询
diff --git a/Src/Dlhis.Canteen/Order/Response/ConsumeNumberResponse.cs b/Src/Dlhis.Canteen/Order/Response/ConsumeNumberResponse.cs
index 609b1a68..130bd99b 100644
--- a/Src/Dlhis.Canteen/Order/Response/ConsumeNumberResponse.cs
+++ b/Src/Dlhis.Canteen/Order/Response/ConsumeNumberResponse.cs
@@ -26,5 +26,15 @@
/// 人均日消费额
///
public int DailyNumber { get; set; }
+
+ ///
+ /// 日消费额走势图
+ ///
+ public List Days { get; set; }
+
+ ///
+ /// 月消费额走势图
+ ///
+ public List Months { get; set; }
}
}
diff --git a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
index 1c02cd6f..f90026d8 100644
--- a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs
@@ -27,9 +27,8 @@ public interface IBalanceService : IScopeDependency
Task GetConsumeNumberAsync();
- Task> GetConsumptionTrendsAsync(ConsumptionTrendRequest request);
- Task> GetSupplementTrendsAsync(ConsumptionTrendRequest request);
+
Task> GetOaEMealVoucherAsync([FromQuery] OaEMealVoucherRequest request);
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index 9a3f88b0..063353ca 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -575,18 +575,25 @@ public class BalanceService : IBalanceService
var monthlySpending = monthbs.Sum(x => x.Amount);
//当日消费人数
var monthlyCount = monthbs.Select(x => x.UserCode).Distinct().Count();
+
+ //消费走势
+ var months = await GetConsumptionTrendsAsync(ConsumptionTrendEnumType.Month);
+ var days = await GetConsumptionTrendsAsync(ConsumptionTrendEnumType.Day);
+
var res = new ConsumeNumberResponse
{
Total = devices.Count(),
OffNumber = offCount,
PlaceNumber = places.Count(),
ConsumerableNumber = consumerable,
- DailyNumber = monthlyCount != 0 ? (int)Math.Ceiling(monthlySpending / monthlyCount) : 0
+ DailyNumber = monthlyCount != 0 ? Math.Abs((int)Math.Ceiling(monthlySpending / monthlyCount)) : 0,
+ Days = days,
+ Months = months
};
return res;
}
- public async Task> GetConsumptionTrendsAsync(ConsumptionTrendRequest request)
+ private async Task> GetConsumptionTrendsAsync(ConsumptionTrendEnumType type)
{
var bs = await _dbContext.Queryable()
.Where(x => x.Type == BalanceRecordTypeEnumType.Out)
@@ -595,7 +602,7 @@ public class BalanceService : IBalanceService
var totalAmount = Math.Round(Math.Abs(bs.Sum(x => x.Amount)), 2);
var list = new List();
- if (request.Type == ConsumptionTrendEnumType.Month)
+ if (type == ConsumptionTrendEnumType.Month)
{
//月与总额对比
var months = GetMonthsOfYear();
@@ -636,11 +643,6 @@ public class BalanceService : IBalanceService
return list;
}
- public async Task