燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-20 8185e5cdc2bbdf7fb4ca46a10864106893a01ed3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.yssh.config;
 
import com.yssh.service.WarningAnalyseService;
import com.yssh.service.XlsReportService;
import com.yssh.utils.CacheUtils;
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;
 
import com.yssh.service.CommonService;
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 Logger logger = LoggerFactory.getLogger(this.getClass());
 
    @Resource
    private CommonService commonService;
 
    @Resource
    private DictRecordService dictRecordService;
 
    @Resource
    WarningAnalyseService warningAnalyseService;
 
    @Resource
    ScheduleConfig task;
 
    @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();
 
        boolean tableExists = commonService.checkTableExists("dict_record");
        if (!tableExists) dictRecordService.createDictRecoTable();
 
        // 读取dat数据
        commonService.readDatData();
 
        logger.info("***************** 系统启动完毕 *****************" + "\n");
        test();
    }
 
    private void test() {
        //task.createMonthReport();
        //task.corpReserveDataSync();
 
        //warningAnalyseService.warningOperationStorage(cal.getTime());
 
        /*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());*/
    }
}