|
@@ -0,0 +1,52 @@
|
|
|
+package cn.com.qmth.examcloud.core.oe.task.service.job;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.support.sms.SmsHelper;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 系统预警任务
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class WarningJobHandler {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(WarningJobHandler.class);
|
|
|
+
|
|
|
+ public void run(int shardTotal, int shardIndex, String jobParam) throws Exception {
|
|
|
+ try {
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ //todo
|
|
|
+
|
|
|
+ List<String> phones = this.parseJobParam(jobParam);
|
|
|
+ if (!phones.isEmpty()) {
|
|
|
+ Map<String, String> templateParams = new HashMap<>();
|
|
|
+ templateParams.put("name", "baidu-face-api");
|
|
|
+ templateParams.put("time", new SimpleDateFormat("HH:mm:ss").format(new Date()));
|
|
|
+ templateParams.put("status", "403");
|
|
|
+ templateParams.put("msg", "鉴权接口异常");
|
|
|
+ SmsHelper.send("启明泰和", "SMS_246635756", phones, templateParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ long cost = System.currentTimeMillis() - startTime;
|
|
|
+ log.warn("系统预警任务_{}_{} cost:{}ms", shardTotal, shardIndex, cost);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> parseJobParam(String jobParam) {
|
|
|
+ // jobParam --> 13600000001,13600000002
|
|
|
+ if (StringUtils.isBlank(jobParam)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] phones = jobParam.split(",");
|
|
|
+ return Arrays.asList(phones);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|