src/main/java/com/yssh/controller/EmailController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/service/EmailService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application-dev.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application-file.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application-prod.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application-test.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/QxshMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/yssh/controller/EmailController.java
@@ -34,4 +34,11 @@ return Result.OK(flag); } @ApiOperationSupport(order = 1) @GetMapping("/calcData") @ApiOperation(value = "计算数据", notes = "计算数据") public Result calcData() { return Result.OK(emailService.calcData()); } } src/main/java/com/yssh/service/EmailService.java
@@ -4,13 +4,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.util.Properties; import java.io.File; import java.text.SimpleDateFormat; import java.util.*; /** * 邮件服务类 @@ -46,6 +47,22 @@ @Value("${email.cc}") private String cc; @Value("${csv.bigPath}") private String bigPath; @Value("${csv.filePath}") private String filePath; @Value("${csv.vocPath}") private String vocPath; @Value("${email.hours}") private Integer hours; private final static SimpleDateFormat YMDH = new SimpleDateFormat("yyyyMMddHH"); private final static SimpleDateFormat Y_M_D_H = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); protected final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -102,4 +119,63 @@ return false; } } public int calcData() { List<String> list = new ArrayList<>(); int count = countCsv(bigPath, hours); if (0 == count) { list.add("大CSV近 " + hours + " 小时存在文件缺失,"); } count = countCsv(filePath, hours); if (0 == count) { list.add("中CSV近 " + hours + " 小时存在文件缺失,"); } count = countCsv(vocPath, hours); if (0 == count) { list.add("小CSV近 " + hours + " 小时存在文件缺失,"); } Calendar calendar = getCalendar(1); calendar = getCalendar(0); Integer iEnd = Integer.parseInt(YMDH.format(calendar.getTime())); String sEnd = Y_M_D_H.format(calendar.getTime()); calendar.add(Calendar.HOUR, 1 - hours); Integer iStart = Integer.parseInt(YMDH.format(calendar.getTime())); String sStart = Y_M_D_H.format(calendar.getTime()); int size = list.size(); return size; } public int countCsv(String path, Integer hours) { try { int count = 0; Calendar calendar = getCalendar(1); for (int i = 0; i < hours; i++) { calendar.add(Calendar.HOUR, -1); String filePath = path + File.separator + YMDH.format(calendar.getTime()) + ".csv"; if (new File(filePath).exists()) { count++; } } return count; } catch (Exception ex) { logger.error(ex.getMessage(), ex); return 0; } } public Calendar getCalendar(int start) { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(Calendar.HOUR, start); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; } } src/main/resources/application-dev.yml
@@ -9,6 +9,7 @@ from: 252740454@qq.com to: wuweiwei@terra-it.cn cc: zhengliusuo@smartearth.cn hours: 6 # 数据源配置 spring: src/main/resources/application-file.yml
@@ -4,6 +4,7 @@ filePath3d: E:\yssh_data\dat\correct_jk_47.dat #csv配置路径 csv: bigPath: E:\yssh_data\BIG filePath: E:\yssh_data\LBM-NEW vocPath: E:\yssh_data\VOC_ALL #日/周/月报路径 src/main/resources/application-prod.yml
@@ -9,6 +9,7 @@ from: 252740454@qq.com to: wuweiwei@terra-it.cn cc: zhengliusuo@smartearth.cn hours: 6 # 数据源配置 spring: src/main/resources/application-test.yml
@@ -9,6 +9,7 @@ from: 252740454@qq.com to: wuweiwei@terra-it.cn cc: zhengliusuo@smartearth.cn hours: 6 # 数据源配置 spring: src/main/resources/mapper/QxshMapper.xml
@@ -136,4 +136,24 @@ where time = #{time} and name = #{name} limit 1; </select> <select id="countGcsjByTime" resultType="java.lang.Integer"> select count(*) from yssh_gcsj where time between #{start} and #{end}; </select> <select id="countQxshByTime" resultType="java.lang.Integer"> select count(*) from yssh_qxsh where time between #{start} and #{end}; </select> <select id="countSuYuan46ByTime" resultType="java.lang.Integer"> select count(*) from suyuan_46 where create_time between #{start} and #{end}; </select> <select id="countSuYuan70ByTime" resultType="java.lang.Integer"> select count(*) from suyuan_70_70 where create_time between #{start} and #{end}; </select> <select id="countSuYuanFastByTime" resultType="java.lang.Integer"> select count(*) from suyuan_fast where create_time between #{start} and #{end}; </select> </mapper>