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

update codes

parent 8c3d46f7
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <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="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -125,6 +127,8 @@ ...@@ -125,6 +127,8 @@
<workItem from="1588248522289" duration="2820000" /> <workItem from="1588248522289" duration="2820000" />
<workItem from="1588344251422" duration="21636000" /> <workItem from="1588344251422" duration="21636000" />
<workItem from="1588761853482" duration="3826000" /> <workItem from="1588761853482" duration="3826000" />
<workItem from="1588905392183" duration="4522000" />
<workItem from="1589447155495" duration="7400000" />
</task> </task>
<task id="LOCAL-00001" summary="add init codes."> <task id="LOCAL-00001" summary="add init codes.">
<created>1587723565207</created> <created>1587723565207</created>
......
...@@ -2,6 +2,7 @@ demo=示例程序-demo ...@@ -2,6 +2,7 @@ demo=示例程序-demo
demo_bak=示例程序-demo_bak demo_bak=示例程序-demo_bak
demo_param=带参数的示例程序 demo_param=带参数的示例程序
demo_java=JAVA实例程序 demo_java=JAVA实例程序
meigou-detail-page=美购详情页 meigou-detail-page=美购详情页
meigou-detail-page-dispense-pv=美购详情页分发pv meigou-detail-page-dispense-pv=美购详情页分发pv
meigou-detail-page-dispense-uv=美购详情页分发uv meigou-detail-page-dispense-uv=美购详情页分发uv
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <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="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -217,6 +219,7 @@ ...@@ -217,6 +219,7 @@
<workItem from="1588344252163" duration="15923000" /> <workItem from="1588344252163" duration="15923000" />
<workItem from="1588762492573" duration="403000" /> <workItem from="1588762492573" duration="403000" />
<workItem from="1588837331043" duration="673000" /> <workItem from="1588837331043" duration="673000" />
<workItem from="1589455301393" duration="4293000" />
</task> </task>
<servers /> <servers />
</component> </component>
......
package com.gmei.data.gateway.server.service; package com.gmei.data.gateway.server.service;
public interface EmailService { 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 { ...@@ -75,4 +75,41 @@ public class EmailServiceImpl implements EmailService {
} }
return rs; 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,6 +45,7 @@ public class ExcelServiceImpl implements ExcelService { ...@@ -45,6 +45,7 @@ public class ExcelServiceImpl implements ExcelService {
@Override @Override
public int genExcel(ExcelGenDto excelGenDto, String name) { public int genExcel(ExcelGenDto excelGenDto, String name) {
int rs = Constants.SUCCESS; int rs = Constants.SUCCESS;
try {
List<String> sheetNameList = excelGenDto.getSheetNameList(); List<String> sheetNameList = excelGenDto.getSheetNameList();
List<List<String>> headersList = excelGenDto.getHeadersList(); List<List<String>> headersList = excelGenDto.getHeadersList();
List<List<List>> rowsList = excelGenDto.getRowsList(); List<List<List>> rowsList = excelGenDto.getRowsList();
...@@ -60,14 +61,13 @@ public class ExcelServiceImpl implements ExcelService { ...@@ -60,14 +61,13 @@ public class ExcelServiceImpl implements ExcelService {
rs = Constants.FAIL; rs = Constants.FAIL;
logger.error("Error!"); logger.error("Error!");
} }
// String subject = ""; // String subject = "";
// String value = ProperUtils.getValue(properFilePath, name); // String value = ProperUtils.getValue(properFilePath, name);
// if(null != value){ // if(null != value){
// subject = value; // subject = value;
// }else{ // }else{
// subject = name; // subject = name;
// } // }
try {
FileOutputStream out = new FileOutputStream(filePath + name + "-" + DateUtils.getYesterdayDateSimpleStr() + ".xlsx"); FileOutputStream out = new FileOutputStream(filePath + name + "-" + DateUtils.getYesterdayDateSimpleStr() + ".xlsx");
wb.write(out); wb.write(out);
out.close(); out.close();
......
...@@ -21,6 +21,12 @@ public class EmailServiceTest { ...@@ -21,6 +21,12 @@ public class EmailServiceTest {
@Test @Test
public void testSendAttachmentsMail() { 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