Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
notes2.0
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zjm
notes2.0
Commits
680e4386
提交
680e4386
authored
4月 01, 2020
作者:
gongwenjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
考勤
上级
afb3bddb
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
594 行增加
和
62 行删除
+594
-62
TestController.java
...om/zjty/tynotes/attendance/controller/TestController.java
+9
-0
CardResultDao.java
...n/java/com/zjty/tynotes/attendance/dao/CardResultDao.java
+4
-1
AttendanceDetails.java
...com/zjty/tynotes/attendance/entity/AttendanceDetails.java
+25
-22
ApprovalInformationServiceImpl.java
...tendance/service/impl/ApprovalInformationServiceImpl.java
+358
-12
AttendanceDetailsServiceImpl.java
...attendance/service/impl/AttendanceDetailsServiceImpl.java
+25
-22
CardTask.java
.../main/java/com/zjty/tynotes/attendance/task/CardTask.java
+88
-5
TestController.java
.../java/com/zjty/tynotes/pas/controller/TestController.java
+82
-0
RoleDao.java
...s-pas/src/main/java/com/zjty/tynotes/pas/dao/RoleDao.java
+2
-0
UserServiceImpl.java
...va/com/zjty/tynotes/pas/service/impl/UserServiceImpl.java
+1
-0
没有找到文件。
notes-attendance/src/main/java/com/zjty/tynotes/attendance/controller/TestController.java
浏览文件 @
680e4386
...
@@ -74,4 +74,13 @@ public class TestController {
...
@@ -74,4 +74,13 @@ public class TestController {
return
ResponseEntity
.
ok
(
responses
);
return
ResponseEntity
.
ok
(
responses
);
}
}
@GetMapping
(
"/test12"
)
public
void
test12
(){
try
{
cardTask
.
calculate
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
notes-attendance/src/main/java/com/zjty/tynotes/attendance/dao/CardResultDao.java
浏览文件 @
680e4386
...
@@ -3,10 +3,13 @@ package com.zjty.tynotes.attendance.dao;
...
@@ -3,10 +3,13 @@ package com.zjty.tynotes.attendance.dao;
import
com.zjty.tynotes.attendance.entity.CardResult
;
import
com.zjty.tynotes.attendance.entity.CardResult
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
java.util.Date
;
import
java.util.List
;
/**
/**
* @Author gwj
* @Author gwj
* @create 2020/3/24 14:51
* @create 2020/3/24 14:51
*/
*/
public
interface
CardResultDao
extends
MongoRepository
<
CardResult
,
String
>
{
public
interface
CardResultDao
extends
MongoRepository
<
CardResult
,
String
>
{
List
<
CardResult
>
findAllByUserIdAndUserCheckTimeBetween
(
String
userId
,
Date
startTime
,
Date
endTime
);
}
}
notes-attendance/src/main/java/com/zjty/tynotes/attendance/entity/AttendanceDetails.java
浏览文件 @
680e4386
...
@@ -27,39 +27,42 @@ public class AttendanceDetails {
...
@@ -27,39 +27,42 @@ public class AttendanceDetails {
@ApiModelProperty
(
value
=
"用户id"
,
example
=
"eqweqw12312e"
)
@ApiModelProperty
(
value
=
"用户id"
,
example
=
"eqweqw12312e"
)
String
userId
;
String
userId
;
@ApiModelProperty
(
value
=
"平均工时"
,
example
=
"176"
)
// @ApiModelProperty(value = "平均工时",example = "176")
Integer
averageWorkHours
;
// Integer averageWorkHours;
//
// @ApiModelProperty(value = "应出勤天数",example = "22")
// Integer attendanceDay;
//
// @ApiModelProperty(value = "实际出勤天数",example = "22")
// Integer realAttendanceDay;
@ApiModelProperty
(
value
=
"
应出勤天数
"
,
example
=
"22"
)
@ApiModelProperty
(
value
=
"
是否出勤0为出勤/1为未出勤
"
,
example
=
"22"
)
Integer
a
ttendanceDay
;
Integer
isRealA
ttendanceDay
;
@ApiModelProperty
(
value
=
"
实际出勤天数"
,
example
=
"22
"
)
@ApiModelProperty
(
value
=
"
是否迟到0为迟到/1为未迟到"
,
example
=
"1
"
)
Integer
realAttendanc
eDay
;
Integer
isLat
eDay
;
@ApiModelProperty
(
value
=
"迟到天数"
,
example
=
"1"
)
@ApiModelProperty
(
value
=
"是否早退0为早退/1为未早退"
,
example
=
"1"
)
Integer
lateDay
;
Integer
isLeaveEarlyDay
;
@ApiModelProperty
(
value
=
"早退天数"
,
example
=
"1"
)
Integer
leaveEarlyDay
;
@ApiModelProperty
(
value
=
"缺卡次数"
,
example
=
"2"
)
@ApiModelProperty
(
value
=
"缺卡次数"
,
example
=
"2"
)
Integer
lessCard
;
Integer
lessCard
;
@ApiModelProperty
(
value
=
"
旷工天数
"
,
example
=
"2"
)
@ApiModelProperty
(
value
=
"
是否旷工0为旷工/1为未旷工
"
,
example
=
"2"
)
Integer
a
bsenteeismDay
;
Integer
isA
bsenteeismDay
;
@ApiModelProperty
(
value
=
"
加班时长
"
,
example
=
"10"
)
@ApiModelProperty
(
value
=
"
是否加班0为加班/1为未加班
"
,
example
=
"10"
)
Integer
w
orkOverHours
;
Integer
isW
orkOverHours
;
@ApiModelProperty
(
value
=
"
调休天数
"
,
example
=
"1"
)
@ApiModelProperty
(
value
=
"
是否调休0为调休/1为未调休
"
,
example
=
"1"
)
Float
p
aidLeaveDay
;
Float
isP
aidLeaveDay
;
@ApiModelProperty
(
value
=
"
病假天数
"
,
example
=
"1"
)
@ApiModelProperty
(
value
=
"
是否病假0为病假/1为未病假
"
,
example
=
"1"
)
Float
s
ickLeaveDay
;
Float
isS
ickLeaveDay
;
@ApiModelProperty
(
value
=
"
公出天数
"
,
example
=
"1"
)
@ApiModelProperty
(
value
=
"
是否公出0为公出/1为未公出
"
,
example
=
"1"
)
Float
o
utSideBusinessDay
;
Float
isO
utSideBusinessDay
;
@ApiModelProperty
(
value
=
"时间
,只需要精确到月份"
,
example
=
"2020-03
"
)
@ApiModelProperty
(
value
=
"时间
"
,
example
=
"2020-03-22
"
)
Date
date
;
Date
date
;
}
}
notes-attendance/src/main/java/com/zjty/tynotes/attendance/service/impl/ApprovalInformationServiceImpl.java
浏览文件 @
680e4386
...
@@ -15,6 +15,8 @@ import com.zjty.tynotes.pas.entity.Day;
...
@@ -15,6 +15,8 @@ import com.zjty.tynotes.pas.entity.Day;
import
com.zjty.tynotes.pas.entity.Department
;
import
com.zjty.tynotes.pas.entity.Department
;
import
com.zjty.tynotes.pas.service.IUserService
;
import
com.zjty.tynotes.pas.service.IUserService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -30,6 +32,8 @@ import java.util.*;
...
@@ -30,6 +32,8 @@ import java.util.*;
*/
*/
@Service
@Service
public
class
ApprovalInformationServiceImpl
implements
ApprovalInformationService
{
public
class
ApprovalInformationServiceImpl
implements
ApprovalInformationService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ApprovalInformationServiceImpl
.
class
);
@Autowired
@Autowired
private
ApprovalInformationDao
approvalInformationDao
;
private
ApprovalInformationDao
approvalInformationDao
;
@Autowired
@Autowired
...
@@ -51,18 +55,24 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
...
@@ -51,18 +55,24 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
if
(
approvalInformation
.
getApprovalType
().
equals
(
"调休"
)){
if
(
approvalInformation
.
getApprovalType
().
equals
(
"调休"
)){
String
userId
=
approvalInformation
.
getUserId
();
String
userId
=
approvalInformation
.
getUserId
();
AttendanceDetails
attendanceDetails
=
attendanceDetailsDao
.
findByUserId
(
userId
);
AttendanceDetails
attendanceDetails
=
attendanceDetailsDao
.
findByUserId
(
userId
);
Integer
workOverHours
=
attendanceDetails
.
getWorkOverHours
();
UserOverWork
userOverWork
=
userOverWorkDao
.
findByUserId
(
approvalInformation
.
getUserId
());
Long
workOverHours
=
userOverWork
.
getOverWorkHour
();
Date
leaveEndTime
=
approvalInformation
.
getLeaveEndTime
();
Date
leaveEndTime
=
approvalInformation
.
getLeaveEndTime
();
Date
leaveStartTime
=
approvalInformation
.
getLeaveStartTime
();
Date
leaveStartTime
=
approvalInformation
.
getLeaveStartTime
();
long
l
=
leaveEndTime
.
getTime
()
-
leaveStartTime
.
getTime
();
Long
aLong
=
0L
;
long
daytime
=
24
*
60
*
60
*
1000
;
try
{
aLong
=
computeTime
(
leaveEndTime
,
leaveStartTime
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"addApproval()方法中计算调休时长出错"
);
}
long
daytime
=
8
;
long
day
;
long
day
;
if
(
l
%
daytime
==
0
){
if
(
aLong
%
daytime
==
0
){
day
=
l
/
daytime
;
day
=
aLong
/
daytime
;
}
else
{
}
else
{
day
=
l
/
daytime
+
1
;
day
=
aLong
/
daytime
+
1
;
}
}
if
(
workOverHours
<=(
day
*
8
)){
if
(
workOverHours
<=(
aLong
)){
return
null
;
return
null
;
}
}
if
(
day
>
2
){
if
(
day
>
2
){
...
@@ -100,7 +110,26 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
...
@@ -100,7 +110,26 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
if
(
approvalInformation
.
getApprovalStatus
()!=
null
&&
approvalInformation
.
getApprovalStatus
().
equals
(
"0"
)){
if
(
approvalInformation
.
getApprovalStatus
()!=
null
&&
approvalInformation
.
getApprovalStatus
().
equals
(
"0"
)){
if
(
StringUtils
.
isNotBlank
(
approvalInformation
.
getApprovalType
())&&
approvalInformation
.
getApprovalType
().
equals
(
"调休"
)){
if
(
StringUtils
.
isNotBlank
(
approvalInformation
.
getApprovalType
())&&
approvalInformation
.
getApprovalType
().
equals
(
"调休"
)){
UserOverWork
userOverWork
=
userOverWorkDao
.
findByUserId
(
approvalInformation
.
getUserId
());
UserOverWork
userOverWork
=
userOverWorkDao
.
findByUserId
(
approvalInformation
.
getUserId
());
try
{
Long
aLong
=
computeTime
(
approvalInformation
.
getLeaveEndTime
(),
approvalInformation
.
getLeaveStartTime
());
Long
overWorkHour
=
userOverWork
.
getOverWorkHour
();
Long
timeLeft
=
overWorkHour
-
aLong
;
userOverWork
.
setOverWorkHour
(
timeLeft
);
userOverWorkDao
.
save
(
userOverWork
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"计算调休时长出错"
);
}
}
else
if
(
StringUtils
.
isNotBlank
(
approvalInformation
.
getApprovalType
())&&
approvalInformation
.
getApprovalType
().
equals
(
"加班"
)){
UserOverWork
userOverWork
=
userOverWorkDao
.
findByUserId
(
approvalInformation
.
getUserId
());
try
{
Long
aLong
=
computeTime
(
approvalInformation
.
getLeaveEndTime
(),
approvalInformation
.
getLeaveStartTime
());
Long
overWorkHour
=
userOverWork
.
getOverWorkHour
();
Long
timeLeft
=
overWorkHour
+
aLong
;
userOverWork
.
setOverWorkHour
(
timeLeft
);
userOverWorkDao
.
save
(
userOverWork
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
approvalInformation
.
setStatus
(
"1"
);
approvalInformation
.
setStatus
(
"1"
);
approvalInformation
.
setApprovalOne
(
"0"
);
approvalInformation
.
setApprovalOne
(
"0"
);
...
@@ -122,6 +151,29 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
...
@@ -122,6 +151,29 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
if
((
"1"
).
equals
(
parentDepartmentLevel
)||(
"2"
).
equals
(
parentDepartmentLevel
)){
if
((
"1"
).
equals
(
parentDepartmentLevel
)||(
"2"
).
equals
(
parentDepartmentLevel
)){
approvalInformation
.
setApprovalUserIdOne
(
userId
);
approvalInformation
.
setApprovalUserIdOne
(
userId
);
if
(
approvalInformation
.
getApprovalStatus
()!=
null
&&
approvalInformation
.
getApprovalStatus
().
equals
(
"0"
)){
if
(
approvalInformation
.
getApprovalStatus
()!=
null
&&
approvalInformation
.
getApprovalStatus
().
equals
(
"0"
)){
if
(
StringUtils
.
isNotBlank
(
approvalInformation
.
getApprovalType
())&&
approvalInformation
.
getApprovalType
().
equals
(
"调休"
)){
UserOverWork
userOverWork
=
userOverWorkDao
.
findByUserId
(
approvalInformation
.
getUserId
());
try
{
Long
aLong
=
computeTime
(
approvalInformation
.
getLeaveEndTime
(),
approvalInformation
.
getLeaveStartTime
());
Long
overWorkHour
=
userOverWork
.
getOverWorkHour
();
Long
timeLeft
=
overWorkHour
-
aLong
;
userOverWork
.
setOverWorkHour
(
timeLeft
);
userOverWorkDao
.
save
(
userOverWork
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"计算调休时长出错"
);
}
}
else
if
(
StringUtils
.
isNotBlank
(
approvalInformation
.
getApprovalType
())&&
approvalInformation
.
getApprovalType
().
equals
(
"加班"
)){
UserOverWork
userOverWork
=
userOverWorkDao
.
findByUserId
(
approvalInformation
.
getUserId
());
try
{
Long
aLong
=
computeTime
(
approvalInformation
.
getLeaveEndTime
(),
approvalInformation
.
getLeaveStartTime
());
Long
overWorkHour
=
userOverWork
.
getOverWorkHour
();
Long
timeLeft
=
overWorkHour
+
aLong
;
userOverWork
.
setOverWorkHour
(
timeLeft
);
userOverWorkDao
.
save
(
userOverWork
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
approvalInformation
.
setStatus
(
"1"
);
approvalInformation
.
setStatus
(
"1"
);
approvalInformation
.
setApprovalOne
(
"0"
);
approvalInformation
.
setApprovalOne
(
"0"
);
}
else
if
(
approvalInformation
.
getApprovalStatus
()!=
null
&&
approvalInformation
.
getApprovalStatus
().
equals
(
"1"
)){
}
else
if
(
approvalInformation
.
getApprovalStatus
()!=
null
&&
approvalInformation
.
getApprovalStatus
().
equals
(
"1"
)){
...
@@ -188,26 +240,216 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
...
@@ -188,26 +240,216 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
return
approvalInformationList
;
return
approvalInformationList
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Config
config
=
new
Config
(
"1"
,
"09:00:00"
,
"17:00:00"
,
"2"
,
"3"
,
"15"
,
"17"
,
"1"
,
"1"
,
"1"
,
"1"
,
"1"
,
"1"
,
"1"
,
"1"
,
"1"
,
"1"
,
"1"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd 00:00:00"
);
SimpleDateFormat
sdf2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
date
=
"2020-03-29 00:00:00"
;
String
date2
=
"2020-03-30 00:00:00"
;
String
date3
=
"2020-03-31 00:00:00"
;
Date
parse
=
sdf
.
parse
(
date
);
Date
parse1
=
sdf
.
parse
(
date2
);
Date
parse2
=
sdf
.
parse
(
date3
);
Day
day
=
new
Day
(
"1"
,
parse
,
"1"
);
Day
day1
=
new
Day
(
"2"
,
parse1
,
"0"
);
Day
day2
=
new
Day
(
"3"
,
parse2
,
"0"
);
List
<
Day
>
days
=
new
ArrayList
<>();
days
.
add
(
day
);
days
.
add
(
day1
);
days
.
add
(
day2
);
String
start
=
"2020-03-29 18:00:00"
;
String
end
=
"2020-03-31 19:00:00"
;
Date
startTime
=
sdf2
.
parse
(
start
);
Date
endTime
=
sdf2
.
parse
(
end
);
ApprovalInformationServiceImpl
approvalInformationService
=
new
ApprovalInformationServiceImpl
();
Long
aLong
=
approvalInformationService
.
computeTime2
(
startTime
,
endTime
,
config
,
days
);
System
.
out
.
println
(
aLong
);
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 17:00:00");
// Date date = new Date();
// String format = sdf.format(date);
// Date parse = sdf.parse(format);
// System.out.println(parse);
}
/**
/**
* 计算调休时长
* 计算调休时长
,请假时长
*/
*/
private
Long
computeTime
(
Date
startTime
,
Date
endTime
)
throws
Exception
{
private
Long
computeTime
(
Date
startTime
,
Date
endTime
)
throws
Exception
{
Config
config
=
configDao
.
findAll
().
get
(
0
);
Config
config
=
configDao
.
findAll
().
get
(
0
);
String
workTime
=
config
.
getWorkTime
();
//上班时间
String
workTime
=
config
.
getWorkTime
();
//上班时间
String
afterWorkTime
=
config
.
getAfterWorkTime
();
//下班时间
String
afterWorkTime
=
config
.
getAfterWorkTime
();
//下班时间
SimpleDateFormat
sdf5
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf3
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
sdf3
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd "
+
workTime
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd "
+
workTime
);
SimpleDateFormat
sdf2
=
new
SimpleDateFormat
(
"yyyy-MM-dd "
+
afterWorkTime
);
SimpleDateFormat
sdf2
=
new
SimpleDateFormat
(
"yyyy-MM-dd "
+
afterWorkTime
);
SimpleDateFormat
sdf4
=
new
SimpleDateFormat
(
"yyyy-MM-dd 00:00:00"
);
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar1
=
Calendar
.
getInstance
();
Calendar
calendar1
=
Calendar
.
getInstance
();
String
format
=
sdf
.
format
(
startTime
);
String
format
=
sdf
.
format
(
startTime
);
Date
parse
=
sdf
.
parse
(
format
);
Date
parse
=
sdf
5
.
parse
(
format
);
String
format1
=
sdf2
.
format
(
startTime
);
String
format1
=
sdf2
.
format
(
startTime
);
Date
parse1
=
sdf
2
.
parse
(
format1
);
Date
parse1
=
sdf
5
.
parse
(
format1
);
calendar1
.
setTime
(
parse1
);
calendar1
.
setTime
(
parse1
);
calendar
.
setTime
(
parse
);
//设置上班时间
calendar
.
setTime
(
parse
);
//设置上班时间
String
format2
=
sdf3
.
format
(
startTime
);
String
format3
=
sdf3
.
format
(
endTime
);
long
hours
=
0
;
long
hour
=
60
*
1000
*
60
;
if
(
startTime
.
before
(
calendar
.
getTime
())){
if
(
format2
.
equals
(
format3
)){
String
format4
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse2
=
sdf4
.
parse
(
format4
);
Day
day
=
dayDao
.
findByDate
(
parse2
);
if
(
day
!=
null
&&
day
.
getStatus
().
equals
(
"0"
)){
Date
leaveWork
=
calendar1
.
getTime
();
if
(
endTime
.
before
(
leaveWork
)){
long
miSecond
=
endTime
.
getTime
()
-
calendar
.
getTime
().
getTime
();
if
(
miSecond
%
hour
==
0
){
hours
=
miSecond
/
hour
;
}
else
{
hours
=
miSecond
/
hour
+
1
;
}
}
else
{
hours
=
8
;
}
}
}
else
{
String
format4
=
sdf4
.
format
(
startTime
);
Date
parse2
=
sdf4
.
parse
(
format4
);
Day
day
=
dayDao
.
findByDate
(
parse2
);
if
(
day
!=
null
&&
day
.
getStatus
().
equals
(
"0"
)){
hours
=
8
;
}
else
{
hours
=
0
;
}
while
(
true
){
String
format5
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse3
=
sdf4
.
parse
(
format5
);
Day
day1
=
dayDao
.
findByDate
(
parse3
);
if
(
day1
!=
null
&&
day1
.
getStatus
().
equals
(
"0"
)){
calendar
.
add
(
Calendar
.
DATE
,
1
);
calendar1
.
add
(
Calendar
.
DATE
,
1
);
Date
leaveWork
=
calendar1
.
getTime
();
Date
startWorkTime
=
calendar
.
getTime
();
if
(
endTime
.
before
(
startWorkTime
)){
return
hours
;
}
else
{
if
(
endTime
.
before
(
leaveWork
)){
long
miSecond
=
endTime
.
getTime
()
-
calendar
.
getTime
().
getTime
();
if
(
miSecond
%
hour
==
0
){
hours
=
miSecond
/
hour
+
hours
;
}
else
{
hours
=
miSecond
/
hour
+
1
+
hours
;
}
return
hours
;
}
else
{
hours
+=
8
;
}
}
}
}
}
}
else
{
if
(
format2
.
equals
(
format3
)){
String
format4
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse2
=
sdf4
.
parse
(
format4
);
Day
day
=
dayDao
.
findByDate
(
parse2
);
if
(
day
!=
null
&&
day
.
getStatus
().
equals
(
"0"
)){
Date
leaveWork
=
calendar1
.
getTime
();
if
(
endTime
.
before
(
leaveWork
)){
long
miSecond
=
endTime
.
getTime
()
-
startTime
.
getTime
();
if
(
miSecond
%
hour
==
0
){
hours
=
miSecond
/
hour
;
}
else
{
hours
=
miSecond
/
hour
+
1
;
}
}
else
{
long
miSecond
=
leaveWork
.
getTime
()
-
startTime
.
getTime
();
if
(
miSecond
%
hour
==
0
){
hours
=
miSecond
/
hour
;
}
else
{
hours
=
miSecond
/
hour
+
1
;
}
}
}
}
else
{
String
format4
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse2
=
sdf4
.
parse
(
format4
);
Day
day
=
dayDao
.
findByDate
(
parse2
);
if
(
day
!=
null
&&
day
.
getStatus
().
equals
(
"0"
)){
long
miSecond1
=
calendar1
.
getTime
().
getTime
()
-
startTime
.
getTime
();
if
(
miSecond1
%
hour
==
0
){
hours
=
miSecond1
/
hour
;
}
else
{
hours
=
miSecond1
/
hour
+
1
;
}
}
else
{
hours
=
0
;
}
while
(
true
){
String
format5
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse3
=
sdf4
.
parse
(
format5
);
Day
day1
=
dayDao
.
findByDate
(
parse3
);
if
(
day1
!=
null
&&
day1
.
getStatus
().
equals
(
"0"
)){
calendar
.
add
(
Calendar
.
DATE
,
1
);
calendar1
.
add
(
Calendar
.
DATE
,
1
);
Date
leaveWork
=
calendar1
.
getTime
();
Date
startWorkTime
=
calendar
.
getTime
();
if
(
endTime
.
before
(
startWorkTime
)){
return
hours
;
}
else
{
if
(
endTime
.
before
(
leaveWork
)){
long
miSecond
=
endTime
.
getTime
()
-
calendar
.
getTime
().
getTime
();
if
(
miSecond
%
hour
==
0
){
hours
=
miSecond
/
hour
+
hours
;
}
else
{
hours
=
miSecond
/
hour
+
1
+
hours
;
}
return
hours
;
}
else
{
hours
+=
8
;
}
}
}
}
}
}
return
hours
;
}
/**
* 计算调休时长
*/
private
Long
computeTime2
(
Date
startTime
,
Date
endTime
,
Config
config
,
List
<
Day
>
days
)
throws
Exception
{
String
workTime
=
config
.
getWorkTime
();
//上班时间
String
afterWorkTime
=
config
.
getAfterWorkTime
();
//下班时间
SimpleDateFormat
sdf5
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf3
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd "
+
workTime
);
SimpleDateFormat
sdf2
=
new
SimpleDateFormat
(
"yyyy-MM-dd "
+
afterWorkTime
);
SimpleDateFormat
sdf4
=
new
SimpleDateFormat
(
"yyyy-MM-dd 00:00:00"
);
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar1
=
Calendar
.
getInstance
();
String
format
=
sdf
.
format
(
startTime
);
Date
parse
=
sdf5
.
parse
(
format
);
String
format1
=
sdf2
.
format
(
startTime
);
Date
parse1
=
sdf5
.
parse
(
format1
);
calendar1
.
setTime
(
parse1
);
calendar
.
setTime
(
parse
);
//设置上班时间
String
format2
=
sdf3
.
format
(
startTime
);
String
format2
=
sdf3
.
format
(
startTime
);
String
format3
=
sdf3
.
format
(
endTime
);
String
format3
=
sdf3
.
format
(
endTime
);
...
@@ -215,6 +457,15 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
...
@@ -215,6 +457,15 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
long
hour
=
60
*
1000
*
60
;
long
hour
=
60
*
1000
*
60
;
if
(
startTime
.
before
(
calendar
.
getTime
())){
if
(
startTime
.
before
(
calendar
.
getTime
())){
if
(
format2
.
equals
(
format3
)){
if
(
format2
.
equals
(
format3
)){
String
format4
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse2
=
sdf4
.
parse
(
format4
);
Day
day
=
null
;
for
(
Day
day1
:
days
)
{
if
(
day1
.
getDate
().
equals
(
parse2
)){
day
=
day1
;
}
}
if
(
day
!=
null
&&
day
.
getStatus
().
equals
(
"0"
)){
Date
leaveWork
=
calendar1
.
getTime
();
Date
leaveWork
=
calendar1
.
getTime
();
if
(
endTime
.
before
(
leaveWork
)){
if
(
endTime
.
before
(
leaveWork
)){
long
miSecond
=
endTime
.
getTime
()
-
calendar
.
getTime
().
getTime
();
long
miSecond
=
endTime
.
getTime
()
-
calendar
.
getTime
().
getTime
();
...
@@ -226,11 +477,34 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
...
@@ -226,11 +477,34 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
}
else
{
}
else
{
hours
=
8
;
hours
=
8
;
}
}
}
}
else
{
}
else
{
String
format4
=
sdf4
.
format
(
startTime
);
Date
parse2
=
sdf4
.
parse
(
format4
);
Day
day
=
null
;
for
(
Day
day1
:
days
)
{
if
(
day1
.
getDate
().
equals
(
parse2
)){
day
=
day1
;
}
}
if
(
day
!=
null
&&
day
.
getStatus
().
equals
(
"0"
)){
hours
=
8
;
hours
=
8
;
}
else
{
hours
=
0
;
}
while
(
true
){
while
(
true
){
calendar
.
add
(
Calendar
.
DATE
,
1
);
calendar
.
add
(
Calendar
.
DATE
,
1
);
calendar1
.
add
(
Calendar
.
DATE
,
1
);
calendar1
.
add
(
Calendar
.
DATE
,
1
);
String
format5
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse3
=
sdf4
.
parse
(
format5
);
Day
day1
=
null
;
for
(
Day
day2
:
days
)
{
if
(
day2
.
getDate
().
equals
(
parse3
)){
day1
=
day2
;
}
}
if
(
day1
!=
null
&&
day1
.
getStatus
().
equals
(
"0"
)){
Date
leaveWork
=
calendar1
.
getTime
();
Date
leaveWork
=
calendar1
.
getTime
();
Date
startWorkTime
=
calendar
.
getTime
();
Date
startWorkTime
=
calendar
.
getTime
();
if
(
endTime
.
before
(
startWorkTime
)){
if
(
endTime
.
before
(
startWorkTime
)){
...
@@ -243,14 +517,25 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
...
@@ -243,14 +517,25 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
}
else
{
}
else
{
hours
=
miSecond
/
hour
+
1
+
hours
;
hours
=
miSecond
/
hour
+
1
+
hours
;
}
}
return
hours
;
}
else
{
}
else
{
hours
+=
8
;
hours
+=
8
;
}
}
}
}
}
}
}
}
}
}
else
{
}
else
{
if
(
format2
.
equals
(
format3
)){
if
(
format2
.
equals
(
format3
)){
String
format4
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse2
=
sdf4
.
parse
(
format4
);
Day
day
=
null
;
for
(
Day
day1
:
days
)
{
if
(
day1
.
getDate
().
equals
(
parse2
)){
day
=
day1
;
}
}
if
(
day
!=
null
&&
day
.
getStatus
().
equals
(
"0"
)){
Date
leaveWork
=
calendar1
.
getTime
();
Date
leaveWork
=
calendar1
.
getTime
();
if
(
endTime
.
before
(
leaveWork
)){
if
(
endTime
.
before
(
leaveWork
)){
long
miSecond
=
endTime
.
getTime
()
-
startTime
.
getTime
();
long
miSecond
=
endTime
.
getTime
()
-
startTime
.
getTime
();
...
@@ -268,10 +553,71 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
...
@@ -268,10 +553,71 @@ public class ApprovalInformationServiceImpl implements ApprovalInformationServic
}
}
}
}
}
}
}
else
{
String
format4
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse2
=
sdf4
.
parse
(
format4
);
Day
day
=
null
;
for
(
Day
day1
:
days
)
{
if
(
day1
.
getDate
().
equals
(
parse2
)){
day
=
day1
;
}
}
if
(
day
!=
null
&&
day
.
getStatus
().
equals
(
"0"
)){
long
miSecond1
=
calendar1
.
getTime
().
getTime
()
-
startTime
.
getTime
();
if
(
miSecond1
%
hour
==
0
){
hours
=
miSecond1
/
hour
;
}
else
{
hours
=
miSecond1
/
hour
+
1
;
}
}
else
{
hours
=
0
;
}
while
(
true
){
calendar
.
add
(
Calendar
.
DATE
,
1
);
calendar1
.
add
(
Calendar
.
DATE
,
1
);
String
format5
=
sdf4
.
format
(
calendar
.
getTime
());
Date
parse3
=
sdf4
.
parse
(
format5
);
Day
day1
=
null
;
for
(
Day
day2
:
days
)
{
if
(
day2
.
getDate
().
equals
(
parse3
)){
day1
=
day2
;
}
}
if
(
day1
!=
null
&&
day1
.
getStatus
().
equals
(
"0"
)){
Date
leaveWork
=
calendar1
.
getTime
();
Date
startWorkTime
=
calendar
.
getTime
();
if
(
endTime
.
before
(
startWorkTime
)){
return
hours
;
}
else
{
if
(
endTime
.
before
(
leaveWork
)){
long
miSecond
=
endTime
.
getTime
()
-
calendar
.
getTime
().
getTime
();
if
(
miSecond
%
hour
==
0
){
hours
=
miSecond
/
hour
+
hours
;
}
else
{
hours
=
miSecond
/
hour
+
1
+
hours
;
}
return
hours
;
}
else
{
hours
+=
8
;
}
}
}
}
return
null
;
}
}
}
}
return
hours
;
}
}
}
notes-attendance/src/main/java/com/zjty/tynotes/attendance/service/impl/AttendanceDetailsServiceImpl.java
浏览文件 @
680e4386
...
@@ -5,6 +5,8 @@ import com.zjty.tynotes.attendance.entity.AttendanceDetails;
...
@@ -5,6 +5,8 @@ import com.zjty.tynotes.attendance.entity.AttendanceDetails;
import
com.zjty.tynotes.attendance.entity.vo.UserAttenVo
;
import
com.zjty.tynotes.attendance.entity.vo.UserAttenVo
;
import
com.zjty.tynotes.attendance.entity.vo.request.AttenRequest
;
import
com.zjty.tynotes.attendance.entity.vo.request.AttenRequest
;
import
com.zjty.tynotes.attendance.service.AttendanceDetailsService
;
import
com.zjty.tynotes.attendance.service.AttendanceDetailsService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -19,6 +21,7 @@ import java.util.List;
...
@@ -19,6 +21,7 @@ import java.util.List;
*/
*/
@Service
@Service
public
class
AttendanceDetailsServiceImpl
implements
AttendanceDetailsService
{
public
class
AttendanceDetailsServiceImpl
implements
AttendanceDetailsService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AttendanceDetailsServiceImpl
.
class
);
@Autowired
@Autowired
private
AttendanceDetailsDao
attendanceDetailsDao
;
private
AttendanceDetailsDao
attendanceDetailsDao
;
...
@@ -62,29 +65,29 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
...
@@ -62,29 +65,29 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
float
sickLeaveDay
=
0
;
float
sickLeaveDay
=
0
;
float
outSideBusinessDay
=
0
;
float
outSideBusinessDay
=
0
;
for
(
AttendanceDetails
attendanceDetails1
:
attendanceDetails
)
{
for
(
AttendanceDetails
attendanceDetails1
:
attendanceDetails
)
{
averageWorkHours
+=
attendanceDetails1
.
getAverageWorkHours
();
//
averageWorkHours += attendanceDetails1.getAverageWorkHours();
attendanceDay
+=
attendanceDetails1
.
getAttendanceDay
();
//
attendanceDay += attendanceDetails1.getAttendanceDay();
realAttendanceDay
+=
attendanceDetails1
.
getRealAttendanceDay
();
//
realAttendanceDay += attendanceDetails1.getRealAttendanceDay();
lateDay
+=
attendanceDetails1
.
getLateDay
();
//
lateDay += attendanceDetails1.getLateDay();
leaveEarlyDay
+=
attendanceDetails1
.
getLeaveEarlyDay
();
//
leaveEarlyDay += attendanceDetails1.getLeaveEarlyDay();
lessCard
+=
attendanceDetails1
.
getLessCard
();
//
lessCard += attendanceDetails1.getLessCard();
absenteeismDay
+=
attendanceDetails1
.
getAbsenteeismDay
();
//
absenteeismDay += attendanceDetails1.getAbsenteeismDay();
workOverHours
+=
attendanceDetails1
.
getWorkOverHours
();
//
workOverHours += attendanceDetails1.getWorkOverHours();
paidLeaveDay
+=
attendanceDetails1
.
getPaidLeaveDay
();
//
paidLeaveDay += attendanceDetails1.getPaidLeaveDay();
sickLeaveDay
+=
attendanceDetails1
.
getSickLeaveDay
();
//
sickLeaveDay += attendanceDetails1.getSickLeaveDay();
outSideBusinessDay
+=
attendanceDetails1
.
getOutSideBusinessDay
();
//
outSideBusinessDay += attendanceDetails1.getOutSideBusinessDay();
}
}
userAttenVo
.
setAverageWorkHours
(
averageWorkHours
);
//
userAttenVo.setAverageWorkHours(averageWorkHours);
userAttenVo
.
setAttendanceDay
(
attendanceDay
);
//
userAttenVo.setAttendanceDay(attendanceDay);
userAttenVo
.
setRealAttendanceDay
(
realAttendanceDay
);
//
userAttenVo.setRealAttendanceDay(realAttendanceDay);
userAttenVo
.
setLateDay
(
lateDay
);
//
userAttenVo.setLateDay(lateDay);
userAttenVo
.
setLeaveEarlyDay
(
leaveEarlyDay
);
//
userAttenVo.setLeaveEarlyDay(leaveEarlyDay);
userAttenVo
.
setLessCard
(
lessCard
);
//
userAttenVo.setLessCard(lessCard);
userAttenVo
.
setAbsenteeismDay
(
absenteeismDay
);
//
userAttenVo.setAbsenteeismDay(absenteeismDay);
userAttenVo
.
setWorkOverHours
(
workOverHours
);
//
userAttenVo.setWorkOverHours(workOverHours);
userAttenVo
.
setPaidLeaveDay
(
paidLeaveDay
);
//
userAttenVo.setPaidLeaveDay(paidLeaveDay);
userAttenVo
.
setSickLeaveDay
(
sickLeaveDay
);
//
userAttenVo.setSickLeaveDay(sickLeaveDay);
userAttenVo
.
setOutSideBusinessDay
(
outSideBusinessDay
);
//
userAttenVo.setOutSideBusinessDay(outSideBusinessDay);
userAttenVo
.
setName
(
""
);
userAttenVo
.
setName
(
""
);
return
userAttenVo
;
return
userAttenVo
;
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
...
...
notes-attendance/src/main/java/com/zjty/tynotes/attendance/task/CardTask.java
浏览文件 @
680e4386
...
@@ -9,6 +9,11 @@ import com.zjty.tynotes.attendance.dao.CardResultDao;
...
@@ -9,6 +9,11 @@ import com.zjty.tynotes.attendance.dao.CardResultDao;
import
com.zjty.tynotes.attendance.dao.DingUserDao
;
import
com.zjty.tynotes.attendance.dao.DingUserDao
;
import
com.zjty.tynotes.attendance.entity.CardResult
;
import
com.zjty.tynotes.attendance.entity.CardResult
;
import
com.zjty.tynotes.attendance.entity.DingUser
;
import
com.zjty.tynotes.attendance.entity.DingUser
;
import
com.zjty.tynotes.pas.dao.ConfigDao
;
import
com.zjty.tynotes.pas.dao.DayDao
;
import
com.zjty.tynotes.pas.dao.PasUserDao
;
import
com.zjty.tynotes.pas.entity.Day
;
import
com.zjty.tynotes.pas.entity.User
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -37,12 +42,25 @@ public class CardTask {
...
@@ -37,12 +42,25 @@ public class CardTask {
private
DingUserDao
dingUserDao
;
private
DingUserDao
dingUserDao
;
@Autowired
@Autowired
private
CardResultDao
cardResultDao
;
private
CardResultDao
cardResultDao
;
@Autowired
private
DayDao
dayDao
;
@Autowired
private
PasUserDao
pasUserDao
;
/**
/**
* 定时任务,定时获取打卡信息
* 定时任务,定时获取打卡信息
.计算前天的个人考勤信息情况
*/
*/
@Scheduled
(
cron
=
"0 59 23 * * ? "
)
@Scheduled
(
cron
=
"0 59 23 * * ? "
)
public
List
<
CardResult
>
getCardDetails
(){
public
List
<
CardResult
>
getCardDetails
(){
List
<
User
>
users
=
pasUserDao
.
findAll
();
List
<
User
>
userList
=
new
ArrayList
<>();
if
(
users
!=
null
){
users
.
forEach
(
user
->
{
if
(!
user
.
getUsername
().
equals
(
"root"
)){
userList
.
add
(
user
);
}
});
}
List
<
CardResult
>
cardResults
=
new
ArrayList
<>();
List
<
CardResult
>
cardResults
=
new
ArrayList
<>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd 00:00:00"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd 00:00:00"
);
SimpleDateFormat
sdf2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
...
@@ -52,7 +70,7 @@ public class CardTask {
...
@@ -52,7 +70,7 @@ public class CardTask {
Date
time
=
calendar
.
getTime
();
Date
time
=
calendar
.
getTime
();
String
startTime
=
sdf
.
format
(
time
);
String
startTime
=
sdf
.
format
(
time
);
String
endTime
=
sdf
2
.
format
(
new
Date
());
String
endTime
=
sdf
.
format
(
new
Date
());
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/attendance/list"
);
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/attendance/list"
);
OapiAttendanceListRequest
request
=
new
OapiAttendanceListRequest
();
OapiAttendanceListRequest
request
=
new
OapiAttendanceListRequest
();
...
@@ -85,6 +103,7 @@ public class CardTask {
...
@@ -85,6 +103,7 @@ public class CardTask {
});
});
}
}
List
<
CardResult
>
cardResults1
=
cardResultDao
.
saveAll
(
cardResults
);
List
<
CardResult
>
cardResults1
=
cardResultDao
.
saveAll
(
cardResults
);
computerPersonAttenDanceDay
(
startTime
,
endTime
,
userList
,
cardResults1
);
return
cardResults1
;
return
cardResults1
;
}
}
}
catch
(
ApiException
e
)
{
}
catch
(
ApiException
e
)
{
...
@@ -93,12 +112,76 @@ public class CardTask {
...
@@ -93,12 +112,76 @@ public class CardTask {
return
null
;
return
null
;
}
}
private
void
computerPersonAttenDanceDay
(
String
startTime
,
String
endTime
,
List
<
User
>
userList
,
List
<
CardResult
>
cardResults1
)
{
if
(
userList
!=
null
){
userList
.
forEach
(
user
->
{
if
(
cardResults1
!=
null
){
List
<
CardResult
>
cardResults
=
new
ArrayList
<>();
cardResults1
.
forEach
(
cardResult
->
{
String
userId
=
cardResult
.
getUserId
();
if
(
user
.
getId
().
equals
(
userId
)){
cardResults
.
add
(
cardResult
);
}
});
cardResults
.
forEach
(
cardResult
->
{
});
}
});
}
}
/**
/**
* 定时任务,定时
获取打卡信息
* 定时任务,定时
进行运算
*/
*/
@Scheduled
(
cron
=
"0 59 23 * * ? "
)
@Scheduled
(
cron
=
"0/30 * * * * ? "
)
public
void
calculate
(){
public
void
calculate
()
throws
Exception
{
int
attendanceDay
=
0
;
//应出勤天数
int
averageWorkHours
=
0
;
//平均工时
int
realAttendanceDay
=
0
;
//实际出勤天数
Calendar
calendar
=
Calendar
.
getInstance
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
format
=
sdf
.
format
(
new
Date
());
Date
parse
=
sdf
.
parse
(
format
);
//计算这个月的应出勤天数
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
Date
startTime
=
calendar
.
getTime
();
calendar
.
add
(
Calendar
.
MONTH
,
1
);
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
0
);
Date
endTime
=
calendar
.
getTime
();
List
<
Day
>
days
=
dayDao
.
findAllByStatusAndDateBetween
(
"0"
,
startTime
,
endTime
);
if
(
days
!=
null
){
attendanceDay
=
days
.
size
();
}
List
<
User
>
users
=
pasUserDao
.
findAll
();
List
<
User
>
userList
=
new
ArrayList
<>();
if
(
users
!=
null
){
users
.
forEach
(
user
->
{
if
(!
user
.
getUsername
().
equals
(
"root"
)){
userList
.
add
(
user
);
List
<
CardResult
>
cardResults
=
cardResultDao
.
findAllByUserIdAndUserCheckTimeBetween
(
user
.
getId
(),
startTime
,
endTime
);
}
}
});
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Calendar
calendar
=
Calendar
.
getInstance
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
// Date date = new Date();
String
date
=
"2020-03-29 11:11:11"
;
String
format
=
sdf
.
format
(
new
Date
());
//计算这个月的应出勤天数
Date
parse
=
sdf
.
parse
(
date
);
calendar
.
setTime
(
parse
);
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
Date
time
=
calendar
.
getTime
();
System
.
out
.
println
(
time
);
calendar
.
add
(
Calendar
.
MONTH
,
1
);
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
0
);
Date
time1
=
calendar
.
getTime
();
System
.
out
.
println
(
"time1:"
+
time1
);
}
}
}
notes-pas/src/main/java/com/zjty/tynotes/pas/controller/TestController.java
0 → 100644
浏览文件 @
680e4386
package
com
.
zjty
.
tynotes
.
pas
.
controller
;
import
com.zjty.tynotes.misc.config.AutoDocument
;
import
com.zjty.tynotes.pas.dao.AuthorityDao
;
import
com.zjty.tynotes.pas.dao.DayDao
;
import
com.zjty.tynotes.pas.dao.RoleAuthorityDao
;
import
com.zjty.tynotes.pas.dao.RoleDao
;
import
com.zjty.tynotes.pas.entity.Authority
;
import
com.zjty.tynotes.pas.entity.Day
;
import
com.zjty.tynotes.pas.entity.Role
;
import
com.zjty.tynotes.pas.entity.RoleAuthority
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Author gwj
* @create 2020/4/1 10:56
*/
@Api
(
tags
=
"用户管理权限管理模块"
,
protocols
=
"http"
)
@RestController
@RequestMapping
(
"/pas/user"
)
@AutoDocument
public
class
TestController
{
@Autowired
private
DayDao
dayDao
;
@Autowired
private
AuthorityDao
authorityDao
;
@Autowired
private
RoleDao
roleDao
;
@Autowired
private
RoleAuthorityDao
roleAuthorityDao
;
@GetMapping
(
"/test"
)
public
void
calculate
()
throws
Exception
{
Calendar
calendar
=
Calendar
.
getInstance
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
format
=
sdf
.
format
(
new
Date
());
Date
parse
=
sdf
.
parse
(
format
);
//计算这个月的应出勤天数
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
Date
startTime
=
calendar
.
getTime
();
calendar
.
add
(
Calendar
.
MONTH
,
1
);
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
Date
endTime
=
calendar
.
getTime
();
List
<
Day
>
days
=
dayDao
.
findAllByStatusAndDateBetween
(
"0"
,
startTime
,
endTime
);
if
(
days
!=
null
){
System
.
out
.
println
(
days
.
size
());
}
}
@GetMapping
(
"/test"
)
public
void
addAuthority
()
throws
Exception
{
List
<
String
>
authorityName
=
new
ArrayList
<>();
authorityName
.
add
(
"用户管理"
);
authorityName
.
add
(
"权限管理"
);
authorityName
.
add
(
"部门管理"
);
authorityName
.
add
(
"考勤管理"
);
authorityName
.
add
(
"角色管理"
);
List
<
Authority
>
authorities
=
authorityDao
.
findAllByNameIn
(
authorityName
);
Role
role
=
roleDao
.
findByName
(
"管理员"
);
List
<
RoleAuthority
>
roleAuthorities
=
new
ArrayList
<>();
if
(
authorities
!=
null
){
authorities
.
forEach
(
authority
->{
RoleAuthority
roleAuthority
=
new
RoleAuthority
(
null
,
role
.
getId
(),
authority
.
getId
());
roleAuthorities
.
add
(
roleAuthority
);
});
}
roleAuthorityDao
.
saveAll
(
roleAuthorities
);
}
}
notes-pas/src/main/java/com/zjty/tynotes/pas/dao/RoleDao.java
浏览文件 @
680e4386
...
@@ -20,4 +20,6 @@ public interface RoleDao extends MongoRepository<Role, String> {
...
@@ -20,4 +20,6 @@ public interface RoleDao extends MongoRepository<Role, String> {
Role
findAllByName
(
String
name
);
Role
findAllByName
(
String
name
);
void
deleteByName
(
String
name
);
void
deleteByName
(
String
name
);
Role
findByName
(
String
name
);
}
}
notes-pas/src/main/java/com/zjty/tynotes/pas/service/impl/UserServiceImpl.java
浏览文件 @
680e4386
...
@@ -361,6 +361,7 @@ public class UserServiceImpl implements IUserService {
...
@@ -361,6 +361,7 @@ public class UserServiceImpl implements IUserService {
}
}
user
.
setRoles
(
roles
);
user
.
setRoles
(
roles
);
}
}
return
users
;
return
users
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论