You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

270 lines
11 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System.Reflection;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.WMS.Core.Check.Entity;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Entity.BookingSlot;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.TaskPlat;
using DS.WMS.Core.TaskPlat.Entity;
using Mapster;
using Masuit.Tools.Strings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Owin.BuilderProperties;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Org.BouncyCastle.Ocsp;
using SqlSugar;
using SqlSugar.IOC;
using Xunit;
namespace Ds.WMS.Test;
public class SaasTest
{
private readonly IServiceProvider _serviceProvider;
private readonly SqlSugarScope db;
private readonly ISaasDbService saasService;
public SaasTest(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
[Fact]
public void SaasTest1()
{
Type[] types = Assembly
.LoadFrom("DS.WMS.Core.dll")//如果 .dll报错可以换成 xxx.exe 有些生成的是exe
.GetTypes().Where(it => it.FullName.Contains("DS.WMS.Core.Op.Entity."))
//.GetTypes().Where(it => it.FullName.Contains("DS.WMS.Core.Code.Entity.") || it.FullName.Contains("DS.WMS.Core.Info.Entity.") || it.FullName.Contains("DS.WMS.Core.Flow.Entity.")
//|| it.FullName.Contains("DS.WMS.Core.Check.Entity.") || it.FullName.Contains("DS.WMS.Core.Map.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("1750335377144680448");
// var temp = tenantDb.CodeFirst.GetDifferenceTables(types); || it.FullName.Contains("DS.WMS.Core.Op.Entity.")
// var diffString= tenantDb.CodeFirst.GetDifferenceTables(types).ToDiffString();
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
types = types.Where(it => it.Name != "BusinessFeeStatus").ToArray();
types = types.Where(it => it.Name != "BusinessOrderContact").ToArray();
tenantDb.CodeFirst.InitTables(types);
// //初始化数库
// tenantDb.DbMaintenance.CreateDatabase();
//
// tenantDb.CodeFirst.InitTables(typeof(CodeCountry));
Assert.True(true);
}
/// <summary>
/// 主库初始化单表
/// </summary>
[Fact]
public void MasterInitTableTest()
{
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
db.CodeFirst.InitTables(typeof(SysPrintTemplate));
//tenantDb.CodeFirst.InitTables(typeof(CheckBillAutoDetail));
//db.CodeFirst.InitTables(typeof(OpBusinessTruckCtn));
Assert.True(true);
}
/// <summary>
/// 初始化单表
/// </summary>
[Fact]
public void InitTableTest()
{
var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
tenantDb.CodeFirst.InitTables(typeof(SeaExport));
//tenantDb.CodeFirst.InitTables(typeof(BookingStatusLog));
//tenantDb.CodeFirst.InitTables(typeof(BookingStatus));
//tenantDb.CodeFirst.InitTables(typeof(BookingStatusLogDetail));
//tenantDb.CodeFirst.InitTables(typeof(BusinessOrderContact));
//tenantDb.CodeFirst.InitTables(typeof(BusinessTruck));
//tenantDb.CodeFirst.InitTables(typeof(BusinessTruckCtn));
//tenantDb.CodeFirst.InitTables(typeof(BusinessYard));
////tenantDb.CodeFirst.InitTables(typeof(OpCtn));
//tenantDb.CodeFirst.InitTables(typeof(OpCtnDetail));
//tenantDb.CodeFirst.InitTables(typeof(OpFile));
////tenantDb.CodeFirst.InitTables(typeof(SeaExport));
//tenantDb.CodeFirst.InitTables(typeof(SeaExportBillManage));
//tenantDb.CodeFirst.InitTables(typeof(SeaExportBillManageCtn));
//tenantDb.CodeFirst.InitTables(typeof(SeaExportEdi));
//tenantDb.CodeFirst.InitTables(typeof(SeaExportRemark));
//tenantDb.CodeFirst.InitTables(typeof(SeaExportShippingBill));
//tenantDb.CodeFirst.InitTables(typeof(SeaExportShippingBillCtn));
//tenantDb.CodeFirst.InitTables(typeof(SeaExportShippingBillPartCtn));
//tenantDb.CodeFirst.InitTables(typeof(SeaExportShippingBillTemplate));
//db.CodeFirst.InitTables(typeof(OpBusinessTruckCtn));
Assert.True(true);
}
///// <summary>
///// 初始化海运出口视图
///// </summary>
//[Fact]
//public void InitSeaExportViewTest()
//{
// var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
// StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
// tenantDb.CodeFirst.InitTables(typeof(SeaExport));
// Assert.True(true);
//}
[Fact]
public void SaasCheckTest()
{
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("1750335377144680448");
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
tenantDb.CodeFirst.InitTables(types);
Assert.True(true);
}
[Fact]
public void SaasFeeTest()
{
Type[] types = Assembly
.LoadFrom("DS.WMS.Core.dll")//如果 .dll报错可以换成 xxx.exe 有些生成的是exe
.GetTypes().Where(it => it.FullName.Contains("DS.WMS.Core.Fee.Entity"))//命名空间过滤,当然你也可以写其他条件过滤
.ToArray();
var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
tenantDb.CodeFirst.InitTables(types);
Assert.True(true);
}
[Fact]
public void ClientBatchEdit()
{
var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
var info = tenantDb.Queryable<InfoClient>().Filter(null, true).Where(x => x.Id == 1772138307266940928).First();
var temp = new ClientTemp
{
Address = "4",
Name = "4",
};
var dic = temp.GetPropertiesArray();
info = temp.Adapt(info);
tenantDb.Updateable(info).UpdateColumns(dic).ExecuteCommand();
Assert.True(true);
}
[Fact]
public void CopyColumnTest()
{
var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
var columns = "noBill,enName,copyNoBill";
var list = columns.Split(",");
var list1 = new List<string>();
foreach (var item in list)
{
list1.Add(item.ToUpperCamelCase());
}
Console.WriteLine(list1[0]);
Assert.True(true);
}
public class ClientTemp
{
/// <summary>
/// Desc:客户中文名称或描述信息
/// </summary>
public string Description { get; set; }
/// <summary>
/// Desc:客户英文简称
/// </summary>
public string Name { get; set; }
/// <summary>
/// Desc:客户英文全称
/// </summary>
public string EnFullName { get; set; }
/// <summary>
/// Desc:通讯地址
/// </summary>
public string Address { get; set; }
}
/// <summary>
/// 初始化单表
/// </summary>
[Fact]
public void InitTableTestJHQ()
{
var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
//tenantDb.CodeFirst.InitTables(typeof(SpaceBookingOrder));
//tenantDb.CodeFirst.InitTables(typeof(SpaceBookingOrderCtn));
//tenantDb.CodeFirst.InitTables(typeof(SpaceBookingOrderShipSchedule));
//tenantDb.CodeFirst.InitTables(typeof(BookingSlotBase));
//tenantDb.CodeFirst.InitTables(typeof(BookingSlotCtn));
//tenantDb.CodeFirst.InitTables(typeof(BookingSlotStock));
tenantDb.CodeFirst.InitTables(typeof(BLIssueManageBase));
//tenantDb.CodeFirst.InitTables(typeof(DraftCompareFeedBackRecord));
//tenantDb.CodeFirst.InitTables(typeof(BookingSlotAllocationCtn));
//tenantDb.CodeFirst.InitTables(typeof(BookingSlotDemand));
//tenantDb.CodeFirst.InitTables(typeof(BookingSlotDemandCtn));
//tenantDb.CodeFirst.InitTables(typeof(BookingSlotCompare));
//tenantDb.CodeFirst.InitTables(typeof(BookingContractNoManage));
//tenantDb.CodeFirst.InitTables(typeof(BookingLabel));
//tenantDb.CodeFirst.InitTables(typeof(BookingLabelAllocation));
//tenantDb.CodeFirst.InitTables(typeof(InfoClient));
//tenantDb.CodeFirst.InitTables(typeof(CodeThirdParty));
//tenantDb.CodeFirst.InitTables(typeof(CheckBillAutoDetail));
//db.CodeFirst.InitTables(typeof(OpBusinessTruckCtn));
Assert.True(true);
}
/// <summary>
/// 初始化单表
/// </summary>
[Fact]
public void InitTableTestZXF()
{
var tenantDb = saasService.GetBizDbScopeById("1819549542425694208");
StaticConfig.CodeFirst_MySqlCollate = "utf8mb4_0900_ai_ci";//较高版本支持
//var ass = Assembly.Load("DS.WMS.Core");
//var types = ass.GetTypes().Where(it => it.FullName?.Contains("DS.WMS.Core.TaskPlat.Entity") == true).ToArray();
//tenantDb.CodeFirst.InitTables(types);
tenantDb.CodeFirst.InitTables(typeof(TaskBaseInfo));
//tenantDb.CodeFirst.InitTables(typeof(TaskFlowLogDetail));
Assert.True(true);
}
[Fact]
public async Task ZxfTest()
{
var tenantDb = saasService.GetBizDbScopeById("1819549542425694208");
var order = await tenantDb.Queryable<SeaExport>().FirstAsync(x => x.Id == 1816649497120477184);
TaskFlowDataContext dataContext = new(
(TaskFlowDataNameConst.Business, order)
);
TaskFlowRuner runer = new TaskFlowRuner(tenantDb, _serviceProvider);
//var result = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext);
}
}