Commit 2005e653 authored by 赵啸非's avatar 赵啸非

添加考勤逻辑判断

parent 25f21526
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 考勤认证通过编码
*
* @author zxfei
*/
public enum DwMinorEnum {
人脸认证通过("0x4b", "人脸认证通过"),
刷卡加密码认证通过("0x02", "刷卡加密码认证通过"),
刷卡加指纹认证通过("0x28", "刷卡加指纹认证通过"),
指纹加密码认证通过("0x2e", "指纹加密码认证通过"),
人脸加指纹认证通过("0x36", "人脸加指纹认证通过"),
人脸加密码认证通过("0x39", "人脸加密码认证通过"),
人脸加刷卡认证通过("0x3c", "人脸加刷卡认证通过"),
人脸加密码加指纹认证通过("0x3f", "人脸加密码加指纹认证通过"),
人脸加刷卡加指纹认证通过("0x42", "人脸加刷卡加指纹认证通过"),
工号加指纹认证通过("0x45", "工号加指纹认证通过"),
工号加指纹加密码认证通过("0x48", "工号加指纹加密码认证通过"),
工号加人脸认证通过("0x4d", "工号加人脸认证通过"),
刷卡加指纹加密码认证通过("0x2b", "刷卡加指纹加密码认证通过");
private String value;
private String desc;
DwMinorEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static DwMinorEnum getByValue(String value) {
for (DwMinorEnum checkResultEnum : DwMinorEnum.values()) {
if (checkResultEnum.getValue() == value) {
return checkResultEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(String... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (DwMinorEnum item : DwMinorEnum.values()) {
try {
boolean hasE = false;
for (String e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
...@@ -14,6 +14,7 @@ import com.mortals.framework.service.ITaskExcuteService; ...@@ -14,6 +14,7 @@ import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DataUtil; import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.common.code.DwMinorEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.RedisKey; import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity; import com.mortals.xhx.module.attendance.model.AttendanceRecordHikEntity;
...@@ -85,13 +86,9 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -85,13 +86,9 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
boolean in = DateUtil.isIn(new Date(), beginDateTime, endDateTime); boolean in = DateUtil.isIn(new Date(), beginDateTime, endDateTime);
if (in) { if (in) {
List<DoorEntity> doorEntities = doorService.find(new DoorQuery()); List<DoorEntity> doorEntities = doorService.find(new DoorQuery());
for (DoorEntity doorEntity : doorEntities) { for (DoorEntity doorEntity : doorEntities) {
syncDoorEvents(doorEntity); syncDoorEvents(doorEntity);
//hikDoorService.searchDoorEventsList()
} }
//syncDoorEvents();
} }
} }
...@@ -117,58 +114,69 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -117,58 +114,69 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
List<AttendanceRecordHikEntity> attRecords = list.stream().map(item -> { List<AttendanceRecordHikEntity> attRecords = list.stream().map(item -> {
AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity(); AttendanceRecordHikEntity recordHikEntity = new AttendanceRecordHikEntity();
recordHikEntity.initAttrValue(); recordHikEntity.initAttrValue();
String jobNo = "";
byte[] byEmployeeNo = item.getStruAcsEventInfo().getByEmployeeNo(); byte[] byEmployeeNo = item.getStruAcsEventInfo().getByEmployeeNo();
if (ObjectUtils.isEmpty(new String(byEmployeeNo).trim())) { if (ObjectUtils.isEmpty(new String(byEmployeeNo).trim())) {
int dwEmployeeNo = item.getStruAcsEventInfo().getDwEmployeeNo(); int dwEmployeeNo = item.getStruAcsEventInfo().getDwEmployeeNo();
if (dwEmployeeNo == 0) { if (dwEmployeeNo == 0) {
log.info("jobNo is null ==>{}", JSON.toJSONString(item)); log.info("jobNo is null ==>{}", JSON.toJSONString(item));
return null; return null;
} else {
jobNo = String.valueOf(dwEmployeeNo);
} }
} else {
jobNo = new String(byEmployeeNo).trim();
} }
String jobNo = new String(byEmployeeNo).trim();
//查看考勤状态 //查看考勤状态
int dwMajor = item.getDwMajor();//报警主类型 int dwMajor = item.getDwMajor();//报警主类型
int dwMinor = item.getDwMinor();//报警次类型 int dwMinor = item.getDwMinor();//报警次类型
int byStatusValue = item.getStruAcsEventInfo().getByStatusValue();//考勤状态值
StruTime struTime = item.getStruTime(); String dwMinorStr = Integer.toHexString(dwMinor);
//格式化时间 年月日 时分秒 yyyy-MM-dd HH:mm:ss //判断次类型 是否在白名单里面
int dwYear = struTime.getDwYear(); Set<String> dwSet = DwMinorEnum.getEnumMap().keySet();
int dwMonth = struTime.getDwMonth(); if (dwSet.contains(dwMinorStr)) {
int dwDay = struTime.getDwDay(); //符号考勤 添加到考勤里面
int dwHour = struTime.getDwHour(); StruTime struTime = item.getStruTime();
int dwMinute = struTime.getDwMinute(); //格式化时间 年月日 时分秒 yyyy-MM-dd HH:mm:ss
int dwSecond = struTime.getDwSecond(); int dwYear = struTime.getDwYear();
int dwMonth = struTime.getDwMonth();
LocalDateTime localDateTime = LocalDateTime.of(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond); int dwDay = struTime.getDwDay();
ZoneId zoneId = ZoneId.systemDefault(); int dwHour = struTime.getDwHour();
ZonedDateTime zdt = localDateTime.atZone(zoneId); int dwMinute = struTime.getDwMinute();
int dwSecond = struTime.getDwSecond();
Date attendDate = Date.from(zdt.toInstant());
LocalDateTime localDateTime = LocalDateTime.of(dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond);
StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(jobNo, 8, "0")); ZoneId zoneId = ZoneId.systemDefault();
if (ObjectUtils.isEmpty(staffCache)) { ZonedDateTime zdt = localDateTime.atZone(zoneId);
log.info("staff is null !staffCode:{}", jobNo);
Date attendDate = Date.from(zdt.toInstant());
StaffEntity staffCache = staffService.getExtCache(StrUtil.padPre(jobNo, 8, "0"));
if (ObjectUtils.isEmpty(staffCache)) {
log.info("staff is null !staffCode:{}", jobNo);
return null;
}
recordHikEntity.setStaffId(staffCache.getId());
recordHikEntity.setStaffName(staffCache.getName());
recordHikEntity.setWorkNum(staffCache.getWorkNum());
recordHikEntity.setDeptId(staffCache.getDeptId());
recordHikEntity.setDeptName(staffCache.getDeptName());
recordHikEntity.setPositionId(staffCache.getPositionId());
recordHikEntity.setPositionName(staffCache.getPositionName());
recordHikEntity.setAttendanceDate(attendDate);
// recordHikEntity.setAttendanceAddress(item.getDoorName());
recordHikEntity.setEventSource("门禁点");
//recordHikEntity.setRemark(item.getEventId());
recordHikEntity.setCreateTime(new Date());
recordHikEntity.setCreateUserName("系统管理员");
recordHikEntity.setCreateUserId(1L);
return recordHikEntity;
} else {
log.info("考勤次类型dwMinorCode:" + dwMinorStr);
return null; return null;
} }
recordHikEntity.setStaffId(staffCache.getId());
recordHikEntity.setStaffName(staffCache.getName());
recordHikEntity.setWorkNum(staffCache.getWorkNum());
recordHikEntity.setDeptId(staffCache.getDeptId());
recordHikEntity.setDeptName(staffCache.getDeptName());
recordHikEntity.setPositionId(staffCache.getPositionId());
recordHikEntity.setPositionName(staffCache.getPositionName());
recordHikEntity.setAttendanceDate(attendDate);
// recordHikEntity.setAttendanceAddress(item.getDoorName());
recordHikEntity.setEventSource("门禁点");
//recordHikEntity.setRemark(item.getEventId());
recordHikEntity.setCreateTime(new Date());
recordHikEntity.setCreateUserName("系统管理员");
recordHikEntity.setCreateUserId(1L);
return recordHikEntity;
}).filter(f -> f != null).collect(Collectors.toList()); }).filter(f -> f != null).collect(Collectors.toList());
log.info("attRecords size:{}", attRecords.size()); log.info("attRecords size:{}", attRecords.size());
...@@ -182,9 +190,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -182,9 +190,7 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
log.error("基础考勤数据保存异常", e.getMessage()); log.error("基础考勤数据保存异常", e.getMessage());
} }
} }
// recordHikService.save(saveRecordList);
} }
} }
} }
......
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