feat 老系统档案上传功能
This commit is contained in:
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// 老系统档案表
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class OldDeviceGainfosController : ControllerBase
|
||||
{
|
||||
private readonly IOldDeviceGainfoService _oldGainfoService;
|
||||
|
||||
public OldDeviceGainfosController(IOldDeviceGainfoService oldGainfoService)
|
||||
{
|
||||
_oldGainfoService = oldGainfoService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传
|
||||
/// </summary>
|
||||
/// <param name="requests"></param>
|
||||
[HttpPost("upload")]
|
||||
public async Task BatchUploadAsync(List<OldDeviceGainfoUploadRequest> requests)
|
||||
{
|
||||
await _oldGainfoService.BatchUploadAsync(requests);
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// 档案号
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string No { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Code { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services;
|
||||
|
||||
public interface IOldDeviceGainfoService : IScopeDependency
|
||||
{
|
||||
Task BatchUploadAsync(List<OldDeviceGainfoUploadRequest> requests);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task BatchUploadAsync(List<OldDeviceGainfoUploadRequest> requests)
|
||||
{
|
||||
var entities = requests.Adapt<List<OldDeviceGainfoEntity>>();
|
||||
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (!await _dbContext.Queryable<OldDeviceGainfoEntity>().AnyAsync(x => x.No == entity.No && x.Code == entity.Code && x.UniqueNo == entity.UniqueNo))
|
||||
{
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ public class SqlSugarPack : BaseAppPack
|
||||
|
||||
return new List<ConnectionConfig>
|
||||
{
|
||||
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<IDbContext>();
|
||||
// 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<GainfoFaceEntity>();
|
||||
using var scope = app.ApplicationServices.CreateScope();
|
||||
var db = scope.ServiceProvider.GetService<IDbContext>();
|
||||
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<GainfoFaceEntity>();
|
||||
}
|
||||
}
|
||||
45
Src/Dlhis.Entity/Basic/Entity/OldDeviceGainfoEntity.cs
Normal file
45
Src/Dlhis.Entity/Basic/Entity/OldDeviceGainfoEntity.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
namespace Dlhis.Entity.Basic.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 老系统设备档案
|
||||
/// </summary>
|
||||
[SugarTable(TableName = "OldDeviceGainfos", TableDescription = "老系统设备档案")]
|
||||
public class OldDeviceGainfoEntity
|
||||
{
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "厂区")]
|
||||
public string Factory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 档案号
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "档案号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
|
||||
public string No { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "工号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备唯一号
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "设备唯一号", IndexGroupNameList = new[] { "unique_OldGainfos_no_code_unique" })]
|
||||
public string UniqueNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 处理状态
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "处理状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public OldDeviceGainfoEnumType Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注说明
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true, ColumnDataType = "varchar(2000)", ColumnDescription = "备注说明")]
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
28
Src/Dlhis.Entity/Device/Enums/OldDeviceGainfoEnumType.cs
Normal file
28
Src/Dlhis.Entity/Device/Enums/OldDeviceGainfoEnumType.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Device.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 老系统设备档案状态
|
||||
/// </summary>
|
||||
[Description("老系统设备档案状态")]
|
||||
public enum OldDeviceGainfoEnumType
|
||||
{
|
||||
/// <summary>
|
||||
/// 待处理
|
||||
/// </summary>
|
||||
[Description("待处理")]
|
||||
Wait = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 已删除
|
||||
/// </summary>
|
||||
[Description("已删除")]
|
||||
Deleted = 10,
|
||||
|
||||
/// <summary>
|
||||
/// 错误
|
||||
/// </summary>
|
||||
[Description("错误")]
|
||||
Error = 99
|
||||
}
|
||||
Reference in New Issue
Block a user