| | |
| | | import javax.mail.MessagingException; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.nio.file.Files; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private HistoryMonthlyService historyMonthlyService; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private EmailSpringUtil emailSpringUtil; |
| | | |
| | | private final EmailSpringUtil emailSpringUtil; |
| | | |
| | | public PubController(EmailSpringUtil emailSpringUtil) { |
| | | this.emailSpringUtil = emailSpringUtil; |
| | | } |
| | | |
| | | @GetMapping("insertHistoryDaily") |
| | | @ApiOperation(value = "天数据补录", notes = "天数据补录") |
| | |
| | | public void excelDevice() throws IOException { |
| | | String startTime = DateUtils.dateToDateString(DateUtils.addDays(new Date(),-1),DateUtils.yyyy_MM_dd_EN); |
| | | List<DeviceExcelDTO> list = deviceService.ListDeviceExcel(startTime,null,72); |
| | | String path = Objects.requireNonNull(this.getClass().getClassLoader().getResource("")).getPath(); |
| | | // String path = this.getClass().getClassLoader().getResource("/data/file").getPath(); |
| | | String path = System.getProperty("user.dir")+"/"; |
| | | String fileName = String.format("%s疾控中心数据-%s.xlsx",path,startTime); |
| | | ByteArrayOutputStream out = null; |
| | | try { |
| | |
| | | out = ExcelUtil.generateExcel(list, DeviceExcelDTO.class); |
| | | // 发送邮件 |
| | | String content = startTime+"疾控中心设备统计数据"; |
| | | String toMail = "909710561@qq.com"; |
| | | String toMail = "ad@7drlb.com"; |
| | | emailSpringUtil.sendEmail("设备分钟数据",content,false,"909710561@qq.com", |
| | | toMail,"null",null, fileName, new ByteArrayResource(out.toByteArray())); |
| | | toMail,"909710561@qq.com",null, fileName, new ByteArrayResource(out.toByteArray())); |
| | | } catch (IOException e) { |
| | | log.error(String.format("生成excel失败,原因:%s",e)); |
| | | e.printStackTrace(); |