BaseBatch脚本报错提醒
This commit is contained in:
@@ -96,7 +96,7 @@ abstract class BaseBatch {
|
||||
exception = true
|
||||
e.printStackTrace()
|
||||
__jms.monitor(batchName, '', extraData, e)
|
||||
def msg = "脚本发生异常 BatchName:${batchName}\t"
|
||||
def msg = "脚本发生异常错误 BatchName:${batchName}\t"
|
||||
def batchOwner = getBatchOwner(batch)
|
||||
if(batchOwner && batchOwner.size() > 0){
|
||||
def owner = null
|
||||
@@ -110,8 +110,9 @@ abstract class BaseBatch {
|
||||
if(e){
|
||||
msg += "\tException:" + e.getClass().name
|
||||
}
|
||||
if(SystemUtils.IS_OS_LINUX){
|
||||
sendDingDingMsg("2307d2fec8314b3e8b4b83dd1d42da2e2051638e3e668f21e77ca01258bf682c",msg)
|
||||
def phoneNum = getBatchPhones(batch)
|
||||
if(true){
|
||||
sendDingDingMsg("ae14f50045e9375c354940a2afb86f14e453bd1f08f78da0ba6e788d35bccec4",msg, phoneNum)
|
||||
|
||||
try {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
@@ -174,6 +175,27 @@ abstract class BaseBatch {
|
||||
return ret
|
||||
}
|
||||
|
||||
static def getBatchPhones(BaseBatch bb) {
|
||||
def phones = []
|
||||
try {
|
||||
BatchOwner annotation = AnnotationUtils.findAnnotation(bb.getClass(), BatchOwner.class)
|
||||
if (annotation) {
|
||||
annotation.value().each {
|
||||
def map = it.toMap()
|
||||
if (map?.mobile) {
|
||||
phones << map.mobile
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bb.logWarn('!!!请使用' + BatchOwner.class.getName() + '注解标明本Batch的拥有者!!!')
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.logWarn('!!!解析BatchOwner失败!!!', e)
|
||||
}
|
||||
return phones[0] ? phones[0] : ""
|
||||
}
|
||||
|
||||
|
||||
static def getBatchDescribe(BaseBatch bb){
|
||||
try {
|
||||
BatchOwner annotation = AnnotationUtils.findAnnotation(bb.getClass(), BatchOwner.class)
|
||||
@@ -217,8 +239,8 @@ abstract class BaseBatch {
|
||||
__jms.sendDingMsg(mobile, msg)
|
||||
}
|
||||
|
||||
def static sendDingDingMsg(String token, String msg){
|
||||
DingDingMessageUtil.sendTextMessage(token, msg);
|
||||
def static sendDingDingMsg(String token, String msg, String phoneNum){
|
||||
DingDingMessageUtil.sendTextMessageAndAt(token, msg, phoneNum);
|
||||
}
|
||||
|
||||
// def static getProp(String key){
|
||||
|
||||
Reference in New Issue
Block a user