wjli
2023-05-16 d8e76c8e094c2312284b5dc7b4207d049f27262b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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<DictData> 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");
        }
 
    }
}