前端定时任务

<template>
    <div class="logo">
    </div>
</template>

<script>
export default {
    name: "",
    computed: {
     
    },
    data(){
      return {
          getDdsListTimer: null,
          getDdsValidateTimer: null
      }
    },
    mounted(){
        // this.validateDdsLogin(); //初始化获取session
        // this.getDdsListTimer = setInterval(this.getDdsList, 10000);   //数据每10秒同步一次
        // this.getDdsValidateTimer = setInterval(this.validateDdsLogin, 1800000); //权限身份每半小时秒同步一次
    },
    beforeDestroy(){
        // clearInterval(this.getDdsListTimer);
        // clearInterval(this.getDdsValidateTimer);
    },
    methods: {
        async validateDdsLogin(){
            await this.$datadiscovery.get("/portal/frame/login/validate-login/manage_report?userID=VTIwMDAwMDA=&userPassword=XWIHJkvKjtkoq92BRot1Bg==").then((res) => {
                console.log("dds权限认证成功:" + JSON.stringify(res.data));
            },(err) => {
                this.$Message.danger("dds权限认证失败" + err);
            });
        },
        async getDdsList(){
            console.log("获取dds列表数据定时任务启动。")
            
            let dtwinLbael = 'LABEL84110E3B50E04FD8BAE9B4D280BA93A7'; //dts分类标签
            let listParam = "?page=0&rows=100&type=all&labelIds=" + dtwinLbael;
            
            await this.$datadiscovery.get("/report/myreport/manage/query-reps/manage_report" + listParam).then((res) => {
                // console.log(JSON.stringify(res.data));
                this.getRows = res.data.reportList.rows;
                this.insertToTwins();
            },(err) => {
                this.$Message.danger("获取dds列表数据失败" + err);
            });
        },
        async insertToTwins(){
            let paramList = [];
            for(let i = 0; i < this.getRows.length; i++){
                if(this.getRows[i].delFlag != '0' || this.getRows[i].dataDeletaFlag != '0'){
                    break;
                }

                let chart = {};
                chart.reportId = this.getRows[i].reportId;
                chart.compName = this.getRows[i].reportName;
                chart.updateTime = this.getRows[i].adminTime;
                chart.comment = this.getRows[i].reportConfig;
                chart.imgbyte = this.getRows[i].imgByte;
                paramList.push(chart);
            }

            await this.$confParmJson.post("/component/compInfo/addDtsComponent", JSON.stringify(paramList)).then((res) => {
                 console.log(res.data.message)
            },(err) => {
                this.$Message.danger("dds组件入库异常" + err);
            });

        }
    }
};
</script>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容