|
@@ -3,10 +3,10 @@ package com.malk.mc.controller;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.malk.server.common.McException;
|
|
|
import com.malk.server.common.McR;
|
|
|
+import com.malk.server.dingtalk.DDConf;
|
|
|
import com.malk.server.dingtalk.DDR_New;
|
|
|
-import com.malk.service.dingtalk.DDClient;
|
|
|
-import com.malk.service.dingtalk.DDClient_Group;
|
|
|
-import com.malk.service.dingtalk.DDClient_Report;
|
|
|
+import com.malk.service.dingtalk.*;
|
|
|
+import com.malk.utils.UtilHttp;
|
|
|
import com.malk.utils.UtilMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
-import com.malk.service.dingtalk.DDClient_Attendance;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -35,6 +34,8 @@ public class McDdController {
|
|
|
|
|
|
@Autowired
|
|
|
private DDClient_Attendance ddClientAttendance;
|
|
|
+ @Autowired
|
|
|
+ private DDClient_Contacts ddClient_contacts;
|
|
|
|
|
|
|
|
|
|
|
@@ -69,18 +70,45 @@ public class McDdController {
|
|
|
String accessToken = ddClient.getAccessToken();
|
|
|
List userIds = (List) param.get("userIds");
|
|
|
String checkDateFrom = param.getString("checkDateFrom")+" 00:00:00";
|
|
|
- String checkDateTo = param.getString("checkDateTo")+" 00:00:00";
|
|
|
+// 将字符串修改成时间
|
|
|
+ String checkDateTo = param.getString("checkDateTo")+" 23:59:59";
|
|
|
List<Map> results = ddClientAttendance.listAttendanceRecord(accessToken, userIds, checkDateFrom, checkDateTo);
|
|
|
log.info("获取考勤详情:{}",results);
|
|
|
Set<String> addressList = new HashSet<>();
|
|
|
String address = "";
|
|
|
for(Map result:results){
|
|
|
System.out.println("result:"+result.get("userAddress"));
|
|
|
- addressList.add(result.get("userAddress").toString()) ;
|
|
|
+// 需要对result.get("userAddress")进行判断,如果为空则不添加
|
|
|
+ if(result.get("userAddress")!=null){
|
|
|
+ addressList.add(result.get("userAddress").toString()) ;
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
System.out.println("address:"+addressList) ;
|
|
|
address = addressList.stream().collect(Collectors.joining(","));
|
|
|
return McR.success(address);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @PostMapping("/orgAccount/changeOrgAccount")
|
|
|
+ public McR changeEnterpriseAccount(@RequestBody JSONObject param){
|
|
|
+ log.info("修改企业账号:{}",param);
|
|
|
+ McException.assertParamException_Null(param,"userId","targetUserId");
|
|
|
+// 根据传过来的企业账号id查找下面的组织
|
|
|
+ String accessToken = ddClient.getAccessToken();
|
|
|
+ String userId = UtilMap.getString(param,"userId");
|
|
|
+ UtilHttp.doGet("https://api.dingtalk.com/v1.0/contact/orgAccounts/ownedOrganizations?userId="+userId,DDConf.initTokenHeader(accessToken),param);
|
|
|
+ log.info("企业账号id:{}下的组织:{}",userId);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// 没有组织直接给这个企业账号办理离职
|
|
|
+
|
|
|
+// 有组织将企业账号中所有组织转给传过来的企业账号id
|
|
|
+
|
|
|
+ return McR.success();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|