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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
244 additions
and
153 deletions
+244
-153
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
+108
-58
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
#
region
自定义提取
/// <summary>
/// 自定义提取
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
[
HttpPost
(
"custom/{allotId}"
)]
public
ApiResponse
CustomExtract
(
int
allotId
)
{
var
userId
=
_claim
.
GetUserId
();
if
(!
_extractService
.
CheckConfigScript
(
userId
,
allotId
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
"未配置自定义抽取,请联系绩效管理人员。"
);
_backgroundTaskQueue
.
QueueBackgroundWorkItem
(
async
token
=>
{
using
(
var
scope
=
_serviceScopeFactory
.
CreateScope
())
{
var
scopedServices
=
scope
.
ServiceProvider
.
GetRequiredService
<
CustomExtractService
>();
var
scopedAllotService
=
scope
.
ServiceProvider
.
GetRequiredService
<
AllotService
>();
var
scopedQueue
=
scope
.
ServiceProvider
.
GetRequiredService
<
IHubNotificationQueue
>();
if
(
scopedServices
.
ExtractData
(
userId
,
allotId
,
out
string
resultFilePath
))
{
scopedAllotService
.
UpdateAllotCustomExtractPath
(
allotId
,
resultFilePath
);
scopedQueue
.
Send
(
new
Notification
(
allotId
,
"CustomDowoload"
,
new
CustomDownloadContent
(
"自定义数据提取数据成功,是否立即下载"
,
allotId
)));
}
else
{
scopedQueue
.
Send
(
new
Notification
(
allotId
,
"Notification"
,
new
TextContent
(
"自定义数据提取数据失败"
,
NotificationLevel
.
ERR
)));
}
await
Task
.
Delay
(
TimeSpan
.
FromSeconds
(
5
),
token
);
}
});
_notificationQueue
.
Send
(
new
Notification
(
allotId
,
"Notification"
,
new
TextContent
(
"自定义数据提取任务开始执行"
)));
return
new
ApiResponse
(
ResponseType
.
OK
);
}
/// <summary>
/// 从WebAPI下载文件
/// </summary>
/// <returns></returns>
[
Route
(
"down/{allotId}"
)]
[
HttpGet
]
[
AllowAnonymous
]
public
IActionResult
DownFile
(
int
allotId
)
{
var
allot
=
_allotService
.
GetAllot
(
allotId
);
if
(
allot
==
null
||
string
.
IsNullOrWhiteSpace
(
allot
.
CustomExtractPath
)
||
!
FileHelper
.
IsExistFile
(
allot
.
CustomExtractPath
))
{
return
new
ObjectResult
(
new
ApiResponse
(
ResponseType
.
Fail
,
"文件不存在"
));
}
var
memoryStream
=
new
MemoryStream
();
using
(
var
stream
=
new
FileStream
(
allot
.
CustomExtractPath
,
FileMode
.
Open
))
{
stream
.
CopyToAsync
(
memoryStream
).
Wait
();
}
memoryStream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
string
fileExt
=
Path
.
GetExtension
(
allot
.
CustomExtractPath
);
var
provider
=
new
FileExtensionContentTypeProvider
();
var
memi
=
provider
.
Mappings
[
fileExt
];
return
File
(
memoryStream
,
memi
,
Path
.
GetFileName
(
allot
.
CustomExtractPath
));
}
///
//
<summary>
///
//
自定义提取
///
//
</summary>
///
//
<param name="allotId"></param>
///
//
<returns></returns>
//
[HttpPost("custom/{allotId}")]
//
public ApiResponse CustomExtract(int allotId)
//
{
//
var userId = _claim.GetUserId();
//
if (!_extractService.CheckConfigScript(userId, allotId))
//
return new ApiResponse(ResponseType.Fail, "未配置自定义抽取,请联系绩效管理人员。");
//
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
//
{
//
using (var scope = _serviceScopeFactory.CreateScope())
//
{
//
var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>();
//
var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>();
//
var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>();
//
if (scopedServices.ExtractData(userId, allotId, out string resultFilePath))
//
{
//
scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath);
//
scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId)));
//
}
//
else
//
{
//
scopedQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
//
}
//
await Task.Delay(TimeSpan.FromSeconds(5), token);
//
}
//
});
//
_notificationQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取任务开始执行")));
//
return new ApiResponse(ResponseType.OK);
//
}
///
//
<summary>
///
//
从WebAPI下载文件
///
//
</summary>
///
//
<returns></returns>
//
[Route("down/{allotId}")]
//
[HttpGet]
//
[AllowAnonymous]
//
public IActionResult DownFile(int allotId)
//
{
//
var allot = _allotService.GetAllot(allotId);
//
if (allot == null || string.IsNullOrWhiteSpace(allot.CustomExtractPath) || !FileHelper.IsExistFile(allot.CustomExtractPath))
//
{
//
return new ObjectResult(new ApiResponse(ResponseType.Fail, "文件不存在"));
//
}
//
var memoryStream = new MemoryStream();
//
using (var stream = new FileStream(allot.CustomExtractPath, FileMode.Open))
//
{
//
stream.CopyToAsync(memoryStream).Wait();
//
}
//
memoryStream.Seek(0, SeekOrigin.Begin);
//
string fileExt = Path.GetExtension(allot.CustomExtractPath);
//
var provider = new FileExtensionContentTypeProvider();
//
var memi = provider.Mappings[fileExt];
//
return File(memoryStream, memi, Path.GetFileName(allot.CustomExtractPath));
//
}
#
endregion
#
region
医院数据库配置
[
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
);
return
new
ApiResponse
<
List
<
sys_hospitalconfig
>>(
ResponseType
.
OK
,
list
);
return
new
ApiResponse
<
List
<
HospitalConfigResponse
>>(
ResponseType
.
OK
,
list
);
}
[
HttpPost
(
"hospital/config/create"
)]
...
...
@@ -178,19 +178,19 @@ public ApiResponse GetExtractTypeAndScript([FromBody] ExTypeRequest request)
return
new
ApiResponse
(
ResponseType
.
OK
,
list
);
}
[
HttpGet
(
"type/{typeId}"
)]
public
ApiResponse
GetExtractTypeAndScriptById
([
FromRoute
]
int
typeId
)
[
HttpGet
(
"type/{typeId}
/{scriptId}
"
)]
public
ApiResponse
GetExtractTypeAndScriptById
([
FromRoute
]
int
typeId
,
int
scriptId
)
{
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
);
}
[
HttpPost
(
"type/{typeId}"
)]
public
ApiResponse
DeleteExtractTypeAndScript
([
FromRoute
]
int
typeId
)
[
HttpPost
(
"type/{typeId}
/{scriptId}
"
)]
public
ApiResponse
DeleteExtractTypeAndScript
([
FromRoute
]
int
typeId
,
int
scriptId
)
{
if
(
typeId
==
0
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"参数错误"
);
var
flag
=
_preConfigService
.
DeleteExtractTypeAndScript
(
typeId
);
var
flag
=
_preConfigService
.
DeleteExtractTypeAndScript
(
typeId
,
scriptId
);
return
flag
?
new
ApiResponse
(
ResponseType
.
OK
,
"删除成功"
)
:
new
ApiResponse
(
ResponseType
.
Fail
,
"删除失败"
);
...
...
@@ -215,5 +215,37 @@ public ApiResponse CheckExecsqlConsumeTime([FromBody] ConsumeTimeRequest request
}
#
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()
.
ForMember
(
dest
=>
dest
.
TypeId
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Id
))
.
ReverseMap
();
CreateMap
<
ex_script
,
Extract
ScriptConfig
>()
CreateMap
<
ex_script
,
Extract
ConfigResponse
>()
.
ForMember
(
dest
=>
dest
.
ExScriptId
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
Id
))
.
ReverseMap
();
}
...
...
performance/Performance.DtoModels/Response/ExtractConfigResponse.cs
View file @
791e75c6
...
...
@@ -8,19 +8,16 @@ public class ExtractConfigResponse
public
string
EName
{
get
;
set
;
}
public
string
Description
{
get
;
set
;
}
public
int
Source
{
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
string
ExecScript
{
get
;
set
;
}
...
...
@@ -29,12 +26,12 @@ public class ExtractScriptConfig
public
string
ConfigName
{
get
;
set
;
}
public
int
IsEnable
{
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
#
region
HospitalConfig
public
List
<
sys_hospitalconfig
>
GetHospitalConfig
(
int
hospitalId
)
public
List
<
HospitalConfigResponse
>
GetHospitalConfig
(
int
hospitalId
)
{
var
hospital
=
hospitalRepository
.
GetEntity
(
w
=>
w
.
ID
==
hospitalId
);
if
(
hospital
==
null
)
throw
new
PerformanceException
(
"医院信息错误"
);
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
)
...
...
@@ -76,6 +87,9 @@ public bool CreateHospitalConfig(sys_hospitalconfig hospitalconfig)
var
hospital
=
hospitalRepository
.
GetEntity
(
w
=>
w
.
ID
==
hospitalconfig
.
HospitalId
);
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
);
}
...
...
@@ -89,6 +103,9 @@ public bool UpdateHospitalConfig(sys_hospitalconfig hospitalconfig)
if
(!
databases
.
Select
(
t
=>
t
.
Value
).
Contains
(
hospitalconfig
.
DataBaseType
))
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
);
if
(
entity
==
null
)
throw
new
PerformanceException
(
"医院配置信息为空"
);
...
...
@@ -162,8 +179,8 @@ public PageList<ExtractConfigResponse> GetExtractTypeAndScript(ExTypeRequest req
var
itemScripts
=
scripts
.
Where
(
w
=>
w
.
TypeId
==
item
.
TypeId
);
if
(
itemScripts
==
null
||
!
itemScripts
.
Any
())
continue
;
item
.
T
otalTime
=
itemScripts
.
Sum
(
t
=>
t
.
TimeConsuming
);
item
.
Children
=
mapper
.
Map
<
List
<
Extract
ScriptConfig
>>(
itemScripts
);
item
.
T
imeConsuming
=
itemScripts
.
Sum
(
t
=>
t
.
TimeConsuming
);
item
.
Children
=
mapper
.
Map
<
List
<
Extract
ConfigResponse
>>(
itemScripts
);
item
.
Children
.
ForEach
(
x
=>
{
...
...
@@ -176,7 +193,7 @@ public PageList<ExtractConfigResponse> GetExtractTypeAndScript(ExTypeRequest req
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
);
if
(
type
==
null
)
throw
new
PerformanceException
(
"参数无效"
);
...
...
@@ -186,37 +203,43 @@ public ExtractConfigResponse GetExtractTypeAndScriptById(int typeId)
var
sheettypes
=
GetSheettypes
();
data
.
SheetType
=
sheettypes
.
FirstOrDefault
(
w
=>
w
.
Value
==
data
.
Source
)?.
Title
;
var
script
s
=
exscriptRepository
.
GetEntities
(
w
=>
w
.
TypeId
==
typeId
)
??
new
List
<
ex_script
>
();
if
(
script
s
!=
null
&&
scripts
.
Any
()
)
var
script
=
exscriptRepository
.
GetEntity
(
w
=>
w
.
TypeId
==
typeId
&&
w
.
Id
==
scriptId
)
??
new
ex_script
();
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
);
if
(
config
!=
null
)
x
.
ConfigName
=
string
.
IsNullOrEmpty
(
config
.
ConfigName
)
?
config
.
DbSource
:
config
.
ConfigName
;
});
data
.
ExScriptId
=
script
.
Id
;
data
.
ExecScript
=
script
.
ExecScript
;
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
;
}
public
bool
DeleteExtractTypeAndScript
(
int
typeId
)
public
bool
DeleteExtractTypeAndScript
(
int
typeId
,
int
scriptId
)
{
var
extype
=
extypeRepository
.
GetEntity
(
w
=>
w
.
Id
==
typeId
);
if
(
extype
==
null
)
throw
new
PerformanceException
(
"参数typeId无效"
);
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
);
if
(
extype
==
null
)
throw
new
PerformanceException
(
"参数typeId无效"
);
var
scripts
=
exscriptRepository
.
GetEntities
(
w
=>
w
.
TypeId
==
typeId
);
if
(
scripts
==
null
||
!
scripts
.
Any
())
return
true
;
var
scripts
=
exscriptRepository
.
GetEntities
(
w
=>
w
.
TypeId
==
typeId
);
if
(
scripts
==
null
||
!
scripts
.
Any
())
return
true
;
if
(!
exscriptRepository
.
RemoveRange
(
scripts
.
ToArray
()))
if
(
extype
==
null
)
throw
new
PerformanceException
(
"提取语句删除失败"
);
if
(!
exscriptRepository
.
RemoveRange
(
scripts
.
ToArray
()))
if
(
extype
==
null
)
throw
new
PerformanceException
(
"提取语句删除失败"
);
return
extypeRepository
.
Remove
(
extype
);
return
extypeRepository
.
Remove
(
extype
);
}
}
public
bool
EditExtractTypeAndScript
(
int
hospitalId
,
ExtractConfigResponse
request
)
...
...
@@ -229,11 +252,16 @@ public bool EditExtractTypeAndScript(int hospitalId, ExtractConfigResponse reque
entity
.
HospitalId
=
hospitalId
;
if
(!
extypeRepository
.
Add
(
entity
))
return
false
;
if
(
request
.
Children
!=
null
&&
request
.
Children
.
Any
(
))
if
(
!
string
.
IsNullOrEmpty
(
request
.
ExecScript
))
{
var
scripts
=
mapper
.
Map
<
List
<
ex_script
>>(
request
.
Children
);
scripts
.
ForEach
(
t
=>
t
.
TypeId
=
entity
.
Id
);
exscriptRepository
.
AddRange
(
scripts
.
ToArray
());
var
script
=
new
ex_script
{
ExecScript
=
request
.
ExecScript
,
ConfigId
=
request
.
ConfigId
,
IsEnable
=
request
.
IsEnable
,
TypeId
=
entity
.
Id
};
exscriptRepository
.
Add
(
script
);
}
}
else
...
...
@@ -244,37 +272,27 @@ public bool EditExtractTypeAndScript(int hospitalId, ExtractConfigResponse reque
entity
.
Source
=
request
.
Source
;
if
(!
extypeRepository
.
Update
(
entity
))
return
false
;
var
scripts
=
exscriptRepository
.
GetEntities
(
w
=>
w
.
TypeId
==
request
.
TypeId
);
/* 添加不存在的数据 */
if
(
request
.
Children
!=
null
&&
request
.
Children
.
Any
(
w
=>
w
.
ExScriptId
==
0
))
if
(
request
.
ExScriptId
!=
0
)
{
var
list
=
mapper
.
Map
<
List
<
ex_script
>>(
request
.
Children
);
return
exscriptRepository
.
AddRange
(
list
.
ToArray
());
var
script
=
exscriptRepository
.
GetEntity
(
w
=>
w
.
Id
==
request
.
ExScriptId
);
if
(
script
!=
null
)
{
script
.
ExecScript
=
request
.
ExecScript
;
script
.
ConfigId
=
request
.
ConfigId
;
script
.
IsEnable
=
request
.
IsEnable
;
exscriptRepository
.
Update
(
script
);
}
}
/* 删除、修改存在的数据 */
if
(
scripts
!=
null
&&
scripts
.
Any
())
else
{
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
())
var
script
=
new
ex_script
{
foreach
(
var
item
in
updScripts
)
{
var
model
=
request
.
Children
.
FirstOrDefault
(
w
=>
w
.
ExScriptId
==
item
.
Id
);
if
(
model
==
null
)
continue
;
item
.
ExecScript
=
model
.
ExecScript
;
item
.
ConfigId
=
model
.
ConfigId
;
item
.
IsEnable
=
model
.
IsEnable
;
}
exscriptRepository
.
UpdateRange
(
updScripts
.
ToArray
());
}
ExecScript
=
request
.
ExecScript
,
ConfigId
=
request
.
ConfigId
,
IsEnable
=
request
.
IsEnable
,
TypeId
=
entity
.
Id
};
exscriptRepository
.
Add
(
script
);
}
}
...
...
@@ -326,7 +344,7 @@ public decimal CheckExecsqlConsumeTime(ConsumeTimeRequest request)
return
script
.
TimeConsuming
;
}
#
endregion
#
endregion
#
region
Model
Item
Special
...
...
@@ -399,6 +417,38 @@ public List<TitleValue<int>> GetSheettypes()
}).
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
}
}
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