use of com.netsteadfast.greenstep.model.TemplateResultObj in project bamboobsc by billchen198318.
the class SystemMessagePublishServiceImpl method process.
private String process(String sessionId, String refreshUUID, List<TbSysMsgNotice> sysMsgNotices) throws ServiceException, Exception {
if (sysMsgNotices == null || sysMsgNotices.size() < 1) {
return "";
}
Date sysDate = new Date();
StringBuilder sb = new StringBuilder();
for (TbSysMsgNotice msgNotice : sysMsgNotices) {
String key = sessionId + ":uuid_" + refreshUUID + ":" + msgNotice.getNoticeId();
if (messagePublishMap.get(key) != null) {
continue;
}
if (!this.isPublishDateTimeRange(msgNotice, sysDate)) {
// 日期區間不合
continue;
}
//msgNotice.setTitle( TemplateUtils.processTemplateHtmlContent(msgNotice.getTitle()) );
//msgNotice.setMessage( TemplateUtils.processTemplateHtmlContent(msgNotice.getMessage()) );
TbSysMsgNotice dataObj = new TbSysMsgNotice();
dataObj.setTitle(TemplateUtils.escapeHtml4TemplateHtmlContent(msgNotice.getTitle()));
dataObj.setMessage(TemplateUtils.escapeHtml4TemplateHtmlContent(msgNotice.getMessage()));
TemplateResultObj result = TemplateUtils.getResult(TemplateCode.TPLMSG0002, dataObj);
dataObj = null;
sb.append(result.getContent());
messagePublishMap.put(key, YesNo.YES);
}
return sb.toString();
}
use of com.netsteadfast.greenstep.model.TemplateResultObj 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.model.TemplateResultObj in project bamboobsc by billchen198318.
the class SystemCalendarNoteHistoryAction method generateContent.
private void generateContent() throws ControllerException, AuthorityException, ServiceException, Exception {
String date = this.getFields().get("date");
if (!SimpleUtils.isDate(date)) {
return;
}
date = date.replaceAll("/", "").replaceAll("-", "");
Map<String, Object> params = new HashMap<String, Object>();
params.put("account", super.getAccountId());
params.put("date", date);
Map<String, String> orderParams = new LinkedHashMap<String, String>();
orderParams.put("time", "ASC");
List<TbSysCalendarNote> searchList = sysCalendarNoteService.findListByParams2(params, null, null, orderParams);
if (searchList == null || searchList.size() < 1) {
this.message = "";
return;
}
StringBuilder sb = new StringBuilder();
for (TbSysCalendarNote calendarNote : searchList) {
calendarNote.setTitle(TemplateUtils.escapeHtml4TemplateHtmlContent(calendarNote.getTitle()));
calendarNote.setNote(TemplateUtils.escapeHtml4TemplateHtmlContent(calendarNote.getNote()));
TemplateResultObj result = TemplateUtils.getResult(TemplateCode.TPLMSG0001, calendarNote);
sb.append(result.getContent());
}
this.message = sb.toString();
}
use of com.netsteadfast.greenstep.model.TemplateResultObj in project bamboobsc by billchen198318.
the class TemplateUtils method getResult.
/**
* 產生 template 結果
* Map 值放入 title 與 message
*
* @param templateId 樣板id
* @param dataObj 資料來源
* @return
* @throws ServiceException
* @throws Exception
*/
public static TemplateResultObj getResult(String templateId, Object dataObj) throws ServiceException, Exception {
if (StringUtils.isBlank(templateId) || null == dataObj) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
TemplateResultObj resultObj = new TemplateResultObj();
SysTemplateVO sysTemplate = loadSysTemplate(templateId);
List<TbSysTemplateParam> sysTemplateParamList = loadSysTemplateParam(templateId);
Map<String, Object> titleParams = getTemplateParamMap(IS_TITLE, sysTemplateParamList, dataObj);
Map<String, Object> msgParams = getTemplateParamMap(IS_MESSAGE, sysTemplateParamList, dataObj);
resultObj.setTitle(processTemplate(sysTemplate.getTitle(), titleParams));
resultObj.setContent(processTemplate(sysTemplate.getMessage(), msgParams));
return resultObj;
}
use of com.netsteadfast.greenstep.model.TemplateResultObj in project bamboobsc by billchen198318.
the class HistoryItemScoreNoticeHandler method createContent.
private void createContent(List<BbMonitorItemScore> monitorItemScoresSrc, StringBuilder out) throws ServiceException, Exception {
// create mail content
List<MonitorItemScoreVO> monitorItemScores = HistoryItemScoreReportContentQueryUtils.fill2ValueObjectList(monitorItemScoresSrc);
BscScoreColorUtils.loadScoreColors();
for (MonitorItemScoreVO itemScore : monitorItemScores) {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("title", itemScore.getName());
paramMap.put("date", SimpleUtils.getStrYMD(itemScore.getDateVal(), "/"));
paramMap.put("frequency", BscMeasureDataFrequency.getFrequencyMap(false).get(frequency));
paramMap.put("score", itemScore.getScore());
paramMap.put("organization", itemScore.getOrganizationName());
paramMap.put("employee", itemScore.getEmployeeName());
paramMap.put("bgColor", BscScoreColorUtils.getBackgroundColor(Float.parseFloat(itemScore.getScore())));
paramMap.put("fnColor", BscScoreColorUtils.getFontColor(Float.parseFloat(itemScore.getScore())));
TemplateResultObj result = TemplateUtils.getResult(TemplateCode.TPLMSG0003, paramMap);
if (result.getContent() != null) {
out.append(result.getContent());
}
}
}
Aggregations