|
|
@@ -981,6 +981,9 @@ public class McYdServiceImpl implements McYdService {
|
|
|
public void getCheckInData(JSONObject eventJson) {
|
|
|
MDC.put("MDC_KEY_PID","1000");
|
|
|
|
|
|
+ String baseId = "YMyQA2dXW7LkEz9LcDgZZDzPVzlwrZgb";//AI表格ID
|
|
|
+ String sheetIdOrName = "签到数据";//数据表ID或数据表名称
|
|
|
+
|
|
|
int retryCount = 0;
|
|
|
int maxRetries = 5;
|
|
|
|
|
|
@@ -1002,6 +1005,7 @@ public class McYdServiceImpl implements McYdService {
|
|
|
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");
|
|
|
+ String unionid = UtilMap.getString(result1, "unionid");
|
|
|
|
|
|
//查询用户考勤数据
|
|
|
DDR_New ddrNew = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/checkin/record/get", null, ddClient.initTokenParams(), body, DDR_New.class);
|
|
|
@@ -1009,26 +1013,30 @@ public class McYdServiceImpl implements McYdService {
|
|
|
List list = UtilMap.getList(result, "page_list");
|
|
|
|
|
|
if (!list.isEmpty()){
|
|
|
- Map formData = new HashMap();
|
|
|
+ Map fields = 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(timeStamp);
|
|
|
- formData.put("textField_mbrbdyl4","签到人:" +userName + ",签到时间:" + formattedDate + ",签到地点:" + detailPlace);//标题
|
|
|
+ Map user = new HashMap();
|
|
|
+ user.put("unionId",unionid);
|
|
|
+ fields.put("9XFXz5d",Arrays.asList(user));//签到人
|
|
|
+ fields.put("mKUEya0",checkinTime);//签到时间
|
|
|
+ fields.put("mHe1U1b",detailPlace);//签到地点
|
|
|
+ fields.put("CngGPET",remark);//备注
|
|
|
|
|
|
- ydClient.operateData(YDParam.builder()
|
|
|
- .formUuid("FORM-94F65C7405A24E20AE70987AD1C39082SLIB")
|
|
|
- .formDataJson(JSONObject.toJSONString(formData))
|
|
|
- .build(),YDConf.FORM_OPERATION.create);
|
|
|
- }
|
|
|
+ Map records = new HashMap();
|
|
|
+
|
|
|
+ Map fieldsMap = new HashMap();
|
|
|
+ fieldsMap.put("fields",fields);
|
|
|
|
|
|
+ records.put("records",Arrays.asList(fieldsMap));
|
|
|
+
|
|
|
+ Map param = new HashMap();
|
|
|
+ param.put("operatorId",unionid);
|
|
|
+
|
|
|
+ UtilHttp.doPost("https://api.dingtalk.com/v1.0/notable/bases/"+baseId+"/sheets/"+sheetIdOrName+"/records",ddClient.initTokenHeader(),param,records);
|
|
|
+ }
|
|
|
break;
|
|
|
} catch (Exception e) {
|
|
|
if (retryCount < maxRetries){
|