Commit 12819cca by lal

提交BUG

parent f79ce8e4
......@@ -4,8 +4,11 @@ import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
......@@ -118,10 +121,14 @@ public class ClockInController {
int dkmx = 0;
int shifid = 0;
long punchcardtime = 0,punchstart,punchend = 0;//应打卡时间,应打卡开始时间,应打卡结束时间
long punchcardtime = 0,punchstart = 0,punchend = 0;//应打卡时间,应打卡开始时间,应打卡结束时间
boolean isRange = true;
int atttype = 0;
int execution_status = 0;//执行状态
boolean kskd = true;//识别是否更新最后一次打卡
ClockCollectData clockt = new ClockCollectData();
//putime: 根据日期 得到打卡所需的详细信息
......@@ -226,9 +233,11 @@ public class ClockInController {
msg = "当前未排班";
sbyf = 0;
}else {
long iclock_time = time_;//
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;
int dakjg1 = 0,dakjg2 = 0,dakjg3 = 0,dakjg4 = 0,dakjg5 = 0,dakjg6 = 0;//打卡时间与应打卡时间的间隔分钟数
if(attdate.getAttsch().size() > 0) {
List<AttSchedule> ash = attdate.getAttsch();
int y = 0;
......@@ -237,61 +246,203 @@ public class ClockInController {
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();
dakjg1 = Math.abs(Integer.valueOf(String.valueOf((iclock_time - starttime1) / (1000 * 60))));
dakjg2 = Math.abs(Integer.valueOf(String.valueOf((iclock_time - endtime1) / (1000 * 60))));
}
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();
dakjg3 = Math.abs(Integer.valueOf(String.valueOf((iclock_time - starttime2) / (1000 * 60))));
dakjg4 = Math.abs(Integer.valueOf(String.valueOf((iclock_time - endtime2) / (1000 * 60))));
}
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();
dakjg5 = Math.abs(Integer.valueOf(String.valueOf((iclock_time - starttime3) / (1000 * 60))));
dakjg6 = Math.abs(Integer.valueOf(String.valueOf((iclock_time - endtime3) / (1000 * 60))));
}
Map<String, Integer> comparemap = new HashMap();
if(dkmc == null) {
//打卡时间 对比班次 接近哪个时间就打哪个时间的卡
if(attdate.getAttsch().size() == 2 || attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
comparemap.put("1", dakjg1); comparemap.put("2", dakjg2);
}
if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
comparemap.put("3", dakjg3); comparemap.put("4", dakjg4);
}
if(attdate.getAttsch().size() == 6) {
comparemap.put("5", dakjg5); comparemap.put("6", dakjg6);
}
execution_status = 1;
}else {
execution_status = 2;
// boolean kskd = true;
if(attdate.getAttsch().size() == 2) {
if(dkmc.getSbdk1() != null) {
kskd = false;
comparemap.clear();
comparemap.put("2", dakjg2);
}
//最后一次卡的时候 再继续打视为更新最后一次打卡
if(dkmc.getXbdk1() != null) {
comparemap.put("2", dakjg2);
}
}
if(attdate.getAttsch().size() == 4) {
if(dkmc.getSbdk1() != null) {
kskd = false;
comparemap.clear();
comparemap.put("2", dakjg2); comparemap.put("3", dakjg3);
comparemap.put("4", dakjg4);
}
if(dkmc.getXbdk1() != null) {
kskd = false;
comparemap.clear();
comparemap.put("3", dakjg3); comparemap.put("4", dakjg4);
}
if(dkmc.getSbdk2() != null) {
kskd = false;
comparemap.clear();
comparemap.put("4", dakjg4);
}
//最后一次卡的时候 再继续打视为更新最后一次打卡
if(dkmc.getXbdk2() != null) {
kskd = true;
comparemap.clear();
comparemap.put("4", dakjg4);
}
}
if(attdate.getAttsch().size() == 6) {
if(dkmc.getSbdk1() != null) {
kskd = false;
comparemap.clear();
comparemap.put("2", dakjg2); comparemap.put("3", dakjg3);
comparemap.put("4", dakjg4); comparemap.put("5", dakjg5);
comparemap.put("6", dakjg6);
}
if(dkmc.getXbdk1() != null) {
kskd = false;
comparemap.clear();
comparemap.put("3", dakjg3); comparemap.put("4", dakjg4);
comparemap.put("5", dakjg5); comparemap.put("6", dakjg6);
}
if(dkmc.getSbdk2() != null) {
kskd = false;
comparemap.clear();
comparemap.put("4", dakjg4); comparemap.put("5", dakjg5);
comparemap.put("6", dakjg6);
}
if(dkmc.getXbdk2() != null) {
kskd = false;
comparemap.clear();
comparemap.put("5", dakjg5); comparemap.put("6", dakjg6);
}
if(dkmc.getSbdk3() != null) {
kskd = false;
comparemap.clear();
comparemap.put("6", dakjg6);
}
// long punchcardtime,punchstart,punchend = 0;//应打卡时间,应打卡开始时间,应打卡结束时间
// int atttype = 0;
if(dkmc == null) {//上班1 ****新增
//最后一次卡的时候 再继续打视为更新最后一次打卡
if(dkmc.getXbdk3() != null) {
kskd = true;
comparemap.clear();
comparemap.put("6", dakjg6);
}
// if(kskd) {
// comparemap.put("6", dakjg6);
// }
}
}
if(comparemap.size() > 0) {
List<Map.Entry<String,Integer>> list = new ArrayList(comparemap.entrySet());
Collections.sort(list, (o1, o2) -> (o1.getValue() - o2.getValue()));
atttype = Integer.valueOf(list.get(0).getKey());//应打卡的顺序
}
}
if(atttype == 1) {
punchcardtime = starttime1;
punchstart = starttime1ks;
punchend = starttime1js;
atttype = 1;
}else {
if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() == null)){ //下班1
}else if(atttype == 2) {
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
}else if(atttype == 3) {
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
}else if(atttype == 4) {
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
}else if(atttype == 5) {
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
}else if(atttype == 6) {
punchcardtime = endtime3;
punchstart = endtime3ks;
punchend = endtime3js;
atttype = 6;
}else {
punchcardtime = 0;punchstart = 0;punchend = 0;atttype = 7;
}
}
// 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();
......@@ -316,29 +467,56 @@ public class ClockInController {
if(isRange) {
int yzcd = shif.getYzcdfzs();//严重迟到分钟数
int kgcdfzs = shif.getKgcdfzs();//旷工迟到分钟数
if(dkmc == null) {//上班1 ****新增
int sbdk1jg = 0,yzcdsc = 0,yzcdcs = 0,kgcdcs = 0;
if(execution_status == 1) {//上班1 ****新增
KqglAssoDkmx pcd = KqglAssoDkmx.builder().userid(userid).data(putime).qyid(qyid).dksj(startDate).build();
int sbdkjg = 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打卡结果
if(time > 0){//上班1打卡结果
sbdkjg = Math.abs(Integer.valueOf(time.toString()));
}
}
if(atttype == 1) {
pcd.setSbdk1(time_);
pcd.setSbdk1jg(sbdkjg);
}else if(atttype == 2) {
pcd.setXbdk1(time_);
pcd.setXbdk1jg(sbdkjg);
}else if(atttype == 3) {
pcd.setSbdk2(time_);
pcd.setSbdk2jg(sbdkjg);
}else if(atttype == 4) {
pcd.setXbdk2(time_);
pcd.setXbdk2jg(sbdkjg);
}else if(atttype == 5) {
pcd.setSbdk3(time_);
pcd.setSbdk3jg(sbdkjg);
}else if(atttype == 6) {
pcd.setXbdk3(time_);
pcd.setXbdk3jg(sbdkjg);
}
int ydkcs = 0;
if(shif != null){ydkcs = shif.getSxbcs()*2;}//应打卡次数
if(sbdk1jg > yzcd) {
if(sbdkjg > yzcd) {
yzcdcs++;
yzcdsc = sbdk1jg - yzcd;
yzcdsc = sbdkjg - 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(sbdkjg > kgcdfzs) {kgcdcs++;}
pcd.setYdkcs(ydkcs);
pcd.setYzcdcs(yzcdcs);
pcd.setYzcdsc(Double.valueOf(yzcdsc));
pcd.setKgcdfzs(kgcdcs);
if (!pcd.insert()) {
throw new CustomException("打卡明细-新增异常-1");
}
dkmx = pcd.getId();
}else { //*****修改
}else if(execution_status == 2){ //*****修改
dkmx = dkmc.getId();
KqglAssoDkmx pcd = KqglAssoDkmx.builder().build();
if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() == null)){//下班1
if(atttype == 2){//下班1
pcd.setId(dkmc.getId());
pcd.setXbdk1(time_);//下班1打卡时间
if(punchcardtime != 0){//有应打卡时间时
......@@ -356,8 +534,7 @@ public class ClockInController {
}
kqglassodkmxmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null)
&& (("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() == null)){//上班2
}else if(atttype == 3){//上班2
int sbdk2jg = 0,yzcdsc = 0,yzcdcs = 0,kgcdcs = 0;
if(punchcardtime != 0){//有应打卡时间时
......@@ -379,8 +556,7 @@ public class ClockInController {
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
}else if(atttype == 4){//下班2
pcd.setId(dkmc.getId());
pcd.setXbdk2(time_);//下班1打卡时间
......@@ -403,9 +579,7 @@ public class ClockInController {
}
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
}else if(atttype == 5){//上班3
int sbdk3jg = 0,yzcdsc = 0,yzcdcs = 0,kgcdcs = 0;
if(punchcardtime != 0){//有应打卡时间时
......@@ -427,9 +601,7 @@ public class ClockInController {
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
}else if(atttype == 6){//下班3
pcd.setId(dkmc.getId());
pcd.setXbdk3(time_);//下班1打卡时间
......@@ -452,10 +624,11 @@ public class ClockInController {
}
pcd.setId(dkmc.getId());
if(atttype <= 6){
if(atttype <= 6 && atttype > 0){
int update = kqglassodkmxmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}
}
}else {
msg = "当前打卡时间不在范围内";
sbyf = 0;
......@@ -604,6 +777,16 @@ public class ClockInController {
/*************************************************************************************************************************************************************************************/
/*************************************************************************************************************************************************************************************/
String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(attendance_date));//转换打卡时间格式
//true:确认为最后一次打卡更新打卡时 之前打卡的一条数据变为“打卡更新数据”
if(kskd) {
KqglAssoDkjl dkjj = KqglAssoDkjl.builder().build().selectOne(new QueryWrapper<KqglAssoDkjl>().lambda().eq(KqglAssoDkjl::getUserId, userid).eq(KqglAssoDkjl::getType, 2)
.eq(KqglAssoDkjl::getSort, atttype).eq(KqglAssoDkjl::getQyid, qyid).eq(KqglAssoDkjl::getAttdate, attdate_+" "+ClockInTool.dateToWeek2(toweek)));
KqglAssoDkjl.builder().id(dkjj.getId()).status(0).sort(0).build().updateById();
}
// 原始打卡记录数据录入
int results = 0;
Long time = (time_ - punchcardtime)/1000/60;
......@@ -679,7 +862,7 @@ public class ClockInController {
}
}
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;}// 考勤时间(应打卡时间)
if(punchcardtime == 0){// 考勤时间(应打卡时间)
......
......@@ -2206,32 +2206,46 @@ public class TimeCardController {
if(chpunchr.getClocktype() == 1) {
sbdk1 = changed_time;
sbdk1jg = results;
if(results == 0) {
sbdk1jg = -1;
}
KqglAssoDkmx.builder().id(dkmx.getId()).sbdk1(sbdk1).sbdk1jg(sbdk1jg).build().updateById();
}else if(chpunchr.getClocktype() == 2) {
xbdk1 = changed_time;
xbdk1jg = results;
if(results == 0) {
xbdk1jg = -1;
}
KqglAssoDkmx.builder().id(dkmx.getId()).xbdk1(xbdk1).xbdk1jg(xbdk1jg).build().updateById();
}else if(chpunchr.getClocktype() == 3) {
sbdk2 = changed_time;
sbdk2jg = results;
if(results == 0) {
sbdk2jg = -1;
}
KqglAssoDkmx.builder().id(dkmx.getId()).sbdk2(sbdk2).sbdk2jg(sbdk2jg).build().updateById();
}else if(chpunchr.getClocktype() == 4) {
xbdk2 = changed_time;
xbdk2jg = results;
if(results == 0) {
xbdk2jg = -1;
}
KqglAssoDkmx.builder().id(dkmx.getId()).xbdk2(xbdk2).xbdk2jg(xbdk2jg).build().updateById();
}else if(chpunchr.getClocktype() == 5) {
sbdk3 = changed_time;
sbdk3jg = results;
if(results == 0) {
sbdk3jg = -1;
}
KqglAssoDkmx.builder().id(dkmx.getId()).sbdk3(sbdk3).sbdk3jg(sbdk3jg).build().updateById();
}else {
xbdk3 = changed_time;
xbdk3jg = results;
if(results == 0) {
xbdk3jg = -1;
}
KqglAssoDkmx.builder().id(dkmx.getId()).xbdk3(xbdk3).xbdk3jg(xbdk3jg).build().updateById();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment