Commit 214aab91 by lal Committed by chenzg

修复考勤BUG

parent e38a8e2b
...@@ -81,7 +81,7 @@ public class ClockInController { ...@@ -81,7 +81,7 @@ public class ClockInController {
String current_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); 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 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 startDateyesterday = DateUtil.getStartTime(0,DateUtil.getStringTime(yesterday,"yyyy-MM-dd")).getTime();
Long endDateyesterday = DateUtil.getnowEndTime(23,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 { ...@@ -90,7 +90,7 @@ public class ClockInController {
String toweek = ""; String toweek = "";
String msg = "未知错误,请联系管理员"; String msg = "未知错误,请联系管理员";
int sbyf = 0;//0:失败;1:成功 int sbyf = 1;//0:失败;1:成功
JSONObject jsonArray = new JSONObject(json); JSONObject jsonArray = new JSONObject(json);
String asDevId = jsonArray.get("dev_id").toString();//考勤机编码 String asDevId = jsonArray.get("dev_id").toString();//考勤机编码
...@@ -123,347 +123,473 @@ public class ClockInController { ...@@ -123,347 +123,473 @@ public class ClockInController {
int atttype = 0; int atttype = 0;
ClockCollectData clockt = new ClockCollectData(); ClockCollectData clockt = new ClockCollectData();
//putime: 根据日期 得到打卡所需的详细信息
AttendanceCardListDto attdate = MethodCall(qyid,userid,putime);
/*******/ /*******/
if(attgro != null) {//判断考勤组是否存在 if(attgro != null) {//判断考勤组是否存在
List<KqglAssoKqzdkfs> kqjs = KqglAssoKqzdkfs.builder().build().selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, attgro.getId())); List<KqglAssoKqzdkfs> kqjs = KqglAssoKqzdkfs.builder().build().selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, attgro.getId()));
if(kqjs.size() > 0) { 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查询是否存在次日打卡 */
//班次信息 if(attdate.getAttgrouptype() != 3) {
KqglAssoBcsz shif = kqglassobcszmapper.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, balan.getBcid()));
int dkcs = shif.getSxbcs()*2; //查询打卡当天是否有记录**********************************
KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build();
List<AttSchedule> ashss = attdate.getAttsch();//获取今天应打卡时间
System.out.println(ashss.get(0).getTime()); //putime: 根据日期 得到打卡所需的详细信息
boolean dnck = false; // AttendanceCardListDto attdate = MethodCall(qyid,userid,putime);
if(ashss.size() > 0) {
Date sd1=df1.parse(ClockInTool.stampToDate(String.valueOf(ashss.get(0).getTime())));//当天应打的首次上班卡时间 String dakariqi = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(startDateyesterday))+" "+ClockInTool.dateToWeek2(yesterday);
Date sd2=df1.parse(current_time);//当前时间
if(sd1.after(sd2)) { //检查昨日的班次是否存在次日打卡
dnck = true; 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 isXbdk1Cr = shif.getIsXbdk1Cr();//下班1是否次日(0:否;1:是) int dkcs = shif.getSxbcs()*2;
int isSbdk2Cr = shif.getIsSbdk2Cr();//上班2是否次日(0:否;1:是)
int isXbdk2Cr = shif.getIsXbdk2Cr();//下班2是否次日(0:否;1:是) List<AttSchedule> ashss = attdate.getAttsch();//获取今天应打卡时间
int isSbdk3Cr = shif.getIsSbdk3Cr();//上班3是否次日(0:否;1:是) boolean dnck = false;
int isXbdk3Cr = shif.getIsXbdk3Cr();//下班3是否次日(0:否;1:是) if(ashss.size() > 0) {
boolean crdk = false;//当次打卡是否存在次日打卡 Date sd1=df1.parse(ClockInTool.stampToDate(String.valueOf(ashss.get(0).getTime())));//当天应打的首次上班卡时间
if(balan.getSort() < dkcs) { Date sd2=df1.parse(current_time);//当前时间
if(balan.getSort()+1 == 2 && dkcs == 2) { if(sd1.after(sd2)) {
if(isXbdk1Cr > 0) {//次日 dnck = true;
crdk = true; }
}
}
if(balan.getSort()+1 == 3 && dkcs == 4) {
if(isSbdk2Cr > 0) {//次日
crdk = true;
} }
}
if(balan.getSort()+1 == 4 && dkcs == 4) { int isXbdk1Cr = shif.getIsXbdk1Cr();//下班1是否次日(0:否;1:是)
if(isXbdk2Cr > 0) {//次日 int isSbdk2Cr = shif.getIsSbdk2Cr();//上班2是否次日(0:否;1:是)
crdk = true; 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(crdk && dnck) {
if(balan.getSort()+1 == 5 && dkcs == 6) { dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userid)
if(isSbdk3Cr > 0) {//次日 .ge(KqglAssoDkmx::getDksj, startDateyesterday).le(KqglAssoDkmx::getDksj, endDateyesterday));
crdk = true; 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) { //putime: 根据日期 得到打卡所需的详细信息
if(isXbdk3Cr > 0) {//次日 // AttendanceCardListDto attdate = MethodCall(qyid,userid,putime);
crdk = true; // 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();
if(crdk && dnck) { endtime3 = ash.get(5).getTime();endtime3ks = ash.get(5).getStarttime();endtime3js = ash.get(5).getEndtime();
dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userid) }
}
// 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)); .ge(KqglAssoDkmx::getDksj, startDateyesterday).le(KqglAssoDkmx::getDksj, endDateyesterday));
attdate = MethodCall(qyid,userid,yesterday);
attendance_date = startDateyesterday; attendance_date = startDateyesterday;
toweek = yesterday; toweek = yesterday;
}else { }else {
dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userid) zydkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userid)
.ge(KqglAssoDkmx::getDksj, startDate).le(KqglAssoDkmx::getDksj, endDate)); .ge(KqglAssoDkmx::getDksj, startDate).le(KqglAssoDkmx::getDksj, endDate));
// attdate = MethodCall(qyid,userid,putime);
attendance_date = startDate; attendance_date = startDate;
toweek = putime; toweek = putime;
} }
}else {
//无记录的话就找昨天的数据
AttendanceCardListDto attdate1 = MethodCall(qyid,userid,yesterday);
}
if(zydkmc == null) {//新增
KqglAssoDkmx pcd = KqglAssoDkmx.builder().build();
//putime: 根据日期 得到打卡所需的详细信息 if(sd1.after(sd2)) {
// AttendanceCardListDto attdate = MethodCall(qyid,userid,putime); 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 {
// ClockCollectData clockt = new ClockCollectData(); 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();
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) { // 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();
List<AttSchedule> ash = attdate.getAttsch(); if (!pcd.insert()) {
int y = 0; throw new CustomException("打卡明细-新增异常-1");
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(isRange) { dkmx = pcd.getId();
int yzcd = shif.getYzcdfzs();//严重迟到分钟数 atttype = 1;
int kgcdfzs = shif.getKgcdfzs();//旷工迟到分钟数 }else {//修改
if(dkmc == null) {//上班1 ****新增 dkmx = zydkmc.getId();
int sbdk1jg = 0,yzcdsc = 0,yzcdcs = 0,kgcdcs = 0;
if(punchcardtime != 0){//有应打卡时间时 KqglAssoDkmx zypcd = KqglAssoDkmx.builder().build();
Long time = (time_ - punchcardtime)/1000/60;
if(time > 0){sbdk1jg = Math.abs(Integer.valueOf(time.toString()));}//上班1打卡结果 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; kqglassodkmxmapper.updateByPrimaryKeySelective(zypcd);//修改打卡记录
if(shif != null){ydkcs = shif.getSxbcs()*2;}//应打卡次数 }
if(sbdk1jg > yzcd) {
yzcdcs++; atttype = 2;
yzcdsc = sbdk1jg - yzcd; }else if((!("").equals(zydkmc.getSbdk1()) || zydkmc.getSbdk1() != null) && (!("").equals(zydkmc.getXbdk1()) || zydkmc.getXbdk1() != null)
} && (("").equals(zydkmc.getSbdk2()) || zydkmc.getSbdk2() == null)){//上班2
if(sbdk1jg > kgcdfzs) {kgcdcs++;} zypcd.setId(zydkmc.getId());
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(); zypcd.setSbdk2(time_);//上班1打卡时间
if (!pcd.insert()) { kqglassodkmxmapper.updateByPrimaryKeySelective(zypcd);//修改打卡记录
throw new CustomException("打卡明细-新增异常-1"); 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(); kqglassodkmxmapper.updateByPrimaryKeySelective(zypcd);//修改打卡记录
}else { //*****修改 }
dkmx = dkmc.getId(); atttype = 4;
KqglAssoDkmx pcd = KqglAssoDkmx.builder().build(); }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)
if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() == null)){//下班1 && (("").equals(zydkmc.getSbdk3()) || zydkmc.getSbdk3() == null)){//上班3
pcd.setId(dkmc.getId()); zypcd.setId(zydkmc.getId());
pcd.setXbdk1(time_);//下班1打卡时间 zypcd.setSbdk3(time_);//上班1打卡时间
if(punchcardtime != 0){//有应打卡时间时 kqglassodkmxmapper.updateByPrimaryKeySelective(zypcd);//修改打卡记录
Long time = (time_ - punchcardtime)/1000/60; atttype = 5;
if(time > 0){ }else if((!("").equals(zydkmc.getSbdk1()) || zydkmc.getSbdk1() != null) && (!("").equals(zydkmc.getXbdk1()) || zydkmc.getXbdk1() != null)
pcd.setXbdk1jg(0);// 打卡结果 && (!("").equals(zydkmc.getSbdk2()) || zydkmc.getSbdk2() != null) && (!("").equals(zydkmc.getXbdk2()) || zydkmc.getXbdk2() != null)
}else{ && (!("").equals(zydkmc.getSbdk3()) || zydkmc.getSbdk3() != null) && (("").equals(zydkmc.getXbdk3()) || zydkmc.getXbdk3() == null)){//下班3
pcd.setXbdk1jg(Math.abs(Integer.valueOf(time.toString())));//上班1打卡结果
} String clock_time = ClockInTool.requires_extra_times(ClockInTool.stampToDate(String.valueOf(zydkmc.getSbdk3())),canpunchworkdate,5,2);
}
Date zysd1=df1.parse(clock_time);//上班打卡后多久大下班卡的时间
if(dkmc.getSbdk1() != null){ Date zysd2=df1.parse(current_time);//当前时间
Long time = (time_ - dkmc.getSbdk1())/1000/60; if(zysd1.after(zysd2)) {//当zysd1大于zysd2时,返回TRUE,当小于等于时,返回false;
pcd.setGzsc(Math.abs(Double.valueOf(time.toString())));//只打一次卡时计算工作时长 msg = "自由工时:上班打卡后"+canpunchworkdate+"小时后,才可打下班卡";
} sbyf = 0;
kqglassodkmxmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录 }else {
zypcd.setId(zydkmc.getId());
}else if((!("").equals(dkmc.getSbdk1()) || dkmc.getSbdk1() != null) && (!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null) zypcd.setXbdk3(time_);//下班1打卡时间
&& (("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() == null)){//上班2 //班次为6次时,计算工作时长
if(zydkmc.getSbdk3() != null){
int sbdk2jg = 0,yzcdsc = 0,yzcdcs = 0,kgcdcs = 0; Long time = (time_ - zydkmc.getSbdk3())/1000/60;
if(punchcardtime != 0){//有应打卡时间时 BigDecimal om = new BigDecimal(zydkmc.getGzsc());//第二次
Long time = (time_ - punchcardtime)/1000/60; BigDecimal on = new BigDecimal(time);
if(time > 0){sbdk2jg = Math.abs(Integer.valueOf(time.toString()));} double worktime = Math.abs(om.add(on).doubleValue());
} zypcd.setGzsc(worktime);
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);//修改打卡记录
}else { }
msg = "当前打卡时间不在范围内";
sbyf = 0; atttype = 6;
} }else {
}else { atttype = 7;
msg = "当前是休息时间"; }
sbyf = 0; }
} }
}else { }else {
msg = "未检测到考勤机"; msg = "未检测到考勤机";
sbyf = 0; sbyf = 0;
} }
/*************************************************************************************************************************************************************************************/ /*************************************************************************************************************************************************************************************/
/*************************************************************************************************************************************************************************************/ /*************************************************************************************************************************************************************************************/
// 原始打卡记录数据录入 // 原始打卡记录数据录入
...@@ -478,42 +604,62 @@ public class ClockInController { ...@@ -478,42 +604,62 @@ public class ClockInController {
} }
} }
} }
int type,status = 0; int type,status = 0;
if((atttype)%2 > 0){ if((atttype)%2 > 0){
type = 1;// 类型(类型 0:无排班打卡 1:上班 2:下班) punchcardtime == 0:无班次打卡 type = 1;// 类型(类型 0:无排班打卡 1:上班 2:下班) punchcardtime == 0:无班次打卡
if(punchcardtime == 0 && clockt.getShifid() != 0){ if(attdate.getAttgrouptype() != 3) {
status = 1; if(punchcardtime == 0 && clockt.getShifid() != 0){
}if(punchcardtime == 0 && clockt.getShifid() == 0) { status = 1;
status = 2; }if(punchcardtime == 0 && clockt.getShifid() == 0) {
}else{ status = 2;
if(isRange) {// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休) }else{
if(time > 0){ if(isRange) {// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
status = 3; if(time > 0){
}else if(results == 0){ status = 3;
status = 1; }else if(results == 0){
status = 1;
}
}else {
status = 2;
} }
}
}else {
if(sbyf == 1) {
status = 1;
}else { }else {
status = 2; status = 2;
} }
} }
}else{ }else{
type = 2;// 类型(类型 0:无排班打卡 1:上班 2:下班) type = 2;// 类型(类型 0:无排班打卡 1:上班 2:下班)
if(punchcardtime == 0 && clockt.getShifid() != 0){ if(attdate.getAttgrouptype() != 3) {
status = 1; if(punchcardtime == 0 && clockt.getShifid() != 0){
}if(punchcardtime == 0 && clockt.getShifid() == 0) { status = 1;
status = 2; }if(punchcardtime == 0 && clockt.getShifid() == 0) {
}else{ status = 2;
if(isRange) { }else{
if(time < 0){ if(isRange) {
status = 4; if(time < 0){
}else if(results == 0){ status = 4;
status = 1; }else if(results == 0){
status = 1;
}
}else {
status = 2;
} }
}
}else {
if(sbyf == 1) {
status = 1;
}else { }else {
status = 2; status = 2;
} }
} }
} }
String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(attendance_date));//转换打卡时间格式 String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(attendance_date));//转换打卡时间格式
long attime; long attime;
// if(punchcardtime == 0 && !isRange){attime = new Date().getTime();}else{attime = punchcardtime;}// 考勤时间(应打卡时间) // if(punchcardtime == 0 && !isRange){attime = new Date().getTime();}else{attime = punchcardtime;}// 考勤时间(应打卡时间)
...@@ -715,7 +861,7 @@ public class ClockInController { ...@@ -715,7 +861,7 @@ public class ClockInController {
int isXbdk3Cr = shiftm.getIsXbdk3Cr();//下班3是否次日(0:否;1:是) 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>(); List<AttSchedule> atts = new ArrayList<AttSchedule>();
if(shiftm.getSxbcs() == 1 || shiftm.getSxbcs() == 2 || shiftm.getSxbcs() == 3){//1次上下班 if(shiftm.getSxbcs() == 1 || shiftm.getSxbcs() == 2 || shiftm.getSxbcs() == 3){//1次上下班
......
...@@ -28,9 +28,15 @@ public class ClockInTool { ...@@ -28,9 +28,15 @@ public class ClockInTool {
* @param numtime * @param numtime
* @return 1:增加一年、2:增加一天、3:减10天、4:增加一个月 * @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; Date date = null;
try { try {
date = df.parse(timeStr); date = df.parse(timeStr);
...@@ -46,8 +52,10 @@ public class ClockInTool { ...@@ -46,8 +52,10 @@ public class ClockInTool {
cal.add(Calendar.DATE, num);//增加一天 cal.add(Calendar.DATE, num);//增加一天
}else if(numtime == 3) { }else if(numtime == 3) {
cal.add(Calendar.DATE, num);//减10天 cal.add(Calendar.DATE, num);//减10天
}else { }else if(numtime == 4){
cal.add(Calendar.MONTH, num);//增加一个月 cal.add(Calendar.MONTH, num);//增加一个月
}else if(numtime == 5) {
cal.add(Calendar.HOUR, num);
} }
return df.format(cal.getTime()); return df.format(cal.getTime());
} }
......
...@@ -986,7 +986,7 @@ public class TimeCardController { ...@@ -986,7 +986,7 @@ public class TimeCardController {
@ApiOperation(value = "39:删除考勤组", httpMethod = "DELETE", notes = "接口发布说明") @ApiOperation(value = "39:删除考勤组", httpMethod = "DELETE", notes = "接口发布说明")
@ApiOperationSupport(order = 39) @ApiOperationSupport(order = 39)
public Result<Integer> DelAttendanceGroup(@CurrentUser UserBean userBean,@PathVariable("id") Integer id) { 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<UserAttendanceRel> attusers = userattendancerelmapper.selectAttendanceOfficerByKqzid(id, userBean.getOrgCode());//该考勤组人数
//该考勤组所绑定的考勤机 //该考勤组所绑定的考勤机
List<KqglAssoKqzdkfs> kqjs = kqglassokqzdkfsmapper.selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, id).eq(KqglAssoKqzdkfs::getType, 1)); List<KqglAssoKqzdkfs> kqjs = kqglassokqzdkfsmapper.selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, id).eq(KqglAssoKqzdkfs::getType, 1));
...@@ -1005,12 +1005,20 @@ public class TimeCardController { ...@@ -1005,12 +1005,20 @@ public class TimeCardController {
params.add("userId", user_id); params.add("userId", user_id);
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
HttpEntity httpEntity = new HttpEntity(params, headers); HttpEntity httpEntity = new HttpEntity(params, headers);
ResponseEntity<String> request = restTemplate.postForEntity(url, httpEntity, String.class); try {
System.err.print(request.getBody()); 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); userequirelationmapper.deleteBykqzid(id);
//删除考勤组绑定的打卡方式 //删除考勤组绑定的打卡方式
......
...@@ -19,6 +19,7 @@ public class DailyDetailsDto { ...@@ -19,6 +19,7 @@ public class DailyDetailsDto {
private String dept;// 部门 private String dept;// 部门
private String post;// 岗位 private String post;// 岗位
private String attname;// 考勤组名称 private String attname;// 考勤组名称
private Integer attpbfs;// 排班方式(1:固定排班;2:自由排班;3:自由工时)
private String attdate;// 考勤日期 private String attdate;// 考勤日期
private Integer userid;// 用户ID private Integer userid;// 用户ID
private String data;// 日期 private String data;// 日期
......
...@@ -167,6 +167,7 @@ ...@@ -167,6 +167,7 @@
<result column="bcxbdk3" property="bcxbdk3" /> <result column="bcxbdk3" property="bcxbdk3" />
<result column="attname" property="attname" /> <result column="attname" property="attname" />
<result column="attpbfs" property="attpbfs" />
<result column="attdate" property="attdate" /> <result column="attdate" property="attdate" />
<result column="userid" property="userid" /> <result column="userid" property="userid" />
<result column="data" property="data" /> <result column="data" property="data" />
...@@ -249,7 +250,8 @@ ...@@ -249,7 +250,8 @@
<select id="Dailydetails" resultMap="DailyDetailsMap"> <select id="Dailydetails" resultMap="DailyDetailsMap">
select sum.`name`,sum.num,sum.dept,sum.post, 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, '' address,
'' remarks, '' remarks,
'' cardtype, '' cardtype,
...@@ -296,8 +298,8 @@ ...@@ -296,8 +298,8 @@
sum.working_transfer_overtime as workingtransferovertime, sum.working_transfer_overtime as workingtransferovertime,
sum.rest_transfer_overtime as resttransferovertime, sum.rest_transfer_overtime as resttransferovertime,
sum.holiday_transfer_overtime as holidaytransferovertime, sum.holiday_transfer_overtime as holidaytransferovertime,
mrtj.leaverulesid, IFNULL(mrtj.leaverulesid,'') as leaverulesid,
mrtj.duration as balancedays IFNULL(mrtj.duration,'') as balancedays
from kqgl_asso_month_punch_summary sum from kqgl_asso_month_punch_summary sum
LEFT JOIN ( LEFT JOIN (
select DISTINCT info.`name` as username , select DISTINCT info.`name` as username ,
......
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