Search in sources :

Example 36 with ServiceException

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

the class SystemCalendarNoteLogicServiceImpl method createMailHelper.

private void createMailHelper(SysCalendarNoteVO note) {
    if (null == note || super.isBlank(note.getOid())) {
        return;
    }
    if (!YesNo.YES.equals(note.getAlert())) {
        return;
    }
    if (super.isBlank(note.getContact())) {
        return;
    }
    String[] receiveMail = note.getContact().trim().split(Constants.ID_DELIMITER);
    String mailId = SimpleUtils.getStrYMD("");
    for (String toMail : receiveMail) {
        try {
            TemplateResultObj result = TemplateUtils.getResult(TemplateCode.TPLMSG0001, note);
            String content = result.getContent();
            if (StringUtils.isBlank(content)) {
                content = note.getNote();
            }
            SysMailHelperVO mailHelper = new SysMailHelperVO();
            mailHelper.setMailId(this.sysMailHelperService.findForMaxMailIdComplete(mailId));
            mailHelper.setMailFrom(MailClientUtils.getDefaultFrom());
            mailHelper.setMailTo(toMail);
            mailHelper.setSubject(note.getTitle());
            mailHelper.setText(content.getBytes("utf8"));
            mailHelper.setRetainFlag(YesNo.NO);
            mailHelper.setSuccessFlag(YesNo.NO);
            this.sysMailHelperService.saveObject(mailHelper);
        } catch (ServiceException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) TemplateResultObj(com.netsteadfast.greenstep.model.TemplateResultObj) SysMailHelperVO(com.netsteadfast.greenstep.vo.SysMailHelperVO) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 37 with ServiceException

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

the class SystemContextBeanLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysCtxBeanVO> create(SysCtxBeanVO ctxBean, String systemOid) throws ServiceException, Exception {
    if (ctxBean == 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();
    ctxBean.setSystem(sys.getSysId());
    if (super.defaultString(ctxBean.getDescription()).length() > MAX_DESCRIPTION_LENGTH) {
        ctxBean.setDescription(ctxBean.getDescription().substring(0, MAX_DESCRIPTION_LENGTH));
    }
    return this.sysCxtBeanService.saveObject(ctxBean);
}
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 38 with ServiceException

use of com.netsteadfast.greenstep.base.exception.ServiceException 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 39 with ServiceException

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

the class SystemMenuLogicServiceImpl method createOrUpdate.

/**
	 * 更新或是新增 TB_SYS_MENU 資料
	 * 
	 * @param folderProgramOid
	 * @param childProgramOidList
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> createOrUpdate(String folderProgramOid, List<String> childProgramOidList) throws ServiceException, Exception {
    if (StringUtils.isBlank(folderProgramOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(false);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    // 找 TB_SYS_PROG 資料
    SysProgVO sysProg = new SysProgVO();
    sysProg.setOid(folderProgramOid);
    DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
    if (spResult.getValue() == null) {
        throw new ServiceException(spResult.getSystemMessage().getValue());
    }
    sysProg = spResult.getValue();
    // 找出 TB_SYS_MENU 原資料 , 沒有資料就是新增
    SysMenuVO sysMenu = new SysMenuVO();
    sysMenu.setProgId(sysProg.getProgId());
    sysMenu.setParentOid(ZeroKeyProvide.OID_KEY);
    if (this.sysMenuService.countByUK(sysMenu) > 0) {
        // update 更新
        DefaultResult<SysMenuVO> smResult = this.sysMenuService.findByUK(sysMenu);
        if (smResult.getValue() == null) {
            throw new ServiceException(smResult.getSystemMessage().getValue());
        }
        sysMenu = smResult.getValue();
    } else {
        // create new 新產
        sysMenu.setProgId(sysProg.getProgId());
        sysMenu.setParentOid(ZeroKeyProvide.OID_KEY);
        sysMenu.setEnableFlag(YesNo.YES);
        DefaultResult<SysMenuVO> smResult = this.sysMenuService.saveObject(sysMenu);
        if (smResult.getValue() == null) {
            throw new ServiceException(smResult.getSystemMessage().getValue());
        }
        sysMenu = smResult.getValue();
    }
    this.removeMenuChildData(sysMenu);
    this.createOrUpdate(sysMenu, childProgramOidList);
    result.setValue(true);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysMenuVO(com.netsteadfast.greenstep.vo.SysMenuVO) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 40 with ServiceException

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

the class SystemMenuLogicServiceImpl method createOrUpdate.

private void createOrUpdate(SysMenuVO parentSysMenu, List<String> childProgramOidList) throws ServiceException, Exception {
    for (String progOid : childProgramOidList) {
        SysProgVO sysProg = new SysProgVO();
        sysProg.setOid(progOid);
        DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
        if (spResult.getValue() == null) {
            throw new ServiceException(spResult.getSystemMessage().getValue());
        }
        sysProg = spResult.getValue();
        SysMenuVO childSysMenu = new SysMenuVO();
        childSysMenu.setProgId(sysProg.getProgId());
        childSysMenu.setParentOid(parentSysMenu.getOid());
        childSysMenu.setEnableFlag(YesNo.YES);
        DefaultResult<SysMenuVO> result = this.sysMenuService.saveObject(childSysMenu);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysMenuVO(com.netsteadfast.greenstep.vo.SysMenuVO) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO)

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