Browse Source

Merge branch 'dev' of http://123.60.180.165:4647/ZZYDOP/DOPCore into dev

# Conflicts:
#	MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs
heteng 3 years ago
parent
commit
cd80e63f72

+ 0 - 1
MicroServices/Business/Business.Application/Business.Application.csproj

@@ -26,7 +26,6 @@
     <ProjectReference Include="..\Business.Domain\Business.Domain.csproj" />
     <ProjectReference Include="..\Business.EntityFrameworkCore\Business.EntityFrameworkCore.csproj" />
     <ProjectReference Include="..\Bussiness.Model\Business.Model.csproj" />
-    <ProjectReference Include="..\Bussiness.Model\Bussiness.Model.csproj" />
     <ProjectReference Include="..\Bussiness.MongoModel\Business.MongoModel.csproj" />
   </ItemGroup>
 

+ 10 - 54
MicroServices/Business/Business.Application/Quartz/ExtJobService.cs

@@ -3,6 +3,7 @@ using Business.EntityFrameworkCore;
 using Business.Model.Ext;
 using Business.Model.MES.IC;
 using Business.Model.SRM;
+using EFCore.BulkExtensions;
 using NLog;
 using System.Collections.Generic;
 using System.Linq;
@@ -300,96 +301,51 @@ namespace Business.Quartz
                 if (ic_itemListAdd.Count > 0)
                 {
                     //await _ic_item.InsertManyAsync(ic_itemListAdd);
-                    await _businessDbContext.ic_item.BulkInsertAsync(ic_itemListAdd, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessDbContext.BulkInsert(ic_itemListAdd);
                 }
                 if (ic_itemListUpdate.Count > 0)
                 {
                     //await _ic_item.UpdateManyAsync(ic_itemListUpdate);
-                    await _businessDbContext.ic_item.BulkUpdateAsync(ic_itemListUpdate, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.AutoMapOutputDirection = false;
-                        options.ColumnPrimaryKeyExpression = c => c.Id;
-                    });
+                    _businessDbContext.BulkUpdate(ic_itemListUpdate);
                 }
 
                 if (ic_factory_detailsListAdd.Count > 0)
                 {
                     //await _ic_factory_details.InsertManyAsync(ic_factory_detailsListAdd);
-                    await _businessDbContext.ic_factory_details.BulkInsertAsync(ic_factory_detailsListAdd, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessDbContext.BulkInsert(ic_factory_detailsListAdd);
                 }
                 if (ic_factory_detailsListUpdate.Count > 0)
                 {
                     //await _ic_factory_details.UpdateManyAsync(ic_factory_detailsListUpdate);
-                    await _businessDbContext.ic_factory_details.BulkUpdateAsync(ic_factory_detailsListUpdate, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.AutoMapOutputDirection = false;
-                        options.ColumnPrimaryKeyExpression = c => c.Id;
-                    });
+                    _businessDbContext.BulkUpdate(ic_factory_detailsListUpdate);
                 }
 
                 if (srm_purchaseListAdd.Count > 0)
                 {
                     //await _ic_item_pur.InsertManyAsync(ic_item_purListAdd);
-                    await _businessDbContext.srm_purchase.BulkInsertAsync(srm_purchaseListAdd, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessDbContext.BulkInsert(srm_purchaseListAdd);
                 }
                 if (srm_purchaseListUpdate.Count > 0)
                 {
                     //await _ic_item_pur.UpdateManyAsync(ic_item_purListUpdate);
-                    await _businessDbContext.srm_purchase.BulkUpdateAsync(srm_purchaseListUpdate, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.AutoMapOutputDirection = false;
-                        options.ColumnPrimaryKeyExpression = c => c.Id;
-                    });
+                    _businessDbContext.BulkUpdate(srm_purchaseListUpdate);
                 }
 
                 if (ic_planListAdd.Count > 0)
                 {
                     //await _ic_plan.InsertManyAsync(ic_planListAdd);
-                    await _businessDbContext.ic_plan.BulkInsertAsync(ic_planListAdd, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessDbContext.BulkInsert(ic_planListAdd);
                 }
                 if (ic_planListUpdate.Count > 0)
                 {
                     //await _ic_plan.UpdateManyAsync(ic_planListUpdate);
-                    await _businessDbContext.ic_plan.BulkUpdateAsync(ic_planListUpdate, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.AutoMapOutputDirection = false;
-                        options.ColumnPrimaryKeyExpression = c => c.Id;
-                    });
+                    _businessDbContext.BulkUpdate(ic_planListUpdate);
                 }
 
                 if (ext_xrefList.Count > 0)
                 {
                     //await _ext_xref.UpdateManyAsync(ext_xrefList);
-                    await _businessExtDbContext.ext_xref.BulkInsertAsync(ext_xrefList, options => 
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessExtDbContext.BulkInsert(ext_xrefList);
                 }
             }
         }

+ 4 - 3
MicroServices/Business/Business.Application/Quartz/ProductionScheduleAppService.cs

@@ -5,6 +5,7 @@ using Business.EntityFrameworkCore;
 using Business.EntityFrameworkCore.SqlRepositories;
 using Business.Model.MES.IC;
 using Business.Model.Production;
+using EFCore.BulkExtensions;
 using System;
 using System.Collections.Generic;
 using System.Collections.Immutable;
@@ -257,9 +258,9 @@ namespace Business.Quartz
                 await _workOrdMaster.Update(item);
             }
             //记录排产数据
-            await _businessDbContext.PeriodSequenceDet.BulkInsertAsync(periodSequenceDtls);
-            await _businessDbContext.ScheduleResultOpMaster.BulkInsertAsync(scheduleMasters);
-            await _businessDbContext.ScheduleExceptionMaster.BulkInsertAsync(scheduleExceptions);
+            _businessDbContext.BulkInsert(periodSequenceDtls);
+            _businessDbContext.BulkInsert(scheduleMasters);
+            _businessDbContext.BulkInsert(scheduleExceptions);
         }
 
         /// <summary>

+ 1 - 0
MicroServices/Business/Business.Application/ResourceExamineManagement/CalcBomViewAppService.cs

@@ -1155,6 +1155,7 @@ namespace Business.ResourceExamineManagement
                 //_srm_pr_main.InsertOne(srm_Pr);
                 decimal? totalLeadTime = leadTime.transportation_leadtime + leadTime.stock_leadtime + leadTime.production_leadtime + leadTime.order_leadtime;
                 srm_Pr.totalLeadTime= totalLeadTime;
+                srm_Pr.create_time = DateTime.Now;
                 sRMPR.srm_Pr_Main.Add(srm_Pr);
             });
             if (sRMPR.srm_Pr_Main.Any())

+ 18 - 17
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -27,7 +27,7 @@ using Volo.Abp.Application.Services;
 using Volo.Abp.DependencyInjection;
 using Volo.Abp.Domain.Repositories;
 using Volo.Abp.MultiTenancy;
-using Z.EntityFramework.Plus;
+using EFCore.BulkExtensions;
 using Business.Quartz;
 
 namespace Business.ResourceExamineManagement
@@ -531,7 +531,7 @@ namespace Business.ResourceExamineManagement
             {
                 await _mes_morder.InsertMany(_CalcBomViewAppService.mordersInsertList);
                 var mesorders = ObjectMapper.Map<List<mo_mes_morder>, List<mes_morder>>(_CalcBomViewAppService.mordersInsertList);
-                await _businessDbContext.mes_morder.BulkInsertAsync(mesorders, options => options.InsertKeepIdentity = true);
+                _businessDbContext.BulkInsert(mesorders);
                 rtn.mordersList = _CalcBomViewAppService.mordersInsertList;
             }
             if (_CalcBomViewAppService.mooccupyAllInsertList.Any())
@@ -543,13 +543,13 @@ namespace Business.ResourceExamineManagement
             {
                 await _mes_moentry.InsertMany(_CalcBomViewAppService.moentriesList);
                 var mesmoentrys = ObjectMapper.Map<List<mo_mes_moentry>, List<mes_moentry>>(_CalcBomViewAppService.moentriesList);
-                await _businessDbContext.mes_moentry.BulkInsertAsync(mesmoentrys, options => options.InsertKeepIdentity = true);
+                _businessDbContext.BulkInsert(mesmoentrys);
             }
             if (_CalcBomViewAppService.orderList.Any())
             {
                 await _mes_oorder.InsertMany(_CalcBomViewAppService.orderList);
                 var ooders = ObjectMapper.Map<List<mo_mes_oorder>, List<mes_oorder>>(_CalcBomViewAppService.orderList);
-                await _businessDbContext.mes_oorder.BulkInsertAsync(ooders, options => options.InsertKeepIdentity = true);
+                _businessDbContext.BulkInsert(ooders);
                 rtn.order_list = _CalcBomViewAppService.orderList;
             }
             if (sklist.Any())
@@ -576,7 +576,7 @@ namespace Business.ResourceExamineManagement
                 {
                     await _srm_pr_main.InsertMany(list);
                     var pr_mainlist = ObjectMapper.Map<List<mo_srm_pr_main>, List<srm_pr_main>>(list);
-                    await _businessDbContext.srm_pr_main.BulkInsertAsync(pr_mainlist, options => options.InsertKeepIdentity = true);
+                    _businessDbContext.BulkInsert(pr_mainlist);
                 }
                 rtn.srm_pr_list = _CalcBomViewAppService.SRMPRDtoList;
             }
@@ -654,31 +654,31 @@ namespace Business.ResourceExamineManagement
             }
             if (examineList.Any())
             {
-                await _businessBangDbContext.b_examine_result.BulkInsertAsync(examineList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(examineList);
             }
             if (bomExamineList.Any())
             {
-                await _businessBangDbContext.b_bom_child_examine.BulkInsertAsync(bomExamineList.OrderBy(s => s.num_order).ToList(), options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(bomExamineList.OrderBy(s => s.num_order).ToList());
             }
             if (mooccupyList.Any())
             {
-                await _businessBangDbContext.b_mo_occupy.BulkInsertAsync(mooccupyList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(mooccupyList);
             }
             if (moorderList.Any())
             {
-                await _businessBangDbContext.b_mo_order.BulkInsertAsync(moorderList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(moorderList);
             }
             if (ooderList.Any())
             {
-                await _businessBangDbContext.b_ooder.BulkInsertAsync(ooderList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(ooderList);
             }
             if (purchaseList.Any())
             {
-                await _businessBangDbContext.b_purchase.BulkInsertAsync(purchaseList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(purchaseList);
             }
             if (purchaseoccupyList.Any())
             {
-                await _businessBangDbContext.b_purchase_occupy.BulkInsertAsync(purchaseoccupyList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(purchaseoccupyList);
             }
             //清空快照数据
             await ClearSnapShot(bangid);
@@ -1333,15 +1333,15 @@ namespace Business.ResourceExamineManagement
             }
             if (examineList.Any())
             {
-                await _businessBangDbContext.b_order_examine_result.BulkInsertAsync(examineList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(examineList);
             }
             if (daybulletinboards.Any())
             {
-                await _businessBangDbContext.b_day_bulletin_board.BulkInsertAsync(daybulletinboards, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(daybulletinboards);
             }
             if (orderDetails.Any())
             {
-                await _businessBangDbContext.b_order_detail.BulkInsertAsync(orderDetails, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(orderDetails);
             }
             
         }
@@ -1751,11 +1751,12 @@ namespace Business.ResourceExamineManagement
             }
             if (deleteList.Any())
             {
-                 _businessDbContext.b_bom_pretreatment.BulkDelete(deleteList);
+                 _businessDbContext.BulkDelete(deleteList);
             }
             if (addList.Any())
             {
-                _businessDbContext.b_bom_pretreatment.BulkInsert(addList, options => options.InsertKeepIdentity = true);
+                _businessDbContext.BulkInsert(addList);
+
                 //await _mysql_b_bom_pretreatment.InsertManyAsync(addList);
             }
         }

+ 1 - 1
MicroServices/Business/Business.EntityFrameworkCore/Business.EntityFrameworkCore.csproj

@@ -11,6 +11,7 @@
 
   <ItemGroup>
     <PackageReference Include="Abp" Version="3.4.0" />
+    <PackageReference Include="EFCore.BulkExtensions" Version="6.0.3" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.5">
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -24,7 +25,6 @@
     <PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="6.0.0" />
     <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="6.0.3" />
     <PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="6.0.0" />
-    <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="6.20.1" />
   </ItemGroup>
 
   <ItemGroup>

+ 3 - 3
MicroServices/Business/Business.EntityFrameworkCore/Repository/SqlRepositories/SqlRepository.cs

@@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore;
 using System.Collections;
 using Business.EntityFrameworkCore;
 using System.Linq.Expressions;
-using Z.EntityFramework.Plus;
 using System.Data.SqlClient;
+using EFCore.BulkExtensions;
 
 namespace Business.EntityFrameworkCore.SqlRepositories
 {
@@ -38,13 +38,13 @@ namespace Business.EntityFrameworkCore.SqlRepositories
 
         public  async Task<int> Update(Expression<Func<T, bool>> whereLambda, Expression<Func<T, T>> entity)
         {
-            _dbContextProvider.GetDbContext().Set<T>().Where(whereLambda).Update(entity);
+            _dbContextProvider.GetDbContext().Set<T>().Where(whereLambda).BatchUpdate(entity);
             return await _dbContextProvider.GetDbContext().SaveChangesAsync();
         }
 
         public  async Task<int> Delete(Expression<Func<T, bool>> whereLambda)
         {
-            _dbContextProvider.GetDbContext().Set<T>().Where(whereLambda).Delete();
+            _dbContextProvider.GetDbContext().Set<T>().Where(whereLambda).BatchDelete();
             return await _dbContextProvider.GetDbContext().SaveChangesAsync();
         }
 

+ 1 - 0
MicroServices/Business/Business.Host/Business.Host.csproj.user

@@ -5,5 +5,6 @@
   </PropertyGroup>
   <PropertyGroup>
     <ActiveDebugProfile>Business.Host</ActiveDebugProfile>
+    <NameOfLastUsedPublishProfile>D:\Project\DOPCore\MicroServices\Business\Business.Host\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
   </PropertyGroup>
 </Project>