diff --git a/ds-wms-service/DS.Module.Nuget/DS.Module.Nuget.csproj b/ds-wms-service/DS.Module.Nuget/DS.Module.Nuget.csproj
index 1f8b316c..f92bcd85 100644
--- a/ds-wms-service/DS.Module.Nuget/DS.Module.Nuget.csproj
+++ b/ds-wms-service/DS.Module.Nuget/DS.Module.Nuget.csproj
@@ -21,6 +21,8 @@
+
+
@@ -28,6 +30,8 @@
+
+
diff --git a/ds-wms-service/DS.Module.SqlSugar/DS.Module.SqlSugar.csproj b/ds-wms-service/DS.Module.SqlSugar/DS.Module.SqlSugar.csproj
index 4dcf551b..b082e67c 100644
--- a/ds-wms-service/DS.Module.SqlSugar/DS.Module.SqlSugar.csproj
+++ b/ds-wms-service/DS.Module.SqlSugar/DS.Module.SqlSugar.csproj
@@ -7,7 +7,7 @@
-
+
@@ -17,4 +17,6 @@
+
+
diff --git a/ds-wms-service/DS.Module.SqlSugar/Ds_Repository.cs b/ds-wms-service/DS.Module.SqlSugar/Ds_Repository.cs
deleted file mode 100644
index 1e8f52cc..00000000
--- a/ds-wms-service/DS.Module.SqlSugar/Ds_Repository.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Microsoft.Extensions.Configuration;
-using SqlSugar;
-using System.Configuration;
-
-namespace DS.Module.SqlSugar
-{
- public class Ds_Repository where T : class, new()
- {
- private readonly ISqlSugarClient _sqlSugarClient;
- private readonly IConfiguration _configuration;
- public Ds_Repository(IConfiguration _configuration)
- {
- var connectionConfig = new ConnectionConfig
- {
- ConnectionString = _configuration.GetConnectionString("YourConnectionStringName"), // 这里替换为你的连接字符串
- DbType = DbType.SqlServer, // 数据库类型
- IsAutoCloseConnection = true, // 自动释放数据务,如果存在事务,在事务结束后释放
- InitKeyType = InitKeyType.Attribute // 从实体特性中读取主键自增列信息
- };
- _sqlSugarClient = new SqlSugarClient(connectionConfig);
- }
-
- public List GetAll()
- {
- return _sqlSugarClient.Queryable().ToList();
- }
-
- }
-}
diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlSugarAppStartup.cs b/ds-wms-service/DS.Module.SqlSugar/SqlSugarAppStartup.cs
index f384e65f..1d3664a6 100644
--- a/ds-wms-service/DS.Module.SqlSugar/SqlSugarAppStartup.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/SqlSugarAppStartup.cs
@@ -1,22 +1,23 @@
using Ds.Module.AppStartup;
-using Microsoft.Extensions.DependencyInjection;
-
+using Microsoft.AspNetCore.Builder;
namespace DS.Module.SqlSugar
{
- public class SqlSugarAppStartup : Ds_StartupAttribute
+
+ [DsStartup(7)]
+ public class SqlSugarAppStartup : IDynamicStartup
{
- public void ConfigureServices(IServiceCollection services)
+
+ public void Configure(WebApplication app)
{
- // 配置服务
- // 其他服务配置...
}
- public void Configure(object app)
+ public void ConfigureServices(WebApplicationBuilder builder)
{
- // 配置中间件
- // 其他中间件配置...
+ builder.Services.AddSqlsugarInstall();
}
+
+
}
}
diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
index bb241ec3..39e590e0 100644
--- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs
@@ -1,13 +1,11 @@
using DS.Module.Core;
+using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.UserModule;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using SqlSugar;
using System.Linq.Dynamic.Core;
-using System.Linq.Expressions;
-using System.Reflection;
-using DS.Module.Core.Data;
using LogLevel = NLog.LogLevel;
namespace DS.Module.SqlSugar;
@@ -153,15 +151,15 @@ public static class SqlsugarInstall
{
if (entityInfo.PropertyName == "UpdateTime")
entityInfo.SetValue(DateTime.Now);
- if (entityInfo.PropertyName == "UpdateBy" && !user.UserId.IsNullOrEmpty())
- entityInfo.SetValue(user.UserId);
+ if (entityInfo.PropertyName == "UpdateBy" && user != null)
+ entityInfo.SetValue(user.UserId);
}
};
dbProvider.Aop.OnError = (exp) => //执行SQL 错误事件
{
Logger.Error(DateTime.Now.ToString() + "\r\n" + exp.Sql + "\r\n" + exp.Parametres);
};
- //全局过滤租户Id
+
dbProvider.QueryFilter.AddTableFilter(m => m.TenantId == user.GetTenantId());
//全局软删除过滤
dbProvider.QueryFilter.AddTableFilter(m => m.Deleted == false);
diff --git a/ds-wms-service/DS.WMS.Core/System/Method/PermissionService.cs b/ds-wms-service/DS.WMS.Core/System/Method/PermissionService.cs
index bcf596d3..626ebe64 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/PermissionService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/PermissionService.cs
@@ -326,4 +326,6 @@ public class PermissionService : IPermissionService
}
return DataResult.Successed("更新成功!");
}
+
+
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/System/Method/UserService.cs b/ds-wms-service/DS.WMS.Core/System/Method/UserService.cs
index 8eeef8cf..43b2e2b9 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/UserService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/UserService.cs
@@ -93,7 +93,7 @@ public class UserService : IUserService
// data.CompanyId = "Comcab2d43f60454327af30a131fc1d3abd";
//data.GID = Guid.NewGuid();
-
+
var entity = db.Insertable(data).ExecuteReturnEntity();
if (model.RoleIds.Count() > 0)
@@ -126,7 +126,7 @@ public class UserService : IUserService
var existRoles = db.Queryable().Where(x => x.UserId == userId).Select(n => n.RoleId)
.ToArray();
-
+
IEnumerable delRoles = existRoles.AsQueryable().Except(model.RoleIds);
if (delRoles.Count() > 0)
{
@@ -134,7 +134,7 @@ public class UserService : IUserService
.Where(it => it.UserId == userId && delRoles.Contains(it.RoleId))
.ExecuteCommand();
}
-
+
IEnumerable addRoles = model.RoleIds.AsQueryable().Except(existRoles);
if (addRoles.Count() > 0)
{
diff --git a/ds-wms-service/DS.WMS.FinanceApi/Controllers/CostExchangeRateController.cs b/ds-wms-service/DS.WMS.FinanceApi/Controllers/CostExchangeRateController.cs
index 3c6387c1..5be37f9e 100644
--- a/ds-wms-service/DS.WMS.FinanceApi/Controllers/CostExchangeRateController.cs
+++ b/ds-wms-service/DS.WMS.FinanceApi/Controllers/CostExchangeRateController.cs
@@ -7,13 +7,12 @@
[ApiController]
public class CostExchangeRateController : DsBaseController
{
-
///
- /// Get
+ /// 根据ID查询汇率基本信息
///
///
[HttpGet("GetCostBasic")]
- public async Task GetCostBasic(Guid id)
+ public async Task GetCostBasic(long id)
{
var getUserQuery = new CostExchangeRateCommand { Id = id };
@@ -21,5 +20,28 @@
return Ok(result);
}
+ ///
+ /// 根据ID删除或者禁用相关的币别
+ ///
+ ///
+ [HttpGet("DelCostBasic")]
+ public async Task DelCostBasic(long id)
+ {
+ var getUserQuery = new CostExchangeForDelCommand { Id = id };
+
+ var result = await Mediator.Send(getUserQuery);
+
+ return Ok(result);
+ }
+ ///
+ /// 币别添加
+ ///
+ ///
+ [HttpPost("AddForCostBasic")]
+ public async Task AddForCostBasic(CostExchangeForAddCommand dto)
+ {
+ var result = await Mediator.Send(dto);
+ return Ok(result);
+ }
}
}
diff --git a/ds-wms-service/DS.WMS.FinanceApi/DS.WMS.FinanceApi.csproj b/ds-wms-service/DS.WMS.FinanceApi/DS.WMS.FinanceApi.csproj
index 0a6b1268..e9d271a6 100644
--- a/ds-wms-service/DS.WMS.FinanceApi/DS.WMS.FinanceApi.csproj
+++ b/ds-wms-service/DS.WMS.FinanceApi/DS.WMS.FinanceApi.csproj
@@ -14,13 +14,7 @@
-
-
-
-
-
-
-
+
diff --git a/ds-wms-service/DS.WMS.FinanceApi/Program.cs b/ds-wms-service/DS.WMS.FinanceApi/Program.cs
index 47f7e47e..a2c90a41 100644
--- a/ds-wms-service/DS.WMS.FinanceApi/Program.cs
+++ b/ds-wms-service/DS.WMS.FinanceApi/Program.cs
@@ -1,32 +1,18 @@
+using Ds.WMS.WebCore;
using Microsoft.OpenApi.Models;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
+
+
+
// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddControllers();
+// ʹչ Startup
-//// ע SqlSugarClient
-builder.Services.AddScoped(provider =>
-{
- var connectionConfig = new SqlSugar.ConnectionConfig
- {
- ConnectionString = builder.Configuration.GetConnectionString("YourConnectionStringName"), // 滻Ϊַ
- DbType = SqlSugar.DbType.MySql, // ݿ
- IsAutoCloseConnection = true, // Զͷͷ
- InitKeyType = SqlSugar.InitKeyType.Attribute // ʵжȡϢ
- };
- var sqlSugarClient = new SqlSugar.SqlSugarClient(connectionConfig);
- return sqlSugarClient;
-});
-// ע MediatR
-var assembly = AppDomain.CurrentDomain.Load("Ds.WMS.Finance.MediatR");
-builder.Services.AddMediatR(c =>
-{
- c.RegisterServicesFromAssembly(assembly);
-});
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
@@ -34,10 +20,13 @@ builder.Services.AddSwaggerGen(c =>
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
+// ʹö̬
+builder.UseDynamicStartups();
-//builder.Services.AddMediatR(Assembly.GetExecutingAssembly());
var app = builder.Build();
+app.UseDynamicStartups();
+
// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
@@ -47,6 +36,7 @@ var app = builder.Build();
// м Swagger Ϊ JSON ս
app.UseSwagger();
+
// м swagger-uiָ Swagger JSON ս
app.UseSwaggerUI(c =>
{
diff --git a/ds-wms-service/DS.WMS.FinanceApi/appsettings.json b/ds-wms-service/DS.WMS.FinanceApi/appsettings.json
index 3059e92f..a763830c 100644
--- a/ds-wms-service/DS.WMS.FinanceApi/appsettings.json
+++ b/ds-wms-service/DS.WMS.FinanceApi/appsettings.json
@@ -5,6 +5,23 @@
"Microsoft.AspNetCore": "Warning"
}
},
- "AllowedHosts": "*"
-
+ "AllowedHosts": "*",
+ "ConnectionStrings": {
+ "testConnection": "server=60.209.125.238;port=32006;uid=root;pwd=Djy@Mysql.test;database=shippingweb8_dev"
+ },
+ "DBInfo": {
+ "DefaultDbConnId": "1288018625843826688",
+ "DefaultDbType": 0,
+ "DefaultDbString": "server=60.209.125.238;port=32006;uid=root;pwd=Djy@Mysql.test;database=shippingweb8_dev",
+ "DBS": [
+ {
+ "ConnId": "1595354960864874496",
+ "DBType": 1,
+ "Enabled": false,
+ "HitRate": 40,
+ "Connection": "Data Source=47.105.193.36,11435;Initial Catalog=SHIPPINGWEB_JNHJ;Integrated Security=False;Connect Timeout=500;User ID=sa;Password=Ds20040201",
+ "ProviderName": "System.Data.SqlClient"
+ }
+ ]
+ }
}
diff --git a/ds-wms-service/Ds.Module.AppStartup/DsStartupAttribute.cs b/ds-wms-service/Ds.Module.AppStartup/DsStartupAttribute.cs
new file mode 100644
index 00000000..e2dd8f5a
--- /dev/null
+++ b/ds-wms-service/Ds.Module.AppStartup/DsStartupAttribute.cs
@@ -0,0 +1,18 @@
+namespace Ds.Module.AppStartup
+{
+ ///
+ ///
+ ///
+ [AttributeUsage(AttributeTargets.Class)]
+ public class DsStartupAttribute : Attribute
+ {
+ public int Order { get; set; }
+
+ public DsStartupAttribute(int order)
+ {
+ Order = order;
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/ds-wms-service/Ds.Module.AppStartup/Ds_StartupAttribute.cs b/ds-wms-service/Ds.Module.AppStartup/Ds_StartupAttribute.cs
deleted file mode 100644
index 5637f2f5..00000000
--- a/ds-wms-service/Ds.Module.AppStartup/Ds_StartupAttribute.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-using System.Reflection;
-
-namespace Ds.Module.AppStartup
-{
- ///
- ///
- ///
- [AttributeUsage(AttributeTargets.Class)]
- public class Ds_StartupAttribute : Attribute
- { }
-
- public interface IDs_App_Startup
- {
- void ConfigureServices(IServiceCollection services);
-
- void Configure(object app);
- }
-
- ///
- ///
- ///
- public static class Ds_App_Startup
- {
- public static void Run()
- {
- try
- {
- var startupTypes = Assembly.GetCallingAssembly().GetTypes()
- .Where(type => type.GetCustomAttribute() != null);
-
- var services = new ServiceCollection();
-
- foreach (var startupType in startupTypes)
- {
- var startupInstance = Activator.CreateInstance(startupType) as IDs_App_Startup;
- startupInstance?.ConfigureServices(services);
- }
-
- // 构建 IServiceProvider
-
- var serviceProvider = services.BuildServiceProvider();
-
- foreach (var startupType in startupTypes)
- {
- var startupInstance = Activator.CreateInstance(startupType);
- var configureMethod = startupType.GetMethod("Configure");
-
- if (configureMethod != null)
- {
- configureMethod.Invoke(startupInstance, new[] { serviceProvider });
- }
- }
- }
- catch (Exception ex)
- {
- // 友好的错误消息和日志记录
- Console.WriteLine($"An error occurred: {ex.Message}");
- // 日志记录
- // Logger.LogError(ex, "An error occurred during startup.");
- }
- }
- }
-
- //// 示例启动类
- //[MyFrameworkStartup]
- //public class MyFrameworkStartup : IMyFrameworkStartup
- //{
- // public void ConfigureServices(IServiceCollection services)
- // {
- // // 配置服务
- // services.AddTransient();
- // // 其他服务配置...
- // }
-
- // public void Configure(object app)
- // {
- // // 配置中间件
- // // 其他中间件配置...
- // }
- //}
-
- // 示例服务
- //public interface IMyService
- //{
- // void DoSomething();
- //}
-
- //public class MyService : IMyService
- //{
- // public void DoSomething()
- // {
- // Console.WriteLine("Doing something...");
- // }
- //}
-
- //internal class Program
- //{
- // private static void Main()
- // {
- // MyFramework.Run();
- // }
- //}
-}
\ No newline at end of file
diff --git a/ds-wms-service/Ds.Module.AppStartup/IDynamicStartup.cs b/ds-wms-service/Ds.Module.AppStartup/IDynamicStartup.cs
new file mode 100644
index 00000000..2db8f867
--- /dev/null
+++ b/ds-wms-service/Ds.Module.AppStartup/IDynamicStartup.cs
@@ -0,0 +1,9 @@
+using Microsoft.AspNetCore.Builder;
+namespace Ds.Module.AppStartup
+{
+ public interface IDynamicStartup
+ {
+ void ConfigureServices(WebApplicationBuilder builder);
+ void Configure(WebApplication app);
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/Ds.Modules.DsEntity/Base/BasEntity.cs b/ds-wms-service/Ds.Modules.DsEntity/Base/BasEntity.cs
index ad89cabc..ceeacf0e 100644
--- a/ds-wms-service/Ds.Modules.DsEntity/Base/BasEntity.cs
+++ b/ds-wms-service/Ds.Modules.DsEntity/Base/BasEntity.cs
@@ -1,5 +1,4 @@
-using System.ComponentModel;
-using SqlSugar;
+using SqlSugar;
namespace Ds.Modules.DsEntity.Base
{
@@ -8,63 +7,64 @@ namespace Ds.Modules.DsEntity.Base
///
/// 备注
///
- [Description("备注")]
- [SugarColumn(ColumnDataType = "300")]
- public string DsNote { get; set; }
+
+ [SqlSugar.SugarColumn(ColumnDescription = "备注")]
+ public string? DsNote { get; set; } = "0qaqq";
///
/// 创建时间
///
- [Description("创建时间")]
- [SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间", InsertServerTime = true)]
- public DateTime DsAddTime { get; set; }
+
+ [SqlSugar.SugarColumn(ColumnDescription = "创建时间")]
+ public DateTime DsAddTime { get; set; } = DateTime.Now;
///
/// 创建人
///
- [Description("创建人")]
- [SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "创建人")]
- public string DsAddUserInfo { get; set; }
+
+ [SqlSugar.SugarColumn(ColumnDescription = "创建人")]
+ public string? DsAddUserInfo { get; set; } = "admin";
///
/// 修改人
///
- [Description("修改人")]
- [SqlSugar.SugarColumn(IsNullable = true, ColumnDescription = "修改人")]
- public string DsUpdateUserInfo { get; set; }
+
+ [SqlSugar.SugarColumn(ColumnDescription = "修改人")]
+ public string? DsUpdateUserInfo { get; set; } = "admin";
///
/// 更新时间
///
- [Description("更新时间")]
- [SqlSugar.SugarColumn(ColumnDescription = "更新时间", UpdateServerTime = true)]
- public DateTime DsUpdateTime { get; set; }
+
+ [SqlSugar.SugarColumn(ColumnDescription = "更新时间")]
+ public DateTime DsUpdateTime { get; set; } = DateTime.Now;
///
/// 删除
///
- [Description("删除")]
+
[SqlSugar.SugarColumn(ColumnDescription = "是否删除")]
public bool DsIsDel { get; set; } = false;
///
/// 删除时间
///
- [Description("删除时间")]
+
[SqlSugar.SugarColumn(ColumnDescription = "删除时间")]
public DateTime DsDeleteTime { get; set; } = DateTime.Now;
///
/// 删除人
///
- [Description("删除人")]
- [SqlSugar.SugarColumn(IsNullable = true, ColumnDescription = "删除人")]
- public string DsDeleteUserInfo { get; set; }
+
+ [SqlSugar.SugarColumn(ColumnDescription = "删除人")]
+ public string? DsDeleteUserInfo { get; set; } = "admin";
///
/// 排序
///
- public int DsSort { get; set; }
+ [SqlSugar.SugarColumn(ColumnDescription = "排序")]
+ public int DsSort { get; set; } = 0;
}
///
@@ -142,16 +142,23 @@ namespace Ds.Modules.DsEntity.Base
///
public abstract class BaseEntityGuid : BaseComEntity
{
+ public BaseEntityGuid()
+ {
+ var worker = new Snowflake.Core.IdWorker(1, 1);
+ Id = worker.NextId();
+ }
+
///
/// 主键ID
///
[Description("主键ID")]
- [SugarColumn(IsPrimaryKey = true, Length = 100, ColumnDescription = "主键ID")]
- public Guid Id { get; set; } = Guid.NewGuid();
+ [SqlSugar.SugarColumn(IsPrimaryKey = true, Length = 100, ColumnDescription = "主键ID")]
+ public long Id { get; set; }
///
/// 租户编号
///
- public string TenantNumber { get; set; }
+ [SqlSugar.SugarColumn(ColumnDescription = "租户编号")]
+ public long TenantNumber { get; set; }
}
}
\ No newline at end of file
diff --git a/ds-wms-service/Ds.Modules.DsEntity/Ds.Modules.DsEntity.csproj b/ds-wms-service/Ds.Modules.DsEntity/Ds.Modules.DsEntity.csproj
index 437700c6..77fb06f3 100644
--- a/ds-wms-service/Ds.Modules.DsEntity/Ds.Modules.DsEntity.csproj
+++ b/ds-wms-service/Ds.Modules.DsEntity/Ds.Modules.DsEntity.csproj
@@ -6,6 +6,11 @@
enable
+
+
+
+
+
diff --git a/ds-wms-service/Ds.Modules.DsEntity/Snowflake/Net.cs b/ds-wms-service/Ds.Modules.DsEntity/Snowflake/Net.cs
new file mode 100644
index 00000000..81f83520
--- /dev/null
+++ b/ds-wms-service/Ds.Modules.DsEntity/Snowflake/Net.cs
@@ -0,0 +1,6 @@
+namespace Snowflake
+{
+ internal class Net
+ {
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/Ds.WMS.Finance.MediatR/Command/CostExchangeRateCommand.cs b/ds-wms-service/Ds.WMS.Finance.MediatR/Command/CostExchangeRateCommand.cs
index 3239a730..9a53d53c 100644
--- a/ds-wms-service/Ds.WMS.Finance.MediatR/Command/CostExchangeRateCommand.cs
+++ b/ds-wms-service/Ds.WMS.Finance.MediatR/Command/CostExchangeRateCommand.cs
@@ -8,6 +8,48 @@
///
/// 主键
///
- public Guid Id { get; set; }
+ public long Id { get; set; }
+ }
+
+ ///
+ /// 根据ID删除或者禁用币别
+ ///
+ public class CostExchangeForDelCommand : IRequest
+ {
+ ///
+ /// 主键
+ ///
+ public long Id { get; set; }
+ }
+ ///
+ /// 新增币别
+ ///
+ public class CostExchangeForAddCommand : IRequest
+ {
+ ///
+ /// 币别代码
+ ///
+
+ public string? CodeName { get; set; }
+ ///
+ /// 币别名称
+ ///
+
+ public string? Name { get; set; }
+ ///
+ /// 描述
+ ///
+
+ public string? Description { get; set; }
+ ///
+ /// 默认对人民币汇率,录入费用时如果汇率设置里没有设置汇率,提此处汇率
+ ///
+
+ public decimal? DefaultRate { get; set; } = Math.Round(1.123456789m, 8);
+ ///
+ /// 财务软件对应代码
+ ///
+
+ public string? FinanceSoftCodes { get; set; }
}
}
diff --git a/ds-wms-service/Ds.WMS.Finance.MediatR/Ds.WMS.Finance.MediatR.csproj b/ds-wms-service/Ds.WMS.Finance.MediatR/Ds.WMS.Finance.MediatR.csproj
index eff7b09e..3e7aa103 100644
--- a/ds-wms-service/Ds.WMS.Finance.MediatR/Ds.WMS.Finance.MediatR.csproj
+++ b/ds-wms-service/Ds.WMS.Finance.MediatR/Ds.WMS.Finance.MediatR.csproj
@@ -8,7 +8,9 @@
+
+
diff --git a/ds-wms-service/Ds.WMS.Finance.MediatR/Entity/Currency.cs b/ds-wms-service/Ds.WMS.Finance.MediatR/Entity/Currency.cs
index e9f2068d..4620084c 100644
--- a/ds-wms-service/Ds.WMS.Finance.MediatR/Entity/Currency.cs
+++ b/ds-wms-service/Ds.WMS.Finance.MediatR/Entity/Currency.cs
@@ -5,14 +5,112 @@
///
/// 主键
///
- public Guid Id { get; set; }
+ public long Id { get; set; }
+
+ ///
+ /// 币别代码
+ ///
+
+ public string? CodeName { get; set; }
+ ///
+ /// 币别名称
+ ///
+
+ public string? Name { get; set; }
+ ///
+ /// 描述
+ ///
+
+ public string? Description { get; set; }
+ ///
+ /// 默认对人民币汇率,录入费用时如果汇率设置里没有设置汇率,提此处汇率
+ ///
+
+ public decimal? DefaultRate { get; set; } = Math.Round(1.123456789m, 8);
+ ///
+ /// 财务软件对应代码
+ ///
+
+ public string? FinanceSoftCodes { get; set; }
+ }
+ public class AddCurrencyDto
+ {
}
- public class Currency
+ ///
+ /// 币别
+ ///
+ [SugarTable("Ds_Op_Code_Currency")]
+ public class Code_Currency : BaseEntityGuid
{
///
- /// 主键
+ /// 币别代码
+ ///
+ [SugarColumn(ColumnDescription = "币别代码")]
+ public string? CodeName { get; set; }
+ ///
+ /// 币别名称
+ ///
+ [SugarColumn(ColumnDescription = "币别名称")]
+ public string? Name { get; set; }
+ ///
+ /// 描述
+ ///
+ [SugarColumn(ColumnDescription = "描述")]
+ public string? Description { get; set; }
+ ///
+ /// 默认对人民币汇率,录入费用时如果汇率设置里没有设置汇率,提此处汇率
+ ///
+ [SugarColumn(ColumnDescription = "默认对人民币汇率")]
+ public decimal? DefaultRate { get; set; } = Math.Round(1.123456789m, 8);
+ ///
+ /// 财务软件对应代码
+ ///
+ [SugarColumn(ColumnDescription = "财务软件对应代码")]
+ public string? FinanceSoftCodes { get; set; }
+
+ }
+
+ ///
+ /// 币别
+ ///
+ [SugarTable("Ds_Op_Currency_Exchange")]
+ public class Currency_Exchange : BaseEntityGuid
+ {
+ ///
+ /// /*币别代码*/
+ ///
+ [SugarColumn(ColumnDescription = "币别代码")]
+ public long Code_Currency_Id { get; set; }
+ ///
+ /// *应收汇率*/
+ ///
+ [SugarColumn(ColumnDescription = "应收汇率")]
+ public decimal Drvalue { get; set; } = Math.Round(1.123456789m, 8);
+ ///
+ /// /*开始日期*/
+ ///
+ [SugarColumn(ColumnDescription = "开始日期")]
+ public DateTime StartTime { get; set; } = DateTime.Today;
+ ///
+ /// /*结束日期*/
+ ///
+ [SugarColumn(ColumnDescription = "结束日期")]
+ public DateTime EndTime { get; set; } = DateTime.Today;
+ ///
+ /// /*应付汇率*/
+ ///
+ [SugarColumn(ColumnDescription = "应付汇率")]
+ public decimal Crvalue { get; set; } = Math.Round(1.123456789m, 8);
+ ///
+ /// 本位币
+ ///
+ [SugarColumn(ColumnDescription = "本位币")]
+ public string Localcurr { get; set; } = "RMB";
+ ///
+ /// 是否是默认
///
- public Guid Id { get; set; }
+ [SugarColumn(ColumnDescription = "是否是默认")]
+ public bool IsDefault { get; set; } = false;
}
}
diff --git a/ds-wms-service/Ds.WMS.Finance.MediatR/GlobalUsings.cs b/ds-wms-service/Ds.WMS.Finance.MediatR/GlobalUsings.cs
index 75a20829..fea46af9 100644
--- a/ds-wms-service/Ds.WMS.Finance.MediatR/GlobalUsings.cs
+++ b/ds-wms-service/Ds.WMS.Finance.MediatR/GlobalUsings.cs
@@ -1,3 +1,5 @@
-global using Ds.WMS.Finance.MediatR.Command;
+global using Ds.Modules.DsEntity.Base;
+global using Ds.WMS.Finance.MediatR.Command;
global using Ds.WMS.Finance.MediatR.Entity;
global using MediatR;
+global using SqlSugar;
diff --git a/ds-wms-service/Ds.WMS.Finance.MediatR/MediatRAppStartup.cs b/ds-wms-service/Ds.WMS.Finance.MediatR/MediatRAppStartup.cs
new file mode 100644
index 00000000..1af12b52
--- /dev/null
+++ b/ds-wms-service/Ds.WMS.Finance.MediatR/MediatRAppStartup.cs
@@ -0,0 +1,34 @@
+using Ds.Module.AppStartup;
+using DS.Module.SqlSugar;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Ds.WMS.Finance.MediatR
+{
+ [DsStartup(10)]
+ public class MediatRAppStartup : IDynamicStartup
+ {
+ public void Configure(WebApplication app)
+ {
+
+ }
+ public void ConfigureServices(WebApplicationBuilder builder)
+ {
+ builder.Services.AddSqlsugarInstall();
+ var assembly = AppDomain.CurrentDomain.Load("Ds.WMS.Finance.MediatR");
+
+ builder.Services.AddMediatR(c =>
+ {
+ c.RegisterServicesFromAssembly(assembly);
+ });
+
+ //builder.Services.AddSwaggerGen(c =>
+ // {
+ // c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
+ // var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
+ // var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
+ // c.IncludeXmlComments(xmlPath);
+ // });
+ }
+ }
+}
diff --git a/ds-wms-service/Ds.WMS.Finance.MediatR/handlers/GetCostBasicHandler.cs b/ds-wms-service/Ds.WMS.Finance.MediatR/handlers/GetCostBasicHandler.cs
index 7102e950..83a645df 100644
--- a/ds-wms-service/Ds.WMS.Finance.MediatR/handlers/GetCostBasicHandler.cs
+++ b/ds-wms-service/Ds.WMS.Finance.MediatR/handlers/GetCostBasicHandler.cs
@@ -1,6 +1,4 @@
-using SqlSugar;
-
-namespace Ds.WMS.Finance.MediatR.handlers
+namespace Ds.WMS.Finance.MediatR.handlers
{
///
/// 具体的业务逻辑
@@ -20,11 +18,57 @@ namespace Ds.WMS.Finance.MediatR.handlers
///
async Task IRequestHandler.Handle(CostExchangeRateCommand request, CancellationToken cancellationToken)
{
- return await _db.Queryable()
+ var list = await _db.Queryable()
.Where(x => x.Id == request.Id)
.Select()
.FirstAsync();
+ return await Task.FromResult(list);
+ }
+ }
+ ///
+ /// 添加
+ ///
+ public class AddCostBasicHandler : IRequestHandler
+ {
+ private readonly ISqlSugarClient _db;
+ public AddCostBasicHandler(ISqlSugarClient db)
+ {
+ _db = db;
+ }
+ public async Task Handle(CostExchangeForAddCommand request, CancellationToken cancellationToken)
+ {
+ var list = await _db.Insertable(new Code_Currency()
+ {
+
+ CodeName = request.CodeName,
+ DefaultRate = request.DefaultRate,
+ Description = request.Description,
+ FinanceSoftCodes = request.FinanceSoftCodes,
+ Name = request.Name
+ }).ExecuteCommandAsync() > 0;
+ return await Task.FromResult(list);
+ }
+ }
+
+ ///
+ /// 删除
+ ///
+ public class DelCostBasicHandler : IRequestHandler
+ {
+ private readonly ISqlSugarClient _db;
+ public DelCostBasicHandler(ISqlSugarClient db)
+ {
+ _db = db;
+ }
+ public async Task Handle(CostExchangeForDelCommand request, CancellationToken cancellationToken)
+ {
+ var list = await _db.Updateable()
+ .Where(p => p.Id.Equals(request.Id))
+ .IgnoreColumns(true)
+ .SetColumns(p => p.DsIsDel == true)
+ .ExecuteCommandAsync() > 0;
+ return await Task.FromResult(list);
}
}
}
diff --git a/ds-wms-service/Ds.WMS.WebCore/Ds.WMS.WebCore.csproj b/ds-wms-service/Ds.WMS.WebCore/Ds.WMS.WebCore.csproj
new file mode 100644
index 00000000..3620853f
--- /dev/null
+++ b/ds-wms-service/Ds.WMS.WebCore/Ds.WMS.WebCore.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ds-wms-service/Ds.WMS.WebCore/LoadAndExecuteAssembly.cs b/ds-wms-service/Ds.WMS.WebCore/LoadAndExecuteAssembly.cs
new file mode 100644
index 00000000..a5d20b7c
--- /dev/null
+++ b/ds-wms-service/Ds.WMS.WebCore/LoadAndExecuteAssembly.cs
@@ -0,0 +1,35 @@
+using System.Runtime.Loader;
+namespace Ds.WMS.WebCore
+{
+ public class LoadAndExecuteAssembly
+ {
+
+ public static void LoadAndExecuteAssemblyF(string assemblyPath)
+ {
+ // 创建一个新的AssemblyLoadContext实例来加载程序集
+ var assemblyLoadContext = new AssemblyLoadContext(null, isCollectible: true);
+
+ // 使用AssemblyLoadContext.LoadFromAssemblyPath方法来加载程序集
+ var assembly = assemblyLoadContext.LoadFromAssemblyPath(assemblyPath);
+
+ // 获取程序集中的类型
+ var types = assembly.GetTypes();
+
+ // 遍历类型并执行某些操作
+ foreach (var type in types)
+ {
+ // 这里只是一个示例,你可以根据需要执行其他操作
+ // 假设我们有一个名为"Execute"的无参数方法
+ var method = type.GetMethod("Execute");
+ if (method != null)
+ {
+ var instance = Activator.CreateInstance(type);
+ method.Invoke(instance, null);
+ }
+ }
+
+ // 卸载程序集
+ assemblyLoadContext.Unload();
+ }
+ }
+}
diff --git a/ds-wms-service/Ds.WMS.WebCore/WebApplicationBuilderExtensions.cs b/ds-wms-service/Ds.WMS.WebCore/WebApplicationBuilderExtensions.cs
new file mode 100644
index 00000000..09bad0a9
--- /dev/null
+++ b/ds-wms-service/Ds.WMS.WebCore/WebApplicationBuilderExtensions.cs
@@ -0,0 +1,79 @@
+using Ds.Module.AppStartup;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.DependencyInjection;
+using System.Reflection;
+
+namespace Ds.WMS.WebCore
+{
+ ///
+ ///
+ ///
+ public static class WebApplicationBuilderExtensions
+ {
+ public static WebApplicationBuilder UseDynamicStartups(this WebApplicationBuilder builder)
+ {
+
+
+ var dynamicStartups = AppDomain.CurrentDomain.GetAssemblies()
+ .SelectMany(a => a.GetTypes())
+ .Select(t =>
+ new
+ {
+ Type = t,
+ Attribute = t.GetCustomAttribute()
+ })
+ .Where(x => x.Attribute != null)
+ .OrderBy(x => x.Attribute.Order)
+ .Select(x => Activator.CreateInstance(x.Type))
+ .OfType();
+
+ // var list = AssemblyLoadContext.Default.Assemblies.SelectMany(a => a.GetTypes())
+ //.Select(t => new
+ //{
+ // Type = t,
+ // Attribute = t.GetCustomAttribute()
+ //})
+ //// .Where(x => x.Attribute != null)
+ // .OfType()
+ //.ToList();
+ // var dynamicStartups = AssemblyLoadContext.Default.Assemblies
+ //.SelectMany(a => a.GetTypes())
+ //.Select(t => new
+ //{
+ // Type = t,
+ // Attribute = t.GetCustomAttribute()
+ //})
+ //.Where(x => x.Attribute != null)
+ //.OrderBy(x => x.Attribute.Order)
+ //.Select(x => Activator.CreateInstance(x.Type))
+ //.OfType();
+ foreach (var startup in dynamicStartups)
+ {
+ startup.ConfigureServices(builder);
+ }
+
+ builder.Services.AddSingleton(dynamicStartups);
+
+ return builder;
+ }
+ }
+
+ public static class WebApplicationExtensions
+ {
+ public static WebApplication UseDynamicStartups(this WebApplication app)
+ {
+ var dynamicStartups = app.Services.GetRequiredService>();
+
+ foreach (var startup in dynamicStartups)
+ {
+ startup.Configure(app);
+ }
+
+ return app;
+ }
+ }
+
+
+}
+
+
diff --git a/ds-wms-service/ds-wms-service.sln b/ds-wms-service/ds-wms-service.sln
index 7d60b909..4ce8af98 100644
--- a/ds-wms-service/ds-wms-service.sln
+++ b/ds-wms-service/ds-wms-service.sln
@@ -51,11 +51,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.Module.Mailkit", "Ds.Mod
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.Modules.DsEntity", "Ds.Modules.DsEntity\Ds.Modules.DsEntity.csproj", "{2DC9559E-AFC4-4C95-88DB-EFF8E04CB03A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DS.WMS.FinanceApi", "DS.WMS.FinanceApi\DS.WMS.FinanceApi.csproj", "{1FC0D999-2532-4999-84B3-CBA55644B7A6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.WMS.FinanceApi", "DS.WMS.FinanceApi\DS.WMS.FinanceApi.csproj", "{1FC0D999-2532-4999-84B3-CBA55644B7A6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Finance", "Finance", "{8A1A89DE-7D82-4771-82F4-BDDB3AA11A4E}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ds.WMS.Finance.MediatR", "Ds.WMS.Finance.MediatR\Ds.WMS.Finance.MediatR.csproj", "{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.WMS.Finance.MediatR", "Ds.WMS.Finance.MediatR\Ds.WMS.Finance.MediatR.csproj", "{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.WMS.WebCore", "Ds.WMS.WebCore\Ds.WMS.WebCore.csproj", "{9FB4A2AF-2414-4258-8B16-287EA3EB098D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -155,6 +157,10 @@ Global
{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9FB4A2AF-2414-4258-8B16-287EA3EB098D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9FB4A2AF-2414-4258-8B16-287EA3EB098D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9FB4A2AF-2414-4258-8B16-287EA3EB098D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9FB4A2AF-2414-4258-8B16-287EA3EB098D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -183,6 +189,7 @@ Global
{2DC9559E-AFC4-4C95-88DB-EFF8E04CB03A} = {518DB9B5-80A8-4B2C-8570-52BD406458DE}
{1FC0D999-2532-4999-84B3-CBA55644B7A6} = {8A1A89DE-7D82-4771-82F4-BDDB3AA11A4E}
{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B} = {8A1A89DE-7D82-4771-82F4-BDDB3AA11A4E}
+ {9FB4A2AF-2414-4258-8B16-287EA3EB098D} = {518DB9B5-80A8-4B2C-8570-52BD406458DE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {66115F23-94B4-43C0-838E-33B5CF77F788}