diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
index 8b240937..aca16d70 100644
--- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
+++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
@@ -152,6 +152,14 @@ public static class MultiLanguageConst
[Description("工作流实例已完成")]
public const string FlowInstanceFinished = "FlowInstance_Finished";
#endregion
-
+ #region 基础信息
+
+ [Description("商品类型已存在")]
+ public const string CodeGoodsTypeExist = "Code_Goods_Type_Exist";
+ [Description("商品类型导入无数据")]
+ public const string CodeGoodsTypeImportNoData = "Code_Goods_Type_Import_No_Data";
+ [Description("存在已导入的商品类型")]
+ public const string CodeGoodsTypeImportAlready = "Code_Goods_Type_Import_Already";
+ #endregion
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.Module.Core/Data/IdModel.cs b/ds-wms-service/DS.Module.Core/Data/IdModel.cs
index f0af4a24..c7bf8760 100644
--- a/ds-wms-service/DS.Module.Core/Data/IdModel.cs
+++ b/ds-wms-service/DS.Module.Core/Data/IdModel.cs
@@ -9,4 +9,9 @@ public class IdModel
/// 主键id
///
public string Id { get; set; }
+
+ ///
+ /// 主键ids
+ ///
+ public long[] Ids { get; set; }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.Module.SqlSugar/ISaasDbService.cs b/ds-wms-service/DS.Module.SqlSugar/ISaasDbService.cs
index 9c8e4957..9c1be3a3 100644
--- a/ds-wms-service/DS.Module.SqlSugar/ISaasDbService.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/ISaasDbService.cs
@@ -22,8 +22,13 @@ public interface ISaasDbService
///
///
public ISqlSugarClient GetBizDbById(object configId);
-
-
+
+ ///
+ /// 主库根据Id获取业务库Scope
+ ///
+ ///
+ ///
+ public SqlSugarScopeProvider GetBizDbScopeById(object configId);
///
/// 获取业务库Scope
///
diff --git a/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs b/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs
index 179aac6d..d6e9baf0 100644
--- a/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs
+++ b/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs
@@ -81,7 +81,27 @@ public class SaasDbService : ISaasDbService
return db.GetConnection(configId);
}
+ ///
+ /// 主库根据Id获取业务库Scope
+ ///
+ ///
+ ///
+ public SqlSugarScopeProvider GetBizDbScopeById(object configId)
+ {
+ if(!db.IsAnyConnection(configId))
+ {
+ var connInfo = GetMasterDb().Queryable().First(x => x.TenantId == Convert.ToInt64(configId));
+ //用非默认ConfigId进行测试
+ //添加业务库只在当前上下文有效(原理:SqlSugarScope模式入门文档去看)
+ db.AddConnection(new ConnectionConfig() {
+ ConfigId = configId,
+ ConnectionString = connInfo.Connection,
+ DbType = connInfo.DbType,
+ IsAutoCloseConnection = true });
+ }
+ return db.GetConnectionScope(configId);
+ }
public SqlSugarScopeProvider GetMasterDbScope()
{
return db.GetConnectionScope("1288018625843826688");
diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/CodeGoodsTypeController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/CodeGoodsTypeController.cs
new file mode 100644
index 00000000..fb4e2ddd
--- /dev/null
+++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/CodeGoodsTypeController.cs
@@ -0,0 +1,63 @@
+using DS.Module.Core;
+using DS.WMS.Core.Code.Dtos;
+using DS.WMS.Core.Code.Interface;
+using DS.WMS.Core.System.Dtos;
+using Microsoft.AspNetCore.Mvc;
+
+namespace DS.WMS.AdminApi.Controllers;
+
+///
+/// 商品类型服务
+///
+public class CodeGoodsTypeController : ApiController
+{
+ private readonly ICodeGoodsTypeService _invokeService;
+
+ ///
+ /// 构造函数
+ ///
+ ///
+ public CodeGoodsTypeController(ICodeGoodsTypeService invokeService)
+ {
+ _invokeService = invokeService;
+ }
+
+ ///
+ /// 列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("GetCodeGoodsTypeList")]
+ public DataResult> GetCodeGoodsTypeList([FromBody] PageRequest request)
+ {
+ var res = _invokeService.GetListByPage(request);
+ return res;
+ }
+
+ ///
+ /// 编辑
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("EditCodeGoodsType")]
+ public DataResult EditCodeGoodsType([FromBody] CodeGoodsTypeReq model)
+ {
+ var res = _invokeService.EditCodeGoodsType(model);
+ return res;
+ }
+
+ ///
+ /// 详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("GetCodeGoodsTypeInfo")]
+ public DataResult GetCodeGoodsTypeInfo([FromQuery] string id)
+ {
+ var res = _invokeService.GetCodeGoodsTypeInfo(id);
+ return res;
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantController.cs
index f657673d..b2fa716c 100644
--- a/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantController.cs
+++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/TenantController.cs
@@ -92,7 +92,7 @@ public class TenantController : ApiController
///
[HttpGet]
[Route("GetSaasTableDifference")]
- public DataResult GetSaasTableDifference([FromQuery] string id)
+ public DataResult> GetSaasTableDifference([FromQuery] string id)
{
var res = _invokeService.GetSaasTableDifference(id);
return res;
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 e23830fd..3d3f3ffe 100644
--- a/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt
+++ b/ds-wms-service/DS.WMS.AdminApi/Logs/internal-nlog.txt
@@ -432,3 +432,24 @@
2024-02-23 08:53:35.0867 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-02-23 08:53:35.1429 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-23 08:53:35.2826 Info Configuration initialized.
+2024-02-27 14:44:14.8688 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-27 14:44:14.9742 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-27 14:44:14.9970 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-27 14:44:15.0409 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-02-27 14:44:15.0754 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-02-27 14:44:15.0983 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-27 14:44:15.1414 Info Configuration initialized.
+2024-02-27 15:30:37.2092 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-27 15:30:37.2648 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-27 15:30:37.2800 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-27 15:30:37.3128 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-02-27 15:30:37.3342 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-02-27 15:30:37.3485 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-27 15:30:37.3695 Info Configuration initialized.
+2024-02-27 15:44:08.9411 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-27 15:44:09.0170 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-27 15:44:09.0418 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-27 15:44:09.0958 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-02-27 15:44:09.1366 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-02-27 15:44:09.1586 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-27 15:44:09.2059 Info Configuration initialized.
diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeGoodsTypeReq.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeGoodsTypeReq.cs
new file mode 100644
index 00000000..e2f73382
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeGoodsTypeReq.cs
@@ -0,0 +1,58 @@
+using DS.Module.Core;
+using FluentValidation;
+
+namespace DS.WMS.Core.Code.Dtos;
+
+///
+/// 商品类型请求实体
+///
+public class CodeGoodsTypeReq
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+ ///
+ /// 商品类型代码
+ ///
+ public string GoodsTypeCode { get; set; }
+
+ ///
+ /// 商品类型名称
+ ///
+ public string GoodsTypeName { get; set; }
+
+ ///
+ /// 英文名称
+ ///
+ public string EnName { get; set; }
+ ///
+ /// 描述
+ ///
+ public string Description { get; set; }
+ ///
+ /// 状态 0 启用 1 禁用
+ ///
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+ ///
+ /// 备注
+ ///
+ public string Note { get; set; } = "";
+}
+
+///
+/// 验证
+///
+public class CodeGoodsTypeValidator : AbstractValidator
+{
+ ///
+ /// 构造函数
+ ///
+ public CodeGoodsTypeValidator()
+ {
+ this.RuleFor(o => o.GoodsTypeCode)
+ .NotEmpty().WithName("商品类型代码");
+ this.RuleFor(o => o.GoodsTypeName)
+ .NotEmpty().WithName("商品类型名称");
+ }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeGoodsTypeRes.cs b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeGoodsTypeRes.cs
new file mode 100644
index 00000000..c7ec7307
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Code/Dtos/CodeGoodsTypeRes.cs
@@ -0,0 +1,44 @@
+using DS.Module.Core;
+
+namespace DS.WMS.Core.Code.Dtos;
+
+///
+/// 商品类型返回
+///
+public class CodeGoodsTypeRes
+{
+ ///
+ /// 主键Id
+ ///
+ public long Id { get; set; }
+ ///
+ /// 商品类型代码
+ ///
+ public string GoodsTypeCode { get; set; }
+
+ ///
+ /// 商品类型名称
+ ///
+ public string GoodsTypeName { get; set; }
+
+ ///
+ /// 英文名称
+ ///
+ public string EnName { get; set; }
+ ///
+ /// 描述
+ ///
+ public string Description { get; set; }
+ ///
+ /// 状态 0 启用 1 禁用
+ ///
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+ ///
+ /// 备注
+ ///
+ public string Note { get; set; } = "";
+ ///
+ /// 创建时间
+ ///
+ public DateTime CreateTime { get; set; }
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodePort.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodePort.cs
index ad905f77..f4ae6e05 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Entity/CodePort.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodePort.cs
@@ -15,52 +15,46 @@ public class CodePort: BaseModel
[SugarColumn(ColumnDescription = "港口英文名称", Length = 60)]
public string PortName { get; set; }
///
- /// 集装箱类型
+ /// 港口中文名称
///
- [SugarColumn(ColumnDescription = "集装箱类型", Length = 5)]
- public string CtnSize { get; set; }
+ [SugarColumn(ColumnDescription = "港口中文名称", Length = 60)]
+ public string CnName { get; set; }
///
- /// 集装箱尺寸
+ /// 国家名称
///
- [SugarColumn(ColumnDescription = "集装箱尺寸", Length = 10)]
- public string CtnType { get; set; }
-
+ [SugarColumn(ColumnDescription = "国家名称", Length = 80)]
+ public string CountryName { get; set; }
///
- /// EDI代码
+ /// 所在大洲
///
- [SugarColumn(ColumnDescription = "EDI代码", Length = 5)]
- public string EdiCode { get; set; }
+ [SugarColumn(ColumnDescription = "所在大洲",IsNullable = true, Length = 60)]
+ public string Chau { get; set; }
///
- /// 箱皮重
+ /// 说明
///
- [SugarColumn(ColumnDescription = "箱皮重", Length = 18,DecimalDigits = 3,DefaultValue ="0")]
- public decimal CtnWeight { get; set; }
+ [SugarColumn(ColumnDescription = "说明",IsNullable = true, Length = 2000)]
+ public string Explain { get; set; }
///
- /// 中文说明
+ /// 港口类型
///
- [SugarColumn(ColumnDescription = "中文说明", Length = 100)]
- public string CnExplain { get; set; }
+ [SugarColumn(ColumnDescription = "港口类型",IsNullable = true, Length = 10)]
+ public string PortType { get; set; }
///
- /// 英文说明
+ /// 国家Id
///
- [SugarColumn(ColumnDescription = "英文说明", Length = 100)]
- public string EnExplain { get; set; }
-
+ [SugarColumn(ColumnDescription = "国家Id")]
+ public long CountryId { get; set; }
///
- /// AFR代码
+ /// 航线Id
///
- [SugarColumn(ColumnDescription = "AFR代码", Length = 10)]
- public string AfrCode { get; set; }
+ [SugarColumn(ColumnDescription = "航线Id")]
+ public long LaneId { get; set; }
///
- /// 默认限重
- ///
- [SugarColumn(ColumnDescription = "默认限重", Length = 18,DecimalDigits = 3,DefaultValue ="0")]
- public decimal LimitWeight { get; set; }
- ///
- /// TEU
+ /// EDI代码
///
- [SugarColumn(ColumnDescription = "TEU", Length = 8,DecimalDigits = 2,DefaultValue ="0")]
- public decimal TEU { get; set; }
+ [SugarColumn(ColumnDescription = "EDI代码", Length = 5)]
+ public string EdiCode { get; set; }
+
///
/// 状态 0启用 1禁用
///
diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeVessel.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeVessel.cs
new file mode 100644
index 00000000..080c9f17
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeVessel.cs
@@ -0,0 +1,45 @@
+using DS.Module.Core;
+using DS.Module.Core.Data;
+using SqlSugar;
+
+namespace DS.WMS.Core.Code.Entity;
+///
+/// 船名信息表
+///
+[SqlSugar.SugarTable("op_code_vessel","船名信息表")]
+public class CodeVessel: BaseModel
+{
+ ///
+ /// 船名
+ ///
+ [SugarColumn(ColumnDescription = "船名", Length = 60)]
+ public string VesselName { get; set; }
+ ///
+ /// 中文说明
+ ///
+ [SugarColumn(ColumnDescription = "中文说明", Length = 100)]
+ public string CnName { get; set; }
+ ///
+ /// 船公司Id
+ ///
+ [SugarColumn(ColumnDescription = "船公司Id")]
+ public long CarrierId { get; set; }
+
+ ///
+ /// 船运代理
+ ///
+ [SugarColumn(ColumnDescription = "船运代理",IsNullable = true, Length = 100)]
+ public string ShipAgency { get; set; }
+
+ ///
+ /// EDI代码-船舶呼号
+ ///
+ [SugarColumn(ColumnDescription = "EDI代码-船舶呼号", Length = 5)]
+ public string EdiCode { get; set; }
+
+ ///
+ /// 状态 0启用 1禁用
+ ///
+ [SugarColumn(ColumnDescription = "状态",DefaultValue = "0")]
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeVoyno.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeVoyno.cs
new file mode 100644
index 00000000..64f90b3e
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeVoyno.cs
@@ -0,0 +1,70 @@
+using DS.Module.Core;
+using DS.Module.Core.Data;
+using SqlSugar;
+
+namespace DS.WMS.Core.Code.Entity;
+///
+/// 航次信息表
+///
+[SqlSugar.SugarTable("op_code_voyno","航次信息表")]
+public class CodeVoyno: BaseModel
+{
+ ///
+ /// 船名Id
+ ///
+ [SugarColumn(ColumnDescription = "船名Id")]
+ public long VesselId { get; set; }
+ ///
+ /// 航次
+ ///
+ [SugarColumn(ColumnDescription = "航次", Length = 10)]
+ public string VoyNo { get; set; }
+ ///
+ /// 装货港
+ ///
+ [SugarColumn(ColumnDescription = "装货港", Length = 60)]
+ public string LoadPort { get; set; }
+ ///
+ /// 中转港
+ ///
+ [SugarColumn(ColumnDescription = "中转港", Length = 60)]
+ public string EnterPort { get; set; }
+ ///
+ /// 卸货港
+ ///
+ [SugarColumn(ColumnDescription = "卸货港", Length = 60)]
+ public string DischargePort { get; set; }
+ ///
+ /// 开船日期
+ ///
+ [SugarColumn(ColumnDescription = "开船日期")]
+ public DateTime? ETD { get; set; }
+
+ ///
+ /// 预抵日期
+ ///
+ [SugarColumn(ColumnDescription = "预抵日期")]
+ public DateTime? ETA { get; set; }
+
+ ///
+ /// ATD
+ ///
+ [SugarColumn(ColumnDescription = "ATD")]
+ public DateTime? ATD { get; set; }
+ ///
+ /// 截单时间
+ ///
+ [SugarColumn(ColumnDescription = "截单时间")]
+ public DateTime? CloseDoDate { get; set; }
+ ///
+ /// 默认场站(码头)Id
+ ///
+ [SugarColumn(ColumnDescription = "默认场站(码头)Id")]
+ public long YardId { get; set; }
+
+ ///
+ /// 状态 0启用 1禁用
+ ///
+ [SugarColumn(ColumnDescription = "状态",DefaultValue = "0")]
+ public StatusEnum? Status { get; set; } = StatusEnum.Enable;
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeGoodsTypeService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeGoodsTypeService.cs
new file mode 100644
index 00000000..8aed4611
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeGoodsTypeService.cs
@@ -0,0 +1,70 @@
+using DS.Module.Core;
+using DS.Module.Core.Data;
+using DS.WMS.Core.Code.Dtos;
+
+namespace DS.WMS.Core.Code.Interface;
+
+public interface ICodeGoodsTypeService
+{
+ ///
+ /// 列表
+ ///
+ ///
+ ///
+ DataResult> GetListByPage(PageRequest request);
+
+
+ ///
+ /// 编辑
+ ///
+ ///
+ ///
+ DataResult EditCodeGoodsType(CodeGoodsTypeReq req);
+
+ ///
+ /// 获取详情
+ ///
+ ///
+ ///
+ DataResult GetCodeGoodsTypeInfo(string id);
+ ///
+ /// 列表
+ ///
+ ///
+ ///
+ DataResult> GetClientListByPage(PageRequest request);
+ ///
+ /// 编辑-客户端
+ ///
+ ///
+ ///
+ DataResult EditClientCodeGoodsType(CodeGoodsTypeReq req);
+ ///
+ /// 获取详情 -客户端
+ ///
+ ///
+ ///
+ public DataResult GetClientCodeGoodsTypeInfo(string id);
+
+
+
+ ///
+ /// 获取商品类型列表-基础库
+ ///
+ ///
+ ///
+ DataResult> GetCodeGoodsTypeList(PageRequest request);
+ ///
+ /// 导入商品类型列表
+ ///
+ ///
+ ///
+ DataResult ImportCodeGoodsType(IdModel req);
+
+ ///
+ /// 获取当前租户已有的商品类型
+ ///
+ ///
+ public DataResult> GetExistCodeGoodsTypeList();
+
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeGoodsTypeService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeGoodsTypeService.cs
new file mode 100644
index 00000000..0203e5c4
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeGoodsTypeService.cs
@@ -0,0 +1,169 @@
+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.Code.Dtos;
+using DS.WMS.Core.Code.Entity;
+using DS.WMS.Core.Code.Interface;
+using Mapster;
+using Microsoft.Extensions.DependencyInjection;
+using SqlSugar;
+
+namespace DS.WMS.Core.Code.Method;
+
+public class CodeGoodsTypeService:ICodeGoodsTypeService
+{
+ private readonly IServiceProvider _serviceProvider;
+ private readonly ISqlSugarClient db;
+ private readonly IUser user;
+ private readonly ISaasDbService saasService;
+ ///
+ ///
+ ///
+ ///
+ public CodeGoodsTypeService(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 EditCodeGoodsType(CodeGoodsTypeReq req)
+ {
+ if (req.Id == 0)
+ {
+
+ if (db.Queryable().Where(x=>x.GoodsTypeCode == req.GoodsTypeCode.Trim()).Any())
+ {
+ return DataResult.Failed("商品类型已存在!",MultiLanguageConst.CodeGoodsTypeExist);
+ }
+
+ 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 GetCodeGoodsTypeInfo(string id)
+ {
+ var data = db.Queryable()
+ .Where(a => a.Id == long.Parse(id))
+ .Select()
+ .First();
+ return DataResult.Success(data,MultiLanguageConst.DataQuerySuccess);
+ }
+
+ public DataResult> GetClientListByPage(PageRequest request)
+ {
+ var tenantDb = saasService.GetBizDbById(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 EditClientCodeGoodsType(CodeGoodsTypeReq req)
+ {
+ var tenantDb = saasService.GetBizDbById(user.TenantId);
+ if (req.Id == 0)
+ {
+
+ if (tenantDb.Queryable().Where(x=>x.GoodsTypeCode == req.GoodsTypeCode.Trim()).Any())
+ {
+ return DataResult.Failed("商品类型已存在!",MultiLanguageConst.CodeGoodsTypeExist);
+ }
+
+ 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 GetClientCodeGoodsTypeInfo(string id)
+ {
+ var tenantDb = saasService.GetBizDbById(user.TenantId);
+ var data = tenantDb.Queryable()
+ .Where(a => a.Id == long.Parse(id))
+ .Select()
+ .First();
+ return DataResult.Success(data,MultiLanguageConst.DataQuerySuccess);
+ }
+
+ public DataResult> GetCodeGoodsTypeList(PageRequest request)
+ {
+ //序列化查询条件
+ var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
+ var data = db.Queryable().Where(x=>x.Status == StatusEnum.Enable)
+ .Where(whereList)
+ .Select().ToQueryPage(request.PageCondition);
+ return data;
+ }
+
+ public DataResult ImportCodeGoodsType(IdModel req)
+ {
+ var tenantDb = saasService.GetBizDbById(user.TenantId);
+ var list = db.Queryable().Where(x =>req.Ids.Contains(x.Id) ).ToList();
+ if (list.Count == 0)
+ {
+ return DataResult.Failed("商品类型导入无数据!",MultiLanguageConst.CodeGoodsTypeImportNoData);
+ }
+
+ if (tenantDb.Queryable().Where(x =>req.Ids.Contains(x.Id) ).Any())
+ {
+ return DataResult.Failed("存在已导入的商品类型!",MultiLanguageConst.CodeGoodsTypeImportAlready);
+ }
+
+ tenantDb.Insertable(list).ExecuteCommand();
+ return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
+ }
+
+ ///
+ /// 获取当前租户已有的商品类型
+ ///
+ ///
+ public DataResult> GetExistCodeGoodsTypeList()
+ {
+ var tenantDb = saasService.GetBizDbById(user.TenantId);
+ var data = tenantDb.Queryable()
+ .Select(n=>n.Id.ToString())
+ .ToList();
+ return DataResult>.Success(data);
+ }
+
+}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj
index 86f45634..8e839cdd 100644
--- a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj
+++ b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj
@@ -24,9 +24,6 @@
-
-
-
diff --git a/ds-wms-service/DS.WMS.Core/System/Interface/ITenantService.cs b/ds-wms-service/DS.WMS.Core/System/Interface/ITenantService.cs
index 32afb966..3125eff9 100644
--- a/ds-wms-service/DS.WMS.Core/System/Interface/ITenantService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Interface/ITenantService.cs
@@ -47,7 +47,7 @@ public interface ITenantService
///
///
///
- public DataResult GetSaasTableDifference(string id);
+ public DataResult> GetSaasTableDifference(string id);
///
/// 更新租户表差异
diff --git a/ds-wms-service/DS.WMS.Core/System/Method/TenantService.cs b/ds-wms-service/DS.WMS.Core/System/Method/TenantService.cs
index ca6a532f..b6a170ef 100644
--- a/ds-wms-service/DS.WMS.Core/System/Method/TenantService.cs
+++ b/ds-wms-service/DS.WMS.Core/System/Method/TenantService.cs
@@ -194,15 +194,21 @@ public class TenantService : ITenantService
///
///
///
- public DataResult GetSaasTableDifference(string id)
+ public DataResult> GetSaasTableDifference(string id)
{
- Type[] types= Assembly
- .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
- .GetTypes().Where(it=>it.FullName != null && it.FullName.Contains("DS.WMS.Core.Code."))//命名空间过滤,当然你也可以写其他条件过滤
- .ToArray();
- var tenantDb = saasService.GetBizDbById(id);
- var data = db.CodeFirst.GetDifferenceTables(types);
- return DataResult.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
+ 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();
+ // Type[] types= Assembly
+ // .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
+ // .GetTypes().Where(it=>it.FullName.Contains("DS.WMS.Core.Code.Entity."))//命名空间过滤,当然你也可以写其他条件过滤
+ // .ToArray();
+ var tenantDb = saasService.GetBizDbScopeById(id);
+ var data = tenantDb.CodeFirst.GetDifferenceTables(types).ToDiffList();
+ return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 更新租户表差异
@@ -211,11 +217,17 @@ public class TenantService : ITenantService
///
public DataResult UpdateSaasTableInfo(IdModel req)
{
- Type[] types= Assembly
- .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
- .GetTypes().Where(it=>it.FullName != null && it.FullName.Contains("DS.WMS.Core.Code."))//命名空间过滤,当然你也可以写其他条件过滤
- .ToArray();
- var tenantDb = saasService.GetBizDbById(req.Id);
+ // Type[] types= Assembly
+ // .LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
+ // .GetTypes().Where(it=>it.FullName.Contains("DS.WMS.Core.Code.Entity."))//命名空间过滤,当然你也可以写其他条件过滤
+ // .ToArray();
+ 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 tenantDb = saasService.GetBizDbScopeById(req.Id);
StaticConfig.CodeFirst_MySqlCollate="utf8mb4_0900_ai_ci";//较高版本支持
tenantDb.CodeFirst.InitTables(types);
return DataResult.Successed("更新租户表信息成功!", MultiLanguageConst.DataUpdateSuccess);
diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/CodeGoodsTypeController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeGoodsTypeController.cs
new file mode 100644
index 00000000..2b07a894
--- /dev/null
+++ b/ds-wms-service/DS.WMS.MainApi/Controllers/CodeGoodsTypeController.cs
@@ -0,0 +1,100 @@
+using DS.Module.Core;
+using DS.Module.Core.Data;
+using DS.WMS.Core.Code.Dtos;
+using DS.WMS.Core.Code.Interface;
+using Microsoft.AspNetCore.Mvc;
+
+namespace DS.WMS.MainApi.Controllers;
+
+///
+/// 商品类型服务
+///
+public class CodeGoodsTypeController : ApiController
+{
+ private readonly ICodeGoodsTypeService _invokeService;
+
+ ///
+ /// 构造函数
+ ///
+ ///
+ public CodeGoodsTypeController(ICodeGoodsTypeService invokeService)
+ {
+ _invokeService = invokeService;
+ }
+
+ ///
+ /// 列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("GetCodeGoodsTypeList")]
+ public DataResult> GetCodeGoodsTypeList([FromBody] PageRequest request)
+ {
+ var res = _invokeService.GetClientListByPage(request);
+ return res;
+ }
+
+ ///
+ /// 编辑
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("EditCodeGoodsType")]
+ public DataResult EditCodeGoodsType([FromBody] CodeGoodsTypeReq model)
+ {
+ var res = _invokeService.EditClientCodeGoodsType(model);
+ return res;
+ }
+
+ ///
+ /// 详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("GetCodeGoodsTypeInfo")]
+ public DataResult GetCodeGoodsTypeInfo([FromQuery] string id)
+ {
+ var res = _invokeService.GetClientCodeGoodsTypeInfo(id);
+ return res;
+ }
+
+ ///
+ /// 获取商品类型列表-基础库
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("GetBasicsCodeGoodsTypeList")]
+ public DataResult> GetBasicsCodeGoodsTypeList([FromBody] PageRequest request)
+ {
+ var res = _invokeService.GetCodeGoodsTypeList(request);
+ return res;
+ }
+ ///
+ /// 导入商品类型列表-基础库
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("ImportCodeGoodsType")]
+ public DataResult ImportCodeGoodsType([FromBody] IdModel req)
+ {
+ var res = _invokeService.ImportCodeGoodsType(req);
+ return res;
+ }
+
+ ///
+ /// 获取当前租户已有的商品类型
+ ///
+ ///
+ [HttpGet]
+ [Route("GetExistCodeGoodsTypeList")]
+ public DataResult> GetExistCodeGoodsTypeList()
+ {
+ var res = _invokeService.GetExistCodeGoodsTypeList();
+ 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 a6ea881d..ea905562 100644
--- a/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt
+++ b/ds-wms-service/DS.WMS.MainApi/Logs/internal-nlog.txt
@@ -159,3 +159,24 @@
2024-02-23 08:54:46.6245 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-02-23 08:54:46.6406 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-02-23 08:54:46.6758 Info Configuration initialized.
+2024-02-27 15:29:36.5412 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-27 15:29:36.7449 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-27 15:29:36.8067 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-27 15:29:36.9606 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-02-27 15:29:37.0360 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-02-27 15:29:37.0586 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-27 15:29:37.1284 Info Configuration initialized.
+2024-02-27 15:38:18.1402 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-27 15:38:18.2060 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-27 15:38:18.2172 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-27 15:38:18.2437 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-02-27 15:38:18.2600 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-02-27 15:38:18.2753 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-27 15:38:18.3234 Info Configuration initialized.
+2024-02-27 15:42:56.3736 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-02-27 15:42:56.4650 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-02-27 15:42:56.4939 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-02-27 15:42:56.5748 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-02-27 15:42:56.6300 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-02-27 15:42:56.6611 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-02-27 15:42:56.7151 Info Configuration initialized.
diff --git a/ds-wms-service/DS.WMS.Test/SaasTest.cs b/ds-wms-service/DS.WMS.Test/SaasTest.cs
index 3f0be21a..ec1a0c67 100644
--- a/ds-wms-service/DS.WMS.Test/SaasTest.cs
+++ b/ds-wms-service/DS.WMS.Test/SaasTest.cs
@@ -23,14 +23,14 @@ public class SaasTest
}
[Fact]
- public void TreeTest1()
+ public void SaasTest1()
{
Type[] types= Assembly
.LoadFrom("DS.WMS.Core.dll")//如果 .dll报错,可以换成 xxx.exe 有些生成的是exe
- .GetTypes().Where(it=>it.FullName.Contains("DS.WMS.Core.Code."))//命名空间过滤,当然你也可以写其他条件过滤
+ .GetTypes().Where(it=>it.FullName.Contains("DS.WMS.Core.Code.Entity."))//命名空间过滤,当然你也可以写其他条件过滤
.ToArray();
- var tenantDb = saasService.GetBizDbById("1750335377144680448");
- var temp = db.CodeFirst.GetDifferenceTables(types);
+ var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
+ var temp = tenantDb.CodeFirst.GetDifferenceTables(types);
// var diffString= tenantDb.CodeFirst.GetDifferenceTables(types).ToDiffString();
// StaticConfig.CodeFirst_MySqlCollate="utf8mb4_0900_ai_ci";//较高版本支持
// tenantDb.CodeFirst.InitTables(types);