|
@@ -1,5 +1,6 @@
|
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
+import ch.qos.logback.core.util.StringCollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.dingtalkcontact_1_0.models.GetUserHeaders;
|
|
@@ -17,19 +18,24 @@ import com.management.platform.entity.vo.UserVO;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.*;
|
|
|
import com.management.platform.util.ColorUtil;
|
|
|
+import com.management.platform.util.DateTimeUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.SnowFlake;
|
|
|
import com.taobao.api.ApiException;
|
|
|
+import com.taobao.api.internal.util.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -93,7 +99,21 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
private ProjectMapper projectMapper;
|
|
|
@Resource
|
|
|
private ProjectBasecostSettingMapper projectBasecostSettingMapper;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private UserDingdingTimeService userDingdingTimeService;
|
|
|
+ @Resource
|
|
|
+ private UserDingdingTimeMapper userDingdingTimeMapper;
|
|
|
+ @Resource
|
|
|
+ private LeaveSheetMapper leaveSheetMapper;
|
|
|
+ @Resource
|
|
|
+ private LeaveSheetService leaveSheetService;
|
|
|
+ //企业内部应用参数
|
|
|
+ @Value("${dingding.appkey}")
|
|
|
+ private String appkey;
|
|
|
+ @Value("${dingding.appsecret}")
|
|
|
+ private String appsecret;
|
|
|
+ @Value("${configEnv.isPrivateDeploy}")
|
|
|
+ private boolean isPrivateDeploy;//企业内部应用,私有化部署的情况
|
|
|
@Override
|
|
|
@Async
|
|
|
public void corpAuth(String corpid, String corpName, String authUserId, Long agentId) throws ApiException {
|
|
@@ -310,6 +330,49 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
return execute;
|
|
|
}
|
|
|
|
|
|
+ private String getCorpAccessToken(CompanyDingding dingding) {
|
|
|
+ String accessToken = null;
|
|
|
+ if (dingding.getExpireTime().isBefore(LocalDateTime.now())) {
|
|
|
+ SysConfig config = sysConfigMapper.selectOne(new QueryWrapper<SysConfig>().eq("param_key", "dingding_suite_ticket"));
|
|
|
+ OapiServiceGetCorpTokenResponse result = null;
|
|
|
+ try {
|
|
|
+ result = getAuthCorpAccessToken(dingding.getCorpid(), config.getParamValue());
|
|
|
+ if (result != null) {
|
|
|
+ if (result.getErrcode() == 0L) {
|
|
|
+ //返回成功
|
|
|
+ dingding.setAccessToken(result.getAccessToken());
|
|
|
+ LocalDateTime time = LocalDateTime.now();
|
|
|
+ time = time.plusSeconds(result.getExpiresIn());//设置token过期时间
|
|
|
+ dingding.setExpireTime(time);
|
|
|
+ companyDingdingMapper.updateById(dingding);
|
|
|
+
|
|
|
+ accessToken = dingding.getAccessToken();
|
|
|
+ } else {
|
|
|
+ System.out.println(result.getBody());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ accessToken = dingding.getAccessToken();
|
|
|
+ }
|
|
|
+ return accessToken;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取钉钉内部企业的token
|
|
|
+ */
|
|
|
+ private OapiGettokenResponse getInnerCorpToken() throws ApiException {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
|
|
|
+ OapiGettokenRequest request = new OapiGettokenRequest();
|
|
|
+ request.setAppkey(appkey);
|
|
|
+ request.setAppsecret(appsecret);
|
|
|
+ request.setHttpMethod("GET");
|
|
|
+ OapiGettokenResponse response = client.execute(request);
|
|
|
+ System.out.println(response.getBody());
|
|
|
+ return response;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 使用 Token 初始化账号Client
|
|
@@ -990,6 +1053,308 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncLeaveTime(Integer companyId, String userId, String startDate, String endDate) {
|
|
|
+ //获取从开始日期到结束日期期间内的每一天的请假时长
|
|
|
+ if (companyId != null) {
|
|
|
+ //指定的某个公司
|
|
|
+ CompanyDingding dingding = companyDingdingMapper.selectOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId));
|
|
|
+ syncOneCompLeave(dingding, userId, startDate, endDate);
|
|
|
+ } else {
|
|
|
+ //全部的
|
|
|
+ List<TimeType> timeTypes = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_dingding", 1));
|
|
|
+ List<Integer> companyIds = timeTypes.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
|
|
|
+ List<CompanyDingding> dingdingList = companyDingdingMapper.selectList(new QueryWrapper<CompanyDingding>().in("company_id", companyIds));
|
|
|
+ for (CompanyDingding dingding : dingdingList) {
|
|
|
+ syncOneCompLeave(dingding, userId, startDate, endDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取当天的员工考勤数据,包括打卡,请假/出差申请单; 仅企业内部应用有权限
|
|
|
+ @Override
|
|
|
+ public void syncUserWorkData(Integer companyId, String workDate) {
|
|
|
+ if (companyId != null) {
|
|
|
+ //指定的某个公司
|
|
|
+ CompanyDingding dingding = companyDingdingMapper.selectOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId));
|
|
|
+ syncOneCompWorkData(dingding, workDate);
|
|
|
+ } else {
|
|
|
+ //全部的
|
|
|
+ List<TimeType> timeTypes = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_dingding", 1));
|
|
|
+ List<Integer> companyIds = timeTypes.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
|
|
|
+ List<CompanyDingding> dingdingList = companyDingdingMapper.selectList(new QueryWrapper<CompanyDingding>().in("company_id", companyIds));
|
|
|
+ for (CompanyDingding dingding : dingdingList) {
|
|
|
+ syncOneCompWorkData(dingding, workDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void syncOneCompLeave(CompanyDingding dingding, String targetUserId, String startDate, String endDate) {
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(dingding.getCompanyId());
|
|
|
+ if (!StringUtils.isEmpty(targetUserId)) {
|
|
|
+ userList.add(userMapper.selectById(targetUserId));
|
|
|
+ } else {
|
|
|
+ userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", dingding.getCompanyId()).eq("is_active", 1));
|
|
|
+ }
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String accessToken = getCorpAccessToken(dingding);
|
|
|
+ List<LeaveSheet> sheetList = new ArrayList<>();
|
|
|
+ for (User u : userList) {
|
|
|
+ String type = "";
|
|
|
+ List<String> typeList = new ArrayList<>();
|
|
|
+ //最后一个其他不要
|
|
|
+ for (int i=0;i<Constant.LEAVE_TYPES.length-1; i++) {
|
|
|
+ type += Constant.LEAVE_TYPES[i];
|
|
|
+ if (i < Constant.LEAVE_TYPES.length -2) {
|
|
|
+ type += ",";
|
|
|
+ }
|
|
|
+ if (type.length() > 15 || i == Constant.LEAVE_TYPES.length -2) {
|
|
|
+ if (type.endsWith(",")) {
|
|
|
+ type = type.substring(0, type.length()-1);
|
|
|
+ }
|
|
|
+ typeList.add(type);
|
|
|
+ type = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String t : typeList) {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/getleavetimebynames");
|
|
|
+ OapiAttendanceGetleavetimebynamesRequest req = new OapiAttendanceGetleavetimebynamesRequest();
|
|
|
+ req.setUserid(u.getDingdingUserid());
|
|
|
+ req.setLeaveNames(t);
|
|
|
+ req.setFromDate(StringUtils.parseDateTime(startDate + " 00:00:00"));
|
|
|
+ req.setToDate(StringUtils.parseDateTime(endDate + " 23:59:59"));
|
|
|
+ OapiAttendanceGetleavetimebynamesResponse rsp = null;
|
|
|
+ try {
|
|
|
+ rsp = client.execute(req, accessToken);
|
|
|
+ System.out.println(rsp.getBody());
|
|
|
+// JSONArray array = JSONObject.parseObject(rsp.getBody()).getJSONObject("result").getJSONArray("columns");
|
|
|
+// for (int i=0;i<array.size(); i++) {
|
|
|
+// JSONObject item = array.getJSONObject(i);
|
|
|
+// String leaveTypeName = item.getJSONObject("columnvo").getString("name");
|
|
|
+// int typeIndex = 0;
|
|
|
+// for (int index=0;index < Constant.LEAVE_TYPES.length; index++) {
|
|
|
+// if (Constant.LEAVE_TYPES[index].equals(leaveTypeName)) {
|
|
|
+// typeIndex = index;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //获取请假的数据
|
|
|
+// JSONArray valArray = item.getJSONArray("columnvals");
|
|
|
+// for (int j=0;j<valArray.size(); j++) {
|
|
|
+// Float val = valArray.getJSONObject(j).getFloat("value");
|
|
|
+// String date = valArray.getJSONObject(j).getString("date");
|
|
|
+// LocalDate localDate = LocalDateTime.parse(date, dtf).toLocalDate();
|
|
|
+// if (val != null && val > 0.0) {
|
|
|
+// //存在请假时长
|
|
|
+// LeaveSheet sheet = new LeaveSheet();
|
|
|
+// sheet.setCompanyId(dingding.getCompanyId());
|
|
|
+// sheet.setOwnerId(u.getId());
|
|
|
+// sheet.setOwnerName(u.getName());
|
|
|
+// sheet.setLeaveType(typeIndex);
|
|
|
+// sheet.setTimeHours(val);
|
|
|
+// sheet.setStartDate(localDate);
|
|
|
+// sheet.setEndDate(localDate);
|
|
|
+// if (val >= timeType.getAllday()) {
|
|
|
+// sheet.setTimeType(0);
|
|
|
+// sheet.setTimeDays(1.0f);
|
|
|
+// } else {
|
|
|
+// sheet.setTimeType(1);//按小时
|
|
|
+// }
|
|
|
+// sheetList.add(sheet);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sheetList.size() > 0) {
|
|
|
+ //添加或更新请假数据
|
|
|
+ List<LeaveSheet> oldList = leaveSheetMapper.selectList(new QueryWrapper<LeaveSheet>()
|
|
|
+ .eq("company_id", dingding.getCompanyId()).between("start_date", startDate, endDate)
|
|
|
+ .between("end_date", startDate, endDate));
|
|
|
+ for (LeaveSheet newSheet : sheetList) {
|
|
|
+ Optional<LeaveSheet> find = oldList.stream()
|
|
|
+ .filter(old->old.getStartDate().isEqual(newSheet.getStartDate()) && old.getOwnerId().equals(newSheet.getOwnerId())
|
|
|
+ && old.getLeaveType().equals(newSheet.getLeaveType())).findFirst();
|
|
|
+ if (find.isPresent()) {
|
|
|
+ newSheet.setId(find.get().getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ leaveSheetService.saveOrUpdateBatch(sheetList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncCardTime(Integer companyId,String userId, String startDate, String endDate) {
|
|
|
+ if (companyId != null) {
|
|
|
+ //指定的某个公司
|
|
|
+ CompanyDingding dingding = companyDingdingMapper.selectOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId));
|
|
|
+ syncOneComp(dingding, userId, startDate, endDate);
|
|
|
+ } else {
|
|
|
+ //全部的
|
|
|
+ List<TimeType> timeTypes = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_dingding", 1));
|
|
|
+ List<Integer> companyIds = timeTypes.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
|
|
|
+ List<CompanyDingding> dingdingList = companyDingdingMapper.selectList(new QueryWrapper<CompanyDingding>().in("company_id", companyIds));
|
|
|
+ for (CompanyDingding dingding : dingdingList) {
|
|
|
+ syncOneComp(dingding, userId, startDate, endDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void syncOneCompWorkData(CompanyDingding dingding, String workDate) {
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", dingding.getCompanyId()));
|
|
|
+ String accessToken = null;
|
|
|
+ try {
|
|
|
+ accessToken = getInnerCorpToken().getAccessToken();
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ for (User user : userList) {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/getupdatedata");
|
|
|
+ OapiAttendanceGetupdatedataRequest req = new OapiAttendanceGetupdatedataRequest();
|
|
|
+ req.setUserid(user.getDingdingUserid());
|
|
|
+ req.setWorkDate(StringUtils.parseDateTime(workDate + " 00:00:00"));
|
|
|
+ OapiAttendanceGetupdatedataResponse rsp = null;
|
|
|
+ try {
|
|
|
+ rsp = client.execute(req, accessToken);
|
|
|
+ System.out.println(rsp.getBody());
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void syncOneComp(CompanyDingding dingding, String targetUserId, String startDate, String endDate) {
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ if (!StringUtils.isEmpty(targetUserId)) {
|
|
|
+ userList.add(userMapper.selectById(targetUserId));
|
|
|
+ } else {
|
|
|
+ userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", dingding.getCompanyId()).eq("is_active", 1));
|
|
|
+ }
|
|
|
+ String accessToken = getCorpAccessToken(dingding);
|
|
|
+ if (userList.size() > 50) {
|
|
|
+ int batchSize = userList.size()/50+userList.size()%50==0?0:1;
|
|
|
+ for (int i=0; i<batchSize; i++) {
|
|
|
+ int endIndex = (i+1)*50;
|
|
|
+ if (endIndex > userList.size()) {
|
|
|
+ endIndex = userList.size();
|
|
|
+ }
|
|
|
+ syncCardDetailList(dingding, startDate, endDate, accessToken, userList.subList(i*50,endIndex));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ syncCardDetailList(dingding, startDate, endDate, accessToken, userList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void syncCardDetailList(CompanyDingding dingding, String startDate, String endDate, String accessToken, List<User> userList) {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/attendance/listRecord");
|
|
|
+ OapiAttendanceListRecordRequest req = new OapiAttendanceListRecordRequest();
|
|
|
+ List<String> ddIds = userList.stream().map(User::getDingdingUserid).collect(Collectors.toList());
|
|
|
+ req.setUserIds(ddIds);
|
|
|
+ req.setCheckDateFrom(startDate+ " 08:00:00");
|
|
|
+ req.setCheckDateTo(endDate+ " 23:59:59");
|
|
|
+ req.setIsI18n(false);
|
|
|
+ OapiAttendanceListRecordResponse rsp = null;
|
|
|
+ try {
|
|
|
+ rsp = client.execute(req, accessToken);
|
|
|
+ System.out.println(rsp);
|
|
|
+ if (rsp.getErrcode() == 0) {
|
|
|
+ //正常
|
|
|
+ JSONArray array = JSONObject.parseObject(rsp.getBody()).getJSONArray("recordresult");
|
|
|
+ List<DdingCardTimeItem> list = new ArrayList<DdingCardTimeItem>();
|
|
|
+ for (int i=0;i<array.size(); i++) {
|
|
|
+ list.add(JSONObject.toJavaObject(array.getJSONObject(i), DdingCardTimeItem.class));
|
|
|
+ }
|
|
|
+ //获取数据库中已有的数据,做比对
|
|
|
+ List<String> ids = userList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<UserDingdingTime> oldList = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>().between("work_date", startDate, endDate).in("user_id", ids));
|
|
|
+ System.out.println("历史数据size===="+oldList.size());
|
|
|
+ List<UserDingdingTime> cardRecordList = new ArrayList<>();
|
|
|
+ //按人员进行分组
|
|
|
+ Map<String, List<DdingCardTimeItem>> map = list.stream().collect(Collectors.groupingBy(DdingCardTimeItem::getUserId));
|
|
|
+ Iterator<String> it = map.keySet().iterator();
|
|
|
+ DateTimeFormatter hmFormat = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
+ while(it.hasNext()) {
|
|
|
+ String key = it.next();
|
|
|
+ //取这个人员的所有考勤记录,再按天进行分组
|
|
|
+ List<DdingCardTimeItem> ddTimes = map.get(key);
|
|
|
+ String uid = userList.stream().filter(u->u.getDingdingUserid().equals(key)).findFirst().get().getId();
|
|
|
+ Map<Long, List<DdingCardTimeItem>> dailyMap = ddTimes.stream().collect(Collectors.groupingBy(DdingCardTimeItem::getWorkDate));
|
|
|
+ Iterator<Long> dayIter = dailyMap.keySet().iterator();
|
|
|
+ while (dayIter.hasNext()) {
|
|
|
+ Long d = dayIter.next();
|
|
|
+ LocalDate workDate = LocalDateTime.ofEpochSecond(d/1000, 0, ZoneOffset.ofHours(8)).toLocalDate();
|
|
|
+ UserDingdingTime timeItem = new UserDingdingTime();
|
|
|
+ timeItem.setWorkDate(workDate);
|
|
|
+ System.out.println("workDate====="+workDate);
|
|
|
+ List<DdingCardTimeItem> oneDayTimes = dailyMap.get(d);
|
|
|
+
|
|
|
+ DdingCardTimeItem onDutyEarleast = null;
|
|
|
+ DdingCardTimeItem offDutyLatest = null;
|
|
|
+ Comparator<DdingCardTimeItem> comparator = Comparator.comparing(DdingCardTimeItem::getUserCheckTime);
|
|
|
+ Optional<DdingCardTimeItem> find = oneDayTimes.stream().filter(p->"OnDuty".equals(p.getCheckType())).min(comparator);
|
|
|
+ if (find.isPresent()) {
|
|
|
+ onDutyEarleast = find.get();
|
|
|
+ }
|
|
|
+ Optional<DdingCardTimeItem> findOff = oneDayTimes.stream().filter(p->"OffDuty".equals(p.getCheckType())).max(comparator);
|
|
|
+ if (findOff.isPresent()) {
|
|
|
+ offDutyLatest = findOff.get();
|
|
|
+ }
|
|
|
+ if (onDutyEarleast != null) {
|
|
|
+ System.out.println("最早打卡时间"+onDutyEarleast.getUserCheckTime());
|
|
|
+ timeItem.setDingdingCorpid(onDutyEarleast.getCorpId());
|
|
|
+ timeItem.setDingdingUserid(onDutyEarleast.getUserId());
|
|
|
+ timeItem.setUserId(uid);
|
|
|
+ LocalDateTime sLt = LocalDateTime.ofEpochSecond(onDutyEarleast.getUserCheckTime()/1000, 0, ZoneOffset.ofHours(8));
|
|
|
+ timeItem.setStartTime(hmFormat.format(sLt));
|
|
|
+ //计算周几
|
|
|
+ timeItem.setWeekDay(workDate.getDayOfWeek().getValue());
|
|
|
+ timeItem.setWeekDayTxt(DateTimeUtil.getWeekDayTxt(timeItem.getWeekDay()));
|
|
|
+ }
|
|
|
+ if (offDutyLatest != null) {
|
|
|
+ System.out.println("最晚打卡时间"+offDutyLatest.getUserCheckTime());
|
|
|
+ LocalDateTime oLt = LocalDateTime.ofEpochSecond(offDutyLatest.getUserCheckTime()/1000, 0, ZoneOffset.ofHours(8));
|
|
|
+ timeItem.setEndTime(hmFormat.format(oLt));
|
|
|
+ }
|
|
|
+ timeItem.setCompanyId(dingding.getCompanyId());
|
|
|
+ if (onDutyEarleast != null && offDutyLatest != null) {
|
|
|
+ long seconds = (offDutyLatest.getUserCheckTime() - onDutyEarleast.getUserCheckTime())/1000;
|
|
|
+ float hours = seconds*1.0f/3600;
|
|
|
+ timeItem.setWorkHours(hours);
|
|
|
+ //对比,看看之前是否已经存了
|
|
|
+ Optional<UserDingdingTime> findOld = oldList.stream().filter(old->old.getUserId().equals(timeItem.getUserId()) && old.getWorkDate().isEqual(timeItem.getWorkDate())).findFirst();
|
|
|
+ if (findOld.isPresent()) {
|
|
|
+ timeItem.setId(findOld.get().getId());
|
|
|
+ }
|
|
|
+ cardRecordList.add(timeItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存数据
|
|
|
+ if (cardRecordList.size() > 0) {
|
|
|
+ System.out.println("插入数据size=="+cardRecordList.size());
|
|
|
+ userDingdingTimeService.saveOrUpdateBatch(cardRecordList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //报错了
|
|
|
+ System.err.println("同步钉钉考勤报错 "+rsp.getErrcode()+":"+rsp.getErrmsg());
|
|
|
+ System.err.println("同步钉钉考勤报错 "+rsp.getErrcode()+":"+rsp.getErrmsg());
|
|
|
+ }
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ System.out.println(rsp.getBody());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public void activateSuite(String authCorpid, String tmpAuthCode) throws ApiException {
|
|
|
DingTalkClient client= new DefaultDingTalkClient("https://oapi.dingtalk.com/service/activate_suite?suite_access_token=" + getDDSuiteAccessToken());
|
|
|
OapiServiceActivateSuiteRequest req= new OapiServiceActivateSuiteRequest();
|