package cn.exrick.xboot.base.controller.common; import cn.exrick.xboot.base.entity.Dict; import cn.exrick.xboot.base.entity.DictData; import cn.exrick.xboot.base.service.DictDataService; import cn.exrick.xboot.base.service.DictService; import cn.hutool.http.HttpRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.List; //测试 @Component public class TestImpl { @Autowired private DictService dictService; @Autowired private DictDataService dictDataService; @Scheduled(cron="0 0/3 * * * ?") //@Scheduled(cron="0 * * * * ?") public void execute(){ Dict shouQuan = dictService.findByType("shouQuan"); if(shouQuan==null){ return; } List byDictId = dictDataService.findByDictId(shouQuan.getId()); String token =""; String cookie=""; String url2=""; for(DictData dictData:byDictId){ if(dictData.getTitle().equals("token")){ token = dictData.getValue(); } if(dictData.getTitle().equals("cookie")){ cookie = dictData.getValue(); } if(dictData.getTitle().equals("url")){ url2 = dictData.getValue(); } } //String url = "https://111.63.178.115:1443/msa-web/multimedia/findPicturesByAlarmId.do?alarmId=1234567_01_20220119083014_01_81&alarmTime=2022-01-19T08%3A30%3A14.000%2B08%3A00"; try { HttpRequest cookie2 = HttpRequest.get(url2).header("X-CSRF-TOKEN", token).header("Cookie", cookie); String body = cookie2.execute().body(); System.out.println(body.substring(0,25)); }catch (Exception e){ System.out.println("error"); } } }