Search in sources :

Example 31 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class SimpleService method ibatisSelectListByParams.

// ------------------------------------------------------------------------------------
@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public DefaultResult<List<E>> ibatisSelectListByParams(Map<String, Object> params) throws ServiceException, Exception {
    if (params == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    DefaultResult<List<E>> result = new DefaultResult<List<E>>();
    List<E> searchList = (List<E>) this.getBaseDataAccessObject().ibatisSelectListByParams(params);
    if (searchList != null && searchList.size() > 0) {
        result.setValue(searchList);
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) List(java.util.List) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Transactional(org.springframework.transaction.annotation.Transactional)

Example 32 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class SystemProgramLogicServiceImpl method create.

/**
	 * 產生 TB_SYS_PROG 資料
	 * 
	 * @param sys
	 * @param iconOid
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysProgVO> create(SysProgVO sysProg, String sysOid, String iconOid) throws ServiceException, Exception {
    SysVO sys = new SysVO();
    sys.setOid(sysOid);
    DefaultResult<SysVO> sysResult = this.sysService.findObjectByOid(sys);
    if (sysResult.getValue() == null) {
        throw new ServiceException(sysResult.getSystemMessage().getValue());
    }
    sys = sysResult.getValue();
    SysIconVO sysIcon = new SysIconVO();
    sysIcon.setOid(iconOid);
    DefaultResult<SysIconVO> iconResult = this.sysIconService.findObjectByOid(sysIcon);
    if (iconResult.getValue() == null) {
        throw new ServiceException(iconResult.getSystemMessage().getValue());
    }
    sysIcon = iconResult.getValue();
    sysProg.setProgSystem(sys.getSysId());
    sysProg.setIcon(sysIcon.getIconId());
    return this.sysProgService.saveObject(sysProg);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysVO(com.netsteadfast.greenstep.vo.SysVO) SysIconVO(com.netsteadfast.greenstep.vo.SysIconVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 33 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class SystemWebServiceConfigLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysWsConfigVO> update(SysWsConfigVO config, String systemOid) throws ServiceException, Exception {
    if (config == null || super.isBlank(config.getOid()) || super.isBlank(systemOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<SysWsConfigVO> oldResult = this.sysWsConfigService.findObjectByOid(config);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    SysVO sys = new SysVO();
    sys.setOid(systemOid);
    DefaultResult<SysVO> sResult = this.sysService.findObjectByOid(sys);
    if (sResult.getValue() == null) {
        throw new ServiceException(sResult.getSystemMessage().getValue());
    }
    sys = sResult.getValue();
    config.setWsId(oldResult.getValue().getWsId());
    config.setSystem(sys.getSysId());
    if (super.defaultString(config.getDescription()).length() > MAX_DESCRIPTION_LENGTH) {
        config.setDescription(config.getDescription().substring(0, MAX_DESCRIPTION_LENGTH));
    }
    return this.sysWsConfigService.updateObject(config);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysWsConfigVO(com.netsteadfast.greenstep.vo.SysWsConfigVO) SysVO(com.netsteadfast.greenstep.vo.SysVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 34 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class SystemWebServiceConfigLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysWsConfigVO> create(SysWsConfigVO config, String systemOid) throws ServiceException, Exception {
    if (config == null || super.isBlank(systemOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysVO sys = new SysVO();
    sys.setOid(systemOid);
    DefaultResult<SysVO> sResult = this.sysService.findObjectByOid(sys);
    if (sResult.getValue() == null) {
        throw new ServiceException(sResult.getSystemMessage().getValue());
    }
    sys = sResult.getValue();
    config.setSystem(sys.getSysId());
    if (super.defaultString(config.getDescription()).length() > MAX_DESCRIPTION_LENGTH) {
        config.setDescription(config.getDescription().substring(0, MAX_DESCRIPTION_LENGTH));
    }
    return this.sysWsConfigService.saveObject(config);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysVO(com.netsteadfast.greenstep.vo.SysVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.

the class ExpressionJobExecuteCallable method call.

@Override
public ExpressionJobObj call() throws Exception {
    Date beginDatetime = new Date();
    String faultMsg = "";
    String runStatus = "";
    String logStatus = "";
    @SuppressWarnings("unchecked") ISysExprJobService<SysExprJobVO, TbSysExprJob, String> sysExprJobService = (ISysExprJobService<SysExprJobVO, TbSysExprJob, String>) AppContext.getBean("core.service.SysExprJobService");
    @SuppressWarnings("unchecked") ISysExprJobLogService<SysExprJobLogVO, TbSysExprJobLog, String> sysExprJobLogService = (ISysExprJobLogService<SysExprJobLogVO, TbSysExprJobLog, String>) AppContext.getBean("core.service.SysExprJobLogService");
    try {
        logger.info("[Expression-Job] (Start) ID: " + this.jobObj.getSysExprJob().getId() + " , NAME: " + this.jobObj.getSysExprJob().getName());
        if (StringUtils.isBlank(jobObj.getSysExpression().getContent())) {
            faultMsg = "No expression content!";
            runStatus = ExpressionJobConstants.RUNSTATUS_FAULT;
            logStatus = ExpressionJobConstants.LOGSTATUS_NO_EXECUTE;
            return this.jobObj;
        }
        if (YesNo.YES.equals(this.jobObj.getSysExprJob().getCheckFault()) && ExpressionJobConstants.RUNSTATUS_FAULT.equals(this.jobObj.getSysExprJob().getRunStatus())) {
            faultMsg = "Before proccess fault, cannot execute expression job!";
            runStatus = ExpressionJobConstants.RUNSTATUS_FAULT;
            logStatus = ExpressionJobConstants.LOGSTATUS_NO_EXECUTE;
            return this.jobObj;
        }
        this.jobObj.getSysExprJob().setRunStatus(ExpressionJobConstants.RUNSTATUS_PROCESS_NOW);
        sysExprJobService.updateObject(this.jobObj.getSysExprJob());
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("jobObj", this.jobObj);
        ScriptExpressionUtils.execute(jobObj.getSysExpression().getType(), jobObj.getSysExpression().getContent(), paramMap, paramMap);
        runStatus = ExpressionJobConstants.RUNSTATUS_SUCCESS;
        logStatus = ExpressionJobConstants.LOGSTATUS_SUCCESS;
    } catch (ServiceException se) {
        faultMsg = se.getMessage().toString();
        runStatus = ExpressionJobConstants.RUNSTATUS_FAULT;
        logStatus = ExpressionJobConstants.LOGSTATUS_FAULT;
        logger.error(se.getMessage().toString());
    } catch (Exception e) {
        faultMsg = e.getMessage().toString();
        if (e.getMessage() == null) {
            faultMsg = e.toString();
        } else {
            faultMsg = e.getMessage().toString();
        }
        runStatus = ExpressionJobConstants.RUNSTATUS_FAULT;
        logStatus = ExpressionJobConstants.LOGSTATUS_FAULT;
        logger.error(faultMsg);
    } finally {
        if (faultMsg.length() > 2000) {
            faultMsg = faultMsg.substring(0, 2000);
        }
        jobObj.getSysExprJob().setRunStatus(runStatus);
        jobObj.getSysExprJobLog().setFaultMsg(faultMsg);
        jobObj.getSysExprJobLog().setLogStatus(logStatus);
        jobObj.getSysExprJobLog().setId(jobObj.getSysExprJob().getId());
        jobObj.getSysExprJobLog().setBeginDatetime(beginDatetime);
        jobObj.getSysExprJobLog().setEndDatetime(new Date());
        sysExprJobService.updateObject(this.jobObj.getSysExprJob());
        DefaultResult<SysExprJobLogVO> jobLogResult = sysExprJobLogService.saveObject(jobObj.getSysExprJobLog());
        if (jobLogResult.getValue() != null) {
            jobObj.setSysExprJobLog(jobLogResult.getValue());
        }
        this.sendMail();
        logger.info("[Expression-Job] (End) ID: " + this.jobObj.getSysExprJob().getId() + " , NAME: " + this.jobObj.getSysExprJob().getName());
    }
    return this.jobObj;
}
Also used : ISysExprJobLogService(com.netsteadfast.greenstep.service.ISysExprJobLogService) SysExprJobVO(com.netsteadfast.greenstep.vo.SysExprJobVO) HashMap(java.util.HashMap) Date(java.util.Date) SysExprJobLogVO(com.netsteadfast.greenstep.vo.SysExprJobLogVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) TbSysExprJob(com.netsteadfast.greenstep.po.hbm.TbSysExprJob) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) TbSysExprJobLog(com.netsteadfast.greenstep.po.hbm.TbSysExprJobLog) ISysExprJobService(com.netsteadfast.greenstep.service.ISysExprJobService)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)291 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)91 Transactional (org.springframework.transaction.annotation.Transactional)89 HashMap (java.util.HashMap)65 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)49 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)48 SysVO (com.netsteadfast.greenstep.vo.SysVO)30 IOException (java.io.IOException)24 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)20 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)19 List (java.util.List)19 Map (java.util.Map)19 ArrayList (java.util.ArrayList)17 LinkedHashMap (java.util.LinkedHashMap)17 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)16 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)15 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)15 SysUploadVO (com.netsteadfast.greenstep.vo.SysUploadVO)14 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)13 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)12