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();
}
}
}
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);
}
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);
}
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;
}
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());
}
}
}
Aggregations