SampleTest.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package org.jeecg;
  2. import cn.com.ctop.common.module.entity.BindAccountLogin;
  3. import cn.com.ctop.common.module.service.IBindAccountLoginService;
  4. import cn.com.ctop.common.module.utils.CtopAdConstant;
  5. import cn.com.ctop.crawler.modules.oceanengine.entity.HotMaterial;
  6. import cn.com.ctop.crawler.modules.oceanengine.service.IHotMaterialService;
  7. import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
  8. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  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.HashMap;
  16. import java.util.List;
  17. import java.util.concurrent.CountDownLatch;
  18. import java.util.concurrent.ExecutorService;
  19. import java.util.concurrent.Executors;
  20. @RunWith(SpringRunner.class)
  21. @SpringBootTest
  22. @Slf4j
  23. public class SampleTest {
  24. @Autowired
  25. private IOceanEngineService oceanEngineService;
  26. @Autowired
  27. private IHotMaterialService hotMaterialService;
  28. @Test
  29. public void initImageUrl(){
  30. List<HotMaterial> hotMaterials = hotMaterialService.getId();
  31. if(null!=hotMaterials&&!hotMaterials.isEmpty()){
  32. hotMaterials.forEach(douyinHot -> {
  33. HotMaterial getHot = hotMaterialService.getById(douyinHot.getId());
  34. // String image = getHot.getCoverImage().replace("data:image/jpg;base64,", "");
  35. String destPath = "D:\\data\\effectCase\\";
  36. String fileName = getHot.getId()+".jpg";
  37. // EffectCase.base64ToFile(destPath,image,fileName);
  38. });
  39. }
  40. }
  41. @Test
  42. public void testOceanEngineJob(){
  43. String account="3248395570@qq.com";
  44. String password = "Ydxq-704127411";
  45. oceanEngineService.login(account,password);
  46. oceanEngineService.douyinHotHandler(1,1);
  47. oceanEngineService.effectCaseHandler(1);
  48. oceanEngineService.hotMaterialHandler(1,4,"抖音");
  49. oceanEngineService.hotMaterialHandler(1,8,"头条");
  50. oceanEngineService.hotMaterialHandler(1,1,"西瓜");
  51. oceanEngineService.hotMaterialHandler(1,3,"火山");
  52. oceanEngineService.hotMaterialHandler(1,9,"穿山甲");
  53. log.info("巨量创意抓取完成");
  54. }
  55. @Autowired
  56. private IBindAccountLoginService bindAccountLoginService;
  57. @Autowired
  58. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  59. @Test
  60. public void kuaishouLogin(){
  61. Long start =System.currentTimeMillis();
  62. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
  63. if(list!=null&&!list.isEmpty()){
  64. for (BindAccountLogin login:list) {
  65. if(null==login.getCookie()||"".equals(login.getCookie().trim())){
  66. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  67. }
  68. }
  69. }
  70. Long end = System.currentTimeMillis();
  71. log.info("总用时:{}毫秒",end-start);
  72. }
  73. static ExecutorService executorService = null;
  74. static CountDownLatch countDownLatch = null;
  75. @Test
  76. public void kuaishouCommentDelete(){
  77. Long start =System.currentTimeMillis();
  78. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
  79. if(list!=null&&!list.isEmpty()){
  80. executorService = Executors.newFixedThreadPool(10);
  81. countDownLatch = new CountDownLatch(list.size());
  82. list.forEach(login -> {
  83. executorService.submit(()->{
  84. try {
  85. if(null!=login.getCookie()&&!"".equals(login.getCookie().trim())){
  86. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login);
  87. }
  88. }catch (Exception e){
  89. }finally {
  90. countDownLatch.countDown();
  91. }
  92. });
  93. });
  94. }
  95. try {
  96. countDownLatch.await();
  97. } catch (InterruptedException e) {
  98. e.printStackTrace();
  99. }
  100. Long end = System.currentTimeMillis();
  101. log.info("总用时:{}毫秒",end-start);
  102. }
  103. @Test
  104. public void testBase64(){
  105. }
  106. }
  107. //刷新token:885936毫秒