Authored by qinchao

格式调整

... ... @@ -66,21 +66,33 @@ public class MonitorAlarmServiceImpl {
List<String> idcList = JSONArray.parseArray(idcs, String.class);
int pageSize = req.getPageSize();
int currentPage = req.getCurrentPage() - 1;
String querySql = "SELECT sms_content, info, send_status,type,idc FROM monitor_alarm WHERE event = 'alarm' ";
String countSql = "SELECT COUNT(sms_content) FROM monitor_alarm WHERE event = 'alarm' ";
StringBuilder conditionBuilder = new StringBuilder(" ");
if (CollectionUtils.isEmpty(idcList)) {//默认查询所有的
conditionBuilder.append(" and type != 'work_system' ");
}else{
String s = "";
String whereSql= " WHERE event = 'alarm' and type != 'work_system' ";
StringBuilder conditionBuilder = new StringBuilder();
if (!CollectionUtils.isEmpty(idcList)) {
for(String item : idcList ){
s = s.concat("idc=\'").concat(item).concat("\'").concat(" or ");
if(conditionBuilder.length()>0){
conditionBuilder.append(" or ");
}
conditionBuilder.append(" idc='").append(item).append("' ");
}
s = StringUtils.stripEnd(s, " or ");
conditionBuilder.append(" and ( ").append(s).append(" ) ");
if(conditionBuilder.length()>0){
conditionBuilder.insert(0," and ( ").append(" ) ");
whereSql += conditionBuilder.toString();
}
}
querySql += conditionBuilder.toString() + " ORDER BY time DESC LIMIT " + pageSize + " OFFSET " + pageSize * currentPage;
countSql += conditionBuilder.toString();
String querySql = "SELECT sms_content, info, send_status,type,idc FROM monitor_alarm "
+whereSql
+ " ORDER BY time DESC LIMIT " + pageSize + " OFFSET " + pageSize * currentPage;
String countSql = "SELECT COUNT(sms_content) FROM monitor_alarm "
+whereSql;
LOGGER.info("getAlarmMsgPageList -- querySql is {} ", querySql);
QueryResult queryResult = influxDataReporter.queryResult(influxDBName, querySql, YOMO_MONITOR);
List<AlarmMsgModel> alarmMsgList = getAlarmMsgModelFromQR(queryResult);
... ...