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
71fafeda
Commit
71fafeda
authored
Jul 31, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传人员绩效Id
parent
48546689
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
137 additions
and
8 deletions
+137
-8
performance/Performance.Api/Controllers/EmployeeController.cs
+54
-7
performance/Performance.Api/wwwroot/Performance.Api.xml
+7
-0
performance/Performance.Services/EmployeeService.cs
+76
-1
No files found.
performance/Performance.Api/Controllers/EmployeeController.cs
View file @
71fafeda
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
AutoMapper
;
using
FluentValidation.AspNetCore
;
using
FluentValidation.AspNetCore
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http.Internal
;
using
Microsoft.AspNetCore.Mvc
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Services
;
using
System
;
using
System.IO
;
using
System.Linq
;
namespace
Performance.Api.Controllers
{
...
...
@@ -15,11 +17,16 @@ namespace Performance.Api.Controllers
public
class
EmployeeController
:
Controller
{
private
EmployeeService
employeeService
;
private
AllotService
allotService
;
private
ClaimService
claim
;
public
EmployeeController
(
EmployeeService
employeeService
,
ClaimService
claim
)
private
IHostingEnvironment
evn
;
public
EmployeeController
(
EmployeeService
employeeService
,
AllotService
allotService
,
ClaimService
claim
,
IHostingEnvironment
evn
)
{
this
.
employeeService
=
employeeService
;
this
.
allotService
=
allotService
;
this
.
claim
=
claim
;
this
.
evn
=
evn
;
}
/// <summary>
...
...
@@ -231,5 +238,44 @@ public ApiResponse DeleteApr([FromBody] per_apr_amount request)
return
new
ApiResponse
(
ResponseType
.
Fail
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
/// <summary>
/// 上传人员绩效文件
/// </summary>
/// <param name="form"></param>
/// <returns></returns>
[
Route
(
"apr/import"
)]
[
HttpPost
]
public
ApiResponse
Import
([
FromForm
]
IFormCollection
form
)
{
var
allotid
=
form
.
ToDictionary
().
GetValue
(
"allotid"
,
0
);
if
(
allotid
<=
0
)
return
new
ApiResponse
(
ResponseType
.
Fail
,
"参数错误"
,
"allotid无效"
);
var
file
=
((
FormFileCollection
)
form
.
Files
).
FirstOrDefault
();
if
(
file
==
null
)
return
new
ApiResponse
(
ResponseType
.
Fail
,
"参数错误"
,
"文件无效"
);
var
allot
=
allotService
.
GetAllot
(
allotid
);
if
(
allot
==
null
)
return
new
ApiResponse
(
ResponseType
.
Fail
,
"allotid不存在"
);
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
dpath
=
Path
.
Combine
(
evn
.
ContentRootPath
,
"Files"
,
$"
{
allot
.
HospitalId
}
"
,
$"
{
allot
.
Year
}{
allot
.
Month
.
ToString
().
PadLeft
(
2
,
'0'
)}
"
);
FileHelper
.
CreateDirectory
(
dpath
);
var
path
=
Path
.
Combine
(
dpath
,
$"
{
name
}{
ext
}
"
);
using
(
var
stream
=
file
.
OpenReadStream
())
{
byte
[]
bytes
=
new
byte
[
stream
.
Length
];
stream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
if
(!
FileHelper
.
CreateFile
(
path
,
bytes
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
$"
{
file
.
FileName
}
上传失败"
);
}
employeeService
.
ImpoerAprEmployees
(
allotid
,
path
,
claim
.
GetUserId
());
return
new
ApiResponse
(
ResponseType
.
OK
);
}
}
}
\ No newline at end of file
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
71fafeda
...
...
@@ -599,6 +599,13 @@
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.EmployeeController.Import(Microsoft.AspNetCore.Http.IFormCollection)"
>
<summary>
上传人员绩效文件
</summary>
<param
name=
"form"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.ExConfigController.Extract(Performance.DtoModels.ModModuleRequest)"
>
<summary>
绩效数据抽取模板
...
...
performance/Performance.Services/EmployeeService.cs
View file @
71fafeda
using
AutoMapper
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Logging
;
using
NPOI.SS.UserModel
;
using
NPOI.SS.Util
;
using
NPOI.XSSF.UserModel
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
...
...
@@ -23,6 +25,7 @@ public class EmployeeService : IAutoInjection
private
PerforUserhospitalRepository
perforUserhospitalRepository
;
private
PerforPerallotRepository
perallotRepository
;
private
PerforPerapramountRepository
perapramountRepository
;
private
ILogger
<
EmployeeService
>
logger
;
public
EmployeeService
(
PerforImemployeeRepository
perforImemployeeRepository
,
PerforPersheetRepository
perforPersheetRepository
,
...
...
@@ -30,7 +33,8 @@ public class EmployeeService : IAutoInjection
PerforImemployeeclinicRepository
perforImemployeeclinicRepository
,
PerforUserhospitalRepository
perforUserhospitalRepository
,
PerforPerallotRepository
perallotRepository
,
PerforPerapramountRepository
perapramountRepository
)
PerforPerapramountRepository
perapramountRepository
,
ILogger
<
EmployeeService
>
logger
)
{
this
.
perforImemployeeRepository
=
perforImemployeeRepository
;
this
.
perforPersheetRepository
=
perforPersheetRepository
;
...
...
@@ -39,6 +43,7 @@ public class EmployeeService : IAutoInjection
this
.
perforUserhospitalRepository
=
perforUserhospitalRepository
;
this
.
perallotRepository
=
perallotRepository
;
this
.
perapramountRepository
=
perapramountRepository
;
this
.
logger
=
logger
;
}
#
region
行政人员
...
...
@@ -316,5 +321,75 @@ public bool DeleteApr(int id)
return
true
;
}
public
void
ImpoerAprEmployees
(
int
allotid
,
string
path
,
int
userid
)
{
var
data
=
perapramountRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
allotid
);
if
(
data
!=
null
&&
data
.
Any
())
perapramountRepository
.
RemoveRange
(
data
.
ToArray
());
try
{
IWorkbook
workbook
=
new
XSSFWorkbook
(
path
);
if
(
workbook
==
null
)
return
;
var
sheet
=
workbook
.
GetSheetAt
(
0
);
var
firstRow
=
sheet
.
GetRow
(
0
);
List
<(
string
,
int
)>
excelheader
=
new
List
<(
string
,
int
)>();
for
(
int
cellindex
=
0
;
cellindex
<
firstRow
.
LastCellNum
+
1
;
cellindex
++)
{
var
cell
=
firstRow
.
GetCell
(
cellindex
);
if
(
cell
==
null
)
continue
;
if
(!
string
.
IsNullOrEmpty
(
cell
.
ToString
()))
excelheader
.
Add
((
cell
.
ToString
(),
cellindex
));
}
if
(
excelheader
==
null
||
!
excelheader
.
Any
())
throw
new
PerformanceException
(
"上传excel内容错误"
);
Dictionary
<
string
,
int
>
dict
=
new
Dictionary
<
string
,
int
>
{
{
"人员工号"
,
-
1
},
{
"姓名"
,
-
1
},
{
"绩效类型"
,
-
1
},
{
"金额"
,
-
1
},
};
List
<
string
>
errorHeaders
=
new
List
<
string
>();
foreach
(
var
key
in
dict
.
Keys
.
ToList
())
{
if
(!
excelheader
.
Select
(
t
=>
t
.
Item1
).
Contains
(
key
))
errorHeaders
.
Add
(
key
);
else
dict
[
key
]
=
excelheader
.
First
(
t
=>
t
.
Item1
==
key
).
Item2
;
}
if
(
errorHeaders
!=
null
&&
errorHeaders
.
Any
())
throw
new
PerformanceException
(
$"excel缺少列
{
string
.
Join
(
", "
,
errorHeaders
)}
"
);
var
entities
=
new
List
<
per_apr_amount
>();
var
createtime
=
DateTime
.
Now
;
for
(
int
rowindex
=
1
;
rowindex
<
sheet
.
LastRowNum
+
1
;
rowindex
++)
{
var
row
=
sheet
.
GetRow
(
rowindex
);
if
(
row
==
null
)
continue
;
var
entity
=
new
per_apr_amount
{
PersonnelNumber
=
row
.
GetCell
(
dict
[
"人员工号"
])?.
ToString
(),
DoctorName
=
row
.
GetCell
(
dict
[
"姓名"
])?.
ToString
(),
PerforType
=
row
.
GetCell
(
dict
[
"绩效类型"
])?.
ToString
(),
Amount
=
(
decimal
)(
row
.
GetCell
(
dict
[
"金额"
])?.
NumericCellValue
??
0
),
AllotId
=
allotid
,
CreateDate
=
createtime
,
CreateUser
=
userid
,
};
entities
.
Add
(
entity
);
}
perapramountRepository
.
AddRange
(
entities
.
ToArray
());
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
ex
.
ToString
());
}
}
}
}
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