燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-20 8185e5cdc2bbdf7fb4ca46a10864106893a01ed3
1
已修改12个文件
100 ■■■■ 文件已修改
src/main/java/com/yssh/config/InitConfig.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/config/ScheduleConfig.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/controller/WarningAnalyseController.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/controller/WeatherController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/CountService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/EmailService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/SuYuanService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/WarningAnalyseService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/utils/DateUtils.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/utils/WebUtils.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-file.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-test.yml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/config/InitConfig.java
@@ -3,8 +3,10 @@
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;
@@ -13,6 +15,9 @@
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 {
@@ -34,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();
src/main/java/com/yssh/config/ScheduleConfig.java
@@ -178,7 +178,7 @@
    }
    private void loadCsv_old() {
        Date date = DateUtils.getNowDate();
        Date date = InitConfig.getDate();
        String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date);
        String filePath = csvFilePathConfig.getFilePath() + "\\\\" + time + ".csv";
        File file = new File(filePath);
src/main/java/com/yssh/controller/WarningAnalyseController.java
@@ -1,5 +1,6 @@
package com.yssh.controller;
import com.yssh.config.InitConfig;
import com.yssh.entity.Report;
import com.yssh.utils.CacheUtils;
import com.yssh.utils.DateUtils;
@@ -54,7 +55,7 @@
    private Integer getStartTime(Date start, Date end) {
        do {
            if (null == start && null == end) {
                start = DateUtils.getAPeriodOfTime(new Date(), -5, Calendar.HOUR_OF_DAY);
                start = DateUtils.getAPeriodOfTime(InitConfig.getDate(), -5, Calendar.HOUR_OF_DAY);
                break;
            }
            if (null != start && null == end) {
@@ -74,7 +75,7 @@
    private Integer getEndTime(Date start, Date end) {
        do {
            if (null == start && null == end) {
                end = new Date();
                end = InitConfig.getDate();
                break;
            }
            if (null != start && null == end) {
@@ -95,21 +96,21 @@
    @ApiOperation(value = "本月预警报警统计", notes = "本月预警报警统计,返回参数alarmNumber对应值为本月报警数据量,参数warningNumber对应值为本月预警数据量")
    @GetMapping("/monthCount")
    public Result thisMonthCount(@RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.monthCount(null == date ? new Date() : date));
        return Result.OK(warningService.monthCount(null == date ? InitConfig.getDate() : date));
    }
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "一周预警报警数量变化趋势", notes = "一周预警报警数量变化趋势,返回参数alarmDayCount为一周每日报警统计数量列表,参数warningDayCount为一周每日预警统计数量列表")
    @GetMapping("/everydayCount")
    public Result everydayCount(@RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.everydayCount(null == date ? new Date() : date));
        return Result.OK(warningService.everydayCount(null == date ? InitConfig.getDate() : date));
    }
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "三小时监测站点数据变化趋势", notes = "返回值为三小时监测站点监测数据,返回值为map集合,其中key为站点名称,value为list集合,保存每天监测数值数据")
    @GetMapping("/locationDataChange")
    public Result locationDataChange(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.select3Hours(null == date ? new Date() : date));
        return Result.OK(warningService.select3Hours(null == date ? InitConfig.getDate() : date));
    }
    @ApiOperationSupport(order = 6)
src/main/java/com/yssh/controller/WeatherController.java
@@ -1,5 +1,6 @@
package com.yssh.controller;
import com.yssh.config.InitConfig;
import com.yssh.entity.Weather;
import com.yssh.service.WeatherService;
import com.yssh.utils.CacheUtils;
@@ -48,7 +49,7 @@
                begin = dateFormat.format(calendar.getTime());
            }
            if (null == end) {
                end = dateFormat.format(new Date());
                end = dateFormat.format(InitConfig.getDate());
            }
            //List<Weather> list = weatherService.query(begin, end);
src/main/java/com/yssh/service/CountService.java
@@ -7,6 +7,7 @@
import java.util.HashMap;
import java.util.Map;
import com.yssh.config.InitConfig;
import com.yssh.utils.DateUtils;
import org.springframework.stereotype.Service;
@@ -25,7 +26,7 @@
    public Map<String, Double> selectAccuracyAvg() {
        Map<String, Double> result = new HashMap<String, Double>();
        Date nowDate = DateUtils.getNowDate();
        Date nowDate = InitConfig.getDate();
        Long beginTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getAPeriodOfTime(nowDate, -7, Calendar.DATE)));
        Double thuAccuracy = thuAccuracyMapper.selectSevenDayAccuracyAvg(beginTime);
        Double tempForecast = thuAccuracy == null ? 0.0 : thuAccuracy;
src/main/java/com/yssh/service/EmailService.java
@@ -1,5 +1,6 @@
package com.yssh.service;
import com.yssh.config.InitConfig;
import com.yssh.mapper.QxshMapper;
import com.yssh.utils.StringUtils;
import org.slf4j.Logger;
@@ -226,7 +227,7 @@
    public Calendar getCalendar(int start) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.setTime(InitConfig.getDate());
        calendar.add(Calendar.HOUR, start);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
src/main/java/com/yssh/service/SuYuanService.java
@@ -4,6 +4,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import com.yssh.config.InitConfig;
import com.yssh.entity.*;
import com.yssh.mapper.*;
import com.yssh.utils.CalculateUtils;
@@ -137,7 +138,7 @@
            Collections.sort(list);
            DistanceSuYuan max = list.get(0);
            FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
                    max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate());
                    max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, InitConfig.getDate());
            feedbackMapper.insert(feedbackDetail);
            result.put("feedbackId", feedbackDetail.getId());
        }
@@ -186,7 +187,7 @@
            Collections.sort(list);
            DistanceSuYuan max = list.get(0);
            FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
                    max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate());
                    max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, InitConfig.getDate());
            feedbackMapper.insert(feedbackDetail);
            result.put("feedbackId", feedbackDetail.getId());
        }
@@ -221,7 +222,7 @@
            Collections.sort(list);
            DistanceSuYuan max = list.get(0);
            FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
                    max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate());
                    max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, InitConfig.getDate());
            feedbackMapper.insert(feedbackDetail);
            result.put("feedbackId", feedbackDetail.getId());
        }
@@ -256,7 +257,7 @@
            Collections.sort(list);
            DistanceSuYuan max = list.get(0);
            FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
                    max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate());
                    max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, InitConfig.getDate());
            feedbackMapper.insert(feedbackDetail);
            result.put("feedbackId", feedbackDetail.getId());
        }
@@ -293,7 +294,7 @@
    }
    public int updateVocsName(Date date, String id, String vocsName) {
        String table = "su_yuan_" + DateUtils.getYyyyMmDdHh(date); // new Date()
        String table = "su_yuan_" + DateUtils.getYyyyMmDdHh(date);
        if (isTableExists(table) == 0) {
            return 0;
        }
src/main/java/com/yssh/service/WarningAnalyseService.java
@@ -3,6 +3,7 @@
import java.util.*;
import java.util.concurrent.CountDownLatch;
import com.yssh.config.InitConfig;
import com.yssh.entity.*;
import com.yssh.mapper.DictRecordMapper;
import com.yssh.mapper.QxshMapper;
@@ -186,7 +187,7 @@
     * 获取本月监测站点最大值TOP10
     */
    public List<Qxsh> selectMonthTop10() {
        String time = DateUtils.getYyyyMm(new Date());
        String time = DateUtils.getYyyyMm(InitConfig.getDate());
        //List<Qxsh> list = qxshMapper.selectMonthTop10(time + "%");
        String key = "qxshMapper.selectMonthTop10." + time;
@@ -203,7 +204,7 @@
     * 获取本周监测站点最大值TOP10
     */
    public List<Qxsh> selectWeekTop10() {
        Date now = new Date();
        Date now = InitConfig.getDate();
        int weekOfYear = DateUtils.getWeekOfYear(now);
        int year = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYY, now));
        Date lastSun = DateUtils.getWeekOfYearForSun(year, weekOfYear);
@@ -227,7 +228,7 @@
     * 获取本日监测站点最大值TOP10
     */
    public List<Qxsh> selectDayTop10() {
        String time = DateUtils.getYyyyMmDd(new Date());
        String time = DateUtils.getYyyyMmDd(InitConfig.getDate());
        //List<Qxsh> list = qxshMapper.selectDayTop10(time + "%");
        String key = "qxshMapper.selectDayTop10." + time;
src/main/java/com/yssh/utils/DateUtils.java
@@ -5,6 +5,7 @@
import java.text.SimpleDateFormat;
import java.util.*;
import com.yssh.config.InitConfig;
import org.apache.commons.lang3.time.DateFormatUtils;
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
@@ -32,9 +33,6 @@
            "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss",
            "yyyy.MM.dd HH:mm", "yyyy.MM"};
    public static Date getNowDate() {
        return new Date();
    }
    public static String getDate() {
        return dateTimeNow(YYYY_MM_DD);
@@ -49,7 +47,7 @@
    }
    public static final String dateTimeNow(final String format) {
        return parseDateToStr(format, new Date());
        return parseDateToStr(format, InitConfig.getDate());
    }
    public static final String dateTime(final Date date) {
@@ -88,16 +86,14 @@
     * 日期路径 即年/月/日 如2018/08/08
     */
    public static final String datePath() {
        Date now = new Date();
        return DateFormatUtils.format(now, "yyyy/MM/dd");
        return DateFormatUtils.format(InitConfig.getDate(), "yyyy/MM/dd");
    }
    /**
     * 日期路径 即年/月/日 如20180808
     */
    public static final String dateTime() {
        Date now = new Date();
        return DateFormatUtils.format(now, "yyyyMMdd");
        return DateFormatUtils.format(InitConfig.getDate(), "yyyyMMdd");
    }
    /**
src/main/java/com/yssh/utils/WebUtils.java
@@ -1,5 +1,7 @@
package com.yssh.utils;
import com.yssh.config.InitConfig;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
@@ -11,7 +13,7 @@
    public static void download(String file, String fileName, boolean inline, HttpServletResponse res) throws Exception {
        if (StringUtils.isEmpty(fileName)) {
            fileName = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date());
            fileName = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, InitConfig.getDate());
        }
        fileName = URLEncoder.encode(fileName, "UTF-8").replace("+", "%20");
        String dispose = inline ? "inline" : "attachment";
src/main/resources/application-file.yml
@@ -1,5 +1,6 @@
#dat配置路径
dat:
  date: 2023-08-08 09:00:00
  filePath2d: E:\yssh_data\dat\extract_mesh.dat
  filePath3d: E:\yssh_data\dat\correct_jk_47.dat
#csv配置路径
src/main/resources/application-test.yml
@@ -21,11 +21,11 @@
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driverClassName: com.mysql.cj.jdbc.Driver
        url: jdbc:mysql://127.0.0.1:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
        #url: jdbc:mysql://192.168.11.206:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
        #url: jdbc:mysql://127.0.0.1:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
        url: jdbc:mysql://192.168.11.206:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
        username: root
        password: mysql
        #password: 123456
        #password: mysql
        password: 123456
        # 初始连接数
        initialSize: 10
        # 最小连接池数量