#include "CAiAlarmMsgInfo.h" #include #include "CAlarmDataCollect.h" #include CAiAlarmMsgInfo::CAiAlarmMsgInfo() { logic_state = E_AiALM_IALS_NORMAL; domain_id = -1; priority = -1; time_stamp = 1000; uuid_base64 = QString(); content = QString(); disposal_plan = QString(); raw_alm_uuid.clear(); priorityOrder = -1; deleteFlag = false; brokenFlag = false; releaseFlag = false; m_needVideoAlm =false; } CAiAlarmMsgInfo::CAiAlarmMsgInfo(const CAiAlarmMsgInfo &other) { logic_state = other.logic_state; domain_id = other.domain_id; time_stamp = other.time_stamp; uuid_base64 = other.uuid_base64; content = other.content; disposal_plan = other.disposal_plan; raw_alm_uuid = other.raw_alm_uuid; priorityOrder = other.priorityOrder; deleteFlag = other.deleteFlag; brokenFlag = other.brokenFlag; releaseFlag = other.releaseFlag; m_needVideoAlm = other.m_needVideoAlm; } void CAiAlarmMsgInfo::initialize(const iot_idl::SIntelliAlmInfo &alarmInfo) { logic_state = (E_AiALARM_LOGICSTATE)alarmInfo.logic_state(); domain_id = alarmInfo.domain_id(); priority = alarmInfo.priority(); time_stamp = alarmInfo.time_stamp(); uuid_base64 = QString::fromStdString(alarmInfo.uuid_base64()); content = QString::fromStdString(alarmInfo.content()); disposal_plan = QString::fromStdString(alarmInfo.disposal_plan()); raw_alm_uuid.clear(); //< 关联的原始告警uuid for(int x(0); x < alarmInfo.raw_alm_uuid_size(); x++) { raw_alm_uuid.append(QString::fromStdString(alarmInfo.raw_alm_uuid(x))); } priorityOrder = -1; if(logic_state == E_AIALM_IALS_DELETED) { deleteFlag = true; }else { deleteFlag = false; } if(logic_state == E_AIALM_IALS_BROKEN) { brokenFlag = true; }else { brokenFlag = false; } releaseFlag = false; m_needVideoAlm =false; } bool CAiAlarmMsgInfo::ailessThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey) { switch (sortkey) { case E_SORT_PRIORITY: if(priority > info->priority) { return true; }else if(priority < info->priority) { return false; }else { if(time_stamp < info->time_stamp) { return true; } return false; } break; case E_SORT_TIME: if(time_stamp < info->time_stamp) { return true; }else if(time_stamp > info->time_stamp) { return false; }else { if(priority > info->priority) { return true; } return false; } break; case E_SORT_LOCATION: return false; break; case E_SORT_REGION: return false; break; case E_SORT_TYPE: return false; break; case E_SORT_CONTENT: if(content.isEmpty() && info->content.isEmpty()) { return true; } else if(content.isEmpty() && (!info->content.isEmpty())) { return true; } else if((!content.isEmpty()) && info->content.isEmpty()) { return false; } else if(content < info->content) { return true; } else if(content > info->content) { return false; } else { if(time_stamp < info->time_stamp) { return true; } return false; } break; case E_SORT_LOGICSTATE: return false; case E_SORT_ALM_STATE: return false; break; default: break; } return false; } bool CAiAlarmMsgInfo::aimoreThan(const AlarmMsgPtr &info, E_ALARM_SORTKEY sortkey) { switch (sortkey) { case E_SORT_PRIORITY: if(priority < info->priority) { return true; }else if(priority > info->priority) { return false; }else { if(time_stamp > info->time_stamp) { return true; } return false; } break; case E_SORT_TIME: if(time_stamp > info->time_stamp) { return true; }else if(time_stamp < info->time_stamp) { return false; }else { if(priority < info->priority) { return true; } return false; } break; case E_SORT_LOCATION: return true; break; case E_SORT_REGION: return true; break; case E_SORT_TYPE: return true; break; case E_SORT_CONTENT: if(content.isEmpty() && info->content.isEmpty()) { return false; } else if(content.isEmpty() && (!info->content.isEmpty())) { return false; } else if((!content.isEmpty()) && info->content.isEmpty()) { return true; } else if(content < info->content) { return false; } else if(content > info->content) { return true; } else { if(time_stamp > info->time_stamp) { return true; } return false; } break; case E_SORT_LOGICSTATE: return true; break; case E_SORT_ALM_STATE: return true; break; default: break; } return false; } //< 智能告警-前者小[不包含的字段进行比较排序] bool CAiAlarmMsgInfo::ailessThan(const AiAlarmMsgPtr &info, E_ALARM_SORTKEY sortkey) { switch (sortkey) { case E_SORT_PRIORITY: if(priority > info->priority) { return true; }else if(priority < info->priority) { return false; }else { if(time_stamp < info->time_stamp) { return true; } return false; } break; case E_SORT_TIME: if(time_stamp < info->time_stamp) { return true; }else if(time_stamp > info->time_stamp) { return false; }else { if(priority > info->priority) { return true; } return false; } break; case E_SORT_LOCATION: return true; break; case E_SORT_REGION: return true; break; case E_SORT_TYPE: return true; break; case E_SORT_CONTENT: if(content.isEmpty() && info->content.isEmpty()) { return true; } else if(content.isEmpty() && (!info->content.isEmpty())) { return true; } else if((!content.isEmpty()) && info->content.isEmpty()) { return false; } else if(content < info->content) { return true; } else if(content > info->content) { return false; } else { if(time_stamp < info->time_stamp) { return true; } return false; } break; case E_SORT_LOGICSTATE: return true; case E_SORT_ALM_STATE: return true; break; default: break; } return false; } bool CAiAlarmMsgInfo::aimoreThan(const AiAlarmMsgPtr &info, E_ALARM_SORTKEY sortkey) { switch (sortkey) { case E_SORT_PRIORITY: if(priority < info->priority) { return true; }else if(priority > info->priority) { return false; }else { if(time_stamp > info->time_stamp) { return true; } return false; } break; case E_SORT_TIME: if(time_stamp > info->time_stamp) { return true; }else if(time_stamp < info->time_stamp) { return false; }else { if(priority < info->priority) { return true; } return false; } break; case E_SORT_LOCATION: return false; break; case E_SORT_REGION: return false; break; case E_SORT_TYPE: return false; break; case E_SORT_CONTENT: if(content.isEmpty() && info->content.isEmpty()) { return false; } else if(content.isEmpty() && (!info->content.isEmpty())) { return false; } else if((!content.isEmpty()) && info->content.isEmpty()) { return true; } else if(content < info->content) { return false; } else if(content > info->content) { return true; } else { if(time_stamp > info->time_stamp) { return true; } return false; } break; case E_SORT_LOGICSTATE: return false; break; case E_SORT_ALM_STATE: return false; break; default: break; } return false; } bool operator==(const CAiAlarmMsgInfo &source, const CAiAlarmMsgInfo &target) { if(source.uuid_base64 == target.uuid_base64) { return true; } return false; // //替换式告警且车站、测点ID相同 // if((0 == source.if_water_alm) && (0 == target.if_water_alm) && (source.location_id == target.location_id) && (source.key_id_tag == target.key_id_tag)) // { // return true; // } // //流水账告警且时标、告警内容相同 // else if((1 == source.if_water_alm) && (1 == target.if_water_alm) && (source.location_id == target.location_id) && (source.time_stamp == target.time_stamp) && (source.content == target.content)) // { // return true; // } // return false; }