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
6f7cc4b3
Commit
6f7cc4b3
authored
May 27, 2022
by
1391696987
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下载人员标签
parent
d89b7803
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
117 additions
and
0 deletions
+117
-0
performance/Performance.Api/Controllers/ReportGlobalController.cs
+32
-0
performance/Performance.Api/wwwroot/Performance.Api.xml
+8
-0
performance/Performance.Services/ReportGlobalService.cs
+77
-0
No files found.
performance/Performance.Api/Controllers/ReportGlobalController.cs
View file @
6f7cc4b3
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.StaticFiles
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Services
;
using
Performance.Services.ExtractExcelService
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
...
...
@@ -166,6 +168,36 @@ public ApiResponse GetReportPersonTag(int hospitalId, int allotId)
relust
.
Data
});
}
/// <summary>
/// 下载人员标签配置
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="allotId"></param>
/// <returns></returns>
[
Route
(
"DownloadReportPersonTag"
)]
[
HttpPost
]
public
ActionResult
DownloadReportPersonTag
(
int
hospitalId
,
int
allotId
)
{
var
result
=
reportGlobalService
.
GetReportPersonTag
(
hospitalId
,
allotId
).
Data
;
var
ser
=
JsonHelper
.
Serialize
(
result
);
var
rows
=
JsonHelper
.
Deserialize
<
List
<
Dictionary
<
string
,
object
>>>(
ser
);
var
filepath
=
reportGlobalService
.
ReportPersonTagDownload
(
rows
,
"人员标签"
);
var
memoryStream
=
new
MemoryStream
();
using
(
var
stream
=
new
FileStream
(
filepath
,
FileMode
.
Open
))
{
stream
.
CopyToAsync
(
memoryStream
).
Wait
();
}
memoryStream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
var
provider
=
new
FileExtensionContentTypeProvider
();
FileInfo
fileInfo
=
new
FileInfo
(
filepath
);
var
memi
=
provider
.
Mappings
[
".xlsx"
];
return
File
(
memoryStream
,
memi
,
Path
.
GetFileName
(
fileInfo
.
Name
));
}
/// <summary>
/// 保存科室标签配置
...
...
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
6f7cc4b3
...
...
@@ -2016,6 +2016,14 @@
<param
name=
"allotId"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.ReportGlobalController.DownloadReportPersonTag(System.Int32,System.Int32)"
>
<summary>
下载人员标签配置
</summary>
<param
name=
"hospitalId"
></param>
<param
name=
"allotId"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.ReportGlobalController.SaveReportPersonTag(System.Int32,System.Int32,Performance.DtoModels.SaveCollectData)"
>
<summary>
保存科室标签配置
...
...
performance/Performance.Services/ReportGlobalService.cs
View file @
6f7cc4b3
using
Microsoft.Extensions.Logging
;
using
NPOI.SS.UserModel
;
using
OfficeOpenXml
;
using
OfficeOpenXml.Style
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
...
...
@@ -8,6 +10,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -629,6 +632,80 @@ select new
return
result
;
}
public
string
ReportPersonTagDownload
(
List
<
Dictionary
<
string
,
object
>>
rows
,
string
title
)
{
var
data
=
new
List
<
Dictionary
<
string
,
object
>>();
foreach
(
var
obj
in
rows
)
{
Dictionary
<
string
,
object
>
nobj
=
new
Dictionary
<
string
,
object
>();
foreach
(
var
item
in
obj
)
{
nobj
[
item
.
Key
.
ToLower
()]
=
item
.
Value
;
}
data
.
Add
(
nobj
);
}
var
dpath
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Files"
);
if
(!
Directory
.
Exists
(
dpath
))
Directory
.
CreateDirectory
(
dpath
);
string
filepath
=
Path
.
Combine
(
dpath
,
$"
{
title
}{
DateTime
.
Now
:
yyyy
年
MM
月
dd
日
}
"
);
if
(
File
.
Exists
(
filepath
))
File
.
Delete
(
filepath
);
using
(
FileStream
fs
=
new
FileStream
(
filepath
,
FileMode
.
OpenOrCreate
))
using
(
ExcelPackage
package
=
new
ExcelPackage
(
fs
))
{
var
worksheet
=
package
.
Workbook
.
Worksheets
.
Add
(
title
);
if
(
rows
!=
null
&&
rows
.
Count
()
>
0
)
{
worksheet
.
SetValue
(
1
,
1
,
title
);
var
headList
=
data
.
FirstOrDefault
().
ToList
();
for
(
int
col
=
0
;
col
<
headList
.
Count
;
col
++)
{
worksheet
.
SetValue
(
2
,
col
+
1
,
headList
[
col
].
Key
);
}
for
(
int
col
=
0
;
col
<
headList
.
Count
;
col
++)
{
for
(
int
row
=
0
;
row
<
data
.
Count
();
row
++)
{
var
temp
=
data
.
ElementAt
(
row
);
var
value
=
temp
[
headList
[
col
].
Key
]
!=
null
?
temp
[
headList
[
col
].
Key
].
ToString
()
:
temp
[
headList
[
col
].
Key
];
worksheet
.
Cells
[
row
+
3
,
col
+
1
].
Value
=
value
;
}
}
#
region
样式设置
for
(
int
row
=
worksheet
.
Dimension
.
Start
.
Row
;
row
<=
worksheet
.
Dimension
.
End
.
Row
;
row
++)
{
worksheet
.
Row
(
row
).
Height
=
20
;
for
(
int
col
=
worksheet
.
Dimension
.
Start
.
Column
;
col
<=
worksheet
.
Dimension
.
End
.
Column
;
col
++)
{
worksheet
.
Cells
[
row
,
col
].
Style
.
Border
.
BorderAround
(
ExcelBorderStyle
.
Thin
);
worksheet
.
Cells
[
row
,
col
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
row
,
col
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
}
}
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Merge
=
true
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
Font
.
Size
=
16
;
worksheet
.
Cells
[
2
,
1
,
2
,
headList
.
Count
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
Row
(
1
).
Height
=
24
;
worksheet
.
View
.
FreezePanes
(
3
,
1
);
worksheet
.
Cells
.
AutoFitColumns
();
for
(
int
col
=
worksheet
.
Dimension
.
Start
.
Column
;
col
<=
worksheet
.
Dimension
.
End
.
Column
;
col
++)
{
worksheet
.
Column
(
col
).
Width
=
worksheet
.
Column
(
col
).
Width
>
20
?
20
:
worksheet
.
Column
(
col
).
Width
;
}
#
endregion
}
package
.
Save
();
}
return
filepath
;
}
public
ApiResponse
SaveReportPersonTag
(
int
hospitalId
,
int
allotId
,
int
userId
,
SaveCollectData
request
)
{
var
hos
=
_hospitalRepository
.
GetEntity
(
t
=>
t
.
ID
==
hospitalId
);
...
...
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