diff --git a/Src/Dlhis.Basic/Organization/Controllers/OldGainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/OldGainfosController.cs
new file mode 100644
index 00000000..a6a99c02
--- /dev/null
+++ b/Src/Dlhis.Basic/Organization/Controllers/OldGainfosController.cs
@@ -0,0 +1,32 @@
+using Dlhis.Basic.Organization.Request;
+using Dlhis.Basic.Organization.Services;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Dlhis.Basic.Organization.Controllers;
+
+///
+/// 老系统档案表
+///
+[Authorize]
+[Route("api/[controller]")]
+[ApiController]
+public class OldDeviceGainfosController : ControllerBase
+{
+ private readonly IOldDeviceGainfoService _oldGainfoService;
+
+ public OldDeviceGainfosController(IOldDeviceGainfoService oldGainfoService)
+ {
+ _oldGainfoService = oldGainfoService;
+ }
+
+ ///
+ /// 上传
+ ///
+ ///
+ [HttpPost("upload")]
+ public async Task BatchUploadAsync(List requests)
+ {
+ await _oldGainfoService.BatchUploadAsync(requests);
+ }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Request/OldGainfoUploadRequest.cs b/Src/Dlhis.Basic/Organization/Request/OldGainfoUploadRequest.cs
new file mode 100644
index 00000000..55a92e0d
--- /dev/null
+++ b/Src/Dlhis.Basic/Organization/Request/OldGainfoUploadRequest.cs
@@ -0,0 +1,24 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Dlhis.Basic.Organization.Request;
+
+public class OldDeviceGainfoUploadRequest
+{
+ [Required]
+ public string Factory { get; set; }
+
+ [Required]
+ public string UniqueNo { get; set; }
+
+ ///
+ /// 档案号
+ ///
+ [Required]
+ public string No { get; set; }
+
+ ///
+ /// 工号
+ ///
+ [Required]
+ public string Code { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Services/IOldGainfoService.cs b/Src/Dlhis.Basic/Organization/Services/IOldGainfoService.cs
new file mode 100644
index 00000000..f2dd7c2b
--- /dev/null
+++ b/Src/Dlhis.Basic/Organization/Services/IOldGainfoService.cs
@@ -0,0 +1,8 @@
+using Dlhis.Basic.Organization.Request;
+
+namespace Dlhis.Basic.Organization.Services;
+
+public interface IOldDeviceGainfoService : IScopeDependency
+{
+ Task BatchUploadAsync(List requests);
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/OldGainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/OldGainfoService.cs
new file mode 100644
index 00000000..c05640bd
--- /dev/null
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/OldGainfoService.cs
@@ -0,0 +1,30 @@
+using Dlhis.Basic.Organization.Request;
+using Dlhis.Entity.Basic.Entity;
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
+using Mapster;
+
+namespace Dlhis.Basic.Organization.Services.Implements;
+
+public class OldGainfoService : IOldDeviceGainfoService
+{
+ private readonly IDbContext _dbContext;
+
+ public OldGainfoService(IDbContext dbContext)
+ {
+ _dbContext = dbContext;
+ }
+
+ ///
+ public async Task BatchUploadAsync(List requests)
+ {
+ var entities = requests.Adapt>();
+
+ foreach (var entity in entities)
+ {
+ if (!await _dbContext.Queryable().AnyAsync(x => x.No == entity.No && x.Code == entity.Code && x.UniqueNo == entity.UniqueNo))
+ {
+ await _dbContext.InsertAsync(entity);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
index 64217444..6d176626 100644
--- a/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
+++ b/Src/Dlhis.Basic/Packs/SqlSugarPack.cs
@@ -19,8 +19,8 @@ public class SqlSugarPack : BaseAppPack
return new List
{
- new()
- {
+ new()
+ {
ConfigId = "face",
ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value,
@@ -32,9 +32,9 @@ public class SqlSugarPack : BaseAppPack
{
DisableNvarchar = true,
}
- },
- new()
- {
+ },
+ new()
+ {
ConfigId = "log",
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
@@ -46,7 +46,7 @@ public class SqlSugarPack : BaseAppPack
{
DisableNvarchar = true,
}
- },
+ },
};
});
}
@@ -59,17 +59,17 @@ public class SqlSugarPack : BaseAppPack
return;
}
- // using var scope = app.ApplicationServices.CreateScope();
- // var db = scope.ServiceProvider.GetService();
- // var tables = App.ActiveTypes.Where(x => x.IsDefined(typeof(SugarTable), false))
- // .Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
- // .ToArray();
- //
- // db.Client.DbMaintenance.CreateDatabase();
- // db.Client.CodeFirst.InitTables(tables);
- //
- // var faceDb = db.ChangeDb("face");
- // faceDb.Client.DbMaintenance.CreateDatabase();
- // faceDb.Client.CodeFirst.InitTables();
+ using var scope = app.ApplicationServices.CreateScope();
+ var db = scope.ServiceProvider.GetService();
+ var tables = App.ActiveTypes.Where(x => x.IsDefined(typeof(SugarTable), false))
+ .Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
+ .ToArray();
+
+ db.Client.DbMaintenance.CreateDatabase();
+ db.Client.CodeFirst.InitTables(tables);
+
+ var faceDb = db.ChangeDb("face");
+ faceDb.Client.DbMaintenance.CreateDatabase();
+ faceDb.Client.CodeFirst.InitTables();
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Entity/Basic/Entity/OldDeviceGainfoEntity.cs b/Src/Dlhis.Entity/Basic/Entity/OldDeviceGainfoEntity.cs
new file mode 100644
index 00000000..f7f17476
--- /dev/null
+++ b/Src/Dlhis.Entity/Basic/Entity/OldDeviceGainfoEntity.cs
@@ -0,0 +1,45 @@
+using Dlhis.Entity.Device.Enums;
+using SqlSugar;
+using SqlSugar.DbConvert;
+
+namespace Dlhis.Entity.Basic.Entity;
+
+///
+/// 老系统设备档案
+///
+[SugarTable(TableName = "OldDeviceGainfos", TableDescription = "老系统设备档案")]
+public class OldDeviceGainfoEntity
+{
+ [SugarColumn(IsNullable = false, ColumnDescription = "厂区")]
+ public string Factory { get; set; }
+
+ ///
+ /// 档案号
+ ///
+ [SugarColumn(IsNullable = false, ColumnDescription = "档案号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
+ public string No { get; set; }
+
+ ///
+ /// 工号
+ ///
+ [SugarColumn(IsNullable = false, ColumnDescription = "工号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
+ public string Code { get; set; }
+
+ ///
+ /// 设备唯一号
+ ///
+ [SugarColumn(IsNullable = false, ColumnDescription = "设备唯一号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
+ public string UniqueNo { get; set; }
+
+ ///
+ /// 处理状态
+ ///
+ [SugarColumn(ColumnDescription = "处理状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
+ public OldDeviceGainfoEnumType Status { get; set; }
+
+ ///
+ /// 备注说明
+ ///
+ [SugarColumn(IsNullable = true, ColumnDataType = "varchar(2000)", ColumnDescription = "备注说明")]
+ public string Remark { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Entity/Device/Enums/OldDeviceGainfoEnumType.cs b/Src/Dlhis.Entity/Device/Enums/OldDeviceGainfoEnumType.cs
new file mode 100644
index 00000000..2fef2b69
--- /dev/null
+++ b/Src/Dlhis.Entity/Device/Enums/OldDeviceGainfoEnumType.cs
@@ -0,0 +1,28 @@
+using System.ComponentModel;
+
+namespace Dlhis.Entity.Device.Enums;
+
+///
+/// 老系统设备档案状态
+///
+[Description("老系统设备档案状态")]
+public enum OldDeviceGainfoEnumType
+{
+ ///
+ /// 待处理
+ ///
+ [Description("待处理")]
+ Wait = 0,
+
+ ///
+ /// 已删除
+ ///
+ [Description("已删除")]
+ Deleted = 10,
+
+ ///
+ /// 错误
+ ///
+ [Description("错误")]
+ Error = 99
+}
\ No newline at end of file