Commit 75dddfea by lal Committed by chenzg

提交

parent 67cb9cdf
package cn.timer.api.controller.kqgl;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -21,18 +27,18 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import cn.hutool.json.JSONObject;
import cn.timer.api.bean.kqgl.AttConditions;
import cn.timer.api.bean.kqgl.AttGroupBinPunchMode;
import cn.timer.api.bean.kqgl.AttendanceGroup;
import cn.timer.api.bean.kqgl.AttendanceMachine;
import cn.timer.api.bean.kqgl.AttendanceWeeklySch;
import cn.timer.api.bean.kqgl.PunchCardAddress;
import cn.timer.api.bean.kqgl.PunchCardDetails;
import cn.timer.api.bean.kqgl.PunchCardWiFi;
import cn.timer.api.dto.kqmk.PunchRecord;
import cn.timer.api.bean.kqgl.ShiftManagement;
import cn.timer.api.bean.kqgl.Schedule;
import cn.timer.api.bean.kqmk.KqglAssoBcsz;
import cn.timer.api.bean.kqmk.KqglAssoDkjl;
import cn.timer.api.bean.kqmk.KqglAssoDkmx;
import cn.timer.api.bean.kqmk.KqglAssoKqj;
import cn.timer.api.bean.kqmk.KqglAssoKqzdkfs;
import cn.timer.api.bean.kqmk.KqglAssoPbmx;
import cn.timer.api.bean.kqmk.KqglAssoRelationSummary;
import cn.timer.api.bean.kqmk.KqglAssoTeshu;
import cn.timer.api.bean.kqmk.KqglAssoZhoupaiban;
import cn.timer.api.bean.kqmk.KqglMainKqz;
......@@ -41,17 +47,16 @@ import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.dao.kqgl.AttGroupBinPunchModeMapper;
import cn.timer.api.dao.kqgl.AttendanceGroupMapper;
import cn.timer.api.dao.kqgl.AttendanceMachineMapper;
import cn.timer.api.dao.kqgl.AttendanceWeeklySchMapper;
import cn.timer.api.dao.kqgl.PunchCardAddressMapper;
import cn.timer.api.dao.kqgl.PunchCardDetailsMapper;
import cn.timer.api.dao.kqgl.PunchCardWiFiMapper;
import cn.timer.api.dao.kqgl.PunchRecordMapper;
import cn.timer.api.dao.kqgl.ShiftManagementMapper;
import cn.timer.api.dao.kqgl.ScheduleMapper;
import cn.timer.api.dao.kqmk.KqglAssoBcszMapper;
import cn.timer.api.dao.kqmk.KqglAssoDkjlMapper;
import cn.timer.api.dao.kqmk.KqglAssoDkmxMapper;
import cn.timer.api.dao.kqmk.KqglAssoPbmxMapper;
import cn.timer.api.dao.kqmk.KqglAssoTeshuMapper;
import cn.timer.api.dao.kqmk.KqglMainKqzMapper;
import cn.timer.api.dto.kqmk.AttClockMethod;
import cn.timer.api.dto.kqmk.AttLateLate;
......@@ -59,6 +64,7 @@ import cn.timer.api.dto.kqmk.AttSchedule;
import cn.timer.api.dto.kqmk.AttendanceCardListDto;
import cn.timer.api.dto.kqmk.ClockCollectData;
import cn.timer.api.dto.kqmk.KqglAssoPbmxDto;
import cn.timer.api.dto.kqmk.WorkbenchCalendarDto;
import cn.timer.api.utils.DateUtil;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
......@@ -1277,436 +1283,813 @@ public class ClockInController {
/************************************************************************** APP打卡 *************************************************************************************************************/
/************************************************************************************************************************************************************************************************/
//考勤组
@Autowired
private AttendanceGroupMapper attendancegroupmapper;
//班次
@Autowired
private ShiftManagementMapper shiftmanagementmapper;
//打卡明细表
@Autowired
private PunchCardDetailsMapper punchcarddetailsmapper;
//打卡记录
@Autowired
private PunchRecordMapper punchrecordmapper;
/**
* 考勤打卡------APP打卡
* @throws ParseException
*/
@PostMapping(value = "/AttendanceCard")
@ApiOperation(value = "考勤打卡------APP打卡", httpMethod = "POST", notes = "接口发布说明")
@ApiOperationSupport(order = 2)
public Result<Void> AttendanceCard(@CurrentUser UserBean userBean,@RequestBody ClockCollectData clock) {
int qyid = userBean.getOrgCode();//坏小孩【企业id】
int userid = userBean.getEmpNum();//用户id
public Result<Object> AttendanceCard(@CurrentUser UserBean userBean,@RequestBody ClockCollectData clock) throws ParseException {
//当前时间
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 sStdIoTime = clock.getPunchtime();
AttendanceGroup attgro = attendancegroupmapper.getAttendanceGroupInformationByUserid(userid,qyid); //考勤组信息
//pbfs;// 排班方式 1:固定排班;2:自由排班;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();
Long attendance_date = 0l;//考勤日期
String toweek = "";
String msg = "未知错误,请联系管理员";
int sbyf = 1;//0:失败;1:成功
YgglMainEmp user = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getEmpNum, clock.getUserid()).eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()));
if(user != null) {
int qyid = user.getOrgCode();
int userid = user.getEmpNum();
// AttendanceGroup attgro = attendancegroupmapper.getAttendanceGroupInformationByUserid(userid,qyid); //考勤组信息
KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(userid,qyid); //考勤组信息
// pbfs;// 排班方式 1:固定排班;2:自由排班;3:自由工时
long time_ = DateUtil.getStringTime(clock.getPunchtime(), "yyyy-MM-dd HH:mm:ss");//打卡时间戳
String putime = new SimpleDateFormat("yyyy-MM-dd").format(Double.valueOf(clock.getPunchtime()));//转换打卡时间格式
Long startDate = 0l;//打卡当天开始时间
Long endDate = 0l;//打卡当天结束时间
try {
startDate = DateUtil.getStartTime(0,DateUtil.getStringTime(putime,"yyyy-MM-dd")).getTime();
endDate = DateUtil.getnowEndTime(23,DateUtil.getStringTime(putime,"yyyy-MM-dd")).getTime();
} catch (ParseException e) {
e.printStackTrace();
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;//打卡明细id
int atttype = 0;//打卡顺序
int shifid = 0;//班次id
boolean isRange = true;//是否在打卡时间范围内
int execution_status = 0;//执行状态
boolean kskd = true;//识别是否更新最后一次打卡 针对于最后一次下班卡
boolean sbdkkd = false;//针对于上班 未超过上班卡打卡 视为无效打卡
long punchcardtime = 0,punchstart = 0,punchend = 0;//应打卡时间,应打卡开始时间,应打卡结束时间
ClockCollectData clockt = new ClockCollectData();
// putime: 根据日期 得到打卡所需的详细信息
AttendanceCardListDto attdate = MethodCall(qyid,userid,putime);
if(attgro != null) {//判断考勤组是否存在
if(attdate.getAttgrouptype() != 3) {
//查询打卡当天是否有记录**********************************
KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build();
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"));
boolean dnck = false;
boolean crdk = false;//当次打卡是否存在次日打卡
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();//获取今天应打卡时间
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:是)
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; }
}
}
}else {
//无记录的话就找昨天的数据
// AttendanceCardListDto attdate1 = MethodCall(qyid,userid,yesterday);
}
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));
attendance_date = startDate;
toweek = putime;
}
if(EmptyUtil.isEmpty(attdate.getAttsch())) {
msg = "当前未排班";
sbyf = 0;
}else {
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();
}
if(dkmc == null) {
kskd = false;
if(attdate.getAttsch().size() == 2) {//一套上下班 上班1
Date sd1=df1.parse(ClockInTool.stampToDate(String.valueOf(starttime1)));//应打卡时间
Date sd2=df1.parse(sStdIoTime);//打卡时间
Date sd3=df1.parse(ClockInTool.stampToDate(String.valueOf(endtime1)));//应打卡时间
if(sd2.before(sd3)) {
atttype = 1;
}
if(sd2.after(sd1) && sd2.after(sd3)) {
atttype = 2;
}
}else {
boolean getinto = true;
//打卡时间 对比班次 接近哪个时间就打哪个时间的卡
if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
//punchstart 应打卡开始时间 punchend:应打卡结束时间 time_:打卡时间
if(clock.getType() == 1) {
boolean effectiveDate1 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime1ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime1js),"yyyy-MM-dd HH:mm");
if (effectiveDate1) {//在范围内就打卡
atttype = clock.getType();
getinto = false;
}else {
if(getinto) {
isRange = false;
}
}
}else if(clock.getType() == 2){
boolean effectiveDate2 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime1ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime1js),"yyyy-MM-dd HH:mm");
if (effectiveDate2) {//在范围内就打卡
atttype = clock.getType();
isRange = true;//在范围
getinto = false;
}else {
if(getinto) {
isRange = false;
}
}
}else if(clock.getType() == 3) {
boolean effectiveDate3 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime2ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime2js),"yyyy-MM-dd HH:mm");
if (effectiveDate3) {//在范围内就打卡
atttype = clock.getType();
isRange = true;//在范围
getinto = false;
}else {
if(getinto) {
isRange = false;
}
}
}else if(clock.getType() == 4) {
boolean effectiveDate4 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime2ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime2js),"yyyy-MM-dd HH:mm");
if (effectiveDate4) {//在范围内就打卡
atttype = clock.getType();
isRange = true;//在范围
getinto = false;
}else {
if(getinto) {
isRange = false;
}
}
}
}
if(attdate.getAttsch().size() == 6) {
if(clock.getType() == 5) {
boolean effectiveDate5 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime3ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime3js),"yyyy-MM-dd HH:mm");
if (effectiveDate5) {//在范围内就打卡
atttype = clock.getType();
isRange = true;//在范围
getinto = false;
}else {
if(getinto) {
isRange = false;
}
}
}else if(clock.getType() == 6) {
boolean effectiveDate6 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime3ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime3js),"yyyy-MM-dd HH:mm");
if (effectiveDate6) {//在范围内就打卡
atttype = clock.getType();
isRange = true;//在范围
getinto = false;
}else {
if(getinto) {
isRange = false;
}
}
}
}
}
execution_status = 1;
}else {
execution_status = 2;
if(attdate.getAttsch().size() == 2) { //下班1
if(clock.getType() == 1) {
if(clock.getDiffer() == 2) {//更新打卡
//如果第二次后打卡,未超过上班时间 即为打卡失效
Date sd1=df1.parse(ClockInTool.stampToDate(String.valueOf(starttime1)));//应打卡时间
Date sd2=df1.parse(sStdIoTime);//打卡时间
if(sd1.after(sd2)) {
sbdkkd = true;//打卡无效
atttype = 1;
}
}
}else if(clock.getType() == 2){
if(dkmc.getSbdk1() != null && dkmc.getXbdk1() == null){
kskd = false;
}else {
//最后一次卡的时候 再继续打视为更新最后一次打卡
kskd = true;
}
atttype = clock.getType();
}
}
if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
if(clock.getType() == 1) {
boolean effectiveDate1 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime1ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime1js),"yyyy-MM-dd HH:mm");
if (effectiveDate1) {//在范围内就打卡
if(dkmc.getSbdk1() != null) {
sbdkkd = true;//打卡无效
}
atttype = clock.getType();
}else {
isRange = false;
}
}else if(clock.getType() == 2) {
boolean effectiveDate2 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime1ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime1js),"yyyy-MM-dd HH:mm");
if (effectiveDate2) {//在范围内就打卡
if(dkmc.getXbdk1() != null) {
kskd = true;
}else {
kskd = false;
atttype = clock.getType();
}
}else {
isRange = false;
}
}else if(clock.getType() == 3) {
boolean effectiveDate3 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime2ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime2js),"yyyy-MM-dd HH:mm");
if (effectiveDate3) {//在范围内就打卡
if(dkmc.getSbdk2() != null) {
sbdkkd = true;//
}
atttype = clock.getType();
}else {
isRange = false;
}
}else if(clock.getType() == 4) {
boolean effectiveDate4 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime2ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime2js),"yyyy-MM-dd HH:mm");
if (effectiveDate4) {//在范围内就打卡
if(dkmc.getXbdk2() != null) {
kskd = true;
}else {
kskd = false;
atttype = clock.getType();
}
}else {
isRange = false;
}
}
}
if(attdate.getAttsch().size() == 6) {
if(clock.getType() == 5) {
boolean effectiveDate5 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime3ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(starttime3js),"yyyy-MM-dd HH:mm");
if (effectiveDate5) {//在范围内就打卡
if(dkmc.getSbdk2() != null) {
sbdkkd = true;//
}
atttype = clock.getType();
}else { isRange = false; }
}else if(clock.getType() == 6) {
boolean effectiveDate6 = ClockInTool.hourMinuteBetween(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime3ks), new SimpleDateFormat("yyyy-MM-dd HH:mm").format(endtime3js),"yyyy-MM-dd HH:mm");
if (effectiveDate6) {//在范围内就打卡
if(dkmc.getXbdk2() != null) {
kskd = true;
}else {
kskd = false;
atttype = clock.getType();
}
}else { isRange = false; }
}
}
}
}
if(atttype == 1) {
punchcardtime = starttime1; punchstart = starttime1ks; punchend = starttime1js;
}else if(atttype == 2) {
punchcardtime = endtime1; punchstart = endtime1ks; punchend = endtime1js;
}else if(atttype == 3) {
punchcardtime = starttime2; punchstart = starttime2ks; punchend = starttime2js;
}else if(atttype == 4) {
punchcardtime = endtime2; punchstart = endtime2ks; punchend = endtime2js;
}else if(atttype == 5) {
punchcardtime = starttime3; punchstart = starttime3ks; punchend = starttime3js;
}else if(atttype == 6) {
punchcardtime = endtime3; punchstart = endtime3ks; punchend = endtime3js;
}
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()));
}
//打卡记录录入 -- 打卡是否有时间范围限制
if(attdate.getAttsch().size() == 2) {
if(punchstart>0 && punchend>0) {
String staputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(punchstart);//应打卡开始时间
String entputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(punchend);//应打卡结束时间
String DKputime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(time_);//打卡时间
boolean effectiveDate = ClockInTool.hourMinuteBetween(DKputime, staputime, entputime,"yyyy-MM-dd HH:mm");
if (!effectiveDate) {
System.out.println("当前打卡时间不在范围内");
isRange = false;
}
}
}
if(isRange) {
int yzcd = shif.getYzcdfzs();//严重迟到分钟数
int kgcdfzs = shif.getKgcdfzs();//旷工迟到分钟数
ShiftManagement shif = null;
if(clock.getShifid() > 0){//有无班次
shif = shiftmanagementmapper.selectByPrimaryKey(clock.getShifid());
//班次的休息时间
long rest_time = 0;
if(shif.getStartTime() != null && shif.getEndTime() != null) {
long kaishixiuxi = Long.valueOf(ClockInTool.dateToStamp(putime + " " +shif.getStartTime()+":00"));
long jieshuxiuxi = Long.valueOf(ClockInTool.dateToStamp(putime + " " +shif.getEndTime()+":00"));
rest_time = (jieshuxiuxi - kaishixiuxi)/1000/60;//休息时间
}
int dkmx = 0;
PunchCardDetails dkmc = punchcarddetailsmapper.SingleAttendanceDays(userid,startDate,endDate);//查询打卡当天是否有记录
if(dkmc != null){//有记录就修改之前的
//修改
dkmx = dkmc.getId();
PunchCardDetails pcd = new PunchCardDetails();
if(clock.getType() == 1){
if(clock.getDiffer() == 1){//打卡
if(!("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() != null){
return ResultUtil.error("重复打卡");
}
}else{//更新打卡
pcd.setId(dkmc.getId());
pcd.setSbdk1(Long.valueOf(clock.getPunchtime()));//上班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
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((atttype)%2 > 0){//上班
if(time > 0){
pcd.setSbdk1jg(Math.abs(Integer.valueOf(time.toString())));//上班1打卡结果
}else{
pcd.setSbdk1jg(0);// 打卡结果
sbdkjg = Integer.valueOf(time.toString());
}// 打卡结果
}else{//下班
if(time > 0){}else{
sbdkjg = Math.abs(Integer.valueOf(time.toString()));
}// 打卡结果
}
}
punchcarddetailsmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
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);
}
}else if(clock.getType() == 2){
if(("").equals(dkmc.getXbdk1()) || dkmc.getXbdk1() == null){
pcd.setXbdk1(Long.valueOf(clock.getPunchtime()));//下班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setXbdk1jg(0);// 打卡结果
}else{
pcd.setXbdk1jg(Math.abs(Integer.valueOf(time.toString())));//上班1打卡结果
int ydkcs = 0;
if(shif != null){ydkcs = shif.getSxbcs()*2;}//应打卡次数
if(sbdkjg > yzcd && yzcd>0) {
yzcdcs++;
yzcdsc = sbdkjg - yzcd;
}
if(sbdkjg > kgcdfzs && kgcdfzs>0) {kgcdcs++;}
pcd.setYdkcs(ydkcs);
pcd.setYzcdcs(yzcdcs);
pcd.setYzcdsc(Double.valueOf(yzcdsc));
pcd.setKgcdfzs(kgcdcs);
if (!pcd.insert()) {
throw new CustomException("打卡明细-新增异常-1");
}
}else{
dkmx = pcd.getId();
if(clock.getDiffer() == 1){//打卡
return ResultUtil.error("重复打卡");
}else{//更新打卡
}else if(execution_status == 2){
dkmx = dkmc.getId();
KqglAssoDkmx pcd = KqglAssoDkmx.builder().build();
if(atttype == 2){//下班1
pcd.setId(dkmc.getId());
pcd.setXbdk1(Long.valueOf(clock.getPunchtime()));//下班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
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打卡结果
}
}
//班次为2次时,计算工作时长
if(dkmc.getSbdk1() != null){
Long time = (Long.valueOf(clock.getPunchtime()) - dkmc.getSbdk1())/1000/60;
pcd.setGzsc(Math.abs(Double.valueOf(time.toString())));//只打一次卡时计算工作时长
}
punchcarddetailsmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
pcd.setXbdk1jg(Math.abs(Integer.valueOf(time.toString())));
}
}
//班次为2次时,计算工作时长
if(dkmc.getSbdk1() != null){
Long time = (Long.valueOf(clock.getPunchtime()) - dkmc.getSbdk1())/1000/60;
Long time = (time_ - dkmc.getSbdk1())/1000/60 - rest_time;
pcd.setGzsc(Math.abs(Double.valueOf(time.toString())));//只打一次卡时计算工作时长
}
}else if(clock.getType() == 3){
if(("").equals(dkmc.getSbdk2()) || dkmc.getSbdk2() == null){
pcd.setSbdk2(Long.valueOf(clock.getPunchtime()));//上班2打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setSbdk2jg(Math.abs(Integer.valueOf(time.toString())));//上班2打卡结果
}else{
pcd.setSbdk2jg(0);// 打卡结果
}
}
}else{
if(clock.getDiffer() == 1){//打卡
return ResultUtil.error("重复打卡");
}else{
pcd.setId(dkmc.getId());
pcd.setSbdk2(Long.valueOf(clock.getPunchtime()));//上班2打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setSbdk2jg(Math.abs(Integer.valueOf(time.toString())));//上班2打卡结果
}else{
pcd.setSbdk2jg(0);// 打卡结果
}
}
punchcarddetailsmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}
kqglassodkmxmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else if(atttype == 3){//上班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()));}
}
}else if(clock.getType() == 4){
if(("").equals(dkmc.getXbdk2()) || dkmc.getXbdk2() == null){
pcd.setXbdk2(Long.valueOf(clock.getPunchtime()));//下班2打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setXbdk2jg(0);// 打卡结果
}else{
pcd.setXbdk2jg(Math.abs(Integer.valueOf(time.toString())));//下班2打卡结果
if(sbdk2jg > yzcd&& yzcd>0) {
yzcdcs = dkmc.getYzcdcs()+1;
yzcdsc = sbdk2jg - yzcd;
}
if(sbdk2jg > kgcdfzs&& kgcdfzs>0) {kgcdcs++;}
}
}else{
if(clock.getDiffer() == 1){//打卡
return ResultUtil.error("重复打卡");
}else{
pcd.setId(dkmc.getId());
pcd.setXbdk2(Long.valueOf(clock.getPunchtime()));//下班2打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
pcd.setSbdk2(time_);//上班1打卡时间
pcd.setSbdk2jg(sbdk2jg);
pcd.setYzcdcs(yzcdcs);
pcd.setYzcdsc(Double.valueOf(yzcdsc));
pcd.setKgcdfzs(kgcdcs);
kqglassodkmxmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else if(atttype == 4){//下班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())));//下班2打卡结果
pcd.setXbdk2jg(Math.abs(Integer.valueOf(time.toString())));
}
}
//班次为4次时,计算工作时长
if(dkmc.getSbdk2() != null){
Long time = (Long.valueOf(clock.getPunchtime()) - dkmc.getSbdk2())/1000/60;
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());
BigDecimal worktime_ = new BigDecimal(Math.abs(om.add(on).doubleValue()));
BigDecimal xx = new BigDecimal(rest_time);
double worktime = Math.abs(worktime_.subtract(xx).doubleValue());
pcd.setGzsc(worktime);
}
punchcarddetailsmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}
kqglassodkmxmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else if(atttype == 5){//上班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()));}
}
//班次为4次时,计算工作时长
if(dkmc.getSbdk2() != null){
Long time = (Long.valueOf(clock.getPunchtime()) - 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);
if(sbdk3jg > yzcd&& yzcd>0) {
yzcdcs = dkmc.getYzcdcs()+1;
yzcdsc = sbdk3jg - yzcd;
}
}else if(clock.getType() == 5){
if(("").equals(dkmc.getSbdk3()) || dkmc.getSbdk3() == null){
pcd.setSbdk3(Long.valueOf(clock.getPunchtime()));//上班3打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(sbdk3jg > kgcdfzs&& kgcdfzs>0) {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(atttype == 6){//下班3
pcd.setId(dkmc.getId());
pcd.setXbdk3(time_);//下班1打卡时间
if(punchcardtime != 0){//有应打卡时间时
Long time = (time_ - punchcardtime)/1000/60;
if(time > 0){
pcd.setSbdk3jg(Math.abs(Integer.valueOf(time.toString())));//上班3打卡结果
pcd.setXbdk3jg(0);// 打卡结果
}else{
pcd.setSbdk3jg(0);// 打卡结果
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);
BigDecimal worktime_ = new BigDecimal(Math.abs(om.add(on).doubleValue()));
BigDecimal xx = new BigDecimal(rest_time);
double worktime = Math.abs(worktime_.subtract(xx).doubleValue());
pcd.setGzsc(worktime);
}
}
}else{
if(clock.getDiffer() == 1){//打卡
return ResultUtil.error("重复打卡");
}else{
pcd.setId(dkmc.getId());
pcd.setSbdk3(Long.valueOf(clock.getPunchtime()));//上班3打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setSbdk3jg(Math.abs(Integer.valueOf(time.toString())));//上班3打卡结果
}else{
pcd.setSbdk3jg(0);// 打卡结果
if(atttype <= 6 && atttype > 0 && !sbdkkd){
kqglassodkmxmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}
}
punchcarddetailsmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
}else {
msg = "当前打卡时间不在范围内";
sbyf = 0;
}
}else {
msg = "当前是休息时间";
sbyf = 0;
}
}else if(clock.getType() == 6){
if(("").equals(dkmc.getXbdk3()) || dkmc.getXbdk3() == null){
pcd.setXbdk3(Long.valueOf(clock.getPunchtime()));//下班3打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setXbdk3jg(0);// 打卡结果
}else{
pcd.setXbdk3jg(Math.abs(Integer.valueOf(time.toString())));//下班3打卡结果
}
}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));
attendance_date = startDateyesterday;
toweek = yesterday;
}else {
zydkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userid)
.ge(KqglAssoDkmx::getDksj, startDate).le(KqglAssoDkmx::getDksj, endDate));
attendance_date = startDate;
toweek = putime;
}
}else{
if(clock.getDiffer() == 1){//打卡
return ResultUtil.error("重复打卡");
}else{
pcd.setId(dkmc.getId());
pcd.setXbdk3(Long.valueOf(clock.getPunchtime()));//下班3打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时[有班次时]
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setXbdk3jg(0);// 打卡结果
}else{
pcd.setXbdk3jg(Math.abs(Integer.valueOf(time.toString())));//下班3打卡结果
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");
}
//班次为6次时,计算工作时长
if(dkmc.getSbdk3() != null){
Long time = (Long.valueOf(clock.getPunchtime()) - dkmc.getSbdk3())/1000/60;
BigDecimal om = new BigDecimal(dkmc.getGzsc());//第二次
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())));//只打一次卡时计算工作时长
}
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());
pcd.setGzsc(worktime);
}
punchcarddetailsmapper.updateByPrimaryKeySelective(pcd);//修改打卡记录
zypcd.setGzsc(worktime);
}
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(dkmc.getSbdk3() != null){
Long time = (Long.valueOf(clock.getPunchtime()) - dkmc.getSbdk3())/1000/60;
BigDecimal om = new BigDecimal(dkmc.getGzsc());//第二次
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());
pcd.setGzsc(worktime);
zypcd.setGzsc(worktime);
}
kqglassodkmxmapper.updateByPrimaryKeySelective(zypcd);//修改打卡记录
}
pcd.setId(dkmc.getId());
if(clock.getType() <= 6){
int update = punchcarddetailsmapper.updateByPrimaryKeySelective(pcd);
}
}else{//没有数据就新增一条数据
//新增
if(clock.getDiffer() == 1){//打卡
PunchCardDetails pcd = new PunchCardDetails();
pcd.setUserid(userid);
pcd.setData(putime);//打卡日期(yyyy-MM-dd)
if(clock.getType() == 1){
pcd.setSbdk1(Long.valueOf(clock.getPunchtime()));//上班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setSbdk1jg(Math.abs(Integer.valueOf(time.toString())));//上班1打卡结果
}else{
pcd.setSbdk1jg(0);// 打卡结果
atttype = 6;
}else {
atttype = 7;
}
}
}else if(clock.getType() == 2){
pcd.setXbdk1(Long.valueOf(clock.getPunchtime()));//下班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setXbdk1jg(0);// 打卡结果
}else{
pcd.setXbdk1jg(Math.abs(Integer.valueOf(time.toString())));//上班1打卡结果
}
/*****************************************************************************************************************************************************************************************************/
/*******************************************************************APP 原始打卡记录数据录入**************************************************************************************************************/
/*****************************************************************************************************************************************************************************************************/
String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(attendance_date));//转换打卡时间格式
//true:确认为最后一次打卡更新打卡时 之前打卡的一条数据变为“打卡更新数据”
if(kskd && (atttype == 2 || atttype == 4 || atttype == 6)) {
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();
}
}else if(clock.getType() == 3){
pcd.setSbdk2(Long.valueOf(clock.getPunchtime()));//上班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
int results = 0;
Long time = (time_ - punchcardtime)/1000/60;
if(punchcardtime != 0){
if(isRange) {
if((atttype)%2 > 0){//上班
if(time > 0){
pcd.setSbdk2jg(Math.abs(Integer.valueOf(time.toString())));
}else{
pcd.setSbdk2jg(0);// 打卡结果
}
results = Integer.valueOf(time.toString());
}// 打卡结果
}else{//下班
if(time > 0){}else{
results = Math.abs(Integer.valueOf(time.toString()));
}// 打卡结果
}
}else if(clock.getType() == 4){
pcd.setXbdk2(Long.valueOf(clock.getPunchtime()));//下班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setXbdk2jg(0);// 打卡结果
}else{
pcd.setXbdk2jg(Math.abs(Integer.valueOf(time.toString())));
}
}
}else if(clock.getType() == 5){
pcd.setSbdk3(Long.valueOf(clock.getPunchtime()));//上班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(time > 0){
pcd.setSbdk3jg(Math.abs(Integer.valueOf(time.toString())));
int type,status = 0;
if((atttype)%2 > 0){
type = 1;// 类型(类型 0:无排班打卡 1:上班 2:下班) punchcardtime == 0:无班次打卡
if(attdate.getAttgrouptype() != 3) {
if(EmptyUtil.isNotEmpty(attdate.getAttsch())) {
if(punchcardtime == 0 && clockt.getShifid() != 0){
status = 1;
}if(punchcardtime == 0 && clockt.getShifid() == 0) {
status = 2;
}else{
pcd.setSbdk3jg(0);// 打卡结果
}
}
}else if(clock.getType() == 6){
pcd.setXbdk3(Long.valueOf(clock.getPunchtime()));//下班1打卡时间
if(!("0").equals(clock.getPunchcardtime())){//有应打卡时间时
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(isRange) {// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
if(time > 0){
pcd.setXbdk3jg(0);// 打卡结果
}else{
pcd.setXbdk3jg(Math.abs(Integer.valueOf(time.toString())));
}
status = 3;
}else if(results == 0){
status = 1;
}
}else {
status = 2;
}
if(shif != null){
pcd.setYdkcs(shif.getSxbcs()*2);//应打卡次数
}
pcd.setQyid(qyid);//企业id
pcd.setDksj(startDate);//打卡时间
punchcarddetailsmapper.insertSelective(pcd);
dkmx = pcd.getId();
}else if(EmptyUtil.isEmpty(attdate.getAttsch())) {
status = 2;
}
}else {
if(sbyf == 1) {
status = 1;
}else {
status = 2;
}
// //打卡记录
// if(clock.getDiffer() == 2){//更新打卡
// PunchRecord punch = punchrecordmapper.selectPunchResults(startDate,endDate,userid,clock.getType());
// if(punch != null){
// PunchRecord pr = new PunchRecord();
// pr.setId(punch.getId());
// pr.setStatus(0);//状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:补卡 4:请假)
// pr.setSort(0);//序号(0:打卡无效:此记录已被更新)
// punchrecordmapper.updateByPrimaryKeySelective(pr);
// }else{
// return ResultUtil.error("打卡失败");
// }
// }
PunchRecord pre = new PunchRecord();
pre.setDktime(Long.valueOf(clock.getPunchtime()));// 打卡时间
if(clock.getPunchcardtype() == 1){
pre.setLon(Double.valueOf(clock.getLon()));// 经度
pre.setLat(Double.valueOf(clock.getLat()));// 纬度
pre.setAddress(clock.getAddress());// 定位地址
}
Long time = (Long.valueOf(clock.getPunchtime()) - Long.valueOf(clock.getPunchcardtime()))/1000/60;
if(("0").equals(clock.getPunchcardtime())){
pre.setResults(0);// 打卡结果
}else{
if((clock.getType())%2 > 0){//上班
if(time > 0){
pre.setResults(Integer.valueOf(time.toString()));// 打卡结果
}else{
pre.setResults(0);// 打卡结果
}
}else{//下班
if(time > 0){
pre.setResults(0);// 打卡结果
type = 2;// 类型(类型 0:无排班打卡 1:上班 2:下班)
if(attdate.getAttgrouptype() != 3) {
if(EmptyUtil.isNotEmpty(attdate.getAttsch())) {
if(punchcardtime == 0 && clockt.getShifid() != 0){
status = 1;
}if(punchcardtime == 0 && clockt.getShifid() == 0) {
status = 2;
}else{
pre.setResults(Math.abs(Integer.valueOf(time.toString())));// 打卡结果
}
if(isRange) {
if(time < 0){
status = 4;
}else if(results == 0){
status = 1;
}
}else {
status = 2;
}
pre.setUserId(userid);// 用户id
if((clock.getType())%2 > 0){
pre.setType(1);// 类型(类型 0:无排班打卡 1:上班 2:下班)
if(("0").equals(clock.getPunchcardtime())){//无班次打卡
pre.setStatus(1);
}else{
//打卡
if(time > 0){
pre.setStatus(3);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}else if(pre.getResults() == 0){
pre.setStatus(1);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}
}else if(EmptyUtil.isEmpty(attdate.getAttsch())) {
status = 2;
}
}else{
pre.setType(2);// 类型(类型 0:无排班打卡 1:上班 2:下班)
if(("0").equals(clock.getPunchcardtime())){//无班次打卡
pre.setStatus(1);
}else{
//打卡
if(time < 0){
pre.setStatus(4);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}else if(pre.getResults() == 0){
pre.setStatus(1);// 状态(0:打卡无效:此记录已被更新 1:正常 2:异常 3:迟到 4:早退 5:补卡 6:请假 7:加班 8:调休)
}else {
if(sbyf == 1) {
status = 1;
}else {
status = 2;
}
}
}
pre.setSort(clock.getType());// 序号
pre.setCardType(clock.getPunchcardtype());// 打卡类型(1:GPS,2:WIFI,3:考勤机)
if(clock.getPunchcardtype() == 2){
pre.setMac(clock.getMac());// mac地址
pre.setMacname(clock.getMacname());// WIFI名称
//第二次未超过应上班打卡时间 打卡为无效
if(sbdkkd) {
status = 2;
atttype = 0;
msg = "已有最优的打卡记录存在";
}
pre.setQyid(qyid);// 企业id
String attdate_ = new SimpleDateFormat("yy-MM-dd").format(Double.valueOf(startDate));//转换打卡时间格式
pre.setAttdate(attdate_+" "+ClockInTool.dateToWeek2(putime));// 考勤日期
long date = new Date().getTime();
if(("0").equals(clock.getPunchcardtime())){
pre.setAttime(date);// 考勤时间(应打卡时间)
long attime;
if(punchcardtime == 0){// 考勤时间(应打卡时间)
attime = new Date().getTime();
}else{
pre.setAttime(Long.valueOf(clock.getPunchcardtime()));// 考勤时间(应打卡时间)
attime = punchcardtime;
}
String remarks = "";//考勤备注
String punchequipment = "";//打卡设备
String commentary = "未知";
if(sbyf == 1) {
commentary = "打卡成功";
}else {
commentary = msg;
}
pre.setDkmxid(dkmx);// 打卡明细id
pre.setBcid(clock.getShifid());// 班次id
// punchrecordmapper.insertSelective(pre);//新增打卡记录
KqglAssoDkjl pre = KqglAssoDkjl.builder().dktime(time_).results(results).userId(userid).type(type).status(status).sort(atttype)
.qyid(qyid).attdate(attdate_+" "+ClockInTool.dateToWeek2(toweek)).attime(attime).dkmxid(dkmx).bcid(shifid).remarks(remarks)
.punchequipment(punchequipment).commentary(commentary).build();
//cardtype--1:GPS,2:WIFI,3:考勤机,4:外勤
int cardtype = 0;
if(clock.getPunchcardtype() == 1 || clock.getPunchcardtype() == 4) {
pre.setAddress(clock.getAddress());
pre.setLat(Double.valueOf(clock.getLat()));
pre.setLon(Double.valueOf(clock.getLon()));
}else if(clock.getPunchcardtype() == 2) {
pre.setMacname(clock.getMacname());
pre.setMac(clock.getMac());
}
pre.setCardType(cardtype);
if (!pre.insert()) {
throw new CustomException("打卡记录-新增异常-2");
}
return ResultUtil.data(null,"打卡成功");
}else {
msg="打卡失败!,未加入考勤组!";
sbyf = 0;
}
}else {
return ResultUtil.error("打卡失败!,用户不存在!");
}
if(sbyf == 1) {
return ResultUtil.data(null, "打卡成功");
}else {
return ResultUtil.data(msg, "打卡失败");
}
}
......@@ -1829,6 +2212,7 @@ public class ClockInController {
List<AttSchedule> ash = attdate.getAttsch();
KqglAssoBcsz shif = KqglAssoBcsz.builder().build().selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, ash.get(0).getId()));
if(shif != null) {
int dkcs_ = shif.getSxbcs();//上下班打卡次数
int iswzwd = shif.getIsWzwd();//是否开启晚走晚到(0:否;1:是)
......@@ -1898,7 +2282,7 @@ public class ClockInController {
}
attdate.setLatetime(latetime_);
attdate.setChanged_time(changed_time);
}
return ResultUtil.data(attdate);
}else {
......@@ -1908,4 +2292,275 @@ public class ClockInController {
}
}
private SimpleDateFormat mat = new SimpleDateFormat("yyyy-MM-dd");
@Autowired
private KqglAssoTeshuMapper kqglassoteshumapper;
@Autowired
private AttendanceWeeklySchMapper attendanceweeklyschmapper;
@Autowired
private ScheduleMapper schedulemapper;
/**
* APP 手机日历数据
* @param userBean
* @return
* @throws ParseException
*/
@GetMapping(value = "/workbench_calendar/{date}")
@ApiOperation(value = "手机日历数据", httpMethod = "GET", notes = "查询数据")
public Result<Object> Workbench_calendar(@CurrentUser UserBean userBean,@PathVariable("date") String date) throws ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
String current = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String yue = new SimpleDateFormat("yyyy-MM").format(new Date());
SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM");
Date date_;
try {
date_ = df1.parse(date);
}catch (ParseException e){
e.printStackTrace();
date_=new Date();
}
int dateOne= ClockInTool.getYearMonth(date_);
int dangqian = ClockInTool.getYearMonth(new Date());//当前
List<WorkbenchCalendarDto> workcal = new ArrayList<WorkbenchCalendarDto>();
if(dateOne<=dangqian){
Long startMonth = 0l;
Long endMonth = 0l;
if(date == null || ("").equals(date)) {
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
String first = mat.format(c.getTime());
startMonth = DateUtil.getStartTime(0,DateUtil.getStringTime(first,"yyyy-MM-dd")).getTime();
endMonth = new Date().getTime();
}else {
String time = date+"-01";
String sdaet = ClockInTool.getMinMonthDate(time);
startMonth = ClockInTool.getStartTime(0,ClockInTool.getStringTime(sdaet,"yyyy-MM-dd")).getTime();
String edate = ClockInTool.getMaxMonthDate(time);
endMonth = ClockInTool.getnowEndTime(23,ClockInTool.getStringTime(edate,"yyyy-MM-dd")).getTime();
if(date.equals(yue)) {
endMonth = new Date().getTime();
}
}
String[] rangeArray=ClockInTool.listToString(ClockInTool.getDays(df.format(startMonth),df.format(endMonth))).split(";");//目前为止所有日期
String[] range=rangeArray[0].split(",");
KqglMainKqz attgro = kqglmainkqzmapper.getAttendanceGroupInformationByUserid(userBean.getEmpNum(),userBean.getOrgCode()); //考勤组信息
for(String num : range) {
Long start_time = DateUtil.getStartTime(0,DateUtil.getStringTime(num,"yyyy-MM-dd")).getTime();
Long end_time = DateUtil.getnowEndTime(23,DateUtil.getStringTime(num,"yyyy-MM-dd")).getTime();
WorkbenchCalendarDto wocal = WorkbenchCalendarDto.builder().build();
wocal.setDate(num);
if(attgro != null) {//有无考勤组
AttendanceCardListDto attdate = MethodCall(userBean.getOrgCode(),userBean.getEmpNum(),num);//获取当天所打卡班次
List<AttSchedule> ashss = attdate.getAttsch();//获取今天应打卡时间
if(EmptyUtil.isNotEmpty(attdate.getAttsch())) {//班次不为空
if(ashss.get(0).getId() != 0) {
KqglAssoDkmx dkmc = KqglAssoDkmx.builder().build().selectOne(new QueryWrapper<KqglAssoDkmx>().lambda().eq(KqglAssoDkmx::getUserid, userBean.getEmpNum()).eq(KqglAssoDkmx::getQyid, userBean.getOrgCode())
.ge(KqglAssoDkmx::getDksj, start_time).le(KqglAssoDkmx::getDksj, end_time));
if(dkmc != null) {
if(attdate.getAttsch().size() == 2 || attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
if(dkmc.getSbdk1() != null && dkmc.getSbdk1jg() == 0 && dkmc.getXbdk1() != null && dkmc.getXbdk1jg() == 0) {
wocal.setCalendar_status(1);//打卡正常
}else {
wocal.setCalendar_status(3);//打卡异常
}
}
if(attdate.getAttsch().size() == 4 || attdate.getAttsch().size() == 6) {
if(dkmc.getSbdk2() != null && dkmc.getSbdk2jg() == 0 && dkmc.getXbdk2() != null && dkmc.getXbdk2jg() == 0) {
wocal.setCalendar_status(1);//打卡正常
}else {
wocal.setCalendar_status(3);//打卡异常
}
}
if(attdate.getAttsch().size() == 6) {
if(dkmc.getSbdk3() != null && dkmc.getSbdk3jg() == 0 && dkmc.getXbdk3() != null && dkmc.getXbdk3jg() == 0) {
wocal.setCalendar_status(1);//打卡正常
}else {
wocal.setCalendar_status(3);//打卡异常
}
}
KqglAssoRelationSummary asssum = KqglAssoRelationSummary.builder().build().selectOne(new QueryWrapper<KqglAssoRelationSummary>().lambda().eq(KqglAssoRelationSummary::getUserId, userBean.getEmpNum())
.eq(KqglAssoRelationSummary::getAppTime, num).last("LIMIT 1"));
if(asssum != null) {
wocal.setCalendar_status(2);//事务(请假,加班,调休,出差)
}
}else {
wocal.setCalendar_status(3);//打卡异常
}
}else {
wocal.setCalendar_status(4);//休息
}
}else {
wocal.setCalendar_status(0);//无排班
}
}else {
wocal.setCalendar_status(0);//无排班
}
workcal.add(wocal);
}
//当月后续补贴数据
if(date == null || ("").equals(date) || date.equals(yue)) {
String next_day = ClockInTool.requires_extra_times(current,1,2,1);
Calendar ca = Calendar.getInstance();
ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
String last = mat.format(ca.getTime());
Long endMonth_ = DateUtil.getnowEndTime(23,DateUtil.getStringTime(last,"yyyy-MM-dd")).getTime();
String[] nextrangeArray=ClockInTool.listToString(ClockInTool.getDays(next_day,sdf1.format(endMonth_))).split(";");//目前为止所有日期
String[] nextrange=nextrangeArray[0].split(",");
String ttstr = date;//
String[] ycqts = new String[31];//应上班的具体天数(yyyy-MM-dd)
String[] xxts = new String[31];//休息的具体天数(yyyy-MM-dd)
if(attgro != null){//该员工是否加入到考勤组 排班方式 1:固定排班;2:自由排班;3:自由工时 计算出应出勤,实际出勤,休息天数
if(attgro.getPbfs() == 1){ //固定排班
List<KqglAssoTeshu> bxdklist = kqglassoteshumapper.ShouldSpecialDatessetByKqzid(attgro.getId(), ttstr,1);//当前月 必须打卡日期
int bxdk = bxdklist.size();
String[] bxdkss = new String[bxdk];////特殊-必须打卡天数(工作日)
int b = 0;
for(KqglAssoTeshu bxd : bxdklist) {
bxdkss[b] = bxd.getTsrq();
b++;
}
List<KqglAssoTeshu> wxdk = kqglassoteshumapper.ShouldSpecialDatessetByKqzid(attgro.getId(), ttstr,2);//当前月 无需打卡日期
String[] appmaps= new String[wxdk.size()];//特殊-无需打卡天数(休息日)
int d1 = 0;
for(KqglAssoTeshu spe:wxdk){
appmaps[d1] = spe.getTsrq();
d1++;
}
//应打卡周期时间
List<AttendanceWeeklySch> atwek = attendanceweeklyschmapper.selectAttendanceMadeByUserid(userBean.getEmpNum(),userBean.getOrgCode());
String[] week= new String[atwek.size()];
String[] needfig = new String[atwek.size()];//应打卡周期时间
int e = 0;
for(AttendanceWeeklySch awek : atwek){
week[e] = awek.getWekmc();
needfig[e] = String.valueOf(awek.getType());//获取设置的应打卡周几
e++;
}
//目前为止应出勤天数
int w = 0,x=0;
int zj = 6;
for(String num : nextrange) {
if(Arrays.binarySearch(needfig, String.valueOf(ClockInTool.dateToWeek(num))) >= 0) {//对比排班应打卡时间
String[] ycqtst = new String[ycqts.length + zj];
System.arraycopy(ycqts, 0, ycqtst, 0, ycqts.length);
ycqtst[w] = num;
ycqts = ycqtst;
w++;
}else {
String[] xxtst = new String[xxts.length + zj];
System.arraycopy(xxts, 0, xxtst, 0, xxts.length);
xxtst[x] = num;
xxts = xxtst;
x++;
}
if(Arrays.binarySearch(bxdkss, num) >= 0) {//检查是否存在 必须打卡名单中
String[] ycqtst = new String[ycqts.length + zj];
System.arraycopy(ycqts, 0, ycqtst, 0, ycqts.length);
ycqtst[w] = num;
ycqts = ycqtst;
w++;
xxts = ClockInTool.doChinFilters(ClockInTool.deleteArrayNull(xxts), num);//为必须上班的话从休息日期中去除
}
if(Arrays.binarySearch(appmaps, num) >= 0) {//检查是否存在 无需打卡名单中
ycqts = ClockInTool.doChinFilters(ClockInTool.deleteArrayNull(ycqts), num);//为必须休息的话从上班日期中去除
String[] xxtst = new String[xxts.length + zj];
System.arraycopy(xxts, 0, xxtst, 0, xxts.length);
xxtst[x] = num;
xxts = xxtst;
x++;
}
}
}else if(attgro.getPbfs() == 2){ //自由排班
DateFormat df11 = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
List<Schedule> ycqs = schedulemapper.getAttendanceShouldList(userBean.getEmpNum(),startMonth,endMonth);
int z=0;
String[] ziyoupb = new String[ycqs.size()];
for(Schedule sc : ycqs){
String data = new SimpleDateFormat("yyyy-MM-dd").format(df11.parse(String.valueOf(sc.getData())));// 获得格式化后的日期字符串
ziyoupb[z] = data;
z++;
}
//目前为止应出勤天数
int y = 0,x=0;
for(String num : nextrange) {
if(Arrays.binarySearch(ziyoupb, num) >= 0) {
KqglAssoPbmx pbx = KqglAssoPbmx.builder().build().selectOne(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getUserid, userBean.getEmpNum()).eq(KqglAssoPbmx::getData, num).eq(KqglAssoPbmx::getKqzid, attgro.getId()));
if(pbx!=null && pbx.getBcid()!=0) {
ycqts[y] = num;
y++;
}else {
xxts[x] = num;
x++;
}
}
}
}else{
List<AttendanceWeeklySch> atwek = attendanceweeklyschmapper.selectAttendanceMadeByUserid(userBean.getEmpNum(),userBean.getOrgCode());
String[] week= new String[atwek.size()];
int e = 0;
String[] ziyoupb = new String[atwek.size()];
for(AttendanceWeeklySch awek : atwek){
week[e] = awek.getWekmc();
ziyoupb[e] = String.valueOf(awek.getType());
e++;
}
//目前为止应出勤天数
int g = 0,x=0;
for(String num : nextrange) {
if(Arrays.binarySearch(ziyoupb, String.valueOf(ClockInTool.dateToWeek(num))) >= 0) {//对比排班应打卡时间
ycqts[g] = num;
g++;
}else {
xxts[x] = num;
x++;
}
}
}
}
for(String nus : nextrange) {
WorkbenchCalendarDto wocal = WorkbenchCalendarDto.builder().build();
wocal.setDate(nus);
if(ClockInTool.contains(ClockInTool.deleteArrayNull(ycqts),nus)) {
wocal.setCalendar_status(1);//打卡异常
}
if(ClockInTool.contains(ClockInTool.deleteArrayNull(xxts),nus)) {
wocal.setCalendar_status(4);//打卡异常
}
workcal.add(wocal);
}
}
}
return ResultUtil.data(workcal, "操作成功!");
}
}
......@@ -2758,16 +2758,10 @@ public class TimeCardController {
@GetMapping(value = "/worktable_attendance_from/{date}")
@ApiOperation(value = "999:工作台考勤表格", httpMethod = "GET", notes = "查询数据")
public Result<Object> worktable_attendance_from(@CurrentUser UserBean userBean,@PathVariable("date") String date) throws ParseException {
CalendarTableDataDto tabl = CalendarTableDataDto.builder().build();
String belongyear = null;
String belongmonth = null;
String ttstr = null;//
if(date == null || ("").equals(date)) {
belongyear = new SimpleDateFormat("yyyy").format(new Date());
belongmonth = new SimpleDateFormat("MM").format(new Date());
......@@ -2777,16 +2771,11 @@ public class TimeCardController {
belongmonth = date.substring(5, 7);
ttstr = date;
}
//1:加班 2:请假 3:出差 4:外出 5:补卡
KqglAssoRelationSummary sums = kqglassorelationsummarymapper.selectTabledata(userBean.getEmpNum(), 1, ttstr);
KqglAssoRelationSummary qjj = kqglassorelationsummarymapper.selectTabledata(userBean.getEmpNum(), 2, ttstr);
KqglAssoRelationSummary cxx = kqglassorelationsummarymapper.selectTabledata(userBean.getEmpNum(), 3, ttstr);
KqglAssoMonthPunchSummary punsum = KqglAssoMonthPunchSummary.builder().build().selectOne(new QueryWrapper<KqglAssoMonthPunchSummary>().lambda().eq(KqglAssoMonthPunchSummary::getNum, userBean.getEmpNum())
.eq(KqglAssoMonthPunchSummary::getOrgCode, userBean.getOrgCode()).eq(KqglAssoMonthPunchSummary::getBelongYear, belongyear).eq(KqglAssoMonthPunchSummary::getBelongMonth, belongmonth));
Double compensatoryleave = 0d;
......@@ -2794,7 +2783,6 @@ public class TimeCardController {
compensatoryleave = punsum.getWorkingTurnCompenLeave() + punsum.getRestTurnCompenLeave() + punsum.getHolidayTurnCompenLeave();
}
tabl.setAttendance(punsum == null ? "" : String.valueOf(punsum.getDaysOnDuty()));// 应出勤
tabl.setAttended(punsum == null ? "" : String.valueOf(punsum.getActualAttDays()));// 已出勤
tabl.setLeave(qjj == null ? "" : String.valueOf(qjj.getDuration()));// 请假
......
......@@ -52,8 +52,8 @@ public class ClockCollectData implements Serializable {
@ApiModelProperty(value = "班次id", example = "无排班时 为“0”")
private Integer shifid;
@ApiModelProperty(value = "打卡状态", example = "状态,1:正常 2:异常 3:补卡 4:请假")
private Integer status;
// @ApiModelProperty(value = "打卡状态", example = "状态,1:正常 2:异常 3:补卡 4:请假")
// private Integer status;
@ApiModelProperty(value = "手机唯一ID", example = "字段说明")
private String registrationid;
......
......@@ -44,9 +44,9 @@ public class EvectionBusiness extends SpmkAssoBusiness {
// 时长
String longTime = ObjectUtil.isNull(jsonObj.get("__longTime",FromData.class)) ? null : jsonObj.get("__longTime",FromData.class).getValue();
// 出差事由
String businessTrip = ObjectUtil.isNull(jsonObj.get("__businessTrip",FromData.class)) ? null : jsonObj.get("__businessTrip",FromData.class).getValue();
// String businessTrip = ObjectUtil.isNull(jsonObj.get("__businessTrip",FromData.class)) ? null : jsonObj.get("__businessTrip",FromData.class).getValue();
// 上传文件
String UploadAttachment = ObjectUtil.isNull(jsonObj.get("UploadAttachment",FromData.class)) ? null : jsonObj.get("UploadAttachment",FromData.class).getValue();
// String UploadAttachment = ObjectUtil.isNull(jsonObj.get("UploadAttachment",FromData.class)) ? null : jsonObj.get("UploadAttachment",FromData.class).getValue();
System.out.println(approveId);
AttEvectionApprovalDto eaD = AttEvectionApprovalDto
.builder()
......
......@@ -40,9 +40,9 @@ public class GoOutBusiness extends SpmkAssoBusiness {
// 时长
String longTime = jsonObj.get("__longTime",FromData.class).getValue();
// 出差事由
String businessTrip = jsonObj.get("__businessTrip",FromData.class).getValue();
// String businessTrip = jsonObj.get("__businessTrip",FromData.class).getValue();
// 上传文件
String UploadAttachment = jsonObj.get("UploadAttachment",FromData.class).getValue();
// String UploadAttachment = jsonObj.get("UploadAttachment",FromData.class).getValue();
AttEvectionApprovalDto eaD = AttEvectionApprovalDto
.builder()
......
......@@ -44,7 +44,7 @@ public class WorkOvertimeBusiness extends SpmkAssoBusiness {
// 加班补偿方式 -前端传中文
String compensate = ObjectUtil.isNull(jsonObj.get("__compensate",FromData.class)) ? null : jsonObj.get("__compensate",FromData.class).getValue();
// 加班原因
String OvertimeReason = ObjectUtil.isNull(jsonObj.get("__OvertimeReason",FromData.class)) ? null : jsonObj.get("__OvertimeReason",FromData.class).getValue();
// String OvertimeReason = ObjectUtil.isNull(jsonObj.get("__OvertimeReason",FromData.class)) ? null : jsonObj.get("__OvertimeReason",FromData.class).getValue();
// 加班类型-前端未给
String workOvertimeType = ObjectUtil.isNull(jsonObj.get("__workOvertimeType",FromData.class)) ? null : jsonObj.get("__workOvertimeType",FromData.class).getValue();
// 上传文件
......
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