|
@@ -18,6 +18,7 @@ import org.apache.logging.log4j.util.Strings;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -1471,6 +1472,63 @@ public class YiyaoServiceImpl implements YiyaoService {
|
|
return McR.success();
|
|
return McR.success();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void getCheckInData(JSONObject eventJson) {
|
|
|
|
+ String timeStamp = eventJson.getString("timeStamp");//签到时间戳
|
|
|
|
+
|
|
|
|
+ timeStamp = roundToNearestThousand(Long.parseLong(timeStamp)) + "";
|
|
|
|
+
|
|
|
|
+ String staffId = eventJson.getString("StaffId");//签到人userId
|
|
|
|
+
|
|
|
|
+ //获取签到数据
|
|
|
|
+ Map body = new HashMap();
|
|
|
|
+ body.put("cursor",0);
|
|
|
|
+ body.put("size",100);
|
|
|
|
+ body.put("start_time",timeStamp);
|
|
|
|
+ body.put("end_time",timeStamp);
|
|
|
|
+ body.put("userid_list",staffId);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //查询用户详情
|
|
|
|
+ DDR_New ddrNew1 = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/user/get", null, ddClient.initTokenParams(), UtilMap.map("userid", staffId), DDR_New.class);
|
|
|
|
+
|
|
|
|
+ Map result1 = (Map) ddrNew1.getResult();
|
|
|
|
+
|
|
|
|
+ String userName = UtilMap.getString(result1, "name");
|
|
|
|
+
|
|
|
|
+ //查询用户考勤数据
|
|
|
|
+ DDR_New ddrNew = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/checkin/record/get", null, ddClient.initTokenParams(), body, DDR_New.class);
|
|
|
|
+
|
|
|
|
+ Map result = (Map) ddrNew.getResult();
|
|
|
|
+
|
|
|
|
+ List list = UtilMap.getList(result, "page_list");
|
|
|
|
+
|
|
|
|
+ if (!list.isEmpty()){
|
|
|
|
+ Map formData = new HashMap();
|
|
|
|
+
|
|
|
|
+ Map checkInData = (Map) list.get(0);
|
|
|
|
+
|
|
|
|
+ Long checkinTime = UtilMap.getLong(checkInData, "checkin_time");
|
|
|
|
+ String detailPlace = UtilMap.getString(checkInData, "detail_place");
|
|
|
|
+ String remark = UtilMap.getString(checkInData,"remark");
|
|
|
|
+
|
|
|
|
+ formData.put("employeeField_mbypt8ro",Arrays.asList(staffId));//签到人
|
|
|
|
+ formData.put("textField_mbyq1cji",userName);//签到人-文本
|
|
|
|
+ formData.put("dateField_mbrb3qfy",checkinTime);//签到时间
|
|
|
|
+ formData.put("textField_mbrb3qfx",detailPlace);//签到地点
|
|
|
|
+ formData.put("textareaField_mbypt8rp",remark);//备注
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
+ String formattedDate = sdf.format(Long.parseLong(timeStamp));
|
|
|
|
+ formData.put("textField_mbrbdyl4","签到人:" +userName + ",签到时间:" + formattedDate + ",签到地点:" + detailPlace);//标题
|
|
|
|
+
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
+ .formUuid("FORM-D4389CDAD1704F959E9D38CB64927AD8PKCH")
|
|
|
|
+ .formDataJson(JSONObject.toJSONString(formData))
|
|
|
|
+ .build(),YDConf.FORM_OPERATION.create);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private List<Map> getYdDataList(String formUuid, String searchCondition, YDConf.FORM_QUERY formQuery) {
|
|
private List<Map> getYdDataList(String formUuid, String searchCondition, YDConf.FORM_QUERY formQuery) {
|
|
List<Map> list = new ArrayList<>();
|
|
List<Map> list = new ArrayList<>();
|
|
@@ -1488,4 +1546,15 @@ public class YiyaoServiceImpl implements YiyaoService {
|
|
}while (ddrNew.getTotalCount() > ddrNew.getPageNumber() * pageSize);
|
|
}while (ddrNew.getTotalCount() > ddrNew.getPageNumber() * pageSize);
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public long roundToNearestThousand(long timestamp) {
|
|
|
|
+ // 将时间戳除以1000,得到秒级部分(带毫秒的小数部分)
|
|
|
|
+ double seconds = timestamp / 1000.0;
|
|
|
|
+
|
|
|
|
+ // 对秒级部分的个位数进行四舍五入(即对毫秒的千位四舍五入)
|
|
|
|
+ long roundedSeconds = Math.round(seconds);
|
|
|
|
+
|
|
|
|
+ // 将四舍五入后的秒级部分转换回毫秒时间戳
|
|
|
|
+ return roundedSeconds * 1000;
|
|
|
|
+ }
|
|
}
|
|
}
|