ApplicationTest.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //package com.simuwang;
  2. //import cn.hutool.core.collection.ListUtil;
  3. //import cn.hutool.core.date.DateUtil;
  4. //import com.simuwang.base.common.conts.DateConst;
  5. //import com.simuwang.base.pojo.dto.MailboxInfoDTO;
  6. //import com.simuwang.daq.service.EmailParseApiService;
  7. //import com.simuwang.daq.service.EmailParseService;
  8. //import org.jasypt.util.text.BasicTextEncryptor;
  9. //import org.junit.jupiter.api.Test;
  10. //import org.springframework.beans.factory.annotation.Autowired;
  11. //import org.springframework.boot.test.context.SpringBootTest;
  12. //import java.io.File;
  13. //import java.util.*;
  14. //import java.util.List;
  15. //import java.util.regex.Matcher;
  16. //import java.util.regex.Pattern;
  17. //
  18. //
  19. //@SpringBootTest(classes = Application.class)
  20. //public class ApplicationTest {
  21. //
  22. // @Autowired
  23. // private EmailParseService emailParseService;
  24. //
  25. // @Autowired
  26. // private EmailParseApiService emailParseApiService;
  27. //
  28. // @Test
  29. // public void test() {
  30. // MailboxInfoDTO emailInfoDTO = this.buildMailbox("", "");
  31. ////
  32. //// emailInfoDTO.setAccount("jjpj_test");
  33. //// emailInfoDTO.setPassword("shzq#919");
  34. //// emailInfoDTO.setHost("mail.shzq.com");
  35. //// emailInfoDTO.setPort("993");
  36. //// emailInfoDTO.setProtocol("imap");
  37. //
  38. // Date startDate = DateUtil.parse("2024-10-10 15:00:00", DateConst.YYYY_MM_DD_HH_MM_SS);
  39. // Date endDate = DateUtil.parse("2024-10-10 16:40:00", DateConst.YYYY_MM_DD_HH_MM_SS);
  40. // try {
  41. // emailParseService.parseEmail(emailInfoDTO, startDate, endDate);
  42. // } catch (Exception e) {
  43. // throw new RuntimeException(e);
  44. // }
  45. // }
  46. //
  47. // @Test
  48. // public void reportTest() {
  49. // MailboxInfoDTO emailInfoDTO = this.buildMailbox("x", "x");
  50. // Date startDate = DateUtil.parse("2024-10-15 15:10:30", DateConst.YYYY_MM_DD_HH_MM_SS);
  51. // Date endDate = DateUtil.parse("2024-10-15 17:50:30", DateConst.YYYY_MM_DD_HH_MM_SS);
  52. // try {
  53. // emailParseService.parseEmail(emailInfoDTO, startDate, endDate);
  54. // } catch (Exception e) {
  55. // throw new RuntimeException(e);
  56. // }
  57. // }
  58. //
  59. // @Test
  60. // public void testReparseEmail() {
  61. // String regexp = ".*_(.*?基金).*";
  62. // String fileName = "排排网净值及季报补充20230425_分红公告_半年添利多策略1号_璞远半年添利多策略1号私募证券投资基金_20210913_分红公告.pdf";
  63. // Pattern pattern = Pattern.compile(regexp);
  64. // Matcher matcher = pattern.matcher(fileName);
  65. // if(matcher.find()){
  66. // System.out.println(matcher.group(1));
  67. // }
  68. // }
  69. //
  70. // @Test
  71. // public void testReparseFile() {
  72. // emailParseApiService.reparseFile(ListUtil.toList(40, 43));
  73. // }
  74. //
  75. // @Test
  76. // public void testDateFormat() {
  77. // String input = "Smppw@2024";
  78. // BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
  79. // textEncryptor.setPassword("qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm12"); // 用您自己的密钥替换"yourSecretKey"
  80. // String encryptedString = textEncryptor.encrypt(input);
  81. // String decrypt = textEncryptor.decrypt(encryptedString);
  82. // System.out.println("加密后的字符串为: " + encryptedString);
  83. // System.out.println("解密后的字符串为: " + decrypt);
  84. // }
  85. //
  86. // private MailboxInfoDTO buildMailbox(String account, String pwd) {
  87. // MailboxInfoDTO emailInfoDTO = new MailboxInfoDTO();
  88. // emailInfoDTO.setUserId(1);
  89. // emailInfoDTO.setAccount(account);
  90. // emailInfoDTO.setPassword(pwd);
  91. // emailInfoDTO.setHost("imap.exmail.qq.com");
  92. // emailInfoDTO.setPort("993");
  93. // emailInfoDTO.setProtocol("imap");
  94. // return emailInfoDTO;
  95. // }
  96. //
  97. //
  98. // /**
  99. // * 得到文件名称
  100. // *
  101. // * @param path 路径
  102. // * @return {@link List}<{@link String}>
  103. // */
  104. // private static List<String> getFileNames(String path) {
  105. // File file = new File(path);
  106. // if (!file.exists()) {
  107. // return null;
  108. // }
  109. // List<String> fileNames = new ArrayList<>();
  110. // return getFileNames(file, fileNames);
  111. // }
  112. //
  113. // /**
  114. // * 得到文件名称
  115. // *
  116. // * @param file 文件
  117. // * @param fileNames 文件名
  118. // * @return {@link List}<{@link String}>
  119. // */
  120. // private static List<String> getFileNames(File file, List<String> fileNames) {
  121. // File[] files = file.listFiles();
  122. // for (File f : files) {
  123. // if (f.isDirectory()) {
  124. // getFileNames(f, fileNames);
  125. // } else {
  126. // fileNames.add(f.getName());
  127. // }
  128. // }
  129. // return fileNames;
  130. // }
  131. //
  132. // public static int getPercent2(float h, float w) {
  133. // int p = 0;
  134. // float p2 = 0.0f;
  135. // p2 = 450 / w * 100;
  136. // p = Math.round(p2);
  137. // return p;
  138. // }
  139. //}