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
791e75c6
Commit
791e75c6
authored
Feb 09, 2022
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口内容调整
parent
c9a93855
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
236 additions
and
145 deletions
+236
-145
performance/Performance.Api/Controllers/EmployeeController.cs.rej
+0
-9
performance/Performance.Api/Controllers/ExtractController.cs
+106
-74
performance/Performance.DtoModels/AutoMapper/AutoMapperConfigs.cs
+1
-1
performance/Performance.DtoModels/Response/ExtractConfigResponse.cs
+8
-11
performance/Performance.DtoModels/Response/HospitalConfigResponse.cs
+21
-0
performance/Performance.Services/ExtractExcelService/ExtractPreConfigService.cs
+100
-50
No files found.
performance/Performance.Api/Controllers/EmployeeController.cs.rej
deleted
100644 → 0
View file @
c9a93855
diff a/performance/Performance.Api/Controllers/EmployeeController.cs b/performance/Performance.Api/Controllers/EmployeeController.cs (rejected hunks)
@@ -824,6 +824,7 @@
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
+ var result = employeeService.GetGatherTotal(allotId, request);
return new ApiResponse(ResponseType.OK, result);
}
performance/Performance.Api/Controllers/ExtractController.cs
View file @
791e75c6
...
@@ -48,82 +48,82 @@ ExtractPreConfigService preConfigService
...
@@ -48,82 +48,82 @@ ExtractPreConfigService preConfigService
#
region
自定义提取
#
region
自定义提取
/// <summary>
///
//
<summary>
/// 自定义提取
///
//
自定义提取
/// </summary>
///
//
</summary>
/// <param name="allotId"></param>
///
//
<param name="allotId"></param>
/// <returns></returns>
///
//
<returns></returns>
[
HttpPost
(
"custom/{allotId}"
)]
//
[HttpPost("custom/{allotId}")]
public
ApiResponse
CustomExtract
(
int
allotId
)
//
public ApiResponse CustomExtract(int allotId)
{
//
{
var
userId
=
_claim
.
GetUserId
();
//
var userId = _claim.GetUserId();
if
(!
_extractService
.
CheckConfigScript
(
userId
,
allotId
))
//
if (!_extractService.CheckConfigScript(userId, allotId))
return
new
ApiResponse
(
ResponseType
.
Fail
,
"未配置自定义抽取,请联系绩效管理人员。"
);
//
return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。");
_backgroundTaskQueue
.
QueueBackgroundWorkItem
(
async
token
=>
//
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
{
//
{
using
(
var
scope
=
_serviceScopeFactory
.
CreateScope
())
//
using (var scope = _serviceScopeFactory.CreateScope())
{
//
{
var
scopedServices
=
scope
.
ServiceProvider
.
GetRequiredService
<
CustomExtractService
>();
//
var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>();
var
scopedAllotService
=
scope
.
ServiceProvider
.
GetRequiredService
<
AllotService
>();
//
var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>();
var
scopedQueue
=
scope
.
ServiceProvider
.
GetRequiredService
<
IHubNotificationQueue
>();
//
var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>();
if
(
scopedServices
.
ExtractData
(
userId
,
allotId
,
out
string
resultFilePath
))
//
if (scopedServices.ExtractData(userId, allotId, out string resultFilePath))
{
//
{
scopedAllotService
.
UpdateAllotCustomExtractPath
(
allotId
,
resultFilePath
);
//
scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath);
scopedQueue
.
Send
(
new
Notification
(
allotId
,
"CustomDowoload"
,
new
CustomDownloadContent
(
"自定义数据提取数据成功,是否立即下载"
,
allotId
)));
//
scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId)));
}
//
}
else
//
else
{
//
{
scopedQueue
.
Send
(
new
Notification
(
allotId
,
"Notification"
,
new
TextContent
(
"自定义数据提取数据失败"
,
NotificationLevel
.
ERR
)));
//
scopedQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
}
//
}
await
Task
.
Delay
(
TimeSpan
.
FromSeconds
(
5
),
token
);
//
await Task.Delay(TimeSpan.FromSeconds(5), token);
}
//
}
});
//
});
_notificationQueue
.
Send
(
new
Notification
(
allotId
,
"Notification"
,
new
TextContent
(
"自定义数据提取任务开始执行"
)));
//
_notificationQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取任务开始执行")));
return
new
ApiResponse
(
ResponseType
.
OK
);
//
return new ApiResponse(ResponseType.OK);
}
//
}
/// <summary>
///
//
<summary>
/// 从WebAPI下载文件
///
//
从WebAPI下载文件
/// </summary>
///
//
</summary>
/// <returns></returns>
///
//
<returns></returns>
[
Route
(
"down/{allotId}"
)]
//
[Route("down/{allotId}")]
[
HttpGet
]
//
[HttpGet]
[
AllowAnonymous
]
//
[AllowAnonymous]
public
IActionResult
DownFile
(
int
allotId
)
//
public IActionResult DownFile(int allotId)
{
//
{
var
allot
=
_allotService
.
GetAllot
(
allotId
);
//
var allot = _allotService.GetAllot(allotId);
if
(
allot
==
null
||
string
.
IsNullOrWhiteSpace
(
allot
.
CustomExtractPath
)
||
!
FileHelper
.
IsExistFile
(
allot
.
CustomExtractPath
))
//
if (allot == null || string.IsNullOrWhiteSpace(allot.CustomExtractPath) || !FileHelper.IsExistFile(allot.CustomExtractPath))
{
//
{
return
new
ObjectResult
(
new
ApiResponse
(
ResponseType
.
Fail
,
"文件不存在"
));
//
return new ObjectResult(new ApiResponse(ResponseType.Fail, "文件不存在"));
}
//
}
var
memoryStream
=
new
MemoryStream
();
//
var memoryStream = new MemoryStream();
using
(
var
stream
=
new
FileStream
(
allot
.
CustomExtractPath
,
FileMode
.
Open
))
//
using (var stream = new FileStream(allot.CustomExtractPath, FileMode.Open))
{
//
{
stream
.
CopyToAsync
(
memoryStream
).
Wait
();
//
stream.CopyToAsync(memoryStream).Wait();
}
//
}
memoryStream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
//
memoryStream.Seek(0, SeekOrigin.Begin);
string
fileExt
=
Path
.
GetExtension
(
allot
.
CustomExtractPath
);
//
string fileExt = Path.GetExtension(allot.CustomExtractPath);
var
provider
=
new
FileExtensionContentTypeProvider
();
//
var provider = new FileExtensionContentTypeProvider();
var
memi
=
provider
.
Mappings
[
fileExt
];
//
var memi = provider.Mappings[fileExt];
return
File
(
memoryStream
,
memi
,
Path
.
GetFileName
(
allot
.
CustomExtractPath
));
//
return File(memoryStream, memi, Path.GetFileName(allot.CustomExtractPath));
}
//
}
#
endregion
#
endregion
#
region
医院数据库配置
#
region
医院数据库配置
[
HttpGet
(
"hospital/config/{hospitalId}"
)]
[
HttpGet
(
"hospital/config/{hospitalId}"
)]
public
ApiResponse
<
List
<
sys_hospitalconfig
>>
GetHospitalConfig
([
FromRoute
]
int
hospitalId
)
public
ApiResponse
<
List
<
HospitalConfigResponse
>>
GetHospitalConfig
([
FromRoute
]
int
hospitalId
)
{
{
if
(
hospitalId
==
0
)
return
new
ApiResponse
<
List
<
sys_hospitalconfig
>>(
ResponseType
.
ParameterError
,
"参数错误"
);
if
(
hospitalId
==
0
)
return
new
ApiResponse
<
List
<
HospitalConfigResponse
>>(
ResponseType
.
ParameterError
,
"参数错误"
);
var
list
=
_preConfigService
.
GetHospitalConfig
(
hospitalId
);
var
list
=
_preConfigService
.
GetHospitalConfig
(
hospitalId
);
return
new
ApiResponse
<
List
<
sys_hospitalconfig
>>(
ResponseType
.
OK
,
list
);
return
new
ApiResponse
<
List
<
HospitalConfigResponse
>>(
ResponseType
.
OK
,
list
);
}
}
[
HttpPost
(
"hospital/config/create"
)]
[
HttpPost
(
"hospital/config/create"
)]
...
@@ -178,19 +178,19 @@ public ApiResponse GetExtractTypeAndScript([FromBody] ExTypeRequest request)
...
@@ -178,19 +178,19 @@ public ApiResponse GetExtractTypeAndScript([FromBody] ExTypeRequest request)
return
new
ApiResponse
(
ResponseType
.
OK
,
list
);
return
new
ApiResponse
(
ResponseType
.
OK
,
list
);
}
}
[
HttpGet
(
"type/{typeId}"
)]
[
HttpGet
(
"type/{typeId}
/{scriptId}
"
)]
public
ApiResponse
GetExtractTypeAndScriptById
([
FromRoute
]
int
typeId
)
public
ApiResponse
GetExtractTypeAndScriptById
([
FromRoute
]
int
typeId
,
int
scriptId
)
{
{
if
(
typeId
==
0
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"参数错误"
);
if
(
typeId
==
0
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"参数错误"
);
var
data
=
_preConfigService
.
GetExtractTypeAndScriptById
(
typeId
);
var
data
=
_preConfigService
.
GetExtractTypeAndScriptById
(
typeId
,
scriptId
);
return
new
ApiResponse
(
ResponseType
.
OK
,
data
);
return
new
ApiResponse
(
ResponseType
.
OK
,
data
);
}
}
[
HttpPost
(
"type/{typeId}"
)]
[
HttpPost
(
"type/{typeId}
/{scriptId}
"
)]
public
ApiResponse
DeleteExtractTypeAndScript
([
FromRoute
]
int
typeId
)
public
ApiResponse
DeleteExtractTypeAndScript
([
FromRoute
]
int
typeId
,
int
scriptId
)
{
{
if
(
typeId
==
0
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"参数错误"
);
if
(
typeId
==
0
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"参数错误"
);
var
flag
=
_preConfigService
.
DeleteExtractTypeAndScript
(
typeId
);
var
flag
=
_preConfigService
.
DeleteExtractTypeAndScript
(
typeId
,
scriptId
);
return
flag
return
flag
?
new
ApiResponse
(
ResponseType
.
OK
,
"删除成功"
)
?
new
ApiResponse
(
ResponseType
.
OK
,
"删除成功"
)
:
new
ApiResponse
(
ResponseType
.
Fail
,
"删除失败"
);
:
new
ApiResponse
(
ResponseType
.
Fail
,
"删除失败"
);
...
@@ -215,5 +215,37 @@ public ApiResponse CheckExecsqlConsumeTime([FromBody] ConsumeTimeRequest request
...
@@ -215,5 +215,37 @@ public ApiResponse CheckExecsqlConsumeTime([FromBody] ConsumeTimeRequest request
}
}
#
endregion
#
endregion
#
region
字典
[
HttpGet
(
"database"
)]
public
ApiResponse
<
List
<
TitleValue
<
int
>>>
GetDatatypes
()
{
var
list
=
_preConfigService
.
GetDatatypes
();
return
new
ApiResponse
<
List
<
TitleValue
<
int
>>>(
ResponseType
.
OK
,
list
);
}
[
HttpGet
(
"sheettype"
)]
public
ApiResponse
<
List
<
TitleValue
<
int
>>>
GetSheettypes
()
{
var
list
=
_preConfigService
.
GetSheettypes
();
return
new
ApiResponse
<
List
<
TitleValue
<
int
>>>(
ResponseType
.
OK
,
list
);
}
[
HttpGet
(
"type/{hospitalId}"
)]
public
ApiResponse
<
List
<
TitleValue
<
int
>>>
GetExTypes
([
FromRoute
]
int
hospitalId
)
{
var
list
=
_preConfigService
.
GetExTypes
(
hospitalId
);
return
new
ApiResponse
<
List
<
TitleValue
<
int
>>>(
ResponseType
.
OK
,
list
);
}
[
HttpGet
(
"config/{hospitalId}"
)]
public
ApiResponse
<
List
<
TitleValue
<
int
>>>
GetConfigs
([
FromRoute
]
int
hospitalId
)
{
var
list
=
_preConfigService
.
GetConfigs
(
hospitalId
);
return
new
ApiResponse
<
List
<
TitleValue
<
int
>>>(
ResponseType
.
OK
,
list
);
}
#
endregion
}
}
}
}
performance/Performance.DtoModels/AutoMapper/AutoMapperConfigs.cs
View file @
791e75c6
...
@@ -257,7 +257,7 @@ public AutoMapperConfigs()
...
@@ -257,7 +257,7 @@ public AutoMapperConfigs()
.
ForMember
(
dest
=>
dest
.
TypeId
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Id
))
.
ForMember
(
dest
=>
dest
.
TypeId
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Id
))
.
ReverseMap
();
.
ReverseMap
();
CreateMap
<
ex_script
,
Extract
ScriptConfig
>()
CreateMap
<
ex_script
,
Extract
ConfigResponse
>()
.
ForMember
(
dest
=>
dest
.
ExScriptId
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Id
))
.
ForMember
(
dest
=>
dest
.
ExScriptId
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Id
))
.
ReverseMap
();
.
ReverseMap
();
}
}
...
...
performance/Performance.DtoModels/Response/ExtractConfigResponse.cs
View file @
791e75c6
...
@@ -8,19 +8,16 @@ public class ExtractConfigResponse
...
@@ -8,19 +8,16 @@ public class ExtractConfigResponse
public
string
EName
{
get
;
set
;
}
public
string
EName
{
get
;
set
;
}
public
string
Description
{
get
;
set
;
}
public
int
Source
{
get
;
set
;
}
public
int
Source
{
get
;
set
;
}
public
string
SheetType
{
get
;
set
;
}
public
string
SheetType
{
get
;
set
;
}
public
decimal
TotalTime
{
get
;
set
;
}
public
string
Description
{
get
;
set
;
}
public
List
<
ExtractScriptConfig
>
Children
{
get
;
set
;
}
=
new
List
<
ExtractScriptConfig
>();
public
decimal
TimeConsuming
{
get
;
set
;
}
}
#
region
Children
public
class
ExtractScriptConfig
{
public
int
ExScriptId
{
get
;
set
;
}
public
int
ExScriptId
{
get
;
set
;
}
public
string
ExecScript
{
get
;
set
;
}
public
string
ExecScript
{
get
;
set
;
}
...
@@ -29,12 +26,12 @@ public class ExtractScriptConfig
...
@@ -29,12 +26,12 @@ public class ExtractScriptConfig
public
string
ConfigName
{
get
;
set
;
}
public
string
ConfigName
{
get
;
set
;
}
public
int
IsEnable
{
get
;
set
;
}
public
int
IsExecSuccess
{
get
;
set
;
}
public
int
IsExecSuccess
{
get
;
set
;
}
public
string
ErrorMessag
e
{
get
;
set
;
}
public
int
IsEnabl
e
{
get
;
set
;
}
public
decimal
TimeConsuming
{
get
;
set
;
}
#
endregion
public
List
<
ExtractConfigResponse
>
Children
{
get
;
set
;
}
=
new
List
<
ExtractConfigResponse
>();
}
}
}
}
performance/Performance.DtoModels/Response/HospitalConfigResponse.cs
0 → 100644
View file @
791e75c6
namespace
Performance.DtoModels
{
public
class
HospitalConfigResponse
{
public
int
Id
{
get
;
set
;
}
public
string
ConfigName
{
get
;
set
;
}
public
string
DbSource
{
get
;
set
;
}
public
string
DbName
{
get
;
set
;
}
public
string
DbUser
{
get
;
set
;
}
public
string
DbPassword
{
get
;
set
;
}
public
string
DataBaseType
{
get
;
set
;
}
public
string
IsConnectioned
{
get
;
set
;
}
}
}
performance/Performance.Services/ExtractExcelService/ExtractPreConfigService.cs
View file @
791e75c6
...
@@ -52,13 +52,24 @@ public class ExtractPreConfigService : IAutoInjection
...
@@ -52,13 +52,24 @@ public class ExtractPreConfigService : IAutoInjection
#
region
HospitalConfig
#
region
HospitalConfig
public
List
<
sys_hospitalconfig
>
GetHospitalConfig
(
int
hospitalId
)
public
List
<
HospitalConfigResponse
>
GetHospitalConfig
(
int
hospitalId
)
{
{
var
hospital
=
hospitalRepository
.
GetEntity
(
w
=>
w
.
ID
==
hospitalId
);
var
hospital
=
hospitalRepository
.
GetEntity
(
w
=>
w
.
ID
==
hospitalId
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院信息错误"
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院信息错误"
);
var
data
=
hospitalconfigRepository
.
GetEntities
(
w
=>
w
.
HospitalId
==
hospitalId
);
var
data
=
hospitalconfigRepository
.
GetEntities
(
w
=>
w
.
HospitalId
==
hospitalId
);
return
data
;
var
dic
=
GetDatatypes
();
return
data
?.
Select
(
t
=>
new
HospitalConfigResponse
{
Id
=
t
.
Id
,
ConfigName
=
t
.
ConfigName
,
DbSource
=
t
.
DbSource
,
DbName
=
t
.
DbName
,
DbUser
=
t
.
DbUser
,
DbPassword
=
t
.
DbPassword
,
DataBaseType
=
dic
.
FirstOrDefault
(
w
=>
w
.
Value
==
t
.
DataBaseType
)?.
Title
,
IsConnectioned
=
t
.
IsConnectioned
?
"成功"
:
"失败"
}).
ToList
();
}
}
public
bool
CreateHospitalConfig
(
sys_hospitalconfig
hospitalconfig
)
public
bool
CreateHospitalConfig
(
sys_hospitalconfig
hospitalconfig
)
...
@@ -76,6 +87,9 @@ public bool CreateHospitalConfig(sys_hospitalconfig hospitalconfig)
...
@@ -76,6 +87,9 @@ public bool CreateHospitalConfig(sys_hospitalconfig hospitalconfig)
var
hospital
=
hospitalRepository
.
GetEntity
(
w
=>
w
.
ID
==
hospitalconfig
.
HospitalId
);
var
hospital
=
hospitalRepository
.
GetEntity
(
w
=>
w
.
ID
==
hospitalconfig
.
HospitalId
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院信息错误"
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院信息错误"
);
var
config
=
hospitalconfigRepository
.
GetEntity
(
w
=>
w
.
ConfigName
==
hospitalconfig
.
ConfigName
);
if
(
config
==
null
)
throw
new
PerformanceException
(
"连接名称重复"
);
return
hospitalconfigRepository
.
Add
(
hospitalconfig
);
return
hospitalconfigRepository
.
Add
(
hospitalconfig
);
}
}
...
@@ -89,6 +103,9 @@ public bool UpdateHospitalConfig(sys_hospitalconfig hospitalconfig)
...
@@ -89,6 +103,9 @@ public bool UpdateHospitalConfig(sys_hospitalconfig hospitalconfig)
if
(!
databases
.
Select
(
t
=>
t
.
Value
).
Contains
(
hospitalconfig
.
DataBaseType
))
if
(!
databases
.
Select
(
t
=>
t
.
Value
).
Contains
(
hospitalconfig
.
DataBaseType
))
throw
new
PerformanceException
(
"数据库类型错误"
);
throw
new
PerformanceException
(
"数据库类型错误"
);
var
config
=
hospitalconfigRepository
.
GetEntity
(
w
=>
w
.
ConfigName
==
hospitalconfig
.
ConfigName
);
if
(
config
==
null
)
throw
new
PerformanceException
(
"连接名称重复"
);
var
entity
=
hospitalconfigRepository
.
GetEntity
(
w
=>
w
.
Id
==
hospitalconfig
.
Id
);
var
entity
=
hospitalconfigRepository
.
GetEntity
(
w
=>
w
.
Id
==
hospitalconfig
.
Id
);
if
(
entity
==
null
)
throw
new
PerformanceException
(
"医院配置信息为空"
);
if
(
entity
==
null
)
throw
new
PerformanceException
(
"医院配置信息为空"
);
...
@@ -162,8 +179,8 @@ public PageList<ExtractConfigResponse> GetExtractTypeAndScript(ExTypeRequest req
...
@@ -162,8 +179,8 @@ public PageList<ExtractConfigResponse> GetExtractTypeAndScript(ExTypeRequest req
var
itemScripts
=
scripts
.
Where
(
w
=>
w
.
TypeId
==
item
.
TypeId
);
var
itemScripts
=
scripts
.
Where
(
w
=>
w
.
TypeId
==
item
.
TypeId
);
if
(
itemScripts
==
null
||
!
itemScripts
.
Any
())
continue
;
if
(
itemScripts
==
null
||
!
itemScripts
.
Any
())
continue
;
item
.
T
otalTime
=
itemScripts
.
Sum
(
t
=>
t
.
TimeConsuming
);
item
.
T
imeConsuming
=
itemScripts
.
Sum
(
t
=>
t
.
TimeConsuming
);
item
.
Children
=
mapper
.
Map
<
List
<
Extract
ScriptConfig
>>(
itemScripts
);
item
.
Children
=
mapper
.
Map
<
List
<
Extract
ConfigResponse
>>(
itemScripts
);
item
.
Children
.
ForEach
(
x
=>
item
.
Children
.
ForEach
(
x
=>
{
{
...
@@ -176,7 +193,7 @@ public PageList<ExtractConfigResponse> GetExtractTypeAndScript(ExTypeRequest req
...
@@ -176,7 +193,7 @@ public PageList<ExtractConfigResponse> GetExtractTypeAndScript(ExTypeRequest req
return
new
PageList
<
ExtractConfigResponse
>(
list
,
data
.
TotalCount
,
request
.
PageNumber
,
request
.
PageSize
);
return
new
PageList
<
ExtractConfigResponse
>(
list
,
data
.
TotalCount
,
request
.
PageNumber
,
request
.
PageSize
);
}
}
public
ExtractConfigResponse
GetExtractTypeAndScriptById
(
int
typeId
)
public
ExtractConfigResponse
GetExtractTypeAndScriptById
(
int
typeId
,
int
scriptId
)
{
{
var
type
=
extypeRepository
.
GetEntity
(
w
=>
w
.
Id
==
typeId
);
var
type
=
extypeRepository
.
GetEntity
(
w
=>
w
.
Id
==
typeId
);
if
(
type
==
null
)
throw
new
PerformanceException
(
"参数无效"
);
if
(
type
==
null
)
throw
new
PerformanceException
(
"参数无效"
);
...
@@ -186,26 +203,31 @@ public ExtractConfigResponse GetExtractTypeAndScriptById(int typeId)
...
@@ -186,26 +203,31 @@ public ExtractConfigResponse GetExtractTypeAndScriptById(int typeId)
var
sheettypes
=
GetSheettypes
();
var
sheettypes
=
GetSheettypes
();
data
.
SheetType
=
sheettypes
.
FirstOrDefault
(
w
=>
w
.
Value
==
data
.
Source
)?.
Title
;
data
.
SheetType
=
sheettypes
.
FirstOrDefault
(
w
=>
w
.
Value
==
data
.
Source
)?.
Title
;
var
scripts
=
exscriptRepository
.
GetEntities
(
w
=>
w
.
TypeId
==
typeId
)
??
new
List
<
ex_script
>();
var
script
=
exscriptRepository
.
GetEntity
(
w
=>
w
.
TypeId
==
typeId
&&
w
.
Id
==
scriptId
)
??
new
ex_script
();
if
(
scripts
!=
null
&&
scripts
.
Any
())
if
(
script
!=
null
)
{
var
configs
=
hospitalconfigRepository
.
GetEntities
(
w
=>
scripts
.
Select
(
s
=>
s
.
ConfigId
).
Contains
(
w
.
Id
))
??
new
List
<
sys_hospitalconfig
>();
data
.
TotalTime
=
scripts
.
Sum
(
t
=>
t
.
TimeConsuming
);
data
.
Children
=
mapper
.
Map
<
List
<
ExtractScriptConfig
>>(
scripts
);
data
.
Children
.
ForEach
(
x
=>
{
{
var
config
=
configs
.
FirstOrDefault
(
w
=>
w
.
Id
==
x
.
ConfigId
);
data
.
ExScriptId
=
script
.
Id
;
if
(
config
!=
null
)
data
.
ExecScript
=
script
.
ExecScript
;
x
.
ConfigName
=
string
.
IsNullOrEmpty
(
config
.
ConfigName
)
?
config
.
DbSource
:
config
.
ConfigName
;
data
.
ConfigId
=
script
.
ConfigId
;
});
data
.
ConfigName
=
hospitalconfigRepository
.
GetEntity
(
w
=>
w
.
Id
==
script
.
ConfigId
)?.
ConfigName
;
data
.
TimeConsuming
=
script
.
TimeConsuming
;
data
.
IsExecSuccess
=
script
.
IsExecSuccess
;
data
.
IsEnable
=
script
.
IsEnable
;
}
}
return
data
;
return
data
;
}
}
public
bool
DeleteExtractTypeAndScript
(
int
typeId
)
public
bool
DeleteExtractTypeAndScript
(
int
typeId
,
int
scriptId
)
{
if
(
scriptId
!=
0
)
{
var
script
=
exscriptRepository
.
GetEntity
(
w
=>
w
.
TypeId
==
typeId
&&
w
.
Id
==
scriptId
);
if
(
script
==
null
)
throw
new
PerformanceException
(
"获取提取语句错误"
);
return
exscriptRepository
.
Remove
(
script
);
}
else
{
{
var
extype
=
extypeRepository
.
GetEntity
(
w
=>
w
.
Id
==
typeId
);
var
extype
=
extypeRepository
.
GetEntity
(
w
=>
w
.
Id
==
typeId
);
if
(
extype
==
null
)
throw
new
PerformanceException
(
"参数typeId无效"
);
if
(
extype
==
null
)
throw
new
PerformanceException
(
"参数typeId无效"
);
...
@@ -218,6 +240,7 @@ public bool DeleteExtractTypeAndScript(int typeId)
...
@@ -218,6 +240,7 @@ public bool DeleteExtractTypeAndScript(int typeId)
return
extypeRepository
.
Remove
(
extype
);
return
extypeRepository
.
Remove
(
extype
);
}
}
}
public
bool
EditExtractTypeAndScript
(
int
hospitalId
,
ExtractConfigResponse
request
)
public
bool
EditExtractTypeAndScript
(
int
hospitalId
,
ExtractConfigResponse
request
)
{
{
...
@@ -229,11 +252,16 @@ public bool EditExtractTypeAndScript(int hospitalId, ExtractConfigResponse reque
...
@@ -229,11 +252,16 @@ public bool EditExtractTypeAndScript(int hospitalId, ExtractConfigResponse reque
entity
.
HospitalId
=
hospitalId
;
entity
.
HospitalId
=
hospitalId
;
if
(!
extypeRepository
.
Add
(
entity
))
return
false
;
if
(!
extypeRepository
.
Add
(
entity
))
return
false
;
if
(
request
.
Children
!=
null
&&
request
.
Children
.
Any
())
if
(!
string
.
IsNullOrEmpty
(
request
.
ExecScript
))
{
var
script
=
new
ex_script
{
{
var
scripts
=
mapper
.
Map
<
List
<
ex_script
>>(
request
.
Children
);
ExecScript
=
request
.
ExecScript
,
scripts
.
ForEach
(
t
=>
t
.
TypeId
=
entity
.
Id
);
ConfigId
=
request
.
ConfigId
,
exscriptRepository
.
AddRange
(
scripts
.
ToArray
());
IsEnable
=
request
.
IsEnable
,
TypeId
=
entity
.
Id
};
exscriptRepository
.
Add
(
script
);
}
}
}
}
else
else
...
@@ -244,37 +272,27 @@ public bool EditExtractTypeAndScript(int hospitalId, ExtractConfigResponse reque
...
@@ -244,37 +272,27 @@ public bool EditExtractTypeAndScript(int hospitalId, ExtractConfigResponse reque
entity
.
Source
=
request
.
Source
;
entity
.
Source
=
request
.
Source
;
if
(!
extypeRepository
.
Update
(
entity
))
return
false
;
if
(!
extypeRepository
.
Update
(
entity
))
return
false
;
var
scripts
=
exscriptRepository
.
GetEntities
(
w
=>
w
.
TypeId
==
request
.
TypeId
);
if
(
request
.
ExScriptId
!=
0
)
/* 添加不存在的数据 */
if
(
request
.
Children
!=
null
&&
request
.
Children
.
Any
(
w
=>
w
.
ExScriptId
==
0
))
{
{
var
list
=
mapper
.
Map
<
List
<
ex_script
>>(
request
.
Children
);
var
script
=
exscriptRepository
.
GetEntity
(
w
=>
w
.
Id
==
request
.
ExScriptId
);
return
exscriptRepository
.
AddRange
(
list
.
ToArray
());
if
(
script
!=
null
)
}
/* 删除、修改存在的数据 */
if
(
scripts
!=
null
&&
scripts
.
Any
())
{
var
existIds
=
request
.
Children
?.
Select
(
w
=>
w
.
ExScriptId
)
??
new
List
<
int
>();
var
delScripts
=
scripts
.
Where
(
w
=>
!
existIds
.
Contains
(
w
.
Id
));
if
(
delScripts
!=
null
&&
delScripts
.
Any
())
exscriptRepository
.
RemoveRange
(
delScripts
.
ToArray
());
var
updScripts
=
scripts
.
Where
(
w
=>
existIds
.
Contains
(
w
.
Id
));
if
(
updScripts
!=
null
&&
updScripts
.
Any
())
{
foreach
(
var
item
in
updScripts
)
{
{
var
model
=
request
.
Children
.
FirstOrDefault
(
w
=>
w
.
ExScriptId
==
item
.
Id
);
script
.
ExecScript
=
request
.
ExecScript
;
if
(
model
==
null
)
continue
;
script
.
ConfigId
=
request
.
ConfigId
;
script
.
IsEnable
=
request
.
IsEnable
;
item
.
ExecScript
=
model
.
ExecScript
;
exscriptRepository
.
Update
(
script
);
item
.
ConfigId
=
model
.
ConfigId
;
item
.
IsEnable
=
model
.
IsEnable
;
}
}
exscriptRepository
.
UpdateRange
(
updScripts
.
ToArray
());
}
}
else
{
var
script
=
new
ex_script
{
ExecScript
=
request
.
ExecScript
,
ConfigId
=
request
.
ConfigId
,
IsEnable
=
request
.
IsEnable
,
TypeId
=
entity
.
Id
};
exscriptRepository
.
Add
(
script
);
}
}
}
}
...
@@ -399,6 +417,38 @@ public List<TitleValue<int>> GetSheettypes()
...
@@ -399,6 +417,38 @@ public List<TitleValue<int>> GetSheettypes()
}).
ToList
();
}).
ToList
();
}
}
public
List
<
TitleValue
<
int
>>
GetExTypes
(
int
hospitalId
)
{
var
hospital
=
hospitalRepository
.
GetEntity
(
w
=>
w
.
ID
==
hospitalId
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院信息错误"
);
var
data
=
extypeRepository
.
GetEntities
(
w
=>
w
.
HospitalId
==
hospitalId
);
if
(
data
==
null
||
!
data
.
Any
())
return
new
List
<
TitleValue
<
int
>>();
return
data
.
Select
(
t
=>
new
TitleValue
<
int
>
{
Title
=
t
.
EName
,
Value
=
t
.
Id
}).
ToList
();
}
public
List
<
TitleValue
<
int
>>
GetConfigs
(
int
hospitalId
)
{
var
hospital
=
hospitalRepository
.
GetEntity
(
w
=>
w
.
ID
==
hospitalId
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院信息错误"
);
var
data
=
hospitalconfigRepository
.
GetEntities
(
w
=>
w
.
HospitalId
==
hospitalId
);
if
(
data
==
null
||
!
data
.
Any
())
return
new
List
<
TitleValue
<
int
>>();
return
data
.
Select
(
t
=>
new
TitleValue
<
int
>
{
Title
=
t
.
ConfigName
,
Value
=
t
.
Id
}).
ToList
();
}
#
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