1
This commit is contained in:
parent
04037fca60
commit
3cfd1b63ec
@ -125,4 +125,10 @@ public class RzAttendanceController extends BaseController
|
|||||||
{
|
{
|
||||||
return success(rzAttendanceDetailService.selectListByAttendanceId(id));
|
return success(rzAttendanceDetailService.selectListByAttendanceId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/load/{id}")
|
||||||
|
public AjaxResult loadAttendance(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(rzAttendanceService.loadAttendance(id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,4 +70,7 @@ public interface IRzAttendanceService extends IService<RzAttendance>
|
|||||||
void addRzOverTime(String result, SysStaff sysStaff, DingShiftGroup dingsShiftGroup, String checkType, Date formatWorkDate, Date formatUserCheckTime, String timeResult, String remark, Double debiting);
|
void addRzOverTime(String result, SysStaff sysStaff, DingShiftGroup dingsShiftGroup, String checkType, Date formatWorkDate, Date formatUserCheckTime, String timeResult, String remark, Double debiting);
|
||||||
|
|
||||||
public RzAttendance queryNowDayAttendanceByStatisticalIdAndDate(Long staffId, Date date);
|
public RzAttendance queryNowDayAttendanceByStatisticalIdAndDate(Long staffId, Date date);
|
||||||
|
|
||||||
|
public RzAttendance loadAttendance(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -534,104 +534,34 @@ public class RzAttendanceServiceImpl extends ServiceImpl<RzAttendanceMapper, RzA
|
|||||||
for (int i = 0; i < jsonArray.size(); i++) {
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
JSONObject ob = jsonArray.getJSONObject(i);
|
JSONObject ob = jsonArray.getJSONObject(i);
|
||||||
if(bizId.equals(ob.getString("bizId"))){
|
if(bizId.equals(ob.getString("bizId"))){
|
||||||
//打卡类型
|
calculationAddRzOverTime(result, sysStaff, ob);
|
||||||
String checkType = ob.getString("checkType");
|
// //打卡类型
|
||||||
//考勤组
|
// String checkType = ob.getString("checkType");
|
||||||
String groupId = ob.getString("groupId");
|
// //考勤组
|
||||||
//排班时间
|
// String groupId = ob.getString("groupId");
|
||||||
Long planCheckTime = ob.getLong("planCheckTime");
|
// //排班时间
|
||||||
// 格式化:先转Date对象,再格式化
|
// Long planCheckTime = ob.getLong("planCheckTime");
|
||||||
String formatPlanCheckTime = DateUtils.parseDateToStr("HH:mm:ss", new Date(planCheckTime));
|
// // 格式化:先转Date对象,再格式化
|
||||||
//用户打卡时间
|
// String formatPlanCheckTime = DateUtils.parseDateToStr("HH:mm:ss", new Date(planCheckTime));
|
||||||
Long userCheckTime = ob.getLong("userCheckTime");
|
// //用户打卡时间
|
||||||
//工作时间 (这里指的是哪一天的卡)
|
// Long userCheckTime = ob.getLong("userCheckTime");
|
||||||
Long workDate = ob.getLong("workDate");
|
// //工作时间 (这里指的是哪一天的卡)
|
||||||
/***
|
// Long workDate = ob.getLong("workDate");
|
||||||
* 打卡结果
|
// /***
|
||||||
* Normal:正常
|
// * 打卡结果
|
||||||
* Early:早退
|
// * Normal:正常
|
||||||
* Late:迟到
|
// * Early:早退
|
||||||
* SeriousLate:严重迟到
|
// * Late:迟到
|
||||||
* Absenteeism:旷工迟到
|
// * SeriousLate:严重迟到
|
||||||
* NotSigned:未打卡
|
// * Absenteeism:旷工迟到
|
||||||
*/
|
// * NotSigned:未打卡
|
||||||
String timeResult = ob.getString("timeResult");
|
// */
|
||||||
|
// String timeResult = ob.getString("timeResult");
|
||||||
Date formatWorkDate = Date.from(Instant.ofEpochMilli(workDate));
|
//
|
||||||
Date formatUserCheckTime = Date.from(Instant.ofEpochMilli(userCheckTime));
|
// Date formatWorkDate = Date.from(Instant.ofEpochMilli(workDate));
|
||||||
DingShiftGroup dingsShiftGroup = dingsShiftGroupMapper.selectByGroupIdAndTypeAndCheckTime(groupId, checkType, formatPlanCheckTime);
|
// Date formatUserCheckTime = Date.from(Instant.ofEpochMilli(userCheckTime));
|
||||||
addRzOverTime(result, sysStaff, dingsShiftGroup, checkType, formatWorkDate, formatUserCheckTime, timeResult, null, 0d);
|
// DingShiftGroup dingsShiftGroup = dingsShiftGroupMapper.selectByGroupIdAndTypeAndCheckTime(groupId, checkType, formatPlanCheckTime);
|
||||||
|
// addRzOverTime(result, sysStaff, dingsShiftGroup, checkType, formatWorkDate, formatUserCheckTime, timeResult, null, 0d);
|
||||||
/* DingShiftGroup dingsShiftGroup = dingsShiftGroupMapper.selectByGroupIdAndTypeAndCheckTime(groupId, checkType, formatPlanCheckTime);
|
|
||||||
if(dingsShiftGroup != null){
|
|
||||||
//用户打卡时间
|
|
||||||
Long userCheckTime = ob.getLong("userCheckTime");
|
|
||||||
//工作时间 (这里指的是哪一天的卡)
|
|
||||||
Long workDate = ob.getLong("workDate");
|
|
||||||
*//***
|
|
||||||
* 打卡结果
|
|
||||||
* Normal:正常
|
|
||||||
* Early:早退
|
|
||||||
* Late:迟到
|
|
||||||
* SeriousLate:严重迟到
|
|
||||||
* Absenteeism:旷工迟到
|
|
||||||
* NotSigned:未打卡
|
|
||||||
*//*
|
|
||||||
String timeResult = ob.getString("timeResult");
|
|
||||||
|
|
||||||
Date formatWorkDate = Date.from(Instant.ofEpochMilli(workDate));
|
|
||||||
Date formatUserCheckTime = Date.from(Instant.ofEpochMilli(userCheckTime));
|
|
||||||
|
|
||||||
//通过打卡类型, classId, 和排班打卡时间, 获取工作时长
|
|
||||||
//通过班次id拿到工作时长
|
|
||||||
DingShift dingsShift = dingsShiftMapper.selectByDingId(dingsShiftGroup.getShiftId());
|
|
||||||
//通过workDate 获取哪一天的卡
|
|
||||||
RzAttendance attendance = queryNowDayAttendanceByStatisticalIdAndDate(sysStaff.getUserId(),formatWorkDate);
|
|
||||||
//生成打卡记录
|
|
||||||
rzAttendanceDetailService.addDetail(attendance, ("OnDuty".equals(checkType) ? "上班卡" : "下班卡"), "/", formatUserCheckTime, "钉钉打卡", "");
|
|
||||||
//上班
|
|
||||||
if("OnDuty".equals(checkType)){
|
|
||||||
attendance.setRules("上班卡");
|
|
||||||
attendance.setWorkStartTime(formatUserCheckTime);
|
|
||||||
if(!"Normal".equals(timeResult)){
|
|
||||||
attendance.setYcsFlag("1");
|
|
||||||
}
|
|
||||||
}else if("OffDuty".equals(checkType)){
|
|
||||||
attendance.setWorkEndTime(formatUserCheckTime);
|
|
||||||
if("Normal".equals(timeResult)){
|
|
||||||
attendance.setWorkSum(BigDecimal.valueOf(dingsShift.getWorkHour()));
|
|
||||||
}else{
|
|
||||||
//早退需要计算工时
|
|
||||||
Long hours = (userCheckTime - attendance.getWorkStartTime().getTime())/1000/60/60;
|
|
||||||
attendance.setWorkSum(BigDecimal.valueOf(hours));
|
|
||||||
attendance.setYcxFlag("1");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
log.error("钉钉打卡=====>>>>>>>>>>>>>>>>>> 出现未知打卡类型, 当前打卡类型");
|
|
||||||
//终止继续执行
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//判断打卡时间, 添加夜班次数 打卡时间在晚上7点以后
|
|
||||||
if(dingsShift.getWorkHour() == 12 && attendance.getWorkSum().intValue() >= 12 && attendance.getWorkStartTime().getHours() > 12){
|
|
||||||
attendance.setNightNumber(1);
|
|
||||||
//必须是8小时倒班制or单班制, 并且工作时长>=8小时, 并且 上班打开时间在12点至21点 算作中班 -- 2026-02-04 因1月份张克龙中班考勤问题, 刘杰面谈
|
|
||||||
}else if(dingsShift.getWorkHour() == 8 && attendance.getWorkSum().intValue() >= 8 && attendance.getWorkStartTime().getHours() >= 12 && attendance.getWorkStartTime().getHours() < 21){
|
|
||||||
attendance.setMiddleShiftNumber(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
getBaseMapper().updateRzAttendance(attendance);
|
|
||||||
//检查是否开启加班
|
|
||||||
if(dingsShift.getOvertimeWork()){
|
|
||||||
//如果开启了加班
|
|
||||||
// BigDecimal hours = new BigDecimal(((userCheckTime - attendance.getWorkStartTime().getTime())/1000/60/60)).subtract(new BigDecimal(dingsShift.getWorkHour())).subtract(BigDecimal.valueOf(1)).subtract(new BigDecimal(String.valueOf(DataUtils.findDefaultValue(dingsShift.getDeductionHour(), 0))));
|
|
||||||
//使用排班下班时间作为加班开始时间
|
|
||||||
rzOverTimeService.overTimeCard(sysStaff, DateUtils.parseDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date(planCheckTime)), "yyyy-MM-dd HH:mm:ss"));
|
|
||||||
//员工打卡时间作为加班下班时间
|
|
||||||
rzOverTimeService.overTimeOffDutyCard(sysStaff, formatUserCheckTime, "/");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
log.info("未找到相关考勤班次数据, 疑似加班打卡=====>>>>> {}", result);
|
|
||||||
}*/
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -662,7 +592,7 @@ public class RzAttendanceServiceImpl extends ServiceImpl<RzAttendanceMapper, RzA
|
|||||||
}
|
}
|
||||||
}else if("OffDuty".equals(checkType)){
|
}else if("OffDuty".equals(checkType)){
|
||||||
attendance.setWorkEndTime(formatUserCheckTime);
|
attendance.setWorkEndTime(formatUserCheckTime);
|
||||||
if("Normal".equals(timeResult)){
|
if("Normal".equals(timeResult) && !"1".equals(attendance.getYcsFlag())){
|
||||||
attendance.setWorkSum(BigDecimal.valueOf(dingsShift.getWorkHour()));
|
attendance.setWorkSum(BigDecimal.valueOf(dingsShift.getWorkHour()));
|
||||||
}else{
|
}else{
|
||||||
//早退需要计算工时
|
//早退需要计算工时
|
||||||
@ -672,7 +602,9 @@ public class RzAttendanceServiceImpl extends ServiceImpl<RzAttendanceMapper, RzA
|
|||||||
}else {
|
}else {
|
||||||
attendance.setWorkSum(DataUtils.DEFAULT_VALUE);
|
attendance.setWorkSum(DataUtils.DEFAULT_VALUE);
|
||||||
}
|
}
|
||||||
attendance.setYcxFlag("1");
|
if(!"Normal".equals(timeResult)){
|
||||||
|
attendance.setYcxFlag("1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
log.error("钉钉打卡=====>>>>>>>>>>>>>>>>>> 出现未知打卡类型, 当前打卡类型");
|
log.error("钉钉打卡=====>>>>>>>>>>>>>>>>>> 出现未知打卡类型, 当前打卡类型");
|
||||||
@ -706,6 +638,57 @@ public class RzAttendanceServiceImpl extends ServiceImpl<RzAttendanceMapper, RzA
|
|||||||
return getBaseMapper().queryNowDayAttendanceByStatisticalIdAndDate(staffId,date);
|
return getBaseMapper().queryNowDayAttendanceByStatisticalIdAndDate(staffId,date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RzAttendance loadAttendance(Long id) {
|
||||||
|
RzAttendance attendance = getById(id);
|
||||||
|
SysStaff sysStaff = sysStaffMapper.selectById(attendance.getStaffId());
|
||||||
|
if(StringUtils.isNotEmpty(sysStaff.getDingUserId())){
|
||||||
|
String result = DingUtils.getListRecord(Collections.asList(sysStaff.getDingUserId()), DateUtils.parseDateToStr("yyyy-MM-dd", attendance.getAttendanceDate())+" 00:00:00", DateUtils.parseDateToStr("yyyy-MM-dd", attendance.getAttendanceDate())+" 23:59:59");
|
||||||
|
JSONObject resultJson = JSON.parseObject(result);
|
||||||
|
if(Integer.valueOf(0).equals(resultJson.getInteger("errcode")))
|
||||||
|
try {
|
||||||
|
JSONArray jsonArray = resultJson.getJSONArray("recordresult");
|
||||||
|
JSONObject onDutyObject = (JSONObject) jsonArray.stream().filter(data -> "OnDuty".equals(((JSONObject)data).getString("checkType"))).findFirst().orElse(null);
|
||||||
|
calculationAddRzOverTime(result, sysStaff, onDutyObject);
|
||||||
|
JSONObject offDutyObject = (JSONObject) jsonArray.stream().filter(data -> "OffDuty".equals(((JSONObject)data).getString("checkType"))).findFirst().orElse(null);
|
||||||
|
calculationAddRzOverTime(result, sysStaff, offDutyObject);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("重新抓取钉钉考勤结果异常, 异常原因是==>>{}, 打卡结果是=====>>>>> {}", e.getMessage(), result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attendance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calculationAddRzOverTime(String result ,SysStaff sysStaff, JSONObject ob){
|
||||||
|
//打卡类型
|
||||||
|
String checkType = ob.getString("checkType");
|
||||||
|
//考勤组
|
||||||
|
String groupId = ob.getString("groupId");
|
||||||
|
//排班时间
|
||||||
|
Long planCheckTime = ob.getLong("planCheckTime");
|
||||||
|
// 格式化:先转Date对象,再格式化
|
||||||
|
String formatPlanCheckTime = DateUtils.parseDateToStr("HH:mm:ss", new Date(planCheckTime));
|
||||||
|
//用户打卡时间
|
||||||
|
Long userCheckTime = ob.getLong("userCheckTime");
|
||||||
|
//工作时间 (这里指的是哪一天的卡)
|
||||||
|
Long workDate = ob.getLong("workDate");
|
||||||
|
/***
|
||||||
|
* 打卡结果
|
||||||
|
* Normal:正常
|
||||||
|
* Early:早退
|
||||||
|
* Late:迟到
|
||||||
|
* SeriousLate:严重迟到
|
||||||
|
* Absenteeism:旷工迟到
|
||||||
|
* NotSigned:未打卡
|
||||||
|
*/
|
||||||
|
String timeResult = ob.getString("timeResult");
|
||||||
|
|
||||||
|
Date formatWorkDate = Date.from(Instant.ofEpochMilli(workDate));
|
||||||
|
Date formatUserCheckTime = Date.from(Instant.ofEpochMilli(userCheckTime));
|
||||||
|
DingShiftGroup dingsShiftGroup = dingsShiftGroupMapper.selectByGroupIdAndTypeAndCheckTime(groupId, checkType, formatPlanCheckTime);
|
||||||
|
addRzOverTime(result, sysStaff, dingsShiftGroup, checkType, formatWorkDate, formatUserCheckTime, timeResult, null, 0d);
|
||||||
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
protected void sendAbnormalAttendance(SysStaff sysStaff, Date date){
|
protected void sendAbnormalAttendance(SysStaff sysStaff, Date date){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user