1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package com.example.xiaoshiweixinback;
- import com.example.xiaoshiweixinback.service.common.EsDenseVectorService;
- import org.junit.jupiter.api.Test;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.context.annotation.Lazy;
- import java.text.SimpleDateFormat;
- import java.time.LocalDateTime;
- import java.time.format.DateTimeFormatter;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.List;
- @SpringBootTest
- class XiaoshiWeixinbackApplicationTests {
- @Autowired
- @Lazy
- private EsDenseVectorService denseVectorService;
- @Test
- void contextLoads() {
- }
- @Test
- public void test() throws Exception {
- // List<EsPictureVectorVo> list = denseVectorService.getPatentVectorSort(null, "大大的原型");
- // EsPatentSearchDTO dto = new EsPatentSearchDTO();
- // dto.setKey("手机 OR 产品");
- // Records records = denseVectorService.getPatentList(dto);
- // List<EsPictureVectorVo> list = JSON.parseArray(records.getData().toString(), EsPictureVectorVo.class);
- // System.out.println(list);
- // String s = "a , b , c , d";
- // boolean regExpReplace = RegexUtil.isRegExpReplace(s);
- // System.out.println(regExpReplace);
- // String all = s.replaceAll("[,。、;,./;]", " OR ");
- // System.out.println(all);
- // String s = "a OR b OR c OR d";
- // boolean regExpReplace = RegexUtil.isRegExpReplace(s);
- // System.out.println(regExpReplace);
- // String sa = s.replaceAll("[,。、;,./;\\s]", " OR ");
- // System.out.println(sa);
- // StpUtil.login("2");
- // Object id = StpUtil.getLoginId();
- // String tokenValue = StpUtil.getTokenValue();
- // String value = StpUtil.getTokenValueByLoginId(2);
- // System.out.println(tokenValue);
- // System.out.println(value);
- SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
- SimpleDateFormat format1 = new SimpleDateFormat("yyyy");
- Date now = new Date();
- String nowFormat = format.format(now);
- System.out.println(nowFormat);
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(now);
- calendar.add(Calendar.YEAR, -3);
- Date beforeDate = calendar.getTime();
- String threeYearsAgo = format1.format(beforeDate) + "0101";
- System.out.println(threeYearsAgo);
- }
- @Test
- public void test1() {
- // 获取当前时间
- LocalDateTime now = LocalDateTime.now();
- now.format(DateTimeFormatter.ISO_DATE);
- // 减去三年
- LocalDateTime threeYearsAgo = now.minusYears(3);
- // 打印结果
- System.out.println("当前时间: " + now);
- System.out.println("三年前的时间: " + threeYearsAgo);
- }
- }
|