版本更新及编码规则

master
ZR20090193-陈敬勇 9 months ago
parent 65d87e7e29
commit e720f12f78

@ -67,6 +67,11 @@ public static class MultiLanguageConst
[Description("系统参数已存在")]
public const string ConfigExist = "Config_Exist";
[Description("系统版本信息已存在")]
public const string VersionExist = "Version_Exist";
[Description("系统版本更新已执行")]
public const string VersionExecuted = "Version_Executed";
/// <summary>
/// 权限模块不存在

@ -0,0 +1,101 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 系统编码模块
/// </summary>
public class SequenceController : ApiController
{
private readonly ISequenceService _invokeService;
private readonly ISequenceRuleService _sequenceRuleService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public SequenceController(ISequenceService invokeService,ISequenceRuleService SequenceRuleService)
{
_invokeService = invokeService;
_sequenceRuleService = SequenceRuleService;
}
/// <summary>
/// 系统编码列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetSequenceTypeList")]
public DataResult<List<SequenceRes>> GetSequenceList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑系统编码
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("EditSequence")]
public DataResult EditSequence([FromBody] SequenceReq model)
{
var res = _invokeService.EditSequence(model);
return res;
}
/// <summary>
/// 编码规则列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetSequenceRuleList")]
public DataResult<List<SequenceRuleRes>> GetSequenceRuleList([FromBody] PageRequest request)
{
var res = _sequenceRuleService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑 编码规则
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("EditSequenceRule")]
public DataResult EditSequenceRule([FromBody] SequenceRuleReq model)
{
var res = _sequenceRuleService.EditSequenceRule(model);
return res;
}
/// <summary>
/// 系统编码详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetSequenceInfo")]
public DataResult<SequenceRes> GetSequenceInfo([FromQuery] string id)
{
var res = _invokeService.GetSequenceInfo(id);
return res;
}
/// <summary>
/// 编码规则详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetSequenceRuleInfo")]
public DataResult<SequenceRuleRes> GetSequenceRuleInfo([FromQuery] string id)
{
var res = _sequenceRuleService.GetSequenceRuleInfo(id);
return res;
}
}

@ -0,0 +1,88 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 系统版本信息 模块
/// </summary>
public class VersionController : ApiController
{
private readonly IVersionService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public VersionController(IVersionService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetVersionList")]
public DataResult<List<VersionRes>> GetVersionList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("EditVersion")]
public DataResult EditVersion([FromBody] VersionReq req)
{
var res = _invokeService.EditVersion(req);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetVersionInfo")]
public DataResult<VersionRes> GetVersionInfo([FromQuery] string id)
{
var res = _invokeService.GetVersionInfo(id);
return res;
}
/// <summary>
/// 执行版本更新
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("ExecuteVersionUpdate")]
public async Task<DataResult> ExecuteVersionUpdate([FromBody] IdModel model)
{
return await _invokeService.ExecuteVersionUpdate(model);
}
/// <summary>
/// 获取版本已更新的租户列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetTenantVersionUpdateList")]
public DataResult<List<TenantVersionRes>> GetTenantVersionUpdateList([FromBody] PageRequest request)
{
var res = _invokeService.GetTenantVersionUpdateList(request);
return res;
}
}

@ -474,3 +474,24 @@
2024-03-04 10:47:49.7181 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-04 10:47:49.7420 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-04 10:47:49.7973 Info Configuration initialized.
2024-03-05 15:55:17.6260 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-05 15:55:17.6907 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-05 15:55:17.7076 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-05 15:55:17.7351 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-05 15:55:17.7554 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-05 15:55:17.7657 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-05 15:55:17.7865 Info Configuration initialized.
2024-03-05 16:12:25.9326 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-05 16:12:26.0383 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-05 16:12:26.0688 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-05 16:12:26.1426 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-05 16:12:26.2022 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-05 16:12:26.2232 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-05 16:12:26.2726 Info Configuration initialized.
2024-03-05 16:16:28.2106 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-05 16:16:28.2508 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-05 16:16:28.2871 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-05 16:16:28.3314 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-05 16:16:28.3845 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-05 16:16:28.4056 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-05 16:16:28.4584 Info Configuration initialized.

@ -26,6 +26,16 @@ public class DictDataReq
/// 字典值
/// </summary>
public string Value { get; set; }
/// <summary>
/// 字典名称(英文)
/// </summary>
public string EnName { get; set; }
/// <summary>
/// 拓展字段
/// </summary>
public string ExpandValue { get; set; }
/// <summary>
/// 排序
/// </summary>

@ -24,6 +24,16 @@ public class DictDataRes
/// 字典值
/// </summary>
public string Value { get; set; }
/// <summary>
/// 字典名称(英文)
/// </summary>
public string EnName { get; set; }
/// <summary>
/// 拓展字段
/// </summary>
public string ExpandValue { get; set; }
/// <summary>
/// 排序
/// </summary>

@ -0,0 +1,27 @@
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 租户版本信息
/// </summary>
public class TenantVersionRes
{
/// <summary>
/// 租户Id
/// </summary>
public long TenantId { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 版本Id
/// </summary>
public long VersionId { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
}

@ -0,0 +1,69 @@
using System.ComponentModel.DataAnnotations;
using DS.Module.Core;
using FluentValidation;
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 版本信息请求实体
/// </summary>
public class VersionReq
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 版本号
/// </summary>
[Required, MaxLength(100)]
public string Version { get; set; }
/// <summary>
/// 标题
/// </summary>
[Required, MaxLength(100)]
public string Title { get; set; }
/// <summary>
/// 主库更新内容
/// </summary>
public string MainContent { get; set; }
/// <summary>
/// 租户库更新内容
/// </summary>
public string TenantContent { get; set; }
/// <summary>
/// 排序
/// </summary>
public int? OrderNo { get; set; } = 100;
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
}
/// <summary>
/// 验证
/// </summary>
public class VersionReqValidator : AbstractValidator<VersionReq>
{
/// <summary>
/// 构造函数
/// </summary>
public VersionReqValidator()
{
// this.RuleFor(o => o.PermissionId)
// .NotEmpty().WithName("权限模块Id");
// this.RuleFor(o => o.ColumnView)
// .NotEmpty().WithName("中文视图名");
}
}

@ -0,0 +1,54 @@
using DS.Module.Core;
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 版本信息返回实体
/// </summary>
public class VersionRes
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 版本号
/// </summary>
public string Version { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 主库更新内容
/// </summary>
public string MainContent { get; set; }
/// <summary>
/// 租户库更新内容
/// </summary>
public string TenantContent { get; set; }
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 排序
/// </summary>
public int? OrderNo { get; set; } = 100;
/// <summary>
/// 执行标识
/// </summary>
public bool Executed { get; set; } = false;
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}

@ -15,7 +15,7 @@ public class SysDictData : BaseModel<long>
/// <summary>
/// 字典值
/// </summary>
[SqlSugar.SugarColumn(Length = 100,ColumnDescription="名称")]
[SqlSugar.SugarColumn(Length = 100,ColumnDescription="字典值")]
public string Value { get; set; }
/// <summary>
@ -24,7 +24,16 @@ public class SysDictData : BaseModel<long>
[SqlSugar.SugarColumn(Length = 50,ColumnDescription="编码")]
public string Code { get; set; }
/// <summary>
/// 字典名称(英文)
/// </summary>
[SqlSugar.SugarColumn(Length = 100,ColumnDescription="字典名称(英文)",IsNullable = true)]
public string EnName { get; set; }
/// <summary>
/// 拓展字段
/// </summary>
[SqlSugar.SugarColumn(Length = 100,ColumnDescription="拓展字段",IsNullable = true)]
public string ExpandValue { get; set; }
/// <summary>
/// 排序
/// </summary>

@ -0,0 +1,30 @@
using SqlSugar;
namespace DS.WMS.Core.System.Entity;
/// <summary>
/// 租户版本更新信息
/// </summary>
[SqlSugar.SugarTable("sys_tenant_version")]
public class SysTenantVersion
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long TenantId { get; set; }
/// <summary>
/// 版本Id
/// </summary>
public long VersionId { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
}

@ -0,0 +1,58 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.System.Entity;
/// <summary>
/// 系统版本表
/// </summary>
[SqlSugar.SugarTable("sys_version")]
public class SysVersion: BaseModel<long>
{
/// <summary>
/// 版本号
/// </summary>
[Required, MaxLength(100)]
[SugarColumn(ColumnDescription = "版本号",Length =100)]
public string Version { get; set; }
/// <summary>
/// 标题
/// </summary>
[Required, MaxLength(100)]
[SugarColumn(ColumnDescription = "标题", Length = 100)]
public string Title { get; set; }
/// <summary>
/// 主库更新内容
/// </summary>
[SugarColumn(ColumnDescription = "主库更新内容", IsNullable = true, Length = 5000)]
public string MainContent { get; set; }
/// <summary>
/// 租户库更新内容
/// </summary>
[SugarColumn(ColumnDescription = "租户库更新内容", IsNullable = true, Length = 5000)]
public string TenantContent { get; set; }
/// <summary>
/// 排序
/// </summary>
[SugarColumn(ColumnDescription = "排序")]
public int? OrderNo { get; set; } = 100;
/// <summary>
/// 状态
/// </summary>
[SugarColumn(ColumnDescription = "状态")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 执行标识
/// </summary>
[Description("执行标识")]
[SqlSugar.SugarColumn(ColumnDescription = "执行标识")]
public bool Executed { get; set; } = false;
}

@ -0,0 +1,52 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface;
public interface IVersionService
{
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<VersionRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult EditVersion(VersionReq model);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<VersionRes> GetVersionInfo(string id);
/// <summary>
/// 更新租户表差异
/// </summary>
/// <returns></returns>
public DataResult UpdateSaasTableInfo();
/// <summary>
/// 执行版本更新
/// </summary>
/// <param name="req">版本信息的Id</param>
/// <returns></returns>
Task<DataResult> ExecuteVersionUpdate(IdModel req);
/// <summary>
/// 获取版本已更新的租户列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<TenantVersionRes>> GetTenantVersionUpdateList(PageRequest request);
}

@ -679,7 +679,6 @@ public class CommonService : ICommonService
#endregion
#region 获取角色下拉列表
/// <summary>
@ -777,6 +776,7 @@ public class CommonService : ICommonService
}
#endregion
#region 国家信息下拉
/// <summary>
@ -836,6 +836,7 @@ public class CommonService : ICommonService
.ToList();
return DataResult<List<CodeLanesSelectRes>>.Success("获取数据成功!", list);
}
/// <summary>
/// 获取港口信息下拉列表
/// </summary>
@ -848,6 +849,7 @@ public class CommonService : ICommonService
.ToList();
return DataResult<List<CodePortSelectRes>>.Success("获取数据成功!", list);
}
/// <summary>
/// 获取港口信息下拉列表-客户端
/// </summary>
@ -1173,16 +1175,32 @@ public class CommonService : ICommonService
/// <returns></returns>
public DataResult GetDictTypeDropDown(DropDownDictTypeInput req)
{
var language = IhttpContext.HttpContext.Request.Headers["LanguageType"].FirstOrDefault();
if (language.IsNullOrEmpty())
{
language = "CN";
}
var type = db.Queryable<SysDictType>().Where(x => x.Code == req.Code && x.Status == StatusEnum.Enable).First();
if (type.IsNull())
{
return DataResult.Failed("字典类型不存在!");
}
var data = db.Queryable<SysDictData>().Where(x => x.TypeId == type.Id &&x.Status == StatusEnum.Enable)
.Select<DropDownData>().ToList();
var data = language == "CN"
? db.Queryable<SysDictData>().Where(x => x.TypeId == type.Id && x.Status == StatusEnum.Enable)
.Select<DropDownData>().ToList()
: db.Queryable<SysDictData>().Where(x => x.TypeId == type.Id && x.Status == StatusEnum.Enable)
.Select(x => new DropDownData
{
Code = x.Code,
Value = x.EnName,
}).ToList();
return DataResult.Successed("获取字典成功!", data);
}
/// <summary>
/// 批量获取字典值
/// </summary>
@ -1190,8 +1208,15 @@ public class CommonService : ICommonService
/// <returns></returns>
public DataResult<List<DictOptions>> GetDictOptions(DropDownDictTypeInput model)
{
var language = IhttpContext.HttpContext.Request.Headers["LanguageType"].FirstOrDefault();
if (language.IsNullOrEmpty())
{
language = "CN";
}
var codes = model.Code.Split(',');
var types = db.Queryable<SysDictType>().Where(x =>codes.Contains(x.Code) &&x.Status == StatusEnum.Enable).ToList();
var types = db.Queryable<SysDictType>().Where(x => codes.Contains(x.Code) && x.Status == StatusEnum.Enable)
.ToList();
var list = new List<DictOptions>();
@ -1200,8 +1225,15 @@ public class CommonService : ICommonService
var temp = new DictOptions
{
DictCode = item.Code,
Data = db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id &&x.Status == StatusEnum.Enable)
Data = language == "CN"
? db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable)
.Select<DropDownData>().ToList()
: db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable)
.Select(x => new DropDownData
{
Code = x.Code,
Value = x.EnName,
}).ToList()
};
list.Add(temp);
}

@ -0,0 +1,204 @@
using System.Reflection;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using SysTenantLink = DS.WMS.Core.System.Entity.SysTenantLink;
namespace DS.WMS.Core.System.Method;
public class VersionService : IVersionService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public VersionService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<VersionRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<SysVersion>()
.Where(whereList)
.Select<VersionRes>().ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult EditVersion(VersionReq req)
{
if (req.Id == 0)
{
if (db.Queryable<SysVersion>().Where(x => x.Version == req.Version).Any())
{
return DataResult.Failed("系统版本信息已存在!", MultiLanguageConst.VersionExist);
}
var data = req.Adapt<SysVersion>();
var entity = db.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = db.Queryable<SysVersion>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<VersionRes> GetVersionInfo(string id)
{
var data = db.Queryable<SysVersion>()
.Where(a => a.Id == long.Parse(id))
.Select<VersionRes>()
.First();
return DataResult<VersionRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
/// <summary>
/// 更新租户表差异
/// </summary>
/// <returns></returns>
public DataResult UpdateSaasTableInfo()
{
var path = AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory;
var referencedAssemblies = Directory.GetFiles(path, "DS.WMS.Core.dll").Select(Assembly.LoadFrom).ToArray();
var types = referencedAssemblies
.SelectMany(a => a.DefinedTypes)
.Select(type => type.AsType())
.Where(it => it.FullName.Contains("DS.WMS.Core.Code.Entity.")).ToArray();
var tenantList = db.Queryable<SysTenantLink>().ToList();
foreach (var item in tenantList)
{
var tenantDb = saasService.GetBizDbScopeById(item.TenantId);
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci"; //较高版本支持
tenantDb.CodeFirst.InitTables(types);
}
return DataResult.Successed("更新租户表信息成功!", MultiLanguageConst.DataUpdateSuccess);
}
/// <summary>
/// 执行版本更新
/// </summary>
/// <param name="req">版本信息的Id</param>
/// <returns></returns>
public async Task<DataResult> ExecuteVersionUpdate(IdModel req)
{
var dbScope = (SqlSugarScope)db;
var version = await db.Queryable<SysVersion>()
.FirstAsync(a => a.Id == long.Parse(req.Id) && a.Status == StatusEnum.Enable);
if (version.IsNull())
{
return await Task.FromResult(DataResult.Failed("系统版本信息已存在!", MultiLanguageConst.VersionExist));
}
if (version.Executed)
{
return await Task.FromResult(DataResult.Failed("系统版本更新已执行!", MultiLanguageConst.VersionExecuted));
}
try
{
//开启事务
await dbScope.Ado.BeginTranAsync();
if (version.MainContent.IsNotEmptyOrNull())
{
db.Ado.ExecuteCommandWithGo(version.MainContent);
}
if (version.TenantContent.IsNotEmptyOrNull())
{
var tenantList = await db.Queryable<SysTenantLink>().ToListAsync();
foreach (var item in tenantList)
{
var tenantDb = saasService.GetBizDbScopeById(item.TenantId);
if (await db.Queryable<SysTenantVersion>()
.Where(x => x.TenantId == item.TenantId && x.VersionId == version.Id).AnyAsync())
{
continue;
}
else
{
tenantDb.Ado.ExecuteCommandWithGo(version.TenantContent);
var tenantVersion = new SysTenantVersion()
{
TenantId = item.TenantId,
VersionId = version.Id,
UpdateTime = DateTime.Now
};
await db.Insertable(tenantVersion).ExecuteCommandAsync();
}
}
}
version.Executed = true;
await db.Updateable(version).ExecuteCommandAsync();
await dbScope.Ado.CommitTranAsync();
return await Task.FromResult(DataResult.Successed("执行版本更新成功!", MultiLanguageConst.DataUpdateSuccess));
}
catch (Exception ex)
{
await dbScope.Ado.RollbackTranAsync();
return await Task.FromResult(DataResult.Failed("审批失败!" + ",请联系管理员!" + ex.ToString()));
}
}
/// <summary/>
/// 获取版本已更新的租户列表
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<TenantVersionRes>> GetTenantVersionUpdateList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<SysTenantVersion>()
.LeftJoin<SysTenant>((a,b)=>a.TenantId == b.Id)
.Where(whereList)
.Select<TenantVersionRes>().ToQueryPage(request.PageCondition);
return data;
}
}

@ -1,33 +1,35 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.MainApi.Controllers;
/// <summary>
/// 系统编码模块
/// </summary>
public class SequenceController : ApiController
{
private readonly ISequenceService _invokeService;
private readonly ISequenceRuleService _sequenceRuleService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public SequenceController(ISequenceService invokeService)
public SequenceController(ISequenceService invokeService,ISequenceRuleService SequenceRuleService)
{
_invokeService = invokeService;
_sequenceRuleService = SequenceRuleService;
}
/// <summary>
/// 列表
/// 系统编码列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetSequenceList")]
[Route("GetSequenceTypeList")]
public DataResult<List<SequenceRes>> GetSequenceList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
@ -35,20 +37,45 @@ public class SequenceController : ApiController
}
/// <summary>
/// 编辑
/// 编辑系统编码
/// </summary>
/// <param name="req"></param>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("EditSequence")]
public DataResult EditSequence([FromBody] SequenceReq req)
public DataResult EditSequence([FromBody] SequenceReq model)
{
var res = _invokeService.EditSequence(req);
var res = _invokeService.EditSequence(model);
return res;
}
/// <summary>
/// 详情
/// 编码规则列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetSequenceRuleList")]
public DataResult<List<SequenceRuleRes>> GetSequenceRuleList([FromBody] PageRequest request)
{
var res = _sequenceRuleService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑 编码规则
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("EditSequenceRule")]
public DataResult EditSequenceRule([FromBody] SequenceRuleReq model)
{
var res = _sequenceRuleService.EditSequenceRule(model);
return res;
}
/// <summary>
/// 系统编码详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
@ -59,4 +86,16 @@ public class SequenceController : ApiController
var res = _invokeService.GetSequenceInfo(id);
return res;
}
/// <summary>
/// 编码规则详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetSequenceRuleInfo")]
public DataResult<SequenceRuleRes> GetSequenceRuleInfo([FromQuery] string id)
{
var res = _sequenceRuleService.GetSequenceRuleInfo(id);
return res;
}
}

@ -1,62 +0,0 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.MainApi.Controllers;
/// <summary>
/// 系统编码规则模块
/// </summary>
public class SequenceRuleController : ApiController
{
private readonly ISequenceRuleService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public SequenceRuleController(ISequenceRuleService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetSequenceRuleList")]
public DataResult<List<SequenceRuleRes>> GetSequenceRuleList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("EditSequenceRule")]
public DataResult EditSequenceRule([FromBody] SequenceRuleReq req)
{
var res = _invokeService.EditSequenceRule(req);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetSequenceRuleInfo")]
public DataResult<SequenceRuleRes> GetSequenceRuleInfo([FromQuery] string id)
{
var res = _invokeService.GetSequenceRuleInfo(id);
return res;
}
}

@ -208,3 +208,10 @@
2024-03-05 11:42:42.7983 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-05 11:42:42.8190 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-05 11:42:42.8903 Info Configuration initialized.
2024-03-05 15:54:02.9352 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-05 15:54:03.0338 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-05 15:54:03.0595 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-05 15:54:03.1220 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-05 15:54:03.1623 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-05 15:54:03.1820 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-05 15:54:03.2199 Info Configuration initialized.

Loading…
Cancel
Save