|
@@ -1,9 +1,12 @@
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.malk.hangshi.Boot;
|
|
import com.malk.hangshi.Boot;
|
|
|
import com.malk.hangshi.service.Impl.PayServiceImpl;
|
|
import com.malk.hangshi.service.Impl.PayServiceImpl;
|
|
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
import com.malk.server.dingtalk.DDConf;
|
|
import com.malk.server.dingtalk.DDConf;
|
|
|
-import com.malk.service.dingtalk.DDClient;
|
|
|
|
|
-import com.malk.service.dingtalk.DDClient_Event;
|
|
|
|
|
-import com.malk.service.dingtalk.DDClient_Workflow;
|
|
|
|
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
|
|
+import com.malk.service.dingtalk.*;
|
|
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
@@ -12,7 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@RunWith(SpringRunner.class)
|
|
@RunWith(SpringRunner.class)
|
|
@@ -33,11 +36,56 @@ public class test {
|
|
|
private String APP_EKY;
|
|
private String APP_EKY;
|
|
|
@Value("${dingtalk.appSecret}")
|
|
@Value("${dingtalk.appSecret}")
|
|
|
private String APP_SECRET;
|
|
private String APP_SECRET;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private YDClient ydClient;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient_Contacts ddClient_contacts;
|
|
|
|
|
+
|
|
|
@Test
|
|
@Test
|
|
|
public void sonUpdateTest(){
|
|
public void sonUpdateTest(){
|
|
|
|
|
|
|
|
- Map processData = ddClient_workflow.getProcessInstanceId(ddClient.getAccessToken(APP_EKY, APP_SECRET), "Zd7HDIdGTkiGFFtsoHkg3A03891763390051");
|
|
|
|
|
|
|
+// Map processData = ddClient_workflow.getProcessInstanceId(ddClient.getAccessToken(APP_EKY, APP_SECRET), "Zd7HDIdGTkiGFFtsoHkg3A03891763390051");
|
|
|
|
|
+//
|
|
|
|
|
+// System.out.println(processData);
|
|
|
|
|
+
|
|
|
|
|
+ syncDept(98531089,false);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- System.out.println(processData);
|
|
|
|
|
|
|
+ public void syncDept(long deptId,boolean isNeedKS){
|
|
|
|
|
+ List<Map> list = ddClient_contacts.listSubDepartmentDetail(ddClient.getAccessToken(), deptId);
|
|
|
|
|
+ for (Map map : list) {
|
|
|
|
|
+ System.out.println(map.toString());
|
|
|
|
|
+ long subDeptId = UtilMap.getLong(map,"dept_id");
|
|
|
|
|
+ String subDeptName = UtilMap.getString(map,"name");
|
|
|
|
|
+ String selectField_mjgj9non = "班组";
|
|
|
|
|
+ Map formData=new HashMap();
|
|
|
|
|
+ if(isNeedKS){
|
|
|
|
|
+ syncDept(subDeptId,false);
|
|
|
|
|
+ selectField_mjgj9non = "室";
|
|
|
|
|
+ }else {
|
|
|
|
|
+ formData.put("radioField_mke10pcc",subDeptName.contains("外包")?"外包":"班组");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> strings = ddClient_contacts.listDepartmentUserId(ddClient.getAccessToken(), subDeptId);
|
|
|
|
|
+ List<String> admins =new ArrayList<>();
|
|
|
|
|
+ for(String string : strings){
|
|
|
|
|
+ Map userInfo = ddClient_contacts.getUserInfoById(ddClient.getAccessToken(), string);
|
|
|
|
|
+ List<Map> leader_in_dept = UtilMap.getList(userInfo,"leader_in_dept");
|
|
|
|
|
+ for(Map leader : leader_in_dept){
|
|
|
|
|
+ if(UtilMap.getString(leader,"dept_id").equals(String.valueOf(subDeptId))&&UtilMap.getBoolean(leader,"leader")){
|
|
|
|
|
+ admins.add(string);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ formData.put("selectField_mjgj9non",selectField_mjgj9non);
|
|
|
|
|
+ formData.put("employeeField_mjgj9noh",admins);
|
|
|
|
|
+ formData.put("departmentSelectField_mjgj9noi", Arrays.asList(String.valueOf(subDeptId)));
|
|
|
|
|
+ formData.put("departmentSelectField_mjgqcjsw",Arrays.asList(String.valueOf(deptId)));
|
|
|
|
|
+ formData.put("radioField_mjgsdrat","开启");
|
|
|
|
|
+ System.out.println(formData.toString());
|
|
|
|
|
+ ydClient.operateData(YDParam.builder().appType("APP_PG9VWQVT23CRFBOOOG6Y")
|
|
|
|
|
+ .systemToken("73D66971EQO1KI40NT9M96FHV3BK3CZNBQGJMWX1").formUuid("FORM-651D1713A25E423FB4EC1A5A06A7A741QWEY").formDataJson(JSONObject.toJSONString(formData)).build(), YDConf.FORM_OPERATION.create);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|