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
3161d240
Commit
3161d240
authored
Mar 07, 2019
by
zry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
绩效文件上传模块
parent
a3a1b55c
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
463 additions
and
15 deletions
+463
-15
performance/Performance.Api/Controllers/AllotController.cs
+109
-0
performance/Performance.Api/Files/9/201808/医院绩效分配系统数据收集模板V120190307092906314.xlsx
+0
-0
performance/Performance.Api/Files/9/201808/医院绩效分配系统数据收集模板V120190307132717963.xlsx
+0
-0
performance/Performance.Api/Files/9/201808/医院绩效分配系统数据收集模板V120190307132853236.xlsx
+0
-0
performance/Performance.Api/Files/9/201808/医院绩效分配系统数据收集模板V120190307133209252.xlsx
+0
-0
performance/Performance.Api/Files/9/201911/医院绩效分配系统数据收集模板V120190307133444707.xlsx
+0
-0
performance/Performance.Api/Filters/ActionsFilter.cs
+1
-2
performance/Performance.Api/Filters/ExceptionsFilter.cs
+6
-5
performance/Performance.Api/Performance.Api.csproj
+7
-0
performance/Performance.Api/Properties/launchSettings.json
+0
-1
performance/Performance.DtoModels/AutoMapper/AutoMapperConfigs.cs
+8
-0
performance/Performance.DtoModels/Request/AllotRequest.cs
+53
-0
performance/Performance.DtoModels/Response/AllotResponse.cs
+46
-0
performance/Performance.EntityModels/Context/PerformanceDbContext.cs
+1
-0
performance/Performance.EntityModels/Entity/sys_allot.cs
+63
-0
performance/Performance.EntityModels/Entity/sys_user_hospital.cs
+1
-1
performance/Performance.Infrastructure/Extensions/Extensions.Dictionary.cs
+20
-1
performance/Performance.Infrastructure/Helper/FileHelper.cs
+1
-1
performance/Performance.Infrastructure/Performance.Infrastructure.csproj
+3
-0
performance/Performance.Repository/PerforAllotRepository.cs
+21
-0
performance/Performance.Services/AllotService.cs
+106
-0
performance/Performance.Services/HospitalService.cs
+14
-1
performance/Performance.Services/UserService.cs
+3
-3
No files found.
performance/Performance.Api/Controllers/AllotController.cs
0 → 100644
View file @
3161d240
using
FluentValidation.AspNetCore
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http.Internal
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Logging
;
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
;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace
Performance.Api.Controllers
{
[
Route
(
"api/[controller]"
)]
public
class
AllotController
:
Controller
{
private
AllotService
_allotService
;
private
HospitalService
_hospitalService
;
private
IHostingEnvironment
_evn
;
private
ILogger
<
AllotController
>
_logger
;
public
AllotController
(
AllotService
allotService
,
HospitalService
hospitalService
,
ILogger
<
AllotController
>
logger
,
IHostingEnvironment
evn
)
{
_allotService
=
allotService
;
_hospitalService
=
hospitalService
;
_logger
=
logger
;
_evn
=
evn
;
}
[
Route
(
"list"
)]
[
HttpPost
]
public
ApiResponse
List
([
FromBody
]
AllotRequest
request
)
{
List
<
AllotResponse
>
allots
=
_allotService
.
GetAllotList
(
request
.
HospitalId
);
return
new
ApiResponse
(
ResponseType
.
OK
,
allots
);
}
[
Route
(
"insert"
)]
[
HttpPost
]
public
ApiResponse
Insert
([
CustomizeValidator
(
RuleSet
=
"Insert"
),
FromBody
]
AllotRequest
request
)
{
bool
result
=
_allotService
.
InsertAllot
(
request
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
[
Route
(
"update"
)]
[
HttpPost
]
public
ApiResponse
Update
([
CustomizeValidator
(
RuleSet
=
"Update"
),
FromBody
]
AllotRequest
request
)
{
bool
result
=
_allotService
.
UpdateAllot
(
request
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
[
Route
(
"delete"
)]
[
HttpPost
]
public
ApiResponse
Delete
([
CustomizeValidator
(
RuleSet
=
"Delete"
),
FromBody
]
AllotRequest
request
)
{
bool
result
=
_allotService
.
DeleteAllot
(
request
.
ID
);
return
new
ApiResponse
(
ResponseType
.
OK
);
}
[
Route
(
"import"
)]
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
,
"参数错误"
,
"allotid无效"
);
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
}
上次失败"
);
allot
.
Path
=
path
;
allot
.
States
=
1
;
allot
.
UploadDate
=
DateTime
.
Now
;
if
(!
_allotService
.
Update
(
allot
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
$"
{
file
.
FileName
}
上次成功,修改状态失败"
);
}
return
new
ApiResponse
(
ResponseType
.
OK
);
}
}
}
performance/Performance.Api/Files/9/201808/医院绩效分配系统数据收集模板V120190307092906314.xlsx
0 → 100644
View file @
3161d240
File added
performance/Performance.Api/Files/9/201808/医院绩效分配系统数据收集模板V120190307132717963.xlsx
0 → 100644
View file @
3161d240
File added
performance/Performance.Api/Files/9/201808/医院绩效分配系统数据收集模板V120190307132853236.xlsx
0 → 100644
View file @
3161d240
File added
performance/Performance.Api/Files/9/201808/医院绩效分配系统数据收集模板V120190307133209252.xlsx
0 → 100644
View file @
3161d240
File added
performance/Performance.Api/Files/9/201911/医院绩效分配系统数据收集模板V120190307133444707.xlsx
0 → 100644
View file @
3161d240
File added
performance/Performance.Api/Filters/ActionsFilter.cs
View file @
3161d240
...
...
@@ -110,8 +110,7 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
}
else
if
(
types
.
Contains
(
"application/x-www-form-urlencoded"
)
||
types
.
Contains
(
"multipart/form-data"
))
{
var
requestContext
=
JsonHelper
.
Serialize
(
request
.
Form
);
return
JsonHelper
.
DeserializeLower
(
requestContext
);
return
request
.
Form
.
ToDictionary
();
}
else
if
(
types
.
Contains
(
"text/xml"
))
{
...
...
performance/Performance.Api/Filters/ExceptionsFilter.cs
View file @
3161d240
...
...
@@ -11,22 +11,23 @@ namespace Performance.Api
{
public
class
ExceptionsFilter
:
IAsyncExceptionFilter
{
private
readonly
ILogger
Factory
loggerFactory
;
private
readonly
ILogger
<
ExceptionsFilter
>
_logger
;
public
ExceptionsFilter
(
ILogger
Factory
loggerFactory
)
public
ExceptionsFilter
(
ILogger
<
ExceptionsFilter
>
logger
)
{
this
.
loggerFactory
=
loggerFactory
;
this
.
_logger
=
logger
;
}
public
Task
OnExceptionAsync
(
ExceptionContext
context
)
{
var
logger
=
loggerFactory
.
CreateLogger
<
ExceptionsFilter
>();
logger
.
LogError
(
$"接口异常:
{
context
.
Exception
.
ToString
()}
"
);
if
(
context
.
Exception
is
PerformanceException
)
{
_logger
.
LogWarning
(
$"接口错误警告:
{
context
.
Exception
.
ToString
()}
"
);
context
.
Result
=
new
ObjectResult
(
new
ApiResponse
(
ResponseType
.
Fail
,
context
.
Exception
.
Message
));
}
else
{
_logger
.
LogError
(
$"接口异常:
{
context
.
Exception
.
ToString
()}
"
);
var
response
=
new
ApiResponse
(
ResponseType
.
Error
,
"接口内部异常"
,
context
.
Exception
.
Message
);
context
.
Result
=
new
ObjectResult
(
response
);
}
...
...
performance/Performance.Api/Performance.Api.csproj
View file @
3161d240
...
...
@@ -6,6 +6,13 @@
</PropertyGroup>
<ItemGroup>
<Compile Remove="Files\**" />
<Content Remove="Files\**" />
<EmbeddedResource Remove="Files\**" />
<None Remove="Files\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.1.3" />
...
...
performance/Performance.Api/Properties/launchSettings.json
View file @
3161d240
...
...
@@ -19,7 +19,6 @@
},
"Performance.Api"
:
{
"commandName"
:
"Project"
,
"launchBrowser"
:
true
,
"launchUrl"
:
"api/values"
,
"environmentVariables"
:
{
"ASPNETCORE_ENVIRONMENT"
:
"Development"
...
...
performance/Performance.DtoModels/AutoMapper/AutoMapperConfigs.cs
View file @
3161d240
...
...
@@ -41,6 +41,14 @@ public AutoMapperConfigs()
.
ForMember
(
dest
=>
dest
.
ID
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
MenuID
));
CreateMap
<
sys_menu
,
MenuResponse
>()
.
ForMember
(
dest
=>
dest
.
MenuID
,
opt
=>
opt
.
MapFrom
(
src
=>
src
.
ID
));
// 绩效 请求
CreateMap
<
AllotRequest
,
sys_allot
>();
CreateMap
<
sys_allot
,
AllotRequest
>();
// 绩效 响应
CreateMap
<
AllotResponse
,
sys_allot
>();
CreateMap
<
sys_allot
,
AllotResponse
>();
}
}
}
performance/Performance.DtoModels/Request/AllotRequest.cs
0 → 100644
View file @
3161d240
using
FluentValidation
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.DtoModels
{
public
class
AllotRequest
{
public
int
ID
{
get
;
set
;
}
/// <summary>
/// 医院ID
/// </summary>
public
Nullable
<
int
>
HospitalId
{
get
;
set
;
}
/// <summary>
/// 绩效发放年
/// </summary>
public
int
Year
{
get
;
set
;
}
/// <summary>
/// 绩效发放月
/// </summary>
public
int
Month
{
get
;
set
;
}
}
public
class
AllotRequestValidator
:
AbstractValidator
<
AllotRequest
>
{
public
AllotRequestValidator
()
{
RuleSet
(
"Insert"
,
()
=>
{
RuleFor
(
x
=>
x
.
HospitalId
).
NotNull
().
GreaterThan
(
0
);
RuleFor
(
x
=>
x
.
Year
).
NotNull
().
InclusiveBetween
(
2010
,
2055
);
RuleFor
(
x
=>
x
.
Month
).
NotNull
().
InclusiveBetween
(
1
,
12
);
});
RuleSet
(
"Update"
,
()
=>
{
RuleFor
(
x
=>
x
.
ID
).
NotNull
().
GreaterThan
(
0
);
RuleFor
(
x
=>
x
.
HospitalId
).
NotNull
().
GreaterThan
(
0
);
RuleFor
(
x
=>
x
.
Year
).
NotNull
().
InclusiveBetween
(
2010
,
2055
);
RuleFor
(
x
=>
x
.
Month
).
NotNull
().
InclusiveBetween
(
1
,
12
);
});
RuleSet
(
"Delete"
,
()
=>
{
RuleFor
(
x
=>
x
.
ID
).
NotNull
().
GreaterThan
(
0
);
});
}
}
}
performance/Performance.DtoModels/Response/AllotResponse.cs
0 → 100644
View file @
3161d240
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.DtoModels
{
public
class
AllotResponse
{
public
int
ID
{
get
;
set
;
}
/// <summary>
/// 医院ID
/// </summary>
public
int
HospitalId
{
get
;
set
;
}
/// <summary>
/// 绩效发放年
/// </summary>
public
int
Year
{
get
;
set
;
}
/// <summary>
/// 绩效发放月
/// </summary>
public
int
Month
{
get
;
set
;
}
/// <summary>
/// 绩效发放总金额
/// </summary>
public
Nullable
<
decimal
>
AllotFee
{
get
;
set
;
}
/// <summary>
/// 绩效统计时间
/// </summary>
public
Nullable
<
DateTime
>
CreateDate
{
get
;
set
;
}
/// <summary>
/// 上传日期
/// </summary>
public
Nullable
<
DateTime
>
UploadDate
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
States
{
get
;
set
;
}
}
}
performance/Performance.EntityModels/Context/PerformanceDbContext.cs
View file @
3161d240
...
...
@@ -19,5 +19,6 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public
virtual
DbSet
<
sys_role
>
Sys_Role
{
get
;
set
;
}
public
virtual
DbSet
<
sys_role_menu
>
Sys_Role_Menu
{
get
;
set
;
}
public
virtual
DbSet
<
sys_user_role
>
Sys_User_Role
{
get
;
set
;
}
public
virtual
DbSet
<
sys_allot
>
Sys_Allot
{
get
;
set
;
}
}
}
performance/Performance.EntityModels/Entity/sys_allot.cs
0 → 100644
View file @
3161d240
//-----------------------------------------------------------------------
// <copyright file=" sys_allot.cs">
// * FileName: sys_allot.cs
// * history : 2019-03-06 16:43:26
// </copyright>
//-----------------------------------------------------------------------
using
System
;
using
System.ComponentModel.DataAnnotations
;
namespace
Performance.EntityModels
{
/// <summary>
/// sys_allot Entity Model
/// </summary>
public
class
sys_allot
{
/// <summary>
/// ID
/// </summary>
[
Key
]
public
int
ID
{
get
;
set
;
}
/// <summary>
/// 医院ID
/// </summary>
public
int
HospitalId
{
get
;
set
;
}
/// <summary>
/// 绩效发放年
/// </summary>
public
int
Year
{
get
;
set
;
}
/// <summary>
/// 绩效发放月
/// </summary>
public
int
Month
{
get
;
set
;
}
/// <summary>
/// 绩效发放总金额
/// </summary>
public
Nullable
<
decimal
>
AllotFee
{
get
;
set
;
}
/// <summary>
/// 绩效统计时间
/// </summary>
public
Nullable
<
DateTime
>
CreateDate
{
get
;
set
;
}
/// <summary>
/// 文件路径
/// </summary>
public
string
Path
{
get
;
set
;
}
/// <summary>
/// 上传日期
/// </summary>
public
Nullable
<
DateTime
>
UploadDate
{
get
;
set
;
}
/// <summary>
/// 0 数据未上传 1 数据已上传 2 数据解析中 3 数据解析成功 4 绩效结果生成中 5绩效结果解析成功 6 归档
/// </summary>
public
int
States
{
get
;
set
;
}
}
}
performance/Performance.EntityModels/Entity/sys_user_hospital.cs
View file @
3161d240
...
...
@@ -28,6 +28,6 @@ public class sys_user_hospital
/// <summary>
///
/// </summary>
public
Nullable
<
int
>
HosID
{
get
;
set
;
}
public
Nullable
<
int
>
Hos
pital
ID
{
get
;
set
;
}
}
}
performance/Performance.Infrastructure/Extensions/Extensions.Dictionary.cs
View file @
3161d240
using
System
;
using
Microsoft.AspNetCore.Http
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Performance.Infrastructure
...
...
@@ -35,5 +37,22 @@ public static T GetValue<T>(this SortedDictionary<string, object> keyValues, str
return
ConvertHelper
.
To
<
T
>(
value
,
defaultValue
);
return
defaultValue
;
}
/// <summary>
/// form 转换 键值对
/// </summary>
/// <param name="pairs"></param>
/// <returns></returns>
public
static
SortedDictionary
<
string
,
object
>
ToDictionary
(
this
IFormCollection
pairs
)
{
SortedDictionary
<
string
,
object
>
kv
=
new
SortedDictionary
<
string
,
object
>();
if
(
pairs
==
null
||
pairs
.
Keys
.
Count
==
0
)
return
kv
;
foreach
(
var
item
in
pairs
.
Keys
)
{
kv
.
Add
(
item
,
pairs
[
item
].
FirstOrDefault
());
}
return
kv
;
}
}
}
performance/Performance.Infrastructure/Helper/FileHelper.cs
View file @
3161d240
...
...
@@ -170,7 +170,7 @@ public static bool CreateFile(string filePath, byte[] buffer)
fs
.
Close
();
}
}
catch
catch
(
Exception
ex
)
{
return
false
;
}
...
...
performance/Performance.Infrastructure/Performance.Infrastructure.csproj
View file @
3161d240
...
...
@@ -11,6 +11,9 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Http.Features">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.http.features\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Http.Features.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.Mvc.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.abstractions\2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll</HintPath>
</Reference>
...
...
performance/Performance.Repository/PerforAllotRepository.cs
0 → 100644
View file @
3161d240
//-----------------------------------------------------------------------
// <copyright file=" sys_allot.cs">
// * FileName: sys_allot.cs
// * history : Created by T4 2019-03-06 16:43:31
// </copyright>
//-----------------------------------------------------------------------
using
System
;
using
Performance.EntityModels
;
namespace
Performance.Repository
{
/// <summary>
/// sys_allot Repository
/// </summary>
public
class
PerforAllotRepository
:
PerforRepository
<
sys_allot
>
{
public
PerforAllotRepository
(
PerformanceDbContext
context
)
:
base
(
context
)
{
}
}
}
performance/Performance.Services/AllotService.cs
0 → 100644
View file @
3161d240
using
AutoMapper
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Performance.Services
{
public
class
AllotService
:
IAutoInjection
{
private
PerforAllotRepository
_allotRepository
;
public
AllotService
(
PerforAllotRepository
allotRepository
)
{
_allotRepository
=
allotRepository
;
}
/// <summary>
/// 绩效记录
/// </summary>
/// <param name="hospitalId"></param>
/// <returns></returns>
public
List
<
AllotResponse
>
GetAllotList
(
int
?
hospitalId
)
{
var
allotList
=
(
hospitalId
.
HasValue
&&
hospitalId
.
Value
>
0
)
?
_allotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
hospitalId
).
ToList
()
:
_allotRepository
.
GetEntities
().
ToList
();
return
Mapper
.
Map
<
List
<
AllotResponse
>>(
allotList
);
}
/// <summary>
/// 新增
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public
bool
InsertAllot
(
AllotRequest
request
)
{
var
repAllot
=
_allotRepository
.
GetEntities
(
t
=>
t
.
HospitalId
==
request
.
HospitalId
&&
t
.
Year
==
request
.
Year
&&
t
.
Month
==
request
.
Month
);
if
(
repAllot
!=
null
&&
repAllot
.
Count
()
>
0
)
throw
new
PerformanceException
(
"当前绩效记录已存在"
);
var
allot
=
Mapper
.
Map
<
sys_allot
>(
request
);
allot
.
CreateDate
=
DateTime
.
Now
;
allot
.
States
=
0
;
return
_allotRepository
.
Add
(
allot
);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public
bool
UpdateAllot
(
AllotRequest
request
)
{
var
allot
=
_allotRepository
.
GetEntity
(
t
=>
t
.
ID
==
request
.
ID
);
if
(
allot
==
null
)
throw
new
PerformanceException
(
"当前绩效记录不存在"
);
var
repAllot
=
_allotRepository
.
GetEntities
(
t
=>
t
.
ID
!=
request
.
ID
&&
t
.
HospitalId
==
request
.
HospitalId
&&
t
.
Year
==
request
.
Year
&&
t
.
Month
==
request
.
Month
);
if
(
repAllot
!=
null
&&
repAllot
.
Count
()
>
0
)
throw
new
PerformanceException
(
"当前绩效记录与其他记录冲突"
);
allot
.
HospitalId
=
request
.
HospitalId
.
Value
;
allot
.
Year
=
request
.
Year
;
allot
.
Month
=
request
.
Month
;
return
_allotRepository
.
Update
(
allot
);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="iD"></param>
/// <returns></returns>
public
bool
DeleteAllot
(
int
iD
)
{
var
allot
=
_allotRepository
.
GetEntity
(
t
=>
t
.
ID
==
iD
);
if
(
allot
==
null
)
throw
new
PerformanceException
(
"当前绩效记录不存在"
);
return
_allotRepository
.
Remove
(
allot
);
}
/// <summary>
/// 查询
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
public
sys_allot
GetAllot
(
int
allotId
)
{
return
_allotRepository
.
GetEntity
(
t
=>
t
.
ID
==
allotId
);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="allot"></param>
/// <returns></returns>
public
bool
Update
(
sys_allot
allot
)
{
return
_allotRepository
.
Update
(
allot
);
}
}
}
performance/Performance.Services/HospitalService.cs
View file @
3161d240
...
...
@@ -34,12 +34,25 @@ public List<HospitalResponse> GetUserHopital(int userid)
if
(
joinList
==
null
&&
joinList
.
Count
==
0
)
return
null
;
var
hosList
=
_hospitalRepository
.
GetEntities
(
t
=>
joinList
.
Select
(
j
=>
j
.
HosID
).
Contains
(
t
.
ID
)).
ToList
();
var
hosList
=
_hospitalRepository
.
GetEntities
(
t
=>
joinList
.
Select
(
j
=>
j
.
Hos
pital
ID
).
Contains
(
t
.
ID
)).
ToList
();
return
Mapper
.
Map
<
List
<
sys_hospital
>,
List
<
HospitalResponse
>>(
hosList
);
}
/// <summary>
/// 查询医院
/// </summary>
/// <param name="userid"></param>
/// <returns></returns>
public
sys_hospital
GetHopital
(
int
hosid
)
{
if
(
hosid
<=
0
)
throw
new
PerformanceException
(
$"hosid:
{
hosid
}
错误"
);
return
_hospitalRepository
.
GetEntity
(
t
=>
t
.
ID
==
hosid
);
}
/// <summary>
/// 新增医院
/// </summary>
/// <param name="request"></param>
...
...
performance/Performance.Services/UserService.cs
View file @
3161d240
...
...
@@ -97,18 +97,18 @@ public bool SetHospital(SetHospitalRequest request)
bool
rmResult
=
true
,
addResult
=
true
;
//获取需要删除的医院
var
rmHospital
=
userHospital
.
Where
(
t
=>
!
request
.
HosIDArray
.
Contains
(
t
.
HosID
.
Value
));
var
rmHospital
=
userHospital
.
Where
(
t
=>
!
request
.
HosIDArray
.
Contains
(
t
.
Hos
pital
ID
.
Value
));
if
(
rmHospital
!=
null
&&
rmHospital
.
Count
()
>
0
)
rmResult
=
_userhospitalRepository
.
RemoveRange
(
rmHospital
.
ToArray
());
//获取需要新增的医院
var
addHospital
=
request
.
HosIDArray
.
Where
(
t
=>
!
userHospital
.
Select
(
u
=>
u
.
HosID
).
Contains
(
t
));
var
addHospital
=
request
.
HosIDArray
.
Where
(
t
=>
!
userHospital
.
Select
(
u
=>
u
.
Hos
pital
ID
).
Contains
(
t
));
if
(
addHospital
!=
null
&&
addHospital
.
Count
()
>
0
)
{
var
allHospital
=
_hospitalRepository
.
GetEntities
();
//获取有效医院ID
var
array
=
addHospital
.
Where
(
t
=>
allHospital
.
Select
(
h
=>
h
.
ID
).
Contains
(
t
))
.
Select
(
t
=>
new
sys_user_hospital
{
UserID
=
request
.
UserID
,
HosID
=
t
}).
ToArray
();
.
Select
(
t
=>
new
sys_user_hospital
{
UserID
=
request
.
UserID
,
Hos
pital
ID
=
t
}).
ToArray
();
addResult
=
_userhospitalRepository
.
AddRange
(
array
);
}
...
...
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