testLocal.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import cn.hutool.core.io.FileUtil;
  2. import cn.hutool.http.HttpUtil;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.malk.poc.Boot;
  5. import com.malk.server.aliwork.YDConf;
  6. import com.malk.server.aliwork.YDParam;
  7. import com.malk.service.aliwork.YDClient;
  8. import com.malk.utils.UtilMap;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.junit.Test;
  11. import org.junit.runner.RunWith;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.boot.test.context.SpringBootTest;
  14. import org.springframework.test.context.junit4.SpringRunner;
  15. import java.util.List;
  16. /**
  17. * @author floe
  18. * @date 2024/7/22 22:29
  19. */
  20. @Slf4j
  21. @SpringBootTest(classes = Boot.class)
  22. @RunWith(SpringRunner.class)
  23. public class testLocal {
  24. @Autowired
  25. private YDClient ydClient;
  26. @Test
  27. public void test(){
  28. String token="Bearer ".concat(getToken());
  29. List<String> ids= FileUtil.readLines("/home/ids.txt","utf-8");
  30. // List<String> ids= Arrays.asList("66697d643f7c5aef23f3a326###FINST-TM966BD1ISXM7XLDC9AGM4N92MDV325WL1YYLV9B","6699cef58e173e99e22d8de4###FINST-MBC668915E4NNTTUAFIFSDQZTPYT2T3WIV0ZLBF6");
  31. for (int i = 0; i < ids.size(); i++) {
  32. String result=HttpUtil.createPost("https://apigateway.awinic.com/sys/teambition/api/aiwei/do-check?taskId="+ids.get(i).split("###")[0])
  33. .header("authorization",token).execute().body();
  34. System.out.println(result);
  35. JSONObject resultObj=JSONObject.parseObject(result);
  36. if(!resultObj.getBoolean("success")){
  37. continue;
  38. }
  39. JSONObject data=resultObj.getJSONObject("data");
  40. data.remove("tableField_lqxxgj4s");
  41. data.remove("userId");
  42. ydClient.operateData(YDParam.builder().updateFormDataJson(JSONObject.toJSONString(data)).formInstanceId(ids.get(i).split("###")[1]).build()
  43. , YDConf.FORM_OPERATION.update);
  44. }
  45. }
  46. private String getToken(){
  47. String a=HttpUtil.post("https://apigateway.awinic.com/token/getToken", JSONObject.toJSONString(UtilMap.map("appKey, secret","AW394034j","RJbH7RMH3vllt4KDri303Mlw@df3434k")));
  48. System.out.println(a);
  49. return JSONObject.parseObject(a).getJSONObject("data").getString("token");
  50. }
  51. }