diff options
| author | LAPTOP-CUUVN8AS\wk <[email protected]> | 2022-09-09 10:19:06 +0800 |
|---|---|---|
| committer | LAPTOP-CUUVN8AS\wk <[email protected]> | 2022-09-09 10:19:06 +0800 |
| commit | 2e5147c633be69f25a8c2f9610cf391c6cd6e79e (patch) | |
| tree | 7810766eaf5bab67b58091b4e753b4c6980b15b9 | |
| parent | bd9ee286d8f746fd1372178cc7e53a03c64d705c (diff) | |
将触发字段由endtime改为issuetime
6 files changed, 32 insertions, 21 deletions
@@ -10,7 +10,7 @@ </parent> <groupId>com.mesa</groupId> <artifactId>galaxy-report-service</artifactId> - <version>22.04.11</version> + <version>22.09.07</version> <name>galaxy-report-service</name> <packaging>jar</packaging> <description>Demo project for Spring Boot</description> @@ -309,7 +309,7 @@ <forceTags>true</forceTags> <imageTags> - <imageTag>22.04.11</imageTag> + <imageTag>22.09.07</imageTag> </imageTags> <!--远程docker构建,供dockerfile使用--> <dockerHost>http://192.168.40.153:2375</dockerHost> diff --git a/src/main/java/com/mesa/reportservice/ReportserviceApplication.java b/src/main/java/com/mesa/reportservice/ReportserviceApplication.java index 4751d77..e5644a1 100644 --- a/src/main/java/com/mesa/reportservice/ReportserviceApplication.java +++ b/src/main/java/com/mesa/reportservice/ReportserviceApplication.java @@ -1,5 +1,6 @@ package com.mesa.reportservice; +import com.mesa.reportservice.util.StringUtil; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; @@ -9,6 +10,9 @@ import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableScheduling; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.util.List; import java.util.TimeZone; @ServletComponentScan @@ -16,11 +20,19 @@ import java.util.TimeZone; @SpringBootApplication @EnableScheduling public class ReportserviceApplication { + public static final String TIMEZONE = "UTC"; public static void main(String[] args) { System.setProperty("jasypt.encryptor.password", "galaxy"); - System.setProperty("user.timezone", "UTC"); - TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); + List<String> inputArguments = runtimeMxBean.getInputArguments(); + if (inputArguments.stream().noneMatch(o -> o.contains("user.timezone")) + && StringUtil.isEmpty(System.getenv().get("TZ"))) { + // java.util.Date + TimeZone.setDefault(TimeZone.getTimeZone(TIMEZONE)); + // joda.time.DateTime + System.setProperty("user.timezone", TIMEZONE); + } SpringApplication.run(ReportserviceApplication.class, args); } diff --git a/src/main/java/com/mesa/reportservice/bean/JobEntity.java b/src/main/java/com/mesa/reportservice/bean/JobEntity.java index 3e7edcf..7da68a5 100644 --- a/src/main/java/com/mesa/reportservice/bean/JobEntity.java +++ b/src/main/java/com/mesa/reportservice/bean/JobEntity.java @@ -11,9 +11,9 @@ public class JobEntity implements Cloneable { private Integer jobId; - private String startTime; +/* private String startTime; - private String endTime; + private String endTime;*/ private String querySql; @@ -79,7 +79,7 @@ public class JobEntity implements Cloneable { this.jobId = jobId; } - public String getStartTime() { +/* public String getStartTime() { return startTime; } @@ -93,7 +93,7 @@ public class JobEntity implements Cloneable { public void setEndTime(String endTime) { this.endTime = endTime; - } + }*/ public String getQuerySql() { return querySql; diff --git a/src/main/java/com/mesa/reportservice/controller/ScheduledResultController.java b/src/main/java/com/mesa/reportservice/controller/ScheduledResultController.java index 1085bfe..bb7ebf0 100644 --- a/src/main/java/com/mesa/reportservice/controller/ScheduledResultController.java +++ b/src/main/java/com/mesa/reportservice/controller/ScheduledResultController.java @@ -51,9 +51,9 @@ public class ScheduledResultController { List<JobEntity> joblist = ms.getJobForExcute(); for (JobEntity jobEntity : joblist) { String sql = jobEntity.getQuerySql().trim(); - sql = sql.replace("$exe_time", "toDateTime('" + jobEntity.getIssuedTime().trim() + "')"); + /* sql = sql.replace("$exe_time", "toDateTime('" + jobEntity.getIssuedTime().trim() + "')"); sql = sql.replace("$start_time", "toDateTime('" + jobEntity.getStartTime().trim() + "')"); - sql = sql.replace("$end_time", "toDateTime('" + jobEntity.getEndTime().trim() + "')"); + sql = sql.replace("$end_time", "toDateTime('" + jobEntity.getEndTime().trim() + "')");*/ String queryid = cs.getQueryId(jobEntity.getResultId().toString(), sql); jobEntity.setQuery_id(queryid); @@ -101,9 +101,9 @@ public class ScheduledResultController { long begintime = System.currentTimeMillis(); job.setBeginTime(begintime); String sql = job.getQuerySql().trim(); - sql = sql.replace("$exe_time", "toDateTime('" + job.getIssuedTime().trim() + "')"); + /* sql = sql.replace("$exe_time", "toDateTime('" + job.getIssuedTime().trim() + "')"); sql = sql.replace("$start_time", "toDateTime('" + job.getStartTime().trim() + "')"); - sql = sql.replace("$end_time", "toDateTime('" + job.getEndTime().trim() + "')"); + sql = sql.replace("$end_time", "toDateTime('" + job.getEndTime().trim() + "')");*/ job.setQuerySql(sql); job.setStatus(1); job.setExcute_status(1); diff --git a/src/main/java/com/mesa/reportservice/service/impl/MysqlServiceImpl.java b/src/main/java/com/mesa/reportservice/service/impl/MysqlServiceImpl.java index bce645f..f16ac68 100644 --- a/src/main/java/com/mesa/reportservice/service/impl/MysqlServiceImpl.java +++ b/src/main/java/com/mesa/reportservice/service/impl/MysqlServiceImpl.java @@ -5,7 +5,6 @@ import com.mesa.reportservice.bean.JobEntity; import com.mesa.reportservice.mapper.ReportResultMapper; import com.mesa.reportservice.service.MysqlService; import com.mesa.reportservice.util.DateUtil; -import com.mesa.reportservice.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -38,7 +37,7 @@ public class MysqlServiceImpl implements MysqlService { String current_time = DateUtil.getDate(); HashMap map = new HashMap(); - map.put("endtime", current_time); + map.put("issuedtime", current_time); map.put("rows", rows); return rrm.getJobTask(map); @@ -62,7 +61,7 @@ public class MysqlServiceImpl implements MysqlService { String current_time = DateUtil.getDate(); String today_time = DateUtil.getCurrentDate(); HashMap map = new HashMap(); - map.put("endtime", current_time); + map.put("issuedtime", current_time); map.put("optime", today_time); return rrm.getJobCount(map); } diff --git a/src/main/resources/mappers/ReportResultMapper.xml b/src/main/resources/mappers/ReportResultMapper.xml index a425efc..a1f610f 100644 --- a/src/main/resources/mappers/ReportResultMapper.xml +++ b/src/main/resources/mappers/ReportResultMapper.xml @@ -4,8 +4,8 @@ <resultMap type="com.mesa.reportservice.bean.JobEntity" id="BaseResultMap"> <id property="resultId" column="result_id"/> <result property="resultName" column="result_name"/> - <result property="startTime" column="start_time"/> - <result property="endTime" column="end_time"/> +<!-- <result property="startTime" column="start_time"/> + <result property="endTime" column="end_time"/>--> <result property="querySql" column="query_sql"/> <result property="status" column="status"/> <result property="excuteTime" column="excute_time"/> @@ -19,21 +19,21 @@ </resultMap> <sql id="Base_Column_List" > - result_id, result_name, DATE_FORMAT(start_time,'%Y-%m-%d %H:%i:%s') as start_time,DATE_FORMAT(end_time,'%Y-%m-%d %H:%i:%s') as end_time, query_sql, status, excute_time, + result_id, result_name, query_sql, status, excute_time, excute_row, excute_process, excute_detail, is_send_notice,DATE_FORMAT(op_time,'%Y-%m-%d %H:%i:%s') as op_time,DATE_FORMAT(issued_time,'%Y-%m-%d %H:%i:%s') as issued_time,result_rows,is_valid </sql> <select id="getJobForExcute" resultMap="BaseResultMap" parameterType="java.lang.Integer" > select <include refid="Base_Column_List" /> from report_result - where status = 1 order by end_time limit 10 + where status = 1 order by issued_time limit 10 </select> <select id="getJobTask" resultMap="BaseResultMap" parameterType="hashmap"> select <include refid="Base_Column_List" /> from report_result - where status = 0 and is_valid = 1 and end_time < #{endtime} order by end_time limit ${rows} + where status = 0 and is_valid = 1 and issued_time < #{issuedtime} order by issued_time limit ${rows} </select> <update id="updateProcesses" parameterType="com.mesa.reportservice.bean.JobEntity" > @@ -89,7 +89,7 @@ <select id="getJobCount" resultType="map" parameterType="hashmap"> - SELECT (SELECT COUNT(1) FROM report_result where status = 0 and is_valid = 1 and end_time < #{endtime}) as queueNum, + SELECT (SELECT COUNT(1) FROM report_result where status = 0 and is_valid = 1 and issued_time < #{issuedtime}) as queueNum, (SELECT COUNT(1) FROM report_result where status = 1 and is_valid = 1 ) as excuteingNum, (SELECT COUNT(1) FROM report_result where status = 2 and op_time > #{optime} ) as todaySuccessNum, (SELECT COUNT(1) FROM report_result where status > 2 and op_time > #{optime} ) as todayErrorNum |
