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
b2fcc28e
Commit
b2fcc28e
authored
Jun 05, 2023
by
wyc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
科室绩效详情下载
parent
12a13c86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
100 deletions
+111
-100
performance/Performance.Api/Controllers/ComputeController.cs
+26
-0
performance/Performance.Services/ComputeService.UniteDeptDetail.cs
+85
-100
No files found.
performance/Performance.Api/Controllers/ComputeController.cs
View file @
b2fcc28e
...
@@ -213,6 +213,32 @@ public ApiResponse UniteDeptDetail([FromBody] UniteDeptDetailRequest request)
...
@@ -213,6 +213,32 @@ public ApiResponse UniteDeptDetail([FromBody] UniteDeptDetailRequest request)
}
}
[
Route
(
"download/unite/deptdetail"
)]
[
HttpPost
]
public
IActionResult
DownloadUniteDeptdetail
([
FromBody
]
UniteDeptDetailRequest
request
)
{
request
.
UnitType
=
request
.
UnitType
.
Replace
(
"行政后勤"
,
"行政工勤"
);
if
(!
Enum
.
TryParse
(
request
.
UnitType
,
ignoreCase
:
true
,
out
UnitType
unitType
))
return
BadRequest
(
"核算组别错误"
);
var
userid
=
_claim
.
GetUserId
();
var
uniteDeptDetail
=
_computeService
.
UniteDeptDetail
(
request
.
AllotId
,
unitType
,
request
.
AccountingUnit
,
userid
);
//var ser = JsonConvert.SerializeObject(response);
//var rows = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(ser);
//Dictionary<string, object> rows = _computeService.ConvertToDictionary(response);
var
filepath
=
_computeService
.
ExcelDownload
(
uniteDeptDetail
,
"科室绩效详情"
,
request
.
AllotId
);
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
));
}
#
region
20230531
即将弃用,由新接口替代
#
region
20230531
即将弃用,由新接口替代
...
...
performance/Performance.Services/ComputeService.UniteDeptDetail.cs
View file @
b2fcc28e
...
@@ -605,106 +605,91 @@ public void SaveUniteDeptDetailSetting(int allotId, List<UniteDeptDetailItem> re
...
@@ -605,106 +605,91 @@ public void SaveUniteDeptDetailSetting(int allotId, List<UniteDeptDetailItem> re
}
}
#
region
科室详情下载
#
region
科室详情下载
//public string ExcelDownload(List<Dictionary<string, object>> rows, string name, int allotId)
public
string
ExcelDownload
(
UniteDeptDetailResponse
uniteDeptDetail
,
string
name
,
int
allotId
)
//{
{
// var perAllot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
var
dpath
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Files"
);
// string title = $"{perAllot.Year}年{perAllot.Month}月{name}";
if
(!
Directory
.
Exists
(
dpath
))
Directory
.
CreateDirectory
(
dpath
);
// var data = new List<Dictionary<string, object>>();
string
filepath
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
DateTime
.
Now
:
yyyy
年
MM
月
dd
日
}
"
);
// foreach (var obj in rows)
if
(
File
.
Exists
(
filepath
))
File
.
Delete
(
filepath
);
// {
// Dictionary<string, object> nobj = new Dictionary<string, object>();
using
(
FileStream
fs
=
new
FileStream
(
filepath
,
FileMode
.
OpenOrCreate
))
using
(
ExcelPackage
package
=
new
ExcelPackage
(
fs
))
// foreach (var item in obj)
{
// {
var
maxColIndex
=
10
;
// var lower = item.Key.ToLower();
var
worksheet
=
package
.
Workbook
.
Worksheets
.
Add
(
name
);
worksheet
.
SetValue
(
1
,
1
,
uniteDeptDetail
.
Title
);
// if (lower.Contains("date"))
worksheet
.
Cells
[
1
,
1
,
1
,
maxColIndex
].
Merge
=
true
;
// nobj[lower] = Convert.ToDateTime(item.Value).ToString("d");
// else if (lower.Contains("detial"))
var
rowIndex
=
1
;
// {
xx
(
worksheet
,
maxColIndex
,
rowIndex
,
uniteDeptDetail
.
DetailItems
);
// var detRows = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(item.Value.ToString());
// foreach (var detlist in detRows)
//#region 样式设置
// {
//for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
// object value = null;
//{
// foreach (var detitem in detlist)
// worksheet.Row(row).Height = 20;
// {
// for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
// if (detitem.Key.Equals("Value", StringComparison.OrdinalIgnoreCase))
// {
// value = detitem.Value;
// worksheet.Cells[row, col].Style.Border.BorderAround(ExcelBorderStyle.Thin);
// if (detitem.Key.Equals("Title", StringComparison.OrdinalIgnoreCase))
// worksheet.Cells[row, col].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
// nobj[detitem.Value.ToString()] = value;
// 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;
// else
////worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Size = 16;
// nobj[lower] = item.Value;
////worksheet.Row(1).Height = 24;
// }
////worksheet.Cells[2, 1, 2, headList.Count].Style.Font.Bold = true;
// data.Add(nobj);
//worksheet.Cells.AutoFitColumns();
// }
//for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
//{
// var dpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files");
// worksheet.Column(col).Width = worksheet.Column(col).Width > 20 ? 20 : worksheet.Column(col).Width;
// if (!Directory.Exists(dpath)) Directory.CreateDirectory(dpath);
//}
//#endregion
// string filepath = Path.Combine(dpath, $"{name}{DateTime.Now:yyyy年MM月dd日}");
// if (File.Exists(filepath)) File.Delete(filepath);
package
.
Save
();
}
// using (FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate))
return
filepath
;
// using (ExcelPackage package = new ExcelPackage(fs))
}
// {
// var worksheet = package.Workbook.Worksheets.Add(name);
void
xx
(
ExcelWorksheet
worksheet
,
int
maxColIndex
,
int
rowIndex
,
List
<
DeptDetailItem
>
detailItems
)
{
// if (rows != null && rows.Count() > 0)
foreach
(
var
item
in
detailItems
)
// {
{
// worksheet.SetValue(1, 1, title);
rowIndex
=
rowIndex
+
1
;
worksheet
.
SetValue
(
rowIndex
,
1
,
$"
{
item
.
Title
}
:
{
item
.
TotalFormat
}
"
);
// for (int col = 0; col < headList.Count; col++)
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Merge
=
true
;
// {
// worksheet.SetValue(2, col + 1, headList[col].Alias);
if
(
item
.
Children
?.
Any
()
==
true
)
// }
{
// for (int col = 0; col < headList.Count; col++)
xx
(
worksheet
,
maxColIndex
,
rowIndex
,
item
.
Children
);
// {
}
// for (int row = 0; row < data.Count(); row++)
else
if
(
item
.
Items
?.
Any
()
==
true
)
// {
{
// var temp = data.ElementAt(row);
rowIndex
=
rowIndex
+
1
;
var
headers
=
item
.
Items
.
FirstOrDefault
().
Keys
.
Select
(
w
=>
w
);
// var key = headList[col].Name;
for
(
int
colIndex
=
0
;
colIndex
<
headers
.
Count
();
colIndex
++)
// if (!temp.ContainsKey(key))
{
// key = key.ToLower();
worksheet
.
SetValue
(
rowIndex
,
colIndex
+
1
,
headers
.
ElementAt
(
colIndex
));
// temp.TryGetValue(key, out object value);
if
(
colIndex
+
1
==
headers
.
Count
())
// worksheet.Cells[row + 3, col + 1].Value = value ?? "";
worksheet
.
Cells
[
rowIndex
,
colIndex
,
rowIndex
,
maxColIndex
].
Merge
=
true
;
}
// }
rowIndex
=
rowIndex
+
1
;
// }
foreach
(
var
row
in
item
.
Items
)
{
// #region 样式设置
rowIndex
=
rowIndex
+
1
;
// for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
for
(
int
colIndex
=
0
;
colIndex
<
headers
.
Count
();
colIndex
++)
// {
{
// worksheet.Row(row).Height = 20;
worksheet
.
SetValue
(
rowIndex
,
colIndex
+
1
,
row
[
headers
.
ElementAt
(
colIndex
)]);
// for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
if
(
colIndex
+
1
==
headers
.
Count
())
// {
worksheet
.
Cells
[
rowIndex
,
colIndex
,
rowIndex
,
maxColIndex
].
Merge
=
true
;
// 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.Row(1).Height = 24;
// //worksheet.Cells[2, 1, 2, headList.Count].Style.Font.Bold = true;
// 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;
//}
#
endregion
#
endregion
}
}
}
}
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