|
|
@@ -1,5 +1,7 @@
|
|
|
package com.shkpr.service.warncore.bizhandler;
|
|
|
|
|
|
+import com.global.base.log.LogLevelFlag;
|
|
|
+import com.global.base.log.LogPrintMgr;
|
|
|
import com.global.base.tools.CastUtil;
|
|
|
import com.global.base.tools.FastJsonUtil;
|
|
|
import com.shkpr.service.warncore.commtools.CommTool;
|
|
|
@@ -7,6 +9,7 @@ import com.shkpr.service.warncore.commtools.TimeTool;
|
|
|
import com.shkpr.service.warncore.constants.CommFieldStatus;
|
|
|
import com.shkpr.service.warncore.constants.EventAction;
|
|
|
import com.shkpr.service.warncore.constants.FrequencyUnit;
|
|
|
+import com.shkpr.service.warncore.constants.LogFlagBusiType;
|
|
|
import com.shkpr.service.warncore.dbdao.DBMgrProxy;
|
|
|
import com.shkpr.service.warncore.dbdao.services.intef.OrdWarnPlanInfoDBService;
|
|
|
import com.shkpr.service.warncore.dbdao.services.intef.OrdWarnPlanRulesDBService;
|
|
|
@@ -15,6 +18,7 @@ import com.shkpr.service.warncore.dto.*;
|
|
|
import com.shkpr.service.warncore.jsonbean.JPGetRegionData;
|
|
|
import com.shkpr.service.warncore.jsonbean.JPGetRegionReport;
|
|
|
import com.shkpr.service.warncore.jsonbean.JPGetRegionReportItem;
|
|
|
+import com.shkpr.service.warncore.jsonbean.JPOrdWarnEventInfo;
|
|
|
import com.shkpr.service.warncore.services.ServiceMgrProxy;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -26,6 +30,7 @@ import java.util.*;
|
|
|
public class SiteDataWarnHandler {
|
|
|
private static int COMPARE_TURE = 1;
|
|
|
private static int COMPARE_FALSE = 0;
|
|
|
+ private final static String mStrClassName = "SiteDataWarnHandler";
|
|
|
private static OrdWarnPlanInfoDBService getWarnPlanInfoDBService(){
|
|
|
return DBMgrProxy.getInstance().applyXXXApi(OrdWarnPlanInfoDBService.class);
|
|
|
}
|
|
|
@@ -42,7 +47,19 @@ public class SiteDataWarnHandler {
|
|
|
put(OrdWarnPlanInfoTable.R_INFO.UNIQUE_ID, planDetail.getUid());
|
|
|
put(OrdWarnPlanInfoTable.R_INFO.VERSION, planDetail.getVersion());
|
|
|
}}, null, "") <= 0){
|
|
|
- step = "Plan is changed,do analysis next time";
|
|
|
+ step = "Plan is changed,do analysis next time.";
|
|
|
+ code = ResponseCode.RESULT_BAD;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean noBindDev = true;
|
|
|
+ for (OrdWarnPlanRules ruleItem:rules){
|
|
|
+ if (!StringUtils.isEmpty(ruleItem.getDevId())){
|
|
|
+ noBindDev = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (noBindDev){
|
|
|
+ step = "No binder device,do analysis next time";
|
|
|
code = ResponseCode.RESULT_BAD;
|
|
|
}
|
|
|
|
|
|
@@ -61,6 +78,8 @@ public class SiteDataWarnHandler {
|
|
|
}
|
|
|
|
|
|
OrdWarnPlanTempStep thisStepTempRes = new OrdWarnPlanTempStep(planDetail);
|
|
|
+ thisStepTempRes.setLastAnalyTime(curUTCTm);
|
|
|
+ thisStepTempRes.setCompareTimes(planDetail.getCompareTimes()+1);
|
|
|
do {
|
|
|
if (code != ResponseCode.RESULT_NORMAL)
|
|
|
break;
|
|
|
@@ -82,7 +101,7 @@ public class SiteDataWarnHandler {
|
|
|
}
|
|
|
}
|
|
|
if (findStartClock < 0){
|
|
|
- step = "Not in time range,do analysis next time";
|
|
|
+ step = "Now out in time range,do analysis next time";
|
|
|
code = ResponseCode.RESULT_BAD;
|
|
|
break;
|
|
|
}
|
|
|
@@ -114,7 +133,7 @@ public class SiteDataWarnHandler {
|
|
|
}
|
|
|
|
|
|
if (queryBeginUTC > queryEndUTC){
|
|
|
- step = "Time is invalid,do analysis next time";
|
|
|
+ step = "Time is invalid,do analysis next time.";
|
|
|
code = ResponseCode.RESULT_BAD;
|
|
|
break;
|
|
|
}
|
|
|
@@ -127,7 +146,7 @@ public class SiteDataWarnHandler {
|
|
|
thisStepTempRes.setDayTriggerTimes(0);
|
|
|
if (planDetail.getDayTriggerUpperTimes() > 0
|
|
|
&& thisStepTempRes.getDayTriggerTimes() >= planDetail.getDayTriggerUpperTimes()){//触发事件达到最大个数
|
|
|
- step = "Event arrive at max limit,stop analysis for today";
|
|
|
+ step = "Event arrive at max limit,stop analysis for today.";
|
|
|
code = ResponseCode.RESULT_BAD;
|
|
|
break;
|
|
|
}
|
|
|
@@ -148,7 +167,13 @@ public class SiteDataWarnHandler {
|
|
|
}
|
|
|
}
|
|
|
}else {//单独更新预警方案的分析时间、次数、说明
|
|
|
+ thisStepTempRes.setLastAnalyExplain(step);
|
|
|
+ Map<String, Object> updatePlan = thisStepTempRes.genUpdatePlan();
|
|
|
+ updatePlan.put(OrdWarnPlanInfoTable.W_INFO.UPDATE_TIME, System.currentTimeMillis());
|
|
|
}
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, LogFlagBusiType.BUSI_SITE_DATA_WARN_HANDLE.toStrValue(), mStrClassName
|
|
|
+ , String.format("Handler Site Data Plan:{planId=%s} {step=%s} {%s}...",
|
|
|
+ planDetail.getUid(), step, code.toString()));
|
|
|
return code;
|
|
|
}
|
|
|
|
|
|
@@ -156,10 +181,10 @@ public class SiteDataWarnHandler {
|
|
|
private static ResponseCode analysisDataForRealBySet(OrdWarnPlanDetail planDetail, List<OrdWarnPlanRules> rules, OrdWarnPlanTempStep thisTempStep){
|
|
|
String step = "Start to deep analysis";
|
|
|
ResponseCode code = ResponseCode.RESULT_NORMAL;
|
|
|
- long curTime = TimeTool.getCurMsUTC();
|
|
|
final String siteId = rules.get(0).getObjId();
|
|
|
SiteSampleDataResult siteSampleData = null;
|
|
|
Map<String, Long> eventId2NewEndUTC = new HashMap<>();//需要更新预警事件的样本截止时间
|
|
|
+ List<Map<String, Object>> eventToGen = new ArrayList<>();
|
|
|
do {
|
|
|
JPGetRegionData jpParam = new JPGetRegionData();
|
|
|
jpParam.setTotal(1);
|
|
|
@@ -238,6 +263,7 @@ public class SiteDataWarnHandler {
|
|
|
if (!matched){//本次没有匹配成功
|
|
|
thisTempStep.setLastCompareSampleTime(sampleRecordTm);
|
|
|
thisTempStep.setLastCompareSampleResult(COMPARE_FALSE);
|
|
|
+ thisTempStep.setLastCompareSampleExplain("This is not matched.");
|
|
|
thisTempStep.setFirstMatchSampleTime(0L);
|
|
|
thisTempStep.setLastEventId("");
|
|
|
thisTempStep.setLastEventTime(0L);
|
|
|
@@ -248,6 +274,7 @@ public class SiteDataWarnHandler {
|
|
|
thisTempStep.setLastCompareSampleTime(sampleRecordTm);
|
|
|
thisTempStep.setLastCompareSampleResult(COMPARE_TURE);
|
|
|
thisTempStep.setFirstMatchSampleTime(sampleRecordTm);
|
|
|
+ thisTempStep.setLastCompareSampleExplain("This is matched, but last is not matched.");
|
|
|
continue;
|
|
|
}//上一次匹配成功了进入下一步
|
|
|
|
|
|
@@ -259,6 +286,7 @@ public class SiteDataWarnHandler {
|
|
|
thisTempStep.setFirstMatchSampleTime(sampleRecordTm);
|
|
|
thisTempStep.setLastEventId("");
|
|
|
thisTempStep.setLastEventTime(0L);
|
|
|
+ thisTempStep.setLastCompareSampleExplain("This is matched, but two matched sample is too distance.");
|
|
|
continue;
|
|
|
}//两个最近匹配样本间隔很近,可认为是持续匹配,则进入下一步
|
|
|
|
|
|
@@ -268,6 +296,7 @@ public class SiteDataWarnHandler {
|
|
|
thisTempStep.setFirstMatchSampleTime(sampleRecordTm);
|
|
|
thisTempStep.setLastEventId("");
|
|
|
thisTempStep.setLastEventTime(0L);
|
|
|
+ thisTempStep.setLastCompareSampleExplain("This is matched, but last is not today.");
|
|
|
continue;
|
|
|
}//上一个匹配样本是当天的,则进入下一步
|
|
|
|
|
|
@@ -276,14 +305,19 @@ public class SiteDataWarnHandler {
|
|
|
if (matchLen < triggerEventPeriodSwitch){//还得持续等待,达不到触发事件的累计时长
|
|
|
thisTempStep.setLastCompareSampleTime(sampleRecordTm);
|
|
|
thisTempStep.setLastCompareSampleResult(COMPARE_TURE);
|
|
|
+ thisTempStep.setLastCompareSampleExplain("This is matched, but need wait the next matched.");
|
|
|
if (thisTempStep.getFirstMatchSampleTime() <= 0)
|
|
|
thisTempStep.setFirstMatchSampleTime(sampleRecordTm);
|
|
|
}else {//触发一个新的事件
|
|
|
thisTempStep.setLastCompareSampleTime(sampleRecordTm);
|
|
|
thisTempStep.setLastCompareSampleResult(COMPARE_TURE);
|
|
|
- thisTempStep.setLastEventId("新事件ID");
|
|
|
- thisTempStep.setLastEventTime(curTime);
|
|
|
+ thisTempStep.setLastEventTime(TimeTool.getCurMsUTC());
|
|
|
thisTempStep.setLastEventAction(EventAction.DOING);
|
|
|
+ thisTempStep.setLastCompareSampleExplain("This is matched, and will gen event.");
|
|
|
+
|
|
|
+ JPOrdWarnEventInfo newEvent = new JPOrdWarnEventInfo(planDetail, rules, thisTempStep, thisTempStep.getLastEventTime());
|
|
|
+ eventToGen.add(newEvent.genNewMapData());
|
|
|
+ thisTempStep.setLastEventId(newEvent.getUid());
|
|
|
thisTempStep.setDayTriggerTimes(thisTempStep.getDayTriggerTimes()+1);
|
|
|
//[!!!]do not change the FirstMatchSampleTime[!!!]
|
|
|
}
|
|
|
@@ -294,14 +328,26 @@ public class SiteDataWarnHandler {
|
|
|
thisTempStep.setFirstMatchSampleTime(sampleRecordTm);
|
|
|
thisTempStep.setLastEventId("");
|
|
|
thisTempStep.setLastEventTime(0L);
|
|
|
+ thisTempStep.setLastCompareSampleExplain("This is matched, but need to wait the next matched.");
|
|
|
}else {//之前的预警事件未处理,则更新预警事件的样本截止时刻
|
|
|
thisTempStep.setLastCompareSampleTime(sampleRecordTm);
|
|
|
thisTempStep.setLastCompareSampleResult(COMPARE_TURE);
|
|
|
eventId2NewEndUTC.put(thisTempStep.getLastEventId(), sampleRecordTm);
|
|
|
+ thisTempStep.setLastCompareSampleExplain("This is matched, but need to merge the last event.");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}while (false);
|
|
|
+
|
|
|
+ thisTempStep.setLastAnalyExplain(step);
|
|
|
+ Map<String, Object> updatePlan = thisTempStep.genUpdatePlan();
|
|
|
+ updatePlan.put(OrdWarnPlanInfoTable.W_INFO.UPDATE_TIME, System.currentTimeMillis());
|
|
|
+ //将eventId2NewEndUTC进行更新
|
|
|
+ //将eventToGen进行插入
|
|
|
+
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, LogFlagBusiType.BUSI_SITE_DATA_WARN_HANDLE.toStrValue(), mStrClassName
|
|
|
+ , String.format("Analysis Data For Real By Set:{planId=%s,siteId=%s} {step=%s} {%s}...",
|
|
|
+ planDetail.getUid(), siteId, step, code.toString()));
|
|
|
return code;
|
|
|
}
|
|
|
|