|
@@ -2277,7 +2277,7 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
try {
|
|
|
rsp = client.execute(req, accessToken);
|
|
|
if (rsp.getErrcode() == 0) {
|
|
|
- System.out.println(rsp.getBody());
|
|
|
+// System.out.println("获取考勤数据="+rsp.getBody());
|
|
|
//正常
|
|
|
JSONArray array = JSONObject.parseObject(rsp.getBody()).getJSONArray("recordresult");
|
|
|
List<DdingCardTimeItem> list = new ArrayList<DdingCardTimeItem>();
|
|
@@ -2317,6 +2317,26 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
Optional<DdingCardTimeItem> find = oneDayTimes.stream().filter(p->"OnDuty".equals(p.getCheckType())).min(comparator);
|
|
|
if (find.isPresent()) {
|
|
|
onDutyEarleast = find.get();
|
|
|
+ } else {
|
|
|
+ //如果没有上班数据,尝试查找invalidRecordType=Other, sourceType=APPROVE
|
|
|
+ for (int i=0;i<array.size(); i++) {
|
|
|
+ JSONObject object = array.getJSONObject(i);
|
|
|
+ if ("Other".equals(object.getString("invalidRecordType")) && "APPROVE".equals(object.getString("sourceType"))) {
|
|
|
+ onDutyEarleast = JSONObject.toJavaObject(object, DdingCardTimeItem.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (onDutyEarleast == null) {
|
|
|
+ //再尝试获取最早的下班打卡,作为上班时间,但是要在13:30之前
|
|
|
+ find = oneDayTimes.stream().filter(p->"OffDuty".equals(p.getCheckType())).min(comparator);
|
|
|
+ if (find.isPresent()) {
|
|
|
+ DdingCardTimeItem time = find.get();
|
|
|
+ LocalDateTime sLt = LocalDateTime.ofEpochSecond(time.getUserCheckTime()/1000, 0, ZoneOffset.ofHours(8));
|
|
|
+ String checkTime = hmFormat.format(sLt);
|
|
|
+ if (checkTime.compareTo("13:30") < 0) {
|
|
|
+ onDutyEarleast = time;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
Optional<DdingCardTimeItem> findOff = oneDayTimes.stream().filter(p->"OffDuty".equals(p.getCheckType())).max(comparator);
|
|
|
if (findOff.isPresent()) {
|
|
@@ -2347,6 +2367,7 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
check=oLt.toLocalDate();
|
|
|
}
|
|
|
timeItem.setCompanyId(dingding.getCompanyId());
|
|
|
+// System.out.println(timeItem.getWorkDate() +", timeItem ="+timeItem.getStartTime() + "--" + timeItem.getEndTime());
|
|
|
if (onDutyEarleast != null && offDutyLatest != null) {
|
|
|
//下班打卡时间在第二天的情况下设置为前一天的23:59
|
|
|
if(offDutyLatest.getUserCheckTime() < onDutyEarleast.getUserCheckTime()){
|
|
@@ -2376,7 +2397,6 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
}
|
|
|
//保存数据
|
|
|
if (cardRecordList.size() > 0) {
|
|
|
- System.out.println("插入数据size=="+cardRecordList.size());
|
|
|
userDingdingTimeService.saveOrUpdateBatch(cardRecordList);
|
|
|
}
|
|
|
} else {
|