|
@@ -1,17 +1,21 @@
|
|
package com.ruoyi.project.plant.controller;
|
|
package com.ruoyi.project.plant.controller;
|
|
|
|
|
|
-import java.io.FileNotFoundException;
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.io.OutputStream;
|
|
|
|
|
|
+import java.io.*;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
+import com.ruoyi.common.sendEmail.IMailService;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
+import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
+import com.ruoyi.framework.config.RuoYiConfig;
|
|
import com.ruoyi.project.plant.domain.TMtOpextrack;
|
|
import com.ruoyi.project.plant.domain.TMtOpextrack;
|
|
|
|
+import com.ruoyi.project.plant.domain.TMtdDaily;
|
|
|
|
+import com.ruoyi.project.plant.domain.TMtdEmail;
|
|
import com.ruoyi.project.plant.mapper.TMtOpextrackMapper;
|
|
import com.ruoyi.project.plant.mapper.TMtOpextrackMapper;
|
|
import com.ruoyi.project.plant.service.*;
|
|
import com.ruoyi.project.plant.service.*;
|
|
import com.ruoyi.project.production.domain.TMonthplan;
|
|
import com.ruoyi.project.production.domain.TMonthplan;
|
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.xwpf.usermodel.*;
|
|
import org.apache.poi.xwpf.usermodel.*;
|
|
@@ -58,6 +62,12 @@ public class TMtMeetingController extends BaseController
|
|
private TMtOpextrackMapper tMtOpextrackMapper;
|
|
private TMtOpextrackMapper tMtOpextrackMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private ITMtPersonService tMtPersonService;
|
|
private ITMtPersonService tMtPersonService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IMailService mailService;
|
|
|
|
+ //系统基础配置
|
|
|
|
+ @Autowired
|
|
|
|
+ private RuoYiConfig ruoyiConfig;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询装置会议列表
|
|
* 查询装置会议列表
|
|
*/
|
|
*/
|
|
@@ -100,7 +110,9 @@ public class TMtMeetingController extends BaseController
|
|
@GetMapping("/last")
|
|
@GetMapping("/last")
|
|
public AjaxResult getLast(TMtMeeting tMtMeeting)
|
|
public AjaxResult getLast(TMtMeeting tMtMeeting)
|
|
{
|
|
{
|
|
- return AjaxResult.success(tMtMeetingService.selectTMtMeetingLast(tMtMeeting));
|
|
|
|
|
|
+ TMtMeeting t = tMtMeetingService.selectTMtMeetingLast(tMtMeeting);
|
|
|
|
+ t.setId(null);
|
|
|
|
+ return AjaxResult.success(t);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -111,7 +123,11 @@ public class TMtMeetingController extends BaseController
|
|
@PostMapping
|
|
@PostMapping
|
|
public AjaxResult add(@RequestBody TMtMeeting tMtMeeting)
|
|
public AjaxResult add(@RequestBody TMtMeeting tMtMeeting)
|
|
{
|
|
{
|
|
- return toAjax(tMtMeetingService.insertTMtMeeting(tMtMeeting));
|
|
|
|
|
|
+ tMtMeetingService.insertTMtMeeting(tMtMeeting);
|
|
|
|
+ String url = getReport(null,tMtMeeting.getId());
|
|
|
|
+ tMtMeeting.setWordUrl(url);
|
|
|
|
+ tMtMeetingService.updateTMtMeeting(tMtMeeting);
|
|
|
|
+ return AjaxResult.success();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -122,7 +138,11 @@ public class TMtMeetingController extends BaseController
|
|
@PutMapping
|
|
@PutMapping
|
|
public AjaxResult edit(@RequestBody TMtMeeting tMtMeeting)
|
|
public AjaxResult edit(@RequestBody TMtMeeting tMtMeeting)
|
|
{
|
|
{
|
|
- return toAjax(tMtMeetingService.updateTMtMeeting(tMtMeeting));
|
|
|
|
|
|
+ tMtMeetingService.updateTMtMeeting(tMtMeeting);
|
|
|
|
+ String url = getReport(null,tMtMeeting.getId());
|
|
|
|
+ tMtMeeting.setWordUrl(url);
|
|
|
|
+ tMtMeetingService.updateTMtMeeting(tMtMeeting);
|
|
|
|
+ return AjaxResult.success();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -139,11 +159,10 @@ public class TMtMeetingController extends BaseController
|
|
/**
|
|
/**
|
|
* 生成报告
|
|
* 生成报告
|
|
*/
|
|
*/
|
|
- @RequestMapping(value = "/meetingReport", produces = "application/json;charset=utf-8")
|
|
|
|
- @ResponseBody
|
|
|
|
- public void AutoReport(HttpServletRequest request, HttpServletResponse response, Long year ,Long meetingId) {
|
|
|
|
|
|
+// @RequestMapping(value = "/meetingReport", produces = "application/json;charset=utf-8")
|
|
|
|
+// @ResponseBody
|
|
|
|
+ public String getReport( Long year ,Long meetingId) {
|
|
logger.info("meetingId:" + meetingId);
|
|
logger.info("meetingId:" + meetingId);
|
|
- String savePath = request.getSession().getServletContext().getRealPath("/"); // 系统根路径
|
|
|
|
String tempUrl = "";
|
|
String tempUrl = "";
|
|
tempUrl = "static/word/meeting.docx"; // 经理模板文件
|
|
tempUrl = "static/word/meeting.docx"; // 经理模板文件
|
|
// 保存结果文
|
|
// 保存结果文
|
|
@@ -154,18 +173,37 @@ public class TMtMeetingController extends BaseController
|
|
// 替换word模板数据
|
|
// 替换word模板数据
|
|
replaceAll(doc,year,meetingId);
|
|
replaceAll(doc,year,meetingId);
|
|
|
|
|
|
- response.setContentType("application/octet-stream");// 下载,默认就是下载
|
|
|
|
- response.setCharacterEncoding("UTF-8");
|
|
|
|
- response.setHeader("Content-Disposition",
|
|
|
|
- "attachment;fileName=" + URLEncoder.encode("meetingReport" + ".docx", "UTF-8"));
|
|
|
|
|
|
+// response.setContentType("application/octet-stream");// 下载,默认就是下载
|
|
|
|
+// response.setCharacterEncoding("UTF-8");
|
|
|
|
+// response.setHeader("Content-Disposition",
|
|
|
|
+// "attachment;fileName=" + URLEncoder.encode("meetingReport" + ".docx", "UTF-8"));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 生成word的路径
|
|
|
|
+ String fileDir = RuoYiConfig.getProfile() + "/" + "plant/meeting";
|
|
|
|
+ // 生成word的文件名称
|
|
|
|
+ String fileName = "装置周会议"+ meetingId + ".docx";
|
|
|
|
+ String filePath = fileDir + "/" + fileName;
|
|
|
|
+ File dir = new File(fileDir);
|
|
|
|
+ if (!dir.exists()) {
|
|
|
|
+ logger.info("目录不存在,创建文件夹{}!", fileDir);
|
|
|
|
+ dir.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ FileOutputStream out = new FileOutputStream(filePath);
|
|
|
|
+ doc.write(out);
|
|
|
|
+ out.close();
|
|
|
|
+ String pathFileName = FileUploadUtils.getPathFileName(RuoYiConfig.getFilePath("/" + "plant/meeting"), fileName);
|
|
|
|
+ logger.info("pathFileName::::::::" + pathFileName);
|
|
|
|
+ return pathFileName;
|
|
// 刷新缓冲
|
|
// 刷新缓冲
|
|
- response.flushBuffer();
|
|
|
|
- OutputStream ouputStream = response.getOutputStream();
|
|
|
|
- doc.write(ouputStream);
|
|
|
|
- ouputStream.flush();
|
|
|
|
- ouputStream.close();
|
|
|
|
|
|
+// response.flushBuffer();
|
|
|
|
+// OutputStream ouputStream = response.getOutputStream();
|
|
|
|
+// doc.write(ouputStream);
|
|
|
|
+// ouputStream.flush();
|
|
|
|
+// ouputStream.close();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ return "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
@@ -313,4 +351,86 @@ public class TMtMeetingController extends BaseController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 发送调度会议邮件
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('plant:dailyMeeting:edit')")
|
|
|
|
+ @Log(title = "发送调度会议邮件", businessType = BusinessType.OTHER)
|
|
|
|
+ @GetMapping("/sendMail")
|
|
|
|
+ public AjaxResult sendMail(TMtMeeting tMtMeeting)
|
|
|
|
+ {
|
|
|
|
+ TMtMeeting mtMeeting = tMtMeetingService.selectTMtMeetingById(tMtMeeting.getId());
|
|
|
|
+
|
|
|
|
+ //写html开始内容
|
|
|
|
+ String start = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title></title></head><body><div style=\"background-color:#ECECEC; padding: 35px;\">" +
|
|
|
|
+ "<table cellpadding=\"0\" align=\"center\"" +
|
|
|
|
+ "style=\"width: 600px; margin: 0px auto; text-align: left; position: relative; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; font-size: 14px; font-family:微软雅黑, 黑体; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0px 0px 5px; border-collapse: collapse; background-position: initial initial; background-repeat: initial initial;background:#fff;\">" +
|
|
|
|
+ "<tbody><tr><th valign=\"middle\" style=\"height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #42a3d3; background-color: #49bcff; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px;\">" +
|
|
|
|
+ "<font face=\"微软雅黑\" size=\"5\" style=\"color: rgb(255, 255, 255); \">化工装置管理系统 </font><font face=\"微软雅黑\" size=\"3\" style=\"color: rgb(255, 255, 255); \">Chemical Plant Management System(CPMS)</font></th></tr>";
|
|
|
|
+ //写html结尾内容
|
|
|
|
+ String end = "</tbody></table></div></body></html>";
|
|
|
|
+ String username = "";
|
|
|
|
+
|
|
|
|
+// email = "735032128@qq.com";
|
|
|
|
+ //表html中间内容
|
|
|
|
+ String prime = "";
|
|
|
|
+ String firstcenter = "<tr><td><div style=\"padding:25px 35px 40px; background-color:#fff;\"><h2 style=\"margin: 5px 0px; \">" +
|
|
|
|
+ "<font color=\"#333333\" style=\"line-height: 20px; \"><font style=\"line-height: 22px; \" size=\"4\">" +
|
|
|
|
+ "亲爱的 CPMS用户</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
|
|
|
|
+ "<p>您有一条新的调度会议:<br>" +
|
|
|
|
+ "会议日期:<b>meetingDate</b><br>" +
|
|
|
|
+ "请前往<a href=\"requestJumpPath/plant/meeting/detail/dailyId\">会议详情</a>查看或下载邮件附件。<br>" +
|
|
|
|
+ "<p align=\"right\">date</p>" +
|
|
|
|
+ "<div style=\"width:700px;margin:0 auto;\">" +
|
|
|
|
+ "<div style=\"padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;\">" +
|
|
|
|
+ "<p>此为系统邮件,请勿回复<br>This e-Mail is an automatic reminder sent by CPMS, please do not reply</p>" +
|
|
|
|
+ "</div></div></div></td></tr>";
|
|
|
|
+
|
|
|
|
+ String pattern = "yyyy年MM月dd日"; // 定义日期格式化模板
|
|
|
|
+
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); // 创建日期格式化器
|
|
|
|
+
|
|
|
|
+ String formattedDate = dateFormat.format(mtMeeting.getMeetingDate()); // 将日期转换为字符串
|
|
|
|
+
|
|
|
|
+ String one = firstcenter.replaceFirst("meetingDate", formattedDate);
|
|
|
|
+ String two = one.replace("requestJumpPath", this.ruoyiConfig.getRequestJumpPath());
|
|
|
|
+ String three = two.replace("dailyId", mtMeeting.getId().toString());
|
|
|
|
+ String result = three.replaceFirst("date", dateFormat.format(new Date()));
|
|
|
|
+ prime = prime + result;
|
|
|
|
+ //拼接html
|
|
|
|
+ String html = start + prime + end;
|
|
|
|
+
|
|
|
|
+ // 需要转换的文件路径
|
|
|
|
+ String filePath = RuoYiConfig.getProfile()+mtMeeting.getWordUrl().replace("/profile","");
|
|
|
|
+
|
|
|
|
+ //发送人和抄送人
|
|
|
|
+ String[] email = {"735032128@qq.com", "1213269375@qq.com"};
|
|
|
|
+ String[] emailCc = {"ly@seashoreept.com", "ly735032128@gmail.com"};
|
|
|
|
+
|
|
|
|
+ ArrayList<String> emailList = new ArrayList<>();
|
|
|
|
+ ArrayList<String> emailCcList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+// List<TMtdEmail> list = tMtdEmailService.selectTMtdEmailList(new TMtdEmail());
|
|
|
|
+// for (TMtdEmail t: list
|
|
|
|
+// ) {
|
|
|
|
+// SysUser user = sysUserService.selectUserByStaffId(t.getStaffid());
|
|
|
|
+// if (user != null) {
|
|
|
|
+// if (t.getType() == 1) {
|
|
|
|
+// emailList.add(user.getEmail());
|
|
|
|
+// }
|
|
|
|
+// if (t.getType() == 2) {
|
|
|
|
+// emailCcList.add(user.getEmail());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+ email = emailList.toArray(new String[emailList.size()]);
|
|
|
|
+ emailCc = emailCcList.toArray(new String[emailCcList.size()]);
|
|
|
|
+ logger.info("发送人:" + email.toString());
|
|
|
|
+ logger.info("抄送人:" + emailCc.toString());
|
|
|
|
+ mailService.sendAttachmentsMail(email, "CPMS:您有一条"+ formattedDate+"装置调度会议信息", html, emailCc,filePath);
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|