Authored by jack-xue

Fix 2-5

@@ -10,6 +10,7 @@ import org.springframework.web.client.RestClientException; @@ -10,6 +10,7 @@ import org.springframework.web.client.RestClientException;
10 import org.springframework.web.client.RestTemplate; 10 import org.springframework.web.client.RestTemplate;
11 11
12 import javax.annotation.Resource; 12 import javax.annotation.Resource;
  13 +import java.util.Calendar;
13 14
14 /** 15 /**
15 * Created by jack on 2017/3/23. 16 * Created by jack on 2017/3/23.
@@ -47,18 +48,11 @@ public class BigdataAlarm { @@ -47,18 +48,11 @@ public class BigdataAlarm {
47 count = 0; 48 count = 0;
48 49
49 if (!checkResp(alarmData)) { 50 if (!checkResp(alarmData)) {
50 -  
51 alarm("WARN:-YOHOBUY实时监控系统:接口返回值异常"); 51 alarm("WARN:-YOHOBUY实时监控系统:接口返回值异常");
52 - }  
53 -  
54 - if (null == lastAlarmData) {  
55 -  
56 - lastAlarmData = alarmData;  
57 52
58 return; 53 return;
59 } 54 }
60 55
61 -  
62 //检查storm 56 //检查storm
63 if (!checkStorm(alarmData)) { 57 if (!checkStorm(alarmData)) {
64 alarm("YOHOBUY实时监控系统:storm数据没写入"); 58 alarm("YOHOBUY实时监控系统:storm数据没写入");
@@ -69,6 +63,10 @@ public class BigdataAlarm { @@ -69,6 +63,10 @@ public class BigdataAlarm {
69 alarm("YOHOBUY实时监控系统:订单从库不同步"); 63 alarm("YOHOBUY实时监控系统:订单从库不同步");
70 } 64 }
71 65
  66 + if (null != alarmData) {
  67 +
  68 + lastAlarmData = alarmData;
  69 + }
72 70
73 } catch (Exception e) { 71 } catch (Exception e) {
74 72
@@ -91,9 +89,13 @@ public class BigdataAlarm { @@ -91,9 +89,13 @@ public class BigdataAlarm {
91 } 89 }
92 90
93 public boolean checkStorm(AlarmData alarmData) { 91 public boolean checkStorm(AlarmData alarmData) {
  92 + //不参与比较
  93 + if (null == lastAlarmData) {
  94 + return true;
  95 + }
94 96
95 //storm未收到消息 97 //storm未收到消息
96 - if (alarmData.getToday().getUv() == lastAlarmData.getToday().getUv()) { 98 + if (alarmData.getToday().getUv() == lastAlarmData.getToday().getUv() && alarmData.getToday().getPv() == lastAlarmData.getToday().getPv()) {
97 99
98 return false; 100 return false;
99 } 101 }
@@ -103,14 +105,32 @@ public class BigdataAlarm { @@ -103,14 +105,32 @@ public class BigdataAlarm {
103 105
104 106
105 public boolean checkOrder(AlarmData alarmData) { 107 public boolean checkOrder(AlarmData alarmData) {
  108 + //不参与比较
  109 + if (null == lastAlarmData) {
  110 +
  111 + return true;
  112 + }
  113 +
  114 + //2点-5点 不检查
  115 + Calendar calendar = Calendar.getInstance();
  116 +
  117 + int hour = calendar.get(Calendar.HOUR_OF_DAY);
  118 +
  119 + if (hour >= 2 && hour <= 6) {
  120 +
  121 + return true;
  122 + }
  123 +
106 //订单数未变 124 //订单数未变
107 if (alarmData.getToday().getOrderCount() == lastAlarmData.getToday().getOrderCount()) { 125 if (alarmData.getToday().getOrderCount() == lastAlarmData.getToday().getOrderCount()) {
108 orderCount++; 126 orderCount++;
109 127
110 } else { 128 } else {
  129 +
111 orderCount = 0; 130 orderCount = 0;
112 } 131 }
113 132
  133 + //三次以上order一样
114 if (orderCount >= 3) { 134 if (orderCount >= 3) {
115 135
116 return false; 136 return false;
@@ -121,10 +141,10 @@ public class BigdataAlarm { @@ -121,10 +141,10 @@ public class BigdataAlarm {
121 141
122 public boolean checkResp(AlarmData alarmData) { 142 public boolean checkResp(AlarmData alarmData) {
123 if (null == alarmData || null == alarmData.getToday()) { 143 if (null == alarmData || null == alarmData.getToday()) {
  144 +
124 return false; 145 return false;
125 } 146 }
126 147
127 return true; 148 return true;
128 } 149 }
129 -  
130 } 150 }