diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index 4b6efd39..d5944d2f 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -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"; /// /// 权限模块不存在 diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/SequenceController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/SequenceController.cs new file mode 100644 index 00000000..e77498f0 --- /dev/null +++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/SequenceController.cs @@ -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; +/// +/// 系统编码模块 +/// +public class SequenceController : ApiController +{ + private readonly ISequenceService _invokeService; + private readonly ISequenceRuleService _sequenceRuleService; + /// + /// 构造函数 + /// + /// + public SequenceController(ISequenceService invokeService,ISequenceRuleService SequenceRuleService) + { + _invokeService = invokeService; + _sequenceRuleService = SequenceRuleService; + } + + /// + /// 系统编码列表 + /// + /// + /// + [HttpPost] + [Route("GetSequenceTypeList")] + public DataResult> GetSequenceList([FromBody] PageRequest request) + { + var res = _invokeService.GetListByPage(request); + return res; + } + + /// + /// 编辑系统编码 + /// + /// + /// + [HttpPost] + [Route("EditSequence")] + public DataResult EditSequence([FromBody] SequenceReq model) + { + var res = _invokeService.EditSequence(model); + return res; + } + + /// + /// 编码规则列表 + /// + /// + /// + [HttpPost] + [Route("GetSequenceRuleList")] + public DataResult> GetSequenceRuleList([FromBody] PageRequest request) + { + var res = _sequenceRuleService.GetListByPage(request); + return res; + } + + /// + /// 编辑 编码规则 + /// + /// + /// + [HttpPost] + [Route("EditSequenceRule")] + public DataResult EditSequenceRule([FromBody] SequenceRuleReq model) + { + var res = _sequenceRuleService.EditSequenceRule(model); + return res; + } + /// + /// 系统编码详情 + /// + /// + /// + [HttpGet] + [Route("GetSequenceInfo")] + public DataResult GetSequenceInfo([FromQuery] string id) + { + var res = _invokeService.GetSequenceInfo(id); + return res; + } + /// + /// 编码规则详情 + /// + /// + /// + [HttpGet] + [Route("GetSequenceRuleInfo")] + public DataResult GetSequenceRuleInfo([FromQuery] string id) + { + var res = _sequenceRuleService.GetSequenceRuleInfo(id); + return res; + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantApplyController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantApplyController.cs index a7e69a39..6906209e 100644 --- a/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantApplyController.cs +++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantApplyController.cs @@ -66,7 +66,7 @@ public class TenantApplyController : ApiController /// [HttpPost] [Route("TenantApplyAudit")] - public async Task TenantApplyAudit([FromBody] TenantApplyAuditReq model) + public async Task TenantApplyAudit([FromBody] TenantApplyAuditReq model) { return await _invokeService.TenantApplyAudit(model); } diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/VersionController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/VersionController.cs new file mode 100644 index 00000000..76943e34 --- /dev/null +++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/VersionController.cs @@ -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; + +/// +/// 系统版本信息 模块 +/// +public class VersionController : ApiController +{ + private readonly IVersionService _invokeService; + + /// + /// 构造函数 + /// + /// + public VersionController(IVersionService invokeService) + { + _invokeService = invokeService; + } + + /// + /// 列表 + /// + /// + /// + [HttpPost] + [Route("GetVersionList")] + public DataResult> GetVersionList([FromBody] PageRequest request) + { + var res = _invokeService.GetListByPage(request); + return res; + } + + /// + /// 编辑 + /// + /// + /// + [HttpPost] + [Route("EditVersion")] + public DataResult EditVersion([FromBody] VersionReq req) + { + var res = _invokeService.EditVersion(req); + return res; + } + + /// + /// 详情 + /// + /// + /// + [HttpGet] + [Route("GetVersionInfo")] + public DataResult GetVersionInfo([FromQuery] string id) + { + var res = _invokeService.GetVersionInfo(id); + return res; + } + + /// + /// 执行版本更新 + /// + /// + /// + [HttpPost] + [Route("ExecuteVersionUpdate")] + public async Task ExecuteVersionUpdate([FromBody] IdModel model) + { + return await _invokeService.ExecuteVersionUpdate(model); + } + + /// + /// 获取版本已更新的租户列表 + /// + /// + /// + [HttpPost] + [Route("GetTenantVersionUpdateList")] + public DataResult> GetTenantVersionUpdateList([FromBody] PageRequest request) + { + var res = _invokeService.GetTenantVersionUpdateList(request); + return res; + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt index ccc59412..fe3a4d89 100644 --- a/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt +++ b/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt @@ -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. diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataReq.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataReq.cs index 4caf70a8..ef45dd56 100644 --- a/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataReq.cs +++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataReq.cs @@ -26,6 +26,16 @@ public class DictDataReq /// 字典值 /// public string Value { get; set; } + + /// + /// 字典名称(英文) + /// + public string EnName { get; set; } + + /// + /// 拓展字段 + /// + public string ExpandValue { get; set; } /// /// 排序 /// diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataRes.cs index 22be3504..f0304ba0 100644 --- a/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataRes.cs +++ b/ds-wms-service/DS.WMS.Core/System/Dtos/DictDataRes.cs @@ -24,6 +24,16 @@ public class DictDataRes /// 字典值 /// public string Value { get; set; } + + /// + /// 字典名称(英文) + /// + public string EnName { get; set; } + + /// + /// 拓展字段 + /// + public string ExpandValue { get; set; } /// /// 排序 /// diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/TenantVersionRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/TenantVersionRes.cs new file mode 100644 index 00000000..c7bc6d6f --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Dtos/TenantVersionRes.cs @@ -0,0 +1,27 @@ +namespace DS.WMS.Core.System.Dtos; + +/// +/// 租户版本信息 +/// +public class TenantVersionRes +{ + /// + /// 租户Id + /// + public long TenantId { get; set; } + + + /// + /// 租户名称 + /// + public string Name { get; set; } + + /// + /// 版本Id + /// + public long VersionId { get; set; } + /// + /// 更新时间 + /// + public DateTime UpdateTime { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/VersionReq.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/VersionReq.cs new file mode 100644 index 00000000..6624a872 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Dtos/VersionReq.cs @@ -0,0 +1,69 @@ +using System.ComponentModel.DataAnnotations; +using DS.Module.Core; +using FluentValidation; + +namespace DS.WMS.Core.System.Dtos; + +/// +/// 版本信息请求实体 +/// +public class VersionReq +{ + /// + /// 主键Id + /// + public long Id { get; set; } + /// + /// 版本号 + /// + [Required, MaxLength(100)] + public string Version { get; set; } + + /// + /// 标题 + /// + [Required, MaxLength(100)] + public string Title { get; set; } + + /// + /// 主库更新内容 + /// + public string MainContent { get; set; } + + /// + /// 租户库更新内容 + /// + public string TenantContent { get; set; } + + /// + /// 排序 + /// + public int? OrderNo { get; set; } = 100; + + /// + /// 状态 0 启用 1 禁用 + /// + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 备注 + /// + public string Note { get; set; } = ""; +} + + +/// +/// 验证 +/// +public class VersionReqValidator : AbstractValidator +{ + /// + /// 构造函数 + /// + public VersionReqValidator() + { + // this.RuleFor(o => o.PermissionId) + // .NotEmpty().WithName("权限模块Id"); + // this.RuleFor(o => o.ColumnView) + // .NotEmpty().WithName("中文视图名"); + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Dtos/VersionRes.cs b/ds-wms-service/DS.WMS.Core/System/Dtos/VersionRes.cs new file mode 100644 index 00000000..7fbb20ba --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Dtos/VersionRes.cs @@ -0,0 +1,54 @@ +using DS.Module.Core; + +namespace DS.WMS.Core.System.Dtos; + +/// +/// 版本信息返回实体 +/// +public class VersionRes +{ + /// + /// 主键Id + /// + public long Id { get; set; } + /// + /// 版本号 + /// + public string Version { get; set; } + + /// + /// 标题 + /// + public string Title { get; set; } + + /// + /// 主库更新内容 + /// + public string MainContent { get; set; } + + /// + /// 租户库更新内容 + /// + public string TenantContent { get; set; } + + /// + /// 状态 0 启用 1 禁用 + /// + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 备注 + /// + public string Note { get; set; } = ""; + /// + /// 排序 + /// + public int? OrderNo { get; set; } = 100; + /// + /// 执行标识 + /// + public bool Executed { get; set; } = false; + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Entity/SysDictData.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysDictData.cs index 887341ec..87a25b67 100644 --- a/ds-wms-service/DS.WMS.Core/System/Entity/SysDictData.cs +++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysDictData.cs @@ -15,7 +15,7 @@ public class SysDictData : BaseModel /// /// 字典值 /// - [SqlSugar.SugarColumn(Length = 100,ColumnDescription="名称")] + [SqlSugar.SugarColumn(Length = 100,ColumnDescription="字典值")] public string Value { get; set; } /// @@ -24,7 +24,16 @@ public class SysDictData : BaseModel [SqlSugar.SugarColumn(Length = 50,ColumnDescription="编码")] public string Code { get; set; } - + /// + /// 字典名称(英文) + /// + [SqlSugar.SugarColumn(Length = 100,ColumnDescription="字典名称(英文)",IsNullable = true)] + public string EnName { get; set; } + /// + /// 拓展字段 + /// + [SqlSugar.SugarColumn(Length = 100,ColumnDescription="拓展字段",IsNullable = true)] + public string ExpandValue { get; set; } /// /// 排序 /// diff --git a/ds-wms-service/DS.WMS.Core/System/Entity/SysTenantVersion.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysTenantVersion.cs new file mode 100644 index 00000000..3368bd68 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysTenantVersion.cs @@ -0,0 +1,30 @@ +using SqlSugar; + +namespace DS.WMS.Core.System.Entity; + +/// +/// 租户版本更新信息 +/// +[SqlSugar.SugarTable("sys_tenant_version")] +public class SysTenantVersion +{ + /// + /// ID + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 租户id + /// + public long TenantId { get; set; } + + /// + /// 版本Id + /// + public long VersionId { get; set; } + /// + /// 更新时间 + /// + public DateTime UpdateTime { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Entity/SysVersion.cs b/ds-wms-service/DS.WMS.Core/System/Entity/SysVersion.cs new file mode 100644 index 00000000..2e5cc636 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Entity/SysVersion.cs @@ -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; +/// +/// 系统版本表 +/// +[SqlSugar.SugarTable("sys_version")] +public class SysVersion: BaseModel +{ + /// + /// 版本号 + /// + [Required, MaxLength(100)] + [SugarColumn(ColumnDescription = "版本号",Length =100)] + public string Version { get; set; } + + /// + /// 标题 + /// + [Required, MaxLength(100)] + [SugarColumn(ColumnDescription = "标题", Length = 100)] + public string Title { get; set; } + + /// + /// 主库更新内容 + /// + [SugarColumn(ColumnDescription = "主库更新内容", IsNullable = true, Length = 5000)] + public string MainContent { get; set; } + + /// + /// 租户库更新内容 + /// + [SugarColumn(ColumnDescription = "租户库更新内容", IsNullable = true, Length = 5000)] + public string TenantContent { get; set; } + + /// + /// 排序 + /// + [SugarColumn(ColumnDescription = "排序")] + public int? OrderNo { get; set; } = 100; + /// + /// 状态 + /// + [SugarColumn(ColumnDescription = "状态")] + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + + /// + /// 执行标识 + /// + [Description("执行标识")] + [SqlSugar.SugarColumn(ColumnDescription = "执行标识")] + public bool Executed { get; set; } = false; + +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/IVersionService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/IVersionService.cs new file mode 100644 index 00000000..637bfbd2 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Interface/IVersionService.cs @@ -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 +{ + /// + /// 列表 + /// + /// + /// + DataResult> GetListByPage(PageRequest request); + + + /// + /// 编辑 + /// + /// + /// + DataResult EditVersion(VersionReq model); + + /// + /// 获取详情 + /// + /// + /// + DataResult GetVersionInfo(string id); + + + /// + /// 更新租户表差异 + /// + /// + public DataResult UpdateSaasTableInfo(); + + /// + /// 执行版本更新 + /// + /// 版本信息的Id + /// + Task ExecuteVersionUpdate(IdModel req); + + /// + /// 获取版本已更新的租户列表 + /// + /// + /// + public DataResult> GetTenantVersionUpdateList(PageRequest request); +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs b/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs index aed410bb..452cb3f0 100644 --- a/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs +++ b/ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs @@ -678,7 +678,6 @@ public class CommonService : ICommonService #endregion - #region 获取角色下拉列表 @@ -777,6 +776,7 @@ public class CommonService : ICommonService } #endregion + #region 国家信息下拉 /// @@ -786,7 +786,7 @@ public class CommonService : ICommonService public DataResult> GetCountrySelectList() { var list = db.Queryable() - .Where(x=>x.Status == StatusEnum.Enable) + .Where(x => x.Status == StatusEnum.Enable) .Select() .ToList(); return DataResult>.Success("获取数据成功!", list); @@ -800,14 +800,14 @@ public class CommonService : ICommonService { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var list = tenantDb.Queryable() - .Where(x=>x.Status == StatusEnum.Enable) + .Where(x => x.Status == StatusEnum.Enable) .Select() .ToList(); return DataResult>.Success("获取数据成功!", list); } #endregion - + #region 航线信息下拉 /// @@ -817,7 +817,7 @@ public class CommonService : ICommonService public DataResult> GetLanesSelectList() { var list = db.Queryable() - .Where(x=>x.Status == StatusEnum.Enable) + .Where(x => x.Status == StatusEnum.Enable) .Select() .ToList(); return DataResult>.Success("获取数据成功!", list); @@ -831,11 +831,12 @@ public class CommonService : ICommonService { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var list = tenantDb.Queryable() - .Where(x=>x.Status == StatusEnum.Enable) + .Where(x => x.Status == StatusEnum.Enable) .Select() .ToList(); return DataResult>.Success("获取数据成功!", list); } + /// /// 获取港口信息下拉列表 /// @@ -843,11 +844,12 @@ public class CommonService : ICommonService public DataResult> GetPortSelectList() { var list = db.Queryable() - .Where(x=>x.Status == StatusEnum.Enable) + .Where(x => x.Status == StatusEnum.Enable) .Select() .ToList(); return DataResult>.Success("获取数据成功!", list); } + /// /// 获取港口信息下拉列表-客户端 /// @@ -856,15 +858,15 @@ public class CommonService : ICommonService { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var list = tenantDb.Queryable() - .Where(x=>x.Status == StatusEnum.Enable) + .Where(x => x.Status == StatusEnum.Enable) .Select() .ToList(); return DataResult>.Success("获取数据成功!", list); } #endregion - - + + #region 获取客户数据权限列表 /// @@ -1173,16 +1175,32 @@ public class CommonService : ICommonService /// public DataResult GetDictTypeDropDown(DropDownDictTypeInput req) { - var type = db.Queryable().Where(x => x.Code == req.Code &&x.Status == StatusEnum.Enable).First(); + var language = IhttpContext.HttpContext.Request.Headers["LanguageType"].FirstOrDefault(); + if (language.IsNullOrEmpty()) + { + language = "CN"; + } + + var type = db.Queryable().Where(x => x.Code == req.Code && x.Status == StatusEnum.Enable).First(); if (type.IsNull()) { return DataResult.Failed("字典类型不存在!"); } - var data = db.Queryable().Where(x => x.TypeId == type.Id &&x.Status == StatusEnum.Enable) - .Select().ToList(); + + var data = language == "CN" + ? db.Queryable().Where(x => x.TypeId == type.Id && x.Status == StatusEnum.Enable) + .Select().ToList() + : db.Queryable().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); } + /// /// 批量获取字典值 /// @@ -1190,22 +1208,36 @@ public class CommonService : ICommonService /// public DataResult> 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().Where(x =>codes.Contains(x.Code) &&x.Status == StatusEnum.Enable).ToList(); + var types = db.Queryable().Where(x => codes.Contains(x.Code) && x.Status == StatusEnum.Enable) + .ToList(); - var list =new List(); + var list = new List(); foreach (var item in types) { var temp = new DictOptions { DictCode = item.Code, - Data = db.Queryable().Where(x => x.TypeId == item.Id &&x.Status == StatusEnum.Enable) - .Select().ToList() + Data = language == "CN" + ? db.Queryable().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable) + .Select().ToList() + : db.Queryable().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable) + .Select(x => new DropDownData + { + Code = x.Code, + Value = x.EnName, + }).ToList() }; list.Add(temp); } - + return DataResult>.Success("获取字典成功!", list); } diff --git a/ds-wms-service/DS.WMS.Core/System/Method/VersionService.cs b/ds-wms-service/DS.WMS.Core/System/Method/VersionService.cs new file mode 100644 index 00000000..7316bd27 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/System/Method/VersionService.cs @@ -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; + + /// + /// + /// + /// + public VersionService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); + } + + /// + /// 列表 + /// + /// + /// + public DataResult> GetListByPage(PageRequest request) + { + //序列化查询条件 + var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); + var data = db.Queryable() + .Where(whereList) + .Select().ToQueryPage(request.PageCondition); + return data; + } + + /// + /// 编辑 + /// + /// + /// + public DataResult EditVersion(VersionReq req) + { + if (req.Id == 0) + { + if (db.Queryable().Where(x => x.Version == req.Version).Any()) + { + return DataResult.Failed("系统版本信息已存在!", MultiLanguageConst.VersionExist); + } + + var data = req.Adapt(); + + var entity = db.Insertable(data).ExecuteReturnEntity(); + + return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess); + } + else + { + var info = db.Queryable().Where(x => x.Id == req.Id).First(); + + info = req.Adapt(info); + + db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); + return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); + } + } + + /// + /// 详情 + /// + /// + /// + public DataResult GetVersionInfo(string id) + { + var data = db.Queryable() + .Where(a => a.Id == long.Parse(id)) + .Select() + .First(); + return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess); + } + + + /// + /// 更新租户表差异 + /// + /// + 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().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); + } + + + /// + /// 执行版本更新 + /// + /// 版本信息的Id + /// + public async Task ExecuteVersionUpdate(IdModel req) + { + var dbScope = (SqlSugarScope)db; + var version = await db.Queryable() + .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().ToListAsync(); + foreach (var item in tenantList) + { + var tenantDb = saasService.GetBizDbScopeById(item.TenantId); + if (await db.Queryable() + .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())); + } + } + + /// + /// 获取版本已更新的租户列表 + /// + /// + public DataResult> GetTenantVersionUpdateList(PageRequest request) + { + //序列化查询条件 + var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); + var data = db.Queryable() + .LeftJoin((a,b)=>a.TenantId == b.Id) + .Where(whereList) + .Select().ToQueryPage(request.PageCondition); + return data; + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/SequenceController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/SequenceController.cs index 06986b1e..af83e52f 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/SequenceController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/SequenceController.cs @@ -1,54 +1,81 @@ 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; - /// /// 系统编码模块 /// -public class SequenceController : ApiController +public class SequenceController : ApiController { private readonly ISequenceService _invokeService; - + private readonly ISequenceRuleService _sequenceRuleService; /// /// 构造函数 /// /// - public SequenceController(ISequenceService invokeService) + public SequenceController(ISequenceService invokeService,ISequenceRuleService SequenceRuleService) { _invokeService = invokeService; - } - + _sequenceRuleService = SequenceRuleService; + } + /// - /// 列表 + /// 系统编码列表 /// /// /// [HttpPost] - [Route("GetSequenceList")] + [Route("GetSequenceTypeList")] public DataResult> GetSequenceList([FromBody] PageRequest request) - { + { var res = _invokeService.GetListByPage(request); return res; } - + /// - /// 编辑 + /// 编辑系统编码 /// - /// + /// /// [HttpPost] - [Route("EditSequence")] - public DataResult EditSequence([FromBody] SequenceReq req) - { - var res = _invokeService.EditSequence(req); + [Route("EditSequence")] + public DataResult EditSequence([FromBody] SequenceReq model) + { + var res = _invokeService.EditSequence(model); return res; } - + + /// + /// 编码规则列表 + /// + /// + /// + [HttpPost] + [Route("GetSequenceRuleList")] + public DataResult> GetSequenceRuleList([FromBody] PageRequest request) + { + var res = _sequenceRuleService.GetListByPage(request); + return res; + } + /// - /// 详情 + /// 编辑 编码规则 + /// + /// + /// + [HttpPost] + [Route("EditSequenceRule")] + public DataResult EditSequenceRule([FromBody] SequenceRuleReq model) + { + var res = _sequenceRuleService.EditSequenceRule(model); + return res; + } + /// + /// 系统编码详情 /// /// /// @@ -59,4 +86,16 @@ public class SequenceController : ApiController var res = _invokeService.GetSequenceInfo(id); return res; } + /// + /// 编码规则详情 + /// + /// + /// + [HttpGet] + [Route("GetSequenceRuleInfo")] + public DataResult GetSequenceRuleInfo([FromQuery] string id) + { + var res = _sequenceRuleService.GetSequenceRuleInfo(id); + return res; + } } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/SequenceRuleController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/SequenceRuleController.cs deleted file mode 100644 index d5af446a..00000000 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/SequenceRuleController.cs +++ /dev/null @@ -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; - -/// -/// 系统编码规则模块 -/// -public class SequenceRuleController : ApiController -{ - private readonly ISequenceRuleService _invokeService; - - /// - /// 构造函数 - /// - /// - public SequenceRuleController(ISequenceRuleService invokeService) - { - _invokeService = invokeService; - } - - /// - /// 列表 - /// - /// - /// - [HttpPost] - [Route("GetSequenceRuleList")] - public DataResult> GetSequenceRuleList([FromBody] PageRequest request) - { - var res = _invokeService.GetListByPage(request); - return res; - } - - /// - /// 编辑 - /// - /// - /// - [HttpPost] - [Route("EditSequenceRule")] - public DataResult EditSequenceRule([FromBody] SequenceRuleReq req) - { - var res = _invokeService.EditSequenceRule(req); - return res; - } - - /// - /// 详情 - /// - /// - /// - [HttpGet] - [Route("GetSequenceRuleInfo")] - public DataResult GetSequenceRuleInfo([FromQuery] string id) - { - var res = _invokeService.GetSequenceRuleInfo(id); - return res; - } -} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt index 837c6d58..b90a4ed3 100644 --- a/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt +++ b/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt @@ -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.