打印日志修改

This commit is contained in:
2025-04-24 13:42:32 +08:00
parent 70fcc20357
commit 9118b112c2
@@ -41,7 +41,7 @@ class SMSOutgoingListener extends BaseBatch {
public static final int MAX_SYS_SEND_COUNT = 4000
//设置Web Service服务器,该服务器用于接收信息
public static final List TASK_QUEUE = Collections.synchronizedList(new ArrayList())
public static final List ADMINISTRATORS = [Watcher.DuXiaoYu.mobile, Watcher.WangWenYan.mobile, "13621625626"]
public static final List ADMINISTRATORS = [ Watcher.WangWenYan.mobile, "13621625626"]
/**初始化手机号白名单和黑名单*/
public static def MOBILE_LIST = [ : ]
@@ -93,35 +93,38 @@ class SMSOutgoingListener extends BaseBatch {
new Thread(){
@Override
void run() {
while(true){
try{
synchronized(TASK_QUEUE){
println("..........................................-->开始消费:" + new Date().format("HH:mm:ss"))
Iterator iter = TASK_QUEUE.iterator();
while (iter.hasNext()){
def msg = iter.next()
def mobile = msg.getObject().mobile
def logs = LOG_COLL.find(new BasicDBObject("mobile",mobile)).sort(new BasicDBObject("c_date", -1)).limit(1).toArray()
if(logs.size() == 0){
consumerQueue(msg)
iter.remove()
}else{
def lastSendTime = (Date)logs[0].get("c_date")
long interval = new Date().getTime() - lastSendTime.getTime()
if(interval > 1000 * 60 * 2){
consumerQueue(msg)
iter.remove()
}else{
int count = smsSendCount(mobile, 10)
if(count < 7){
try{
def msg = iter.next()
def mobile = msg.getObject().mobile
def logs = LOG_COLL.find(new BasicDBObject("mobile",mobile)).sort(new BasicDBObject("c_date", -1)).limit(1).toArray()
if(logs.size() == 0){
consumerQueue(msg)
iter.remove()
}else {
println "$mobile 短信发送频繁 延后再发"
}else{
def lastSendTime = (Date)logs[0].get("c_date")
long interval = new Date().getTime() - lastSendTime.getTime()
if(interval > 1000 * 60 * 2){
consumerQueue(msg)
iter.remove()
}else{
int count = smsSendCount(mobile, 10)
if(count < 7){
consumerQueue(msg)
iter.remove()
}else {
println "$mobile 短信发送频繁 延后再发"
}
}
}
}catch(Exception e){
println "Error:"+e.getMessage()
iter.remove()
}
}
}
if(TASK_QUEUE.isEmpty()){
TASK_QUEUE.wait()
@@ -129,9 +132,7 @@ class SMSOutgoingListener extends BaseBatch {
sleep(100)
}
}
}catch(Exception e){
println "Error:"+e.getMessage()
}
println("..........................................")
}
@@ -273,19 +274,6 @@ class SMSOutgoingListener extends BaseBatch {
}
}
/**
* 监控短信使用量
* @return
*/
def monitorUsage(){
int amount = (int)(SingletonClient.getClient().balance * 10)
if(amount < 1000 && amount % 300 == 0 && amount != 0){//调用失败时为0
ADMINISTRATORS.each {phone->
jms.sendSms(phone, "短信剩余量:${amount} 请尽快充值!!".toString(), false)
}
}
println("短信剩余数量" + amount)
}
/**
* 是否是白名单手机号