Forráskód Böngészése

实体索引调整和修复

Murphy 2 éve
szülő
commit
359254cdf7
25 módosított fájl, 54 hozzáadás és 43 törlés
  1. 2 1
      MicroServices/Business/Business.Domain/MongoDB/Base/MoBaseEntity.cs
  2. 2 1
      MicroServices/Business/Business.Domain/StructuredDB/Base/BaseEntity.cs
  3. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_bom.cs
  4. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_bom_child.cs
  5. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item.cs
  6. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item_stock.cs
  7. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item_stockoccupy.cs
  8. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Production/MonthlyProdCapacityDtl.cs
  9. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Production/MonthlyProdCapacityMain.cs
  10. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Production/OverallDemandPlanDtl.cs
  11. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_po_list.cs
  12. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_po_main.cs
  13. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_pr_main.cs
  14. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_purchase.cs
  15. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_supplier.cs
  16. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_customer.cs
  17. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_seorder.cs
  18. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_seorderentry.cs
  19. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/DomesticTerminalFcst.cs
  20. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/OverseasSaleFcst.cs
  21. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/PlatformFcstCollect.cs
  22. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/StandardItemModelSet.cs
  23. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/YearDemandManagement.cs
  24. 20 20
      MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContextModelCreatingExtensions.cs
  25. 9 0
      MicroServices/Business/Business.Host/BusinessHostModule.cs

+ 2 - 1
MicroServices/Business/Business.Domain/MongoDB/Base/MoBaseEntity.cs

@@ -72,7 +72,8 @@ namespace Business.Domain
         /// </summary>
         [Required]
         [Comment("租户ID")]
-        public virtual long? tenant_id { get; set; }
+        [DefaultValue(1000)]
+        public virtual long tenant_id { get; set; }
         /// <summary>
         /// 公司ID
         /// </summary>

+ 2 - 1
MicroServices/Business/Business.Domain/StructuredDB/Base/BaseEntity.cs

@@ -67,7 +67,8 @@ namespace Business.Domain
         /// </summary>
         [Required]
         [Comment("租户ID")]
-        public virtual long? tenant_id { get; set; }
+        [DefaultValue(1000)]
+        public virtual long tenant_id { get; set; }
 
         /// <summary>
         /// 公司ID

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_bom.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_bom")]
     [Comment("物料BOM")]
-    [Index(nameof(bom_number), nameof(item_number), nameof(version), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(bom_number), nameof(item_number), nameof(version), nameof(tenant_id), nameof(company_id), nameof(factory_id),IsUnique = true)]
     public class ic_bom : BaseEntity
     {
         public ic_bom(long Id) : base(Id)

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_bom_child.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_bom_child")]
     [Comment("物料BOM明细")]
-    [Index(nameof(bom_number), nameof(item_number), nameof(version), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(bom_number), nameof(item_number), nameof(version), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class ic_bom_child : BaseEntity
     {
         public ic_bom_child(long Id) : base(Id)

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_item")]
     [Comment("物料详情")]
-    [Index(nameof(number), nameof(fversion), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(number), nameof(fversion), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class ic_item : BaseEntity
     {
         public ic_item(long Id) : base(Id)

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item_stock.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_item_stock")]
     [Comment("物料库存表")]
-    [Index(nameof(icitem_number), nameof(fversion), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(icitem_number), nameof(fversion), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class ic_item_stock : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item_stockoccupy.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_item_stockoccupy")]
     [Comment("资源检查物料占用明细表")]
-    [Index(nameof(orderentry_id), nameof(icitem_number), nameof(fversion), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(orderentry_id), nameof(icitem_number), nameof(fversion), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class ic_item_stockoccupy : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Production/MonthlyProdCapacityDtl.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 月度产能共识明细表
     /// </summary>
     [Comment("月度产能共识主表")]
-    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(tenant_id), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
     public class MonthlyProdCapacityDtl
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Production/MonthlyProdCapacityMain.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 月度产能共识主表
     /// </summary>
     [Comment("月度产能共识主表")]
-    [Index(nameof(Year), nameof(Month), nameof(ProdRange), nameof(Model), nameof(ProdLine), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(ProdRange), nameof(Model), nameof(ProdLine), nameof(tenant_id), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
     public class MonthlyProdCapacityMain
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Production/OverallDemandPlanDtl.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 整体需求计划明细表
     /// </summary>
     [Comment("整体需求计划明细表")]
-    [Index(nameof(Version), nameof(ProdRange), nameof(Model), nameof(PlanDate), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Version), nameof(ProdRange), nameof(Model), nameof(PlanDate), nameof(tenant_id), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
     public class OverallDemandPlanDtl
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_po_list.cs

@@ -11,7 +11,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "srm_po_list")]
     [Comment("采购订单明细详情")]
-    [Index(nameof(po_billno), nameof(polist_row), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(po_billno), nameof(polist_row), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_po_list : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_po_main.cs

@@ -11,7 +11,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "srm_po_main")]
     [Comment("采购订单")]
-    [Index(nameof(po_billno), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(po_billno), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_po_main : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_pr_main.cs

@@ -11,7 +11,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "srm_pr_main")]
     [Comment("采购申请单")]
-    [Index(nameof(pr_billno), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(pr_billno), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_pr_main : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_purchase.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "srm_purchase")]
     [Comment("物料采购报价单")]
-    [Index(nameof(number), nameof(supplier_number), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(number), nameof(supplier_number), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_purchase : BaseEntity
     {
 

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_supplier.cs

@@ -11,7 +11,7 @@ namespace Business.Domain
     /// </summary>
     [Comment("供应商")]
     [CollectionName("dopbase", "srm_supplier")]
-    [Index(nameof(supplier_no), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(supplier_no), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_supplier : BaseEntity
     {
         ///// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_customer.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [Comment("客户")]
     [CollectionName("dopbase", "crm_customer")]
-    [Index(nameof(customer_no), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(customer_no), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class crm_customer : BaseEntity
     {
         ///// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_seorder.cs

@@ -12,7 +12,7 @@ namespace Business.Domain
     /// </summary>
     [Comment("销售订单表")]
     [CollectionName("dopbase", "crm_seorder")]
-    [Index(nameof(bill_no), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(bill_no), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class crm_seorder : BaseEntity
     {
         ///// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_seorderentry.cs

@@ -12,7 +12,7 @@ namespace Business.Domain
     /// </summary>
     [Comment("销售订单明细表")]
     [CollectionName("dopbase", "crm_seorderentry")]
-    [Index(nameof(bill_no), nameof(entry_seq), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(bill_no), nameof(entry_seq), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class crm_seorderentry : BaseEntity
     {
         ///// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/DomesticTerminalFcst.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 国内终端预测表
     /// </summary>
     [Comment("国内终端预测表")]
-    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(Model),nameof(TypeEnum),nameof(PlanMonth),nameof(company_id), nameof(company_id),nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(Model),nameof(TypeEnum),nameof(PlanMonth),nameof(tenant_id), nameof(company_id),nameof(factory_id), IsUnique = true)]
     public class DomesticTerminalFcst:BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/OverseasSaleFcst.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 海外销售预测表
     /// </summary>
     [Comment("海外销售预测表")]
-    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(Model),nameof(Language),nameof(PlanMonth),nameof(company_id),nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(Model),nameof(Language),nameof(PlanMonth),nameof(tenant_id),nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class OverseasSaleFcst : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/PlatformFcstCollect.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 平台预测收集表
     /// </summary>
     [Comment("平台预测收集表")]
-    [Index(nameof(Year), nameof(Month), nameof(Platform), nameof(Model),nameof(ProdType),nameof(PlanMonth),nameof(company_id),nameof(company_id),nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(Platform), nameof(Model),nameof(ProdType),nameof(PlanMonth),nameof(tenant_id),nameof(company_id),nameof(factory_id), IsUnique = true)]
     public class PlatformFcstCollect : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/StandardItemModelSet.cs

@@ -14,7 +14,7 @@ namespace Business.Domain
     /// 标准物料规格型号设置表
     /// </summary>
     [Comment("标准物料规格型号设置表")]
-    [Index(nameof(Model),nameof(ItemNumber), nameof(company_id),nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Model),nameof(ItemNumber), nameof(tenant_id),nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class StandardItemModelSet:BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/YearDemandManagement.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 年度生产需求管理表
     /// </summary>
     [Comment("年度生产需求管理表")]
-    [Index(nameof(Year), nameof(Area), nameof(ProdLine),nameof(ProdRange), nameof(Line),nameof(Model),nameof(PlanMonth),nameof(company_id), nameof(company_id),nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Area), nameof(ProdLine),nameof(ProdRange), nameof(Line),nameof(Model),nameof(PlanMonth),nameof(tenant_id), nameof(company_id),nameof(factory_id), IsUnique = true)]
     public class YearDemandManagement:BaseEntity
     {
         /// <summary>

+ 20 - 20
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContextModelCreatingExtensions.cs

@@ -14,7 +14,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_bom>(b =>
             {
                 b.ToTable("ic_bom");
-                b.HasIndex(b => new { b.bom_number, b.item_number,b.version, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.bom_number, b.item_number,b.version,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -22,7 +22,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_bom_child>(b =>
             {
                 b.ToTable("ic_bom_child");
-                b.HasIndex(b => new { b.bom_id,b.bom_number, b.item_number, b.version, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.bom_id,b.bom_number, b.item_number, b.version,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -30,7 +30,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_item>(b =>
             {
                 b.ToTable("ic_item");
-                b.HasIndex(b => new { b.number, b.name,b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.number, b.name,b.tenant_id,b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -38,7 +38,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_item_stock>(b =>
             {
                 b.ToTable("ic_item_stock");
-                b.HasIndex(b => new { b.icitem_id, b.icitem_name, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.icitem_id, b.icitem_name,b.tenant_id, b.company_id, b.factory_id });
                 //不映射到数据库中
                 b.Ignore(x => x.bang_id);
                 b.ConfigureByConvention();
@@ -48,7 +48,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_substitute>(b =>
             {
                 b.ToTable("ic_substitute");
-                b.HasIndex(b => new { b.substitute_code, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.substitute_code,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -56,7 +56,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_substitute_group>(b =>
             {
                 b.ToTable("ic_substitute_group");
-                b.HasIndex(b => new { b.substitute_code, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.substitute_code,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -64,7 +64,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_substitute_group_detail>(b =>
             {
                 b.ToTable("ic_substitute_group_detail");
-                b.HasIndex(b => new { b.substitute_code,b.icitem_number, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.substitute_code,b.icitem_number,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -72,7 +72,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_po_list>(b =>
             {
                 b.ToTable("srm_po_list");
-                b.HasIndex(b => new { b.po_billno, b.number, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.po_billno, b.number,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -80,7 +80,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_po_main>(b =>
             {
                 b.ToTable("srm_po_main");
-                b.HasIndex(b => new { b.po_billno, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.po_billno,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -88,7 +88,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_purchase>(b =>
             {
                 b.ToTable("srm_purchase");
-                b.HasIndex(b => new {b.icitem_id, b.supplier_number, b.company_id, b.factory_id });
+                b.HasIndex(b => new {b.icitem_id, b.supplier_number,b.tenant_id, b.company_id, b.factory_id });
                 b.Ignore(x => x.bang_id);
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
@@ -97,7 +97,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_po_occupy>(b =>
             {
                 b.ToTable("srm_po_occupy");
-                b.HasIndex(b => new { b.polist_id, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.polist_id,b.tenant_id, b.company_id, b.factory_id });
                 b.Ignore(v => v.bang_id);
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
@@ -106,7 +106,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_pr_main>(b =>
             {
                 b.ToTable("srm_pr_main");
-                b.HasIndex(b => new { b.pr_billno,b.pr_purchasenumber,b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.pr_billno, b.pr_purchasenumber, b.tenant_id, b.company_id, b.factory_id });
                 b.Ignore(v => v.bang_id);
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
@@ -115,7 +115,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_moentry>(b =>
             {
                 b.ToTable("mes_moentry");
-                b.HasIndex(b => new { b.moentry_moid, b.moentry_mono, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.moentry_moid, b.moentry_mono, b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -123,7 +123,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_mooccupy>(b =>
             {
                 b.ToTable("mes_mooccupy");
-                b.HasIndex(b => new { b.moo_id_billid, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.moo_id_billid,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -131,7 +131,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_morder>(b =>
             {
                 b.ToTable("mes_morder");
-                b.HasIndex(b => new { b.morder_no, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.morder_no,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -147,7 +147,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_stockoccupy>(b =>
             {
                 b.ToTable("mes_stockoccupy");
-                b.HasIndex(b => new { b.fbill_no,b.fitem_number, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.fbill_no,b.fitem_number,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -157,7 +157,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<crm_seorder>(b =>
             {
                 b.ToTable("crm_seorder");
-                b.HasIndex(b => new { b.bill_no, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.bill_no,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -165,7 +165,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<crm_seorderentry>(b =>
             {
                 b.ToTable("crm_seorderentry");
-                b.HasIndex(b => new { b.seorder_id, b.bill_no,b.item_number,b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.seorder_id, b.bill_no,b.item_number,b.tenant_id,b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -173,7 +173,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<crm_customer>(b =>
             {
                 b.ToTable("crm_customer");
-                b.HasIndex(b => new { b.customer_no, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.customer_no,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -181,7 +181,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_supplier>(b =>
             {
                 b.ToTable("srm_supplier");
-                b.HasIndex(b => new { b.supplier_no, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.supplier_no,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });

+ 9 - 0
MicroServices/Business/Business.Host/BusinessHostModule.cs

@@ -165,6 +165,7 @@ namespace Business
                Ascending(_ => _.bom_number).
                Ascending(_ => _.item_number).
                Ascending(_ => _.version).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id)
                , new CreateIndexOptions
@@ -183,6 +184,7 @@ namespace Business
                Ascending(_ => _.bom_number).
                Ascending(_ => _.item_number).
                Ascending(_ => _.version).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id)
                , new CreateIndexOptions
@@ -200,6 +202,7 @@ namespace Business
                Builders<mo_ic_item>.IndexKeys.
                Ascending(_ => _.number).
                Ascending(_ => _.fversion).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id)
                , new CreateIndexOptions
@@ -217,6 +220,7 @@ namespace Business
                Builders<mo_ic_item_stock>.IndexKeys.
                Ascending(_ => _.icitem_number).
                Ascending(_ => _.fversion).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -236,6 +240,7 @@ namespace Business
                Builders<mo_srm_po_list>.IndexKeys.
                Ascending(_ => _.po_billno).
                Ascending(_ => _.polist_row).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -253,6 +258,7 @@ namespace Business
             CreateIndexModel<mo_srm_po_main> indexModel_mo_srm_po_main = new CreateIndexModel<mo_srm_po_main>(
                Builders<mo_srm_po_main>.IndexKeys.
                Ascending(_ => _.po_billno).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -270,6 +276,7 @@ namespace Business
             CreateIndexModel<mo_srm_pr_main> indexModel_mo_srm_pr_main = new CreateIndexModel<mo_srm_pr_main>(
                Builders<mo_srm_pr_main>.IndexKeys.
                Ascending(_ => _.pr_billno).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -288,6 +295,7 @@ namespace Business
                Builders<mo_srm_purchase>.IndexKeys.
                Ascending(_ => _.number).
                Ascending(_ => _.supplier_number).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -305,6 +313,7 @@ namespace Business
             CreateIndexModel<mo_srm_supplier> indexModel_mo_srm_supplier = new CreateIndexModel<mo_srm_supplier>(
                Builders<mo_srm_supplier>.IndexKeys.
                Ascending(_ => _.supplier_no).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id)
                , new CreateIndexOptions