Browse Source

job运行异常 日志乱码

mydq 5 years ago
parent
commit
b40cdc985d

+ 3 - 1
src/main/java/com/lightinit/hsdataplatform/tasks/logger/FluxTask.java

@@ -94,8 +94,10 @@ public class FluxTask implements ApplicationListener {
             return;
         }
         String[] timeStrFromStr = timeStrFrom.split(":");
+        String start = timeStrFromStr[0];
         String[] timeStrToStr = timeStrTo.split(":");
-        String cron="0 0/"+cycle+" "+timeStrFromStr[0]+"-"+timeStrToStr[0]+" * * ? *";
+        String end = timeStrToStr[0];
+        String cron="0 0/"+cycle+" "+(start.startsWith("0") ? start.charAt(1) : start)+"-"+(end.startsWith("0") ? end.charAt(1) : end) +" * * ? *";
         QuartzManager.modifyJobTime(JOB_NAME, JOB_GROUP_NAME, TRIGGER_NAME, TRIGGER_GROUP_NAME,cron);
     }
 }

+ 3 - 2
src/main/java/com/lightinit/hsdataplatform/tasks/logger/LoggerJob.java

@@ -55,8 +55,9 @@ public class LoggerJob implements Job {
             if(StringUtils.isEmpty(path)){
                 return;
             }
-            File file = new File(path);
-            BufferedReader reader = new BufferedReader(new FileReader(file));
+            FileInputStream fis = new FileInputStream(path);
+            InputStreamReader inputStreamReader = new InputStreamReader(fis, "UTF-8");
+            BufferedReader reader = new BufferedReader(inputStreamReader);
             String line=null;
             StringBuilder builder = new StringBuilder();
             int count=0;//统计几处错误

+ 3 - 1
src/main/java/com/lightinit/hsdataplatform/tasks/logger/LoggerTask.java

@@ -71,8 +71,10 @@ public class LoggerTask implements ApplicationListener {
                 return;
             }
             String[] timeStrFromStr = timeStrFrom.split(":");
+            String start = timeStrFromStr[0];
             String[] timeStrToStr = timeStrTo.split(":");
-            String cron="0 0/"+cycle+" "+timeStrFromStr[0]+"-"+timeStrToStr[0]+" * * ? *";
+            String end = timeStrToStr[0];
+            String cron="0 0/"+cycle+" "+(start.startsWith("0") ? start.charAt(1) : start)+"-"+(end.startsWith("0") ? end.charAt(1) : end) +" * * ? *";
             QuartzManager.addJob(JOB_NAME, JOB_GROUP_NAME, TRIGGER_NAME, TRIGGER_GROUP_NAME, LoggerJob.class, cron,map);
         }
     }

+ 3 - 1
src/main/java/com/lightinit/hsdataplatform/tasks/logger/StateTask.java

@@ -70,8 +70,10 @@ public class StateTask implements ApplicationListener {
                 return;
             }
             String[] timeStrFromStr = timeStrFrom.split(":");
+            String start = timeStrFromStr[0];
             String[] timeStrToStr = timeStrTo.split(":");
-            String cron="0 0/"+cycle+" "+timeStrFromStr[0]+"-"+timeStrToStr[0]+" * * ? *";
+            String end = timeStrToStr[0];
+            String cron="0 0/"+cycle+" "+(start.startsWith("0") ? start.charAt(1) : start)+"-"+(end.startsWith("0") ? end.charAt(1) : end) +" * * ? *";
             QuartzManager.addJob(JOB_NAME, JOB_GROUP_NAME, TRIGGER_NAME, TRIGGER_GROUP_NAME, StateJob.class, cron,map);
         }
     }

+ 8 - 8
src/main/resources/spring-task.xml

@@ -8,15 +8,15 @@
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
     <context:component-scan base-package="com.lightinit.hsdataplatform.tasks,com.lightinit.hsdataplatform.tasks.*" />
-    <task:scheduled-tasks>
-        <!--每天早7点50开始读取系统日志  0 40 15 * * ?-->
-        <task:scheduled ref="readLogsJobTask" method="run" cron="0 50 14 * * ?"/>
-    </task:scheduled-tasks>
+<!--    <task:scheduled-tasks>-->
+<!--        &lt;!&ndash;每天早7点50开始读取系统日志  0 40 15 * * ?&ndash;&gt;-->
+<!--        <task:scheduled ref="readLogsJobTask" method="run" cron="0 50 14 * * ?"/>-->
+<!--    </task:scheduled-tasks>-->
 
-    <task:scheduled-tasks>
-        <!--每天00:00:00开始对已付款的三天后到期的订单进行提醒  0 0 0 * * ? -->
-        <task:scheduled ref="ordersAndContractExpireTask" method="orderExpireWarningTask" cron="0 0 0 * * ?"/>
-    </task:scheduled-tasks>
+<!--    <task:scheduled-tasks>-->
+<!--        &lt;!&ndash;每天00:00:00开始对已付款的三天后到期的订单进行提醒  0 0 0 * * ? &ndash;&gt;-->
+<!--        <task:scheduled ref="ordersAndContractExpireTask" method="orderExpireWarningTask" cron="0 0 0 * * ?"/>-->
+<!--    </task:scheduled-tasks>-->
 
     <!--开启切面-->
     <aop:aspectj-autoproxy/>

+ 1 - 2
src/main/resources/spring.xml

@@ -6,7 +6,6 @@
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
-
     <!-- 引入项目配置文件 -->
     <bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
         <property name="locations">
@@ -24,7 +23,7 @@
     <context:annotation-config></context:annotation-config>
     <import resource="classpath:spring-shiro.xml"/>
     <!--<import resource="classpath:spring-mongodb.xml"/>-->
-    <!--<import resource="classpath:spring-task.xml"/>-->
+    <import resource="classpath:spring-task.xml"/>
     <!--<import resource="classpath:spring-solr.xml"/>-->
     <!--<import resource="spring-activemq.xml"/>-->
 

+ 3 - 3
src/main/webapp/pages/admin/runing_monitoring/runing_monitoring.jsp

@@ -55,7 +55,7 @@
 
 
         <div class="col-md-5 col-sm-5 form-group">
-            <label   >监控周期:</label>
+            <label   >监控周期(0-59):</label>
             <input type="text"  class="form-control"  name="apiMonitoringCycle"value="${apiType.monitoringCycle}"  class="col-md-3 col-sm-3 control-label" />
             <span class="field-validation-valid help-block"></span>
         </div>
@@ -113,7 +113,7 @@
             <span class="field-validation-valid help-block"></span>
         </div>
         <div class="col-md-5 col-sm-5 form-group">
-            <label   >监控周期:</label>
+            <label   >监控周期(0-59):</label>
             <input type="text"  class="form-control"  name="microappMonitoringCycle"value="${microappType.monitoringCycle}"  class="col-md-3 col-sm-3 control-label" />
             <span class="field-validation-valid help-block"></span>
         </div>
@@ -170,7 +170,7 @@
             <span class="field-validation-valid help-block"></span>
         </div>
         <div class="col-md-5 col-sm-5 form-group">
-            <label   >监控周期:</label>
+            <label   >监控周期(0-59):</label>
             <input type="text"  class="form-control"  name="userLogMonitoringCycle"value="${userLogType.monitoringCycle}"  class="col-md-3 col-sm-3 control-label" />
             <span class="field-validation-valid help-block"></span>
         </div>