You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
19 KiB

package com.fr.plugin.sms;
import com.fanruan.api.log.LogKit;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.plugin.SMSDBAccess;
import com.fr.plugin.dao.SMSDao;
import com.fr.plugin.entity.SMSConfigEntity;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import com.fr.stable.query.QueryFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/7/23
**/
public class SMSUserInfo {
private static JSONObject getDatax() {
return JSONObject.create()
.put("balance", 9999)
.put("testSMSNum", 5)
.put("userId", 99999)
.put("sign", getSigns())
.put("public_tpl", getDataTemp())
.put("private_tpl", getPrivateTpl());
}
public static JSONObject getData() {
return JSONObject.create()
.put("data", getDatax())
.put("status", "success");
}
private static JSONArray getSigns() {
return JSONArray.create()
.put(newSign(2, "【贵阳烟草】", null, "success", true));
}
private static JSONArray getDataTemp() {
try {
return SMSDBAccess.getAccessor().runQueryAction(new DBAction<JSONArray>() {
@Override
public JSONArray run(DAOContext daoContext) throws Exception {
JSONArray jsonArray = JSONArray.create();
List<SMSConfigEntity> all = daoContext.getDAO(SMSDao.class).find(QueryFactory.create());
for (SMSConfigEntity smsConfigEntity : all) {
jsonArray.put(newTpl(Integer.parseInt(smsConfigEntity.getId()), smsConfigEntity.getContent(), "zh_CN", true));
}
LogKit.info("初始化短信模板:{}", jsonArray);
return jsonArray;
}
});
} catch (Exception e) {
e.printStackTrace();
}
return JSONArray.create();
}
private static JSONArray getPublicTpl() {
return JSONArray.create()
.put(newTpl(10, "【贵阳烟草】尊敬的管理员,#taskname#于#time#运行失败,请知晓。", "zh_CN", true))
.put(newTpl(11, "【贵阳烟草】尊敬的#name#,您有一个工单号为:#order_number#的待处理工单,请您及时处理!", "zh_CN", true))
.put(newTpl(13, "【贵阳烟草】您好,#webname#系统内存持续#m#分钟内存高于#n#,可能存在宕机风险,请及时关注。", "zh_CN", true))
.put(newTpl(14, "【贵阳烟草】尊敬的管理员,#taskname#于#time#运行失败,请知晓。", "zh_CN", true))
.put(newTpl(15, "【贵阳烟草】您好,#taskname#于#time#运行成功。", "zh_CN", true))
.put(newTpl(16, "【贵阳烟草】您的手机验证码为#Verifiecode#,请于10分钟内正确输入。", "zh_CN", true))
.put(newTpl(17, "【贵阳烟草】您好,#webname#系统内存持续#m#分钟内存高于#n#,可能存在宕机风险,请及时关注。", "zh_CN", true))
.put(newTpl(18, "【贵阳烟草】恭喜!您的短信服务已经配置成功。", "zh_CN", true))
.put(newTpl(20, "【贵阳烟草】您的手机验证码为#verifiecode#,请于10分钟内正确输入。", "zh_CN", true))
.put(newTpl(49, "【贵阳烟草】您好,#webname#系统日志文件已大于#logsize#M,请及时登录平台进行日志清理。", "zh_CN", true))
.put(newTpl(50, "【贵阳烟草】您好,#webname#系统#clustername#内存持续#m#分钟内存高于#n#,可能存在宕机风险,请及时关注。", "zh_CN", true))
.put(newTpl(51, "【贵阳烟草】你好,#task#出错,请及时处理。该任务开始执行时间:#time#", "zh_CN", true))
.put(newTpl(53, "【贵阳烟草】上报任务 #task#,已经到您这里#time#,请尽快处理!", "zh_CN", true))
.put(newTpl(54, "【贵阳烟草】#name#您好,上报任务#task#已经发起,请尽快处理!", "zh_CN", true))
.put(newTpl(63, "【贵阳烟草】节点#nodename2#,与节点#nodename1#系统时间相差超过#time_different#秒,为避免影响用户使用,请及时调整使各节点时间保持一致。", "zh_CN", true))
.put(newTpl(64, "【贵阳烟草】节点#nodename#已脱离集群环境,可能原因为:节点FullGC、节点宕机、节点间通…其他异常。为避免影响用户使用,请及时检查该节点状态,若该节点长时间无法自行恢复,则建议重启该节点。", "zh_CN", true))
.put(newTpl(89, "【贵阳烟草】节点#nodename#,与节点#node1name#的jar包不一致,将影响集群工程的稳定性,请前往集群节点管理页面查看详细异常信息,并及时处理。", "zh_CN", true))
.put(newTpl(90, "【贵阳烟草】节点#nodename#情况异常,用户不能正常访问,请及时检查该节点状态。", "zh_CN", true))
.put(newTpl(125, "【贵阳烟草】您有个#proname#任务即将过期,请您尽快办理。", "zh_CN", true))
.put(newTpl(127, "【贵阳烟草】您有个#proname#任务需要处理,请您尽快办理。发起人:#startpeople#,发起时间:#starttime#。", "zh_CN", true))
.put(newTpl(134, "【贵阳烟草】Redis集群#ip_port#节点已无法正常使用,可能原因为:节点宕机、内存已满、其他异常。为避免影响用户使用,请前往状态服务器配置页面查看详情,并及时处理。", "zh_CN", true))
.put(newTpl(135, "【贵阳烟草】文件服务器出现无法读写的情况,可能原因为:文件服务器宕机、磁盘已满、其他异常。为避免影响用户使用,请及时检查文件服务器状态。", "zh_CN", true))
.put(newTpl(136, "【贵阳烟草】您好,#webname#系统#clustername#当前负载状态过高,可能存在宕机风险,请及时关注。建议使用管理系统-智能运维-云端运维功能分析当前系统存在的性能问题。", "zh_CN", true))
.put(newTpl(239, "【贵阳烟草】您好,预警任务#warningname#达到阈值被触发,请及时关注!模板路径:#templatePath#", "zh_CN", true))
.put(newTpl(264, "【贵阳烟草】更新任务「#job_name#」结束。任务开始于#year#年#month#月#day#…aset# , 关联更新 #success_relation#/#total_relation#。", "zh_CN", true))
.put(newTpl(265, "【贵阳烟草】贵阳烟草已宕机,请访问运维工具关注问题处理状态或及时进行系统重启。", "zh_CN", true))
.put(newTpl(266, "【贵阳烟草】贵阳烟草已宕机,自动重启系统失败,请及时进行手动重启。", "zh_CN", true))
.put(newTpl(269, "【贵阳烟草】检查到系统环境配置存有不合理项,请及时查看并改正不合理项。", "zh_CN", true))
.put(newTpl(276, "【贵阳烟草】你好,[#taskname#]备份失败,请及时处理,备份时间:#time#", "zh_CN", true))
.put(newTpl(306, "【贵阳烟草】尊敬的管理員,#taskname#於#time#運行失敗,請知曉。", "zh_TW", true))
.put(newTpl(307, "【贵阳烟草】您好,#webname#系統記憶體持續#m#分鐘記憶體高於#n#,可能存在宕機風險,請及時關注。", "zh_TW", true))
.put(newTpl(308, "【贵阳烟草】恭喜!您的簡訊服務已經配置成功。", "zh_TW", true))
.put(newTpl(309, "【贵阳烟草】您的手機驗證碼為#verifiecode#,請於10分鐘內正確輸入。", "zh_TW", true))
.put(newTpl(310, "【贵阳烟草】您好,#webname#系統日誌檔已大於#logsize#M,請及時登入平臺進行日誌清理。", "zh_TW", true))
.put(newTpl(311, "【贵阳烟草】您好,#webname#系統#clustername#記憶體持續#m#分鐘記憶體高於#n#,可能存在宕機風險,請及時關注。", "zh_TW", true))
.put(newTpl(312, "【贵阳烟草】你好,#task#出錯,請及時處理。該任務開始執行時間:#time#", "zh_TW", true))
.put(newTpl(313, "【贵阳烟草】上報任務#task#,已經到您這裡#time#,請儘快處理!", "zh_TW", true))
.put(newTpl(314, "【贵阳烟草】#name#您好,上報任務#task#已經發起,請儘快處理!", "zh_TW", true))
.put(newTpl(315, "【贵阳烟草】系統檢測到,節點#node_id#的系統時間與其他節點不一致。請配置時間伺服器,實現節點時間的自動同步。", "zh_TW", true))
.put(newTpl(316, "【贵阳烟草】節點#nodename#已脫離叢集環境,可能原因為:節點FullGC、節點宕機、節點間通…他异常。為避免影響使用者使用,請及時檢查該節點狀態,若該節點長時間無法自行恢復,則建議重啓該節點。", "zh_TW", true))
.put(newTpl(317, "【贵阳烟草】節點#nodename#,與節點#node1name#的jar包不一致,將影響叢集工程的穩定性,請前往叢集節點管理頁面查看詳細异常資訊,並及時處理。", "zh_TW", true))
.put(newTpl(318, "【贵阳烟草】節點#nodename#情况异常,使用者不能正常訪問,請及時檢查該節點狀態。", "zh_TW", true))
.put(newTpl(319, "【贵阳烟草】您有個#proname#任務即將過期,請您儘快辦理。", "zh_TW", true))
.put(newTpl(320, "【贵阳烟草】您有個#proname#任務需要處理,請您儘快辦理。發起人:#startpeople#,發起時間:#starttime#。", "zh_TW", true))
.put(newTpl(321, "【贵阳烟草】Redis叢集#ip_port#節點已無法正常使用,可能原因為:節點宕機、記憶體已滿、其他異常。為避免影響使用者使用,請前往狀態伺服器配置頁面檢視詳情,並及時處理。", "zh_TW", true))
.put(newTpl(322, "【贵阳烟草】檔案伺服器出現無法讀寫的情况,可能原因為:檔案伺服器宕機、磁片已滿、其他异常。為避免影響使用者使用,請及時檢查檔案伺服器狀態。", "zh_TW", true))
.put(newTpl(323, "【贵阳烟草】您好,#webname#系統#clustername#當前負載狀態過高,可能存在宕機風險,請及時關注。", "zh_TW", true))
.put(newTpl(324, "【贵阳烟草】更新任務「#job_name#」結束。任務開始於#year#年#month#月#day#…dataset#,關聯更新#success_relation#/#total_relation#。", "zh_TW", true))
.put(newTpl(325, "【贵阳烟草】報表系統已宕機,請訪問維運工具關注問題處理狀態或及時進行系統重啓。", "zh_TW", true))
.put(newTpl(326, "【贵阳烟草】報表系統已宕機,自動重啟系統失敗,請及時進行手動重啓。", "zh_TW", true))
.put(newTpl(327, "【贵阳烟草】檢查到系統環境配置存有不合理項,請及時查看並改正不合理項。", "zh_TW", true))
.put(newTpl(328, "【贵阳烟草】你好,[#taskname#]備份失敗,請及時處理,備份時間:#time#", "zh_TW", true))
.put(newTpl(329, "【贵阳烟草】Dear administrator, #taskname# failed to run at #time#.", "en_US", true))
.put(newTpl(330, "【贵阳烟草】Hello, the system memory of #webname# keeps …y be downtime risk. Please pay attention in time.", "en_US", true))
.put(newTpl(331, "【贵阳烟草】Congratulations! Your SMS service has been configured successfully.", "en_US", true))
.put(newTpl(332, "【贵阳烟草】Your mobile phone verification code is #veri…de#. Please input it correctly within 10 minutes.", "en_US", true))
.put(newTpl(333, "【贵阳烟草】Hello, the system log files of #webname# occ…g in the platform to clean the log files in time.", "en_US", true))
.put(newTpl(334, "【贵阳烟草】Hello, the memory of #clustername# in system…y be downtime risk. Please pay attention in time.", "en_US", true))
.put(newTpl(335, "【贵阳烟草】Hello, there is an error in the task #task#,…t in time. The start time of the task is: #time#.", "en_US", true))
.put(newTpl(336, "【贵阳烟草】Reporting task #task# has arrived at #time#. Please deal with it as soon as possible!", "en_US", true))
.put(newTpl(337, "【贵阳烟草】Hello #name#, the reporting task #task# has … initiated. Please handle it as soon as possible!", "en_US", true))
.put(newTpl(338, "【贵阳烟草】The system detects that the system time of n…o realize automatic synchronization of node time.", "en_US", true))
.put(newTpl(339, "【贵阳烟草】Node #nodename# has been out of the cluster …der to avoid affecting the user's use, please che", "en_US", true))
.put(newTpl(340, "【贵阳烟草】The jar packages of node #nodename# and node…iled exception information and handle it in time.", "en_US", true))
.put(newTpl(341, "【贵阳烟草】There exists abnormal condition of node #nod…lly. Please check the status of the node in time.", "en_US", true))
.put(newTpl(342, "【贵阳烟草】Task #proname# will expire recently. Please handle it as soon as possible.", "en_US", true))
.put(newTpl(343, "【贵阳烟草】Task #proname# needs to be handled. Please h…nitiator: #startpeople#. Start time: #starttime#.", "en_US", true))
.put(newTpl(344, "【贵阳烟草】The Redis cluster #ip_port# node is no longe…page, check the details and deal with it in time.", "en_US", true))
.put(newTpl(345, "【贵阳烟草】The file server is unable to read and write.…ease check the status of the file server in time.", "en_US", true))
.put(newTpl(346, "【贵阳烟草】Hello, the load of #clustername# in system #…intenance and use the function of Cloud Operation", "en_US", true))
.put(newTpl(347, "【贵阳烟草】Update task 「#job_name#」is completed. The ta…table#/#total_basetable# basic table, #success_da", "en_US", true))
.put(newTpl(348, "【贵阳烟草】The report system has been down. Please use … processing status or restart the system in time.", "en_US", true))
.put(newTpl(349, "【贵阳烟草】The report system has been down, and automat… restart failed. Please restart manually in time.", "en_US", true))
.put(newTpl(350, "【贵阳烟草】It is found that there are unreasonable item…check and correct the unreasonable items in time.", "en_US", true))
.put(newTpl(351, "【贵阳烟草】Hello, [#taskname#] backup failed. Please handle it in time. Backup time: #time#.", "en_US", true))
.put(newTpl(367, "【贵阳烟草】集群节点#node_name#与基准节点存在不一致文件,且无法自动同步。请检查该节点状态", "zn_CN", true))
.put(newTpl(368, "【贵阳烟草】集群节点#node_name#与基准节点存在不一致文件,已自动同步与基准节点一致,不一致文件备份在该节点工程WEB-INF/#directory#/下", "zh_CN", true))
.put(newTpl(369, "【贵阳烟草】節點#nodename1#與節點#nodename1#之間通訊異常,無法加入節點管理,請…7830, 7840, 7850,7860,7870][UDP:45588~65536 隨機埠]。", "zh_TW", true))
.put(newTpl(370, "【贵阳烟草】節點#node_name#的#type#模組存在異常,暫無法正常提供服務,請及時對異常狀況進行排查", "zh_TW", true))
.put(newTpl(371, "【贵阳烟草】叢集節點#node_name#與基準節點存在不一致檔案,且無法自動同步。請檢查該節點狀態", "zh_TW", true))
.put(newTpl(372, "【贵阳烟草】叢集節點#node_name#與基準節點存在不一致檔案,已自動同步與基準節點一致,不一致檔案備份在該節點工程WEB-INF/#directory#/下", "zh_TW", true))
.put(newTpl(373, "【贵阳烟草】The communication between node #nodename1# a…7850,7860,7870] [UDP: 45588 ~ 65536 random port].", "en_US", true))
.put(newTpl(374, "【贵阳烟草】The #node_name# node #type# module has start…ng. Please check for abnormal conditions in time.", "en_US", true))
.put(newTpl(375, "【贵阳烟草】Cluster node #node_name# has inconsistent fi…ized automatically. Please check the node status.", "en_US", true))
.put(newTpl(376, "【贵阳烟草】The cluster node #node_name# has an inconsis…up under the node project WEB-INF/ #directory# /.", "en_US", true))
.put(newTpl(401, "【贵阳烟草】Hello, #taskname# runs successfully on #time#.", "en_US", true))
.put(newTpl(402, "【贵阳烟草】您好,#taskname#於#time#運行成功運行。", "zh_TW", true))
.put(newTpl(509, "【贵阳烟草】尊敬的管理员,用户管理-同步用户于#time#运行失败,可手动触发同步,以查看详细报错。", "zh_CN", true))
.put(newTpl(550, "【贵阳烟草】Dear administrator, \\\"User>Sync user\\\" failed … sync manually to view the detailed error report.", "en_US", true))
.put(newTpl(551, "【贵阳烟草】尊敬的管理員,使用者管理-同步使用者於#time#執行失敗,可手動觸發同步,以檢視詳細報錯。", "zh_TW", true))
.put(newTpl(998, "【贵阳烟草】节点#nodename1#与节点#nodename2#之间通信异常,无法加入节点管理,请…830, 7840, 7850,7860,7870][UDP:45588~65536 随机端口]。", "zh_CN", true))
.put(newTpl(999, "【贵阳烟草】节点#node_name#的#type#模块存在异常,暂无法正常提供服务,请及时对异常状况进行排查", "zh_CN", true));
}
public static Map<String, String> getTpls() {
JSONArray arrs = getPublicTpl();
Map<String, String> rt = new HashMap<String, String>();
for (int i = 0, len = arrs.length(); i < len; i++) {
JSONObject tpl = arrs.optJSONObject(i);
rt.put("" + tpl.optInt("id"), tpl.optString("content"));
}
arrs = getPrivateTpl();
for (int i = 0, len = arrs.length(); i < len; i++) {
JSONObject tpl = arrs.optJSONObject(i);
rt.put("" + tpl.optInt("id"), tpl.optString("content"));
}
return rt;
}
private static JSONArray getPrivateTpl() {
return JSONArray.create();
}
private static JSONObject newSign(int id, String sign, String remark, String status, boolean isDefault) {
return JSONObject.create()
.put("id", id)
.put("sign", sign)
.put("remark", remark)
.put("status", status)
.put("is_default", isDefault);
}
private static JSONObject newTpl(int id, String content, String language, boolean isDefault) {
return JSONObject.create()
.put("id", id)
.put("content", content)
.put("language", language)
.put("remark", (String) null)
.put("status", "success")
.put("is_default", isDefault);
}
}