Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
d0d91b94
Commit
d0d91b94
authored
Nov 29, 2024
by
wyc
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ORM' into develop
parents
0650f856
ddf312c5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
128 deletions
+148
-128
performance/Performance.Repository/InfraRepository.cs
+20
-0
performance/Performance.Repository/Performance.Repository.csproj
+2
-1
performance/Performance.Services/AllotCompute/EPImportDataService.cs
+17
-9
performance/Performance.Services/AllotCompute/ImportDataService.cs
+109
-118
No files found.
performance/Performance.Repository/InfraRepository.cs
0 → 100644
View file @
d0d91b94
using
SqlSugar
;
namespace
Performance.Repository
{
public
class
InfraRepository
{
public
static
SqlSugarClient
GetDbclient
(
string
connectionString
)
{
return
new
SqlSugarClient
(
new
ConnectionConfig
()
{
ConnectionString
=
connectionString
,
DbType
=
SqlSugar
.
DbType
.
MySql
,
IsAutoCloseConnection
=
true
},
db
=>
{
});
}
}
}
performance/Performance.Repository/Performance.Repository.csproj
View file @
d0d91b94
...
@@ -6,8 +6,9 @@
...
@@ -6,8 +6,9 @@
<ItemGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="5.0.18" />
<PackageReference Include="Npgsql" Version="5.0.18" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.
4
" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.
100
" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.170" />
</ItemGroup>
</ItemGroup>
...
...
performance/Performance.Services/AllotCompute/EPImportDataService.cs
View file @
d0d91b94
...
@@ -10,9 +10,11 @@
...
@@ -10,9 +10,11 @@
using
Performance.EntityModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Infrastructure
;
using
Performance.Infrastructure.Extensions
;
using
Performance.Infrastructure.Extensions
;
using
Performance.Repository
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Data
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Drawing
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
...
@@ -131,18 +133,24 @@ public List<ImportData> ReadSheetData(per_allot allot)
...
@@ -131,18 +133,24 @@ public List<ImportData> ReadSheetData(per_allot allot)
try
try
{
{
//var connectionString = _configuration.GetValue("AppConnection:PerformanceConnectionString", "");
//var tasks = new List<Task>();
//foreach (var sheetName in importDatas.Select(w => w.SheetName).Distinct())
//{
// var task = Task.Factory.StartNew(() =>
// {
// var items = importDatas.Where(w => w.SheetName == sheetName).ToList();
// DapperExtensions.BulkInsert(connectionString, items, tableName: "im_orig_data", commandTimeout: 60 * 60 * 5);
// });
// tasks.Add(task);
//}
//Task.WaitAll(tasks.ToArray());
var
connectionString
=
_configuration
.
GetValue
(
"AppConnection:PerformanceConnectionString"
,
""
);
var
connectionString
=
_configuration
.
GetValue
(
"AppConnection:PerformanceConnectionString"
,
""
);
var
tasks
=
new
List
<
Task
>(
);
var
db
=
InfraRepository
.
GetDbclient
(
connectionString
);
foreach
(
var
sheetName
in
importDatas
.
Select
(
w
=>
w
.
SheetName
).
Distinct
())
if
(
importDatas
.
Any
())
{
{
var
task
=
Task
.
Factory
.
StartNew
(()
=>
db
.
Fastest
<
ImportData
>().
AS
(
"im_orig_data"
).
PageSize
(
100000
).
BulkCopy
(
importDatas
);
{
var
items
=
importDatas
.
Where
(
w
=>
w
.
SheetName
==
sheetName
).
ToList
();
DapperExtensions
.
BulkInsert
(
connectionString
,
items
,
tableName
:
"im_orig_data"
,
commandTimeout
:
60
*
60
*
5
);
});
tasks
.
Add
(
task
);
}
}
Task
.
WaitAll
(
tasks
.
ToArray
());
_logManageService
.
WriteMsg
(
"保存基础数据"
,
$"基础数据保存完成!"
,
1
,
allot
.
ID
,
"ReceiveMessage"
,
true
);
_logManageService
.
WriteMsg
(
"保存基础数据"
,
$"基础数据保存完成!"
,
1
,
allot
.
ID
,
"ReceiveMessage"
,
true
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
...
performance/Performance.Services/AllotCompute/ImportDataService.cs
View file @
d0d91b94
using
System
;
using
AutoMapper
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
AutoMapper
;
using
Dapper
;
using
Dapper
;
using
Dapper.Contrib.Extensions
;
using
Dapper.Contrib.Extensions
;
using
Microsoft.Extensions.Options
;
using
Microsoft.Extensions.Options
;
using
MySql.Data.MySqlClient
;
using
NPOI.HSSF.UserModel
;
using
NPOI.HSSF.UserModel
;
using
NPOI.SS.UserModel
;
using
NPOI.SS.UserModel
;
using
NPOI.XSSF.UserModel
;
using
NPOI.XSSF.UserModel
;
...
@@ -16,6 +9,13 @@
...
@@ -16,6 +9,13 @@
using
Performance.DtoModels.AppSettings
;
using
Performance.DtoModels.AppSettings
;
using
Performance.EntityModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Infrastructure
;
using
Performance.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Performance.Services.AllotCompute
namespace
Performance.Services.AllotCompute
{
{
...
@@ -49,10 +49,13 @@ public class ImportDataService : IAutoInjection
...
@@ -49,10 +49,13 @@ public class ImportDataService : IAutoInjection
public
PerExcel
ReadDataAndSave
(
per_allot
allot
)
public
PerExcel
ReadDataAndSave
(
per_allot
allot
)
{
{
var
excel
=
Import
(
allot
);
var
excel
=
Import
(
allot
);
Save
(
excel
,
allot
.
ID
);
bool
isSave
=
Save
(
excel
,
allot
.
ID
);
if
(
isSave
)
{
var
item
=
excel
.
PerSheet
.
FirstOrDefault
(
w
=>
w
.
SheetType
==
SheetType
.
AccountBasicSpecial
);
var
item
=
excel
.
PerSheet
.
FirstOrDefault
(
w
=>
w
.
SheetType
==
SheetType
.
AccountBasicSpecial
);
if
(
item
!=
null
)
if
(
item
!=
null
)
excel
.
PerSheet
.
Remove
(
item
);
excel
.
PerSheet
.
Remove
(
item
);
}
return
excel
;
return
excel
;
}
}
...
@@ -123,57 +126,27 @@ private PerExcel Import(per_allot allot)
...
@@ -123,57 +126,27 @@ private PerExcel Import(per_allot allot)
private
bool
Save
(
PerExcel
excel
,
int
allotId
)
private
bool
Save
(
PerExcel
excel
,
int
allotId
)
{
{
var
tasks
=
new
List
<
Task
>();
var
db
=
InfraRepository
.
GetDbclient
(
_options
.
Value
.
PerformanceConnectionString
);
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
{
var
allotList
=
db
.
Ado
.
SqlQuery
<
per_allot
>(
"SELECT * FROM per_allot WHERE allotId = @allotId ORDER BY Year DESC, Month DESC"
,
new
{
allotId
}).
ToList
();
var
allot
=
allotList
.
FirstOrDefault
();
var
sheets
=
db
.
Ado
.
SqlQuery
<
per_sheet
>(
"select * from per_sheet where AllotID = @allotId"
,
new
{
allotId
}).
ToList
();
foreach
(
var
sheet
in
excel
.
PerSheet
)
foreach
(
var
sheet
in
excel
.
PerSheet
)
{
{
_logManageService
.
WriteMsg
(
"准备保存数据"
,
$"正在准备保存数据“
{
sheet
.
SheetName
}
”"
,
1
,
allotId
,
"ReceiveMessage"
,
true
);
_logManageService
.
WriteMsg
(
"准备保存数据"
,
$"正在准备保存数据“
{
sheet
.
SheetName
}
”"
,
1
,
allotId
,
"ReceiveMessage"
,
true
);
Func
<
int
>
saveHandler
=
sheet
.
SheetType
switch
var
allot
=
connection
.
Get
<
per_allot
>(
allotId
);
{
var
allotList
=
connection
.
Query
<
per_allot
>(
"select * from per_allot where HospitalId = @HospitalId"
,
new
{
allot
.
HospitalId
}).
ToList
();
SheetType
.
Employee
=>
()
=>
SaveEmployee
(
sheet
,
allot
,
allotList
),
var
sheets
=
connection
.
Query
<
per_sheet
>(
"select * from per_sheet where AllotID = @allotId"
,
new
{
allotId
}).
ToList
();
SheetType
.
LogisticsEmployee
=>
()
=>
SaveLogisticsEmployee
(
sheet
,
allot
,
allotList
),
SheetType
.
ClinicEmployee
=>
()
=>
SaveClinicEmployee
(
sheet
,
allot
,
allotList
),
var
task
=
Task
.
Factory
.
StartNew
(()
=>
SheetType
.
AccountBasic
=>
()
=>
SaveAccountBasic
(
sheet
,
allot
,
sheets
),
{
SheetType
.
SpecialUnit
=>
()
=>
SaveSpecialUnit
(
sheet
,
allot
),
if
(
sheet
.
SheetType
==
SheetType
.
Employee
)
_
=>
()
=>
SaveCommon
(
sheet
,
allot
,
sheets
),
{
};
var
imsheetid
=
SaveEmployee
(
sheet
,
allot
,
allotList
);
var
imsheetid
=
saveHandler
();
SaveHeader
(
sheet
,
allot
,
imsheetid
);
}
else
if
(
sheet
.
SheetType
==
SheetType
.
LogisticsEmployee
)
{
var
imsheetid
=
SaveLogisticsEmployee
(
sheet
,
allot
,
allotList
);
SaveHeader
(
sheet
,
allot
,
imsheetid
);
}
else
if
(
sheet
.
SheetType
==
SheetType
.
ClinicEmployee
)
{
var
imsheetid
=
SaveClinicEmployee
(
sheet
,
allot
,
allotList
);
SaveHeader
(
sheet
,
allot
,
imsheetid
);
}
else
if
(
sheet
.
SheetType
==
SheetType
.
AccountBasic
)
{
var
imsheetid
=
SaveAccountBasic
(
sheet
,
allot
,
sheets
);
SaveHeader
(
sheet
,
allot
,
imsheetid
);
}
else
if
(
sheet
.
SheetType
==
SheetType
.
SpecialUnit
)
{
var
imsheetid
=
SaveSpecialUnit
(
sheet
,
allot
);
SaveHeader
(
sheet
,
allot
,
imsheetid
);
}
else
{
var
imsheetid
=
SaveCommon
(
sheet
,
allot
,
sheets
);
SaveHeader
(
sheet
,
allot
,
imsheetid
);
SaveHeader
(
sheet
,
allot
,
imsheetid
);
}
}
});
//_logManageService.WriteMsg("保存基础数据", $"基础数据保存中...当前操作需要一点时间,请耐心等待", 1, allotId, "ReceiveMessage", true);
tasks
.
Add
(
task
);
}
}
_logManageService
.
WriteMsg
(
"保存基础数据"
,
$"基础数据保存中...当前操作需要一点时间,请耐心等待"
,
1
,
allotId
,
"ReceiveMessage"
,
true
);
Task
.
WaitAll
(
tasks
.
ToArray
());
_logManageService
.
WriteMsg
(
"保存基础数据"
,
$"基础数据保存完成!"
,
1
,
allotId
,
"ReceiveMessage"
,
true
);
_logManageService
.
WriteMsg
(
"保存基础数据"
,
$"基础数据保存完成!"
,
1
,
allotId
,
"ReceiveMessage"
,
true
);
return
true
;
return
true
;
}
}
...
@@ -186,38 +159,42 @@ private bool Save(PerExcel excel, int allotId)
...
@@ -186,38 +159,42 @@ private bool Save(PerExcel excel, int allotId)
/// <returns></returns>
/// <returns></returns>
public
int
SaveEmployee
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_allot
>
allotList
)
public
int
SaveEmployee
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_allot
>
allotList
)
{
{
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
var
db
=
InfraRepository
.
GetDbclient
(
_options
.
Value
.
PerformanceConnectionString
);
{
var
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
var
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
imsheet
.
ID
=
(
int
)
connection
.
Insert
(
imsheet
);
imsheet
.
ID
=
db
.
Insertable
(
imsheet
).
AS
(
"per_sheet"
).
ExecuteReturnIdentity
(
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataEmployee
)
t
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataEmployee
)
t
);
//新上传名单中无人员名单,取到最后
日期的数据
//新上传名单中无人员名单,取到当前绩效月下的,还是没有就取倒叙
日期的数据
if
(
dataList
==
null
||
dataList
.
Count
()
<=
0
)
if
(!
dataList
.
Any
()
)
{
{
foreach
(
var
item
in
allotList
)
var
empList
=
db
.
Ado
.
SqlQuery
<
im_employee
>(
"select * from im_employee where AllotID = @allotid"
,
new
{
AllotID
=
allot
.
ID
}).
ToList
();
if
(
empList
.
Any
())
{
dataList
=
_mapper
.
Map
<
List
<
PerDataEmployee
>>(
empList
);
}
else
{
{
var
employeeList
=
connection
.
Query
<
im_employee
>(
"select * from im_employee where AllotID = @allotid"
,
new
{
AllotID
=
allot
.
ID
}
);
empList
=
db
.
Ado
.
SqlQuery
<
im_employee
>(
"select * from im_employee "
).
ToList
(
);
if
(
employeeList
!=
null
&&
employeeList
.
Count
()
>
0
)
foreach
(
var
item
in
allotList
)
{
{
dataList
=
_mapper
.
Map
<
List
<
PerDataEmployee
>>(
employeeList
);
var
emp
=
empList
.
Where
(
w
=>
w
.
AllotID
==
item
.
ID
).
ToList
();
if
(!
emp
.
Any
())
continue
;
dataList
=
_mapper
.
Map
<
List
<
PerDataEmployee
>>(
emp
);
break
;
break
;
}
}
}
}
}
}
List
<
im_employee
>
addList
=
new
List
<
im_employee
>();
var
addList
=
new
List
<
im_employee
>();
foreach
(
var
data
in
dataList
)
foreach
(
var
data
in
dataList
)
{
{
var
imdata
=
_mapper
.
Map
<
im_employee
>(
data
);
var
imdata
=
_mapper
.
Map
<
im_employee
>(
data
);
imdata
.
SheetID
=
imsheet
.
ID
;
imdata
.
SheetID
=
imsheet
.
ID
;
imdata
.
AllotID
=
allot
.
ID
;
imdata
.
AllotID
=
allot
.
ID
;
//imdata.OtherPerfor = data.OthePerfor;
addList
.
Add
(
imdata
);
addList
.
Add
(
imdata
);
}
}
connection
.
Insert
(
addList
.
ToArray
()
);
db
.
Insertable
(
addList
).
ExecuteCommand
(
);
return
imsheet
.
ID
;
return
imsheet
.
ID
;
}
#
region
旧代码
//var imsheet = new per_sheet { AllotID =allot.ID, SheetName = sheet.SheetName, Source = 1, SheetType = (int)sheet.SheetType };
//var imsheet = new per_sheet { AllotID =allot.ID, SheetName = sheet.SheetName, Source = 1, SheetType = (int)sheet.SheetType };
//perforPerSheetRepository.Add(imsheet);
//perforPerSheetRepository.Add(imsheet);
//var dataList = sheet.PerData.Select(t => (PerDataEmployee)t);
//var dataList = sheet.PerData.Select(t => (PerDataEmployee)t);
...
@@ -248,6 +225,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi
...
@@ -248,6 +225,7 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi
//}
//}
//perforImEmployeeRepository.BulkInsert(addList.ToArray());
//perforImEmployeeRepository.BulkInsert(addList.ToArray());
//return imsheet.ID;
//return imsheet.ID;
#
endregion
}
}
/// <summary>
/// <summary>
...
@@ -258,21 +236,27 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi
...
@@ -258,21 +236,27 @@ public int SaveEmployee(PerSheet sheet, per_allot allot, List<per_allot> allotLi
/// <returns></returns>
/// <returns></returns>
public
int
SaveClinicEmployee
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_allot
>
allotList
)
public
int
SaveClinicEmployee
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_allot
>
allotList
)
{
{
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
var
db
=
InfraRepository
.
GetDbclient
(
_options
.
Value
.
PerformanceConnectionString
);
{
var
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
var
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
imsheet
.
ID
=
(
int
)
connection
.
Insert
(
imsheet
);
imsheet
.
ID
=
db
.
Insertable
(
imsheet
).
AS
(
"per_sheet"
).
ExecuteReturnIdentity
(
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataClinicEmployee
)
t
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataClinicEmployee
)
t
);
//新上传名单中无人员名单,取到最后日期的数据
//新上传名单中无人员名单,取到最后日期的数据
if
(
dataList
==
null
||
dataList
.
Count
()
<=
0
)
if
(!
dataList
.
Any
()
)
{
{
foreach
(
var
item
in
allotList
)
var
empList
=
db
.
Ado
.
SqlQuery
<
im_employee_clinic
>(
"select * from im_employee_clinic where AllotID = @allotid"
,
new
{
AllotID
=
allot
.
ID
}).
ToList
();
if
(
empList
.
Any
())
{
{
var
employeeList
=
connection
.
Query
<
im_employee_clinic
>(
"select * from im_employee_clinic where AllotID = @allotid"
,
new
{
AllotID
=
allot
.
ID
});
dataList
=
_mapper
.
Map
<
List
<
PerDataClinicEmployee
>>(
empList
);
if
(
employeeList
!=
null
&&
employeeList
.
Count
()
>
0
)
}
else
{
{
dataList
=
_mapper
.
Map
<
List
<
PerDataClinicEmployee
>>(
employeeList
);
empList
=
db
.
Ado
.
SqlQuery
<
im_employee_clinic
>(
"select * from im_employee_clinic "
).
ToList
();
foreach
(
var
item
in
allotList
)
{
var
emp
=
empList
.
Where
(
w
=>
w
.
AllotID
==
item
.
ID
).
ToList
();
if
(!
emp
.
Any
())
continue
;
dataList
=
_mapper
.
Map
<
List
<
PerDataClinicEmployee
>>(
emp
);
break
;
break
;
}
}
}
}
...
@@ -286,9 +270,9 @@ public int SaveClinicEmployee(PerSheet sheet, per_allot allot, List<per_allot> a
...
@@ -286,9 +270,9 @@ public int SaveClinicEmployee(PerSheet sheet, per_allot allot, List<per_allot> a
imdata
.
OtherPerfor
=
data
.
OthePerfor
;
imdata
.
OtherPerfor
=
data
.
OthePerfor
;
addList
.
Add
(
imdata
);
addList
.
Add
(
imdata
);
}
}
connection
.
Insert
(
addList
);
db
.
Insertable
(
addList
).
ExecuteCommand
(
);
return
imsheet
.
ID
;
return
imsheet
.
ID
;
}
}
}
/// <summary>
/// <summary>
...
@@ -299,21 +283,27 @@ public int SaveClinicEmployee(PerSheet sheet, per_allot allot, List<per_allot> a
...
@@ -299,21 +283,27 @@ public int SaveClinicEmployee(PerSheet sheet, per_allot allot, List<per_allot> a
/// <returns></returns>
/// <returns></returns>
public
int
SaveLogisticsEmployee
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_allot
>
allotList
)
public
int
SaveLogisticsEmployee
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_allot
>
allotList
)
{
{
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
var
db
=
InfraRepository
.
GetDbclient
(
_options
.
Value
.
PerformanceConnectionString
);
{
var
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
var
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
imsheet
.
ID
=
(
int
)
connection
.
Insert
(
imsheet
);
imsheet
.
ID
=
db
.
Insertable
(
imsheet
).
AS
(
"per_sheet"
).
ExecuteReturnIdentity
(
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataLogisticsEmployee
)
t
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataLogisticsEmployee
)
t
);
//新上传名单中无人员名单,取到最后日期的数据
//新上传名单中无人员名单,取到最后日期的数据
if
(
dataList
==
null
||
dataList
.
Count
()
<=
0
)
if
(!
dataList
.
Any
())
{
var
empList
=
db
.
Ado
.
SqlQuery
<
im_employee_logistics
>(
"select * from im_employee_logistics where AllotID = @allotid"
,
new
{
AllotID
=
allot
.
ID
}).
ToList
();
if
(
empList
.
Any
())
{
{
foreach
(
var
item
in
allotList
?.
OrderByDescending
(
t
=>
t
.
Year
).
ThenByDescending
(
t
=>
t
.
Month
))
dataList
=
_mapper
.
Map
<
List
<
PerDataLogisticsEmployee
>>(
empList
);
}
else
{
{
var
employeeList
=
connection
.
Query
<
im_employee_logistics
>(
"select * from im_employee_logistics where AllotID = @allotid"
,
new
{
AllotID
=
allot
.
ID
}
);
empList
=
db
.
Ado
.
SqlQuery
<
im_employee_logistics
>(
"select * from im_employee_logistics "
).
ToList
(
);
if
(
employeeList
!=
null
&&
employeeList
.
Count
()
>
0
)
foreach
(
var
item
in
allotList
)
{
{
dataList
=
_mapper
.
Map
<
List
<
PerDataLogisticsEmployee
>>(
employeeList
);
var
emp
=
empList
.
Where
(
w
=>
w
.
AllotID
==
item
.
ID
).
ToList
();
if
(!
emp
.
Any
())
continue
;
dataList
=
_mapper
.
Map
<
List
<
PerDataLogisticsEmployee
>>(
emp
);
break
;
break
;
}
}
}
}
...
@@ -327,10 +317,9 @@ public int SaveLogisticsEmployee(PerSheet sheet, per_allot allot, List<per_allot
...
@@ -327,10 +317,9 @@ public int SaveLogisticsEmployee(PerSheet sheet, per_allot allot, List<per_allot
imdata
.
OtherPerfor
=
data
.
OthePerfor
;
imdata
.
OtherPerfor
=
data
.
OthePerfor
;
addList
.
Add
(
imdata
);
addList
.
Add
(
imdata
);
}
}
connection
.
Insert
(
addList
);
db
.
Insertable
(
addList
).
ExecuteCommand
(
);
return
imsheet
.
ID
;
return
imsheet
.
ID
;
}
}
}
/// <summary>
/// <summary>
/// 保存科室绩效基础表
/// 保存科室绩效基础表
...
@@ -340,23 +329,19 @@ public int SaveLogisticsEmployee(PerSheet sheet, per_allot allot, List<per_allot
...
@@ -340,23 +329,19 @@ public int SaveLogisticsEmployee(PerSheet sheet, per_allot allot, List<per_allot
/// <returns></returns>
/// <returns></returns>
public
int
SaveAccountBasic
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_sheet
>
sheets
)
public
int
SaveAccountBasic
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_sheet
>
sheets
)
{
{
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
var
db
=
InfraRepository
.
GetDbclient
(
_options
.
Value
.
PerformanceConnectionString
);
{
//var imsheet = new per_sheet { AllotID =allot.ID, SheetName = sheet.SheetName, Source = 1, SheetType = (int)sheet.SheetType };
//perforPerSheetRepository.Add(imsheet);
List
<
int
>
types
=
new
List
<
int
>
{
(
int
)
SheetType
.
AccountBasicSpecial
,
(
int
)
SheetType
.
AccountBasic
};
List
<
int
>
types
=
new
List
<
int
>
{
(
int
)
SheetType
.
AccountBasicSpecial
,
(
int
)
SheetType
.
AccountBasic
};
var
imsheet
=
sheets
?.
FirstOrDefault
(
w
=>
w
.
AllotID
==
allot
.
ID
&&
w
.
SheetType
.
HasValue
&&
types
.
Contains
(
w
.
SheetType
.
Value
));
var
imsheet
=
sheets
?.
FirstOrDefault
(
w
=>
w
.
AllotID
==
allot
.
ID
&&
w
.
SheetType
.
HasValue
&&
types
.
Contains
(
w
.
SheetType
.
Value
));
if
(
imsheet
!=
null
)
if
(
imsheet
!=
null
)
{
{
imsheet
.
SheetType
=
(
int
)
SheetType
.
AccountBasic
;
imsheet
.
SheetType
=
(
int
)
SheetType
.
AccountBasic
;
connection
.
Updat
e
(
imsheet
);
db
.
Updateabl
e
(
imsheet
);
}
}
else
else
{
{
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
imsheet
.
ID
=
(
int
)
connection
.
Insert
(
imsheet
);
imsheet
.
ID
=
db
.
Insertable
(
imsheet
).
AS
(
"per_sheet"
).
ExecuteReturnIdentity
(
);
}
}
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataAccountBaisc
)
t
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataAccountBaisc
)
t
);
List
<
im_accountbasic
>
addList
=
new
List
<
im_accountbasic
>();
List
<
im_accountbasic
>
addList
=
new
List
<
im_accountbasic
>();
foreach
(
var
data
in
dataList
)
foreach
(
var
data
in
dataList
)
...
@@ -367,10 +352,9 @@ public int SaveAccountBasic(PerSheet sheet, per_allot allot, List<per_sheet> she
...
@@ -367,10 +352,9 @@ public int SaveAccountBasic(PerSheet sheet, per_allot allot, List<per_sheet> she
imdata
.
DoctorExtra
=
data
.
Extra
;
imdata
.
DoctorExtra
=
data
.
Extra
;
addList
.
Add
(
imdata
);
addList
.
Add
(
imdata
);
}
}
connection
.
Insert
(
addList
.
ToArray
()
);
db
.
Insertable
(
addList
).
ExecuteCommand
(
);
return
imsheet
.
ID
;
return
imsheet
.
ID
;
}
}
}
/// <summary>
/// <summary>
/// 保存特殊科室
/// 保存特殊科室
...
@@ -380,10 +364,9 @@ public int SaveAccountBasic(PerSheet sheet, per_allot allot, List<per_sheet> she
...
@@ -380,10 +364,9 @@ public int SaveAccountBasic(PerSheet sheet, per_allot allot, List<per_sheet> she
/// <returns></returns>
/// <returns></returns>
public
int
SaveSpecialUnit
(
PerSheet
sheet
,
per_allot
allot
)
public
int
SaveSpecialUnit
(
PerSheet
sheet
,
per_allot
allot
)
{
{
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
var
db
=
InfraRepository
.
GetDbclient
(
_options
.
Value
.
PerformanceConnectionString
);
{
var
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
var
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
imsheet
.
ID
=
(
int
)
connection
.
Insert
(
imsheet
);
imsheet
.
ID
=
db
.
Insertable
(
imsheet
).
AS
(
"per_sheet"
).
ExecuteReturnIdentity
(
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataSpecialUnit
)
t
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerDataSpecialUnit
)
t
);
List
<
im_specialunit
>
addList
=
new
List
<
im_specialunit
>();
List
<
im_specialunit
>
addList
=
new
List
<
im_specialunit
>();
...
@@ -394,9 +377,9 @@ public int SaveSpecialUnit(PerSheet sheet, per_allot allot)
...
@@ -394,9 +377,9 @@ public int SaveSpecialUnit(PerSheet sheet, per_allot allot)
imdata
.
AllotID
=
allot
.
ID
;
imdata
.
AllotID
=
allot
.
ID
;
addList
.
Add
(
imdata
);
addList
.
Add
(
imdata
);
}
}
connection
.
Insert
(
addList
.
ToArray
()
);
db
.
Insertable
(
addList
).
ExecuteCommand
(
);
return
imsheet
.
ID
;
return
imsheet
.
ID
;
}
}
}
/// <summary>
/// <summary>
...
@@ -407,8 +390,7 @@ public int SaveSpecialUnit(PerSheet sheet, per_allot allot)
...
@@ -407,8 +390,7 @@ public int SaveSpecialUnit(PerSheet sheet, per_allot allot)
/// <returns></returns>
/// <returns></returns>
public
int
SaveCommon
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_sheet
>
sheets
)
public
int
SaveCommon
(
PerSheet
sheet
,
per_allot
allot
,
List
<
per_sheet
>
sheets
)
{
{
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
var
db
=
InfraRepository
.
GetDbclient
(
_options
.
Value
.
PerformanceConnectionString
);
{
per_sheet
imsheet
=
null
;
per_sheet
imsheet
=
null
;
List
<
int
>
types
=
new
List
<
int
>
{
(
int
)
SheetType
.
AccountBasicSpecial
,
(
int
)
SheetType
.
AccountBasic
};
List
<
int
>
types
=
new
List
<
int
>
{
(
int
)
SheetType
.
AccountBasicSpecial
,
(
int
)
SheetType
.
AccountBasic
};
if
(
types
.
Any
(
type
=>
type
==
(
int
)
sheet
.
SheetType
))
if
(
types
.
Any
(
type
=>
type
==
(
int
)
sheet
.
SheetType
))
...
@@ -417,16 +399,15 @@ public int SaveCommon(PerSheet sheet, per_allot allot, List<per_sheet> sheets)
...
@@ -417,16 +399,15 @@ public int SaveCommon(PerSheet sheet, per_allot allot, List<per_sheet> sheets)
if
(
imsheet
!=
null
)
if
(
imsheet
!=
null
)
{
{
imsheet
.
SheetType
=
(
int
)
SheetType
.
AccountBasic
;
imsheet
.
SheetType
=
(
int
)
SheetType
.
AccountBasic
;
connection
.
Updat
e
(
imsheet
);
db
.
Updateabl
e
(
imsheet
);
}
}
}
}
if
(
imsheet
==
null
)
if
(
imsheet
==
null
)
{
{
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
imsheet
=
new
per_sheet
{
AllotID
=
allot
.
ID
,
SheetName
=
sheet
.
SheetName
,
Source
=
1
,
SheetType
=
(
int
)
sheet
.
SheetType
};
imsheet
.
ID
=
(
int
)
connection
.
Insert
(
imsheet
);
imsheet
.
ID
=
db
.
Insertable
(
imsheet
).
AS
(
"per_sheet"
).
ExecuteReturnIdentity
(
);
}
}
List
<
im_data
>
addDataList
=
new
List
<
im_data
>();
List
<
im_data
>
addDataList
=
new
List
<
im_data
>();
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerData
)
t
);
var
dataList
=
sheet
.
PerData
.
Select
(
t
=>
(
PerData
)
t
);
foreach
(
var
data
in
dataList
)
foreach
(
var
data
in
dataList
)
...
@@ -436,29 +417,31 @@ public int SaveCommon(PerSheet sheet, per_allot allot, List<per_sheet> sheets)
...
@@ -436,29 +417,31 @@ public int SaveCommon(PerSheet sheet, per_allot allot, List<per_sheet> sheets)
imdata
.
AllotID
=
allot
.
ID
;
imdata
.
AllotID
=
allot
.
ID
;
addDataList
.
Add
(
imdata
);
addDataList
.
Add
(
imdata
);
}
}
if
(
addDataList
!=
null
&&
addDataList
.
Any
())
if
(
addDataList
.
Any
())
{
{
int
rows
=
500
;
int
batchSize
=
1000
;
// 每批插入1000条记录
for
(
int
i
=
0
;
i
<
Math
.
Ceiling
((
double
)
addDataList
.
Count
/
rows
);
i
++)
int
total
=
addDataList
.
Count
;
for
(
int
i
=
0
;
i
<
total
;
i
+=
batchSize
)
{
{
connection
.
Insert
(
addDataList
.
Skip
(
rows
*
i
).
Take
(
rows
).
ToArray
());
var
batch
=
addDataList
.
Skip
(
i
).
Take
(
batchSize
).
ToList
();
db
.
Insertable
(
batch
).
ExecuteCommand
();
}
}
}
}
return
imsheet
.
ID
;
return
imsheet
.
ID
;
}
}
}
public
void
SaveHeader
(
PerSheet
sheet
,
per_allot
allot
,
int
imsheetid
)
public
void
SaveHeader
(
PerSheet
sheet
,
per_allot
allot
,
int
imsheetid
)
{
{
using
(
IDbConnection
connection
=
new
MySqlConnection
(
_options
.
Value
.
PerformanceConnectionString
))
var
db
=
InfraRepository
.
GetDbclient
(
_options
.
Value
.
PerformanceConnectionString
);
{
List
<
im_header
>
addHeadList
=
new
List
<
im_header
>();
List
<
im_header
>
addHeadList
=
new
List
<
im_header
>();
foreach
(
var
header
in
sheet
.
PerHeader
)
foreach
(
var
header
in
sheet
.
PerHeader
)
{
{
var
imheader
=
_mapper
.
Map
<
im_header
>(
header
);
var
imheader
=
_mapper
.
Map
<
im_header
>(
header
);
imheader
.
SheetID
=
imsheetid
;
imheader
.
SheetID
=
imsheetid
;
imheader
.
AllotID
=
allot
.
ID
;
imheader
.
AllotID
=
allot
.
ID
;
imheader
.
ID
=
(
int
)
connection
.
Insert
(
imheader
);
imheader
.
ID
=
db
.
Insertable
(
imheader
).
AS
(
"im_header"
).
ExecuteReturnIdentity
(
);
if
(
header
.
IsHasChildren
)
if
(
header
.
IsHasChildren
)
{
{
...
@@ -472,10 +455,18 @@ public void SaveHeader(PerSheet sheet, per_allot allot, int imsheetid)
...
@@ -472,10 +455,18 @@ public void SaveHeader(PerSheet sheet, per_allot allot, int imsheetid)
}
}
}
}
}
}
if
(
addHeadList
!=
null
&&
addHeadList
.
Any
())
if
(
addHeadList
.
Any
())
connection
.
Insert
(
addHeadList
);
{
int
batchSize
=
1000
;
// 每批插入1000条记录
int
total
=
addHeadList
.
Count
;
for
(
int
i
=
0
;
i
<
total
;
i
+=
batchSize
)
{
var
batch
=
addHeadList
.
Skip
(
i
).
Take
(
batchSize
).
ToList
();
db
.
Insertable
(
batch
).
ExecuteCommand
();
}
}
}
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment