Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
27d4edc6
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
27d4edc6
编写于
9月 02, 2020
作者:
L
luojing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
考勤统计结果-排除不参加考勤的人员及组织
上级
b840df8d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
442 addition
and
10 deletion
+442
-10
o2server/x_attendance_assemble_control/src/main/java/com/x/attendance/assemble/control/factory/StatisticPersonForMonthFactory.java
...emble/control/factory/StatisticPersonForMonthFactory.java
+364
-0
o2server/x_attendance_assemble_control/src/main/java/com/x/attendance/assemble/control/service/AttendanceStatisticService.java
.../assemble/control/service/AttendanceStatisticService.java
+78
-10
未找到文件。
o2server/x_attendance_assemble_control/src/main/java/com/x/attendance/assemble/control/factory/StatisticPersonForMonthFactory.java
浏览文件 @
27d4edc6
...
...
@@ -16,6 +16,9 @@ import org.apache.commons.lang3.StringUtils;
import
com.x.attendance.assemble.control.AbstractFactory
;
import
com.x.attendance.assemble.control.Business
;
import
com.x.attendance.assemble.control.jaxrs.attendancestatistic.WrapInFilterStatisticPersonForMonth
;
import
com.x.attendance.assemble.control.service.AttendanceEmployeeConfigServiceAdv
;
import
com.x.attendance.assemble.control.service.UserManagerService
;
import
com.x.attendance.entity.AttendanceEmployeeConfig
;
import
com.x.attendance.entity.StatisticPersonForMonth
;
import
com.x.attendance.entity.StatisticPersonForMonth_
;
import
com.x.base.core.project.exception.ExceptionWhen
;
...
...
@@ -416,6 +419,46 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织,统计年月,计算组织内所有员工迟到数总和(排除不参加考勤的员工)
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Long
sumLateCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
lateTimes
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工出勤天数总和
...
...
@@ -450,6 +493,45 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工出勤天数总和(排除不参加考勤的员工)
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Double
sumAttendanceDayCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Double
>
cq
=
cb
.
createQuery
(
Double
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
onDutyDayCount
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工异常打卡数总和
* @param unitName
...
...
@@ -483,6 +565,46 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工异常打卡数总和(排除不参加考勤的员工)
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Long
sumAbNormalDutyCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
abNormalDutyCount
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工工时不足次数总和
* @param unitName
...
...
@@ -516,6 +638,46 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工工时不足次数总和(排除不参加考勤的员工)
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Long
sumLackOfTimeCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
lackOfTimeCount
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工早退次数总和
* @param unitName
...
...
@@ -549,6 +711,46 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工早退次数总和(排除不参加考勤的员工)
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Long
sumLeaveEarlyCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
leaveEarlyTimes
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工签退次数总和
* @param unitName
...
...
@@ -582,6 +784,46 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工签退次数总和
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Long
sumOffDutyCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
offDutyTimes
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工签到退次数总和
* @param unitName
...
...
@@ -615,6 +857,46 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工签到退次数总和(排除不参加考勤的员工)
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Long
sumOnDutyCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
cq
=
cb
.
createQuery
(
Long
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
onDutyTimes
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工请假天数总和
* @param unitName
...
...
@@ -648,6 +930,46 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工请假天数总和(排除不参加考勤的员工)
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Double
sumOnSelfHolidayCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Double
>
cq
=
cb
.
createQuery
(
Double
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
onSelfHolidayCount
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工缺勤天数总和
* @param unitName
...
...
@@ -683,4 +1005,46 @@ public class StatisticPersonForMonthFactory extends AbstractFactory {
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
/**
* 根据组织列表,统计年月,计算组织内所有员工缺勤天数总和(排除不参加考勤的员工)
* @param unitName
* @param sYear
* @param sMonth
* @return
* @throws Exception
*/
public
Double
sumAbsenceDayCountByUnitYearAndMonthUn
(
List
<
String
>
unitName
,
List
<
String
>
unUnitNameList
,
List
<
String
>
personNameList
,
String
sYear
,
String
sMonth
)
throws
Exception
{
if
(
unitName
==
null
||
unitName
.
size
()
==
0
){
logger
.
error
(
new
UnitNamesEmptyException
()
);
return
null
;
}
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
StatisticPersonForMonth
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Double
>
cq
=
cb
.
createQuery
(
Double
.
class
);
Root
<
StatisticPersonForMonth
>
root
=
cq
.
from
(
StatisticPersonForMonth
.
class
);
//查询总数
cq
.
select
(
cb
.
sum
(
root
.
get
(
StatisticPersonForMonth_
.
absenceDayCount
)
)
);
Predicate
p
=
root
.
get
(
StatisticPersonForMonth_
.
unitName
).
in
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
unUnitNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
unitName
),
cb
.
literal
(
unUnitNameList
)));
}
if
(
ListTools
.
isNotEmpty
(
personNameList
)){
p
=
cb
.
and
(
p
,
cb
.
isNotMember
(
root
.
get
(
StatisticPersonForMonth_
.
employeeName
),
cb
.
literal
(
personNameList
)));
}
if
(
sYear
==
null
||
sYear
.
isEmpty
()
){
logger
.
error
(
new
StatisticYearEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticYear
),
sYear
));
}
if
(
sMonth
==
null
||
sMonth
.
isEmpty
()
){
logger
.
error
(
new
StatisticMonthEmptyException
()
);
}
else
{
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
StatisticPersonForMonth_
.
statisticMonth
),
sMonth
));
}
return
em
.
createQuery
(
cq
.
where
(
p
)).
getSingleResult
();
}
}
\ No newline at end of file
o2server/x_attendance_assemble_control/src/main/java/com/x/attendance/assemble/control/service/AttendanceStatisticService.java
浏览文件 @
27d4edc6
...
...
@@ -5,9 +5,12 @@ import java.util.Date;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.attendance.assemble.control.Business
;
import
com.x.attendance.assemble.control.factory.AttendanceDetailStatisticFactory
;
import
com.x.attendance.assemble.control.factory.StatisticUnitForMonthFactory
;
import
com.x.attendance.entity.AttendanceEmployeeConfig
;
import
com.x.attendance.entity.AttendanceStatisticRequireLog
;
import
com.x.attendance.entity.AttendanceStatisticalCycle
;
import
com.x.attendance.entity.AttendanceWorkDayConfig
;
...
...
@@ -27,6 +30,7 @@ public class AttendanceStatisticService {
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
AttendanceStatisticService
.
class
);
private
UserManagerService
userManagerService
=
new
UserManagerService
();
protected
AttendanceEmployeeConfigServiceAdv
attendanceEmployeeConfigServiceAdv
=
new
AttendanceEmployeeConfigServiceAdv
();
/**
* 根据数据统计需求,进行员工每月考勤分析结果统计
...
...
@@ -229,7 +233,8 @@ public class AttendanceStatisticService {
Object
workDayCountForMonth
=
0.0
,
absenceDayCount
=
0.0
,
onSelfHolidayCount
=
0.0
;
String
cycleYear
=
null
,
cycleMonth
=
null
;
Business
business
=
null
;
List
<
String
>
unUnitNameList
=
new
ArrayList
<
String
>();
List
<
String
>
personNameList
=
new
ArrayList
<
String
>();
cycleYear
=
attendanceStatisticRequireLog
.
getStatisticYear
();
cycleMonth
=
attendanceStatisticRequireLog
.
getStatisticMonth
();
...
...
@@ -237,6 +242,8 @@ public class AttendanceStatisticService {
query_unitNames
.
add
(
unitName
);
try
{
unUnitNameList
=
getUnUnitNameList
();
personNameList
=
getUnPersonNameList
();
business
=
new
Business
(
emc
);
statisticUnitForMonth
=
new
StatisticUnitForMonth
();
statisticUnitForMonth
.
setUnitName
(
unitName
);
...
...
@@ -250,42 +257,51 @@ public class AttendanceStatisticService {
logger
.
warn
(
"根据组织名称["
+
unitName
+
"]未查询到组织信息。"
);
}
// 1.2.1 应出勤天数
workDayCountForMonth
=
business
.
getStatisticPersonForMonthFactory
().
sumAttendanceDayCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//workDayCountForMonth = business.getStatisticPersonForMonthFactory().sumAttendanceDayCountByUnitYearAndMonth(query_unitNames, cycleYear, cycleMonth);
workDayCountForMonth
=
business
.
getStatisticPersonForMonthFactory
().
sumAttendanceDayCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
double
count
=
0.0
;
if
(
workDayCountForMonth
!=
null
){
count
=
(
double
)
workDayCountForMonth
;
}
statisticUnitForMonth
.
setOnDutyEmployeeCount
(
count
);
// 1.2.3 异常打卡次数
abNormalDutyCount
=
business
.
getStatisticPersonForMonthFactory
().
sumAbNormalDutyCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//abNormalDutyCount = business.getStatisticPersonForMonthFactory().sumAbNormalDutyCountByUnitYearAndMonth( query_unitNames, cycleYear, cycleMonth );
abNormalDutyCount
=
business
.
getStatisticPersonForMonthFactory
().
sumAbNormalDutyCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
if
(
abNormalDutyCount
==
null
){
abNormalDutyCount
=
0L
;}
statisticUnitForMonth
.
setAbNormalDutyCount
((
long
)
abNormalDutyCount
);
// 1.2.4 工时不足次数
lackOfTimeCount
=
business
.
getStatisticPersonForMonthFactory
().
sumLackOfTimeCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//lackOfTimeCount = business.getStatisticPersonForMonthFactory().sumLackOfTimeCountByUnitYearAndMonth( query_unitNames, cycleYear, cycleMonth);
lackOfTimeCount
=
business
.
getStatisticPersonForMonthFactory
().
sumLackOfTimeCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
if
(
lackOfTimeCount
==
null
){
lackOfTimeCount
=
0L
;}
statisticUnitForMonth
.
setLackOfTimeCount
((
long
)
lackOfTimeCount
);
// 1.2.5 签到次数
onDutyTimes
=
business
.
getStatisticPersonForMonthFactory
().
sumOnDutyCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//onDutyTimes = business.getStatisticPersonForMonthFactory().sumOnDutyCountByUnitYearAndMonth( query_unitNames, cycleYear, cycleMonth);
onDutyTimes
=
business
.
getStatisticPersonForMonthFactory
().
sumOnDutyCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
if
(
onDutyTimes
==
null
){
onDutyTimes
=
0L
;}
statisticUnitForMonth
.
setOnDutyCount
(
(
long
)
onDutyTimes
);
// 1.2.6 签退次数
offDutyTimes
=
business
.
getStatisticPersonForMonthFactory
().
sumOffDutyCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//offDutyTimes = business.getStatisticPersonForMonthFactory().sumOffDutyCountByUnitYearAndMonth( query_unitNames, cycleYear, cycleMonth);
offDutyTimes
=
business
.
getStatisticPersonForMonthFactory
().
sumOffDutyCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
if
(
offDutyTimes
==
null
){
offDutyTimes
=
0L
;}
statisticUnitForMonth
.
setOffDutyCount
((
long
)
offDutyTimes
);
// 1.2.7 迟到次数
lateTimes
=
business
.
getStatisticPersonForMonthFactory
().
sumLateCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//lateTimes = business.getStatisticPersonForMonthFactory().sumLateCountByUnitYearAndMonth( query_unitNames, cycleYear, cycleMonth);
lateTimes
=
business
.
getStatisticPersonForMonthFactory
().
sumLateCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
if
(
lateTimes
==
null
){
lateTimes
=
0L
;}
statisticUnitForMonth
.
setLateCount
((
long
)
lateTimes
);
// 1.2.8 缺勤天数
absenceDayCount
=
business
.
getStatisticPersonForMonthFactory
().
sumAbsenceDayCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//absenceDayCount = business.getStatisticPersonForMonthFactory().sumAbsenceDayCountByUnitYearAndMonth( query_unitNames, cycleYear, cycleMonth);
absenceDayCount
=
business
.
getStatisticPersonForMonthFactory
().
sumAbsenceDayCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
if
(
absenceDayCount
==
null
){
absenceDayCount
=
0.0
;}
statisticUnitForMonth
.
setAbsenceDayCount
((
double
)
absenceDayCount
);
// 1.2.9 早退次数
leaveEarlyTimes
=
business
.
getStatisticPersonForMonthFactory
().
sumLeaveEarlyCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//leaveEarlyTimes = business.getStatisticPersonForMonthFactory().sumLeaveEarlyCountByUnitYearAndMonth( query_unitNames, cycleYear, cycleMonth);
leaveEarlyTimes
=
business
.
getStatisticPersonForMonthFactory
().
sumLeaveEarlyCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
if
(
leaveEarlyTimes
==
null
){
leaveEarlyTimes
=
0L
;}
statisticUnitForMonth
.
setLeaveEarlyCount
((
long
)
leaveEarlyTimes
);
// 1.2.10 休假天数
onSelfHolidayCount
=
business
.
getStatisticPersonForMonthFactory
().
sumOnSelfHolidayCountByUnitYearAndMonth
(
query_unitNames
,
cycleYear
,
cycleMonth
);
//onSelfHolidayCount = business.getStatisticPersonForMonthFactory().sumOnSelfHolidayCountByUnitYearAndMonth( query_unitNames, cycleYear, cycleMonth);
onSelfHolidayCount
=
business
.
getStatisticPersonForMonthFactory
().
sumOnSelfHolidayCountByUnitYearAndMonthUn
(
query_unitNames
,
unUnitNameList
,
personNameList
,
cycleYear
,
cycleMonth
);
if
(
onSelfHolidayCount
==
null
){
onSelfHolidayCount
=
0.0
;}
statisticUnitForMonth
.
setOnSelfHolidayCount
((
double
)
onSelfHolidayCount
);
...
...
@@ -861,4 +877,56 @@ public class AttendanceStatisticService {
Business
business
=
new
Business
(
emc
);
return
business
.
getStatisticTopUnitForDayFactory
().
list
(
ids
);
}
/**
* 获取不需要考勤的组织
* @return
* @throws Exception
*/
protected
List
<
String
>
getUnUnitNameList
()
throws
Exception
{
List
<
String
>
unUnitNameList
=
new
ArrayList
<
String
>();
List
<
AttendanceEmployeeConfig
>
attendanceEmployeeConfigs
=
attendanceEmployeeConfigServiceAdv
.
listByConfigType
(
"NOTREQUIRED"
);
if
(
ListTools
.
isNotEmpty
(
attendanceEmployeeConfigs
)){
for
(
AttendanceEmployeeConfig
attendanceEmployeeConfig
:
attendanceEmployeeConfigs
)
{
String
unitName
=
attendanceEmployeeConfig
.
getUnitName
();
String
employeeName
=
attendanceEmployeeConfig
.
getEmployeeName
();
if
(
StringUtils
.
isEmpty
(
employeeName
)
&&
StringUtils
.
isNotEmpty
(
unitName
)){
unUnitNameList
.
add
(
unitName
);
List
<
String
>
tempUnitNameList
=
userManagerService
.
listSubUnitNameWithParent
(
unitName
);
if
(
ListTools
.
isNotEmpty
(
tempUnitNameList
)){
for
(
String
tempUnit:
tempUnitNameList
){
if
(!
ListTools
.
contains
(
unUnitNameList
,
tempUnit
)){
unUnitNameList
.
add
(
tempUnit
);
}
}
}
}
}
}
return
unUnitNameList
;
}
/**
* 获取不需要考勤的人员
* @return
* @throws Exception
*/
protected
List
<
String
>
getUnPersonNameList
()
throws
Exception
{
List
<
String
>
personNameList
=
new
ArrayList
<
String
>();
List
<
AttendanceEmployeeConfig
>
attendanceEmployeeConfigs
=
attendanceEmployeeConfigServiceAdv
.
listByConfigType
(
"NOTREQUIRED"
);
if
(
ListTools
.
isNotEmpty
(
attendanceEmployeeConfigs
)){
for
(
AttendanceEmployeeConfig
attendanceEmployeeConfig
:
attendanceEmployeeConfigs
)
{
String
employeeName
=
attendanceEmployeeConfig
.
getEmployeeName
();
if
(
StringUtils
.
isNotEmpty
(
employeeName
)
&&
!
ListTools
.
contains
(
personNameList
,
employeeName
)){
personNameList
.
add
(
employeeName
);
}
}
}
return
personNameList
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录