|
|
@@ -28,18 +28,32 @@ public class TimerCheckWarnPlanMgr {
|
|
|
return DBMgrProxy.getInstance().applyXXXApi(OrdWarnPlanRulesDBService.class);
|
|
|
}
|
|
|
|
|
|
- public static void checkWarnPlanByMinute(int curClock, int curMinute){
|
|
|
+ public static void checkWarnPlanByFrequency(int curClock, int curMinute, String frequencyUnit){
|
|
|
+ int curTmForCompare = 1;
|
|
|
+ String tmFiler = "";
|
|
|
+ if (FrequencyUnit.MIN.equals(frequencyUnit)){
|
|
|
+ curTmForCompare = curMinute;
|
|
|
+ String.format("and %s <= %d "
|
|
|
+ , OrdWarnPlanInfoTable.W_INFO.FREQUENCY
|
|
|
+ , curTmForCompare);
|
|
|
+ }else if (FrequencyUnit.HOUR.equals(frequencyUnit)){
|
|
|
+ curTmForCompare = curClock;
|
|
|
+ String.format("and %s <= %d "
|
|
|
+ , OrdWarnPlanInfoTable.W_INFO.FREQUENCY
|
|
|
+ , curTmForCompare);
|
|
|
+ }
|
|
|
+
|
|
|
long thisDayBegin = TimeTool.getTodayBeginUTC();
|
|
|
+ final int preMonthInYear = TimeTool.getYearIndex(TimeTool.getTimeChgMonth(thisDayBegin, -1));//前一月所在的年份
|
|
|
+ final int preDayInMonth = TimeTool.getMonthIndex(thisDayBegin-TimeTool.MS_ONE_DAY);//前一日所在的月份
|
|
|
Map<String, Object> mapSel = getThisDBService().totalWillAnalysisCounts(new HashMap<String, Object>(){{
|
|
|
put(OrdWarnPlanInfoTable.R_INFO.STATUS, CommFieldStatus.ENABLE);
|
|
|
put(OrdWarnPlanInfoTable.R_INFO.DISUSED, 0);
|
|
|
- put(OrdWarnPlanInfoTable.R_INFO.FREQUENCY_UNIT, FrequencyUnit.MIN);
|
|
|
+ put(OrdWarnPlanInfoTable.R_INFO.FREQUENCY_UNIT, frequencyUnit);
|
|
|
}}
|
|
|
, null
|
|
|
, ""
|
|
|
- , String.format("and %s <= %d "
|
|
|
- , OrdWarnPlanInfoTable.W_INFO.FREQUENCY
|
|
|
- , curMinute));
|
|
|
+ , tmFiler);
|
|
|
|
|
|
if (mapSel != null && mapSel.size() > 0){
|
|
|
CommTotalMinMax oTotal = FastJsonUtil.map2Obj(mapSel, CommTotalMinMax.class, true);
|
|
|
@@ -75,24 +89,42 @@ public class TimerCheckWarnPlanMgr {
|
|
|
if (oItem.getId() > curIndex)
|
|
|
curIndex = oItem.getId();
|
|
|
|
|
|
+ if (!FrequencyUnit.MIN.equals(frequencyUnit) && !FrequencyUnit.HOUR.equals(frequencyUnit)){
|
|
|
+ curTmForCompare = oItem.getFrequency();
|
|
|
+ }
|
|
|
+
|
|
|
if (oItem.getStatus() != CommFieldStatus.ENABLE
|
|
|
|| oItem.getFrequency() <= 0
|
|
|
- || !FrequencyUnit.MIN.equals(oItem.getFrequencyUnit())
|
|
|
- || oItem.getFrequency() > curMinute
|
|
|
- || (curMinute%oItem.getFrequency() != 0))
|
|
|
+ || !frequencyUnit.equals(oItem.getFrequencyUnit())
|
|
|
+ || oItem.getFrequency() > curTmForCompare
|
|
|
+ || (curTmForCompare%oItem.getFrequency() != 0))
|
|
|
continue;
|
|
|
|
|
|
//if (DoPeriodUnit.HOUR.equals(oItem.getDoPeriodUnit())){
|
|
|
if (oItem.getCycleTriggerUpperTimes() >= 0){
|
|
|
if (oItem.getCycleTriggerUpperTimes() == 0)
|
|
|
continue;
|
|
|
- if (oItem.getLastEventTime() >= thisDayBegin
|
|
|
- && oItem.getCycleTriggerTimes() >= oItem.getCycleTriggerUpperTimes()){
|
|
|
- continue;
|
|
|
+ if (FrequencyUnit.MIN.equals(frequencyUnit) || FrequencyUnit.HOUR.equals(frequencyUnit)){
|
|
|
+ if (oItem.getLastEventTime() >= thisDayBegin
|
|
|
+ && oItem.getCycleTriggerTimes() >= oItem.getCycleTriggerUpperTimes()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if (FrequencyUnit.DAY.equals(frequencyUnit) && oItem.getLastEventTime() > 0L){
|
|
|
+ int lastEventTmInMonth = TimeTool.getMonthIndex(oItem.getLastEventTime());
|
|
|
+ if (lastEventTmInMonth == preDayInMonth
|
|
|
+ && oItem.getCycleTriggerTimes() >= oItem.getCycleTriggerUpperTimes()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if (FrequencyUnit.MONTH.equals(frequencyUnit) && oItem.getLastEventTime() > 0L){
|
|
|
+ int lastEventTmInYear = TimeTool.getYearIndex(oItem.getLastEventTime());
|
|
|
+ if (lastEventTmInYear == preMonthInYear
|
|
|
+ && oItem.getCycleTriggerTimes() >= oItem.getCycleTriggerUpperTimes()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (curClock < oItem.getMinStarts())
|
|
|
+ if (DoPeriodUnit.HOUR.equals(oItem.getDoPeriodUnit()) && curClock < oItem.getMinStarts())
|
|
|
continue;
|
|
|
//}
|
|
|
AsyncTaskQueueMgr.getInstance().postTaskData(TaskQueueDataTypeEx.ASYNC_ANALY_WARN_PLAN, new OrdWarnPlanWillDo(oItem.getUid(), oItem.getObjSrc()));
|