From b34727ebd73a4f346d53730865e83fd5b3e5a0ef Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 26 十月 2023 16:36:37 +0800
Subject: [PATCH] 1. 新增定时任务和定时任务日志数据库表映射; 2. 修改异常分析和日、月统计分析定时任务的执行逻辑

---
 src/main/java/com/flightfeather/monitor/utils/DateUtil.kt                                  |   14 
 src/main/java/com/flightfeather/monitor/scheduledtasks/DustAnalysisTask.kt                 |   68 +++++++
 src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionSettingRep.kt   |    9 
 src/main/java/com/flightfeather/monitor/config/Swagger2Configuration.kt                    |   45 +++++
 src/main/resources/mapper/ds1/RequestTaskLogMapper.xml                                     |   31 +++
 src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustStatisticsValueRep.kt    |   11 
 src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RequestTaskMapper.kt             |    8 
 src/main/java/com/flightfeather/monitor/domain/ds1/repository/RequestTaskRep.kt            |   30 +++
 pom.xml                                                                                    |    5 
 src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RequestTaskLogMapper.kt          |    8 
 src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionDataRep.kt      |    9 
 src/main/java/com/flightfeather/monitor/scheduledtasks/TaskController.kt                   |   22 +-
 src/main/java/com/flightfeather/monitor/domain/ds1/entity/RequestTaskLog.java              |   98 ++++++++++
 src/main/resources/mapper/ds1/RequestTaskMapper.xml                                        |   20 ++
 src/main/java/com/flightfeather/monitor/scheduledtasks/DustMonthlyStatisticAnalysisTask.kt |    2 
 src/main/java/com/flightfeather/monitor/domain/ds1/entity/RequestTask.java                 |  119 +++++++++++++
 src/main/resources/generator/generatorConfig4ds1.xml                                       |   16 +
 src/main/resources/application.yml                                                         |    3 
 18 files changed, 490 insertions(+), 28 deletions(-)

diff --git a/pom.xml b/pom.xml
index a3ef5a1..dfe88eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -96,6 +96,11 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>3.0.0</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/src/main/java/com/flightfeather/monitor/config/Swagger2Configuration.kt b/src/main/java/com/flightfeather/monitor/config/Swagger2Configuration.kt
new file mode 100644
index 0000000..e21dc4f
--- /dev/null
+++ b/src/main/java/com/flightfeather/monitor/config/Swagger2Configuration.kt
@@ -0,0 +1,45 @@
+package com.flightfeather.monitor.config
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import springfox.documentation.builders.ApiInfoBuilder
+import springfox.documentation.builders.PathSelectors
+import springfox.documentation.builders.RequestHandlerSelectors
+import springfox.documentation.oas.annotations.EnableOpenApi
+import springfox.documentation.spi.DocumentationType
+import springfox.documentation.spring.web.plugins.Docket
+
+/**
+ * Date: 2023/10/25
+ */
+@Configuration
+@EnableOpenApi
+class Swagger2Configuration {
+
+    companion object {
+        const val SWAGGER_SCAN_BASE_PACKAGE = "com.flightfeather.monitor"
+
+        const val VERSION = "1.0.0"
+    }
+
+//    @Value("\${springfox.documentation.swagger.v2.enabled}")
+    var swagger2Enable: Boolean = true
+
+    @Bean
+    fun createRestApi(): Docket =
+        Docket(DocumentationType.OAS_30)
+            .enable(swagger2Enable)
+            .apiInfo(apiInfo())
+            .select()
+            .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
+            .paths(PathSelectors.any())
+            .build()
+
+
+    private fun apiInfo() =
+        ApiInfoBuilder()
+            .title("鐩戞祴鏁版嵁璐ㄩ噺鍒嗘瀽鏈嶅姟")
+            .description("鐩戞祴鏁版嵁璐ㄩ噺鍒嗘瀽鏈嶅姟 API 鎺ュ彛鏂囨。")
+            .version(VERSION)
+            .build()
+}
\ No newline at end of file
diff --git a/src/main/java/com/flightfeather/monitor/domain/ds1/entity/RequestTask.java b/src/main/java/com/flightfeather/monitor/domain/ds1/entity/RequestTask.java
new file mode 100644
index 0000000..0940a83
--- /dev/null
+++ b/src/main/java/com/flightfeather/monitor/domain/ds1/entity/RequestTask.java
@@ -0,0 +1,119 @@
+package com.flightfeather.monitor.domain.ds1.entity;
+
+import java.util.Date;
+import javax.persistence.*;
+
+@Table(name = "du_js_t_request_task")
+public class RequestTask {
+    @Id
+    private Integer id;
+
+    /**
+     * 浠诲姟寮�鍚椂闂�
+     */
+    @Column(name = "start_time")
+    private Date startTime;
+
+    /**
+     * 浠诲姟缁撴潫鏃堕棿
+     */
+    @Column(name = "end_time")
+    private Date endTime;
+
+    /**
+     * 杩愯鐘舵��
+     */
+    @Column(name = "running_status")
+    private Boolean runningStatus;
+
+    /**
+     * 浠诲姟鏄惁鎴愬姛瀹屾垚
+     */
+    private Boolean success;
+
+    /**
+     * @return id
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * @param id
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * 鑾峰彇浠诲姟寮�鍚椂闂�
+     *
+     * @return start_time - 浠诲姟寮�鍚椂闂�
+     */
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    /**
+     * 璁剧疆浠诲姟寮�鍚椂闂�
+     *
+     * @param startTime 浠诲姟寮�鍚椂闂�
+     */
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    /**
+     * 鑾峰彇浠诲姟缁撴潫鏃堕棿
+     *
+     * @return end_time - 浠诲姟缁撴潫鏃堕棿
+     */
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    /**
+     * 璁剧疆浠诲姟缁撴潫鏃堕棿
+     *
+     * @param endTime 浠诲姟缁撴潫鏃堕棿
+     */
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    /**
+     * 鑾峰彇杩愯鐘舵��
+     *
+     * @return running_status - 杩愯鐘舵��
+     */
+    public Boolean getRunningStatus() {
+        return runningStatus;
+    }
+
+    /**
+     * 璁剧疆杩愯鐘舵��
+     *
+     * @param runningStatus 杩愯鐘舵��
+     */
+    public void setRunningStatus(Boolean runningStatus) {
+        this.runningStatus = runningStatus;
+    }
+
+    /**
+     * 鑾峰彇浠诲姟鏄惁鎴愬姛瀹屾垚
+     *
+     * @return success - 浠诲姟鏄惁鎴愬姛瀹屾垚
+     */
+    public Boolean getSuccess() {
+        return success;
+    }
+
+    /**
+     * 璁剧疆浠诲姟鏄惁鎴愬姛瀹屾垚
+     *
+     * @param success 浠诲姟鏄惁鎴愬姛瀹屾垚
+     */
+    public void setSuccess(Boolean success) {
+        this.success = success;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/flightfeather/monitor/domain/ds1/entity/RequestTaskLog.java b/src/main/java/com/flightfeather/monitor/domain/ds1/entity/RequestTaskLog.java
new file mode 100644
index 0000000..87e0344
--- /dev/null
+++ b/src/main/java/com/flightfeather/monitor/domain/ds1/entity/RequestTaskLog.java
@@ -0,0 +1,98 @@
+package com.flightfeather.monitor.domain.ds1.entity;
+
+import java.util.Date;
+import javax.persistence.*;
+
+@Table(name = "du_js_t_request_task_log")
+public class RequestTaskLog {
+    @Id
+    private Integer id;
+
+    @Column(name = "request_id")
+    private Integer requestId;
+
+    /**
+     * 鍒涘缓鏃堕棿
+     */
+    @Column(name = "create_time")
+    private Date createTime;
+
+    @Column(name = "log_type")
+    private String logType;
+
+    private String log;
+
+    /**
+     * @return id
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * @param id
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * @return request_id
+     */
+    public Integer getRequestId() {
+        return requestId;
+    }
+
+    /**
+     * @param requestId
+     */
+    public void setRequestId(Integer requestId) {
+        this.requestId = requestId;
+    }
+
+    /**
+     * 鑾峰彇鍒涘缓鏃堕棿
+     *
+     * @return create_time - 鍒涘缓鏃堕棿
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * 璁剧疆鍒涘缓鏃堕棿
+     *
+     * @param createTime 鍒涘缓鏃堕棿
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * @return log_type
+     */
+    public String getLogType() {
+        return logType;
+    }
+
+    /**
+     * @param logType
+     */
+    public void setLogType(String logType) {
+        this.logType = logType == null ? null : logType.trim();
+    }
+
+    /**
+     * @return log
+     */
+    public String getLog() {
+        return log;
+    }
+
+    /**
+     * @param log
+     */
+    public void setLog(String log) {
+        this.log = log == null ? null : log.trim();
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RequestTaskLogMapper.kt b/src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RequestTaskLogMapper.kt
new file mode 100644
index 0000000..f40ba7d
--- /dev/null
+++ b/src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RequestTaskLogMapper.kt
@@ -0,0 +1,8 @@
+package com.flightfeather.monitor.domain.ds1.mapper
+
+import com.flightfeather.monitor.domain.ds1.entity.RequestTaskLog
+import com.flightfeather.monitor.domain.util.MyMapper
+import org.apache.ibatis.annotations.Mapper
+
+@Mapper
+interface RequestTaskLogMapper : MyMapper<RequestTaskLog?>
\ No newline at end of file
diff --git a/src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RequestTaskMapper.kt b/src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RequestTaskMapper.kt
new file mode 100644
index 0000000..8ba2649
--- /dev/null
+++ b/src/main/java/com/flightfeather/monitor/domain/ds1/mapper/RequestTaskMapper.kt
@@ -0,0 +1,8 @@
+package com.flightfeather.monitor.domain.ds1.mapper
+
+import com.flightfeather.monitor.domain.ds1.entity.RequestTask
+import com.flightfeather.monitor.domain.util.MyMapper
+import org.apache.ibatis.annotations.Mapper
+
+@Mapper
+interface RequestTaskMapper : MyMapper<RequestTask?>
\ No newline at end of file
diff --git a/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionDataRep.kt b/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionDataRep.kt
index 2876b18..3bf25c9 100644
--- a/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionDataRep.kt
+++ b/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionDataRep.kt
@@ -2,6 +2,7 @@
 
 import com.flightfeather.monitor.domain.ds1.entity.DustExceptionData
 import com.flightfeather.monitor.domain.ds1.mapper.DustExceptionDataMapper
+import com.github.pagehelper.PageHelper
 import org.springframework.stereotype.Repository
 import tk.mybatis.mapper.entity.Example
 import java.time.LocalDate
@@ -13,9 +14,15 @@
      * 鑾峰彇鏈�鏂颁竴鏉¤褰�
      */
     fun findLatestData(): DustExceptionData? {
-        return dustExceptionDataMapper.selectOneByExample(Example(DustExceptionData::class.java).apply {
+        val p = PageHelper.startPage<DustExceptionData>(1, 1)
+        dustExceptionDataMapper.selectByExample(Example(DustExceptionData::class.java).apply {
             orderBy("endTime").desc()
         })
+        return if (p.isNotEmpty()) {
+            p[0]
+        } else {
+            null
+        }
     }
 
     /**
diff --git a/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionSettingRep.kt b/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionSettingRep.kt
index 03f6ce1..c2c75de 100644
--- a/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionSettingRep.kt
+++ b/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustExceptionSettingRep.kt
@@ -2,6 +2,7 @@
 
 import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting
 import com.flightfeather.monitor.domain.ds1.mapper.DustExceptionSettingMapper
+import com.github.pagehelper.PageHelper
 import org.springframework.stereotype.Repository
 import tk.mybatis.mapper.entity.Example
 
@@ -13,9 +14,15 @@
      * @param region 鍖哄幙
      */
     fun findLatestSetting(region: String): DustExceptionSetting? {
-        return dustExceptionSettingMapper.selectOneByExample(Example(DustExceptionSetting::class.java).apply {
+        val p = PageHelper.startPage<DustExceptionSetting>(1, 1)
+        dustExceptionSettingMapper.selectByExample(Example(DustExceptionSetting::class.java).apply {
             createCriteria().andEqualTo("region", region)
             orderBy("version").desc()
         })
+        return if (p.isNotEmpty()) {
+            p[0]
+        } else {
+            null
+        }
     }
 }
\ No newline at end of file
diff --git a/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustStatisticsValueRep.kt b/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustStatisticsValueRep.kt
index 2dfcdf3..6af586e 100644
--- a/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustStatisticsValueRep.kt
+++ b/src/main/java/com/flightfeather/monitor/domain/ds1/repository/DustStatisticsValueRep.kt
@@ -1,9 +1,8 @@
 package com.flightfeather.monitor.domain.ds1.repository
 
-import com.flightfeather.monitor.domain.ds1.entity.DustExceptionData
-import com.flightfeather.monitor.domain.ds1.entity.DustSiteData
 import com.flightfeather.monitor.domain.ds1.entity.DustStatisticsValue
 import com.flightfeather.monitor.domain.ds1.mapper.DustStatisticsValueMapper
+import com.github.pagehelper.PageHelper
 import org.springframework.stereotype.Repository
 import tk.mybatis.mapper.entity.Example
 import java.time.Duration
@@ -13,10 +12,16 @@
 class DustStatisticsValueRep(private val dustStatisticsValueMapper: DustStatisticsValueMapper) {
 
     fun findLatestData(type: String): DustStatisticsValue? {
-        return dustStatisticsValueMapper.selectOneByExample(Example(DustStatisticsValue::class.java).apply {
+        val p = PageHelper.startPage<DustStatisticsValue>(1, 1)
+        dustStatisticsValueMapper.selectByExample(Example(DustStatisticsValue::class.java).apply {
             createCriteria().andEqualTo("type", type)
             orderBy("lst").desc()
         })
+        return if (p.isNotEmpty()) {
+            p[0]
+        } else {
+            null
+        }
     }
 
 
diff --git a/src/main/java/com/flightfeather/monitor/domain/ds1/repository/RequestTaskRep.kt b/src/main/java/com/flightfeather/monitor/domain/ds1/repository/RequestTaskRep.kt
new file mode 100644
index 0000000..382ac5e
--- /dev/null
+++ b/src/main/java/com/flightfeather/monitor/domain/ds1/repository/RequestTaskRep.kt
@@ -0,0 +1,30 @@
+package com.flightfeather.monitor.domain.ds1.repository
+
+import com.flightfeather.monitor.domain.ds1.entity.RequestTask
+import com.flightfeather.monitor.domain.ds1.mapper.RequestTaskMapper
+import com.github.pagehelper.PageHelper
+import org.springframework.stereotype.Repository
+import tk.mybatis.mapper.entity.Example
+import java.time.LocalDateTime
+
+@Repository
+class RequestTaskRep(private val requestTaskMapper: RequestTaskMapper) {
+
+    /**
+     * 鏌ヨ鏈�杩戠殑涓�涓换鍔�
+     */
+    fun findLatestTask(localDateTime: LocalDateTime): RequestTask? {
+        val p = PageHelper.startPage<RequestTask>(1, 1)
+        val s = localDateTime.withHour(0).withMinute(0).withSecond(0)
+        val e = localDateTime.withHour(23).withMinute(59).withSecond(59)
+        requestTaskMapper.selectByExample(Example(RequestTask::class.java).apply {
+            createCriteria().andBetween("startTime", s, e)
+            orderBy("startTime").desc()
+        })
+        return if (p.isNotEmpty()) {
+            p[0]
+        } else {
+            null
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/flightfeather/monitor/scheduledtasks/DustAnalysisTask.kt b/src/main/java/com/flightfeather/monitor/scheduledtasks/DustAnalysisTask.kt
new file mode 100644
index 0000000..631da3a
--- /dev/null
+++ b/src/main/java/com/flightfeather/monitor/scheduledtasks/DustAnalysisTask.kt
@@ -0,0 +1,68 @@
+package com.flightfeather.monitor.scheduledtasks
+
+import com.flightfeather.monitor.analysis.dust.ExceptionAnalysisController
+import com.flightfeather.monitor.analysis.dust.StatisticAnalysisController
+import com.flightfeather.monitor.domain.ds1.entity.RequestTask
+import com.flightfeather.monitor.domain.ds1.repository.RequestTaskRep
+import org.springframework.stereotype.Component
+import java.time.LocalDateTime
+
+/**
+ * 鎵皹鏁版嵁鍒嗘瀽浠诲姟
+ */
+@Component
+class DustAnalysisTask(
+    private val statisticAnalysisController: StatisticAnalysisController,
+    private val exceptionAnalysisController: ExceptionAnalysisController,
+    private val requestTaskRep: RequestTaskRep,
+) : BaseTimingTask() {
+
+    // 浠诲姟鏄惁寤惰繜鎵ц
+    private var task1Delay = false
+    private var task2Delay = false
+    private var task3Delay = false
+
+    override val period: Long = 15
+
+    override fun execute(localtime: LocalDateTime) {
+        doTask(localtime)
+    }
+
+    override fun doTask(localtime: LocalDateTime) {
+        if (task1Delay || (localtime.hour == 8 && localtime.minute == 0)) {
+            // 鍒ゆ柇浠婃棩鐖彇浠诲姟鏄惁瀹屾垚
+            val task = requestTaskRep.findLatestTask(localtime)
+            task1Delay = isTaskDelay(task)
+            if (task1Delay) return
+            log.info("寮傚父鍒嗘瀽鎵ц")
+            exceptionAnalysisController.init()
+            exceptionAnalysisController.autoRun()
+        }
+
+        if (task2Delay || (localtime.hour == 9 && localtime.minute == 0)) {
+            val task = requestTaskRep.findLatestTask(localtime)
+            task2Delay = isTaskDelay(task)
+            if (task2Delay) return
+            log.info("鏃ュ垎鏋愭墽琛�")
+            statisticAnalysisController.autoRunDailyStatics()
+        }
+
+        if (localtime.dayOfMonth == 1 && localtime.hour == 9 && localtime.minute == 0) {
+            val task = requestTaskRep.findLatestTask(localtime)
+            task3Delay = isTaskDelay(task)
+            if (task3Delay) return
+            log.info("鏈堝垎鏋愭墽琛�")
+            statisticAnalysisController.autoRunMonthlyStatics()
+        }
+    }
+
+    /**
+     * 褰撲换鍔″紑濮嬫墽琛屾椂锛屽垽鏂换鍔$姸鎬侊紝鍐冲畾鏄惁寤惰繜鎵ц
+     */
+    private fun isTaskDelay(task: RequestTask?): Boolean {
+        // 浠诲姟姝e湪鎵ц锛岃烦杩囨娆″垎鏋愶紝鍦ㄤ笅涓�鍛ㄦ湡缁х画鍒ゆ柇锛岀瓑寰呬换鍔″畬鎴愬悗杩涜鍒嗘瀽
+        return if (task == null || task.runningStatus) {
+            true
+        } else !task.success
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/flightfeather/monitor/scheduledtasks/DustMonthlyStatisticAnalysisTask.kt b/src/main/java/com/flightfeather/monitor/scheduledtasks/DustMonthlyStatisticAnalysisTask.kt
index 8656414..4595de5 100644
--- a/src/main/java/com/flightfeather/monitor/scheduledtasks/DustMonthlyStatisticAnalysisTask.kt
+++ b/src/main/java/com/flightfeather/monitor/scheduledtasks/DustMonthlyStatisticAnalysisTask.kt
@@ -13,7 +13,7 @@
     override fun execute(localtime: LocalDateTime) {
 //        println("鏈堝垎鏋愯疆璇�")
 //        println(localtime)
-        if (localtime.dayOfMonth == 2 && localtime.hour == 0 && localtime.minute == 0) {
+        if (localtime.dayOfMonth == 1 && localtime.hour == 9 && localtime.minute == 0) {
             doTask(localtime)
         }
     }
diff --git a/src/main/java/com/flightfeather/monitor/scheduledtasks/TaskController.kt b/src/main/java/com/flightfeather/monitor/scheduledtasks/TaskController.kt
index 02f5d16..0970b24 100644
--- a/src/main/java/com/flightfeather/monitor/scheduledtasks/TaskController.kt
+++ b/src/main/java/com/flightfeather/monitor/scheduledtasks/TaskController.kt
@@ -14,17 +14,17 @@
 /**
  * 鏁版嵁鑾峰彇鎺у埗鍣�
  */
-@Slf4j
 @Component
 class TaskController(
     dustExceptionAnalysisTask: DustExceptionAnalysisTask,
     dustDailyStatisticAnalysisTask: DustDailyStatisticAnalysisTask,
     dustMonthlyStatisticAnalysisTask: DustMonthlyStatisticAnalysisTask,
+    dustAnalysisTask: DustAnalysisTask,
 ) {
 
     companion object {
-        private const val FETCH_PERIOD_MIN = 1L * 60
-        private const val MAINTAIN_PERIOD_MIN = 5L * 60
+        private const val FETCH_PERIOD_MIN = 15L
+        private const val MAINTAIN_PERIOD_MIN = 15L
         val log: Logger = LoggerFactory.getLogger(TaskController::class.java)
     }
 
@@ -37,10 +37,10 @@
     init {
         log.info("娣诲姞瀹氭椂浠诲姟")
         timeTask.clear()
-       /*鍋氱殑瀹氭椂浠诲姟鍔犺繘鏉�*/
-        timeTask.add(dustExceptionAnalysisTask)
-        timeTask.add(dustDailyStatisticAnalysisTask)
-        timeTask.add(dustMonthlyStatisticAnalysisTask)
+//        timeTask.add(dustExceptionAnalysisTask)
+//        timeTask.add(dustDailyStatisticAnalysisTask)
+//        timeTask.add(dustMonthlyStatisticAnalysisTask)
+        timeTask.add(dustAnalysisTask)
         log.info("娣诲姞瀹氭椂浠诲姟瀹屾垚锛屼换鍔℃�昏${timeTask.size}涓�")
     }
 
@@ -51,8 +51,8 @@
 
     private fun fetchTask(isFirst: Boolean = false) {
         val time = LocalTime.now()
-        val sec = time.second
-        val delay = 60L - sec
+        val min = time.minute
+        val delay = FETCH_PERIOD_MIN - min % FETCH_PERIOD_MIN
 //        var localtime = LocalDateTime.of(2021, 4, 16, 9, 0)
         if (!isFirst) {
             schedule = closeThread(schedule)
@@ -70,7 +70,7 @@
                 it.execute(localtime)
             }
 //            localtime = localtime.plusMinutes(1)
-        }, delay, FETCH_PERIOD_MIN, TimeUnit.SECONDS)
+        }, delay, FETCH_PERIOD_MIN, TimeUnit.MINUTES)
     }
 
     private fun maintainTask(isFirst: Boolean = false) {
@@ -82,7 +82,7 @@
             if (Date().time - taskTime.time > (FETCH_PERIOD_MIN + 1) * 60 * 1000) {
                 fetchTask()
             }
-        }, 0, MAINTAIN_PERIOD_MIN, TimeUnit.SECONDS)
+        }, 0, MAINTAIN_PERIOD_MIN, TimeUnit.MINUTES)
     }
 
     private fun closeThread(s: ScheduledExecutorService): ScheduledExecutorService {
diff --git a/src/main/java/com/flightfeather/monitor/utils/DateUtil.kt b/src/main/java/com/flightfeather/monitor/utils/DateUtil.kt
index 4aed1d4..48f7cb7 100644
--- a/src/main/java/com/flightfeather/monitor/utils/DateUtil.kt
+++ b/src/main/java/com/flightfeather/monitor/utils/DateUtil.kt
@@ -6,18 +6,20 @@
 
     fun findDurationDate(s: LocalDate, e: LocalDate): List<LocalDate> {
         val res = mutableListOf<LocalDate>()
-        while (s.isBefore(e) || s.isEqual(e)) {
-            res.add(s)
-            s.plusDays(1)
+        var sT = s
+        while (sT.isBefore(e) || sT.isEqual(e)) {
+            res.add(sT)
+            sT = sT.plusDays(1)
         }
         return res
     }
 
     fun findDurationMonth(s: LocalDate, e: LocalDate): List<LocalDate> {
         val res = mutableListOf<LocalDate>()
-        while (s.monthValue <= e.monthValue) {
-            res.add(s)
-            s.plusMonths(1)
+        var sT = s
+        while (sT.monthValue <= e.monthValue) {
+            res.add(sT)
+            sT = sT.plusMonths(1)
         }
         return res
     }
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 5588ba3..050fda5 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -20,7 +20,8 @@
 
 mybatis:
   configuration:
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
     map-underscore-to-camel-case: true
   type-aliases-package: com.flightfeather.monitor.domain.ds1.entity
   mapper-locations: classpath*:mapper/**/*.xml
diff --git a/src/main/resources/generator/generatorConfig4ds1.xml b/src/main/resources/generator/generatorConfig4ds1.xml
index af8aefa..a6775aa 100644
--- a/src/main/resources/generator/generatorConfig4ds1.xml
+++ b/src/main/resources/generator/generatorConfig4ds1.xml
@@ -50,10 +50,10 @@
 <!--               enableCountByExample="false"-->
 <!--               enableUpdateByExample="false" enableDeleteByExample="false"-->
 <!--               enableSelectByExample="false" selectByExampleQueryId="false"/>-->
-        <table tableName="du_js_t_site_latest_time" domainObjectName="DustSiteStatus"
-               enableCountByExample="false"
-               enableUpdateByExample="false" enableDeleteByExample="false"
-               enableSelectByExample="false" selectByExampleQueryId="false"/>
+<!--        <table tableName="du_js_t_site_latest_time" domainObjectName="DustSiteStatus"-->
+<!--               enableCountByExample="false"-->
+<!--               enableUpdateByExample="false" enableDeleteByExample="false"-->
+<!--               enableSelectByExample="false" selectByExampleQueryId="false"/>-->
 <!--        <table tableName="du_js_t_site_map" domainObjectName="DustSiteMap"-->
 <!--               enableCountByExample="false"-->
 <!--               enableUpdateByExample="false" enableDeleteByExample="false"-->
@@ -82,5 +82,13 @@
 <!--               enableCountByExample="false"-->
 <!--               enableUpdateByExample="false" enableDeleteByExample="false"-->
 <!--               enableSelectByExample="false" selectByExampleQueryId="false"/>-->
+        <table tableName="du_js_t_request_task_log" domainObjectName="RequestTaskLog"
+               enableCountByExample="false"
+               enableUpdateByExample="false" enableDeleteByExample="false"
+               enableSelectByExample="false" selectByExampleQueryId="false"/>
+        <table tableName="du_js_t_request_task" domainObjectName="RequestTask"
+               enableCountByExample="false"
+               enableUpdateByExample="false" enableDeleteByExample="false"
+               enableSelectByExample="false" selectByExampleQueryId="false"/>
     </context>
 </generatorConfiguration>
\ No newline at end of file
diff --git a/src/main/resources/mapper/ds1/RequestTaskLogMapper.xml b/src/main/resources/mapper/ds1/RequestTaskLogMapper.xml
new file mode 100644
index 0000000..70dea2b
--- /dev/null
+++ b/src/main/resources/mapper/ds1/RequestTaskLogMapper.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.flightfeather.monitor.domain.ds1.mapper.RequestTaskLogMapper">
+  <resultMap id="BaseResultMap" type="com.flightfeather.monitor.domain.ds1.entity.RequestTaskLog">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="request_id" jdbcType="INTEGER" property="requestId" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="log_type" jdbcType="VARCHAR" property="logType" />
+  </resultMap>
+  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.flightfeather.monitor.domain.ds1.entity.RequestTaskLog">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    <result column="log" jdbcType="LONGVARCHAR" property="log" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    id, request_id, create_time, log_type
+  </sql>
+  <sql id="Blob_Column_List">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    log
+  </sql>
+</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/ds1/RequestTaskMapper.xml b/src/main/resources/mapper/ds1/RequestTaskMapper.xml
new file mode 100644
index 0000000..1828534
--- /dev/null
+++ b/src/main/resources/mapper/ds1/RequestTaskMapper.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.flightfeather.monitor.domain.ds1.mapper.RequestTaskMapper">
+  <resultMap id="BaseResultMap" type="com.flightfeather.monitor.domain.ds1.entity.RequestTask">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
+    <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
+    <result column="running_status" jdbcType="BIT" property="runningStatus" />
+    <result column="success" jdbcType="BIT" property="success" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    id, start_time, end_time, running_status, success
+  </sql>
+</mapper>
\ No newline at end of file

--
Gitblit v1.9.3