Search in sources :

Example 1 with TbSysExpression

use of com.netsteadfast.greenstep.po.hbm.TbSysExpression in project bamboobsc by billchen198318.

the class SystemExpressionJobUtils method getExpressionJobs.

public static List<ExpressionJobObj> getExpressionJobs() throws ServiceException, Exception {
    int year = Integer.parseInt(SimpleUtils.getStrYMD(SimpleUtils.IS_YEAR));
    int month = Integer.parseInt(SimpleUtils.getStrYMD(SimpleUtils.IS_MONTH));
    String dayOfWeek = String.valueOf(SimpleUtils.getDayOfWeek(year, month));
    String hour = String.valueOf(LocalDateTime.now().getHourOfDay());
    String minute = String.valueOf(LocalDateTime.now().getMinuteOfHour());
    List<ExpressionJobObj> jobObjList = new ArrayList<ExpressionJobObj>();
    @SuppressWarnings("unchecked") ISysExprJobService<SysExprJobVO, TbSysExprJob, String> sysExprJobService = (ISysExprJobService<SysExprJobVO, TbSysExprJob, String>) AppContext.getBean("core.service.SysExprJobService");
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("system", Constants.getSystem());
    paramMap.put("active", YesNo.YES);
    List<SysExprJobVO> exprJobList = sysExprJobService.findListVOByParams(paramMap);
    if (null == exprJobList || exprJobList.size() < 1) {
        return jobObjList;
    }
    @SuppressWarnings("unchecked") ISysExpressionService<SysExpressionVO, TbSysExpression, String> sysExpressionService = (ISysExpressionService<SysExpressionVO, TbSysExpression, String>) AppContext.getBean("core.service.SysExpressionService");
    for (SysExprJobVO exprJob : exprJobList) {
        if (ExpressionJobConstants.RUNSTATUS_PROCESS_NOW.equals(exprJob.getRunStatus())) {
            log.warn("[Expression-Job] Please check it, process now, Id: " + exprJob.getExprId() + " , name: " + exprJob.getName());
            continue;
        }
        if (!isRunTime(exprJob, dayOfWeek, hour, minute)) {
            continue;
        }
        ExpressionJobObj jobObj = new ExpressionJobObj();
        jobObj.setSysExprJob(exprJob);
        jobObj.setSysExprJobLog(new SysExprJobLogVO());
        SysExpressionVO expr = new SysExpressionVO();
        expr.setExprId(exprJob.getExprId());
        DefaultResult<SysExpressionVO> exprResult = sysExpressionService.findByUK(expr);
        if (exprResult.getValue() == null) {
            log.error("[Expression-Job] Id: " + exprJob.getExprId() + " , data not found.");
            log.error(exprResult.getSystemMessage().getValue());
            continue;
        }
        expr = exprResult.getValue();
        jobObj.setSysExpression(expr);
        jobObjList.add(jobObj);
    }
    return jobObjList;
}
Also used : SysExprJobVO(com.netsteadfast.greenstep.vo.SysExprJobVO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SysExprJobLogVO(com.netsteadfast.greenstep.vo.SysExprJobLogVO) ISysExpressionService(com.netsteadfast.greenstep.service.ISysExpressionService) TbSysExprJob(com.netsteadfast.greenstep.po.hbm.TbSysExprJob) TbSysExpression(com.netsteadfast.greenstep.po.hbm.TbSysExpression) ISysExprJobService(com.netsteadfast.greenstep.service.ISysExprJobService) ExpressionJobObj(com.netsteadfast.greenstep.model.ExpressionJobObj) SysExpressionVO(com.netsteadfast.greenstep.vo.SysExpressionVO)

Example 2 with TbSysExpression

use of com.netsteadfast.greenstep.po.hbm.TbSysExpression in project bamboobsc by billchen198318.

the class SystemExpressionJobUtils method getExpressionJobForManualMode.

public static ExpressionJobObj getExpressionJobForManualMode(String expressionJobOid) throws ServiceException, Exception {
    if (StringUtils.isBlank(expressionJobOid)) {
        throw new Exception("error, expressionJobId is blank!");
    }
    @SuppressWarnings("unchecked") ISysExprJobService<SysExprJobVO, TbSysExprJob, String> sysExprJobService = (ISysExprJobService<SysExprJobVO, TbSysExprJob, String>) AppContext.getBean("core.service.SysExprJobService");
    @SuppressWarnings("unchecked") ISysExpressionService<SysExpressionVO, TbSysExpression, String> sysExpressionService = (ISysExpressionService<SysExpressionVO, TbSysExpression, String>) AppContext.getBean("core.service.SysExpressionService");
    SysExprJobVO exprJob = new SysExprJobVO();
    exprJob.setOid(expressionJobOid);
    DefaultResult<SysExprJobVO> exprJobResult = sysExprJobService.findObjectByOid(exprJob);
    if (exprJobResult.getValue() == null) {
        throw new ServiceException(exprJobResult.getSystemMessage().getValue());
    }
    exprJob = exprJobResult.getValue();
    SysExpressionVO expr = new SysExpressionVO();
    expr.setExprId(exprJob.getExprId());
    DefaultResult<SysExpressionVO> exprResult = sysExpressionService.findByUK(expr);
    if (exprResult.getValue() == null) {
        throw new ServiceException(exprResult.getSystemMessage().getValue());
    }
    expr = exprResult.getValue();
    ExpressionJobObj jobObj = new ExpressionJobObj();
    jobObj.setSysExprJob(exprJob);
    jobObj.setSysExprJobLog(new SysExprJobLogVO());
    jobObj.setSysExpression(expr);
    return jobObj;
}
Also used : SysExprJobVO(com.netsteadfast.greenstep.vo.SysExprJobVO) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysExprJobLogVO(com.netsteadfast.greenstep.vo.SysExprJobLogVO) ISysExpressionService(com.netsteadfast.greenstep.service.ISysExpressionService) TbSysExprJob(com.netsteadfast.greenstep.po.hbm.TbSysExprJob) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) TbSysExpression(com.netsteadfast.greenstep.po.hbm.TbSysExpression) ISysExprJobService(com.netsteadfast.greenstep.service.ISysExprJobService) ExpressionJobObj(com.netsteadfast.greenstep.model.ExpressionJobObj) SysExpressionVO(com.netsteadfast.greenstep.vo.SysExpressionVO)

Aggregations

ExpressionJobObj (com.netsteadfast.greenstep.model.ExpressionJobObj)2 TbSysExprJob (com.netsteadfast.greenstep.po.hbm.TbSysExprJob)2 TbSysExpression (com.netsteadfast.greenstep.po.hbm.TbSysExpression)2 ISysExprJobService (com.netsteadfast.greenstep.service.ISysExprJobService)2 ISysExpressionService (com.netsteadfast.greenstep.service.ISysExpressionService)2 SysExprJobLogVO (com.netsteadfast.greenstep.vo.SysExprJobLogVO)2 SysExprJobVO (com.netsteadfast.greenstep.vo.SysExprJobVO)2 SysExpressionVO (com.netsteadfast.greenstep.vo.SysExpressionVO)2 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1