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
5726ad95
Commit
5726ad95
authored
Feb 02, 2021
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
绩效数据导入his_importdata
parent
5494db62
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
382 additions
and
5 deletions
+382
-5
performance/Performance.Api/Controllers/ReportGlobalController.cs
+51
-3
performance/Performance.Api/wwwroot/Performance.Api.xml
+8
-0
performance/Performance.Api/wwwroot/Performance.EntityModels.xml
+78
-0
performance/Performance.EntityModels/Context/PerformanceDbContext.cs
+3
-0
performance/Performance.EntityModels/Entity/his_importdata.cs
+89
-0
performance/Performance.Repository/Repository/PerforHisimportdataRepository.cs
+20
-0
performance/Performance.Services/ReportGlobalService.cs
+133
-2
No files found.
performance/Performance.Api/Controllers/ReportGlobalController.cs
View file @
5726ad95
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http.Internal
;
using
Microsoft.AspNetCore.Mvc
;
using
Performance.DtoModels
;
using
Performance.Infrastructure
;
using
Performance.Services
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
...
...
@@ -10,10 +17,51 @@ namespace Performance.Api.Controllers
[
Route
(
"api/{hospitalId}/report/global"
)]
public
class
ReportGlobalController
:
Controller
{
//private readonly
private
readonly
IHostingEnvironment
env
;
private
readonly
AllotService
allotService
;
private
readonly
ReportGlobalService
reportGlobalService
;
public
ReportGlobalController
()
public
ReportGlobalController
(
IHostingEnvironment
env
,
AllotService
allotService
,
ReportGlobalService
reportGlobalService
)
{
this
.
env
=
env
;
this
.
allotService
=
allotService
;
this
.
reportGlobalService
=
reportGlobalService
;
}
/// <summary>
/// 上传人员绩效文件
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="form"></param>
/// <returns></returns>
[
Route
(
"import"
)]
[
HttpPost
]
public
ApiResponse
Import
(
int
hospitalId
,
[
FromForm
]
IFormCollection
form
)
{
var
file
=
((
FormFileCollection
)
form
.
Files
).
FirstOrDefault
();
if
(
file
==
null
)
return
new
ApiResponse
(
ResponseType
.
Fail
,
"参数错误"
,
"文件无效"
);
var
name
=
FileHelper
.
GetFileNameNoExtension
(
file
.
FileName
)
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
ext
=
FileHelper
.
GetExtension
(
file
.
FileName
);
var
dpath
=
Path
.
Combine
(
env
.
ContentRootPath
,
"Files"
,
$"
{
hospitalId
}
"
,
$"ImportDataFiles"
);
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
}
上传失败"
);
}
reportGlobalService
.
ImportAllotData
(
hospitalId
,
path
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
}
}
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
5726ad95
...
...
@@ -1094,6 +1094,14 @@
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.ReportGlobalController.Import(System.Int32,Microsoft.AspNetCore.Http.IFormCollection)"
>
<summary>
上传人员绩效文件
</summary>
<param
name=
"hospitalId"
></param>
<param
name=
"form"
></param>
<returns></returns>
</member>
<member
name=
"T:Performance.Api.Controllers.SecondAllotController"
>
<summary>
二次绩效
...
...
performance/Performance.Api/wwwroot/Performance.EntityModels.xml
View file @
5726ad95
...
...
@@ -118,6 +118,9 @@
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.ex_type"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.his_importdata"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.hos_personfee"
>
<summary>
</summary>
</member>
...
...
@@ -1913,6 +1916,81 @@
来源
</summary>
</member>
<member
name=
"T:Performance.EntityModels.his_importdata"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.Id"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.HospitalId"
>
<summary>
医院ID
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.AllotId"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.Year"
>
<summary>
年
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.Month"
>
<summary>
月
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.AccountingUnit"
>
<summary>
科室核算单元
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.Department"
>
<summary>
科室
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.PersonnelName"
>
<summary>
医生姓名
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.PersonnelNumber"
>
<summary>
人员工号
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.SourceType"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.Category"
>
<summary>
一级分类
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.Original"
>
<summary>
原始分类
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.ItemName"
>
<summary>
二级分类
</summary>
</member>
<member
name=
"P:Performance.EntityModels.his_importdata.Value"
>
<summary>
值
</summary>
</member>
<member
name=
"T:Performance.EntityModels.hos_personfee"
>
<summary>
...
...
performance/Performance.EntityModels/Context/PerformanceDbContext.cs
View file @
5726ad95
...
...
@@ -132,6 +132,9 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public
virtual
DbSet
<
ex_type
>
ex_type
{
get
;
set
;
}
/// <summary> </summary>
public
virtual
DbSet
<
his_importdata
>
his_importdata
{
get
;
set
;
}
/// <summary> </summary>
public
virtual
DbSet
<
hos_personfee
>
hos_personfee
{
get
;
set
;
}
/// <summary> 科室核算导入信息 </summary>
...
...
performance/Performance.EntityModels/Entity/his_importdata.cs
0 → 100644
View file @
5726ad95
//-----------------------------------------------------------------------
// <copyright file=" his_importdata.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using
System
;
using
System.ComponentModel.DataAnnotations
;
using
System.ComponentModel.DataAnnotations.Schema
;
namespace
Performance.EntityModels
{
/// <summary>
///
/// </summary>
[
Table
(
"his_importdata"
)]
public
class
his_importdata
{
/// <summary>
///
/// </summary>
[
Key
]
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 医院ID
/// </summary>
public
int
HospitalId
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
Nullable
<
int
>
AllotId
{
get
;
set
;
}
/// <summary>
/// 年
/// </summary>
public
int
Year
{
get
;
set
;
}
/// <summary>
/// 月
/// </summary>
public
int
Month
{
get
;
set
;
}
/// <summary>
/// 科室核算单元
/// </summary>
public
string
AccountingUnit
{
get
;
set
;
}
/// <summary>
/// 科室
/// </summary>
public
string
Department
{
get
;
set
;
}
/// <summary>
/// 医生姓名
/// </summary>
public
string
PersonnelName
{
get
;
set
;
}
/// <summary>
/// 人员工号
/// </summary>
public
string
PersonnelNumber
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
SourceType
{
get
;
set
;
}
/// <summary>
/// 一级分类
/// </summary>
public
string
Category
{
get
;
set
;
}
/// <summary>
/// 原始分类
/// </summary>
public
string
Original
{
get
;
set
;
}
/// <summary>
/// 二级分类
/// </summary>
public
string
ItemName
{
get
;
set
;
}
/// <summary>
/// 值
/// </summary>
public
Nullable
<
decimal
>
Value
{
get
;
set
;
}
}
}
performance/Performance.Repository/Repository/PerforHisimportdataRepository.cs
0 → 100644
View file @
5726ad95
//-----------------------------------------------------------------------
// <copyright file=" his_importdata.cs">
// * FileName: his_importdata.cs
// </copyright>
//-----------------------------------------------------------------------
using
System
;
using
Performance.EntityModels
;
namespace
Performance.Repository
{
/// <summary>
/// his_importdata Repository
/// </summary>
public
partial
class
PerforHisimportdataRepository
:
PerforRepository
<
his_importdata
>
{
public
PerforHisimportdataRepository
(
PerformanceDbContext
context
)
:
base
(
context
)
{
}
}
}
performance/Performance.Services/ReportGlobalService.cs
View file @
5726ad95
using
Performance.EntityModels
;
using
Microsoft.Extensions.Logging
;
using
NPOI.SS.UserModel
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Repository
;
using
Performance.Services.ExtractExcelService
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Performance.Services
{
public
class
ReportGlobalService
:
IAutoInjection
{
private
readonly
ILogger
logger
;
private
readonly
PerforPerallotRepository
perallotRepository
;
private
readonly
PerforReportglobalRepository
reportglobalRepository
;
private
readonly
PerforHisimportdataRepository
hisimportdataRepository
;
public
ReportGlobalService
(
PerforReportglobalRepository
reportglobalRepository
)
public
ReportGlobalService
(
ILogger
<
ReportGlobalService
>
logger
,
PerforPerallotRepository
perallotRepository
,
PerforReportglobalRepository
reportglobalRepository
,
PerforHisimportdataRepository
hisimportdataRepository
)
{
this
.
logger
=
logger
;
this
.
perallotRepository
=
perallotRepository
;
this
.
reportglobalRepository
=
reportglobalRepository
;
this
.
hisimportdataRepository
=
hisimportdataRepository
;
}
public
List
<
report_global
>
GetReportGlobals
(
int
hospitalId
)
...
...
@@ -20,5 +37,119 @@ public List<report_global> GetReportGlobals(int hospitalId)
var
globals
=
reportglobalRepository
.
GetEntities
(
t
=>
t
.
HospitalID
==
hospitalId
);
return
globals
;
}
#
region
ImportFile
&&
SaveData
public
void
ImportAllotData
(
int
hospitalId
,
string
filePath
)
{
IWorkbook
workbook
=
null
;
try
{
workbook
=
ExcelHelper
.
GetWorkbook
(
filePath
);
if
(
workbook
==
null
)
throw
new
PerformanceException
(
"文件读取失败"
);
var
allots
=
perallotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
);
for
(
int
sheetIndex
=
0
;
sheetIndex
<
workbook
.
NumberOfSheets
;
sheetIndex
++)
{
var
sheet
=
workbook
.
GetSheetAt
(
sheetIndex
);
if
(
sheet
==
null
)
continue
;
string
sheetName
=
sheet
.
SheetName
.
NoBlank
();
var
columns
=
GetColumns
(
sheet
,
sheetName
,
out
string
sourceType
);
if
(
columns
==
null
||
!
columns
.
Any
(
t
=>
!
string
.
IsNullOrEmpty
(
t
.
NoBlank
())))
continue
;
var
data
=
new
List
<
his_importdata
>();
for
(
int
rowIndex
=
1
;
rowIndex
<
sheet
.
LastRowNum
+
1
;
rowIndex
++)
{
var
row
=
sheet
.
GetRow
(
rowIndex
);
if
(
row
==
null
)
continue
;
his_importdata
importdata
=
new
his_importdata
{
Year
=
GetCellValue
<
int
>(
row
,
columns
,
nameof
(
his_importdata
.
Year
)),
Month
=
GetCellValue
<
int
>(
row
,
columns
,
nameof
(
his_importdata
.
Month
)),
AccountingUnit
=
GetCellValue
<
string
>(
row
,
columns
,
nameof
(
his_importdata
.
AccountingUnit
)),
Department
=
GetCellValue
<
string
>(
row
,
columns
,
nameof
(
his_importdata
.
Department
)),
PersonnelNumber
=
GetCellValue
<
string
>(
row
,
columns
,
nameof
(
his_importdata
.
PersonnelNumber
)),
PersonnelName
=
GetCellValue
<
string
>(
row
,
columns
,
nameof
(
his_importdata
.
PersonnelName
)),
Original
=
GetCellValue
<
string
>(
row
,
columns
,
nameof
(
his_importdata
.
Original
)),
Value
=
GetCellValue
<
decimal
>(
row
,
columns
,
nameof
(
his_importdata
.
Value
)),
};
data
.
Add
(
importdata
);
}
if
(
data
==
null
||
!
data
.
Any
(
t
=>
t
.
Year
!=
0
&&
t
.
Month
!=
0
))
return
;
data
.
ForEach
(
t
=>
{
t
.
HospitalId
=
hospitalId
;
t
.
AllotId
=
allots
?.
FirstOrDefault
(
w
=>
w
.
Year
==
t
.
Year
&&
t
.
Month
==
w
.
Month
)?.
ID
;
t
.
SourceType
=
sourceType
;
t
.
Category
=
sheetName
;
});
var
years
=
data
.
Select
(
t
=>
t
.
Year
).
Distinct
();
var
months
=
data
.
Select
(
t
=>
t
.
Month
).
Distinct
();
var
historyData
=
hisimportdataRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
&&
years
.
Contains
(
t
.
Year
)
&&
months
.
Contains
(
t
.
Month
)
&&
t
.
Category
==
sheetName
);
if
(
historyData
!=
null
&&
historyData
.
Any
())
hisimportdataRepository
.
RemoveRange
(
historyData
.
ToArray
());
hisimportdataRepository
.
AddRange
(
data
.
Where
(
t
=>
t
.
Year
!=
0
&&
t
.
Month
!=
0
).
ToArray
());
}
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
ex
.
ToString
());
}
}
private
List
<
string
>
GetColumns
(
ISheet
sheet
,
string
sheetName
,
out
string
sourceType
)
{
sourceType
=
""
;
foreach
(
var
item
in
sourceTypes
)
{
if
(
item
.
Value
.
Contains
(
sheetName
))
{
sourceType
=
item
.
Key
;
break
;
}
}
if
(
string
.
IsNullOrEmpty
(
sourceType
))
return
new
List
<
string
>();
;
var
columnRow
=
sheet
.
GetOrCreate
(
0
);
return
columnRow
.
GetCellValues
();
}
private
T
GetCellValue
<
T
>(
IRow
row
,
List
<
string
>
columns
,
string
key
)
{
var
value
=
hisImportdataDict
[
key
];
if
(
columns
.
Contains
(
value
)
&&
row
.
GetCell
(
columns
.
IndexOf
(
value
))
!=
null
)
return
row
.
GetCell
(
columns
.
IndexOf
(
value
)).
GetCellValue
<
T
>();
return
default
;
}
private
readonly
Dictionary
<
string
,
string
[
]>
sourceTypes
=
new
Dictionary
<
string
,
string
[
]>
{
{
"收入"
,
new
string
[]
{
"门诊收入"
,
"住院收入"
}
},
{
"医生工作量"
,
new
string
[]
{
"门诊人次"
,
"出院人次"
,
"手术概况"
,
"住院天数"
,
"实际开放总床日数"
}
},
{
"医技工作量"
,
new
string
[]
{
"医技工作量"
}
},
};
private
readonly
Dictionary
<
string
,
string
>
hisImportdataDict
=
new
Dictionary
<
string
,
string
>
{
{
nameof
(
his_importdata
.
Year
),
"年份"
},
{
nameof
(
his_importdata
.
Month
),
"月份"
},
{
nameof
(
his_importdata
.
AccountingUnit
),
"核算单元"
},
{
nameof
(
his_importdata
.
Department
),
"科室"
},
{
nameof
(
his_importdata
.
PersonnelNumber
),
"工号"
},
{
nameof
(
his_importdata
.
PersonnelName
),
"医生姓名"
},
{
nameof
(
his_importdata
.
Original
),
"类别"
},
{
nameof
(
his_importdata
.
Value
),
"值"
},
};
#
endregion
ImportFile
&&
SaveData
}
}
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