XiaoshiWeixinbackApplicationTests.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package com.example.xiaoshiweixinback;
  2. import com.example.xiaoshiweixinback.service.common.EsDenseVectorService;
  3. import org.junit.jupiter.api.Test;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.boot.test.context.SpringBootTest;
  6. import org.springframework.context.annotation.Lazy;
  7. import java.text.SimpleDateFormat;
  8. import java.time.LocalDateTime;
  9. import java.time.format.DateTimeFormatter;
  10. import java.util.Calendar;
  11. import java.util.Date;
  12. import java.util.List;
  13. @SpringBootTest
  14. class XiaoshiWeixinbackApplicationTests {
  15. @Autowired
  16. @Lazy
  17. private EsDenseVectorService denseVectorService;
  18. @Test
  19. void contextLoads() {
  20. }
  21. @Test
  22. public void test() throws Exception {
  23. // List<EsPictureVectorVo> list = denseVectorService.getPatentVectorSort(null, "大大的原型");
  24. // EsPatentSearchDTO dto = new EsPatentSearchDTO();
  25. // dto.setKey("手机 OR 产品");
  26. // Records records = denseVectorService.getPatentList(dto);
  27. // List<EsPictureVectorVo> list = JSON.parseArray(records.getData().toString(), EsPictureVectorVo.class);
  28. // System.out.println(list);
  29. // String s = "a , b , c , d";
  30. // boolean regExpReplace = RegexUtil.isRegExpReplace(s);
  31. // System.out.println(regExpReplace);
  32. // String all = s.replaceAll("[,。、;,./;]", " OR ");
  33. // System.out.println(all);
  34. // String s = "a OR b OR c OR d";
  35. // boolean regExpReplace = RegexUtil.isRegExpReplace(s);
  36. // System.out.println(regExpReplace);
  37. // String sa = s.replaceAll("[,。、;,./;\\s]", " OR ");
  38. // System.out.println(sa);
  39. // StpUtil.login("2");
  40. // Object id = StpUtil.getLoginId();
  41. // String tokenValue = StpUtil.getTokenValue();
  42. // String value = StpUtil.getTokenValueByLoginId(2);
  43. // System.out.println(tokenValue);
  44. // System.out.println(value);
  45. SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
  46. SimpleDateFormat format1 = new SimpleDateFormat("yyyy");
  47. Date now = new Date();
  48. String nowFormat = format.format(now);
  49. System.out.println(nowFormat);
  50. Calendar calendar = Calendar.getInstance();
  51. calendar.setTime(now);
  52. calendar.add(Calendar.YEAR, -3);
  53. Date beforeDate = calendar.getTime();
  54. String threeYearsAgo = format1.format(beforeDate) + "0101";
  55. System.out.println(threeYearsAgo);
  56. }
  57. @Test
  58. public void test1() {
  59. // 获取当前时间
  60. LocalDateTime now = LocalDateTime.now();
  61. now.format(DateTimeFormatter.ISO_DATE);
  62. // 减去三年
  63. LocalDateTime threeYearsAgo = now.minusYears(3);
  64. // 打印结果
  65. System.out.println("当前时间: " + now);
  66. System.out.println("三年前的时间: " + threeYearsAgo);
  67. }
  68. }