From 8185e5cdc2bbdf7fb4ca46a10864106893a01ed3 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 20 十一月 2024 15:30:12 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/config/InitConfig.java |   69 +++++++++++++++++++++++++++-------
 1 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/yssh/config/InitConfig.java b/src/main/java/com/yssh/config/InitConfig.java
index 7ad74a0..9d51e50 100644
--- a/src/main/java/com/yssh/config/InitConfig.java
+++ b/src/main/java/com/yssh/config/InitConfig.java
@@ -3,10 +3,10 @@
 import com.yssh.service.WarningAnalyseService;
 import com.yssh.service.XlsReportService;
 import com.yssh.utils.CacheUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.yssh.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.stereotype.Component;
@@ -15,11 +15,13 @@
 import com.yssh.service.DictRecordService;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Date;
 
 @Component
 public class InitConfig implements ApplicationRunner {
-    //protected final Log logger = LogFactory.getLog(this.getClass());
+    // protected final Log logger = LogFactory.getLog(this.getClass())
     protected final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     @Resource
@@ -37,6 +39,36 @@
     @Resource
     XlsReportService xlsReportService;
 
+    static String date;
+
+    // YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"
+    static SimpleDateFormat YYYY_MM_DD_HH_MM_SS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    @Value("${dat.date}")
+    public void setDate(String date) {
+        InitConfig.date = date;
+    }
+
+    public static Date getDate() {
+        if (StringUtils.isEmpty(date)) {
+            return new Date();
+        }
+
+        try {
+            return YYYY_MM_DD_HH_MM_SS.parse(date);
+
+            //Calendar calendar = Calendar.getInstance();
+            //calendar.setTime(d);
+            //calendar.set(Calendar.YEAR, d.getYear());
+            //calendar.set(Calendar.MONTH, d.getMonth());
+            //calendar.set(Calendar.DAY_OF_MONTH, d.getDay());
+
+            //return calendar.getTime();
+        } catch (Exception ex) {
+            return new Date();
+        }
+    }
+
     @Override
     public void run(ApplicationArguments args) throws Exception {
         CacheUtils.init();
@@ -52,19 +84,28 @@
     }
 
     private void test() {
+        //task.createMonthReport();
         //task.corpReserveDataSync();
-        //warningAnalyseService.warningOperationStorage(calendar.getTime());
 
-        Calendar cal = Calendar.getInstance();
-        cal.set(Calendar.MONTH, 6);
-        cal.set(Calendar.DAY_OF_MONTH, 25);
-        cal.set(Calendar.HOUR_OF_DAY, 14);
-        cal.set(Calendar.MINUTE, 0);
-        cal.set(Calendar.SECOND, 0);
-        cal.set(Calendar.MILLISECOND, 0);
+        //warningAnalyseService.warningOperationStorage(cal.getTime());
 
-        xlsReportService.createDayReport(cal.getTime());
-        // xlsReportService.createWeekReport();
-        // xlsReportService.createMonthReport();
+        /*Calendar cal1 = Calendar.getInstance();
+        cal1.set(Calendar.MONTH, 6);
+        cal1.set(Calendar.DAY_OF_MONTH, 25);
+        cal1.set(Calendar.HOUR_OF_DAY, 14);
+        cal1.set(Calendar.MINUTE, 0);
+        cal1.set(Calendar.SECOND, 0);
+        cal1.set(Calendar.MILLISECOND, 0);
+        xlsReportService.createDayReport(cal1.getTime());*/
+
+        /*Calendar cal2 = Calendar.getInstance();
+        cal2.set(Calendar.MONTH, 6);
+        cal2.set(Calendar.DAY_OF_MONTH, 31);
+        xlsReportService.createWeekReport(cal2.getTime());*/
+
+        /*Calendar cal3 = Calendar.getInstance();
+        cal3.set(Calendar.MONTH, 7);
+        cal3.set(Calendar.DAY_OF_MONTH, 1);
+        xlsReportService.createMonthReport(cal3.getTime());*/
     }
 }

--
Gitblit v1.9.3