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
633de37d
Commit
633de37d
authored
Mar 02, 2022
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
人员字典验证完善
parent
1a12ee5c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
19 deletions
+76
-19
performance/Performance.Api/Controllers/PersonController.cs
+2
-6
performance/Performance.Services/PersonService.cs
+74
-13
No files found.
performance/Performance.Api/Controllers/PersonController.cs
View file @
633de37d
...
@@ -59,9 +59,7 @@ public ApiResponse GetPersons([FromRoute] int allotId, [FromBody] PersonParamsRe
...
@@ -59,9 +59,7 @@ public ApiResponse GetPersons([FromRoute] int allotId, [FromBody] PersonParamsRe
public
ApiResponse
CreatePerson
([
FromBody
]
PerEmployeeResponse
request
)
public
ApiResponse
CreatePerson
([
FromBody
]
PerEmployeeResponse
request
)
{
{
request
.
CreateUser
=
claimService
.
GetUserId
();
request
.
CreateUser
=
claimService
.
GetUserId
();
var
employeee
=
personService
.
CreatePerson
(
request
);
return
personService
.
CreatePerson
(
request
);
return
employeee
.
Id
>
0
?
new
ApiResponse
(
ResponseType
.
OK
,
"添加成功!"
,
employeee
)
:
new
ApiResponse
(
ResponseType
.
Fail
,
"添加失败!"
);
}
}
/// <summary>
/// <summary>
...
@@ -73,9 +71,7 @@ public ApiResponse CreatePerson([FromBody] PerEmployeeResponse request)
...
@@ -73,9 +71,7 @@ public ApiResponse CreatePerson([FromBody] PerEmployeeResponse request)
[
HttpPost
]
[
HttpPost
]
public
ApiResponse
UpdatePerson
([
FromBody
]
PerEmployeeResponse
request
)
public
ApiResponse
UpdatePerson
([
FromBody
]
PerEmployeeResponse
request
)
{
{
var
result
=
personService
.
UpdatePerson
(
request
);
return
personService
.
UpdatePerson
(
request
);
return
result
?
new
ApiResponse
(
ResponseType
.
OK
,
"修改成功!"
)
:
new
ApiResponse
(
ResponseType
.
OK
,
"修改失败!"
);
}
}
/// <summary>
/// <summary>
...
...
performance/Performance.Services/PersonService.cs
View file @
633de37d
...
@@ -231,10 +231,38 @@ public PageList<per_employee> GetPersons(int allotId, int userId, PersonParamsRe
...
@@ -231,10 +231,38 @@ public PageList<per_employee> GetPersons(int allotId, int userId, PersonParamsRe
/// </summary>
/// </summary>
/// <param name="request"></param>
/// <param name="request"></param>
/// <returns></returns>
/// <returns></returns>
public
per_employe
e
CreatePerson
(
PerEmployeeResponse
request
)
public
ApiRespons
e
CreatePerson
(
PerEmployeeResponse
request
)
{
{
var
employee
=
peremployeeRepository
.
GetEntity
(
t
=>
t
.
AllotId
==
request
.
AllotId
&&
t
.
PersonnelNumber
==
request
.
PersonnelNumber
List
<
Dictionary
<
string
,
string
>>
error
=
new
List
<
Dictionary
<
string
,
string
>>();
&&
t
.
DoctorName
==
request
.
DoctorName
&&
t
.
Department
==
request
.
Department
);
var
oldEmployees
=
peremployeeRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
request
.
AllotId
);
for
(
int
i
=
0
;
i
<
oldEmployees
.
Count
;
i
++)
{
if
(
oldEmployees
.
Count
(
w
=>
w
.
PersonnelNumber
==
oldEmployees
[
i
].
PersonnelNumber
)
>
1
)
{
error
.
Add
(
new
Dictionary
<
string
,
string
>
{
{
"行号"
,
$"第
{
i
+
1
}
行"
},
{
"人员工号"
,
oldEmployees
[
i
].
PersonnelNumber
??
""
},
{
"姓名"
,
oldEmployees
[
i
].
DoctorName
??
""
},
{
"错误原因"
,
"“人员工号”重复"
},
});
}
}
if
(
error
.
Count
>
0
)
return
new
ApiResponse
(
ResponseType
.
WarningTable
,
"验证不通过,当前操作已拒绝"
,
error
);
if
(
string
.
IsNullOrEmpty
(
request
.
UnitType
?.
Trim
())
||
string
.
IsNullOrEmpty
(
request
.
Department
?.
Trim
())
||
string
.
IsNullOrEmpty
(
request
.
AccountingUnit
?.
Trim
())
||
string
.
IsNullOrEmpty
(
request
.
DoctorName
?.
Trim
())
||
string
.
IsNullOrEmpty
(
request
.
PersonnelNumber
?.
Trim
()))
{
throw
new
PerformanceException
(
$"“关键信息缺失”请补全!"
);
}
var
employee
=
peremployeeRepository
.
GetEntity
(
t
=>
t
.
AllotId
==
request
.
AllotId
&&
t
.
PersonnelNumber
==
request
.
PersonnelNumber
);
if
(
employee
!=
null
)
if
(
employee
!=
null
)
throw
new
PerformanceException
(
$"员工工号为
{
request
.
PersonnelNumber
}
的数据已存在!"
);
throw
new
PerformanceException
(
$"员工工号为
{
request
.
PersonnelNumber
}
的数据已存在!"
);
...
@@ -253,7 +281,8 @@ public per_employee CreatePerson(PerEmployeeResponse request)
...
@@ -253,7 +281,8 @@ public per_employee CreatePerson(PerEmployeeResponse request)
//CheckAccountingDept(request.HospitalId.Value, request.AccountingUnit, request.Department);
//CheckAccountingDept(request.HospitalId.Value, request.AccountingUnit, request.Department);
peremployeeRepository
.
Add
(
entity
);
peremployeeRepository
.
Add
(
entity
);
return
entity
;
return
new
ApiResponse
(
ResponseType
.
OK
,
"添加成功"
,
entity
);
}
}
/// <summary>
/// <summary>
...
@@ -261,12 +290,44 @@ public per_employee CreatePerson(PerEmployeeResponse request)
...
@@ -261,12 +290,44 @@ public per_employee CreatePerson(PerEmployeeResponse request)
/// </summary>
/// </summary>
/// <param name="request"></param>
/// <param name="request"></param>
/// <returns></returns>
/// <returns></returns>
public
bool
UpdatePerson
(
PerEmployeeResponse
request
)
public
ApiResponse
UpdatePerson
(
PerEmployeeResponse
request
)
{
{
var
employee
=
peremployeeRepository
.
GetEntity
(
t
=>
t
.
AllotId
==
request
.
AllotId
&&
t
.
PersonnelNumber
==
request
.
PersonnelNumber
List
<
Dictionary
<
string
,
string
>>
error
=
new
List
<
Dictionary
<
string
,
string
>>();
&&
t
.
DoctorName
==
request
.
DoctorName
&&
t
.
Department
==
request
.
Department
);
var
oldEmployees
=
peremployeeRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
request
.
AllotId
);
if
(
employee
!=
null
&&
employee
.
Id
!=
request
.
Id
)
throw
new
PerformanceException
(
$"员工工号为
{
request
.
PersonnelNumber
}
的数据已存在!"
);
for
(
int
i
=
0
;
i
<
oldEmployees
.
Count
;
i
++)
{
if
(
oldEmployees
.
Count
(
w
=>
w
.
PersonnelNumber
==
oldEmployees
[
i
].
PersonnelNumber
)
>
1
)
{
error
.
Add
(
new
Dictionary
<
string
,
string
>
{
{
"行号"
,
$"第
{
i
+
1
}
行"
},
{
"人员工号"
,
oldEmployees
[
i
].
PersonnelNumber
??
""
},
{
"姓名"
,
oldEmployees
[
i
].
DoctorName
??
""
},
{
"错误原因"
,
"“人员工号”重复"
},
});
}
}
if
(
error
.
Count
>
0
)
return
new
ApiResponse
(
ResponseType
.
WarningTable
,
"验证不通过,当前操作已拒绝"
,
error
);
if
(
string
.
IsNullOrEmpty
(
request
.
UnitType
?.
Trim
())
||
string
.
IsNullOrEmpty
(
request
.
Department
?.
Trim
())
||
string
.
IsNullOrEmpty
(
request
.
AccountingUnit
?.
Trim
())
||
string
.
IsNullOrEmpty
(
request
.
DoctorName
?.
Trim
())
||
string
.
IsNullOrEmpty
(
request
.
PersonnelNumber
?.
Trim
()))
{
throw
new
PerformanceException
(
$"“关键信息缺失”请补全!"
);
}
var
employees
=
peremployeeRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
request
.
AllotId
&&
t
.
PersonnelNumber
==
request
.
PersonnelNumber
);
if
(
employees
==
null
)
throw
new
PerformanceException
(
$"员工工号为“
{
request
.
PersonnelNumber
}
”不存在,请重新添加!"
);
if
(
employees
.
Count
()
>
1
)
throw
new
PerformanceException
(
$"工号为“
{
request
.
PersonnelNumber
}
”存在多条数据,请删除多余数据!"
);
var
unittype
=
EnumHelper
.
GetItems
<
UnitType
>().
Select
(
t
=>
t
.
Description
).
ToList
();
var
unittype
=
EnumHelper
.
GetItems
<
UnitType
>().
Select
(
t
=>
t
.
Description
).
ToList
();
unittype
.
AddRange
(
EnumHelper
.
GetItems
<
AccountUnitType
>().
Select
(
t
=>
t
.
Description
));
unittype
.
AddRange
(
EnumHelper
.
GetItems
<
AccountUnitType
>().
Select
(
t
=>
t
.
Description
));
...
@@ -274,9 +335,7 @@ public bool UpdatePerson(PerEmployeeResponse request)
...
@@ -274,9 +335,7 @@ public bool UpdatePerson(PerEmployeeResponse request)
if
(!
unittype
.
Contains
(
request
.
UnitType
))
if
(!
unittype
.
Contains
(
request
.
UnitType
))
throw
new
PerformanceException
(
$"人员类别不符合规范!"
);
throw
new
PerformanceException
(
$"人员类别不符合规范!"
);
if
(
employee
==
null
)
var
employee
=
employees
.
First
();
employee
=
peremployeeRepository
.
GetEntity
(
t
=>
t
.
Id
==
request
.
Id
)
??
throw
new
PerformanceException
(
"人员信息无效!"
);
//_mapper.Map(request, employee, typeof(per_employee), typeof(per_employee));
//_mapper.Map(request, employee, typeof(per_employee), typeof(per_employee));
employee
.
AccountingUnit
=
request
.
AccountingUnit
;
employee
.
AccountingUnit
=
request
.
AccountingUnit
;
...
@@ -304,7 +363,9 @@ public bool UpdatePerson(PerEmployeeResponse request)
...
@@ -304,7 +363,9 @@ public bool UpdatePerson(PerEmployeeResponse request)
employee
.
Attendance
=
Math
.
Round
((
request
.
AttendanceDay
??
0
)
/
day
,
4
);
employee
.
Attendance
=
Math
.
Round
((
request
.
AttendanceDay
??
0
)
/
day
,
4
);
//CheckAccountingDept(request.HospitalId.Value, request.AccountingUnit, request.Department);
//CheckAccountingDept(request.HospitalId.Value, request.AccountingUnit, request.Department);
return
peremployeeRepository
.
Update
(
employee
);
var
res
=
peremployeeRepository
.
Update
(
employee
);
return
new
ApiResponse
(
ResponseType
.
OK
,
"修改成功"
);
}
}
/// <summary>
/// <summary>
...
...
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