Commit b3065992 authored by 赵啸非's avatar 赵啸非

添加员工钉钉同步userId

parent b9b0ae79
...@@ -38,6 +38,7 @@ import com.mortals.xhx.module.staff.service.StaffService; ...@@ -38,6 +38,7 @@ import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -225,6 +226,9 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At ...@@ -225,6 +226,9 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
return Rest.ok(); return Rest.ok();
} }
@Value("${source.type:''}")
protected String sourceType;
private void getLeaveRecordByUserList(AttendanceLeaveRecordQuery query, List<StaffEntity> staffCacheList, List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords) { private void getLeaveRecordByUserList(AttendanceLeaveRecordQuery query, List<StaffEntity> staffCacheList, List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords) {
List<List<StaffEntity>> partition = Lists.partition(staffCacheList, 10); List<List<StaffEntity>> partition = Lists.partition(staffCacheList, 10);
for (List<StaffEntity> staffList : partition) { for (List<StaffEntity> staffList : partition) {
...@@ -234,6 +238,8 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At ...@@ -234,6 +238,8 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
long endTime = DateUtil.parseDateTime(query.getEndTimeEnd() + " 23:59:59").getTime(); long endTime = DateUtil.parseDateTime(query.getEndTimeEnd() + " 23:59:59").getTime();
Long nextToken = 0L; Long nextToken = 0L;
long maxResults = 20L; long maxResults = 20L;
if (AttendSourceTypeEnum.海康云平台.getValue().equals(sourceType)) {
for (ProcessInstanceEnum processInstanceEnum : ProcessInstanceEnum.values()) { for (ProcessInstanceEnum processInstanceEnum : ProcessInstanceEnum.values()) {
try { try {
getRecords(waitSyncLeaveRecords, processInstanceEnum, startTime, endTime, nextToken, maxResults, dingUserIds); getRecords(waitSyncLeaveRecords, processInstanceEnum, startTime, endTime, nextToken, maxResults, dingUserIds);
...@@ -241,6 +247,26 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At ...@@ -241,6 +247,26 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
log.error("同步请假记录异常", e); log.error("同步请假记录异常", e);
} }
} }
} else if (AttendSourceTypeEnum.钉钉.getValue().equals(sourceType)) {
for (QiongLaiProcessInstanceEnum processInstanceEnum : QiongLaiProcessInstanceEnum.values()) {
try {
getRecords(waitSyncLeaveRecords, processInstanceEnum, startTime, endTime, nextToken, maxResults, dingUserIds);
} catch (Exception e) {
log.error("同步请假记录异常", e);
}
}
}else {
for (ProcessInstanceEnum processInstanceEnum : ProcessInstanceEnum.values()) {
try {
getRecords(waitSyncLeaveRecords, processInstanceEnum, startTime, endTime, nextToken, maxResults, dingUserIds);
} catch (Exception e) {
log.error("同步请假记录异常", e);
}
}
}
} }
} }
...@@ -263,6 +289,25 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At ...@@ -263,6 +289,25 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
} }
} }
private void getRecords(List<AttendanceLeaveRecordEntity> waitSyncLeaveRecords, QiongLaiProcessInstanceEnum processInstanceEnum, long startTime, long endTime, Long nextToken, long maxResults, List<String> dingUserIds) throws Exception {
Rest<ListProcessInstanceIdsResponseBody.ListProcessInstanceIdsResponseBodyResult> rest = dingPersonService.getProcessInstanceIdByUserIds(processInstanceEnum.getValue(), startTime, endTime, nextToken, maxResults, dingUserIds);
if (YesNoEnum.YES.getValue() == rest.getCode()) {
if (ObjectUtils.isEmpty(rest.getData().getNextToken())) {
List<String> processInstanceList = rest.getData().getList();
for (String process : processInstanceList) {
AttendanceLeaveRecordEntity leaveRecord = new AttendanceLeaveRecordEntity();
leaveRecord.setRemark(process);
// leaveRecord.setStaffId(item.getCustomerId());
waitSyncLeaveRecords.add(leaveRecord);
log.info("更新记录成功==>" + process);
}
} else {
nextToken = DataUtil.converStr2Long(rest.getData().getNextToken(), 0L);
getRecords(waitSyncLeaveRecords, processInstanceEnum, startTime, endTime, nextToken, maxResults, dingUserIds);
}
}
}
private void creatPerformAttend(AttendanceLeaveRecordEntity entity, Context context) { private void creatPerformAttend(AttendanceLeaveRecordEntity entity, Context context) {
try { try {
if (AppealResultEnum.通过.getValue() == entity.getAuditResult() && LeaveTypeEnum.事假.getValue() == entity.getLeaveType()) { if (AppealResultEnum.通过.getValue() == entity.getAuditResult() && LeaveTypeEnum.事假.getValue() == entity.getLeaveType()) {
......
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