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
8b6a7ec3
Commit
8b6a7ec3
authored
May 07, 2024
by
wyc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
考勤类型(双主键/增删改调整)/加载上月修改/加载默认考勤(调整)
parent
ef210c57
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
142 additions
and
97 deletions
+142
-97
performance/Performance.Api/Controllers/AttendanceController.cs
+4
-3
performance/Performance.Api/wwwroot/Performance.Api.xml
+2
-1
performance/Performance.Api/wwwroot/Performance.EntityModels.xml
+12
-0
performance/Performance.EntityModels/Context/Configurations/per_attendance_typeConfiguration.cs
+20
-0
performance/Performance.EntityModels/Context/PerformanceDbContext.cs
+10
-0
performance/Performance.Services/AttendanceService.cs
+26
-19
performance/Performance.Services/CopyService.cs
+68
-74
No files found.
performance/Performance.Api/Controllers/AttendanceController.cs
View file @
8b6a7ec3
...
@@ -172,13 +172,14 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT
...
@@ -172,13 +172,14 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT
/// <summary>
/// <summary>
/// 删除考勤类型
/// 删除考勤类型
/// </summary>
/// </summary>
/// <param name="allotId"></param>
/// <param name="id"></param>
/// <param name="id"></param>
/// <returns></returns>
/// <returns></returns>
[
HttpPost
(
"Type/Delete/{id}"
)]
[
HttpPost
(
"Type/Delete/{
allotId},{
id}"
)]
public
ApiResponse
DeleteAttendanceType
(
int
id
)
public
ApiResponse
DeleteAttendanceType
(
int
allotId
,
int
id
)
{
{
// 删除前需要验证当前类型是否被使用,如果被使用则禁止删除
// 删除前需要验证当前类型是否被使用,如果被使用则禁止删除
return
_attendanceService
.
DeleteAttendanceType
(
id
);
return
_attendanceService
.
DeleteAttendanceType
(
allotId
,
id
);
}
}
/// <summary>
/// <summary>
/// 返回HandsonTable格式考勤类型
/// 返回HandsonTable格式考勤类型
...
...
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
8b6a7ec3
...
@@ -604,10 +604,11 @@
...
@@ -604,10 +604,11 @@
<param
name=
"attendanceType"
></param>
<param
name=
"attendanceType"
></param>
<returns></returns>
<returns></returns>
</member>
</member>
<member
name=
"M:Performance.Api.Controllers.AttendanceController.DeleteAttendanceType(System.Int32)"
>
<member
name=
"M:Performance.Api.Controllers.AttendanceController.DeleteAttendanceType(System.Int32
,System.Int32
)"
>
<summary>
<summary>
删除考勤类型
删除考勤类型
</summary>
</summary>
<param
name=
"allotId"
></param>
<param
name=
"id"
></param>
<param
name=
"id"
></param>
<returns></returns>
<returns></returns>
</member>
</member>
...
...
performance/Performance.Api/wwwroot/Performance.EntityModels.xml
View file @
8b6a7ec3
...
@@ -4,6 +4,11 @@
...
@@ -4,6 +4,11 @@
<name>
Performance.EntityModels
</name>
<name>
Performance.EntityModels
</name>
</assembly>
</assembly>
<members>
<members>
<member
name=
"T:Performance.EntityModels.Context.Configurations.PerAttendanceTypeConfiguration"
>
<summary>
定义数据模型(per_attendance_type)
</summary>
</member>
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.ag_againsituation"
>
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.ag_againsituation"
>
<summary>
二次分配概览
</summary>
<summary>
二次分配概览
</summary>
</member>
</member>
...
@@ -391,6 +396,13 @@
...
@@ -391,6 +396,13 @@
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.per_assess_scheme_target"
>
<member
name=
"P:Performance.EntityModels.PerformanceDbContext.per_assess_scheme_target"
>
<summary>
被考核对象
</summary>
<summary>
被考核对象
</summary>
</member>
</member>
<member
name=
"M:Performance.EntityModels.PerformanceDbContext.OnModelCreating(Microsoft.EntityFrameworkCore.ModelBuilder)"
>
<summary>
在这个方法中,你可以配置实体类型之间的关系、数据库表的映射以及其他一些高级配置。
这是 Entity Framework Core 中的一个重要方法,在派生自 DbContext 的类中重写它以定义数据模型
</summary>
<param
name=
"modelBuilder"
></param>
</member>
<member
name=
"T:Performance.EntityModels.ag_againsituation"
>
<member
name=
"T:Performance.EntityModels.ag_againsituation"
>
<summary>
<summary>
二次分配概览
二次分配概览
...
...
performance/Performance.EntityModels/Context/Configurations/per_attendance_typeConfiguration.cs
0 → 100644
View file @
8b6a7ec3
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Metadata.Builders
;
using
Performance.EntityModels.Entity
;
namespace
Performance.EntityModels.Context.Configurations
{
/// <summary>
/// 定义数据模型(per_attendance_type)
/// </summary>
public
partial
class
PerAttendanceTypeConfiguration
:
IEntityTypeConfiguration
<
per_attendance_type
>
{
public
void
Configure
(
EntityTypeBuilder
<
per_attendance_type
>
entity
)
{
entity
.
HasKey
(
x
=>
new
{
x
.
Id
,
x
.
AllotId
})
.
HasName
(
"PRIMARY"
)
.
HasAnnotation
(
"MySql:IndexPrrfixLength"
,
new
[]
{
0
,
0
});
entity
.
ToTable
(
"per_attendance_type"
);
}
}
}
performance/Performance.EntityModels/Context/PerformanceDbContext.cs
View file @
8b6a7ec3
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore
;
using
Performance.EntityModels.Context.Configurations
;
using
Performance.EntityModels.Entity
;
using
Performance.EntityModels.Entity
;
namespace
Performance.EntityModels
namespace
Performance.EntityModels
...
@@ -283,5 +284,14 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
...
@@ -283,5 +284,14 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public
virtual
DbSet
<
per_assess_scheme_items
>
per_assess_scheme_items
{
get
;
set
;
}
public
virtual
DbSet
<
per_assess_scheme_items
>
per_assess_scheme_items
{
get
;
set
;
}
/// <summary>被考核对象</summary>
/// <summary>被考核对象</summary>
public
virtual
DbSet
<
per_assess_scheme_target
>
per_assess_scheme_target
{
get
;
set
;
}
public
virtual
DbSet
<
per_assess_scheme_target
>
per_assess_scheme_target
{
get
;
set
;
}
/// <summary>
/// 在这个方法中,你可以配置实体类型之间的关系、数据库表的映射以及其他一些高级配置。
/// 这是 Entity Framework Core 中的一个重要方法,在派生自 DbContext 的类中重写它以定义数据模型
/// </summary>
/// <param name="modelBuilder"></param>
protected
override
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
{
modelBuilder
.
ApplyConfiguration
(
new
PerAttendanceTypeConfiguration
());
}
}
}
}
}
performance/Performance.Services/AttendanceService.cs
View file @
8b6a7ec3
...
@@ -547,7 +547,7 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT
...
@@ -547,7 +547,7 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT
if
(
attendanceType
.
Id
>
0
)
if
(
attendanceType
.
Id
>
0
)
{
{
var
per_Attendance_Type
=
perfoPperAttendanceTypeRepository
.
GetEntities
().
Find
(
f
=>
f
.
Id
==
attendanceType
.
Id
);
var
per_Attendance_Type
=
perfoPperAttendanceTypeRepository
.
GetEntities
().
Find
(
f
=>
f
.
Id
==
attendanceType
.
Id
&&
f
.
AllotId
==
allotId
);
per_Attendance_Type
.
AttendanceName
=
attendanceType
.
AttendanceName
;
per_Attendance_Type
.
AttendanceName
=
attendanceType
.
AttendanceName
;
per_Attendance_Type
.
IsDeduction
=
attendanceType
.
IsDeduction
;
per_Attendance_Type
.
IsDeduction
=
attendanceType
.
IsDeduction
;
per_Attendance_Type
.
IsDefault
=
attendanceType
.
IsDefault
;
per_Attendance_Type
.
IsDefault
=
attendanceType
.
IsDefault
;
...
@@ -579,19 +579,21 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT
...
@@ -579,19 +579,21 @@ public ApiResponse<AttendanceType> InsertAttendanceType(int allotId, AttendanceT
}
}
public
ApiResponse
DeleteAttendanceType
(
int
id
)
public
ApiResponse
DeleteAttendanceType
(
int
allotId
,
int
id
)
{
{
var
a
ny
=
perfoPperAttendanceTypeRepository
.
GetEntity
(
t
=>
t
.
Id
==
i
d
)
var
a
ttendanceType
=
perfoPperAttendanceTypeRepository
.
GetEntity
(
t
=>
t
.
Id
==
id
&&
t
.
AllotId
==
allotI
d
)
??
throw
new
PerformanceException
(
"未找到该类型,请刷新后重试!!!"
);
??
throw
new
PerformanceException
(
"未找到该类型,请刷新后重试!!!"
);
var
use
=
perfoPperAttendanceVacationeRepository
.
GetEntity
(
t
=>
t
.
TypeId
==
any
.
Id
);
var
isTypeUsed
=
perfoPperAttendanceVacationeRepository
.
GetEntity
(
t
=>
t
.
TypeId
==
attendanceType
.
Id
&&
t
.
AllotId
==
allot
Id
);
if
(
use
!=
null
)
if
(
isTypeUsed
!=
null
)
return
new
ApiResponse
(
ResponseType
.
Fail
,
"该类型正在使用!"
);
return
new
ApiResponse
(
ResponseType
.
Fail
,
"该类型正在使用!"
);
return
perfoPperAttendanceTypeRepository
.
DeleteFromQuery
(
t
=>
t
.
Id
==
id
)
>
0
var
deletedCount
=
perfoPperAttendanceTypeRepository
.
DeleteFromQuery
(
t
=>
t
.
Id
==
id
&&
t
.
AllotId
==
allotId
);
return
deletedCount
>
0
?
new
ApiResponse
(
ResponseType
.
OK
,
"删除成功"
)
?
new
ApiResponse
(
ResponseType
.
OK
,
"删除成功"
)
:
new
ApiResponse
(
ResponseType
.
Fail
,
"删除失败"
);
:
new
ApiResponse
(
ResponseType
.
Fail
,
"删除失败"
);
}
}
/// <summary>
/// <summary>
/// 返回HandsonTable格式考勤类型
/// 返回HandsonTable格式考勤类型
/// </summary>
/// </summary>
...
@@ -736,21 +738,24 @@ public ApiResponse AttendanceTypeBatch(int allotId, int hospitalId, SaveCollectD
...
@@ -736,21 +738,24 @@ public ApiResponse AttendanceTypeBatch(int allotId, int hospitalId, SaveCollectD
/// <exception cref="PerformanceException"></exception>
/// <exception cref="PerformanceException"></exception>
public
ApiResponse
GetAttendanceReplenishment
(
int
allotId
,
int
userid
)
public
ApiResponse
GetAttendanceReplenishment
(
int
allotId
,
int
userid
)
{
{
var
allot
=
perforPerallotRepository
.
GetEntity
(
w
=>
w
.
ID
==
allotId
)
??
throw
new
PerformanceException
(
"当前绩效记录不存在"
);
var
typeDefault
=
perfoPperAttendanceTypeRepository
.
GetEntities
()
.
Find
(
f
=>
f
.
AllotId
==
allotId
&&
f
.
IsDefault
==
(
int
)
Attendance
.
Default
.
默认
)
??
throw
new
PerformanceException
(
"未设置默认类型"
);
//查询全部考勤上报内容
var
attendanceDepts
=
_perforPerAttendanceDeptRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
allot
.
ID
);
if
(
attendanceDepts
==
null
)
throw
new
PerformanceException
(
"请添加考勤人员"
);
//当角色对应时过滤
//当角色对应时过滤
var
userInfo
=
_userRepository
.
GetUser
(
userid
);
var
userInfo
=
_userRepository
.
GetUser
(
userid
);
if
(
userInfo
?.
User
==
null
)
throw
new
NotImplementedException
(
"当前用户不存在"
);
if
(
userInfo
?.
User
==
null
)
throw
new
NotImplementedException
(
"当前用户不存在"
);
if
(
userInfo
?.
URole
==
null
)
throw
new
NotImplementedException
(
"当前用户暂未分配角色"
);
if
(
userInfo
?.
URole
==
null
)
throw
new
NotImplementedException
(
"当前用户暂未分配角色"
);
var
unitTypes
=
UnitTypeUtil
.
GetMaps
(
userInfo
?.
URole
.
Type
??
0
);
var
unitTypes
=
UnitTypeUtil
.
GetMaps
(
userInfo
?.
URole
.
Type
??
0
);
if
(!
unitTypes
.
Any
())
throw
new
PerformanceException
(
"当前用户没有分配科室!!!"
);
var
result
=
attendanceDepts
.
Where
(
w
=>
w
.
AccountingUnit
==
userInfo
.
User
.
Department
&&
UnitTypeUtil
.
Is
(
w
.
UnitType
,
unitTypes
)).
ToList
();
var
typeDefault
=
perfoPperAttendanceTypeRepository
.
GetEntity
(
g
=>
g
.
AllotId
==
allotId
&&
g
.
IsDefault
==
(
int
)
Attendance
.
Default
.
默认
)
??
throw
new
PerformanceException
(
"未设置默认类型"
);
//查询全部考勤上报内容
var
attendanceDepts
=
_perforPerAttendanceDeptRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
allotId
);
var
result
=
unitTypes
?.
Any
()
==
true
?
attendanceDepts
.
Where
(
w
=>
w
.
AccountingUnit
==
userInfo
.
User
.
Department
&&
UnitTypeUtil
.
Is
(
w
.
UnitType
,
unitTypes
)).
ToList
()
:
attendanceDepts
;
List
<
Dictionary
<
string
,
string
>>
error
=
new
List
<
Dictionary
<
string
,
string
>>();
List
<
Dictionary
<
string
,
string
>>
error
=
new
List
<
Dictionary
<
string
,
string
>>();
foreach
(
var
item
in
result
)
foreach
(
var
item
in
result
)
{
//查询其他科室是否存在考勤
{
//查询其他科室是否存在考勤
...
@@ -2124,12 +2129,14 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
...
@@ -2124,12 +2129,14 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
if
(!
queryUnitTypes
.
Contains
(
unitType
))
throw
new
PerformanceException
(
"当前用户角色与“核算组别”不匹配"
);
if
(!
queryUnitTypes
.
Contains
(
unitType
))
throw
new
PerformanceException
(
"当前用户角色与“核算组别”不匹配"
);
var
perAttendanceDepts
=
_attendanceDeptRepository
.
GetEntities
(
w
=>
w
.
AllotId
==
allotId
)
??
new
List
<
per_attendance_dept
>();
var
perAttendanceDepts
=
_attendanceDeptRepository
.
GetEntities
(
w
=>
w
.
AllotId
==
allotId
)
??
new
List
<
per_attendance_dept
>();
var
attendances
=
perAttendanceDepts
?.
Where
(
(
w
)
=>
queryUnitTypes
.
Contains
(
w
.
UnitType
)
&&
queryAccountingUnit
.
Equals
(
w
.
AccountingUnit
)
).
ToList
();
var
attendances
=
perAttendanceDepts
?.
Where
(
w
=>
w
.
UnitType
==
unitType
&&
w
.
AccountingUnit
==
queryAccountingUnit
).
ToList
();
if
(!
attendances
.
Any
())
return
new
ApiResponse
(
ResponseType
.
OK
,
"暂无数据,无需提交!"
);
if
(!
attendances
.
Any
())
return
new
ApiResponse
(
ResponseType
.
OK
,
"暂无数据,无需提交!"
);
int
[]
states
=
{
(
int
)
Attendance
.
Report
.
通过
,
(
int
)
Attendance
.
Report
.
提交
};
int
[]
states
=
{
(
int
)
Attendance
.
Report
.
通过
,
(
int
)
Attendance
.
Report
.
提交
};
//查询是否在其他科室的考勤记录
//查询是否在其他科室的考勤记录
var
data_Numbers
=
attendances
.
Select
(
w
=>
w
.
PersonnelNumber
).
ToList
();
var
data_Numbers
=
attendances
.
Select
(
w
=>
w
.
PersonnelNumber
).
ToList
();
var
attendanceDepts
=
perAttendanceDepts
?.
Where
(
w
=>
data_Numbers
.
Contains
(
w
.
PersonnelNumber
)
&&
unitType
!=
w
.
UnitType
&&
queryAccountingUnit
!=
w
.
AccountingUnit
&&
w
.
State
.
Equals
(
states
)).
ToList
();
var
attendanceDepts
=
perAttendanceDepts
?.
Where
(
w
=>
data_Numbers
.
Contains
(
w
.
PersonnelNumber
)
&&
states
.
Contains
(
w
.
State
)
&&
(
w
.
UnitType
!=
unitType
||
w
.
AccountingUnit
!=
queryAccountingUnit
)).
ToList
();
var
employees
=
perforPeremployeeRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
allotId
);
var
employees
=
perforPeremployeeRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
allotId
);
var
types
=
perfoPperAttendanceTypeRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
allotId
)
??
new
List
<
per_attendance_type
>();
var
types
=
perfoPperAttendanceTypeRepository
.
GetEntities
(
t
=>
t
.
AllotId
==
allotId
)
??
new
List
<
per_attendance_type
>();
...
@@ -2266,7 +2273,7 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
...
@@ -2266,7 +2273,7 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
{
{
string
dayPropertyName
=
$"Day
{
day
:
00
}
"
;
string
dayPropertyName
=
$"Day
{
day
:
00
}
"
;
var
attendanceDeptValue
=
typeof
(
per_attendance_dept
).
GetProperty
(
dayPropertyName
)?.
GetValue
(
attendanceDept
);
var
attendanceDeptValue
=
typeof
(
per_attendance_dept
).
GetProperty
(
dayPropertyName
)?.
GetValue
(
attendanceDept
);
var
dataValue
=
typeof
(
AttendanceD
ept
).
GetProperty
(
dayPropertyName
)?.
GetValue
(
row
);
var
dataValue
=
typeof
(
per_attendance_d
ept
).
GetProperty
(
dayPropertyName
)?.
GetValue
(
row
);
if
(!
string
.
IsNullOrEmpty
(
attendanceDeptValue
?.
ToString
())
&&
!
string
.
IsNullOrEmpty
(
dataValue
?.
ToString
()))
if
(!
string
.
IsNullOrEmpty
(
attendanceDeptValue
?.
ToString
())
&&
!
string
.
IsNullOrEmpty
(
dataValue
?.
ToString
()))
{
{
error
.
Add
(
new
Dictionary
<
string
,
string
>
error
.
Add
(
new
Dictionary
<
string
,
string
>
...
...
performance/Performance.Services/CopyService.cs
View file @
8b6a7ec3
using
Microsoft.Extensions.Logging
;
using
GraphQL
;
using
Microsoft.Extensions.Logging
;
using
Performance.DtoModels
;
using
Performance.DtoModels
;
using
Performance.DtoModels.Request
;
using
Performance.EntityModels
;
using
Performance.EntityModels
;
using
Performance.EntityModels.Entity
;
using
Performance.EntityModels.Entity
;
using
Performance.EntityModels.Other
;
using
Performance.EntityModels.Other
;
...
@@ -321,96 +323,88 @@ public void Copy_Empdetail(per_allot allot, int prevAllotId, bool delHistotyData
...
@@ -321,96 +323,88 @@ public void Copy_Empdetail(per_allot allot, int prevAllotId, bool delHistotyData
/// <param name="prevAllotId">上月绩效Id</param>
/// <param name="prevAllotId">上月绩效Id</param>
public
void
Copy_AttendanceType
(
per_allot
allot
,
int
prevAllotId
)
public
void
Copy_AttendanceType
(
per_allot
allot
,
int
prevAllotId
)
{
{
_logger
.
LogInformation
(
$"加载上月 考勤类型(per_attendance_type)和考勤上报(per_attendance_dept)"
);
var
log
=
"加载上月(考勤类型per_attendance_type)和(考勤上报per_attendance_dept"
;
var
attendanceTypes
=
_pperAttendanceTypeRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
prevAllotId
||
g
.
AllotId
==
allot
.
ID
)
??
new
List
<
per_attendance_type
>();
_logger
.
LogInformation
(
log
);
var
attendanceTypes
=
_pperAttendanceTypeRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
prevAllotId
||
g
.
AllotId
==
allot
.
ID
)
??
new
List
<
per_attendance_type
>();
//查询上月有没有类型,没有就跳过
//查询上月有没有类型,没有就跳过
var
prevAttTypes
=
attendanceTypes
.
Where
(
w
=>
w
.
AllotId
==
prevAllotId
).
ToList
();
var
prevAttTypes
=
attendanceTypes
.
Where
(
w
=>
w
.
AllotId
==
prevAllotId
).
ToList
();
if
(!
prevAttTypes
.
Any
())
return
;
if
(!
prevAttTypes
.
Any
())
return
;
// 修改当月的考勤类型,加载上月完成在删除
var
attTypes
=
attendanceTypes
.
Where
(
w
=>
w
.
AllotId
==
allot
.
ID
).
ToList
();
var
updataAttTypes
=
attendanceTypes
.
Where
(
w
=>
w
.
AllotId
==
allot
.
ID
).
ToList
();
//判断是否存在默认值
if
(
updataAttTypes
.
Any
())
bool
IsDefault
=
attTypes
.
Any
(
f
=>
f
.
IsDefault
==
1
);
var
perAttendanceTypeList
=
new
List
<
per_attendance_type
>();
foreach
(
var
prevAttType
in
prevAttTypes
)
{
{
updataAttTypes
.
ForEach
(
w
=>
w
.
AllotId
=
0
);
var
existingType
=
attTypes
.
FirstOrDefault
(
a
=>
a
.
AttendanceName
==
prevAttType
.
AttendanceName
);
_pperAttendanceTypeRepository
.
UpdateRange
(
updataAttTypes
.
ToArray
());
if
(
existingType
==
null
)
{
var
newAttType
=
new
per_attendance_type
{
Id
=
prevAttType
.
Id
,
HospitalId
=
prevAttType
.
HospitalId
,
AllotId
=
allot
.
ID
,
AttendanceName
=
prevAttType
.
AttendanceName
,
IsDeduction
=
prevAttType
.
IsDeduction
,
IsDefault
=
IsDefault
?
0
:
prevAttType
.
IsDefault
,
RemarksOne
=
prevAttType
.
RemarksOne
,
RemarksTwo
=
prevAttType
.
RemarksTwo
,
RemarksThree
=
prevAttType
.
RemarksThree
};
perAttendanceTypeList
.
Add
(
newAttType
);
}
}
}
//插入上月的考勤类型
var
successfulType
=
_pperAttendanceTypeRepository
.
AddRange
(
perAttendanceTypeList
.
ToArray
());
var
newAttTypes
=
prevAttTypes
.
Select
(
t
=>
new
per_attendance_type
{
AllotId
=
allot
.
ID
,
AttendanceName
=
t
.
AttendanceName
,
HospitalId
=
t
.
HospitalId
,
IsDeduction
=
t
.
IsDeduction
,
IsDefault
=
t
.
IsDefault
,
RemarksOne
=
t
.
RemarksOne
,
RemarksTwo
=
t
.
RemarksTwo
,
RemarksThree
=
t
.
RemarksThree
,
}).
ToList
();
var
successfulType
=
_pperAttendanceTypeRepository
.
AddRange
(
newAttTypes
.
ToArray
());
if
(
successfulType
)
if
(
successfulType
)
{
{
var
prevPerEmployee
=
_perforPeremployeeRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
prevAllotId
);
var
prevPerEmployee
=
_perforPeremployeeRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
prevAllotId
&&
g
.
IsVerify
==
1
);
if
(!
prevPerEmployee
.
Any
())
return
;
if
(!
prevPerEmployee
.
Any
())
return
;
var
attendance_Types
=
_pperAttendanceTypeRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
0
).
ToList
();
// 当月的考勤上报
// 修改当月的考勤上报
var
attDepts
=
_perforPerAttendanceDeptRepository
.
GetEntities
(
w
=>
w
.
AllotId
==
allot
.
ID
).
ToList
();
var
updataAttDepts
=
_perforPerAttendanceDeptRepository
.
GetEntities
(
w
=>
w
.
AllotId
==
allot
.
ID
).
ToList
();
if
(!
attDepts
.
Any
())
if
(
updataAttDepts
.
Any
())
{
{
foreach
(
var
att
in
updataAttDepts
)
//查询默认考勤类型
var
typeDefault
=
_pperAttendanceTypeRepository
.
GetEntity
(
g
=>
g
.
AllotId
==
allot
.
ID
&&
g
.
IsDefault
==
(
int
)
Attendance
.
Default
.
默认
)?.
Id
??
null
;
var
cofaccounting
=
_cofaccountingRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
prevAllotId
);
int
currentMonth
=
DateTime
.
DaysInMonth
(
allot
.
Year
,
allot
.
Month
);
var
newAttDepts
=
prevPerEmployee
.
Select
(
t
=>
{
{
for
(
int
day
=
1
;
day
<=
31
;
day
++)
var
code
=
cofaccounting
.
Where
(
p
=>
p
.
UnitType
==
t
.
UnitType
&&
p
.
AccountingUnit
==
t
.
AccountingUnit
)
.
Select
(
p
=>
p
.
Code
)
.
FirstOrDefault
()
??
""
;
var
newDept
=
new
per_attendance_dept
{
{
string
dayPropertyName
=
$"Day
{
day
:
00
}
"
;
HospitalId
=
t
.
HospitalId
,
PropertyInfo
dayProperty
=
typeof
(
per_attendance_dept
).
GetProperty
(
dayPropertyName
);
AllotId
=
allot
.
ID
,
if
(
dayProperty
!=
null
)
PersonnelName
=
t
.
DoctorName
,
{
PersonnelNumber
=
t
.
PersonnelNumber
,
int
?
dayValue
=
(
int
?)
dayProperty
.
GetValue
(
att
);
PermanentStaff
=
t
.
PermanentStaff
??
0
,
var
oldDayPropertyName
=
attendance_Types
.
FirstOrDefault
(
w
=>
w
.
Id
==
dayValue
)?.
AttendanceName
??
"考勤类型缺失"
;
Code
=
code
,
var
newDayPropertyName
=
newAttTypes
.
FirstOrDefault
(
w
=>
w
.
AttendanceName
==
oldDayPropertyName
)?.
Id
;
UnitType
=
t
.
UnitType
,
if
(
newDayPropertyName
!=
null
)
AccountingUnit
=
t
.
AccountingUnit
,
{
State
=
(
int
)
Attendance
.
Report
.
未提交
dayProperty
.
SetValue
(
att
,
newDayPropertyName
);
};
}
}
}
}
_perforPerAttendanceDeptRepository
.
UpdateRange
(
updataAttDepts
.
ToArray
());
}
//查询默认考勤类型
for
(
int
i
=
1
;
i
<=
currentMonth
;
i
++)
var
typeDefault
=
newAttTypes
.
Find
(
f
=>
f
.
IsDefault
==
(
int
)
Attendance
.
Default
.
默认
);
{
var
cofaccounting
=
_cofaccountingRepository
.
GetEntities
(
g
=>
g
.
AllotId
==
prevAllotId
);
typeof
(
per_attendance_dept
).
GetProperty
(
$"Day
{
i
:
d2
}
"
)?.
SetValue
(
newDept
,
typeDefault
);
int
currentMonth
=
DateTime
.
DaysInMonth
(
allot
.
Year
,
allot
.
Month
);
}
var
newAttDepts
=
prevPerEmployee
.
Select
(
t
=>
{
var
code
=
cofaccounting
.
Where
(
p
=>
p
.
UnitType
==
t
.
UnitType
&&
p
.
AccountingUnit
==
t
.
AccountingUnit
)
.
Select
(
p
=>
p
.
Code
)
.
FirstOrDefault
()
??
""
;
var
newDept
=
new
per_attendance_dept
{
HospitalId
=
t
.
HospitalId
,
AllotId
=
allot
.
ID
,
PersonnelName
=
t
.
DoctorName
,
PersonnelNumber
=
t
.
PersonnelNumber
,
PermanentStaff
=
t
.
PermanentStaff
??
0
,
Code
=
code
,
UnitType
=
t
.
UnitType
,
AccountingUnit
=
t
.
AccountingUnit
,
State
=
(
int
)
Attendance
.
Report
.
未提交
};
for
(
int
i
=
1
;
i
<=
currentMonth
;
i
++)
return
newDept
;
{
}).
ToList
();
typeof
(
per_attendance_dept
).
GetProperty
(
$"Day
{
i
:
d2
}
"
)?.
SetValue
(
newDept
,
typeDefault
.
Id
);
_perforPerAttendanceDeptRepository
.
AddRange
(
newAttDepts
.
ToArray
()
);
}
}
return
newDept
;
}).
ToList
();
_perforPerAttendanceDeptRepository
.
AddRange
(
newAttDepts
.
ToArray
());
_pperAttendanceTypeRepository
.
RemoveRange
(
attendance_Types
.
ToArray
());
}
}
}
}
...
...
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