Commit 4ec7235a by 陶湘宇

修复穗港跨天打卡bug

parent f8142048
......@@ -142,14 +142,10 @@ public class ClockInController {
//pbfs;// 排班方式 1:固定排班;2:自由排班;3:自由工时
/*******/
long time_ = DateUtil.getStringTime(sStdIoTime, "yyyy-MM-dd HH:mm:ss");//打卡时间戳
long time_ = DateUtil.getStringTime(sStdIoTime, "yyyy-MM-dd HH:mm:SS");//打卡时间戳
long isFirsTimer=time_+60*60*1000;
String putime = new SimpleDateFormat("yyyy-MM-dd").format(time_);//转换打卡时间格式 年月日
String putimehhmm = new SimpleDateFormat("yyyy-MM-dd HH:mm").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();
int dkmx = 0;
int shifid = 0;
long punchcardtime = 0,punchstart = 0,punchend = 0;//应打卡时间,应打卡开始时间,应打卡结束时间
......@@ -160,7 +156,14 @@ public class ClockInController {
boolean sbdkkd = false;//针对于上班 未超过上班卡打卡 视为无效打卡
ClockCollectData clockt = new ClockCollectData();
//putime: 根据日期 得到打卡所需的详细信息
AttendanceCardListDto attdate = MethodCall(qyid,userid,putime);
AttendanceCardListDto attdate = MethodCall(qyid,userid,ClockInTool.paraseStringToDate(sStdIoTime,"yyyy-MM-dd HH:mm:SS"));
// = new SimpleDateFormat("yyyy-MM-dd").format(sStdIoTime);//转换打卡时间格式 年月日
String putime= new SimpleDateFormat("yyyy-MM-dd").format(attdate.getAttsch().get(0).getTime());//转换打卡时间格式 年月日
String putimehhmm = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(attdate.getAttsch().get(0).getTime());//转换打卡时间格式 年月日
//打卡当天开始时间,打卡当天结束时间
Long startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(putime,"yyyy-MM-dd")).getTime();
Long endDate = DateUtil.getnowEndTime(23,DateUtil.getStringTime(putime,"yyyy-MM-dd")).getTime();
/*******/
if(attgro != null) {//判断考勤组是否存在
List<KqglAssoKqzdkfs> kqjs = KqglAssoKqzdkfs.builder().build().selectList(new QueryWrapper<KqglAssoKqzdkfs>().lambda().eq(KqglAssoKqzdkfs::getKqzId, attgro.getId()));
......@@ -198,7 +201,9 @@ public class ClockInController {
if((isXbdk1Cr + isSbdk2Cr +isXbdk2Cr + isSbdk3Cr + isXbdk3Cr) > 0) {
crdk = true;
}
//如果是上班打卡,没有次日
if(attdate.getAttsch().get(0).getSort()==1&&attdate.getAttsch().get(0).getStarttime()<time_&&attdate.getAttsch().get(0).getEndtime()>time_)
crdk = false;
// if(balan.getSort()+1 == 2 && dkcs == 2) {
// //次日
// if(isXbdk1Cr > 0) { crdk = true; }
......@@ -241,8 +246,11 @@ public class ClockInController {
int isXbdk2Cr = shifi.getIsXbdk2Cr();//下班2是否次日(0:否;1:是)
int isSbdk3Cr = shifi.getIsSbdk3Cr();//上班3是否次日(0:否;1:是)
int isXbdk3Cr = shifi.getIsXbdk3Cr();//下班3是否次日(0:否;1:是)
if((isXbdk1Cr + isSbdk2Cr +isXbdk2Cr + isSbdk3Cr + isXbdk3Cr) > 0) {
//如果是上班打卡,没有次日
if(attdate.getAttsch().get(0).getSort()==1&&attdate.getAttsch().get(0).getStarttime()<time_&&attdate.getAttsch().get(0).getEndtime()>time_)
crdk = false;
else if((isXbdk1Cr + isSbdk2Cr +isXbdk2Cr + isSbdk3Cr + isXbdk3Cr) > 0) {
crdk = true;
attdate = MethodCall(qyid,userid,yesterday);
......@@ -250,9 +258,10 @@ public class ClockInController {
}else {
crdk = false;
}
}
}
if(crdk && dnck) {
dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userid).eq(KqglAssoDkmx::getQyid, qyid)
.ge(KqglAssoDkmx::getDksj, startDateyesterday).le(KqglAssoDkmx::getDksj, endDateyesterday).eq(KqglAssoDkmx::getData, yesterday));
......@@ -1211,12 +1220,14 @@ public class ClockInController {
* @return
* 获取当天打卡班次数据
*/
public AttendanceCardListDto MethodCall(int qyid,int userid,String date) throws ParseException {
public AttendanceCardListDto MethodCall(int qyid,int userid,Date date) throws ParseException {
AttendanceCardListDto attcar = new AttendanceCardListDto();
String str = null;
if(!("").equals(date)){
str = date;
str = new SimpleDateFormat("yyyy-MM-dd").format(date);//转换打卡时间格式 年月日
}else{
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
......@@ -1242,7 +1253,8 @@ public class ClockInController {
attcar.setAttsch(atts);
}else{//今天上班
KqglAssoBcsz bcz = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, atwek.getBcid()));
String putdate=getPutDate(bcz,date);
str=putdate;
if(bcz != null){
Getshiftinformationbatch(bcz,attcar,str);
}
......@@ -1348,7 +1360,150 @@ public class ClockInController {
return attcar;
}
/**
* @param qyid
* @param userid
* @param date
* @return
* 获取当天打卡班次数据
*/
public AttendanceCardListDto MethodCall(int qyid,int userid,String putdate) throws ParseException {
AttendanceCardListDto attcar = new AttendanceCardListDto();
String str = null;
if(!("").equals(putdate)){
str = putdate;//转换打卡时间格式 年月日
}else{
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
str = sdf.format(d);
}
KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(userid,qyid); //考勤组信息
//pbfs:排班方式 1:固定排班;2:自由排班;3:自由工时
if(attgro != null){//判断当前用户是否加入到考勤组
//排班制
KqglAssoPbmxDto jrpb = kqglassopbmxmapper.getScheduleSpecificAttendance(attgro.getId(),userid,str);
//固定排班
int week = Integer.valueOf(ClockInTool.dateToWeek(str));//4
KqglAssoZhoupaiban atwek = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
.eq(KqglAssoZhoupaiban::getType, week).ne(KqglAssoZhoupaiban::getBcid, 0));
if(attgro.getPbfs() == 1){//固定排班
if(atwek != null){//有固定周排班
KqglAssoTeshu rest = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, attgro.getId())
.eq(KqglAssoTeshu::getTsrq, str).eq(KqglAssoTeshu::getBcid, 0));
if(rest != null){//今天休息 Sort返回0【特殊日期--休息】
List<AttSchedule> atts = new ArrayList<AttSchedule>();
AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
atts.add(as);
attcar.setAttsch(atts);
}else{//今天上班
KqglAssoBcsz bcz = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, atwek.getBcid()));
if(bcz != null){
Getshiftinformationbatch(bcz,attcar,str);
}
}
}else{//必须打卡
KqglAssoTeshu tsri = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, attgro.getId())
.eq(KqglAssoTeshu::getTsrq, str).ne(KqglAssoTeshu::getBcid, 0));
if(tsri != null){
KqglAssoBcsz tsrq = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, tsri.getBcid()));
if(tsrq!=null){
Getshiftinformationbatch(tsrq,attcar,str);
}
}else{//休息
List<AttSchedule> atts = new ArrayList<AttSchedule>();
AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
atts.add(as);
attcar.setAttsch(atts);
}
}
}else if(attgro.getPbfs() == 2){//自由排班
//未排班时,员工可选择班次打卡
// if(attgro.getIsXzbcdk() == 1){
// attcar.setOptscheduling(true);
// }else{
// attcar.setOptscheduling(false);
// }
if(jrpb != null){
if(jrpb.getBcid() != 0){//有班次时("Bcid"不为0时)
KqglAssoBcsz tsrq = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, jrpb.getBcid()));
/**已简化**/
Getshiftinformationbatch(tsrq,attcar,str);
}else{//当天排班为休息
List<AttSchedule> atts1 = new ArrayList<AttSchedule>();
AttSchedule as = AttSchedule.builder().id(0).sort(0).time(0l).starttime(0l).endtime(0l).build();
atts1.add(as);
attcar.setAttsch(atts1);
}
}
}else{//自由工时
KqglAssoZhoupaiban wekz = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
.eq(KqglAssoZhoupaiban::getBcid, 0).eq(KqglAssoZhoupaiban::getType, week));
if(wekz != null){//
String dada = str+" "+attgro.getKqkssjTime()+":00";
attcar.setStapclotime(Long.valueOf(ClockInTool.dateToStamp(dada)));
}
if(!("").equals(attgro.getJbzdsc())){
attcar.setCanpunchworkdate(Double.valueOf(attgro.getJbzdsc()));//上班打卡后多久大下班卡
}
}
if(jrpb != null || atwek != null){
KqglAssoBcsz shif = KqglAssoBcsz.builder().build();
if(attgro.getPbfs() == 1){
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, atwek.getBcid()));
}else if(attgro.getPbfs() == 2){
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, jrpb.getBcid()));
}
if(shif != null){
if(shif.getIsXbdk() == 1){
attcar.setNoclockout(true);// 下班不用打卡
}else{
attcar.setNoclockout(false);// 下班不用打卡
}
attcar.setAllowlate(shif.getYxcdfzs());// 允许迟到分钟数
attcar.setSeriouslate(shif.getYzcdfzs());// 严重迟到分钟数
attcar.setAbsenteeismlate(shif.getKgcdfzs());// 旷工迟到分钟数
if(shif.getIsWzwd() == 1){
attcar.setIslatelate(true);// 晚走晚到
List<AttLateLate> atwzwd = new ArrayList<AttLateLate>();
int p = 0;
if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1())){p = 2;}
if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1()) && !("").equals(shif.getXbwz2()) && !("").equals(shif.getSbwd2())){p = 4;}
if(!("").equals(shif.getXbwz1()) && !("").equals(shif.getSbwd1()) && !("").equals(shif.getXbwz2()) && !("").equals(shif.getSbwd2()) && !("").equals(shif.getXbwz3()) && !("").equals(shif.getSbwd3())){p = 6;}
AttLateLate ala = AttLateLate.builder().build();
ala.setLatewalk(shif.getXbwz1());
ala.setArrivelate(shif.getSbwd1());
atwzwd.add(ala);
if(p == 4 || p == 6){
AttLateLate alat = AttLateLate.builder().build();
alat.setLatewalk(shif.getXbwz2());
alat.setArrivelate(shif.getSbwd2());
atwzwd.add(alat);
}
if(p == 6){
AttLateLate alas = AttLateLate.builder().build();
alas.setLatewalk(shif.getXbwz3());
alas.setArrivelate(shif.getSbwd3());
atwzwd.add(alas);
}
attcar.setAttlat(atwzwd);
}else{
attcar.setIslatelate(false);// 晚走晚到
}
}
}
attcar.setAttgrouptype(attgro.getPbfs());//1:固定排班;2:自由排班;3:自由工时
}else{
attcar.setAttgrouptype(0);//1:固定排班;2:自由排班;3:自由工时
}
return attcar;
}
/**
* @param shiftm
* @param attcar
......@@ -1360,7 +1515,7 @@ public class ClockInController {
int isXbdk2Cr = shiftm.getIsXbdk2Cr();//下班2是否次日(0:否;1:是)
int isSbdk3Cr = shiftm.getIsSbdk3Cr();//上班3是否次日(0:否;1:是)
int isXbdk3Cr = shiftm.getIsXbdk3Cr();//下班3是否次日(0:否;1:是)
//次日专用
String next_day = ClockInTool.requires_extra_times(str,1,2,1);
......@@ -1468,7 +1623,14 @@ public class ClockInController {
}
}
String getPutDate(KqglAssoBcsz bcz,Date puttime){
String workHour=new SimpleDateFormat("HHmmss").format(puttime);
//如果是跨天并且在下班打卡时间范围,就算到上一天考勤
if(bcz.getIsXbdk1Cr()==1&&Integer.parseInt(bcz.getXbqjks1().replace(":","")+"00")<Integer.parseInt(workHour)&&Integer.parseInt(bcz.getXbqjjs1().replace(":","")+"00")>Integer.parseInt(workHour))
return ClockInTool.requires_extra_times(new SimpleDateFormat("yyyy-MM-dd").format(puttime),-1,2,1);//昨天的班次
else
return new SimpleDateFormat("yyyy-MM-dd").format(puttime);//转换打卡时间格式 年月日;
}
/************************************************************************************************************************************************************************************************/
/************************************************************************** APP打卡 *************************************************************************************************************/
......
......@@ -233,7 +233,17 @@ public class ClockInTool {
}
return date;
}
// 将字符串转化为日期
public static Date paraseStringToDate(String timestr,String format){
Date date = null;
Format f = new SimpleDateFormat(format);
try {
date = (Date) f.parseObject(timestr);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/***
* 去除String数组中的空值
*/
......
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