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
1806cc52
Commit
1806cc52
authored
Jul 05, 2022
by
纪旭 韦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
预留金额下载,添加绩效报错提示修复
parent
120066ee
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
188 additions
and
2 deletions
+188
-2
performance/Performance.Api/Controllers/AllotController.cs
+65
-1
performance/Performance.Api/wwwroot/Performance.Api.xml
+7
-0
performance/Performance.Services/AllotService.cs
+116
-0
performance/Performance.Services/DownloadService.cs
+0
-1
No files found.
performance/Performance.Api/Controllers/AllotController.cs
View file @
1806cc52
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
Newtonsoft.Json
;
using
Performance.DtoModels
;
using
Performance.DtoModels
;
using
Performance.EntityModels.Entity
;
using
Performance.EntityModels.Entity
;
using
Performance.Infrastructure
;
using
Performance.Infrastructure
;
...
@@ -534,6 +535,69 @@ public ApiResponse Reserved([FromBody] ReservedRequest request)
...
@@ -534,6 +535,69 @@ public ApiResponse Reserved([FromBody] ReservedRequest request)
}
}
/// <summary>
/// <summary>
/// 预留金额下载
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
Route
(
"reservedDownload"
)]
[
HttpPost
]
public
IActionResult
ReservedDownload
([
FromBody
]
ReservedRequest
request
)
{
try
{
List
<
ExcelDownloadHeads
>
excelDownloadHeads
=
new
List
<
ExcelDownloadHeads
>
{
new
ExcelDownloadHeads
(){
Alias
=
"年份"
,
Name
=
nameof
(
EmployeeReservedDto
.
Year
)
},
new
ExcelDownloadHeads
(){
Alias
=
"来源"
,
Name
=
nameof
(
EmployeeReservedDto
.
Source
)
},
new
ExcelDownloadHeads
(){
Alias
=
"核算单元组别"
,
Name
=
nameof
(
EmployeeReservedDto
.
UnitType
)
},
new
ExcelDownloadHeads
(){
Alias
=
"核算单元"
,
Name
=
nameof
(
EmployeeReservedDto
.
AccountingUnit
)
},
new
ExcelDownloadHeads
(){
Alias
=
"人员姓名"
,
Name
=
nameof
(
EmployeeReservedDto
.
EmployeeName
)
},
new
ExcelDownloadHeads
(){
Alias
=
"人员工号"
,
Name
=
nameof
(
EmployeeReservedDto
.
JobNumber
)
},
new
ExcelDownloadHeads
(){
Alias
=
"预留金额总计"
,
Name
=
nameof
(
EmployeeReservedDto
.
TotalReseFee
)
},
new
ExcelDownloadHeads
(){
Alias
=
"实发金额总计"
,
Name
=
nameof
(
EmployeeReservedDto
.
TotalGiveFee
)
},
};
var
userid
=
_claim
.
GetUserId
();
var
result
=
_allotService
.
GetReserved
(
request
,
userid
);
var
ser
=
JsonConvert
.
SerializeObject
(
result
);
var
rows
=
JsonConvert
.
DeserializeObject
<
List
<
Dictionary
<
string
,
object
>>>(
ser
);
string
name
;
string
[]
ignoreColumns
;
if
(
request
.
Source
==
1
)
{
name
=
"预留金额(按人员字典)"
;
ignoreColumns
=
new
string
[]
{
"hospitalid"
,
"source"
,
"newunittype"
,
"newaccountingunit"
};
}
else
{
name
=
"预留金额(按发放科室)"
;
ignoreColumns
=
new
string
[]{
"hospitalid"
,
"newunittype"
,
"newaccountingunit"
};
}
var
filepath
=
_allotService
.
ExcelDownload
(
rows
,
name
,
excelDownloadHeads
,
ignoreColumns
);
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
));
}
catch
(
Exception
ex
)
{
_logger
.
LogError
(
new
EventId
(
10000
),
ex
,
"下载异常"
);
throw
;
}
}
/// <summary>
/// 下载当前测算表
/// 下载当前测算表
/// </summary>
/// </summary>
/// <param name="allotid"></param>
/// <param name="allotid"></param>
...
@@ -610,7 +674,7 @@ private void LogAllotAction(int allotId, string path, string actionName)
...
@@ -610,7 +674,7 @@ private void LogAllotAction(int allotId, string path, string actionName)
AllotId
=
allotId
,
AllotId
=
allotId
,
CreateDate
=
DateTime
.
Now
,
CreateDate
=
DateTime
.
Now
,
CreateUser
=
_claim
.
GetUserId
(),
CreateUser
=
_claim
.
GetUserId
(),
FilePath
=
path
,
FilePath
=
path
??
""
,
ActionName
=
actionName
ActionName
=
actionName
};
};
...
...
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
1806cc52
...
@@ -254,6 +254,13 @@
...
@@ -254,6 +254,13 @@
<param
name=
"request"
></param>
<param
name=
"request"
></param>
<returns></returns>
<returns></returns>
</member>
</member>
<member
name=
"M:Performance.Api.Controllers.AllotController.ReservedDownload(Performance.DtoModels.ReservedRequest)"
>
<summary>
预留金额下载
</summary>
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.AllotController.DownloadCurrentCalculationTable(System.Int32)"
>
<member
name=
"M:Performance.Api.Controllers.AllotController.DownloadCurrentCalculationTable(System.Int32)"
>
<summary>
<summary>
下载当前测算表
下载当前测算表
...
...
performance/Performance.Services/AllotService.cs
View file @
1806cc52
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
Microsoft.Extensions.Options
;
using
Newtonsoft.Json
;
using
OfficeOpenXml
;
using
OfficeOpenXml.Style
;
using
Performance.DtoModels
;
using
Performance.DtoModels
;
using
Performance.DtoModels.AppSettings
;
using
Performance.DtoModels.AppSettings
;
using
Performance.EntityModels
;
using
Performance.EntityModels
;
...
@@ -11,6 +14,7 @@
...
@@ -11,6 +14,7 @@
using
Performance.Services.ExtractExcelService
;
using
Performance.Services.ExtractExcelService
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Data
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
...
@@ -672,6 +676,118 @@ public List<EmployeeReservedDto> GetReserved(ReservedRequest request, int userid
...
@@ -672,6 +676,118 @@ public List<EmployeeReservedDto> GetReserved(ReservedRequest request, int userid
}
}
return
reserveds
;
return
reserveds
;
}
}
/// <summary>
/// 预留金额下载
/// </summary>
/// <param name="rows"></param>
/// <param name="name"></param>
/// <param name="allotId"></param>
/// <param name="headList"></param>
/// <returns></returns>
public
string
ExcelDownload
(
List
<
Dictionary
<
string
,
object
>>
rows
,
string
name
,
List
<
ExcelDownloadHeads
>
excelDownloadHeads
,
params
string
[]
ignoreColumns
)
{
var
dpath
=
Path
.
Combine
(
_evn
.
ContentRootPath
,
"Files"
,
"PerformanceRelease"
);
FileHelper
.
CreateDirectory
(
dpath
);
string
filepath
=
Path
.
Combine
(
dpath
,
$"
{
name
}
-
{
DateTime
.
Now
:
yyyy
年
MM
月
dd
日
}
"
);
FileHelper
.
DeleteFile
(
filepath
);
string
[]
notSum
=
new
string
[]
{
"year"
,
"month"
,
"jobnumber"
,
"source"
,
"unittype"
,
"accountingunit"
,
"newunittype"
,
"newaccountingunit"
,
"employeename"
};
using
(
FileStream
fs
=
new
FileStream
(
filepath
,
FileMode
.
OpenOrCreate
))
using
(
ExcelPackage
package
=
new
ExcelPackage
(
fs
))
{
var
worksheet
=
package
.
Workbook
.
Worksheets
.
Add
(
name
);
if
(
rows
!=
null
&&
rows
.
Count
()
>
0
)
{
worksheet
.
SetValue
(
1
,
1
,
name
);
var
headList
=
rows
.
FirstOrDefault
().
Where
(
w
=>
!
ignoreColumns
.
Contains
(
w
.
Key
.
ToLower
())).
ToList
();
for
(
int
col
=
0
;
col
<
headList
.
Count
;
col
++)
{
string
headKey
=
headList
[
col
].
Key
;
string
head
;
head
=
headKey
.
Contains
(
"ReseFee"
)
?
"预留金额"
:
headKey
.
Contains
(
"GiveFee"
)
?
"实发金额"
:
headKey
;
foreach
(
var
item
in
excelDownloadHeads
)
{
if
(
headKey
==
item
.
Name
)
{
head
=
item
.
Alias
;
break
;
}
};
worksheet
.
SetValue
(
3
,
col
+
1
,
head
);
}
for
(
int
col
=
0
;
col
<
headList
.
Count
;
col
++)
{
for
(
int
row
=
0
;
row
<
rows
.
Count
();
row
++)
{
var
temp
=
rows
.
ElementAt
(
row
);
var
value
=
temp
[
headList
[
col
].
Key
]
??
""
;
worksheet
.
Cells
[
row
+
4
,
col
+
1
].
Value
=
value
;
}
if
(
col
==
0
)
worksheet
.
SetValue
(
rows
.
Count
()
+
4
,
col
+
1
,
"合计"
);
else
if
(!
notSum
.
Contains
(
headList
[
col
].
Key
.
ToLower
()))
worksheet
.
Cells
[
rows
.
Count
()
+
4
,
col
+
1
].
Formula
=
string
.
Format
(
"SUM({0})"
,
new
ExcelAddress
(
4
,
col
+
1
,
rows
.
Count
()
+
3
,
col
+
1
).
Address
);
}
#
region
样式设置
int
num
=
name
.
Contains
(
"科室"
)
?
6
:
5
;
for
(
int
i
=
1
;
i
<=
num
;
i
++)
{
worksheet
.
SetValue
(
2
,
i
,
worksheet
.
GetValue
(
3
,
i
));
worksheet
.
Cells
[
2
,
i
,
3
,
i
].
Merge
=
true
;
}
int
month
=
1
;
for
(
int
i
=
num
+
1
;
i
<=
headList
.
Count
;
i
+=
2
)
{
worksheet
.
SetValue
(
2
,
i
,
month
+
"月"
);
if
(
month
==
13
)
worksheet
.
SetValue
(
2
,
i
,
"合计"
);
worksheet
.
Cells
[
2
,
i
,
2
,
i
+
1
].
Merge
=
true
;
month
++;
}
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
++)
{
if
(
col
<=
headList
.
Count
&&
!
notSum
.
Contains
(
headList
[
col
-
1
].
Key
.
ToLower
()))
{
worksheet
.
Cells
[
row
,
col
].
Style
.
Numberformat
.
Format
=
"#,##0.00"
;
}
worksheet
.
Cells
[
row
,
col
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
row
,
col
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
worksheet
.
Cells
[
row
,
col
].
Style
.
Border
.
BorderAround
(
ExcelBorderStyle
.
Thin
);
}
}
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Merge
=
true
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
Font
.
Size
=
16
;
worksheet
.
Row
(
1
).
Height
=
24
;
worksheet
.
Cells
[
2
,
1
,
2
,
headList
.
Count
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
View
.
FreezePanes
(
4
,
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
;
}
/// <summary>
/// <summary>
/// 查询个人绩效
/// 查询个人绩效
/// </summary>
/// </summary>
...
...
performance/Performance.Services/DownloadService.cs
View file @
1806cc52
...
@@ -268,7 +268,6 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
...
@@ -268,7 +268,6 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
worksheet
.
Cells
[
row
,
col
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
row
,
col
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
}
}
}
}
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Merge
=
true
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
Cells
[
1
,
1
,
1
,
headList
.
Count
].
Style
.
Font
.
Bold
=
true
;
...
...
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