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
014152f8
Commit
014152f8
authored
Jun 04, 2019
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
aba86203
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
65 additions
and
17 deletions
+65
-17
performance/Performance.Api/Controllers/AgainAllotController.cs
+4
-4
performance/Performance.Api/Controllers/AllotController.cs
+1
-1
performance/Performance.Api/Controllers/TemplateController.cs
+10
-3
performance/Performance.Api/Filters/ActionsFilter.cs
+1
-0
performance/Performance.Api/Startup.cs
+0
-1
performance/Performance.Api/appsettings.Development.json
+3
-1
performance/Performance.Api/appsettings.json
+3
-1
performance/Performance.DtoModels/AppSettings/Application.cs
+8
-0
performance/Performance.EntityModels/Entity/sys_extract.cs
+1
-1
performance/Performance.Infrastructure/Helper/LogHelper.cs
+1
-1
performance/Performance.Services/AllotService.cs
+11
-1
performance/Performance.Services/ExtractService.cs
+22
-3
No files found.
performance/Performance.Api/Controllers/AgainAllotController.cs
View file @
014152f8
...
@@ -32,13 +32,13 @@ public class AgainAllotController : Controller
...
@@ -32,13 +32,13 @@ public class AgainAllotController : Controller
private
ComputeService
computeService
;
private
ComputeService
computeService
;
private
ClaimService
claimService
;
private
ClaimService
claimService
;
private
AllotService
allotService
;
private
AllotService
allotService
;
private
IHostingEnvironment
e
vn
;
private
IHostingEnvironment
e
nv
;
private
ConfigService
configService
;
private
ConfigService
configService
;
private
Application
application
;
private
Application
application
;
public
AgainAllotController
(
AgainAllotService
againAllotService
,
public
AgainAllotController
(
AgainAllotService
againAllotService
,
ClaimService
claimService
,
ClaimService
claimService
,
AllotService
allotService
,
AllotService
allotService
,
IHostingEnvironment
e
vn
,
IHostingEnvironment
e
nv
,
ConfigService
configService
,
ConfigService
configService
,
ComputeService
computeService
,
ComputeService
computeService
,
IOptions
<
Application
>
options
)
IOptions
<
Application
>
options
)
...
@@ -46,7 +46,7 @@ public class AgainAllotController : Controller
...
@@ -46,7 +46,7 @@ public class AgainAllotController : Controller
this
.
againAllotService
=
againAllotService
;
this
.
againAllotService
=
againAllotService
;
this
.
claimService
=
claimService
;
this
.
claimService
=
claimService
;
this
.
allotService
=
allotService
;
this
.
allotService
=
allotService
;
this
.
e
vn
=
evn
;
this
.
e
nv
=
env
;
this
.
configService
=
configService
;
this
.
configService
=
configService
;
this
.
computeService
=
computeService
;
this
.
computeService
=
computeService
;
this
.
application
=
options
.
Value
;
this
.
application
=
options
.
Value
;
...
@@ -91,7 +91,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
...
@@ -91,7 +91,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
dpath
=
Path
.
Combine
(
e
vn
.
ContentRootPath
,
"Files"
,
$"
{
allot
.
HospitalId
}
"
,
$"
{
allot
.
Year
}{
allot
.
Month
.
ToString
().
PadLeft
(
2
,
'0'
)}
"
);
var
dpath
=
Path
.
Combine
(
e
nv
.
ContentRootPath
.
Substring
(
0
,
env
.
ContentRootPath
.
LastIndexOf
(
"\\"
))
,
"Files"
,
$"
{
allot
.
HospitalId
}
"
,
$"
{
allot
.
Year
}{
allot
.
Month
.
ToString
().
PadLeft
(
2
,
'0'
)}
"
);
FileHelper
.
CreateDirectory
(
dpath
);
FileHelper
.
CreateDirectory
(
dpath
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
...
...
performance/Performance.Api/Controllers/AllotController.cs
View file @
014152f8
...
@@ -120,7 +120,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
...
@@ -120,7 +120,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
dpath
=
Path
.
Combine
(
_evn
.
ContentRootPath
,
"Files"
,
$"
{
allot
.
HospitalId
}
"
,
$"
{
allot
.
Year
}{
allot
.
Month
.
ToString
().
PadLeft
(
2
,
'0'
)}
"
);
var
dpath
=
Path
.
Combine
(
_evn
.
ContentRootPath
.
Substring
(
0
,
_evn
.
ContentRootPath
.
LastIndexOf
(
"\\"
))
,
"Files"
,
$"
{
allot
.
HospitalId
}
"
,
$"
{
allot
.
Year
}{
allot
.
Month
.
ToString
().
PadLeft
(
2
,
'0'
)}
"
);
FileHelper
.
CreateDirectory
(
dpath
);
FileHelper
.
CreateDirectory
(
dpath
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
...
...
performance/Performance.Api/Controllers/TemplateController.cs
View file @
014152f8
...
@@ -69,7 +69,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
...
@@ -69,7 +69,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
dpath
=
Path
.
Combine
(
evn
.
ContentRootPath
,
"Files"
,
$"
{
hospitalid
}
"
,
"first"
);
var
dpath
=
Path
.
Combine
(
evn
.
ContentRootPath
.
Substring
(
0
,
evn
.
ContentRootPath
.
LastIndexOf
(
"\\"
))
,
"Files"
,
$"
{
hospitalid
}
"
,
"first"
);
FileHelper
.
CreateDirectory
(
dpath
);
FileHelper
.
CreateDirectory
(
dpath
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
...
@@ -133,11 +133,17 @@ public IActionResult DownFile([FromQuery]AllotRequest request)
...
@@ -133,11 +133,17 @@ public IActionResult DownFile([FromQuery]AllotRequest request)
{
{
return
new
ObjectResult
(
new
ApiResponse
(
ResponseType
.
Fail
,
"文件不存在"
));
return
new
ObjectResult
(
new
ApiResponse
(
ResponseType
.
Fail
,
"文件不存在"
));
}
}
var
stream
=
new
FileStream
(
allot
.
ExtractPath
,
FileMode
.
Open
);
var
memoryStream
=
new
MemoryStream
();
using
(
var
stream
=
new
FileStream
(
allot
.
ExtractPath
,
FileMode
.
Open
))
{
stream
.
CopyToAsync
(
memoryStream
).
Wait
();
}
memoryStream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
string
fileExt
=
Path
.
GetExtension
(
allot
.
ExtractPath
);
string
fileExt
=
Path
.
GetExtension
(
allot
.
ExtractPath
);
var
provider
=
new
FileExtensionContentTypeProvider
();
var
provider
=
new
FileExtensionContentTypeProvider
();
var
memi
=
provider
.
Mappings
[
fileExt
];
var
memi
=
provider
.
Mappings
[
fileExt
];
return
File
(
s
tream
,
memi
,
Path
.
GetFileName
(
allot
.
ExtractPath
));
return
File
(
memoryS
tream
,
memi
,
Path
.
GetFileName
(
allot
.
ExtractPath
));
}
}
}
}
}
}
\ No newline at end of file
performance/Performance.Api/Filters/ActionsFilter.cs
View file @
014152f8
...
@@ -85,6 +85,7 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
...
@@ -85,6 +85,7 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
if
(
executedContext
.
Result
is
ObjectResult
)
if
(
executedContext
.
Result
is
ObjectResult
)
{
{
LogHelper
.
Information
(
JsonHelper
.
Serialize
(
executedContext
.
Result
),
"响应结果"
);
var
objectResult
=
(
ObjectResult
)
executedContext
.
Result
;
var
objectResult
=
(
ObjectResult
)
executedContext
.
Result
;
var
jsonData
=
JsonHelper
.
Serialize
(
objectResult
.
Value
);
var
jsonData
=
JsonHelper
.
Serialize
(
objectResult
.
Value
);
_logger
.
LogInformation
(
$"响应结果:
{
jsonData
}
"
);
_logger
.
LogInformation
(
$"响应结果:
{
jsonData
}
"
);
...
...
performance/Performance.Api/Startup.cs
View file @
014152f8
...
@@ -187,7 +187,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
...
@@ -187,7 +187,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
app
.
UseHangfireDashboard
(
"/hangfire"
,
new
DashboardOptions
{
Authorization
=
new
[]
{
new
HangfireAuthorizationFilter
()
}
});
app
.
UseHangfireDashboard
(
"/hangfire"
,
new
DashboardOptions
{
Authorization
=
new
[]
{
new
HangfireAuthorizationFilter
()
}
});
#
endregion
#
endregion
loggerFactory
.
CreateLogger
<
Startup
>().
LogDebug
(
env
.
EnvironmentName
);
loggerFactory
.
CreateLogger
<
Startup
>().
LogDebug
(
env
.
EnvironmentName
);
app
.
UseMvc
();
app
.
UseMvc
();
}
}
...
...
performance/Performance.Api/appsettings.Development.json
View file @
014152f8
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
//护士长二次绩效管理员
//护士长二次绩效管理员
"NurseRole"
:
"3"
,
"NurseRole"
:
"3"
,
//科主任二次绩效管理员
//科主任二次绩效管理员
"DirectorRole"
:
"4"
"DirectorRole"
:
"4"
,
"AbsolutePath"
:
"E:
\\
wwwroot
\\
testjx.suvalue.com"
,
"HttpPath"
:
"http://testjx.suvalue.com:81"
}
}
}
}
performance/Performance.Api/appsettings.json
View file @
014152f8
...
@@ -34,6 +34,8 @@
...
@@ -34,6 +34,8 @@
//科主任二次绩效管理员
//科主任二次绩效管理员
"DirectorRole"
:
"4"
,
"DirectorRole"
:
"4"
,
//邮件指定接收人
//邮件指定接收人
"Receiver"
:
[
"chengxiang.li@suvalue.com"
,
"486035085@qq.com"
]
"Receiver"
:
[
"chengxiang.li@suvalue.com"
,
"486035085@qq.com"
],
"AbsolutePath"
:
"E:
\\
wwwroot
\\
testjx.suvalue.com"
,
"HttpPath"
:
"http://testjx.suvalue.com:81"
}
}
}
}
performance/Performance.DtoModels/AppSettings/Application.cs
View file @
014152f8
...
@@ -30,5 +30,13 @@ public class Application
...
@@ -30,5 +30,13 @@ public class Application
/// 邮件指定接收人
/// 邮件指定接收人
/// </summary>
/// </summary>
public
string
[]
Receiver
{
get
;
set
;
}
public
string
[]
Receiver
{
get
;
set
;
}
/// <summary>
/// 绝对路径
/// </summary>
public
string
AbsolutePath
{
get
;
set
;
}
/// <summary>
/// 相对
/// </summary>
public
string
HttpPath
{
get
;
set
;
}
}
}
}
}
performance/Performance.EntityModels/Entity/sys_extract.cs
View file @
014152f8
...
@@ -39,6 +39,6 @@ public class sys_extract
...
@@ -39,6 +39,6 @@ public class sys_extract
/// <summary>
/// <summary>
/// 是否可用 1 可用 2 不可用
/// 是否可用 1 可用 2 不可用
/// </summary>
/// </summary>
public
string
IsEnable
{
get
;
set
;
}
public
Nullable
<
int
>
IsEnable
{
get
;
set
;
}
}
}
}
}
performance/Performance.Infrastructure/Helper/LogHelper.cs
View file @
014152f8
...
@@ -65,7 +65,7 @@ private static void WriteLog(string message, string[] tag, LogLevel logLevel)
...
@@ -65,7 +65,7 @@ private static void WriteLog(string message, string[] tag, LogLevel logLevel)
{
{
try
try
{
{
if
(
_contextAccessor
.
HttpContext
==
null
)
if
(
_contextAccessor
.
HttpContext
==
null
||
string
.
IsNullOrEmpty
(
_contextAccessor
.
HttpContext
.
TraceIdentifier
)
)
{
{
if
(
string
.
IsNullOrEmpty
(
_asyncLocal
.
Value
))
if
(
string
.
IsNullOrEmpty
(
_asyncLocal
.
Value
))
lock
(
_lockObject
)
lock
(
_lockObject
)
...
...
performance/Performance.Services/AllotService.cs
View file @
014152f8
using
AutoMapper
;
using
AutoMapper
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
Performance.DtoModels
;
using
Performance.DtoModels
;
using
Performance.DtoModels.AppSettings
;
using
Performance.EntityModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Infrastructure
;
using
Performance.Repository
;
using
Performance.Repository
;
...
@@ -28,6 +30,7 @@ public class AllotService : IAutoInjection
...
@@ -28,6 +30,7 @@ public class AllotService : IAutoInjection
private
ILogger
<
AllotService
>
_logger
;
private
ILogger
<
AllotService
>
_logger
;
private
PerforPerallotRepository
_allotRepository
;
private
PerforPerallotRepository
_allotRepository
;
private
IEmailService
emailService
;
private
IEmailService
emailService
;
private
readonly
IOptions
<
Application
>
options
;
private
PerforPeragainallotRepository
_againallotRepository
;
private
PerforPeragainallotRepository
_againallotRepository
;
private
PerforLogcheckRepository
perforLogcheckRepository
;
private
PerforLogcheckRepository
perforLogcheckRepository
;
private
readonly
PerforHospitalRepository
perforHospitalRepository
;
private
readonly
PerforHospitalRepository
perforHospitalRepository
;
...
@@ -42,6 +45,7 @@ public class AllotService : IAutoInjection
...
@@ -42,6 +45,7 @@ public class AllotService : IAutoInjection
PerforLogdbugRepository
logdbug
,
PerforLogdbugRepository
logdbug
,
IHostingEnvironment
evn
,
ILogger
<
AllotService
>
logger
,
IHostingEnvironment
evn
,
ILogger
<
AllotService
>
logger
,
IEmailService
emailService
,
IEmailService
emailService
,
IOptions
<
Application
>
options
,
PerforPeragainallotRepository
againallotRepository
,
PerforPeragainallotRepository
againallotRepository
,
PerforLogcheckRepository
perforLogcheckRepository
,
PerforLogcheckRepository
perforLogcheckRepository
,
PerforHospitalRepository
perforHospitalRepository
)
PerforHospitalRepository
perforHospitalRepository
)
...
@@ -56,6 +60,7 @@ public class AllotService : IAutoInjection
...
@@ -56,6 +60,7 @@ public class AllotService : IAutoInjection
this
.
processComputService
=
processComputService
;
this
.
processComputService
=
processComputService
;
this
.
resultComputeService
=
resultComputeService
;
this
.
resultComputeService
=
resultComputeService
;
this
.
emailService
=
emailService
;
this
.
emailService
=
emailService
;
this
.
options
=
options
;
this
.
configService
=
configService
;
this
.
configService
=
configService
;
this
.
logdbug
=
logdbug
;
this
.
logdbug
=
logdbug
;
this
.
perforLogcheckRepository
=
perforLogcheckRepository
;
this
.
perforLogcheckRepository
=
perforLogcheckRepository
;
...
@@ -75,7 +80,12 @@ public List<AllotResponse> GetAllotList(int? hospitalId)
...
@@ -75,7 +80,12 @@ public List<AllotResponse> GetAllotList(int? hospitalId)
var
allotList
=
_allotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
allotList
=
_allotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
allotList
=
allotList
==
null
?
allotList
:
allotList
.
OrderByDescending
(
t
=>
t
.
ID
).
ToList
();
allotList
=
allotList
==
null
?
allotList
:
allotList
.
OrderByDescending
(
t
=>
t
.
ID
).
ToList
();
var
reuslt
=
Mapper
.
Map
<
List
<
AllotResponse
>>(
allotList
);
var
reuslt
=
Mapper
.
Map
<
List
<
AllotResponse
>>(
allotList
);
reuslt
.
ForEach
(
t
=>
t
.
IsDown
=
!
string
.
IsNullOrEmpty
(
t
.
ExtractPath
));
reuslt
.
ForEach
(
t
=>
{
t
.
IsDown
=
!
string
.
IsNullOrEmpty
(
t
.
ExtractPath
);
if
(!
string
.
IsNullOrEmpty
(
t
.
ExtractPath
))
t
.
ExtractPath
=
t
.
ExtractPath
.
Replace
(
options
.
Value
.
AbsolutePath
,
options
.
Value
.
HttpPath
).
Replace
(
"\\"
,
"/"
);
});
return
reuslt
;
return
reuslt
;
}
}
...
...
performance/Performance.Services/ExtractService.cs
View file @
014152f8
...
@@ -66,6 +66,7 @@ public class ExtractService : IAutoInjection
...
@@ -66,6 +66,7 @@ public class ExtractService : IAutoInjection
public
void
ExtractData
(
int
allotId
,
string
mail
,
sys_hospital
hospital
)
public
void
ExtractData
(
int
allotId
,
string
mail
,
sys_hospital
hospital
)
{
{
LogHelper
.
Information
(
$"开始执行绩效数据提取任务
{
new
{
allotId
,
mail
,
hospital
}}
"
,
"提取绩效数据"
);
List
<
PerSheet
>
sheetList
=
new
List
<
PerSheet
>();
List
<
PerSheet
>
sheetList
=
new
List
<
PerSheet
>();
try
try
...
@@ -92,6 +93,7 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
...
@@ -92,6 +93,7 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
//判断是否是首次
//判断是否是首次
if
((
allotList
==
null
||
!
allotList
.
Any
(
t
=>
t
.
States
>
0
))
&&
(
firstList
!=
null
||
!
firstList
.
Any
()))
if
((
allotList
==
null
||
!
allotList
.
Any
(
t
=>
t
.
States
>
0
))
&&
(
firstList
!=
null
||
!
firstList
.
Any
()))
{
{
LogHelper
.
Information
(
$"当前绩效为首次提取,从EXCEL中获取信息"
,
"提取绩效数据"
);
var
first
=
firstList
.
OrderByDescending
(
t
=>
t
.
CreateDate
).
FirstOrDefault
();
var
first
=
firstList
.
OrderByDescending
(
t
=>
t
.
CreateDate
).
FirstOrDefault
();
//首次 从excel中获取人员信息,SHEET页信息,列头信息
//首次 从excel中获取人员信息,SHEET页信息,列头信息
sheetList
=
GetFileData
(
first
.
Path
);
sheetList
=
GetFileData
(
first
.
Path
);
...
@@ -99,6 +101,7 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
...
@@ -99,6 +101,7 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
}
}
else
else
{
{
LogHelper
.
Information
(
$"当前绩效为非首次提取,从数据库中获取信息"
,
"提取绩效数据"
);
//非首次 从数据库中获取人员信息,SHEET页信息,列头信息
//非首次 从数据库中获取人员信息,SHEET页信息,列头信息
allotList
=
allotList
.
Where
(
t
=>
t
.
Path
!=
null
&&
t
.
Path
!=
""
).
ToList
();
allotList
=
allotList
.
Where
(
t
=>
t
.
Path
!=
null
&&
t
.
Path
!=
""
).
ToList
();
if
(
allotList
!=
null
&&
allotList
.
Count
>
0
)
if
(
allotList
!=
null
&&
allotList
.
Count
>
0
)
...
@@ -113,12 +116,14 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
...
@@ -113,12 +116,14 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
throw
new
PerformanceException
(
$"历史绩效未上传文件"
);
throw
new
PerformanceException
(
$"历史绩效未上传文件"
);
}
}
}
}
var
dpath
=
Path
.
Combine
(
environment
.
ContentRootPath
,
"Files"
,
$"
{
hospital
.
ID
}
"
,
"autoextract"
);
LogHelper
.
Information
(
$"基础数据提取完成,"
,
"提取绩效数据"
);
var
dpath
=
Path
.
Combine
(
environment
.
ContentRootPath
.
Substring
(
0
,
environment
.
ContentRootPath
.
LastIndexOf
(
"\\"
)),
"Files"
,
$"
{
hospital
.
ID
}
"
,
"autoextract"
);
FileHelper
.
CreateDirectory
(
dpath
);
FileHelper
.
CreateDirectory
(
dpath
);
string
path
=
Path
.
Combine
(
dpath
,
$"绩效数据
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}
.xlsx"
);
string
path
=
Path
.
Combine
(
dpath
,
$"绩效数据
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}
.xlsx"
);
//根据SHEET页信息,列头信息,创建EXCEL文件
//根据SHEET页信息,列头信息,创建EXCEL文件
if
(
WriteExcel
(
path
,
originalPath
,
sheetList
,
hospitalConfig
,
hospital
.
ID
,
out
string
filepath
))
if
(
WriteExcel
(
path
,
originalPath
,
sheetList
,
hospitalConfig
,
hospital
.
ID
,
out
string
filepath
))
{
{
LogHelper
.
Information
(
$"基础数据提取完成,文件保存成功
{
filepath
}
"
,
"提取绩效数据"
);
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
var
allot
=
perforPerallotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
allot
.
ExtractPath
=
filepath
;
allot
.
ExtractPath
=
filepath
;
if
(!
string
.
IsNullOrEmpty
(
filepath
))
if
(!
string
.
IsNullOrEmpty
(
filepath
))
...
@@ -174,16 +179,18 @@ private void SendEmail(string mail, string path, string subject, string body)
...
@@ -174,16 +179,18 @@ private void SendEmail(string mail, string path, string subject, string body)
/// <param name="hospitalId"></param>
/// <param name="hospitalId"></param>
private
bool
WriteExcel
(
string
newpath
,
string
originalPath
,
List
<
PerSheet
>
sheetList
,
sys_hospitalconfig
hospitalConfig
,
int
hospitalId
,
out
string
filepath
)
private
bool
WriteExcel
(
string
newpath
,
string
originalPath
,
List
<
PerSheet
>
sheetList
,
sys_hospitalconfig
hospitalConfig
,
int
hospitalId
,
out
string
filepath
)
{
{
LogHelper
.
Information
(
$"开始向EXCEL中写入数据,"
,
"提取绩效数据"
);
if
(
string
.
IsNullOrEmpty
(
originalPath
))
if
(
string
.
IsNullOrEmpty
(
originalPath
))
{
{
LogHelper
.
Error
(
$"
{
originalPath
}
文件路径无效"
,
"提取绩效数据"
);
LogHelper
.
Error
(
$"
{
originalPath
}
文件路径无效"
,
"提取绩效数据"
);
throw
new
PerformanceException
(
$"
{
originalPath
}
文件路径无效"
);
throw
new
PerformanceException
(
$"
{
originalPath
}
文件路径无效"
);
}
}
var
scriptList
=
perforExtractRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
var
scriptList
=
perforExtractRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
t
.
IsEnable
==
1
);
//根据SHEET页信息,列头信息,创建EXCEL文件
//根据SHEET页信息,列头信息,创建EXCEL文件
IWorkbook
workbook
=
null
;
IWorkbook
workbook
=
null
;
FileStream
file
=
null
;
try
try
{
{
workbook
=
new
XSSFWorkbook
(
originalPath
);
workbook
=
new
XSSFWorkbook
(
originalPath
);
...
@@ -193,6 +200,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
...
@@ -193,6 +200,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
if
(
importSheet
==
null
)
continue
;
if
(
importSheet
==
null
)
continue
;
if
(
sheet
.
PerHeader
==
null
)
continue
;
if
(
sheet
.
PerHeader
==
null
)
continue
;
LogHelper
.
Information
(
$"列头信息写入,"
,
"提取绩效数据"
);
var
maxHeaderRowNumber
=
sheet
.
PerHeader
.
Max
(
t
=>
t
.
PointRow
);
var
maxHeaderRowNumber
=
sheet
.
PerHeader
.
Max
(
t
=>
t
.
PointRow
);
sheet
.
PerHeader
?.
ForEach
(
t
=>
sheet
.
PerHeader
?.
ForEach
(
t
=>
{
{
...
@@ -215,6 +223,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
...
@@ -215,6 +223,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
//填充人员信息
//填充人员信息
if
(
SheetType
.
Employee
==
sheet
.
SheetType
&&
sheet
.
PerData
!=
null
&&
sheet
.
PerData
.
Any
())
if
(
SheetType
.
Employee
==
sheet
.
SheetType
&&
sheet
.
PerData
!=
null
&&
sheet
.
PerData
.
Any
())
{
{
LogHelper
.
Information
(
$"填充人员信息,"
,
"提取绩效数据"
);
var
dataList
=
sheet
.
PerData
.
ConvertAll
(
new
Converter
<
IPerData
,
PerDataEmployee
>(
t
=>
(
PerDataEmployee
)
t
));
var
dataList
=
sheet
.
PerData
.
ConvertAll
(
new
Converter
<
IPerData
,
PerDataEmployee
>(
t
=>
(
PerDataEmployee
)
t
));
for
(
int
i
=
0
;
i
<
dataList
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
dataList
.
Count
;
i
++)
{
{
...
@@ -251,9 +260,11 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
...
@@ -251,9 +260,11 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
//SHEET页在SQL提取中出现时,执行SQL脚本获得结果向EXCEL中填充
//SHEET页在SQL提取中出现时,执行SQL脚本获得结果向EXCEL中填充
else
if
(
scriptList
.
Any
(
t
=>
sheet
.
SheetName
.
Contains
(
t
.
SheetName
)))
else
if
(
scriptList
.
Any
(
t
=>
sheet
.
SheetName
.
Contains
(
t
.
SheetName
)))
{
{
LogHelper
.
Information
(
$"执行SQL脚本获取数据,"
,
"提取绩效数据"
);
var
script
=
scriptList
.
First
(
t
=>
sheet
.
SheetName
.
Contains
(
t
.
SheetName
));
var
script
=
scriptList
.
First
(
t
=>
sheet
.
SheetName
.
Contains
(
t
.
SheetName
));
if
(!
string
.
IsNullOrEmpty
(
script
.
ExecuteScript
))
if
(!
string
.
IsNullOrEmpty
(
script
.
ExecuteScript
))
{
{
LogHelper
.
Information
(
$"SQL脚本
{
script
.
ExecuteScript
}
,"
,
"提取绩效数据"
);
var
children
=
new
List
<
PerHeader
>();
var
children
=
new
List
<
PerHeader
>();
foreach
(
var
item
in
sheet
.
PerHeader
?.
Select
(
t
=>
t
.
Children
))
foreach
(
var
item
in
sheet
.
PerHeader
?.
Select
(
t
=>
t
.
Children
))
{
{
...
@@ -263,6 +274,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
...
@@ -263,6 +274,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
var
connection
=
ConnectionBuilder
.
Create
(
DatabaseType
.
SqlServer
,
hospitalConfig
.
DbSource
,
hospitalConfig
.
DbName
,
hospitalConfig
.
DbUser
,
hospitalConfig
.
DbPassword
);
var
connection
=
ConnectionBuilder
.
Create
(
DatabaseType
.
SqlServer
,
hospitalConfig
.
DbSource
,
hospitalConfig
.
DbName
,
hospitalConfig
.
DbUser
,
hospitalConfig
.
DbPassword
);
var
dataList
=
perforExtractRepository
.
ExecuteScript
(
connection
,
script
.
ExecuteScript
,
null
);
var
dataList
=
perforExtractRepository
.
ExecuteScript
(
connection
,
script
.
ExecuteScript
,
null
);
LogHelper
.
Information
(
$"写入SQL脚本执行结果"
,
"提取绩效数据"
);
//创建数据行
//创建数据行
foreach
(
var
pointRow
in
dataList
.
Select
(
t
=>
t
.
RowNumber
).
Distinct
().
OrderBy
(
t
=>
t
))
foreach
(
var
pointRow
in
dataList
.
Select
(
t
=>
t
.
RowNumber
).
Distinct
().
OrderBy
(
t
=>
t
))
{
{
...
@@ -281,18 +293,24 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
...
@@ -281,18 +293,24 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
}
}
}
}
}
}
using
(
FileStream
file
=
new
FileStream
(
newpath
,
FileMode
.
Create
))
LogHelper
.
Information
(
$"数据写入完成,开始保存文件
{
newpath
}
"
,
"提取绩效数据"
);
file
=
new
FileStream
(
newpath
,
FileMode
.
Create
);
workbook
.
Write
(
file
);
workbook
.
Write
(
file
);
filepath
=
newpath
;
filepath
=
newpath
;
return
true
;
return
true
;
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogHelper
.
Error
(
$"数据写入出现异常
{
ex
.
ToString
()}
"
,
"提取绩效数据"
,
"异常"
);
throw
ex
;
throw
ex
;
}
}
finally
finally
{
{
workbook
.
Close
();
workbook
.
Close
();
file
.
Close
();
file
.
Dispose
();
GC
.
Collect
();
}
}
}
}
...
@@ -393,6 +411,7 @@ private List<PerSheet> GetFileData(string path)
...
@@ -393,6 +411,7 @@ private List<PerSheet> GetFileData(string path)
{
{
workbook
.
Close
();
workbook
.
Close
();
fs
.
Close
();
fs
.
Close
();
fs
.
Dispose
();
}
}
return
sheetList
;
return
sheetList
;
...
...
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