干燥机配套车间生产管理系统/云平台服务端
bsw215583320
2024-04-16 c2fccb01b972176dc3da5a497b5e904025e9e98d
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
//package org.jeecg.modules.demo.cloud.xxljob;
//
//import com.xxl.job.core.biz.model.ReturnT;
//import com.xxl.job.core.handler.annotation.XxlJob;
//import lombok.extern.slf4j.Slf4j;
//import org.jeecg.common.config.mqtoken.UserTokenContext;
//import org.jeecg.common.constant.CommonConstant;
//import org.jeecg.common.system.api.ISysBaseAPI;
//import org.jeecg.common.system.util.JwtUtil;
//import org.jeecg.common.util.RedisUtil;
//import org.jeecg.common.util.SpringContextUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//
///**
// * xxl-job定时任务测试
// */
//@Slf4j
//@Component
//public class TestJobHandler {
//    @Autowired
//    ISysBaseAPI sysBaseApi;
//
//    /**
//     * 简单任务
//     *
//     * 测试:无token调用feign接口
//     *
//     * @param params
//     * @return
//     */
//
//    @XxlJob(value = "testJob")
//    public ReturnT<String> demoJobHandler(String params) {
//        //1.生成临时令牌Token到线程中
//        UserTokenContext.setToken(getTemporaryToken());
//
//        log.info("我是 jeecg-demo 服务里的定时任务 testJob , 我执行了...............................");
//        log.info("我调用 jeecg-system 服务的字典接口:{}",sysBaseApi.queryAllDict());
//        //。。。此处可以写多个feign接口调用
//
//        //2.使用完,删除临时令牌Token
//        UserTokenContext.remove();
//        return ReturnT.SUCCESS;
//    }
//
//    public void init() {
//        log.info("init");
//    }
//
//    public void destroy() {
//        log.info("destory");
//    }
//
//    /**
//     * 获取临时令牌
//     *
//     * 模拟登陆接口,获取模拟 Token
//     * @return
//     */
//    public static String getTemporaryToken() {
//        RedisUtil redisUtil = SpringContextUtils.getBean(RedisUtil.class);
//        // 模拟登录生成Token
//        String token = JwtUtil.sign("??", "??");
//        // 设置Token缓存有效时间为 5 分钟
//        redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
//        redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, 5 * 60 * 1000);
//        return token;
//    }
//
//}
//