commit
This commit is contained in:
@@ -14,6 +14,7 @@ import com.budwk.app.sys.services.SysMsgUserService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nutz.aop.interceptor.async.Async;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
@@ -108,7 +109,8 @@ public class SysMsgServiceImpl extends BaseServiceImpl<Sys_msg> implements SysMs
|
||||
if(sysMsg.getWechatEnterprise()) {
|
||||
ThreadUtil.execute(() -> {
|
||||
//smsService.massSend(loginNames, sysMsg.getTitle(), HtmlUtil.cleanHtmlTag(StrUtil.blankToDefault(sysMsg.getNote(),"")), sysMsg.getUrl());
|
||||
smsService.massSendMessage(loginNames, HtmlUtil.cleanHtmlTag(StrUtil.blankToDefault(sysMsg.getNote(),"")));
|
||||
String plainText = SysMsgServiceImpl.htmlToPlainText(StrUtil.blankToDefault(sysMsg.getNote(), ""));
|
||||
smsService.massSendMessage(loginNames, HtmlUtil.cleanHtmlTag(plainText));
|
||||
});
|
||||
}
|
||||
return sysMsg;
|
||||
@@ -319,4 +321,25 @@ public class SysMsgServiceImpl extends BaseServiceImpl<Sys_msg> implements SysMs
|
||||
sysMsg.setCreatedBy(sender);
|
||||
this.saveMsg(sysMsg, loginNames.toArray(new String[]{}), false);
|
||||
}
|
||||
|
||||
public static String htmlToPlainText(String htmlContent) {
|
||||
if (StrUtil.isBlank(htmlContent)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 1. 把 <p> 标签 换成 \n
|
||||
String result = htmlContent.replaceAll("<p[^>]*>", "\n");
|
||||
// 2. 把 </p> 闭合标签去掉
|
||||
result = result.replaceAll("</p>", "");
|
||||
// 3. 把 <br/> <br> 都换成 \n
|
||||
result = result.replaceAll("<br\\s*/?>", "\n");
|
||||
// 4. 清除所有剩余 HTML 标签
|
||||
result = result.replaceAll("<[^>]+>", "");
|
||||
// 5. 清除多余空行(可选)
|
||||
result = result.replaceAll("\\n+", "\n");
|
||||
// 6. 去掉首尾空格
|
||||
result = result.trim();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user