Browse Source

#定时刷新数据任务运行堵塞邮件发送

zhongwei
yang_shj 5 months ago
parent
commit
02dd1fece2
  1. 1
      hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java
  2. 31
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

1
hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java

@ -59,4 +59,5 @@ public interface CommonConstant {
*/
Long SYSTEM_USER = 1434782836098891778L;
Long SYSTEM_DEPT_ID = 20000001L;
}

31
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

@ -6,11 +6,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.equipment.entity.WorkshopInfoEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.message.dto.MailPushDto;
import com.hnac.hzims.message.fegin.IPushMsgClient;
import com.hnac.hzims.operational.config.enume.ConfigStatus;
import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
import com.hnac.hzims.operational.main.vo.RealAttributeVo;
import com.hnac.hzims.operational.main.vo.RealDeviceVo;
import com.hnac.hzims.operational.main.vo.RealStationVo;
@ -35,6 +39,7 @@ import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@ -76,6 +81,8 @@ public class MonitorServiceImpl implements MonitorService {
private final RedisClient redisClient;
private final IPushMsgClient pushMsgClient;
private final IAnalyseDataSearchClient analyseDataSearchClient;
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 60L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
@ -227,6 +234,8 @@ public class MonitorServiceImpl implements MonitorService {
boolean flag = countDownLatch.await(3,TimeUnit.SECONDS);
if(!flag){
log.error("实时数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME));
// 发生邮件
this.sendMonthReport("实时数据运行堵塞");
}
} catch (InterruptedException e) {
e.printStackTrace();
@ -331,6 +340,8 @@ public class MonitorServiceImpl implements MonitorService {
boolean flag = countDownLatch.await(2,TimeUnit.SECONDS);
if(!flag){
log.error("集中监控数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME));
// 发生邮件
this.sendMonthReport("集中监控数据运行堵塞");
}
} catch (InterruptedException e) {
e.printStackTrace();
@ -748,4 +759,24 @@ public class MonitorServiceImpl implements MonitorService {
}
return result;
}
/**
* 推送当月月报
*/
private void sendMonthReport(String text) {
// 发送邮件
MailPushDto pushDto = new MailPushDto();
pushDto.setBusinessClassify("system");
pushDto.setBusinessKey("Run_Blocking");
pushDto.setSubject(text);
pushDto.setText(text);
pushDto.setToAccount(Collections.singletonList("1069818635@qq.com").toArray(new String[0]));
pushDto.setHtml(false);
pushDto.setCreateUser(CommonConstant.SYSTEM_USER);
pushDto.setTenantId(CommonConstant.TENANT_ID);
pushDto.setCreateDept(CommonConstant.SYSTEM_DEPT_ID);
pushDto.setMailType(0);
pushDto.setFromAccount("huangxing951023@163.com");
pushMsgClient.sendMail(pushDto);
}
}
Loading…
Cancel
Save