use of com.netsteadfast.greenstep.vo.SysMailHelperVO 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.vo.SysMailHelperVO in project bamboobsc by billchen198318.
the class ExpressionJobExecuteCallable method sendMail.
private void sendMail() {
try {
if (ExpressionJobConstants.CONTACT_MODE_NO.equals(this.jobObj.getSysExprJob().getContactMode())) {
return;
}
if (ExpressionJobConstants.CONTACT_MODE_ONLY_FAULT.equals(this.jobObj.getSysExprJob().getContactMode()) && !ExpressionJobConstants.RUNSTATUS_FAULT.equals(this.jobObj.getSysExprJob().getRunStatus())) {
return;
}
if (ExpressionJobConstants.CONTACT_MODE_ONLY_SUCCESS.equals(this.jobObj.getSysExprJob().getContactMode()) && !ExpressionJobConstants.RUNSTATUS_SUCCESS.equals(this.jobObj.getSysExprJob().getRunStatus())) {
return;
}
String contact = StringUtils.defaultString(this.jobObj.getSysExprJob().getContact()).trim();
if (StringUtils.isBlank(contact)) {
return;
}
String subject = this.jobObj.getSysExprJob().getId() + " - " + this.jobObj.getSysExprJob().getName();
String content = subject + Constants.HTML_BR;
content += "Run status: " + this.jobObj.getSysExprJob().getRunStatus() + Constants.HTML_BR;
content += "Start: " + this.jobObj.getSysExprJobLog().getBeginDatetime().toString() + Constants.HTML_BR;
content += "End: " + this.jobObj.getSysExprJobLog().getEndDatetime().toString() + Constants.HTML_BR;
if (ExpressionJobConstants.RUNSTATUS_FAULT.equals(this.jobObj.getSysExprJob().getRunStatus())) {
content += Constants.HTML_BR;
content += "Fault: " + Constants.HTML_BR;
content += this.jobObj.getSysExprJobLog().getFaultMsg();
}
@SuppressWarnings("unchecked") ISysMailHelperService<SysMailHelperVO, TbSysMailHelper, String> sysMailHelperService = (ISysMailHelperService<SysMailHelperVO, TbSysMailHelper, String>) AppContext.getBean("core.service.SysMailHelperService");
String mailId = SimpleUtils.getStrYMD("");
SysMailHelperVO mailHelper = new SysMailHelperVO();
mailHelper.setMailId(sysMailHelperService.findForMaxMailIdComplete(mailId));
mailHelper.setMailFrom(MailClientUtils.getDefaultFrom());
mailHelper.setMailTo(contact);
mailHelper.setSubject(subject);
mailHelper.setText(content.getBytes("utf8"));
mailHelper.setRetainFlag(YesNo.NO);
mailHelper.setSuccessFlag(YesNo.NO);
sysMailHelperService.saveObject(mailHelper);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.netsteadfast.greenstep.vo.SysMailHelperVO in project bamboobsc by billchen198318.
the class HistoryItemScoreNoticeHandler method action.
public void action() throws ServiceException, Exception {
if (toMail.size() < 1) {
return;
}
if (!MailClientUtils.getEnable()) {
logger.warn("MailClientUtils no enable.");
return;
}
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("frequency", frequency);
paramMap.put("dateVal", dateStr);
List<BbMonitorItemScore> monitorItemScores = monitorItemScoreService.findListByParams(paramMap);
this.clearNoNeedItem(monitorItemScores);
if (null == monitorItemScores || monitorItemScores.size() < 1) {
logger.warn("No history monitor item score data.");
return;
}
StringBuilder outContent = new StringBuilder();
this.createContent(monitorItemScores, outContent);
if (null == outContent || outContent.length() < 1) {
logger.warn("No history monitor mail content data.");
return;
}
SysMailHelperVO sysMailHelper = new SysMailHelperVO();
sysMailHelper.setSubject("bambooBSC monitor item score mail - frequency: " + BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) + " , date: " + SimpleUtils.getStrYMD(dateStr, "/"));
sysMailHelper.setText(outContent.toString().getBytes("utf-8"));
sysMailHelper.setMailFrom(MailClientUtils.getDefaultFrom());
StringBuilder to = new StringBuilder();
for (String mail : toMail) {
to.append(mail).append(";");
}
sysMailHelper.setMailTo(this.toMail.get(0));
if (this.toMail.size() > 1) {
sysMailHelper.setMailCc(to.toString());
}
sysMailHelper.setMailId(this.sysMailHelperService.findForMaxMailIdComplete(dateStr));
sysMailHelper.setRetainFlag(YesNo.NO);
sysMailHelper.setSuccessFlag(YesNo.NO);
sysMailHelperService.saveObject(sysMailHelper);
}
Aggregations