diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceReq.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceReq.cs new file mode 100644 index 00000000..02241af6 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceReq.cs @@ -0,0 +1,85 @@ +using DS.Module.Core; +using FluentValidation; + +namespace DS.WMS.Core.Code.Dtos; + +/// +/// 基础编码请求实体 +/// +public class CodeSequenceReq +{ + /// + /// 主键Id + /// + public long Id { get; set; } + /// + /// 权限ID + /// + public long PermissionId { get; set; } + /// + /// 权限实体 + /// + public string PermissionEntity { get; set; }= ""; + + /// + /// 名称 + /// + public string SequenceName { get; set; }= ""; + /// + /// 分隔符 + /// + public string SequenceDelimiter { get; set; }= ""; + + /// + /// 序号重置规则 + /// + public string SequenceReset { get; set; } = ""; + + /// + /// 步长 + /// + public int Step { get; set; } = 0; + /// + /// 当前值 + /// + public int CurrentNo { get; set; }= 0; + /// + /// 当前编码 + /// + public string CurrentCode { get; set; }= ""; + /// + /// 当前重置依赖,即最后一次获取编码的日期 + /// + public string CurrentReset { get; set; }= ""; + /// + /// 排序 + /// + public int? OrderNo { get; set; } = 100; + + /// + /// 状态 0 启用 1 禁用 + /// + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 备注 + /// + public string Note { get; set; } = ""; +} + + +/// +/// 验证 +/// +public class CodeSequenceReqValidator : AbstractValidator +{ + /// + /// 构造函数 + /// + public CodeSequenceReqValidator() + { + this.RuleFor(o => o.PermissionId) + .NotEmpty().WithName("权限模块Id"); + this.RuleFor(o => o.SequenceName) + .NotEmpty().WithName("名称"); + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRes.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRes.cs new file mode 100644 index 00000000..8d093f8b --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRes.cs @@ -0,0 +1,71 @@ +using DS.Module.Core; + +namespace DS.WMS.Core.Code.Dtos; + +/// +/// 基础编码返回实体 +/// +public class CodeSequenceRes +{ + /// + /// 主键Id + /// + public long Id { get; set; } + /// + /// 权限ID + /// + public long PermissionId { get; set; } + /// + /// 权限实体 + /// + public string PermissionEntity { get; set; }= ""; + + /// + /// 名称 + /// + public string SequenceName { get; set; }= ""; + /// + /// 分隔符 + /// + public string SequenceDelimiter { get; set; }= ""; + + /// + /// 序号重置规则 + /// + public string SequenceReset { get; set; } = ""; + + /// + /// 步长 + /// + public int Step { get; set; } = 0; + /// + /// 当前值 + /// + public int CurrentNo { get; set; }= 0; + /// + /// 当前编码 + /// + public string CurrentCode { get; set; }= ""; + /// + /// 当前重置依赖,即最后一次获取编码的日期 + /// + public string CurrentReset { get; set; }= ""; + + /// + /// 状态 0 启用 1 禁用 + /// + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 备注 + /// + public string Note { get; set; } = ""; + /// + /// 排序 + /// + public int? OrderNo { get; set; } = 100; + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRuleReq.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRuleReq.cs new file mode 100644 index 00000000..ad7c7265 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRuleReq.cs @@ -0,0 +1,71 @@ +using DS.Module.Core; +using FluentValidation; + +namespace DS.WMS.Core.Code.Dtos; + +/// +/// 基础编码规则请求实体 +/// +public class CodeSequenceRuleReq +{ + /// + /// 主键Id + /// + public long Id { get; set; } + /// + /// 单据Id + /// + public long SequenceId { get; set; } + + /// + /// 取规则类别,timestamp、const、number + /// + public string RuleType { get; set; } + /// + /// 规则参数,如 YYMMDD + /// + public string RuleValue { get; set; } + /// + /// 补齐方向,left或right + /// + public string PaddingSide { get; set; } + /// + /// 补齐宽度 + /// + public int PaddingWidth { get; set; } + /// + /// 填充字符 + /// + public string PaddingChar { get; set; } + /// + /// 排序 + /// + public int? OrderNo { get; set; } = 100; + + /// + /// 状态 0 启用 1 禁用 + /// + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 备注 + /// + public string Note { get; set; } = ""; +} + + +/// +/// 验证 +/// +public class CodeSequenceRuleReqValidator : AbstractValidator +{ + /// + /// 构造函数 + /// + public CodeSequenceRuleReqValidator() + { + this.RuleFor(o => o.RuleType) + .NotEmpty().WithName("取规则类别"); + this.RuleFor(o => o.RuleValue) + .NotEmpty().WithName("规则参数"); + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRuleRes.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRuleRes.cs new file mode 100644 index 00000000..cd82d562 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeSequenceRuleRes.cs @@ -0,0 +1,57 @@ +using DS.Module.Core; + +namespace DS.WMS.Core.Code.Dtos; + +/// +/// 基础编码规则返回实体 +/// +public class CodeSequenceRuleRes +{ + /// + /// 主键Id + /// + public long Id { get; set; } + /// + /// 单据Id + /// + public long SequenceId { get; set; } + + /// + /// 取规则类别,timestamp、const、number + /// + public string RuleType { get; set; } + /// + /// 规则参数,如 YYMMDD + /// + public string RuleValue { get; set; } + /// + /// 补齐方向,left或right + /// + public string PaddingSide { get; set; } + /// + /// 补齐宽度 + /// + public int PaddingWidth { get; set; } + /// + /// 填充字符 + /// + public string PaddingChar { get; set; } + + /// + /// 状态 0 启用 1 禁用 + /// + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 备注 + /// + public string Note { get; set; } = ""; + /// + /// 排序 + /// + public int? OrderNo { get; set; } = 100; + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeSequence.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeSequence.cs new file mode 100644 index 00000000..7f330f03 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeSequence.cs @@ -0,0 +1,75 @@ +using DS.Module.Core; +using DS.Module.Core.Data; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DS.WMS.Core.Code.Entity +{ + /// + /// 基础编码表 + /// + [SqlSugar.SugarTable("code_sequence", "基础编码表")] + public class CodeSequence : BaseOrgModel + { + /// + /// 权限ID + /// + [SugarColumn(ColumnDescription = "权限ID")] + public long PermissionId { get; set; } + /// + /// 权限实体 + /// + [SugarColumn(ColumnDescription = "权限实体",Length = 50)] + public string PermissionEntity { get; set; } + + /// + /// 名称 + /// + [SugarColumn(ColumnDescription = "名称", Length = 50)] + public string SequenceName { get; set; } + /// + /// 分隔符 + /// + [SugarColumn(ColumnDescription = "分隔符", Length = 50,IsNullable = true)] + public string SequenceDelimiter { get; set; } + /// + /// 序号重置规则 + /// + [SugarColumn(ColumnDescription = "分隔符", Length = 100, IsNullable = true)] + public string SequenceReset { get; set; } + /// + /// 步长 + /// + [SugarColumn(ColumnDescription = "步长", DefaultValue ="1")] + public int Step { get; set; } + /// + /// 当前值 + /// + [SugarColumn(ColumnDescription = "当前值")] + public int CurrentNo { get; set; } + /// + /// 当前编码 + /// + [SugarColumn(ColumnDescription = "当前编码", Length = 100, IsNullable = true)] + public string CurrentCode { get; set; } + /// + /// 当前重置依赖,即最后一次获取编码的日期 + /// + [SugarColumn(ColumnDescription = "当前重置依赖", Length = 100, IsNullable = true)] + public string CurrentReset { get; set; } + /// + /// 状态 + /// + [SqlSugar.SugarColumn(ColumnDescription = "状态")] + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 排序号 + /// + [SugarColumn(ColumnDescription = "排序号",DefaultValue ="100")] + public int OrderNo { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeSequenceRule.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeSequenceRule.cs new file mode 100644 index 00000000..a42ebe0e --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeSequenceRule.cs @@ -0,0 +1,60 @@ +using DS.Module.Core; +using DS.Module.Core.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; + +namespace DS.WMS.Core.Code.Entity +{ + /// + /// 基础编码规则表 + /// + [SqlSugar.SugarTable("code_sequence_rule", "基础编码规则表")] + public class CodeSequenceRule : BaseModel + { + /// + /// 单据Id + /// + [SugarColumn(ColumnDescription = "单据Id")] + public long SequenceId { get; set; } + + /// + /// 取规则类别,timestamp、const、number + /// + [SugarColumn(ColumnDescription = "取规则类别", Length = 100, IsNullable = false)] + public string RuleType { get; set; } + /// + /// 规则参数,如 YYMMDD + /// + [SugarColumn(ColumnDescription = "补齐方向", Length = 100, IsNullable = false)] + public string RuleValue { get; set; } + /// + /// 补齐方向,left或right + /// + [SugarColumn(ColumnDescription = "补齐方向", Length = 50, IsNullable = true)] + public string PaddingSide { get; set; } + /// + /// 补齐宽度 + /// + [SugarColumn(ColumnDescription = "补齐宽度")] + public int PaddingWidth { get; set; } + /// + /// 填充字符 + /// + [SugarColumn(ColumnDescription = "填充字符", Length = 100, IsNullable = true)] + public string PaddingChar { get; set; } + /// + /// 状态 + /// + [SqlSugar.SugarColumn(ColumnDescription = "状态")] + public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 排序号 + /// + [SugarColumn(ColumnDescription = "排序号",DefaultValue ="100")] + public int OrderNo { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeSequenceRuleService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeSequenceRuleService.cs new file mode 100644 index 00000000..acf8f04a --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeSequenceRuleService.cs @@ -0,0 +1,31 @@ +using DS.Module.Core; +using DS.WMS.Core.Code.Dtos; +using DS.WMS.Core.Sys.Dtos; +using DS.WMS.Core.Sys.Entity; + +namespace DS.WMS.Core.Code.Interface; + +public interface ICodeSequenceRuleService +{ + /// + /// 列表 + /// + /// + /// + DataResult> GetListByPage(PageRequest request); + + + /// + /// 编辑 + /// + /// + /// + DataResult EditSequenceRule(CodeSequenceRuleReq model); + + /// + /// 获取详情 + /// + /// + /// + DataResult GetSequenceRuleInfo(string id); +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeSequenceService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeSequenceService.cs new file mode 100644 index 00000000..e19a2061 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeSequenceService.cs @@ -0,0 +1,31 @@ +using DS.Module.Core; +using DS.WMS.Core.Code.Dtos; +using DS.WMS.Core.Sys.Dtos; +using DS.WMS.Core.Sys.Entity; + +namespace DS.WMS.Core.Code.Interface; + +public interface ICodeSequenceService +{ + /// + /// 列表 + /// + /// + /// + DataResult> GetListByPage(PageRequest request); + + + /// + /// 编辑 + /// + /// + /// + DataResult EditSequence(CodeSequenceReq model); + + /// + /// 获取详情 + /// + /// + /// + DataResult GetSequenceInfo(string id); +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceRuleService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceRuleService.cs new file mode 100644 index 00000000..487d360c --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceRuleService.cs @@ -0,0 +1,95 @@ +using DS.Module.Core; +using DS.Module.Core.Extensions; +using DS.Module.UserModule; +using DS.WMS.Core.Code.Interface; +using DS.WMS.Core.Sys.Dtos; +using DS.WMS.Core.Sys.Entity; +using DS.WMS.Core.Sys.Interface; +using Mapster; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using DS.Module.SqlSugar; +using DS.WMS.Core.Code.Dtos; +using DS.WMS.Core.Code.Entity; +namespace DS.WMS.Core.Code.Method; + +public class CodeSequenceRuleService : ICodeSequenceRuleService +{ + private readonly IServiceProvider _serviceProvider; + private readonly ISqlSugarClient db; + private readonly IUser user; + private readonly ISaasDbService saasService; + /// + /// + /// + /// + public CodeSequenceRuleService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); + } + + /// + /// 列表 + /// + /// + /// + public DataResult> GetListByPage(PageRequest request) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + //序列化查询条件 + var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); + var data = tenantDb.Queryable() + .Where(whereList) + .Select().ToQueryPage(request.PageCondition); + return data; + } + /// + /// 编辑 + /// + /// + /// + public DataResult EditSequenceRule(CodeSequenceRuleReq req) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + if (req.Id == 0) + { + + if (tenantDb.Queryable().Where(x=>x.SequenceId == req.SequenceId && x.RuleType == req.RuleType).Any()) + { + return DataResult.Failed("基础编码规则已存在!",MultiLanguageConst.SequenceRuleExist); + } + + var data = req.Adapt(); + + var entity = tenantDb.Insertable(data).ExecuteReturnEntity(); + + return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess); + } + else + { + var info = tenantDb.Queryable().Where(x => x.Id == req.Id).First(); + + info = req.Adapt(info); + + tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); + return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess); + } + } + /// + /// 详情 + /// + /// + /// + public DataResult GetSequenceRuleInfo(string id) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + var data = tenantDb.Queryable() + .Where(a => a.Id == long.Parse(id)) + .Select() + .First(); + return DataResult.Success(data,MultiLanguageConst.DataQuerySuccess); + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceService.cs new file mode 100644 index 00000000..d83570fb --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeSequenceService.cs @@ -0,0 +1,97 @@ +using DS.Module.Core; +using DS.Module.Core.Extensions; +using DS.Module.SqlSugar; +using DS.Module.UserModule; +using DS.WMS.Core.Code.Dtos; +using DS.WMS.Core.Code.Entity; +using DS.WMS.Core.Code.Interface; +using DS.WMS.Core.Sys.Entity; +using Mapster; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; + +namespace DS.WMS.Core.Code.Method; + +public class CodeSequenceService : ICodeSequenceService +{ + private readonly IServiceProvider _serviceProvider; + private readonly ISqlSugarClient db; + private readonly IUser user; + private readonly ISaasDbService saasService; + /// + /// + /// + /// + public CodeSequenceService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); + } + + /// + /// 列表 + /// + /// + /// + public DataResult> GetListByPage(PageRequest request) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + //序列化查询条件 + var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); + var data = tenantDb.Queryable() + .LeftJoin((a, b) => a.PermissionId == b.Id) + .Where(whereList) + .Select().ToQueryPage(request.PageCondition); + return data; + } + /// + /// 编辑 + /// + /// + /// + public DataResult EditSequence(CodeSequenceReq req) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + if (req.Id == 0) + { + + if (tenantDb.Queryable().Where(x => x.PermissionId == req.PermissionId && x.OrderNo == req.OrderNo).Any()) + { + return DataResult.Failed("基础编码已存在!", MultiLanguageConst.SequenceExist); + } + + var data = req.Adapt(); + + var entity = tenantDb.Insertable(data).ExecuteReturnEntity(); + + return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess); + } + else + { + var info = tenantDb.Queryable().Where(x => x.Id == req.Id).First(); + + info = req.Adapt(info); + + tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); + return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); + } + } + /// + /// 详情 + /// + /// + /// + public DataResult GetSequenceInfo(string id) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + var data = tenantDb.Queryable() + .LeftJoin((a, b) => a.PermissionId == b.Id) + .Where(a => a.Id == long.Parse(id)) + .Select() + .First(); + return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess); + } + +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeSequenceController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeSequenceController.cs new file mode 100644 index 00000000..86dc98cb --- /dev/null +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeSequenceController.cs @@ -0,0 +1,105 @@ +using DS.Module.Core; +using DS.WMS.Core.Code.Dtos; +using DS.WMS.Core.Code.Interface; +using DS.WMS.Core.Sys.Dtos; +using DS.WMS.Core.Sys.Entity; +using DS.WMS.Core.Sys.Interface; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace DS.WMS.MainApi.Controllers; +/// +/// 基础编码模块 +/// +public class CodeSequenceController : ApiController +{ + private readonly ICodeSequenceService _invokeService; + private readonly ICodeSequenceRuleService _sequenceRuleService; + /// + /// 构造函数 + /// + /// + public CodeSequenceController(ICodeSequenceService invokeService, ICodeSequenceRuleService 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] CodeSequenceReq 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] CodeSequenceRuleReq 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