Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
8timerv2
8timerapiv200
Commits
214aab91
Commit
214aab91
authored
Jun 10, 2020
by
lal
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复考勤BUG
parent
e38a8e2b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
511 additions
and
346 deletions
+511
-346
src/main/java/cn/timer/api/controller/kqgl/ClockInController.java
+483
-337
src/main/java/cn/timer/api/controller/kqgl/ClockInTool.java
+11
-3
src/main/java/cn/timer/api/controller/kqgl/TimeCardController.java
+11
-3
src/main/java/cn/timer/api/dto/kqmk/DailyDetailsDto.java
+1
-0
src/main/resources/mapping/kqmk/KqglAssoMonthPunchSummaryMapper.xml
+5
-3
No files found.
src/main/java/cn/timer/api/controller/kqgl/ClockInController.java
View file @
214aab91
...
...
@@ -81,7 +81,7 @@ public class ClockInController {
String
current_time
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
());
String
current
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
new
Date
());
String
yesterday
=
ClockInTool
.
requires_extra_times
(
current
,-
1
,
3
);
//前一天
String
yesterday
=
ClockInTool
.
requires_extra_times
(
current
,-
1
,
3
,
1
);
//前一天
Long
startDateyesterday
=
DateUtil
.
getStartTime
(
0
,
DateUtil
.
getStringTime
(
yesterday
,
"yyyy-MM-dd"
)).
getTime
();
Long
endDateyesterday
=
DateUtil
.
getnowEndTime
(
23
,
DateUtil
.
getStringTime
(
yesterday
,
"yyyy-MM-dd"
)).
getTime
();
...
...
@@ -90,7 +90,7 @@ public class ClockInController {
String
toweek
=
""
;
String
msg
=
"未知错误,请联系管理员"
;
int
sbyf
=
0
;
//0:失败;1:成功
int
sbyf
=
1
;
//0:失败;1:成功
JSONObject
jsonArray
=
new
JSONObject
(
json
);
String
asDevId
=
jsonArray
.
get
(
"dev_id"
).
toString
();
//考勤机编码
...
...
@@ -123,347 +123,473 @@ public class ClockInController {
int
atttype
=
0
;
ClockCollectData
clockt
=
new
ClockCollectData
();
//putime: 根据日期 得到打卡所需的详细信息
AttendanceCardListDto
attdate
=
MethodCall
(
qyid
,
userid
,
putime
);
/*******/
if
(
attgro
!=
null
)
{
//判断考勤组是否存在
List
<
KqglAssoKqzdkfs
>
kqjs
=
KqglAssoKqzdkfs
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
KqglAssoKqzdkfs
>().
lambda
().
eq
(
KqglAssoKqzdkfs:
:
getKqzId
,
attgro
.
getId
()));
if
(
kqjs
.
size
()
>
0
)
{
// long time_ = DateUtil.getStringTime(sStdIoTime, "yyyy-MM-dd HH:mm:ss");
// String putime = new SimpleDateFormat("yyyy-MM-dd").format(time_);//转换打卡时间格式
//打卡当天开始时间,打卡当天结束时间
// Long startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(putime,"yyyy-MM-dd")).getTime();
// Long endDate = DateUtil.getnowEndTime(23,DateUtil.getStringTime(putime,"yyyy-MM-dd")).getTime();
//查询打卡当天是否有记录**********************************
// KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userid)
// .ge(KqglAssoDkmx::getDksj, startDate).le(KqglAssoDkmx::getDksj, endDate));
KqglAssoDkmx
dkmc
=
KqglAssoDkmx
.
builder
().
build
();
//putime: 根据日期 得到打卡所需的详细信息
AttendanceCardListDto
attdate
=
MethodCall
(
qyid
,
userid
,
putime
);
String
dakariqi
=
new
SimpleDateFormat
(
"yy-MM-dd"
).
format
(
Double
.
valueOf
(
startDateyesterday
))+
" "
+
ClockInTool
.
dateToWeek2
(
yesterday
);
//检查昨日的班次是否存在次日打卡
KqglAssoDkjl
balan
=
kqglassodkjlmapper
.
selectOne
(
new
QueryWrapper
<
KqglAssoDkjl
>().
lambda
().
eq
(
KqglAssoDkjl:
:
getUserId
,
userid
).
eq
(
KqglAssoDkjl:
:
getAttdate
,
dakariqi
).
ne
(
KqglAssoDkjl:
:
getBcid
,
0
).
orderByDesc
(
KqglAssoDkjl
::
getSort
).
last
(
"LIMIT 1"
));
if
(
balan
!=
null
)
{
//前一天是否打过卡 去班次id查询是否存在次日打卡
//班次信息
KqglAssoBcsz
shif
=
kqglassobcszmapper
.
selectOne
(
new
QueryWrapper
<
KqglAssoBcsz
>().
lambda
().
eq
(
KqglAssoBcsz:
:
getId
,
balan
.
getBcid
()));
int
dkcs
=
shif
.
getSxbcs
()*
2
;
List
<
AttSchedule
>
ashss
=
attdate
.
getAttsch
();
//获取今天应打卡时间
System
.
out
.
println
(
ashss
.
get
(
0
).
getTime
());
boolean
dnck
=
false
;
if
(
ashss
.
size
()
>
0
)
{
Date
sd1
=
df1
.
parse
(
ClockInTool
.
stampToDate
(
String
.
valueOf
(
ashss
.
get
(
0
).
getTime
())));
//当天应打的首次上班卡时间
Date
sd2
=
df1
.
parse
(
current_time
);
//当前时间
if
(
sd1
.
after
(
sd2
))
{
dnck
=
true
;
}
}
int
isXbdk1Cr
=
shif
.
getIsXbdk1Cr
();
//下班1是否次日(0:否;1:是)
int
isSbdk2Cr
=
shif
.
getIsSbdk2Cr
();
//上班2是否次日(0:否;1:是)
int
isXbdk2Cr
=
shif
.
getIsXbdk2Cr
();
//下班2是否次日(0:否;1:是)
int
isSbdk3Cr
=
shif
.
getIsSbdk3Cr
();
//上班3是否次日(0:否;1:是)
int
isXbdk3Cr
=
shif
.
getIsXbdk3Cr
();
//下班3是否次日(0:否;1:是)
boolean
crdk
=
false
;
//当次打卡是否存在次日打卡
if
(
balan
.
getSort
()
<
dkcs
)
{
if
(
balan
.
getSort
()+
1
==
2
&&
dkcs
==
2
)
{
if
(
isXbdk1Cr
>
0
)
{
//次日
crdk
=
true
;
}
}
if
(
balan
.
getSort
()+
1
==
3
&&
dkcs
==
4
)
{
if
(
isSbdk2Cr
>
0
)
{
//次日
crdk
=
true
;
/**
* 当考勤组为“固定排班”和“自定义排班”时 方可使用
*/
if
(
attdate
.
getAttgrouptype
()
!=
3
)
{
//查询打卡当天是否有记录**********************************
KqglAssoDkmx
dkmc
=
KqglAssoDkmx
.
builder
().
build
();
//putime: 根据日期 得到打卡所需的详细信息
// AttendanceCardListDto attdate = MethodCall(qyid,userid,putime);
String
dakariqi
=
new
SimpleDateFormat
(
"yy-MM-dd"
).
format
(
Double
.
valueOf
(
startDateyesterday
))+
" "
+
ClockInTool
.
dateToWeek2
(
yesterday
);
//检查昨日的班次是否存在次日打卡
KqglAssoDkjl
balan
=
kqglassodkjlmapper
.
selectOne
(
new
QueryWrapper
<
KqglAssoDkjl
>().
lambda
().
eq
(
KqglAssoDkjl:
:
getUserId
,
userid
).
eq
(
KqglAssoDkjl:
:
getAttdate
,
dakariqi
).
ne
(
KqglAssoDkjl:
:
getBcid
,
0
).
orderByDesc
(
KqglAssoDkjl
::
getSort
).
last
(
"LIMIT 1"
));
if
(
balan
!=
null
)
{
//前一天是否打过卡 去班次id查询是否存在次日打卡
//班次信息
KqglAssoBcsz
shif
=
kqglassobcszmapper
.
selectOne
(
new
QueryWrapper
<
KqglAssoBcsz
>().
lambda
().
eq
(
KqglAssoBcsz:
:
getId
,
balan
.
getBcid
()));
int
dkcs
=
shif
.
getSxbcs
()*
2
;
List
<
AttSchedule
>
ashss
=
attdate
.
getAttsch
();
//获取今天应打卡时间
boolean
dnck
=
false
;
if
(
ashss
.
size
()
>
0
)
{
Date
sd1
=
df1
.
parse
(
ClockInTool
.
stampToDate
(
String
.
valueOf
(
ashss
.
get
(
0
).
getTime
())));
//当天应打的首次上班卡时间
Date
sd2
=
df1
.
parse
(
current_time
);
//当前时间
if
(
sd1
.
after
(
sd2
))
{
dnck
=
true
;
}
}
}
if
(
balan
.
getSort
()+
1
==
4
&&
dkcs
==
4
)
{
if
(
isXbdk2Cr
>
0
)
{
//次日
crdk
=
true
;
int
isXbdk1Cr
=
shif
.
getIsXbdk1Cr
();
//下班1是否次日(0:否;1:是)
int
isSbdk2Cr
=
shif
.
getIsSbdk2Cr
();
//上班2是否次日(0:否;1:是)
int
isXbdk2Cr
=
shif
.
getIsXbdk2Cr
();
//下班2是否次日(0:否;1:是)
int
isSbdk3Cr
=
shif
.
getIsSbdk3Cr
();
//上班3是否次日(0:否;1:是)
int
isXbdk3Cr
=
shif
.
getIsXbdk3Cr
();
//下班3是否次日(0:否;1:是)
boolean
crdk
=
false
;
//当次打卡是否存在次日打卡
if
(
balan
.
getSort
()
<
dkcs
)
{
if
(
balan
.
getSort
()+
1
==
2
&&
dkcs
==
2
)
{
if
(
isXbdk1Cr
>
0
)
{
//次日
crdk
=
true
;
}
}
if
(
balan
.
getSort
()+
1
==
3
&&
dkcs
==
4
)
{
if
(
isSbdk2Cr
>
0
)
{
//次日
crdk
=
true
;
}
}
if
(
balan
.
getSort
()+
1
==
4
&&
dkcs
==
4
)
{
if
(
isXbdk2Cr
>
0
)
{
//次日
crdk
=
true
;
}
}
if
(
balan
.
getSort
()+
1
==
5
&&
dkcs
==
6
)
{
if
(
isSbdk3Cr
>
0
)
{
//次日
crdk
=
true
;
}
}
if
(
balan
.
getSort
()+
1
==
6
&&
dkcs
==
6
)
{
if
(
isXbdk3Cr
>
0
)
{
//次日
crdk
=
true
;
}
}
}
}
if
(
balan
.
getSort
()+
1
==
5
&&
dkcs
==
6
)
{
if
(
isSbdk3Cr
>
0
)
{
//次日
crdk
=
true
;
if
(
crdk
&&
dnck
)
{
dkmc
=
KqglAssoDkmx
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
KqglAssoDkmx
>().
lambda
().
eq
(
KqglAssoDkmx:
:
getUserid
,
userid
)
.
ge
(
KqglAssoDkmx:
:
getDksj
,
startDateyesterday
).
le
(
KqglAssoDkmx:
:
getDksj
,
endDateyesterday
));
attdate
=
MethodCall
(
qyid
,
userid
,
yesterday
);
attendance_date
=
startDateyesterday
;
toweek
=
yesterday
;
}
else
{
dkmc
=
KqglAssoDkmx
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
KqglAssoDkmx
>().
lambda
().
eq
(
KqglAssoDkmx:
:
getUserid
,
userid
)
.
ge
(
KqglAssoDkmx:
:
getDksj
,
startDate
).
le
(
KqglAssoDkmx:
:
getDksj
,
endDate
));
// attdate = MethodCall(qyid,userid,putime);
attendance_date
=
startDate
;
toweek
=
putime
;
}
}
else
{
//无记录的话就找昨天的数据
AttendanceCardListDto
attdate1
=
MethodCall
(
qyid
,
userid
,
yesterday
);
}
if
(
balan
.
getSort
()+
1
==
6
&&
dkcs
==
6
)
{
if
(
isXbdk3Cr
>
0
)
{
//次日
crdk
=
true
;
//putime: 根据日期 得到打卡所需的详细信息
// AttendanceCardListDto attdate = MethodCall(qyid,userid,putime);
// ClockCollectData clockt = new ClockCollectData();
long
starttime1
=
0
,
starttime1ks
=
0
,
starttime1js
=
0
,
endtime1
=
0
,
endtime1ks
=
0
,
endtime1js
=
0
,
starttime2
=
0
,
starttime2ks
=
0
,
starttime2js
=
0
,
endtime2
=
0
,
endtime2ks
=
0
,
endtime2js
=
0
,
starttime3
=
0
,
starttime3ks
=
0
,
starttime3js
=
0
,
endtime3
=
0
,
endtime3ks
=
0
,
endtime3js
=
0
;
if
(
attdate
.
getAttsch
().
size
()
>
0
)
{
List
<
AttSchedule
>
ash
=
attdate
.
getAttsch
();
int
y
=
0
;
clockt
.
setShifid
(
ash
.
get
(
y
).
getId
());
shifid
=
ash
.
get
(
y
).
getId
();
//班次id
if
(
attdate
.
getAttsch
().
size
()
==
2
||
attdate
.
getAttsch
().
size
()
==
4
||
attdate
.
getAttsch
().
size
()
==
6
)
{
starttime1
=
ash
.
get
(
0
).
getTime
();
starttime1ks
=
ash
.
get
(
0
).
getStarttime
();
starttime1js
=
ash
.
get
(
0
).
getEndtime
();
endtime1
=
ash
.
get
(
1
).
getTime
();
endtime1ks
=
ash
.
get
(
1
).
getStarttime
();
endtime1js
=
ash
.
get
(
1
).
getEndtime
();
}
if
(
attdate
.
getAttsch
().
size
()
==
4
||
attdate
.
getAttsch
().
size
()
==
6
)
{
starttime2
=
ash
.
get
(
2
).
getTime
();
starttime2ks
=
ash
.
get
(
2
).
getStarttime
();
starttime2js
=
ash
.
get
(
2
).
getEndtime
();
endtime2
=
ash
.
get
(
3
).
getTime
();
endtime2ks
=
ash
.
get
(
3
).
getStarttime
();
endtime2js
=
ash
.
get
(
3
).
getEndtime
();
}
}
}
if
(
crdk
&&
dnck
)
{
dkmc
=
KqglAssoDkmx
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
KqglAssoDkmx
>().
lambda
().
eq
(
KqglAssoDkmx:
:
getUserid
,
userid
)
if
(
attdate
.
getAttsch
().
size
()
==
6
)
{
starttime3
=
ash
.
get
(
4
).
getTime
();
starttime3ks
=
ash
.
get
(
4
).
getStarttime
();
starttime3js
=
ash
.
get
(
4
).
getEndtime
();
endtime3
=
ash
.
get
(
5
).
getTime
();
endtime3ks
=
ash
.
get
(
5
).
getStarttime
();
endtime3js
=
ash
.
get
(
5
).
getEndtime
();
}
}
// long punchcardtime,punchstart,punchend = 0;//应打卡时间,应打卡开始时间,应打卡结束时间
// int atttype = 0;
if
(
dkmc
==
null
)
{
//上班1 ****新增
punchcardtime
=
starttime1
;
punchstart
=
starttime1ks
;
punchend
=
starttime1js
;
atttype
=
1
;
}
else
{
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
==
null
)){
//下班1
punchcardtime
=
endtime1
;
punchstart
=
endtime1ks
;
punchend
=
endtime1js
;
atttype
=
2
;
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
==
null
)){
//上班2
punchcardtime
=
starttime2
;
punchstart
=
starttime2ks
;
punchend
=
starttime2js
;
atttype
=
3
;
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
==
null
)){
//下班2
punchcardtime
=
endtime2
;
punchstart
=
endtime2ks
;
punchend
=
endtime2js
;
atttype
=
4
;
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getSbdk3
())
||
dkmc
.
getSbdk3
()
==
null
)){
//上班3
punchcardtime
=
starttime3
;
punchstart
=
starttime3ks
;
punchend
=
starttime3js
;
atttype
=
5
;
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk3
())
||
dkmc
.
getSbdk3
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk3
())
||
dkmc
.
getXbdk3
()
==
null
)){
//下班3
punchcardtime
=
endtime3
;
punchstart
=
endtime3ks
;
punchend
=
endtime3js
;
atttype
=
6
;
}
else
{
punchcardtime
=
0
;
punchstart
=
0
;
punchend
=
0
;
atttype
=
7
;
}
}
if
(
clockt
.
getShifid
()
!=
0
)
{
KqglAssoBcsz
shif
=
KqglAssoBcsz
.
builder
().
build
();
if
(
attdate
.
getAttsch
().
size
()
>
0
&&
clockt
.
getShifid
()
>
0
){
//有无班次
shif
=
shif
.
selectOne
(
new
QueryWrapper
<
KqglAssoBcsz
>().
lambda
().
eq
(
KqglAssoBcsz:
:
getId
,
clockt
.
getShifid
()));
}
//打卡记录录入 -- 打卡是否有时间范围限制
// boolean isRange = true;
if
(
punchstart
>
0
&&
punchend
>
0
)
{
String
staputime
=
new
SimpleDateFormat
(
"HH:mm"
).
format
(
punchstart
);
//应打卡开始时间
String
entputime
=
new
SimpleDateFormat
(
"HH:mm"
).
format
(
punchend
);
//应打卡结束时间
String
DKputime
=
new
SimpleDateFormat
(
"HH:mm"
).
format
(
time_
);
//打卡时间
boolean
effectiveDate
=
ClockInTool
.
hourMinuteBetween
(
DKputime
,
staputime
,
entputime
,
"HH:mm"
);
if
(!
effectiveDate
)
{
System
.
out
.
println
(
"当前打卡时间不在范围内"
);
// 手动抛出异常
isRange
=
false
;
// throw new Exception();
}
}
if
(
isRange
)
{
int
yzcd
=
shif
.
getYzcdfzs
();
//严重迟到分钟数
int
kgcdfzs
=
shif
.
getKgcdfzs
();
//旷工迟到分钟数
if
(
dkmc
==
null
)
{
//上班1 ****新增
int
sbdk1jg
=
0
,
yzcdsc
=
0
,
yzcdcs
=
0
,
kgcdcs
=
0
;
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
sbdk1jg
=
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
()));}
//上班1打卡结果
}
int
ydkcs
=
0
;
if
(
shif
!=
null
){
ydkcs
=
shif
.
getSxbcs
()*
2
;}
//应打卡次数
if
(
sbdk1jg
>
yzcd
)
{
yzcdcs
++;
yzcdsc
=
sbdk1jg
-
yzcd
;
}
if
(
sbdk1jg
>
kgcdfzs
)
{
kgcdcs
++;}
KqglAssoDkmx
pcd
=
KqglAssoDkmx
.
builder
().
userid
(
userid
).
data
(
putime
).
sbdk1
(
time_
).
sbdk1jg
(
sbdk1jg
).
ydkcs
(
ydkcs
).
qyid
(
qyid
).
dksj
(
startDate
).
yzcdcs
(
yzcdcs
).
yzcdsc
(
Double
.
valueOf
(
yzcdsc
)).
kgcdfzs
(
kgcdcs
).
build
();
if
(!
pcd
.
insert
())
{
throw
new
CustomException
(
"打卡明细-新增异常-1"
);
}
dkmx
=
pcd
.
getId
();
}
else
{
//*****修改
dkmx
=
dkmc
.
getId
();
KqglAssoDkmx
pcd
=
KqglAssoDkmx
.
builder
().
build
();
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
==
null
)){
//下班1
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setXbdk1
(
time_
);
//下班1打卡时间
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
pcd
.
setXbdk1jg
(
0
);
// 打卡结果
}
else
{
pcd
.
setXbdk1jg
(
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
())));
//上班1打卡结果
}
}
if
(
dkmc
.
getSbdk1
()
!=
null
){
Long
time
=
(
time_
-
dkmc
.
getSbdk1
())/
1000
/
60
;
pcd
.
setGzsc
(
Math
.
abs
(
Double
.
valueOf
(
time
.
toString
())));
//只打一次卡时计算工作时长
}
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
==
null
)){
//上班2
int
sbdk2jg
=
0
,
yzcdsc
=
0
,
yzcdcs
=
0
,
kgcdcs
=
0
;
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
sbdk2jg
=
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
()));}
}
if
(
sbdk2jg
>
yzcd
)
{
yzcdcs
=
dkmc
.
getYzcdcs
()+
1
;
yzcdsc
=
sbdk2jg
-
yzcd
;
}
if
(
sbdk2jg
>
kgcdfzs
)
{
kgcdcs
++;}
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setSbdk2
(
time_
);
//上班1打卡时间
pcd
.
setSbdk2jg
(
sbdk2jg
);
pcd
.
setYzcdcs
(
yzcdcs
);
pcd
.
setYzcdsc
(
Double
.
valueOf
(
yzcdsc
));
pcd
.
setKgcdfzs
(
kgcdcs
);
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
==
null
)){
//下班2
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setXbdk2
(
time_
);
//下班1打卡时间
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
pcd
.
setXbdk2jg
(
0
);
// 打卡结果
}
else
{
pcd
.
setXbdk2jg
(
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
())));
}
}
//班次为4次时,计算工作时长
if
(
dkmc
.
getSbdk2
()
!=
null
){
Long
time
=
(
time_
-
dkmc
.
getSbdk2
())/
1000
/
60
;
BigDecimal
om
=
new
BigDecimal
(
dkmc
.
getGzsc
());
BigDecimal
on
=
new
BigDecimal
(
time
);
double
worktime
=
Math
.
abs
(
om
.
add
(
on
).
doubleValue
());
pcd
.
setGzsc
(
worktime
);
}
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getSbdk3
())
||
dkmc
.
getSbdk3
()
==
null
)){
//上班3
int
sbdk3jg
=
0
,
yzcdsc
=
0
,
yzcdcs
=
0
,
kgcdcs
=
0
;
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
sbdk3jg
=
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
()));}
}
if
(
sbdk3jg
>
yzcd
)
{
yzcdcs
=
dkmc
.
getYzcdcs
()+
1
;
yzcdsc
=
sbdk3jg
-
yzcd
;
}
if
(
sbdk3jg
>
kgcdfzs
)
{
kgcdcs
++;}
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setSbdk3
(
time_
);
//上班1打卡时间
pcd
.
setSbdk3jg
(
sbdk3jg
);
pcd
.
setYzcdcs
(
yzcdcs
);
pcd
.
setYzcdsc
(
Double
.
valueOf
(
yzcdsc
));
pcd
.
setKgcdfzs
(
kgcdcs
);
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk3
())
||
dkmc
.
getSbdk3
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk3
())
||
dkmc
.
getXbdk3
()
==
null
)){
//下班3
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setXbdk3
(
time_
);
//下班1打卡时间
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
pcd
.
setXbdk3jg
(
0
);
// 打卡结果
}
else
{
pcd
.
setXbdk3jg
(
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
())));
}
}
//班次为6次时,计算工作时长
if
(
dkmc
.
getSbdk3
()
!=
null
){
Long
time
=
(
time_
-
dkmc
.
getSbdk3
())/
1000
/
60
;
BigDecimal
om
=
new
BigDecimal
(
dkmc
.
getGzsc
());
//第二次
BigDecimal
on
=
new
BigDecimal
(
time
);
double
worktime
=
Math
.
abs
(
om
.
add
(
on
).
doubleValue
());
pcd
.
setGzsc
(
worktime
);
}
}
pcd
.
setId
(
dkmc
.
getId
());
if
(
atttype
<=
6
){
int
update
=
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
}
}
else
{
msg
=
"当前打卡时间不在范围内"
;
sbyf
=
0
;
}
}
else
{
msg
=
"当前是休息时间"
;
sbyf
=
0
;
}
}
else
{
//自由工时打卡
Long
stapclotime
=
attdate
.
getStapclotime
();
// 今天考勤 自由排班开始时间
int
canpunchworkdate
=
Integer
.
valueOf
(
String
.
valueOf
(
attdate
.
getCanpunchworkdate
()).
replaceAll
(
"(\\d+)(?:(\\.\\d*[^0])|\\.)0*"
,
"$1$2"
));
// 上班打卡后多久大下班卡
KqglAssoDkmx
zydkmc
=
KqglAssoDkmx
.
builder
().
build
();
Date
sd1
=
df1
.
parse
(
ClockInTool
.
stampToDate
(
String
.
valueOf
(
stapclotime
)));
//应打卡时间 2020-06-10 18:30:00
Date
sd2
=
df1
.
parse
(
current_time
);
//当前时间 2020-06-10 16:06:58
if
(
sd1
.
after
(
sd2
))
{
//为true时 打的是昨天的卡
zydkmc
=
KqglAssoDkmx
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
KqglAssoDkmx
>().
lambda
().
eq
(
KqglAssoDkmx:
:
getUserid
,
userid
)
.
ge
(
KqglAssoDkmx:
:
getDksj
,
startDateyesterday
).
le
(
KqglAssoDkmx:
:
getDksj
,
endDateyesterday
));
attdate
=
MethodCall
(
qyid
,
userid
,
yesterday
);
attendance_date
=
startDateyesterday
;
toweek
=
yesterday
;
}
else
{
dkmc
=
KqglAssoDkmx
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
KqglAssoDkmx
>().
lambda
().
eq
(
KqglAssoDkmx:
:
getUserid
,
userid
)
zy
dkmc
=
KqglAssoDkmx
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
KqglAssoDkmx
>().
lambda
().
eq
(
KqglAssoDkmx:
:
getUserid
,
userid
)
.
ge
(
KqglAssoDkmx:
:
getDksj
,
startDate
).
le
(
KqglAssoDkmx:
:
getDksj
,
endDate
));
// attdate = MethodCall(qyid,userid,putime);
attendance_date
=
startDate
;
toweek
=
putime
;
}
}
else
{
//无记录的话就找昨天的数据
AttendanceCardListDto
attdate1
=
MethodCall
(
qyid
,
userid
,
yesterday
);
}
}
//putime: 根据日期 得到打卡所需的详细信息
// AttendanceCardListDto attdate = MethodCall(qyid,userid,putime);
// ClockCollectData clockt = new ClockCollectData();
long
starttime1
=
0
,
starttime1ks
=
0
,
starttime1js
=
0
,
endtime1
=
0
,
endtime1ks
=
0
,
endtime1js
=
0
,
starttime2
=
0
,
starttime2ks
=
0
,
starttime2js
=
0
,
endtime2
=
0
,
endtime2ks
=
0
,
endtime2js
=
0
,
starttime3
=
0
,
starttime3ks
=
0
,
starttime3js
=
0
,
endtime3
=
0
,
endtime3ks
=
0
,
endtime3js
=
0
;
if
(
attdate
.
getAttsch
().
size
()
>
0
)
{
List
<
AttSchedule
>
ash
=
attdate
.
getAttsch
();
int
y
=
0
;
clockt
.
setShifid
(
ash
.
get
(
y
).
getId
());
shifid
=
ash
.
get
(
y
).
getId
();
//班次id
if
(
attdate
.
getAttsch
().
size
()
==
2
||
attdate
.
getAttsch
().
size
()
==
4
||
attdate
.
getAttsch
().
size
()
==
6
)
{
starttime1
=
ash
.
get
(
0
).
getTime
();
starttime1ks
=
ash
.
get
(
0
).
getStarttime
();
starttime1js
=
ash
.
get
(
0
).
getEndtime
();
endtime1
=
ash
.
get
(
1
).
getTime
();
endtime1ks
=
ash
.
get
(
1
).
getStarttime
();
endtime1js
=
ash
.
get
(
1
).
getEndtime
();
}
if
(
attdate
.
getAttsch
().
size
()
==
4
||
attdate
.
getAttsch
().
size
()
==
6
)
{
starttime2
=
ash
.
get
(
2
).
getTime
();
starttime2ks
=
ash
.
get
(
2
).
getStarttime
();
starttime2js
=
ash
.
get
(
2
).
getEndtime
();
endtime2
=
ash
.
get
(
3
).
getTime
();
endtime2ks
=
ash
.
get
(
3
).
getStarttime
();
endtime2js
=
ash
.
get
(
3
).
getEndtime
();
}
if
(
attdate
.
getAttsch
().
size
()
==
6
)
{
starttime3
=
ash
.
get
(
4
).
getTime
();
starttime3ks
=
ash
.
get
(
4
).
getStarttime
();
starttime3js
=
ash
.
get
(
4
).
getEndtime
();
endtime3
=
ash
.
get
(
5
).
getTime
();
endtime3ks
=
ash
.
get
(
5
).
getStarttime
();
endtime3js
=
ash
.
get
(
5
).
getEndtime
();
}
}
// long punchcardtime,punchstart,punchend = 0;//应打卡时间,应打卡开始时间,应打卡结束时间
// int atttype = 0;
if
(
dkmc
==
null
)
{
//上班1 ****新增
punchcardtime
=
starttime1
;
punchstart
=
starttime1ks
;
punchend
=
starttime1js
;
atttype
=
1
;
}
else
{
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
==
null
)){
//下班1
punchcardtime
=
endtime1
;
punchstart
=
endtime1ks
;
punchend
=
endtime1js
;
atttype
=
2
;
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
==
null
)){
//上班2
punchcardtime
=
starttime2
;
punchstart
=
starttime2ks
;
punchend
=
starttime2js
;
atttype
=
3
;
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
==
null
)){
//下班2
punchcardtime
=
endtime2
;
punchstart
=
endtime2ks
;
punchend
=
endtime2js
;
atttype
=
4
;
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getSbdk3
())
||
dkmc
.
getSbdk3
()
==
null
)){
//上班3
punchcardtime
=
starttime3
;
punchstart
=
starttime3ks
;
punchend
=
starttime3js
;
atttype
=
5
;
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk3
())
||
dkmc
.
getSbdk3
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk3
())
||
dkmc
.
getXbdk3
()
==
null
)){
//下班3
punchcardtime
=
endtime3
;
punchstart
=
endtime3ks
;
punchend
=
endtime3js
;
atttype
=
6
;
}
else
{
punchcardtime
=
0
;
punchstart
=
0
;
punchend
=
0
;
atttype
=
7
;
}
}
if
(
clockt
.
getShifid
()
!=
0
)
{
KqglAssoBcsz
shif
=
KqglAssoBcsz
.
builder
().
build
();
if
(
attdate
.
getAttsch
().
size
()
>
0
&&
clockt
.
getShifid
()
>
0
){
//有无班次
shif
=
shif
.
selectOne
(
new
QueryWrapper
<
KqglAssoBcsz
>().
lambda
().
eq
(
KqglAssoBcsz:
:
getId
,
clockt
.
getShifid
()));
}
//打卡记录录入 -- 打卡是否有时间范围限制
// boolean isRange = true;
if
(
punchstart
>
0
&&
punchend
>
0
)
{
String
staputime
=
new
SimpleDateFormat
(
"HH:mm"
).
format
(
punchstart
);
//应打卡开始时间
String
entputime
=
new
SimpleDateFormat
(
"HH:mm"
).
format
(
punchend
);
//应打卡结束时间
String
DKputime
=
new
SimpleDateFormat
(
"HH:mm"
).
format
(
time_
);
//打卡时间
boolean
effectiveDate
=
ClockInTool
.
hourMinuteBetween
(
DKputime
,
staputime
,
entputime
,
"HH:mm"
);
if
(!
effectiveDate
)
{
System
.
out
.
println
(
"当前打卡时间不在范围内"
);
// 手动抛出异常
isRange
=
false
;
// throw new Exception();
}
if
(
zydkmc
==
null
)
{
//新增
KqglAssoDkmx
pcd
=
KqglAssoDkmx
.
builder
().
build
();
if
(
sd1
.
after
(
sd2
))
{
pcd
=
KqglAssoDkmx
.
builder
().
userid
(
userid
).
data
(
yesterday
).
sbdk1
(
time_
).
sbdk1jg
(
0
).
ydkcs
(
0
).
qyid
(
qyid
).
dksj
(
startDateyesterday
).
yzcdcs
(
0
).
yzcdsc
(
Double
.
valueOf
(
0
)).
kgcdfzs
(
0
).
build
();
}
else
{
pcd
=
KqglAssoDkmx
.
builder
().
userid
(
userid
).
data
(
putime
).
sbdk1
(
time_
).
sbdk1jg
(
0
).
ydkcs
(
0
).
qyid
(
qyid
).
dksj
(
startDate
).
yzcdcs
(
0
).
yzcdsc
(
Double
.
valueOf
(
0
)).
kgcdfzs
(
0
).
build
();
}
// KqglAssoDkmx pcd = KqglAssoDkmx.builder().userid(userid).data(putime).sbdk1(time_).sbdk1jg(0).ydkcs(0).qyid(qyid).dksj(startDate).yzcdcs(0).yzcdsc(Double.valueOf(0)).kgcdfzs(0).build();
if
(!
pcd
.
insert
())
{
throw
new
CustomException
(
"打卡明细-新增异常-1"
);
}
if
(
isRange
)
{
int
yzcd
=
shif
.
getYzcdfzs
();
//严重迟到分钟数
int
kgcdfzs
=
shif
.
getKgcdfzs
();
//旷工迟到分钟数
if
(
dkmc
==
null
)
{
//上班1 ****新增
int
sbdk1jg
=
0
,
yzcdsc
=
0
,
yzcdcs
=
0
,
kgcdcs
=
0
;
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
sbdk1jg
=
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
()));}
//上班1打卡结果
dkmx
=
pcd
.
getId
();
atttype
=
1
;
}
else
{
//修改
dkmx
=
zydkmc
.
getId
();
KqglAssoDkmx
zypcd
=
KqglAssoDkmx
.
builder
().
build
();
if
((!(
""
).
equals
(
zydkmc
.
getSbdk1
())
||
zydkmc
.
getSbdk1
()
!=
null
)
&&
((
""
).
equals
(
zydkmc
.
getXbdk1
())
||
zydkmc
.
getXbdk1
()
==
null
)){
//下班1
String
clock_time
=
ClockInTool
.
requires_extra_times
(
ClockInTool
.
stampToDate
(
String
.
valueOf
(
zydkmc
.
getSbdk1
())),
canpunchworkdate
,
5
,
2
);
Date
zysd1
=
df1
.
parse
(
clock_time
);
//上班打卡后多久大下班卡的时间
Date
zysd2
=
df1
.
parse
(
current_time
);
//当前时间
if
(
zysd1
.
after
(
zysd2
))
{
//当zysd1大于zysd2时,返回TRUE,当小于等于时,返回false;
msg
=
"自由工时:上班打卡后"
+
canpunchworkdate
+
"小时后,才可打下班卡"
;
sbyf
=
0
;
}
else
{
zypcd
.
setId
(
zydkmc
.
getId
());
zypcd
.
setXbdk1
(
time_
);
//下班1打卡时间
if
(
zydkmc
.
getSbdk1
()
!=
null
){
Long
time
=
(
time_
-
zydkmc
.
getSbdk1
())/
1000
/
60
;
zypcd
.
setGzsc
(
Math
.
abs
(
Double
.
valueOf
(
time
.
toString
())));
//只打一次卡时计算工作时长
}
int
ydkcs
=
0
;
if
(
shif
!=
null
){
ydkcs
=
shif
.
getSxbcs
()*
2
;}
//应打卡次数
if
(
sbdk1jg
>
yzcd
)
{
yzcdcs
++;
yzcdsc
=
sbdk1jg
-
yzcd
;
}
if
(
sbdk1jg
>
kgcdfzs
)
{
kgcdcs
++;}
KqglAssoDkmx
pcd
=
KqglAssoDkmx
.
builder
().
userid
(
userid
).
data
(
putime
).
sbdk1
(
time_
).
sbdk1jg
(
sbdk1jg
).
ydkcs
(
ydkcs
).
qyid
(
qyid
).
dksj
(
startDate
).
yzcdcs
(
yzcdcs
).
yzcdsc
(
Double
.
valueOf
(
yzcdsc
)).
kgcdfzs
(
kgcdcs
).
build
();
if
(!
pcd
.
insert
())
{
throw
new
CustomException
(
"打卡明细-新增异常-1"
);
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
zypcd
);
//修改打卡记录
}
atttype
=
2
;
}
else
if
((!(
""
).
equals
(
zydkmc
.
getSbdk1
())
||
zydkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getXbdk1
())
||
zydkmc
.
getXbdk1
()
!=
null
)
&&
((
""
).
equals
(
zydkmc
.
getSbdk2
())
||
zydkmc
.
getSbdk2
()
==
null
)){
//上班2
zypcd
.
setId
(
zydkmc
.
getId
());
zypcd
.
setSbdk2
(
time_
);
//上班1打卡时间
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
zypcd
);
//修改打卡记录
atttype
=
3
;
}
else
if
((!(
""
).
equals
(
zydkmc
.
getSbdk1
())
||
zydkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getXbdk1
())
||
zydkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getSbdk2
())
||
zydkmc
.
getSbdk2
()
!=
null
)
&&
((
""
).
equals
(
zydkmc
.
getXbdk2
())
||
zydkmc
.
getXbdk2
()
==
null
)){
//下班2
String
clock_time
=
ClockInTool
.
requires_extra_times
(
ClockInTool
.
stampToDate
(
String
.
valueOf
(
zydkmc
.
getSbdk2
())),
canpunchworkdate
,
5
,
2
);
Date
zysd1
=
df1
.
parse
(
clock_time
);
//上班打卡后多久大下班卡的时间
Date
zysd2
=
df1
.
parse
(
current_time
);
//当前时间
if
(
zysd1
.
after
(
zysd2
))
{
//当zysd1大于zysd2时,返回TRUE,当小于等于时,返回false;
msg
=
"自由工时:上班打卡后"
+
canpunchworkdate
+
"小时后,才可打下班卡"
;
sbyf
=
0
;
}
else
{
zypcd
.
setId
(
zydkmc
.
getId
());
zypcd
.
setXbdk2
(
time_
);
//下班1打卡时间
//班次为4次时,计算工作时长
if
(
zydkmc
.
getSbdk2
()
!=
null
){
Long
time
=
(
time_
-
zydkmc
.
getSbdk2
())/
1000
/
60
;
BigDecimal
om
=
new
BigDecimal
(
zydkmc
.
getGzsc
());
BigDecimal
on
=
new
BigDecimal
(
time
);
double
worktime
=
Math
.
abs
(
om
.
add
(
on
).
doubleValue
());
zypcd
.
setGzsc
(
worktime
);
}
dkmx
=
pcd
.
getId
();
}
else
{
//*****修改
dkmx
=
dkmc
.
getId
();
KqglAssoDkmx
pcd
=
KqglAssoDkmx
.
builder
().
build
();
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
==
null
)){
//下班1
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setXbdk1
(
time_
);
//下班1打卡时间
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
pcd
.
setXbdk1jg
(
0
);
// 打卡结果
}
else
{
pcd
.
setXbdk1jg
(
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
())));
//上班1打卡结果
}
}
if
(
dkmc
.
getSbdk1
()
!=
null
){
Long
time
=
(
time_
-
dkmc
.
getSbdk1
())/
1000
/
60
;
pcd
.
setGzsc
(
Math
.
abs
(
Double
.
valueOf
(
time
.
toString
())));
//只打一次卡时计算工作时长
}
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
==
null
)){
//上班2
int
sbdk2jg
=
0
,
yzcdsc
=
0
,
yzcdcs
=
0
,
kgcdcs
=
0
;
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
sbdk2jg
=
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
()));}
}
if
(
sbdk2jg
>
yzcd
)
{
yzcdcs
=
dkmc
.
getYzcdcs
()+
1
;
yzcdsc
=
sbdk2jg
-
yzcd
;
}
if
(
sbdk2jg
>
kgcdfzs
)
{
kgcdcs
++;}
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setSbdk2
(
time_
);
//上班1打卡时间
pcd
.
setSbdk2jg
(
sbdk2jg
);
pcd
.
setYzcdcs
(
yzcdcs
);
pcd
.
setYzcdsc
(
Double
.
valueOf
(
yzcdsc
));
pcd
.
setKgcdfzs
(
kgcdcs
);
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
==
null
)){
//下班2
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setXbdk2
(
time_
);
//下班1打卡时间
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
pcd
.
setXbdk2jg
(
0
);
// 打卡结果
}
else
{
pcd
.
setXbdk2jg
(
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
())));
}
}
//班次为4次时,计算工作时长
if
(
dkmc
.
getSbdk2
()
!=
null
){
Long
time
=
(
time_
-
dkmc
.
getSbdk2
())/
1000
/
60
;
BigDecimal
om
=
new
BigDecimal
(
dkmc
.
getGzsc
());
BigDecimal
on
=
new
BigDecimal
(
time
);
double
worktime
=
Math
.
abs
(
om
.
add
(
on
).
doubleValue
());
pcd
.
setGzsc
(
worktime
);
}
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getSbdk3
())
||
dkmc
.
getSbdk3
()
==
null
)){
//上班3
int
sbdk3jg
=
0
,
yzcdsc
=
0
,
yzcdcs
=
0
,
kgcdcs
=
0
;
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
sbdk3jg
=
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
()));}
}
if
(
sbdk3jg
>
yzcd
)
{
yzcdcs
=
dkmc
.
getYzcdcs
()+
1
;
yzcdsc
=
sbdk3jg
-
yzcd
;
}
if
(
sbdk3jg
>
kgcdfzs
)
{
kgcdcs
++;}
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setSbdk3
(
time_
);
//上班1打卡时间
pcd
.
setSbdk3jg
(
sbdk3jg
);
pcd
.
setYzcdcs
(
yzcdcs
);
pcd
.
setYzcdsc
(
Double
.
valueOf
(
yzcdsc
));
pcd
.
setKgcdfzs
(
kgcdcs
);
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
}
else
if
((!(
""
).
equals
(
dkmc
.
getSbdk1
())
||
dkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk1
())
||
dkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk2
())
||
dkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getXbdk2
())
||
dkmc
.
getXbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
dkmc
.
getSbdk3
())
||
dkmc
.
getSbdk3
()
!=
null
)
&&
((
""
).
equals
(
dkmc
.
getXbdk3
())
||
dkmc
.
getXbdk3
()
==
null
)){
//下班3
pcd
.
setId
(
dkmc
.
getId
());
pcd
.
setXbdk3
(
time_
);
//下班1打卡时间
if
(
punchcardtime
!=
0
){
//有应打卡时间时
Long
time
=
(
time_
-
punchcardtime
)/
1000
/
60
;
if
(
time
>
0
){
pcd
.
setXbdk3jg
(
0
);
// 打卡结果
}
else
{
pcd
.
setXbdk3jg
(
Math
.
abs
(
Integer
.
valueOf
(
time
.
toString
())));
}
}
//班次为6次时,计算工作时长
if
(
dkmc
.
getSbdk3
()
!=
null
){
Long
time
=
(
time_
-
dkmc
.
getSbdk3
())/
1000
/
60
;
BigDecimal
om
=
new
BigDecimal
(
dkmc
.
getGzsc
());
//第二次
BigDecimal
on
=
new
BigDecimal
(
time
);
double
worktime
=
Math
.
abs
(
om
.
add
(
on
).
doubleValue
());
pcd
.
setGzsc
(
worktime
);
}
}
pcd
.
setId
(
dkmc
.
getId
());
if
(
atttype
<=
6
){
int
update
=
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
pcd
);
//修改打卡记录
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
zypcd
);
//修改打卡记录
}
atttype
=
4
;
}
else
if
((!(
""
).
equals
(
zydkmc
.
getSbdk1
())
||
zydkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getXbdk1
())
||
zydkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getSbdk2
())
||
zydkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getXbdk2
())
||
zydkmc
.
getXbdk2
()
!=
null
)
&&
((
""
).
equals
(
zydkmc
.
getSbdk3
())
||
zydkmc
.
getSbdk3
()
==
null
)){
//上班3
zypcd
.
setId
(
zydkmc
.
getId
());
zypcd
.
setSbdk3
(
time_
);
//上班1打卡时间
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
zypcd
);
//修改打卡记录
atttype
=
5
;
}
else
if
((!(
""
).
equals
(
zydkmc
.
getSbdk1
())
||
zydkmc
.
getSbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getXbdk1
())
||
zydkmc
.
getXbdk1
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getSbdk2
())
||
zydkmc
.
getSbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getXbdk2
())
||
zydkmc
.
getXbdk2
()
!=
null
)
&&
(!(
""
).
equals
(
zydkmc
.
getSbdk3
())
||
zydkmc
.
getSbdk3
()
!=
null
)
&&
((
""
).
equals
(
zydkmc
.
getXbdk3
())
||
zydkmc
.
getXbdk3
()
==
null
)){
//下班3
String
clock_time
=
ClockInTool
.
requires_extra_times
(
ClockInTool
.
stampToDate
(
String
.
valueOf
(
zydkmc
.
getSbdk3
())),
canpunchworkdate
,
5
,
2
);
Date
zysd1
=
df1
.
parse
(
clock_time
);
//上班打卡后多久大下班卡的时间
Date
zysd2
=
df1
.
parse
(
current_time
);
//当前时间
if
(
zysd1
.
after
(
zysd2
))
{
//当zysd1大于zysd2时,返回TRUE,当小于等于时,返回false;
msg
=
"自由工时:上班打卡后"
+
canpunchworkdate
+
"小时后,才可打下班卡"
;
sbyf
=
0
;
}
else
{
zypcd
.
setId
(
zydkmc
.
getId
());
zypcd
.
setXbdk3
(
time_
);
//下班1打卡时间
//班次为6次时,计算工作时长
if
(
zydkmc
.
getSbdk3
()
!=
null
){
Long
time
=
(
time_
-
zydkmc
.
getSbdk3
())/
1000
/
60
;
BigDecimal
om
=
new
BigDecimal
(
zydkmc
.
getGzsc
());
//第二次
BigDecimal
on
=
new
BigDecimal
(
time
);
double
worktime
=
Math
.
abs
(
om
.
add
(
on
).
doubleValue
());
zypcd
.
setGzsc
(
worktime
);
}
}
}
else
{
msg
=
"当前打卡时间不在范围内"
;
sbyf
=
0
;
}
}
else
{
msg
=
"当前是休息时间"
;
sbyf
=
0
;
}
kqglassodkmxmapper
.
updateByPrimaryKeySelective
(
zypcd
);
//修改打卡记录
}
atttype
=
6
;
}
else
{
atttype
=
7
;
}
}
}
}
else
{
msg
=
"未检测到考勤机"
;
sbyf
=
0
;
}
/*************************************************************************************************************************************************************************************/
/*************************************************************************************************************************************************************************************/
// 原始打卡记录数据录入
...
...
@@ -478,42 +604,62 @@ public class ClockInController {
}
}
}
int
type
,
status
=
0
;
if
((
atttype
)%
2
>
0
){
type
=
1
;
// 类型(类型 0:无排班打卡 1:上班 2:下班) punchcardtime == 0:无班次打卡
if
(
punchcardtime
==
0
&&
clockt
.
getShifid
()
!=
0
){
status
=
1
;
}
if
(
punchcardtime
==
0
&&
clockt
.
getShifid
()
==
0
)
{
status
=
2
;
}
else
{
if
(
isRange
)
{
// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
if
(
time
>
0
){
status
=
3
;
}
else
if
(
results
==
0
){
status
=
1
;
if
(
attdate
.
getAttgrouptype
()
!=
3
)
{
if
(
punchcardtime
==
0
&&
clockt
.
getShifid
()
!=
0
){
status
=
1
;
}
if
(
punchcardtime
==
0
&&
clockt
.
getShifid
()
==
0
)
{
status
=
2
;
}
else
{
if
(
isRange
)
{
// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
if
(
time
>
0
){
status
=
3
;
}
else
if
(
results
==
0
){
status
=
1
;
}
}
else
{
status
=
2
;
}
}
}
else
{
if
(
sbyf
==
1
)
{
status
=
1
;
}
else
{
status
=
2
;
}
}
}
else
{
type
=
2
;
// 类型(类型 0:无排班打卡 1:上班 2:下班)
if
(
punchcardtime
==
0
&&
clockt
.
getShifid
()
!=
0
){
status
=
1
;
}
if
(
punchcardtime
==
0
&&
clockt
.
getShifid
()
==
0
)
{
status
=
2
;
}
else
{
if
(
isRange
)
{
if
(
time
<
0
){
status
=
4
;
}
else
if
(
results
==
0
){
status
=
1
;
if
(
attdate
.
getAttgrouptype
()
!=
3
)
{
if
(
punchcardtime
==
0
&&
clockt
.
getShifid
()
!=
0
){
status
=
1
;
}
if
(
punchcardtime
==
0
&&
clockt
.
getShifid
()
==
0
)
{
status
=
2
;
}
else
{
if
(
isRange
)
{
if
(
time
<
0
){
status
=
4
;
}
else
if
(
results
==
0
){
status
=
1
;
}
}
else
{
status
=
2
;
}
}
}
else
{
if
(
sbyf
==
1
)
{
status
=
1
;
}
else
{
status
=
2
;
}
}
}
String
attdate_
=
new
SimpleDateFormat
(
"yy-MM-dd"
).
format
(
Double
.
valueOf
(
attendance_date
));
//转换打卡时间格式
long
attime
;
// if(punchcardtime == 0 && !isRange){attime = new Date().getTime();}else{attime = punchcardtime;}// 考勤时间(应打卡时间)
...
...
@@ -715,7 +861,7 @@ public class ClockInController {
int
isXbdk3Cr
=
shiftm
.
getIsXbdk3Cr
();
//下班3是否次日(0:否;1:是)
//次日专用
String
next_day
=
ClockInTool
.
requires_extra_times
(
str
,
1
,
2
);
String
next_day
=
ClockInTool
.
requires_extra_times
(
str
,
1
,
2
,
1
);
List
<
AttSchedule
>
atts
=
new
ArrayList
<
AttSchedule
>();
if
(
shiftm
.
getSxbcs
()
==
1
||
shiftm
.
getSxbcs
()
==
2
||
shiftm
.
getSxbcs
()
==
3
){
//1次上下班
...
...
src/main/java/cn/timer/api/controller/kqgl/ClockInTool.java
View file @
214aab91
...
...
@@ -28,9 +28,15 @@ public class ClockInTool {
* @param numtime
* @return 1:增加一年、2:增加一天、3:减10天、4:增加一个月
*/
public
static
String
requires_extra_times
(
String
timeStr
,
int
num
,
int
numtime
)
{
public
static
String
requires_extra_times
(
String
timeStr
,
int
num
,
int
numtime
,
int
daft
)
{
DateFormat
df
;
if
(
daft
==
1
)
{
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
}
else
{
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
}
DateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Date
date
=
null
;
try
{
date
=
df
.
parse
(
timeStr
);
...
...
@@ -46,8 +52,10 @@ public class ClockInTool {
cal
.
add
(
Calendar
.
DATE
,
num
);
//增加一天
}
else
if
(
numtime
==
3
)
{
cal
.
add
(
Calendar
.
DATE
,
num
);
//减10天
}
else
{
}
else
if
(
numtime
==
4
)
{
cal
.
add
(
Calendar
.
MONTH
,
num
);
//增加一个月
}
else
if
(
numtime
==
5
)
{
cal
.
add
(
Calendar
.
HOUR
,
num
);
}
return
df
.
format
(
cal
.
getTime
());
}
...
...
src/main/java/cn/timer/api/controller/kqgl/TimeCardController.java
View file @
214aab91
...
...
@@ -986,7 +986,7 @@ public class TimeCardController {
@ApiOperation
(
value
=
"39:删除考勤组"
,
httpMethod
=
"DELETE"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
39
)
public
Result
<
Integer
>
DelAttendanceGroup
(
@CurrentUser
UserBean
userBean
,
@PathVariable
(
"id"
)
Integer
id
)
{
if
(
KqglMainKqz
.
builder
().
id
(
id
).
build
().
deleteById
())
{
List
<
UserAttendanceRel
>
attusers
=
userattendancerelmapper
.
selectAttendanceOfficerByKqzid
(
id
,
userBean
.
getOrgCode
());
//该考勤组人数
//该考勤组所绑定的考勤机
List
<
KqglAssoKqzdkfs
>
kqjs
=
kqglassokqzdkfsmapper
.
selectList
(
new
QueryWrapper
<
KqglAssoKqzdkfs
>().
lambda
().
eq
(
KqglAssoKqzdkfs:
:
getKqzId
,
id
).
eq
(
KqglAssoKqzdkfs:
:
getType
,
1
));
...
...
@@ -1005,12 +1005,20 @@ public class TimeCardController {
params
.
add
(
"userId"
,
user_id
);
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpEntity
httpEntity
=
new
HttpEntity
(
params
,
headers
);
ResponseEntity
<
String
>
request
=
restTemplate
.
postForEntity
(
url
,
httpEntity
,
String
.
class
);
System
.
err
.
print
(
request
.
getBody
());
try
{
ResponseEntity
<
String
>
request
=
restTemplate
.
postForEntity
(
url
,
httpEntity
,
String
.
class
);
System
.
err
.
print
(
request
.
getBody
());
}
catch
(
RestClientException
e
)
{
System
.
err
.
println
(
"提示:考勤机服务出错"
);
return
ResultUtil
.
error
(
"删除失败:提示:考勤机服务出错"
);
}
}
}
}
if
(
KqglMainKqz
.
builder
().
id
(
id
).
build
().
deleteById
())
{
userequirelationmapper
.
deleteBykqzid
(
id
);
//删除考勤组绑定的打卡方式
...
...
src/main/java/cn/timer/api/dto/kqmk/DailyDetailsDto.java
View file @
214aab91
...
...
@@ -19,6 +19,7 @@ public class DailyDetailsDto {
private
String
dept
;
// 部门
private
String
post
;
// 岗位
private
String
attname
;
// 考勤组名称
private
Integer
attpbfs
;
// 排班方式(1:固定排班;2:自由排班;3:自由工时)
private
String
attdate
;
// 考勤日期
private
Integer
userid
;
// 用户ID
private
String
data
;
// 日期
...
...
src/main/resources/mapping/kqmk/KqglAssoMonthPunchSummaryMapper.xml
View file @
214aab91
...
...
@@ -167,6 +167,7 @@
<result
column=
"bcxbdk3"
property=
"bcxbdk3"
/>
<result
column=
"attname"
property=
"attname"
/>
<result
column=
"attpbfs"
property=
"attpbfs"
/>
<result
column=
"attdate"
property=
"attdate"
/>
<result
column=
"userid"
property=
"userid"
/>
<result
column=
"data"
property=
"data"
/>
...
...
@@ -249,7 +250,8 @@
<select
id=
"Dailydetails"
resultMap=
"DailyDetailsMap"
>
select sum.`name`,sum.num,sum.dept,sum.post,
(select kqz.name from kqgl_main_kqz kqz where kqz.id = sum.att_group) as attname,
IFNULL((select kqz.name from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') as attname,
IFNULL((select kqz.pbfs from kqgl_main_kqz kqz where kqz.id = sum.att_group),'') as attpbfs,
'' address,
'' remarks,
'' cardtype,
...
...
@@ -296,8 +298,8 @@
sum.working_transfer_overtime as workingtransferovertime,
sum.rest_transfer_overtime as resttransferovertime,
sum.holiday_transfer_overtime as holidaytransferovertime,
mrtj.
leaverulesid,
mrtj.duration
as balancedays
IFNULL(mrtj.leaverulesid,'') as
leaverulesid,
IFNULL(mrtj.duration,'')
as balancedays
from kqgl_asso_month_punch_summary sum
LEFT JOIN (
select DISTINCT info.`name` as username ,
...
...
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