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
3abb61e8
Commit
3abb61e8
authored
Mar 20, 2020
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
报表抽取
parent
ebbfab54
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
275 additions
and
35 deletions
+275
-35
performance/Performance.Api/wwwroot/Performance.EntityModels.xml
+48
-0
performance/Performance.EntityModels/Context/PerformanceDbContext.cs
+2
-0
performance/Performance.EntityModels/Entity/rep_importconfig.cs
+59
-0
performance/Performance.Repository/BaseRepository.cs
+1
-1
performance/Performance.Repository/PerforPerAllotRepository.cs
+58
-21
performance/Performance.Repository/Repository/PerforRepimportconfigRepository.cs
+20
-0
performance/Performance.Services/AllotService.cs
+1
-1
performance/Performance.Services/ExtractService.cs
+56
-3
performance/Performance.Services/ReportService.cs
+30
-9
No files found.
performance/Performance.Api/wwwroot/Performance.EntityModels.xml
View file @
3abb61e8
...
...
@@ -154,6 +154,9 @@
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.rep_selection"
>
<summary>
条件表
</summary>
</member>
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.rep_importconfig"
>
<summary>
导入报表SQL配置
</summary>
</member>
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.res_account"
>
<summary>
科室核算结果
</summary>
</member>
...
...
@@ -2545,6 +2548,51 @@
</summary>
</member>
<member
name=
"T:Performance.EntityModels.rep_importconfig"
>
<summary>
导入报表SQL配置
</summary>
</member>
<member
name=
"P:Performance.EntityModels.rep_importconfig.ID"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.rep_importconfig.TableName"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.rep_importconfig.ImportScript"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.rep_importconfig.DeleteScript"
>
<summary>
</summary>
</member>
<member
name=
"P:Performance.EntityModels.rep_importconfig.ConfigId"
>
<summary>
数据库地址,仅在HIS抽取时使用
</summary>
</member>
<member
name=
"P:Performance.EntityModels.rep_importconfig.ScriptType"
>
<summary>
脚本类型 1 HIS抽取 2 EXCEL抽取
</summary>
</member>
<member
name=
"P:Performance.EntityModels.rep_importconfig.TimeRange"
>
<summary>
时间范围 1 当前 2 同期 3 上期
</summary>
</member>
<member
name=
"P:Performance.EntityModels.rep_importconfig.IsEnable"
>
<summary>
是否有效 1 有效 0 无效
</summary>
</member>
<member
name=
"T:Performance.EntityModels.rep_report"
>
<summary>
报表配置表
...
...
performance/Performance.EntityModels/Context/PerformanceDbContext.cs
View file @
3abb61e8
...
...
@@ -112,6 +112,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public
virtual
DbSet
<
rep_group_selection
>
rep_group_selection
{
get
;
set
;
}
/// <summary> 条件表 </summary>
public
virtual
DbSet
<
rep_selection
>
rep_selection
{
get
;
set
;
}
/// <summary> 导入报表SQL配置 </summary>
public
virtual
DbSet
<
rep_importconfig
>
rep_importconfig
{
get
;
set
;
}
/// <summary> 科室核算结果 </summary>
public
virtual
DbSet
<
res_account
>
res_account
{
get
;
set
;
}
/// <summary> 医生科室核算结果 </summary>
...
...
performance/Performance.EntityModels/Entity/rep_importconfig.cs
0 → 100644
View file @
3abb61e8
//-----------------------------------------------------------------------
// <copyright file=" rep_importconfig.cs">
// * FileName: 导入报表SQL配置.cs
// </copyright>
//-----------------------------------------------------------------------
using
System
;
using
System.ComponentModel.DataAnnotations
;
using
System.ComponentModel.DataAnnotations.Schema
;
namespace
Performance.EntityModels
{
/// <summary>
/// 导入报表SQL配置
/// </summary>
[
Table
(
"rep_importconfig"
)]
public
class
rep_importconfig
{
/// <summary>
///
/// </summary>
[
Key
]
public
int
ID
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
TableName
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
ImportScript
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
DeleteScript
{
get
;
set
;
}
/// <summary>
/// 数据库地址,仅在HIS抽取时使用
/// </summary>
public
Nullable
<
int
>
ConfigId
{
get
;
set
;
}
/// <summary>
/// 脚本类型 1 HIS抽取 2 EXCEL抽取
/// </summary>
public
int
ScriptType
{
get
;
set
;
}
/// <summary>
/// 时间范围 1 当前 2 同期 3 上期
/// </summary>
public
int
TimeRange
{
get
;
set
;
}
/// <summary>
/// 是否有效 1 有效 0 无效
/// </summary>
public
int
IsEnable
{
get
;
set
;
}
}
}
performance/Performance.Repository/BaseRepository.cs
View file @
3abb61e8
...
...
@@ -12,7 +12,7 @@ namespace Performance.Repository
public
abstract
class
BaseRepository
<
TEntity
>
where
TEntity
:
class
,
new
()
{
pr
ivate
DbContext
context
;
pr
otected
DbContext
context
;
public
BaseRepository
(
DbContext
context
)
{
...
...
performance/Performance.Repository/PerforPerAllotRepository.cs
View file @
3abb61e8
...
...
@@ -4,8 +4,14 @@
// * history : Created by T4 2019-03-06 16:43:31
// </copyright>
//-----------------------------------------------------------------------
using
Dapper
;
using
Microsoft.EntityFrameworkCore
;
using
Performance.EntityModels
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Data.SqlClient
;
using
System.Linq
;
namespace
Performance.Repository
{
...
...
@@ -22,33 +28,64 @@ public bool UpdateAllotStates(int allotId, int states, string remark)
return
Update
(
allot
);
}
public
int
ImportData
(
int
allotId
)
/// <summary>
/// 只支持EXCEL抽取报表数据
/// </summary>
/// <param name="import"></param>
/// <param name="pairs"></param>
/// <returns></returns>
public
bool
ImportData
(
rep_importconfig
import
,
Dictionary
<
string
,
object
>
pairs
)
{
string
sql
=
@"
delete from report_allot_summary where allotid=@allotId;
insert into report_allot_summary(allotid,year,month,hospitalid,realgivefee)
select allotid,year,month,hospitalid,realgivefee from view_report_allot_summary where allotid=@allotId;
delete from report_original_income where allotid=@allotId;
insert into report_original_income(allotid,year,month,hospitalid,sourcetype,department,typename,cellvalue)
select distinct allotid,year,month,hospitalid,sourcetype,department,typename,cellvalue from view_report_original_income where allotid=@allotId;"
;
return
Execute
(
sql
,
new
{
allotId
});
using
(
var
connection
=
context
.
Database
.
GetDbConnection
())
{
var
data
=
connection
.
Query
(
import
.
ImportScript
,
new
DynamicParameters
(
pairs
),
commandTimeout
:
60
*
60
);
ImportData
(
import
,
pairs
,
data
);
}
return
true
;
}
/// <summary>
///
///
指定数据源插入MYSQL
/// </summary>
/// <param name="allotId"></param>
/// <param name="import"></param>
/// <param name="pairs"></param>
/// <param name="data"></param>
/// <returns></returns>
public
int
SupplyData
(
int
allotId
)
{
string
sql
=
@"
insert into cof_drugtype(charge,allotid) select distinct id.typename charge,
@allotId allotid from im_data id
inner join per_sheet ps on id.sheetid = ps.id
where id.allotid = @allotId and ps.sheettype = 3 and ifnull(id.typename, '') != ''
and id.typename not in (select charge from cof_drugtype where allotid = @allotId);"
;
return
Execute
(
sql
,
new
{
allotId
});
public
bool
ImportData
(
rep_importconfig
import
,
Dictionary
<
string
,
object
>
pairs
,
IEnumerable
<
dynamic
>
data
)
{
if
(
data
!=
null
&&
data
.
Any
())
{
using
(
var
connection
=
context
.
Database
.
GetDbConnection
())
{
if
(
connection
.
State
!=
ConnectionState
.
Open
)
connection
.
Open
();
using
(
var
transaction
=
connection
.
BeginTransaction
())
{
try
{
connection
.
Execute
(
import
.
DeleteScript
,
new
DynamicParameters
(
pairs
),
commandTimeout
:
60
*
60
,
transaction
:
transaction
);
List
<
string
>
columns
=
new
List
<
string
>();
foreach
(
KeyValuePair
<
string
,
object
>
col
in
data
.
First
())
{
columns
.
Add
(
col
.
Key
);
}
var
c1
=
string
.
Join
(
","
,
columns
.
Select
(
w
=>
$"`
{
w
}
`"
));
var
c2
=
string
.
Join
(
","
,
columns
.
Select
(
w
=>
$"@
{
w
}
"
));
string
insert
=
$"insert into
{
import
.
TableName
}
(
{
c1
}
) values(
{
c2
}
)"
;
connection
.
Execute
(
insert
,
data
,
commandTimeout
:
60
*
60
,
transaction
:
transaction
);
transaction
.
Commit
();
}
catch
(
Exception
ex
)
{
transaction
.
Rollback
();
throw
ex
;
}
}
}
}
return
true
;
}
}
}
performance/Performance.Repository/Repository/PerforRepimportconfigRepository.cs
0 → 100644
View file @
3abb61e8
//-----------------------------------------------------------------------
// <copyright file=" rep_importconfig.cs">
// * FileName: rep_importconfig.cs
// </copyright>
//-----------------------------------------------------------------------
using
System
;
using
Performance.EntityModels
;
namespace
Performance.Repository
{
/// <summary>
/// rep_importconfig Repository
/// </summary>
public
partial
class
PerforRepimportconfigRepository
:
PerforRepository
<
rep_importconfig
>
{
public
PerforRepimportconfigRepository
(
PerformanceDbContext
context
)
:
base
(
context
)
{
}
}
}
performance/Performance.Services/AllotService.cs
View file @
3abb61e8
...
...
@@ -305,7 +305,7 @@ public void Generate(per_allot allot, string mail)
UpdateAllotStates
(
allot
.
ID
,
(
int
)
AllotStates
.
GenerateSucceed
,
EnumHelper
.
GetDescription
(
AllotStates
.
GenerateSucceed
));
logManageService
.
WriteMsg
(
"正在生成报表数据"
,
"正在生成报表数据"
,
1
,
allot
.
ID
,
"ReceiveMessage"
,
true
);
var
res
=
reportService
.
ImportData
(
allot
.
ID
);
var
res
=
reportService
.
ImportData
(
allot
);
logManageService
.
WriteMsg
(
"正在生成报表数据"
,
$"报表数据生成完成;受影响:
{
res
}
行"
,
1
,
allot
.
ID
,
"ReceiveMessage"
,
true
);
//发送邮件
...
...
performance/Performance.Services/ExtractService.cs
View file @
3abb61e8
using
Microsoft.AspNetCore.Hosting
;
using
Dapper
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
NPOI.HSSF.UserModel
;
...
...
@@ -12,6 +13,7 @@
using
Performance.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -37,6 +39,7 @@ public class ExtractService : IAutoInjection
private
readonly
PerforExtractRepository
perforExtractRepository
;
private
readonly
PerforPerfirstRepository
perforPerfirstRepository
;
private
readonly
PerforPerallotRepository
perforPerallotRepository
;
private
readonly
PerforRepimportconfigRepository
repimportconfigRepository
;
private
readonly
PerforHospitalconfigRepository
perforHospitalconfigRepository
;
public
ExtractService
(
ILogger
<
ExtractService
>
logger
,
...
...
@@ -52,6 +55,7 @@ public class ExtractService : IAutoInjection
PerforExtractRepository
perforExtractRepository
,
PerforPerfirstRepository
perforPerfirstRepository
,
PerforPerallotRepository
perforPerallotRepository
,
PerforRepimportconfigRepository
repimportconfigRepository
,
PerforHospitalconfigRepository
perforHospitalconfigRepository
)
{
this
.
logger
=
logger
;
...
...
@@ -67,6 +71,7 @@ public class ExtractService : IAutoInjection
this
.
perforExtractRepository
=
perforExtractRepository
;
this
.
perforPerfirstRepository
=
perforPerfirstRepository
;
this
.
perforPerallotRepository
=
perforPerallotRepository
;
this
.
repimportconfigRepository
=
repimportconfigRepository
;
this
.
perforHospitalconfigRepository
=
perforHospitalconfigRepository
;
}
...
...
@@ -160,11 +165,11 @@ public string ExtractData(int allotId, string mail, sys_hospital hospital, strin
if
(
WriteExcel
(
path
,
originalPath
,
sheetList
,
hospitalConfig
,
hospital
.
ID
,
allotList
.
First
(
t
=>
t
.
ID
==
allotId
),
out
filepath
))
{
logger
.
LogInformation
(
$"提取绩效数据 基础数据提取完成,文件保存成功
{
filepath
}
"
,
""
);
//
var allot = allotList.First(t => t.ID == allotId);
var
allot
=
allotList
.
First
(
t
=>
t
.
ID
==
allotId
);
//allot.ExtractPath = filepath;
//if (!string.IsNullOrEmpty(filepath))
// perforPerallotRepository.Update(allot);
ImportData
(
allot
,
configList
);
SendEmail
(
mail
,
filepath
,
$"
{
hospital
.
HosName
}
HIS数据提取成功"
,
$"
{
hospital
.
HosName
}
在
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
成功提取。"
);
}
}
...
...
@@ -191,6 +196,54 @@ public string ExtractData(int allotId, string mail, sys_hospital hospital, strin
}
/// <summary>
/// 从HIS抽取报表数据
/// </summary>
/// <param name="allot"></param>
/// <param name="configs"></param>
public
void
ImportData
(
per_allot
allot
,
List
<
sys_hospitalconfig
>
configs
)
{
Dictionary
<
string
,
object
>
pairs
=
new
Dictionary
<
string
,
object
>
{
{
"@allotid"
,
allot
.
ID
},
{
"@hospitalid"
,
allot
.
HospitalId
},
};
var
imports
=
repimportconfigRepository
.
GetEntities
(
w
=>
w
.
ScriptType
==
1
);
foreach
(
var
import
in
imports
)
{
var
conf
=
configs
.
FirstOrDefault
(
w
=>
w
.
HospitalId
==
allot
.
HospitalId
&&
w
.
Id
==
import
.
ConfigId
);
if
(
conf
!=
null
)
{
if
(
import
.
TimeRange
==
1
)
{
pairs
.
Add
(
"@year"
,
allot
.
Year
);
pairs
.
Add
(
"@month"
,
allot
.
Month
);
}
else
if
(
import
.
TimeRange
==
2
)
{
pairs
.
Add
(
"@year"
,
allot
.
Year
-
1
);
pairs
.
Add
(
"@month"
,
allot
.
Month
);
}
else
if
(
import
.
TimeRange
==
3
)
{
pairs
.
Add
(
"@year"
,
allot
.
Year
);
pairs
.
Add
(
"@month"
,
allot
.
Month
-
1
);
}
try
{
DatabaseType
type
=
(
DatabaseType
)
conf
.
DataBaseType
;
var
connection
=
ConnectionBuilder
.
Create
(
type
,
conf
.
DbSource
,
conf
.
DbName
,
conf
.
DbUser
,
conf
.
DbPassword
);
var
data
=
connection
.
Query
(
import
.
ImportScript
,
new
DynamicParameters
(
pairs
),
commandTimeout
:
60
*
60
);
perforPerallotRepository
.
ImportData
(
import
,
pairs
,
data
);
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
ex
.
ToString
());
}
}
}
}
/// <summary>
/// 发送邮件
/// </summary>
/// <param name="path"></param>
...
...
performance/Performance.Services/ReportService.cs
View file @
3abb61e8
using
Performance.DtoModels
;
using
Microsoft.Extensions.Logging
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Repository
;
using
System
;
...
...
@@ -11,26 +12,30 @@ namespace Performance.Services
{
public
class
ReportService
:
IAutoInjection
{
private
readonly
ILogger
<
ReportService
>
logger
;
private
PerforReportRepository
perforReportRepository
;
private
PerforPerallotRepository
perforPerallotRepository
;
private
PerforResbaiscnormRepository
perforResbaiscnormRepository
;
private
PerforHospersonfeeRepository
perforHospersonfeeRepository
;
private
PerforResaccountRepository
perforResaccountRepository
;
//private PerforResaccountnurseRepository perforResaccountnurse
Repository;
private
PerforRepimportconfigRepository
repimportconfig
Repository
;
public
ReportService
(
PerforReportRepository
perforReportRepository
,
public
ReportService
(
ILogger
<
ReportService
>
logger
,
PerforReportRepository
perforReportRepository
,
PerforPerallotRepository
perforPerallotRepository
,
PerforResbaiscnormRepository
perforResbaiscnormRepository
,
PerforHospersonfeeRepository
perforHospersonfeeRepository
,
//PerforResaccountdoctorRepository perforResaccountdoctor
Repository,
PerforRepimportconfigRepository
repimportconfig
Repository
,
PerforResaccountRepository
perforResaccountRepository
)
{
this
.
logger
=
logger
;
this
.
perforReportRepository
=
perforReportRepository
;
this
.
perforPerallotRepository
=
perforPerallotRepository
;
this
.
perforResbaiscnormRepository
=
perforResbaiscnormRepository
;
this
.
perforHospersonfeeRepository
=
perforHospersonfeeRepository
;
this
.
perforResaccountRepository
=
perforResaccountRepository
;
//this.perforResaccountnurseRepository = perforResaccountnurse
Repository;
this
.
repimportconfigRepository
=
repimportconfig
Repository
;
}
/// <summary>
...
...
@@ -224,14 +229,30 @@ public List<PerReport> Income(int hospitalId, int isIndex)
return
perforReportRepository
.
Income
(
hospitalId
,
date
);
}
internal
int
ImportData
(
int
allotId
)
/// <summary>
/// 只支持EXCEL抽取报表数据
/// </summary>
/// <param name="allot"></param>
/// <returns></returns>
internal
int
ImportData
(
per_allot
allot
)
{
Dictionary
<
string
,
object
>
pairs
=
new
Dictionary
<
string
,
object
>
{
{
"@allotid"
,
allot
.
ID
},
{
"@hospitalid"
,
allot
.
HospitalId
},
};
var
imports
=
repimportconfigRepository
.
GetEntities
(
w
=>
w
.
ScriptType
==
2
);
foreach
(
var
item
in
imports
)
{
try
{
var
flag
=
perforPerallotRepository
.
SupplyData
(
allotId
);
return
perforPerallotRepository
.
ImportData
(
allotId
);
var
flag
=
perforPerallotRepository
.
ImportData
(
item
,
pairs
);
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
ex
.
ToString
());
}
}
catch
{
}
return
0
;
}
...
...
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