zoukankan      html  css  js  c++  java
  • quartzJob 例子

    KpiOfPoorQualityJob.java

    package
    com.eastcom_sw.inas.workorder.quartzJob.kpi; import net.sf.json.JSONObject; import org.apache.commons.lang3.StringUtils; import org.jfree.util.Log; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com..utils.DateUtil; import com..utils.service.quartz.QuartzService; import com..workorder.rest.service.KpiOfPoorQualityCellService; import com..workorder.rest.service.WorkorderService; @Service("kpiOfPoorQualityJob") public class KpiOfPoorQualityJob { private static String className = "com..workorder.quartzJob.kpi.KpiOfPoorQualityInvokingJob"; @Autowired private QuartzService quartzService; @Autowired private KpiOfPoorQualityCellService kpiOfPoorQualityCellService; public void execute(String jobName, String jobParames) { String status = "0"; try { String task_name = quartzService.fetchTaskNameByClass(className); System.out.println("####################:" + task_name); String desc = ""; String executeTime = DateUtil.getCurrentDatetime(); long startTime = System.currentTimeMillis(); try { String type = "type_areaIndex,type_areaAppIndex,type_areaNeIndex"; if (StringUtils.isNotBlank(jobParames) && !"null".equals(jobParames)) { JSONObject json = JSONObject.fromObject(jobParames.toLowerCase()); type = json.get("type".toLowerCase()).toString(); } kpiOfPoorQualityCellService.getKpiOfPoorQualityCell(type); desc = "实时数据保存任务执行正常"; } catch (Exception e) { e.printStackTrace(); status = "1"; desc = "实时数据保存任务执行异常"; } long endTime = System.currentTimeMillis(); long between = endTime - startTime; long s = between / 1000; String lastTime = String.valueOf(s);// 获取任务执行花费的时间 quartzService.saveQuartzLog(task_name, lastTime, executeTime, status, desc); } catch (Exception e) { e.printStackTrace(); } Log.info("--------task start--------"); } }
    package com.eastcom_sw.inas.workorder.quartzJob.kpi;
    
    import org.quartz.Job;
    import org.quartz.JobExecutionContext;
    import org.quartz.JobExecutionException;
    import org.springframework.web.context.WebApplicationContext;
    
    import com..utils.quartzInit.WebAppicationContextBean;
    
    public class KpiOfPoorQualityInvokingJob implements Job {
    
        @SuppressWarnings("rawtypes")
        @Override
        public void execute(JobExecutionContext context)
                throws JobExecutionException {
            WebAppicationContextBean wacb = new WebAppicationContextBean();        
            WebApplicationContext wac = wacb.getWebAppicationContext();
            KpiOfPoorQualityJob kpiOfPoorQualityJob = (KpiOfPoorQualityJob) wac.getBean("kpiOfPoorQualityJob");
            String jobName = context.getMergedJobDataMap().getString("targetJobName");
            Object jobP = context.getMergedJobDataMap().get("jobParames");
            String jobParames = null;
            if (jobP != null) {
                jobParames = String.valueOf(jobP);
            }
            kpiOfPoorQualityJob.execute(jobName, jobParames);
        }
    }
    KpiOfPoorQualityInvokingJob
  • 相关阅读:
    C#项目间循环引用的解决办法,有图有真相
    打破关注自己的门
    引用AForge.video.ffmpeg,打开时会报错:找不到指定的模块,需要把发行包第三方文件externalsffmpegin里的dll文件拷到windows的system32文件夹下。
    Gs_Class.Gs_DataFunction数据操作类库20160225
    Gs_Class._BaseQueryWeb查询页面基类(aspx.net)
    关于开钱箱(不是用螺丝刀子开)
    处理模糊查询时读取url地址参数变化的情况
    jeecg单步调试
    jeecg安装——mysql数据库创建+手动执行初始化脚本
    小程序动画效果
  • 原文地址:https://www.cnblogs.com/baixiuhua/p/8079069.html
Copyright © 2011-2022 走看看