From 01bc68180795370838b4addd95c4f67f9e799cd0 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 26 Jun 2024 18:23:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=95=B0=E6=8D=AEwhere=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/SysDataService.cs | 17 +++- .../Entities/LocalDeviceEntity.cs | 88 ++++++++++++++++++- Src/Dlhis.Middle/Program.cs | 18 ++-- .../Implements/DataDownloadService.cs | 7 +- 4 files changed, 115 insertions(+), 15 deletions(-) diff --git a/Src/Dlhis.Common/SysData/Services/Implements/SysDataService.cs b/Src/Dlhis.Common/SysData/Services/Implements/SysDataService.cs index 4e2de1f3..a8764994 100644 --- a/Src/Dlhis.Common/SysData/Services/Implements/SysDataService.cs +++ b/Src/Dlhis.Common/SysData/Services/Implements/SysDataService.cs @@ -1,4 +1,5 @@ using System.Reflection; +using Dlhis.Entity.Basic.Entity; using Kurisu.AspNetCore; using Kurisu.AspNetCore.DataAccess.Entity; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; @@ -27,9 +28,21 @@ public class SysDataService : ISysDataService var sql = $"select * from {table}"; if (type.IsAssignableTo(typeof(ITenantId))) { - sql += $" where tenantId = '{tableName}'"; + sql += $" where tenantId = '{factory}'"; } - return await _dbContext.Client.SqlQueryable(sql).ToListAsync(); + switch (tableName) + { + case "Gainfo": + //sql = $"select * from Gainfo where factory = '{factory}'"; + return await _dbContext.Queryable().Where(x => x.Factory == factory).Select(x => (object)x).ToListAsync(); + case "GainfoMeal": + { + var codes = await _dbContext.Queryable().Where(x => x.Factory == factory).Select(x => x.Code).ToListAsync(); + return await _dbContext.Queryable().Where(x => codes.Contains(x.UserCode)).Select(x => (object)x).ToListAsync(); + } + default: + return await _dbContext.Client.SqlQueryable(sql).ToListAsync(); + } } } \ No newline at end of file diff --git a/Src/Dlhis.Middle/Entities/LocalDeviceEntity.cs b/Src/Dlhis.Middle/Entities/LocalDeviceEntity.cs index e019ecac..e3a9f833 100644 --- a/Src/Dlhis.Middle/Entities/LocalDeviceEntity.cs +++ b/Src/Dlhis.Middle/Entities/LocalDeviceEntity.cs @@ -1,9 +1,91 @@ -using Dlhis.Entity.Basic.Entity; +using Dlhis.Entity.Device.Enums; +using Kurisu.AspNetCore.DataAccess.Entity; +using Kurisu.AspNetCore.DataAccess.SqlSugar; +using Mapster; +using SqlSugar; +using SqlSugar.DbConvert; namespace Dlhis.Middle.Entities { - public class LocalDeviceEntity : DeviceEntity + [SugarTable(TableName = "Device")] + public class LocalDeviceEntity : SugarBaseEntity , ITenantId { - public new int Id { get; set; } + public new int Id { get; set; } + + /// + /// 设备code + /// + [SugarColumn(ColumnDescription = "设备code")] + public Guid Code { get; set; } + + /// + /// 设备唯一码,IP/MAC/SNO + /// + [AdaptIgnore(MemberSide.Destination)] + [SugarColumn(ColumnDescription = "设备唯一码", IsNullable = false, UniqueGroupNameList = new[] { "Idx_Device_UniqueNo" })] + public string UniqueNo { get; set; } + + /// + /// 心跳间隔 + /// + [SugarColumn(ColumnDescription = "心跳检查间隔")] + public int HeartbeatInterval { get; set; } + + /// + /// 供应商 + /// + [SugarColumn(ColumnDescription = "供应商")] + public string Supplier { get; set; } + + /// + /// 设备类型 + /// + [SugarColumn(ColumnDescription = "设备类型", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public DeviceTypeEnumType Type { get; set; } + + /// + /// 部署点 + /// + [SugarColumn(ColumnDescription = "部署点")] + public string DeployPlace { get; set; } + + /// + /// 部署坐标 + /// + [SugarColumn(ColumnDescription = "部署坐标")] + public string DeployPosition { get; set; } + + /// + /// 部署方向 + /// + [SugarColumn(ColumnDescription = "部署方向", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] + public DeviceDeployDirectionEnumType? DeployDirection { get; set; } + + /// + /// 模板code + /// + [SugarColumn(ColumnDescription = "模板code")] + public Guid? TemplateCode { get; set; } + + /// + /// 连接信息 + /// + [SugarColumn(ColumnDescription = "连接信息")] + public string ConnectionInfo { get; set; } + + /// + /// 是否启用 + /// + [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.Middle/Program.cs b/Src/Dlhis.Middle/Program.cs index 0fe8d793..9adeef49 100644 --- a/Src/Dlhis.Middle/Program.cs +++ b/Src/Dlhis.Middle/Program.cs @@ -51,14 +51,14 @@ public class Startup : DefaultStartup var ds = scope.ServiceProvider.GetService(); ds.TruncateAsync().Wait(); ds.DownloadAsync(factory).Wait(); - // ds.DownloadAsync(factory).Wait(); - // ds.DownloadAsync(factory).Wait(); - // ds.DownloadAsync(factory).Wait(); - // ds.DownloadAsync(factory).Wait(); - // ds.DownloadAsync(factory).Wait(); - // ds.DownloadAsync(factory).Wait(); - // - // ds.DownloadAsync(factory).Wait(); - // ds.DownloadAsync(factory).Wait(); + ds.DownloadAsync(factory).Wait(); + ds.DownloadAsync(factory).Wait(); + ds.DownloadAsync(factory).Wait(); + ds.DownloadAsync(factory).Wait(); + ds.DownloadAsync(factory).Wait(); + ds.DownloadAsync(factory).Wait(); + + ds.DownloadAsync(factory).Wait(); + ds.DownloadAsync(factory).Wait(); } } \ No newline at end of file diff --git a/Src/Dlhis.Middle/Services/Implements/DataDownloadService.cs b/Src/Dlhis.Middle/Services/Implements/DataDownloadService.cs index 8450d253..a492d71f 100644 --- a/Src/Dlhis.Middle/Services/Implements/DataDownloadService.cs +++ b/Src/Dlhis.Middle/Services/Implements/DataDownloadService.cs @@ -35,7 +35,12 @@ public class DataDownloadService : IDataDownloadService var httpClient = _httpClientFactory.CreateClient("face"); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - var requestUrl = QueryHelpers.AddQueryString($"https://{_hostName}/api/common/SysData/download", new Dictionary + var url = $"https://{_hostName}/api/common/SysData/download"; +#if DEBUG + url = $"http://localhost:5001/api/SysData/download"; +#endif + + var requestUrl = QueryHelpers.AddQueryString(url, new Dictionary { ["factory"] = factory, ["tableName"] = typeof(T).GetCustomAttribute()!.TableName