Query q=session.createQuery("update AlarmsHeader set status=:status, startEpochMicrosecCleared=:startEpochMicrosecCleared ,lastEpochMicroSecCleared=:lastEpochMicroSecCleared where eventName=:eventName and reportingEntityName=:reportingEntityName and specificProblem =:specificProblem");\r
\r
q.setString("status",status);\r
- q.setDate("date",date);\r
\r
q.setString("startEpochMicrosecCleared",startEpochMicrosecCleared);\r
q.setString("lastEpochMicroSecCleared",lastEpochMicroSecCleared);\r
if (null == alarmsInformation) {\r
logger.error("alarmsInformation saveAlarmsInformation alarmsInformation is null!");\r
}\r
- logger.info("AlarmsInformationServiceImpl saveAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
Transaction tx = session.beginTransaction();\r
session.save(alarmsInformation);\r
tx.commit();\r
if (null == alarmsInformation) {\r
logger.error("alarmsInformation updateAlarmsInformation alarmsInformation is null!");\r
}\r
- logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
Transaction tx = session.beginTransaction();\r
session.update(alarmsInformation);\r
tx.commit();\r
try(Session session = getSession()){\r
StringBuffer hql = new StringBuffer("select count(*) from AlarmsInformation a where 1=1");\r
if (null == alarmsInformation) {\r
- logger.error("AlarmsInformationServiceImpl getAllCount alarmsInformation is null!");\r
}else {\r
if(null!=alarmsInformation.getName()) {\r
String ver=alarmsInformation.getName();\r
hql.append(" and a.startEpochMicrosec between :startTime and :endTime");\r
}\r
}\r
- logger.info("AlarmsInformationServiceImpl queryAlarmsInformation: alarmsInformation={}", alarmsInformation);\r
Query query = session.createQuery(hql.toString());\r
if(null!=alarmsInformation.getStartEpochMicroSec() || alarmsInformation.getLastEpochMicroSec()!= null) {\r
query.setString("startTime",alarmsInformation.getStartEpochMicroSec());\r
public List<AlarmsInformation> queryId(String[] id) {\r
try {\r
if(id.length==0) {\r
- logger.error("AlarmsInformationServiceImpl queryId is null!");\r
}\r
List<AlarmsInformation> list = new ArrayList<AlarmsInformation>();\r
Session session = getSession();\r
logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");\r
return "0";\r
}\r
- logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);\r
Transaction tx = session.beginTransaction();\r
session.save(performanceHeder);\r
tx.commit();\r
logger.error("PerformanceHeaderServiceImpl updatePerformanceHeader performanceHeder is null!");\r
return "0";\r
}\r
- logger.info("PerformanceHeaderServiceImpl updatePerformanceHeader: performanceHeder={}", performanceHeder);\r
Transaction tx = session.beginTransaction();\r
session.update(performanceHeder);\r
tx.commit();\r
try(Session session = getSession()){\r
StringBuffer hql = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");\r
if (null == performanceHeder) {\r
- logger.error("PerformanceHeaderServiceImpl getAllCount performanceHeder is null!");\r
return 0;\r
}else {\r
if(null!=performanceHeder.getVersion()) {\r
try(Session session = getSession()){\r
StringBuffer hql =new StringBuffer("from PerformanceHeader a where 1=1");\r
if (null == performanceHeder) {\r
- logger.error("PerformanceHeaderServiceImpl queryPerformanceHeader performanceHeder is null!");\r
return page;\r
}else {\r
if(null!=performanceHeder.getVersion()) {\r
hql.append(" and a.startEpochMicrosec between :startTime and :endTime ");\r
}\r
}\r
- logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHeder);\r
Query query = session.createQuery(hql.toString());\r
if(null!=performanceHeder.getStartEpochMicrosec() && null!=performanceHeder.getLastEpochMicroSec()) {\r
query.setString("startTime",performanceHeder.getStartEpochMicrosec()).setString("endTime",performanceHeder.getLastEpochMicroSec());\r
try(Session session = getSession()) {\r
List<PerformanceHeader> list = new ArrayList<PerformanceHeader>();\r
if(id.length==0) {\r
- logger.error("PerformanceHeaderServiceImpl queryId is null!");\r
return list;\r
}\r
Query query = session.createQuery("from PerformanceHeader a where a.eventName IN (:alist)");\r
public String savePerformanceInformation(PerformanceInformation performanceInformation) {\r
try(Session session = getSession()) {\r
if (null == performanceInformation) {\r
- logger.error("performanceInformation savePerformanceInformation performanceInformation is null!");\r
}\r
- logger.info("PerformanceInformationServiceImpl savePerformanceInformation: performanceInformation={}", performanceInformation);\r
Transaction tx = session.beginTransaction();\r
session.save(performanceInformation);\r
tx.commit();\r
public String updatePerformanceInformation(PerformanceInformation performanceInformation) {\r
try(Session session = getSession()) {\r
if (null == performanceInformation) {\r
- logger.error("performanceInformation updatePerformanceInformation performanceInformation is null!");\r
}\r
logger.info("PerformanceInformationServiceImpl updatePerformanceInformation: performanceInformation={}", performanceInformation);\r
Transaction tx = session.beginTransaction();\r
try(Session session = getSession()){\r
StringBuffer hql = new StringBuffer("select count(*) from PerformanceInformation a where 1=1");\r
if (null == performanceInformation) {\r
- logger.error("AlarmsInformationServiceImpl getAllCount performanceInformation is null!");\r
}else {\r
if(null!=performanceInformation.getName()) {\r
String ver=performanceInformation.getName();\r
try(Session session = getSession()){\r
StringBuffer hql =new StringBuffer("from PerformanceInformation a where 1=1 ");\r
if (null == performanceInformation) {\r
- logger.error("AlarmsInformationServiceImpl queryPerformanceInformation performanceInformation is null!");\r
}else {\r
if(null!=performanceInformation.getName()) {\r
String ver=performanceInformation.getName();\r
hql.append(" and a.startEpochMicrosec between :startTime and :endTime");\r
}\r
}\r
- logger.info("PerformanceInformationServiceImpl queryPerformanceInformation: performanceInformation={}", performanceInformation);\r
Query query = session.createQuery(hql.toString());\r
if(null!=performanceInformation.getStartEpochMicrosec() || performanceInformation.getLastEpochMicroSec()!= null) {\r
query.setString("startTime",performanceInformation.getStartEpochMicrosec());\r
public List<PerformanceInformation> queryId(String[] id) {\r
try(Session session = getSession()) {\r
if(id.length==0) {\r
- logger.error("PerformanceInformationServiceImpl queryId is null!");\r
}\r
List<PerformanceInformation> list = new ArrayList<>();\r
Query query = session.createQuery("from PerformanceInformation a where a.sourceId IN (:alist)");\r
List<PerformanceInformation> list = new ArrayList<>();\r
Query query = session.createQuery("from PerformanceInformation a where a.sourceId = :sourceId and a.createTime BETWEEN :startDate and :endDate");\r
list = query.setParameter("sourceId",sourceId).setParameter("startDate", startDate).setParameter("endDate",endDate).list();\r
- logger.info("PerformanceInformationServiceImpl queryDateBetween: list={}", list);\r
return list;\r
} catch (Exception e) {\r
logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDateBetween. Details:" + e.getMessage());\r
int sum = 0;\r
Query query = session.createQuery("select sum(a.value) from PerformanceInformation a where a.sourceId = :sourceId and a.name = :name and a.createTime BETWEEN :startDate and :endDate");\r
sum = Integer.parseInt(query.setParameter("sourceId",sourceId).setParameter("name",name).setParameter("startDate", startDate).setParameter("endDate",endDate).uniqueResult().toString());\r
- logger.info("PerformanceInformationServiceImpl queryDataBetweenSum: sum={}", sum);\r
return sum;\r
} catch (Exception e) {\r
logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDataBetweenSum. Details:" + e.getMessage());\r
hql += " and a.name = :name ";\r
}\r
if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){\r
- hql += " and a.startEpochMicrosec between :startTime and :endTime ";\r
+ hql += " and (CASE WHEN a.startEpochMicrosec=0 THEN a.lastEpochMicroSec ELSE a.startEpochMicrosec END) between :startTime and :endTime ";\r
}\r
Query query = session.createQuery(hql);\r
if (sourceId != null && !"".equals(sourceId)){\r
if (k2.equals("priority"))
alarm_header.setPriority(v2.toString());
if (k2.equals("startEpochMicrosec"))
- alarm_header.setStartEpochMicrosec(v2.toString().substring(0, 13));
+ alarm_header.setStartEpochMicrosec(this.getTime(v2.toString()));
if (k2.equals("lastEpochMicrosec"))
- alarm_header.setLastEpochMicroSec(v2.toString().substring(0, 13));
+ alarm_header.setLastEpochMicroSec(this.getTime(v2.toString()));
if (k2.equals("sequence"))
alarm_header.setSequence(v2.toString());
});
});
}
});
- if (alarm_header.getEventName() != null){
+ if (alarm_header.getEventName() != null&&(alarm_header.getStartEpochMicrosec().length()>=13||alarm_header.getLastEpochMicroSec().length()>=13)){
Long l = System.currentTimeMillis();
Timestamp date_get = new Timestamp(l);
if (k2.equals("priority"))
performance_header.setPriority(v2.toString());
if (k2.equals("startEpochMicrosec"))
- performance_header.setStartEpochMicrosec(v2.toString().substring(0, 13));
+ performance_header.setStartEpochMicrosec(this.getTime(v2.toString()));
if (k2.equals("lastEpochMicrosec"))
- performance_header.setLastEpochMicroSec(v2.toString().substring(0, 13));
+ performance_header.setLastEpochMicroSec(this.getTime(v2.toString()));
if (k2.equals("sequence"))
performance_header.setSequence(v2.toString());
});
}
}
});
- performanceHeaderService.savePerformanceHeader(performance_header);
- performance_informations.forEach(ai -> {
- performanceInformationService.savePerformanceInformation(ai);
- });
+ if ((performance_header.getStartEpochMicrosec().length()>=13||performance_header.getLastEpochMicroSec().length()>=13)){//时间有效才会进行存储
+ performanceHeaderService.savePerformanceHeader(performance_header);
+ performance_informations.forEach(ai -> {
+ performanceInformationService.savePerformanceInformation(ai);
+ });
+ }
}
});
}
+
+ private String getTime(String time){
+ String result=time;
+ if(time.length()>=13){
+ result=time.substring(0, 13);
+ }
+ return result;
+ }
}
\ No newline at end of file
echo "Starting mysql"
service mysql start
-sleep 10
-echo "run.sh 1"
+sleep 100
SCRIPT="/home/uui/resources/bin/initDB.sh"
-echo "run.sh 2"
chmod 755 $SCRIPT
-echo "run.sh 3"
-$SCRIPT root root 3306 127.0.0.1
-echo "run.sh 4"
+$SCRIPT root root 3306 127.0.0.1
echo @JAVA_HOME@ $JAVA_HOME
JAVA="$JAVA_HOME/bin/java"
-#! /bin/bash
+#!/bin/bash
#
# Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
#
# limitations under the License.
#
-echo "initDB.sh 1"
DIRNAME=`dirname $0`
-echo "initDB.sh 2"
HOME=`cd $DIRNAME/; pwd`
-echo "initDB.sh 3"
user=$1
password=$2
port=$3
host=$4
-echo "initDB.sh 4"
echo "start create usecase-ui db"
sql_path=$HOME/../
-echo "initDB.sh 5"
mysql -u$user -p$password -P$port -h$host <$sql_path/dbscripts/mysql/usecase-ui-createdb.sql
-echo "initDB.sh 6"
sql_result=$?
if [ $sql_result != 0 ] ; then
echo "failed to create usecase-ui database"