租户端基础编码规则
parent
0d96551453
commit
b229901c96
@ -0,0 +1,85 @@
|
||||
using DS.Module.Core;
|
||||
using FluentValidation;
|
||||
|
||||
namespace DS.WMS.Core.Code.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 基础编码请求实体
|
||||
/// </summary>
|
||||
public class CodeSequenceReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 权限ID
|
||||
/// </summary>
|
||||
public long PermissionId { get; set; }
|
||||
/// <summary>
|
||||
/// 权限实体
|
||||
/// </summary>
|
||||
public string PermissionEntity { get; set; }= "";
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string SequenceName { get; set; }= "";
|
||||
/// <summary>
|
||||
/// 分隔符
|
||||
/// </summary>
|
||||
public string SequenceDelimiter { get; set; }= "";
|
||||
|
||||
/// <summary>
|
||||
/// 序号重置规则
|
||||
/// </summary>
|
||||
public string SequenceReset { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 步长
|
||||
/// </summary>
|
||||
public int Step { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 当前值
|
||||
/// </summary>
|
||||
public int CurrentNo { get; set; }= 0;
|
||||
/// <summary>
|
||||
/// 当前编码
|
||||
/// </summary>
|
||||
public string CurrentCode { get; set; }= "";
|
||||
/// <summary>
|
||||
/// 当前重置依赖,即最后一次获取编码的日期
|
||||
/// </summary>
|
||||
public string CurrentReset { 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 CodeSequenceReqValidator : AbstractValidator<CodeSequenceReq>
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CodeSequenceReqValidator()
|
||||
{
|
||||
this.RuleFor(o => o.PermissionId)
|
||||
.NotEmpty().WithName("权限模块Id");
|
||||
this.RuleFor(o => o.SequenceName)
|
||||
.NotEmpty().WithName("名称");
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
using DS.Module.Core;
|
||||
|
||||
namespace DS.WMS.Core.Code.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 基础编码返回实体
|
||||
/// </summary>
|
||||
public class CodeSequenceRes
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 权限ID
|
||||
/// </summary>
|
||||
public long PermissionId { get; set; }
|
||||
/// <summary>
|
||||
/// 权限实体
|
||||
/// </summary>
|
||||
public string PermissionEntity { get; set; }= "";
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string SequenceName { get; set; }= "";
|
||||
/// <summary>
|
||||
/// 分隔符
|
||||
/// </summary>
|
||||
public string SequenceDelimiter { get; set; }= "";
|
||||
|
||||
/// <summary>
|
||||
/// 序号重置规则
|
||||
/// </summary>
|
||||
public string SequenceReset { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 步长
|
||||
/// </summary>
|
||||
public int Step { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 当前值
|
||||
/// </summary>
|
||||
public int CurrentNo { get; set; }= 0;
|
||||
/// <summary>
|
||||
/// 当前编码
|
||||
/// </summary>
|
||||
public string CurrentCode { get; set; }= "";
|
||||
/// <summary>
|
||||
/// 当前重置依赖,即最后一次获取编码的日期
|
||||
/// </summary>
|
||||
public string CurrentReset { 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 DateTime CreateTime { get; set; }
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<List<CodeSequenceRuleRes>> GetListByPage(PageRequest request);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
DataResult EditSequenceRule(CodeSequenceRuleReq model);
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<CodeSequenceRuleRes> GetSequenceRuleInfo(string id);
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<List<CodeSequenceRes>> GetListByPage(PageRequest request);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
DataResult EditSequence(CodeSequenceReq model);
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<CodeSequenceRes> GetSequenceInfo(string id);
|
||||
}
|
@ -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;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
public CodeSequenceRuleService(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<CodeSequenceRuleRes>> GetListByPage(PageRequest request)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
//序列化查询条件
|
||||
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||||
var data = tenantDb.Queryable<CodeSequenceRule>()
|
||||
.Where(whereList)
|
||||
.Select<CodeSequenceRuleRes>().ToQueryPage(request.PageCondition);
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult EditSequenceRule(CodeSequenceRuleReq req)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
if (req.Id == 0)
|
||||
{
|
||||
|
||||
if (tenantDb.Queryable<CodeSequenceRule>().Where(x=>x.SequenceId == req.SequenceId && x.RuleType == req.RuleType).Any())
|
||||
{
|
||||
return DataResult.Failed("基础编码规则已存在!",MultiLanguageConst.SequenceRuleExist);
|
||||
}
|
||||
|
||||
var data = req.Adapt<CodeSequenceRule>();
|
||||
|
||||
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
||||
|
||||
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
var info = tenantDb.Queryable<CodeSequenceRule>().Where(x => x.Id == req.Id).First();
|
||||
|
||||
info = req.Adapt(info);
|
||||
|
||||
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<CodeSequenceRuleRes> GetSequenceRuleInfo(string id)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
var data = tenantDb.Queryable<CodeSequenceRule>()
|
||||
.Where(a => a.Id == long.Parse(id))
|
||||
.Select<CodeSequenceRuleRes>()
|
||||
.First();
|
||||
return DataResult<CodeSequenceRuleRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
|
||||
}
|
||||
}
|
@ -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;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
public CodeSequenceService(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<CodeSequenceRes>> GetListByPage(PageRequest request)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
//序列化查询条件
|
||||
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||||
var data = tenantDb.Queryable<CodeSequence>()
|
||||
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
||||
.Where(whereList)
|
||||
.Select<CodeSequenceRes>().ToQueryPage(request.PageCondition);
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult EditSequence(CodeSequenceReq req)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
if (req.Id == 0)
|
||||
{
|
||||
|
||||
if (tenantDb.Queryable<CodeSequence>().Where(x => x.PermissionId == req.PermissionId && x.OrderNo == req.OrderNo).Any())
|
||||
{
|
||||
return DataResult.Failed("基础编码已存在!", MultiLanguageConst.SequenceExist);
|
||||
}
|
||||
|
||||
var data = req.Adapt<CodeSequence>();
|
||||
|
||||
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
||||
|
||||
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
var info = tenantDb.Queryable<CodeSequence>().Where(x => x.Id == req.Id).First();
|
||||
|
||||
info = req.Adapt(info);
|
||||
|
||||
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<CodeSequenceRes> GetSequenceInfo(string id)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
var data = tenantDb.Queryable<CodeSequence>()
|
||||
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
||||
.Where(a => a.Id == long.Parse(id))
|
||||
.Select<CodeSequenceRes>()
|
||||
.First();
|
||||
return DataResult<CodeSequenceRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue