| | |
| | | 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.DictRecordService; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | |
| | | @Component |
| | | public class InitConfig implements ApplicationRunner { |
| | |
| | | @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(); |
| | |
| | | } |
| | | |
| | | 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); |
| | |
| | | package com.yssh.controller; |
| | | |
| | | import com.yssh.config.InitConfig; |
| | | import com.yssh.entity.Report; |
| | | import com.yssh.utils.CacheUtils; |
| | | import com.yssh.utils.DateUtils; |
| | |
| | | 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) { |
| | |
| | | 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) { |
| | |
| | | @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) |
| | |
| | | package com.yssh.controller; |
| | | |
| | | import com.yssh.config.InitConfig; |
| | | import com.yssh.entity.Weather; |
| | | import com.yssh.service.WeatherService; |
| | | import com.yssh.utils.CacheUtils; |
| | |
| | | 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); |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.yssh.config.InitConfig; |
| | | import com.yssh.utils.DateUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | 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; |
| | |
| | | package com.yssh.service; |
| | | |
| | | import com.yssh.config.InitConfig; |
| | | import com.yssh.mapper.QxshMapper; |
| | | import com.yssh.utils.StringUtils; |
| | | import org.slf4j.Logger; |
| | |
| | | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | 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()); |
| | | } |
| | |
| | | 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()); |
| | | } |
| | |
| | | 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()); |
| | | } |
| | |
| | | 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()); |
| | | } |
| | |
| | | } |
| | | |
| | | 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; |
| | | } |
| | |
| | | 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; |
| | |
| | | * 获取本月监测站点最大值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; |
| | |
| | | * 获取本周监测站点最大值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); |
| | |
| | | * 获取本日监测站点最大值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; |
| | |
| | | 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 { |
| | |
| | | "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); |
| | |
| | | } |
| | | |
| | | 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) { |
| | |
| | | * 日期路径 即年/月/日 如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"); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.yssh.utils; |
| | | |
| | | import com.yssh.config.InitConfig; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.FileInputStream; |
| | |
| | | |
| | | 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"; |
| | |
| | | #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配置路径 |
| | |
| | | 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 |
| | | # 最小连接池数量 |