|
@@ -35,52 +35,64 @@ public class SuperviseMailSchedule {
|
|
|
private EmailUtil emailUtil;
|
|
|
|
|
|
@XxlJob("ruleMessageJob")
|
|
|
-
|
|
|
+
|
|
|
public ReturnT<String> sendMail(String param) {
|
|
|
+
|
|
|
List<Rule> allRule = superviseMailMapper.getAllRule();
|
|
|
ArrayList<Map<String, String>> maps = new ArrayList<>();
|
|
|
ArrayList<ControllerRule> rules = new ArrayList<>();
|
|
|
for (Rule rule : allRule) {
|
|
|
- Map<String, Object> object = runSql(rule.getRuleSql(), rule.getParams());
|
|
|
- if (object != null && !object.isEmpty() && "1".equals(rule.getLastState())) {
|
|
|
-
|
|
|
- if (DateUtil.isIn(new Date(), 9, 18)) {
|
|
|
-
|
|
|
- if (rule.getUpdateDate() == null || rule.getUpdateDate().getTime() + rule.getTaktTimeWork() < new Date().getTime()) {
|
|
|
-
|
|
|
- ControllerRule controllerRule = new ControllerRule();
|
|
|
- controllerRule.setId(rule.getId().longValue());
|
|
|
- controllerRule.setLastState("1");
|
|
|
- controllerRule.setUpdateTime(new Date());
|
|
|
- rules.add(controllerRule);
|
|
|
- makeContent(rule, object, maps);
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
- if (rule.getUpdateDate() == null || rule.getUpdateDate().getTime() + rule.getTaktTimeUnWork() < new Date().getTime()) {
|
|
|
-
|
|
|
- ControllerRule controllerRule = new ControllerRule();
|
|
|
- controllerRule.setId(rule.getId().longValue());
|
|
|
- controllerRule.setLastState("1");
|
|
|
- controllerRule.setUpdateTime(new Date());
|
|
|
- rules.add(controllerRule);
|
|
|
- makeContent(rule, object, maps);
|
|
|
+ try {
|
|
|
+ Map<String, Object> object = null;
|
|
|
+ try {
|
|
|
+ object = runSql(rule.getRuleSql(), rule.getParams());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("规则出错{}", rule.getRuleName() + rule.getRuleSql() + e.getMessage());
|
|
|
+ }
|
|
|
+ System.out.println(rule.getRuleSql());
|
|
|
+ if (object != null && !object.isEmpty() && "1".equals(rule.getLastState())) {
|
|
|
+
|
|
|
+ if (DateUtil.isIn(new Date(), 9, 18)) {
|
|
|
+
|
|
|
+ if (rule.getUpdateDate() == null || rule.getUpdateDate().getTime() + rule.getTaktTimeWork() < new Date().getTime()) {
|
|
|
+
|
|
|
+ ControllerRule controllerRule = new ControllerRule();
|
|
|
+ controllerRule.setId(rule.getId().longValue());
|
|
|
+ controllerRule.setLastState("1");
|
|
|
+ controllerRule.setUpdateTime(new Date());
|
|
|
+ rules.add(controllerRule);
|
|
|
+ makeContent(rule, object, maps);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (rule.getUpdateDate() == null || rule.getUpdateDate().getTime() + rule.getTaktTimeUnWork() < new Date().getTime()) {
|
|
|
+
|
|
|
+ ControllerRule controllerRule = new ControllerRule();
|
|
|
+ controllerRule.setId(rule.getId().longValue());
|
|
|
+ controllerRule.setLastState("1");
|
|
|
+ controllerRule.setUpdateTime(new Date());
|
|
|
+ rules.add(controllerRule);
|
|
|
+ makeContent(rule, object, maps);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (object == null && "1".equals(rule.getLastState())) {
|
|
|
+
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", rule.getId().toString());
|
|
|
+ String res = rule.getRuleName() + "恢复正常";
|
|
|
+ map.put("res", res);
|
|
|
+ ControllerRule controllerRule = new ControllerRule();
|
|
|
+ controllerRule.setId(rule.getId().longValue());
|
|
|
+ controllerRule.setLastState("0");
|
|
|
+ controllerRule.setUpdateTime(new Date());
|
|
|
+ rules.add(controllerRule);
|
|
|
+ makeContent2(rule, map, maps);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("出现未知异常{}",e.getMessage());
|
|
|
}
|
|
|
- if (object == null && "1".equals(rule.getLastState())) {
|
|
|
-
|
|
|
- HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("id", rule.getId().toString());
|
|
|
- String res = rule.getRuleName() + "恢复正常";
|
|
|
- map.put("res", res);
|
|
|
- ControllerRule controllerRule = new ControllerRule();
|
|
|
- controllerRule.setId(rule.getId().longValue());
|
|
|
- controllerRule.setLastState("0");
|
|
|
- controllerRule.setUpdateTime(new Date());
|
|
|
- rules.add(controllerRule);
|
|
|
- makeContent2(rule, map, maps);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
if (!maps.isEmpty()) {
|