Commit 3c363424 by liushutao

修改统计逻辑

parent 1ff209ba
......@@ -41,7 +41,7 @@ public class PmcGetData {
String endTime = DateUtils.getDateStringYMDHMS(endDate,DateUtils.DATE_TIME_PATTERN);
String endTimestr = DateUtils.getDateStringYMDHMS(endDate,DateUtils.DATE_YYYYMMDDHHMMSS);
return smsPushsysService.pushTravelCardByMinRate(startTime,endTime,startTimestr,endTimestr);
return smsPushsysService.pushTravelCardByMinRate(startTime,endTime,startTimestr,endTimestr,"1","");
}
}
......@@ -12,7 +12,7 @@ public interface SmsPushsysService {
/**
* 统计每分钟日志
*/
String pushTravelCardByMinRate(String startTimeStr, String endTimeStr, String shellPath, String logPath);
String pushTravelCardByMinRate(String startTimeStr, String endTimeStr, String shellPath, String logPath, String flag, String startTimeStri);
}
......@@ -38,12 +38,19 @@ public class SmsPushsysServiceImpl implements SmsPushsysService {
* @return
*/
@Override
public String pushTravelCardByMinRate(String startTime, String endTime,String startTimeStr, String endTimeStr){
public String pushTravelCardByMinRate(String startTime, String endTime,String startTimeStr, String endTimeStr,String tjflag, String startTimeStri){
DynamicDataSourceContextHolder.setDataSourceKey(DataType.MASTER);
String logPath1 ="";
if( StringUtils.isBlank(shellPath) ){
return "配置脚本信息有误";
}
// pCode = CryptoEncoder.base64Decode(pCode);
if("00".equals(tjflag)){
logPath ="/opt/pmc/envoy/envoy-in/logs/envoy-in.txt."+startTimeStri;
logPath1 ="/opt/pmc/envoy/envoy-in/logs/envoy-in.txt";
}else{
logPath ="/opt/pmc/envoy/envoy-in/logs/envoy-in.txt";
}
List<String> commandList1 = this.getCommandList(startTimeStr,endTimeStr,shellPath,logPath);
String finalCommand = "";
for(String str : commandList1){
......@@ -58,6 +65,24 @@ public class SmsPushsysServiceImpl implements SmsPushsysService {
if(result==null||"".equals(result)){
result="0";
}
String result2 ="";
if("00".equals(tjflag)){
List<String> commandList2 = this.getCommandList(startTimeStr,endTimeStr,shellPath,logPath1);
String finalCommand2 = "";
for(String str : commandList2){
finalCommand2 = finalCommand2 + str + " && ";
}
finalCommand2 = finalCommand2.substring(0,finalCommand2.length()-4);
result2 = ExecShell.executes(finalCommand2);
if(result2==null||"".equals(result2)){
result2="0";
}
}
if(!"0".equals(result2)&&!"".equals(result2)){
Integer result1 =Integer.valueOf(result)+Integer.valueOf(result2);
result =result1.toString();
}
Date nowDate = new Date ();
//获取当前时间的前一分钟
String createTime = DateUtils.getDateStringYMDHMS(nowDate,DateUtils.DATE_TIME_PATTERN_YYYYMMDDHHMMSSSSS);
......@@ -88,6 +113,7 @@ public class SmsPushsysServiceImpl implements SmsPushsysService {
String timePath = path+" "+startTime+" "+endTime+" ";
String command = timePath + logPath ;
log.info("统计数据命令:"+command);
commandStrList.add(command);
}catch (Exception e) {
......
......@@ -39,17 +39,26 @@ public class FiveIndexMonitorTask {
*/
@Scheduled(cron = "${springTiming.monitor1-min-time}")
public void StatisticsTravelCardDaily() {
String flag="1";
//获取现在时间(开始时间)
Date nowDate = new Date ();
//获取当前时间的前一分钟
Date startDate = DateUtils.getDate(nowDate,beforeminutes);
String startTime = DateUtils.getDateStringYMDHMS(startDate,DateUtils.DATE_TIME_PATTERN);
String startTimeStri = DateUtils.getDateStringYMDHMS(startDate,DateUtils.DATE_YYYYMMDD);
String startTimestr = DateUtils.getDateStringYMDHMS(startDate,DateUtils.DATE_YYYYMMDDHHMMSS);
Date endDate = DateUtils.getDate(nowDate,beforeendminutes);
Date endDates = DateUtils.getDate(nowDate,inputminute);
String endTime = DateUtils.getDateStringYMDHMS(endDates,DateUtils.DATE_TIME_PATTERNS);
String endTimestr = DateUtils.getDateStringYMDHMS(endDate,DateUtils.DATE_YYYYMMDDHHMMSS);
smsPushsysService.pushTravelCardByMinRate(startTime,endTime,startTimestr,endTimestr);
//获取当前时间,进行判断是否当前时间是00:00:00或者00:01:00
String startDateNewstr = DateUtils.getDateStringYMDHMS(nowDate,DateUtils.DATE_YYYYMMDDHHMMSS);
String endTimeStrs = startDateNewstr.substring(startDateNewstr.length()-6);
if("000000".equals(endTimeStrs)||"000100".equals(endTimeStrs)) {
flag ="00";
}
smsPushsysService.pushTravelCardByMinRate(startTime,endTime,startTimestr,endTimestr,flag,startTimeStri);
}
......
......@@ -30,7 +30,7 @@ public class DateUtils {
public final static String DATE_XIE = "yyyy/MM/dd";
public final static String DATE_YYYYMMDD = "yyyyMMdd";
public final static String DATE_YYYYMMDDHH = "yyyyMMddHH";
public final static String DATE_YYYYMMDDHHMM = "yyyyMMddHHmm";
public final static String DATE_YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
......@@ -287,4 +287,17 @@ public class DateUtils {
String date = sdf.format(sdate);
return date;
}
//获取当前时间的00:00时
public static Date getDateByday() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE,0);
Date zero = calendar.getTime();
return zero;
}
}
......@@ -94,7 +94,6 @@ public class ExecShell {
/**
* 登录主机
* @return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment