|
@@ -235,6 +235,7 @@ public class SiteDataWarnHandler {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ int maxDevCycle = 0, minDevCycle = 0;
|
|
|
int ruleStartClock = -1, ruleEndClock = -1;
|
|
int ruleStartClock = -1, ruleEndClock = -1;
|
|
|
OrdWarnPlanTempStep thisStepTempRes = new OrdWarnPlanTempStep(planDetail);
|
|
OrdWarnPlanTempStep thisStepTempRes = new OrdWarnPlanTempStep(planDetail);
|
|
|
thisStepTempRes.setLastAnalyTime(curUTCTm);
|
|
thisStepTempRes.setLastAnalyTime(curUTCTm);
|
|
@@ -245,6 +246,12 @@ public class SiteDataWarnHandler {
|
|
|
|
|
|
|
|
int findStartClock = -1;
|
|
int findStartClock = -1;
|
|
|
for (int i=rules.size()-1;i>=0;i--){
|
|
for (int i=rules.size()-1;i>=0;i--){
|
|
|
|
|
+ int thisDevCycle = rules.get(i).getDevCycle();
|
|
|
|
|
+ if (maxDevCycle <= 0 || thisDevCycle > maxDevCycle)
|
|
|
|
|
+ maxDevCycle = thisDevCycle;
|
|
|
|
|
+ if (minDevCycle <= 0 || thisDevCycle < minDevCycle)
|
|
|
|
|
+ minDevCycle = thisDevCycle;
|
|
|
|
|
+
|
|
|
if (curClock >= rules.get(i).getStarts() && curClock <= rules.get(i).getEnds()){
|
|
if (curClock >= rules.get(i).getStarts() && curClock <= rules.get(i).getEnds()){
|
|
|
findStartClock = rules.get(i).getStarts();
|
|
findStartClock = rules.get(i).getStarts();
|
|
|
ruleStartClock = findStartClock;
|
|
ruleStartClock = findStartClock;
|
|
@@ -256,7 +263,7 @@ public class SiteDataWarnHandler {
|
|
|
queryEndUTC = Math.min(TimeTool.convertDateStr2UTC(String.format("%s %02d:59:59", curDate, curClock))
|
|
queryEndUTC = Math.min(TimeTool.convertDateStr2UTC(String.format("%s %02d:59:59", curDate, curClock))
|
|
|
, TimeTool.convertDateStr2UTC(String.format("%s %02d:59:59", curDate, rules.get(i).getEnds())));
|
|
, TimeTool.convertDateStr2UTC(String.format("%s %02d:59:59", curDate, rules.get(i).getEnds())));
|
|
|
}
|
|
}
|
|
|
- break;
|
|
|
|
|
|
|
+ //break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (findStartClock < 0){
|
|
if (findStartClock < 0){
|
|
@@ -289,6 +296,13 @@ public class SiteDataWarnHandler {
|
|
|
if (thisStepTempRes.getLastCompareSampleTime() <= 0L){//从未分析过则重新计数
|
|
if (thisStepTempRes.getLastCompareSampleTime() <= 0L){//从未分析过则重新计数
|
|
|
thisStepTempRes.resetData();
|
|
thisStepTempRes.resetData();
|
|
|
}else {
|
|
}else {
|
|
|
|
|
+ if (FrequencyUnit.MIN.equals(planDetail.getFrequencyUnit())){
|
|
|
|
|
+ if (minDevCycle > 0 && ((thisStepTempRes.getLastCompareSampleTime()+TimeTool.MS_ONE_SEC*minDevCycle) > curUTCTm)){//设备的下一个采集数据还未到
|
|
|
|
|
+ step = "Dev next record not arrived,do analysis next time.";
|
|
|
|
|
+ code = ResponseCode.RESULT_BAD;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
int sampleClock = (int)((thisStepTempRes.getLastCompareSampleTime()/1000/60/60%24+8)%24);
|
|
int sampleClock = (int)((thisStepTempRes.getLastCompareSampleTime()/1000/60/60%24+8)%24);
|
|
|
if ((sampleClock >= ruleStartClock && sampleClock <= ruleEndClock)
|
|
if ((sampleClock >= ruleStartClock && sampleClock <= ruleEndClock)
|
|
|
|| ((sampleClock+1)%24) == ruleStartClock){
|
|
|| ((sampleClock+1)%24) == ruleStartClock){
|
|
@@ -306,6 +320,8 @@ public class SiteDataWarnHandler {
|
|
|
code = ResponseCode.RESULT_BAD;
|
|
code = ResponseCode.RESULT_BAD;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+ thisStepTempRes.setMaxDevCycle(maxDevCycle);
|
|
|
|
|
+ thisStepTempRes.setMinDevCycle(minDevCycle);
|
|
|
thisStepTempRes.setDoForTodayBefore(doForTodayBefore);
|
|
thisStepTempRes.setDoForTodayBefore(doForTodayBefore);
|
|
|
thisStepTempRes.setQueryBeginUTC(queryBeginUTC);
|
|
thisStepTempRes.setQueryBeginUTC(queryBeginUTC);
|
|
|
thisStepTempRes.setQueryEndUTC(queryEndUTC);
|
|
thisStepTempRes.setQueryEndUTC(queryEndUTC);
|
|
@@ -368,7 +384,6 @@ public class SiteDataWarnHandler {
|
|
|
private static ResponseCode analysisDataForRealBySet(OrdWarnPlanDetail planDetail, List<OrdWarnPlanRules> rules, OrdWarnPlanTempStep thisTempStep){
|
|
private static ResponseCode analysisDataForRealBySet(OrdWarnPlanDetail planDetail, List<OrdWarnPlanRules> rules, OrdWarnPlanTempStep thisTempStep){
|
|
|
String step = "Start to deep analysis";
|
|
String step = "Start to deep analysis";
|
|
|
ResponseCode code = ResponseCode.RESULT_NORMAL;
|
|
ResponseCode code = ResponseCode.RESULT_NORMAL;
|
|
|
- int maxDevCycle = 0;//最大设备采集频率(单位:秒)
|
|
|
|
|
final String siteId = rules.get(0).getObjId();
|
|
final String siteId = rules.get(0).getObjId();
|
|
|
SiteSampleDataResult siteSampleData = null;
|
|
SiteSampleDataResult siteSampleData = null;
|
|
|
Map<String, Long> oldEvent2EndUTC = new HashMap<>();//需要更新预警事件的样本截止时间
|
|
Map<String, Long> oldEvent2EndUTC = new HashMap<>();//需要更新预警事件的样本截止时间
|
|
@@ -423,11 +438,9 @@ public class SiteDataWarnHandler {
|
|
|
OrdWarnPlanRules findRule = null;
|
|
OrdWarnPlanRules findRule = null;
|
|
|
int sampleRecordClock = (int)((sampleRecordTm/1000/60/60%24+8)%24);
|
|
int sampleRecordClock = (int)((sampleRecordTm/1000/60/60%24+8)%24);
|
|
|
for (OrdWarnPlanRules ruleItem:rules){
|
|
for (OrdWarnPlanRules ruleItem:rules){
|
|
|
- if (ruleItem.getDevCycle() > maxDevCycle)
|
|
|
|
|
- maxDevCycle = ruleItem.getDevCycle();
|
|
|
|
|
if (sampleRecordClock <= ruleItem.getEnds() && sampleRecordClock >= ruleItem.getStarts()){
|
|
if (sampleRecordClock <= ruleItem.getEnds() && sampleRecordClock >= ruleItem.getStarts()){
|
|
|
findRule = ruleItem;
|
|
findRule = ruleItem;
|
|
|
- //break;
|
|
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (findRule == null)
|
|
if (findRule == null)
|
|
@@ -485,7 +498,7 @@ public class SiteDataWarnHandler {
|
|
|
}//上一次匹配成功了进入下一步
|
|
}//上一次匹配成功了进入下一步
|
|
|
|
|
|
|
|
long triggerEventPeriodSwitch = planDetail.getFrequency()*planDetail.getThreshold()*TimeTool.MS_ONE_MIN;//触发预警事件的最小时长(单位:毫秒)
|
|
long triggerEventPeriodSwitch = planDetail.getFrequency()*planDetail.getThreshold()*TimeTool.MS_ONE_MIN;//触发预警事件的最小时长(单位:毫秒)
|
|
|
- long tooDistanceMs = Math.max(maxDevCycle*TimeTool.MS_ONE_SEC, triggerEventPeriodSwitch);
|
|
|
|
|
|
|
+ long tooDistanceMs = Math.max(thisTempStep.getMaxDevCycle()*TimeTool.MS_ONE_SEC, triggerEventPeriodSwitch);
|
|
|
long diffMatch = sampleRecordTm-thisTempStep.getLastCompareSampleTime();//两个最近匹配样本之间的采集时间差(单位:毫秒)
|
|
long diffMatch = sampleRecordTm-thisTempStep.getLastCompareSampleTime();//两个最近匹配样本之间的采集时间差(单位:毫秒)
|
|
|
if (diffMatch > tooDistanceMs){//两个最近匹配样本间缺失的数据太多、或跨了天、或跨了时段,可认为重新计数
|
|
if (diffMatch > tooDistanceMs){//两个最近匹配样本间缺失的数据太多、或跨了天、或跨了时段,可认为重新计数
|
|
|
step = "This is matched, but two matched sample is too distance.";
|
|
step = "This is matched, but two matched sample is too distance.";
|