Commit 5b8b3076 authored by 赵建伟's avatar 赵建伟

update codes

parent 8c3d46f7
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="18c38e3b-9b7f-4a3f-b141-edcb320b1d24" name="Default Changelist" comment="" />
<list default="true" id="18c38e3b-9b7f-4a3f-b141-edcb320b1d24" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/conf/en-cn.properties" beforeDir="false" afterPath="$PROJECT_DIR$/conf/en-cn.properties" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -125,6 +127,8 @@
<workItem from="1588248522289" duration="2820000" />
<workItem from="1588344251422" duration="21636000" />
<workItem from="1588761853482" duration="3826000" />
<workItem from="1588905392183" duration="4522000" />
<workItem from="1589447155495" duration="7400000" />
</task>
<task id="LOCAL-00001" summary="add init codes.">
<created>1587723565207</created>
......
......@@ -2,6 +2,7 @@ demo=示例程序-demo
demo_bak=示例程序-demo_bak
demo_param=带参数的示例程序
demo_java=JAVA实例程序
meigou-detail-page=美购详情页
meigou-detail-page-dispense-pv=美购详情页分发pv
meigou-detail-page-dispense-uv=美购详情页分发uv
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="73604af3-3cbc-41f8-9a5f-e6a14a2ada76" name="Default Changelist" comment="add" />
<list default="true" id="73604af3-3cbc-41f8-9a5f-e6a14a2ada76" name="Default Changelist" comment="add">
<change beforePath="$PROJECT_DIR$/../../../conf/en-cn.properties" beforeDir="false" afterPath="$PROJECT_DIR$/../../../conf/en-cn.properties" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -217,6 +219,7 @@
<workItem from="1588344252163" duration="15923000" />
<workItem from="1588762492573" duration="403000" />
<workItem from="1588837331043" duration="673000" />
<workItem from="1589455301393" duration="4293000" />
</task>
<servers />
</component>
......
package com.gmei.data.gateway.server.service;
public interface EmailService {
int sendAttachmentsMail(String to,String cc,String subject);
int sendAttachmentsMail(String to,String cc,String name);
int sendFormatedMail(String to,String cc,String name,String content);
}
......@@ -75,4 +75,41 @@ public class EmailServiceImpl implements EmailService {
}
return rs;
}
@Override
public int sendFormatedMail(String to,String cc,String name, String htmlContent){
int rs = Constants.SUCCESS;
// 主题内容转义
String subject = "";
String value = ProperUtils.getValue(properFilePath, name);
if(null != value){
subject = value;
}else{
subject = name;
}
// 邮件发送逻辑
MimeMessage message = mailSender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(message, true,"UTF-8");
helper.setFrom(from);
String[] toUsers = to.split(",");
helper.setTo(toUsers);
helper.setSubject(subject);
helper.setText(htmlContent, true);
if (cc != null && !"".equals(cc.trim())) {
String[] ccUsers = cc.split(",");
helper.setCc(ccUsers);
}
if (bcc != null && !"".equals(bcc.trim())) {
String[] bccUsers = bcc.split(",");
helper.setBcc(bccUsers);
}
mailSender.send(message);
logger.info("格式化的邮件已经发送。");
} catch (Exception e) {
logger.error("格式化后的邮件发送异常!", e);
rs = Constants.FAIL;
}
return rs;
}
}
......@@ -45,29 +45,29 @@ public class ExcelServiceImpl implements ExcelService {
@Override
public int genExcel(ExcelGenDto excelGenDto, String name) {
int rs = Constants.SUCCESS;
List<String> sheetNameList = excelGenDto.getSheetNameList();
List<List<String>> headersList = excelGenDto.getHeadersList();
List<List<List>> rowsList = excelGenDto.getRowsList();
XSSFWorkbook wb = new XSSFWorkbook();
if(null != sheetNameList && sheetNameList.size() > 0){
List<XSSFSheet> sheets = new ArrayList<XSSFSheet>();
for(int i=0;i<sheetNameList.size();i++){
XSSFSheet sheet = wb.createSheet(sheetNameList.get(i));
sheets.add(sheet);
}
this.output(wb,sheets,headersList,rowsList);
}else{
rs = Constants.FAIL;
logger.error("Error!");
}
// String subject = "";
// String value = ProperUtils.getValue(properFilePath, name);
// if(null != value){
// subject = value;
// }else{
// subject = name;
// }
try {
List<String> sheetNameList = excelGenDto.getSheetNameList();
List<List<String>> headersList = excelGenDto.getHeadersList();
List<List<List>> rowsList = excelGenDto.getRowsList();
XSSFWorkbook wb = new XSSFWorkbook();
if(null != sheetNameList && sheetNameList.size() > 0){
List<XSSFSheet> sheets = new ArrayList<XSSFSheet>();
for(int i=0;i<sheetNameList.size();i++){
XSSFSheet sheet = wb.createSheet(sheetNameList.get(i));
sheets.add(sheet);
}
this.output(wb,sheets,headersList,rowsList);
}else{
rs = Constants.FAIL;
logger.error("Error!");
}
// String subject = "";
// String value = ProperUtils.getValue(properFilePath, name);
// if(null != value){
// subject = value;
// }else{
// subject = name;
// }
FileOutputStream out = new FileOutputStream(filePath + name + "-" + DateUtils.getYesterdayDateSimpleStr() + ".xlsx");
wb.write(out);
out.close();
......
......@@ -21,6 +21,12 @@ public class EmailServiceTest {
@Test
public void testSendAttachmentsMail() {
emailService.sendAttachmentsMail("zhaojianwei@igengmei.com","jianweizhao@yeah.net","敏感稽查元数据库账户");
emailService.sendAttachmentsMail("zhaojianwei@igengmei.com","jianweizhao@yeah.net","demo");
}
@Test
public void testSendFormattedMail() {
String htmlContent = "<h1>demo</h1>";
emailService.sendFormatedMail("zhaojianwei@igengmei.com","jianweizhao@yeah.net","demo",htmlContent);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment