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
b53eca2a
Commit
b53eca2a
authored
May 15, 2019
by
李承祥
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug -- 部分列头无法获取
parent
f118e442
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
32 deletions
+133
-32
performance/Performance.Api/Controllers/TemplateController.cs
+17
-2
performance/Performance.Services/ExtractService.cs
+112
-24
performance/Performance.Services/TemplateService.cs
+4
-6
No files found.
performance/Performance.Api/Controllers/TemplateController.cs
View file @
b53eca2a
...
...
@@ -3,11 +3,14 @@
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http.Internal
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Options
;
using
Performance.DtoModels
;
using
Performance.DtoModels.AppSettings
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Services
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
...
...
@@ -21,17 +24,20 @@ public class TemplateController : Controller
private
HospitalService
hospitalService
;
private
IHostingEnvironment
evn
;
private
ClaimService
claim
;
private
Application
application
;
public
TemplateController
(
TemplateService
templateService
,
HospitalService
hospitalService
,
ExtractService
extractService
,
IHostingEnvironment
evn
,
ClaimService
claim
)
ClaimService
claim
,
IOptions
<
Application
>
options
)
{
this
.
templateService
=
templateService
;
this
.
extractService
=
extractService
;
this
.
hospitalService
=
hospitalService
;
this
.
evn
=
evn
;
this
.
claim
=
claim
;
this
.
application
=
options
.
Value
;
}
/// <summary>
...
...
@@ -80,7 +86,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
};
if
(
templateService
.
InsertFirst
(
template
))
{
templateService
.
SendEmail
(
path
,
$"
{
hospital
.
HosName
}
首次上传模板"
,
"上传成功"
);
templateService
.
SendEmail
(
application
.
Receiver
.
ToList
(),
path
,
$"
{
hospital
.
HosName
}
首次上传模板"
,
"上传成功"
);
}
}
return
new
ApiResponse
(
ResponseType
.
OK
);
...
...
@@ -95,7 +101,16 @@ public ApiResponse Import([FromForm] IFormCollection form)
[
HttpPost
]
public
ApiResponse
ExtractData
([
CustomizeValidator
(
RuleSet
=
"Delete"
),
FromBody
]
HospitalRequest
request
)
{
var
hospital
=
hospitalService
.
GetHopital
(
request
.
ID
);
if
(
hospital
==
null
)
return
new
ApiResponse
(
ResponseType
.
Fail
,
"hospitalid不存在"
);
var
filePath
=
extractService
.
ExtractData
(
request
.
ID
);
if
(!
string
.
IsNullOrEmpty
(
filePath
)
&&
FileHelper
.
IsExistFile
(
filePath
))
{
var
user
=
claim
.
At
(
request
.
Token
);
templateService
.
SendEmail
(
new
List
<
string
>
{
user
.
Mail
},
filePath
,
$"
{
hospital
.
HosName
}
提取数据"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
}
return
new
ApiResponse
(
ResponseType
.
OK
,
"OK"
,
filePath
);
}
}
...
...
performance/Performance.Services/ExtractService.cs
View file @
b53eca2a
...
...
@@ -93,8 +93,8 @@ public string ExtractData(int hospitalId)
FileHelper
.
CreateDirectory
(
dpath
);
string
path
=
Path
.
Combine
(
dpath
,
$"绩效数据
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}
.xlsx"
);
//根据SHEET页信息,列头信息,创建EXCEL文件
if
(
WriteExcel
(
path
,
originalPath
,
sheetList
,
hospitalConfig
,
hospitalId
))
return
d
path
;
if
(
WriteExcel
(
path
,
originalPath
,
sheetList
,
hospitalConfig
,
hospitalId
,
out
string
filepath
))
return
file
path
;
throw
new
PerformanceException
(
"绩效数据提取失败"
);
}
...
...
@@ -109,7 +109,7 @@ public string ExtractData(int hospitalId)
/// <param name="sheetList"></param>
/// <param name="hospitalConfig"></param>
/// <param name="hospitalId"></param>
private
bool
WriteExcel
(
string
newpath
,
string
originalPath
,
List
<
PerSheet
>
sheetList
,
sys_hospitalconfig
hospitalConfig
,
int
hospitalId
)
private
bool
WriteExcel
(
string
newpath
,
string
originalPath
,
List
<
PerSheet
>
sheetList
,
sys_hospitalconfig
hospitalConfig
,
int
hospitalId
,
out
string
filepath
)
{
if
(
string
.
IsNullOrEmpty
(
originalPath
))
throw
new
PerformanceException
(
$"
{
originalPath
}
文件路径无效"
);
...
...
@@ -123,25 +123,10 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
{
var
importSheet
=
workbook
.
GetSheet
(
sheet
.
SheetName
);
if
(
importSheet
==
null
)
continue
;
//var importSheet = workbook.CreateSheet(sheet.SheetName);
//创建列头
//foreach (var pointRow in sheet.PerHeader.Select(t => t.PointRow).Distinct().OrderBy(t => t))
//{
// var importRow = importSheet.CreateRow(pointRow);
// //写入单元格
// foreach (var perHeader in sheet.PerHeader.Where(t => t.PointRow == pointRow))
// {
// importRow.CreateCell(perHeader.PointCell).SetCellValue(perHeader.CellValue);
// //设置合并单元格
// if (perHeader.IsMerge)
// {
// var cellRange = new CellRangeAddress(perHeader.PointRow, perHeader.PointRow + perHeader.MergeRow, perHeader.PointCell, perHeader.PointCell + perHeader.MergeCell);
// importSheet.AddMergedRegion(cellRange);
// }
// }
//}
if
(
sheet
.
PerHeader
==
null
)
continue
;
var
maxHeaderRowNumber
=
sheet
.
PerHeader
.
Max
(
t
=>
t
.
PointRow
);
sheet
.
PerHeader
.
ForEach
(
t
=>
sheet
.
PerHeader
?
.
ForEach
(
t
=>
{
if
(
t
.
IsHasChildren
)
{
...
...
@@ -221,6 +206,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
}
using
(
FileStream
file
=
new
FileStream
(
newpath
,
FileMode
.
Create
))
workbook
.
Write
(
file
);
filepath
=
newpath
;
return
true
;
}
...
...
@@ -234,6 +220,10 @@ private List<PerSheet> GetRepositoryData(int allotId)
List
<
PerSheet
>
sheetList
=
new
List
<
PerSheet
>();
//获取最近一次绩效
var
perSheetList
=
perforPersheetRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotId
);
if
(
perSheetList
==
null
||
perSheetList
.
Count
==
0
)
return
sheetList
;
foreach
(
var
sheet
in
perSheetList
)
{
PerSheet
perSheet
=
new
PerSheet
()
...
...
@@ -246,9 +236,18 @@ private List<PerSheet> GetRepositoryData(int allotId)
perSheet
.
PerHeader
=
AutoMapper
.
Mapper
.
Map
<
List
<
PerHeader
>>(
perHeadList
);
if
(
SheetType
.
Employee
==
(
SheetType
)
sheet
.
SheetType
)
{
var
employeeList
=
perforImemployeeRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
sheet
.
ID
);
perSheet
.
PerHeader
=
GetHeader
((
SheetType
)
sheet
.
SheetType
);
var
employeeList
=
perforImemployeeRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
sheet
.
AllotID
);
var
perEmployeeList
=
AutoMapper
.
Mapper
.
Map
<
List
<
PerDataEmployee
>>(
employeeList
);
perSheet
.
PerData
=
perEmployeeList
.
ConvertAll
(
new
Converter
<
PerDataEmployee
,
IPerData
>(
m
=>
m
));
perSheet
.
PerData
=
perEmployeeList
?.
ConvertAll
(
new
Converter
<
PerDataEmployee
,
IPerData
>(
m
=>
m
));
}
else
if
(
SheetType
.
SpecialUnit
==
(
SheetType
)
sheet
.
SheetType
)
{
perSheet
.
PerHeader
=
GetHeader
((
SheetType
)
sheet
.
SheetType
);
}
else
if
(
SheetType
.
AccountBasic
==
(
SheetType
)
sheet
.
SheetType
)
{
perSheet
.
PerHeader
=
GetHeader
((
SheetType
)
sheet
.
SheetType
);
}
sheetList
.
Add
(
perSheet
);
}
...
...
@@ -310,7 +309,7 @@ public dynamic Verify(string obj)
try
{
//判断值是否为double类型
if
(!
string
.
IsNullOrEmpty
(
obj
)
&&
Regex
.
Match
(
obj
.
Trim
(),
@"([1-9]\d*\.?\d*)|(0\.\d*[1-9])|0"
).
ToString
()
==
obj
.
Trim
())
if
(!
string
.
IsNullOrEmpty
(
obj
)
&&
Regex
.
Match
(
obj
.
Trim
(),
@"([1-9]\d*\.?\d*)|(0\.\d*[1-9]
?\d*
)|0"
).
ToString
()
==
obj
.
Trim
())
return
ConvertHelper
.
To
<
double
>(
obj
);
//判断值是否为日期格式
else
if
(!
string
.
IsNullOrEmpty
(
obj
)
&&
Regex
.
Match
(
obj
.
Trim
(),
@"(19|20)\d{2}(-|/)[01]?\d(-|/)[0123]?\d( [012]?\d\:\d{2}\:\d{2})?"
).
ToString
()
==
obj
.
Trim
())
...
...
@@ -323,5 +322,94 @@ public dynamic Verify(string obj)
return
obj
;
}
}
#
region
获取列头
/// <summary>
/// 获取列头
/// </summary>
/// <param name="sheetType">sheet页类型</param>
/// <returns></returns>
public
List
<
PerHeader
>
GetHeader
(
SheetType
sheetType
)
{
Dictionary
<
string
,
List
<
int
>>
keyValues
=
new
Dictionary
<
string
,
List
<
int
>>();
if
(
SheetType
.
Employee
==
sheetType
)
{
keyValues
=
new
Dictionary
<
string
,
List
<
int
>>
{
{
"核算单元分类"
,
new
List
<
int
>
{
1
,
1
,
0
,
1
}
},
{
"核算单元"
,
new
List
<
int
>
{
1
,
1
,
1
,
1
}
},
{
"绩效基数核算参考对象"
,
new
List
<
int
>
{
1
,
1
,
2
,
1
}
},
{
"医生姓名"
,
new
List
<
int
>
{
1
,
1
,
3
,
1
}
},
{
"职称"
,
new
List
<
int
>
{
1
,
1
,
4
,
1
}
},
{
"岗位系数"
,
new
List
<
int
>
{
1
,
1
,
5
,
1
}
},
{
"参加工作时间"
,
new
List
<
int
>
{
1
,
1
,
6
,
1
}
},
{
"考核得分率"
,
new
List
<
int
>
{
1
,
1
,
7
,
1
}
},
{
"出勤率"
,
new
List
<
int
>
{
1
,
1
,
8
,
1
}
},
{
"核算单元医生数"
,
new
List
<
int
>
{
1
,
1
,
9
,
1
}
},
{
"工作量绩效"
,
new
List
<
int
>
{
1
,
1
,
10
,
1
}
},
{
"其他绩效"
,
new
List
<
int
>
{
1
,
1
,
11
,
1
}
},
{
"医院奖罚"
,
new
List
<
int
>
{
1
,
1
,
12
,
1
}
},
{
"调节系数"
,
new
List
<
int
>
{
1
,
1
,
13
,
1
}
},
{
"发放系数"
,
new
List
<
int
>
{
1
,
1
,
14
,
1
}
},
};
}
else
if
(
SheetType
.
AccountBasic
==
sheetType
)
{
keyValues
=
new
Dictionary
<
string
,
List
<
int
>>
{
{
"核算单元"
,
new
List
<
int
>
{
1
,
2
,
0
,
1
}
},
{
"科室"
,
new
List
<
int
>
{
1
,
2
,
1
,
1
}
},
{
"医生组"
,
new
List
<
int
>
{
8
,
1
,
2
,
1
}
},
{
"护理组"
,
new
List
<
int
>
{
8
,
1
,
3
,
1
}
},
{
"核算单元医生数量"
,
new
List
<
int
>
{
1
,
1
,
2
,
2
}
},
{
"基础系数"
,
new
List
<
int
>
{
1
,
1
,
3
,
2
}
},
{
"倾斜系数"
,
new
List
<
int
>
{
1
,
1
,
4
,
2
}
},
{
"其他绩效1"
,
new
List
<
int
>
{
1
,
1
,
5
,
2
}
},
{
"考核得分率"
,
new
List
<
int
>
{
1
,
1
,
6
,
2
}
},
{
"医院奖罚"
,
new
List
<
int
>
{
1
,
1
,
7
,
2
}
},
{
"其他绩效2"
,
new
List
<
int
>
{
1
,
1
,
8
,
2
}
},
{
"调节系数"
,
new
List
<
int
>
{
1
,
1
,
9
,
2
}
},
{
"核算单元护士数量"
,
new
List
<
int
>
{
1
,
1
,
10
,
2
}
},
{
"基础系数?"
,
new
List
<
int
>
{
1
,
1
,
11
,
2
}
},
{
"倾斜系数?"
,
new
List
<
int
>
{
1
,
1
,
12
,
2
}
},
{
"其他绩效1?"
,
new
List
<
int
>
{
1
,
1
,
13
,
2
}
},
{
"考核得分率?"
,
new
List
<
int
>
{
1
,
1
,
14
,
2
}
},
{
"医院奖罚?"
,
new
List
<
int
>
{
1
,
1
,
15
,
2
}
},
{
"其他绩效2?"
,
new
List
<
int
>
{
1
,
1
,
16
,
2
}
},
{
"调节系数?"
,
new
List
<
int
>
{
1
,
1
,
17
,
2
}
},
};
}
else
if
(
SheetType
.
SpecialUnit
==
sheetType
)
{
keyValues
=
new
Dictionary
<
string
,
List
<
int
>>
{
{
"科室"
,
new
List
<
int
>
{
1
,
1
,
0
,
1
}
},
{
"人数"
,
new
List
<
int
>
{
1
,
1
,
1
,
1
}
},
{
"量化指标"
,
new
List
<
int
>
{
1
,
1
,
2
,
1
}
},
{
"数量"
,
new
List
<
int
>
{
1
,
1
,
3
,
1
}
},
{
"量化指标绩效分值"
,
new
List
<
int
>
{
1
,
1
,
4
,
1
}
},
{
"考核得分率"
,
new
List
<
int
>
{
1
,
1
,
5
,
1
}
},
{
"医院奖罚"
,
new
List
<
int
>
{
1
,
1
,
6
,
1
}
},
{
"其他绩效"
,
new
List
<
int
>
{
1
,
1
,
7
,
1
}
},
{
"调节系数"
,
new
List
<
int
>
{
1
,
1
,
8
,
1
}
},
};
}
List
<
PerHeader
>
header
=
new
List
<
PerHeader
>();
foreach
(
var
item
in
keyValues
.
Keys
)
{
header
.
Add
(
new
PerHeader
{
CellValue
=
item
.
Replace
(
"?"
,
""
),
IsTotal
=
0
,
MergeCell
=
keyValues
[
item
][
0
],
MergeRow
=
keyValues
[
item
][
1
],
PointCell
=
keyValues
[
item
][
2
],
PointRow
=
keyValues
[
item
][
3
]
});
}
return
header
;
}
#
endregion
}
}
performance/Performance.Services/TemplateService.cs
View file @
b53eca2a
...
...
@@ -12,17 +12,15 @@ namespace Performance.Services
{
public
class
TemplateService
:
IAutoInjection
{
private
Application
application
;
private
IEmailService
emailService
;
private
PerforPerfirstRepository
PerforPerfirstRepository
;
public
TemplateService
(
I
Options
<
Application
>
options
,
I
EmailService
emailService
,
public
TemplateService
(
IEmailService
emailService
,
PerforPerfirstRepository
PerforPerfirstRepository
)
{
this
.
application
=
options
.
Value
;
this
.
emailService
=
emailService
;
this
.
PerforPerfirstRepository
=
PerforPerfirstRepository
;
}
/// <summary>
/// 添加数据 per_first
/// </summary>
...
...
@@ -40,11 +38,11 @@ public bool InsertFirst(per_first first)
/// <param name="path"></param>
/// <param name="subject"></param>
/// <param name="body"></param>
public
void
SendEmail
(
string
path
,
string
subject
,
string
body
)
public
void
SendEmail
(
List
<
string
>
receiver
,
string
path
,
string
subject
,
string
body
)
{
var
message
=
new
EmailMessage
{
To
=
application
.
Receiver
.
ToList
()
,
To
=
receiver
,
Attachments
=
new
List
<
string
>
{
path
},
DisplayName
=
"溯直健康"
,
Subject
=
subject
,
...
...
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