Commit 35e393f2 authored by 赵建伟's avatar 赵建伟

upadte codes

parent c55121af
<?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 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" />
......@@ -119,7 +121,8 @@
<workItem from="1588152481879" duration="139000" />
<workItem from="1588154352798" duration="195000" />
<workItem from="1588220085338" duration="7993000" />
<workItem from="1588248522289" duration="867000" />
<workItem from="1588248522289" duration="2820000" />
<workItem from="1588344251422" duration="1056000" />
</task>
<task id="LOCAL-00001" summary="add init codes.">
<created>1587723565207</created>
......
demo=示例程序
demo_param=带参数的示例程序
\ No newline at end of file
<?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 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" />
......@@ -215,7 +217,8 @@
<workItem from="1584945647680" duration="4469000" />
<workItem from="1588148891822" duration="2318000" />
<workItem from="1588152718016" duration="1463000" />
<workItem from="1588154601852" duration="27470000" />
<workItem from="1588154601852" duration="28557000" />
<workItem from="1588344252163" duration="1178000" />
</task>
<servers />
</component>
......@@ -284,24 +287,28 @@
</state>
<state x="553" y="153" key="CommitChangelistDialog2/246.1080.1920.1151/0.22.1920.1058@0.22.1920.1058" timestamp="1584956237641" />
<state x="784" y="1223" key="CommitChangelistDialog2/246.1080.1920.1151/0.22.1920.1058@246.1080.1920.1151" timestamp="1588154132365" />
<state width="1878" height="244" key="GridCell.Tab.0.bottom" timestamp="1588242806115">
<screen x="246" y="1080" width="1920" height="1151" />
<state width="1878" height="238" key="GridCell.Tab.0.bottom" timestamp="1588345465517">
<screen x="0" y="22" width="1920" height="1129" />
</state>
<state width="1878" height="238" key="GridCell.Tab.0.bottom/0.22.1920.1129@0.22.1920.1129" timestamp="1588345465517" />
<state width="1878" height="321" key="GridCell.Tab.0.bottom/246.1080.1920.1151/0.22.1920.1058@0.22.1920.1058" timestamp="1584688137007" />
<state width="1878" height="244" key="GridCell.Tab.0.bottom/246.1080.1920.1151/0.22.1920.1058@246.1080.1920.1151" timestamp="1588242806115" />
<state width="1878" height="244" key="GridCell.Tab.0.center" timestamp="1588242806111">
<screen x="246" y="1080" width="1920" height="1151" />
<state width="1878" height="238" key="GridCell.Tab.0.center" timestamp="1588345465516">
<screen x="0" y="22" width="1920" height="1129" />
</state>
<state width="1878" height="238" key="GridCell.Tab.0.center/0.22.1920.1129@0.22.1920.1129" timestamp="1588345465516" />
<state width="1878" height="321" key="GridCell.Tab.0.center/246.1080.1920.1151/0.22.1920.1058@0.22.1920.1058" timestamp="1584688137005" />
<state width="1878" height="244" key="GridCell.Tab.0.center/246.1080.1920.1151/0.22.1920.1058@246.1080.1920.1151" timestamp="1588242806111" />
<state width="1878" height="244" key="GridCell.Tab.0.left" timestamp="1588242806109">
<screen x="246" y="1080" width="1920" height="1151" />
<state width="1878" height="238" key="GridCell.Tab.0.left" timestamp="1588345465515">
<screen x="0" y="22" width="1920" height="1129" />
</state>
<state width="1878" height="238" key="GridCell.Tab.0.left/0.22.1920.1129@0.22.1920.1129" timestamp="1588345465515" />
<state width="1878" height="321" key="GridCell.Tab.0.left/246.1080.1920.1151/0.22.1920.1058@0.22.1920.1058" timestamp="1584688137005" />
<state width="1878" height="244" key="GridCell.Tab.0.left/246.1080.1920.1151/0.22.1920.1058@246.1080.1920.1151" timestamp="1588242806108" />
<state width="1878" height="244" key="GridCell.Tab.0.right" timestamp="1588242806112">
<screen x="246" y="1080" width="1920" height="1151" />
<state width="1878" height="238" key="GridCell.Tab.0.right" timestamp="1588345465517">
<screen x="0" y="22" width="1920" height="1129" />
</state>
<state width="1878" height="238" key="GridCell.Tab.0.right/0.22.1920.1129@0.22.1920.1129" timestamp="1588345465517" />
<state width="1878" height="321" key="GridCell.Tab.0.right/246.1080.1920.1151/0.22.1920.1058@0.22.1920.1058" timestamp="1584688137006" />
<state width="1878" height="244" key="GridCell.Tab.0.right/246.1080.1920.1151/0.22.1920.1058@246.1080.1920.1151" timestamp="1588242806112" />
<state width="1878" height="319" key="GridCell.Tab.1.bottom" timestamp="1588216559611">
......@@ -324,9 +331,10 @@
<screen x="0" y="22" width="1920" height="1058" />
</state>
<state x="560" y="291" key="Vcs.Push.Dialog.v2/246.1080.1920.1151/0.22.1920.1058@0.22.1920.1058" timestamp="1584949293518" />
<state x="715" y="1270" width="670" height="675" key="run.anything.popup" timestamp="1588241253713">
<screen x="246" y="1080" width="1920" height="1151" />
<state x="469" y="208" width="670" height="663" key="run.anything.popup" timestamp="1588345465540">
<screen x="0" y="22" width="1920" height="1129" />
</state>
<state x="469" y="208" width="670" height="663" key="run.anything.popup/0.22.1920.1129@0.22.1920.1129" timestamp="1588345465540" />
<state x="715" y="1270" width="670" height="675" key="run.anything.popup/246.1080.1920.1151/0.22.1920.1058@246.1080.1920.1151" timestamp="1588241253713" />
</component>
</project>
\ No newline at end of file
......@@ -18,9 +18,8 @@ public class BiReportEndpoint {
}
@ResponseBody
@RequestMapping(value = "/sendEmail/{to}/{cc}/{name}/{subject}",method = RequestMethod.GET)
public int sendEmail(@PathVariable("to") String to,@PathVariable("cc") String cc,@PathVariable("name") String name,
@PathVariable("subject") String subject){
return biReportService.sendEmail(to,cc,name,subject);
@RequestMapping(value = "/sendEmailExtend/{to}/{cc}/{name}",method = RequestMethod.GET)
public int sendEmailExtend(@PathVariable("to") String to,@PathVariable("cc") String cc,@PathVariable("name") String name){
return biReportService.sendEmail(to,cc,name);
}
}
......@@ -2,5 +2,5 @@ package com.gmei.data.gateway.server.service;
public interface BiReportService {
int genExcel(String name);
int sendEmail(String to,String cc,String name,String subject);
int sendEmail(String to,String cc,String name);
}
......@@ -3,5 +3,5 @@ package com.gmei.data.gateway.server.service;
import com.gmei.data.gateway.server.dto.ExcelGenDto;
public interface ExcelService {
int genExcel(ExcelGenDto excelGenDto, String subject);
int genExcel(ExcelGenDto excelGenDto, String name);
}
......@@ -36,12 +36,12 @@ public class BiReportServiceImpl implements BiReportService {
}
@Override
public int sendEmail(String to,String cc,String name,String subject){
public int sendEmail(String to,String cc,String name){
int rs = Constants.SUCCESS;
ExcelGenDto resultDto = sparksqlService.getResultDto(name);
int genExcelRs = excelService.genExcel(resultDto, subject);
int genExcelRs = excelService.genExcel(resultDto,name);
if(Constants.SUCCESS == genExcelRs){
rs = emailService.sendAttachmentsMail(to,cc,subject);
rs = emailService.sendAttachmentsMail(to,cc,name);
}
return rs;
}
......
......@@ -3,6 +3,7 @@ package com.gmei.data.gateway.server.service.impl;
import com.gmei.data.gateway.server.common.Constants;
import com.gmei.data.gateway.server.service.EmailService;
import com.gmei.data.gateway.server.utils.DateUtils;
import com.gmei.data.gateway.server.utils.ProperUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -27,13 +28,24 @@ public class EmailServiceImpl implements EmailService {
private String bcc;
@Value("${excel.output.path}")
private String filePath;
@Value("${proper.file.path}")
private String properFilePath;
@Autowired
private JavaMailSender mailSender;
private static final Logger logger = LoggerFactory.getLogger(EmailServiceImpl.class);
@Override
public int sendAttachmentsMail(String to,String cc,String subject){
public int sendAttachmentsMail(String to,String cc,String name){
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);
......
......@@ -4,6 +4,7 @@ import com.gmei.data.gateway.server.common.Constants;
import com.gmei.data.gateway.server.dto.ExcelGenDto;
import com.gmei.data.gateway.server.service.ExcelService;
import com.gmei.data.gateway.server.utils.DateUtils;
import com.gmei.data.gateway.server.utils.ProperUtils;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
......@@ -33,6 +34,8 @@ public class ExcelServiceImpl implements ExcelService {
@Value("${excel.output.path}")
private String filePath;
@Value("${proper.file.path}")
private String properFilePath;
private static final Logger logger = LoggerFactory.getLogger(ExcelServiceImpl.class);
/**
......@@ -40,7 +43,7 @@ public class ExcelServiceImpl implements ExcelService {
* @return
*/
@Override
public int genExcel(ExcelGenDto excelGenDto, String subject) {
public int genExcel(ExcelGenDto excelGenDto, String name) {
int rs = Constants.SUCCESS;
List<String> sheetNameList = excelGenDto.getSheetNameList();
List<List<String>> headersList = excelGenDto.getHeadersList();
......@@ -57,6 +60,13 @@ public class ExcelServiceImpl implements ExcelService {
rs = Constants.FAIL;
logger.error("Error!");
}
String subject = "";
String value = ProperUtils.getValue(properFilePath, name);
if(null != value){
subject = value;
}else{
subject = name;
}
try {
FileOutputStream out = new FileOutputStream(filePath + subject + "-" + DateUtils.getCurrentDateSimpleStr() + ".xlsx");
wb.write(out);
......
......@@ -72,7 +72,7 @@ public class SparksqlServiceImpl implements SparksqlService {
String hql = sbf.toString();
Connection conn = null;
try{
conn = DriverManager.getConnection(sparksqlJdbcUrl,"data","");
conn = DriverManager.getConnection(sparksqlJdbcUrl);
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery(hql);
ResultSetMetaData metaData = rs.getMetaData();
......
package com.gmei.data.gateway.server.utils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* @ClassName ProperUtils
* @Author apple
* @Date 2020/5/1
* @Version V1.0
**/
public class ProperUtils {
/**
* 根据属性文件路径、key获取value的值
* @param path
* @param key
* @return
*/
public static String getValue(String path,String key){
Properties properties = getProperties(path);
return properties.getProperty(key);
}
/**
* 获取属性文件对象
*
* @param path
* @return
*/
private static Properties getProperties(String path) {
Properties properties = new Properties();
try {
InputStream inputStream = ProperUtils.class.getClassLoader().getResourceAsStream(path);
properties.load(inputStream);
inputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return properties;
}
}
......@@ -34,3 +34,7 @@ excel:
#---log config---
logging:
config: classpath:logback.xml
proper:
file:
path: /home/bi/bi-report/conf/en-cn.properties
\ No newline at end of file
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