Search in sources :

Example 1 with SysExpressionVO

use of com.netsteadfast.greenstep.vo.SysExpressionVO 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 SysExpressionVO

use of com.netsteadfast.greenstep.vo.SysExpressionVO in project bamboobsc by billchen198318.

the class ServiceScriptExpressionUtils method process.

private static void process(String runType, String beanId, Method method, String system, Object resultObj, ProceedingJoinPoint pjp) throws ServiceException, Exception {
    SysBeanHelpVO beanHelp = loadSysBeanHelperData(beanId, method.getName(), system);
    if (!YesNo.YES.equals(beanHelp.getEnableFlag())) {
        return;
    }
    List<TbSysBeanHelpExpr> beanHelpExprs = loadSysBeanHelpExprsData(beanHelp);
    if (beanHelpExprs == null || beanHelpExprs.size() < 1) {
        return;
    }
    for (TbSysBeanHelpExpr helpExpr : beanHelpExprs) {
        SysExpressionVO expression = new SysExpressionVO();
        expression.setExprId(helpExpr.getExprId());
        DefaultResult<SysExpressionVO> eResult = sysExpressionService.findByUK(expression);
        if (eResult.getValue() == null) {
            continue;
        }
        expression = eResult.getValue();
        List<TbSysBeanHelpExprMap> exprMaps = loadSysBeanHelpExprMapsData(helpExpr);
        /* 2015-04-14 rem
			try {
				ScriptExpressionUtils.execute(
						expression.getType(), 
						expression.getContent(), 
						null, 
						getParameters(helpExpr, exprMaps, resultObj, pjp));						
			} catch (Exception e) {
				e.printStackTrace();
			}	
			*/
        // 不要 try catch 包起來, 讓外面也能接到 Exception 
        ScriptExpressionUtils.execute(expression.getType(), expression.getContent(), null, getParameters(helpExpr, exprMaps, resultObj, pjp));
    }
}
Also used : TbSysBeanHelpExprMap(com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap) SysBeanHelpVO(com.netsteadfast.greenstep.vo.SysBeanHelpVO) TbSysBeanHelpExpr(com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExpr) SysExpressionVO(com.netsteadfast.greenstep.vo.SysExpressionVO)

Example 3 with SysExpressionVO

use of com.netsteadfast.greenstep.vo.SysExpressionVO in project bamboobsc by billchen198318.

the class SystemExpressionLogicServiceImpl method createJob.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysExprJobVO> createJob(SysExprJobVO exprJob, String systemOid, String expressionOid) throws ServiceException, Exception {
    if (exprJob == null || super.isBlank(systemOid) || super.isBlank(expressionOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysVO sys = new SysVO();
    sys.setOid(systemOid);
    DefaultResult<SysVO> sysResult = this.sysService.findObjectByOid(sys);
    if (sysResult.getValue() == null) {
        throw new ServiceException(sysResult.getSystemMessage().getValue());
    }
    sys = sysResult.getValue();
    SysExpressionVO expression = new SysExpressionVO();
    expression.setOid(expressionOid);
    DefaultResult<SysExpressionVO> expressionResult = this.sysExpressionService.findObjectByOid(expression);
    if (expressionResult.getValue() == null) {
        throw new ServiceException(expressionResult.getSystemMessage().getValue());
    }
    expression = expressionResult.getValue();
    exprJob.setSystem(sys.getSysId());
    exprJob.setExprId(expression.getExprId());
    // 預設值
    exprJob.setRunStatus(ExpressionJobConstants.RUNSTATUS_SUCCESS);
    this.setStringValueMaxLength(exprJob, "description", MAX_DESCRIPTION_LENGTH);
    return this.sysExprJobService.saveObject(exprJob);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysVO(com.netsteadfast.greenstep.vo.SysVO) SysExpressionVO(com.netsteadfast.greenstep.vo.SysExpressionVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with SysExpressionVO

use of com.netsteadfast.greenstep.vo.SysExpressionVO in project bamboobsc by billchen198318.

the class SystemExpressionSaveOrUpdateAction method copy2Upload.

private void copy2Upload() throws ControllerException, AuthorityException, ServiceException, Exception {
    SysExpressionVO expression = new SysExpressionVO();
    this.transformFields2ValueObject(expression, new String[] { "oid" });
    DefaultResult<SysExpressionVO> result = this.sysExpressionService.findObjectByOid(expression);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    expression = result.getValue();
    this.uploadOid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, expression.getContent().getBytes(), expression.getExprId() + "." + expression.getType());
    this.message = SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS);
    this.success = IS_YES;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysExpressionVO(com.netsteadfast.greenstep.vo.SysExpressionVO)

Example 5 with SysExpressionVO

use of com.netsteadfast.greenstep.vo.SysExpressionVO in project bamboobsc by billchen198318.

the class SystemExpressionSaveOrUpdateAction method save.

private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    SysExpressionVO expression = new SysExpressionVO();
    this.transformFields2ValueObject(expression, new String[] { "exprId", "type", "name", "content", "description" });
    DefaultResult<SysExpressionVO> result = this.systemExpressionLogicService.create(expression);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null) {
        this.success = IS_YES;
    }
}
Also used : SysExpressionVO(com.netsteadfast.greenstep.vo.SysExpressionVO)

Aggregations

SysExpressionVO (com.netsteadfast.greenstep.vo.SysExpressionVO)19 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)8 HashMap (java.util.HashMap)6 SysExprJobVO (com.netsteadfast.greenstep.vo.SysExprJobVO)4 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)3 SysVO (com.netsteadfast.greenstep.vo.SysVO)3 Transactional (org.springframework.transaction.annotation.Transactional)3 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 SysBeanHelpVO (com.netsteadfast.greenstep.vo.SysBeanHelpVO)2 SysExprJobLogVO (com.netsteadfast.greenstep.vo.SysExprJobLogVO)2 LinkedHashMap (java.util.LinkedHashMap)2 TbSysBeanHelpExpr (com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExpr)1 TbSysBeanHelpExprMap (com.netsteadfast.greenstep.po.hbm.TbSysBeanHelpExprMap)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1