Commit 6f09bbeb8ec7b21d8d7b5529e29d6717dbba795a
1 parent
5917e358
1.路单发送后多邮箱通知
Showing
2 changed files
with
47 additions
and
40 deletions
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| @@ -31,7 +31,9 @@ import org.apache.commons.lang.time.DateUtils; | @@ -31,7 +31,9 @@ import org.apache.commons.lang.time.DateUtils; | ||
| 31 | import org.joda.time.DateTime; | 31 | import org.joda.time.DateTime; |
| 32 | import org.slf4j.Logger; | 32 | import org.slf4j.Logger; |
| 33 | import org.slf4j.LoggerFactory; | 33 | import org.slf4j.LoggerFactory; |
| 34 | +import org.springframework.beans.factory.InitializingBean; | ||
| 34 | import org.springframework.beans.factory.annotation.Autowired; | 35 | import org.springframework.beans.factory.annotation.Autowired; |
| 36 | +import org.springframework.beans.factory.annotation.Value; | ||
| 35 | import org.springframework.data.domain.Sort; | 37 | import org.springframework.data.domain.Sort; |
| 36 | import org.springframework.data.domain.Sort.Direction; | 38 | import org.springframework.data.domain.Sort.Direction; |
| 37 | import org.springframework.stereotype.Service; | 39 | import org.springframework.stereotype.Service; |
| @@ -64,7 +66,7 @@ import java.util.regex.Pattern; | @@ -64,7 +66,7 @@ import java.util.regex.Pattern; | ||
| 64 | */ | 66 | */ |
| 65 | 67 | ||
| 66 | @Service | 68 | @Service |
| 67 | -public class TrafficManageServiceImpl implements TrafficManageService{ | 69 | +public class TrafficManageServiceImpl implements TrafficManageService { |
| 68 | 70 | ||
| 69 | Logger logger = LoggerFactory.getLogger(this.getClass()); | 71 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 70 | 72 | ||
| @@ -157,7 +159,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -157,7 +159,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 157 | // 密码 | 159 | // 密码 |
| 158 | private final String passwordUp = "user"; | 160 | private final String passwordUp = "user"; |
| 159 | // 接收邮件人 | 161 | // 接收邮件人 |
| 160 | - private final String emailSendToAddress = "175912183@qq.com"; | 162 | + @Value("${waybill.emails}") |
| 163 | + private String[] emails; | ||
| 161 | // 记录路单上线的成功、失败线路数 | 164 | // 记录路单上线的成功、失败线路数 |
| 162 | private Integer countSuccess,countFailure; | 165 | private Integer countSuccess,countFailure; |
| 163 | 166 | ||
| @@ -558,11 +561,13 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -558,11 +561,13 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 558 | logger.error("setLD:", e); | 561 | logger.error("setLD:", e); |
| 559 | } finally { | 562 | } finally { |
| 560 | try { | 563 | try { |
| 561 | - //发送邮件 | ||
| 562 | - EmailBean mail = new EmailBean(); | ||
| 563 | - mail.setSubject(IpUtils.getLocalIpAddress() +":路单日志数据"+date); | ||
| 564 | - mail.setContent("总数:" + (listGroup == null ? 0 : listGroup.size()) + "<br/>成功数:" + scount + "<br/>跳过数:" + ccount + "<br/>耗时:" + (System.currentTimeMillis() - start)); | ||
| 565 | - sendEmailController.sendMail(emailSendToAddress, mail); | 564 | + for (String email : emails) { |
| 565 | + //发送邮件 | ||
| 566 | + EmailBean mail = new EmailBean(); | ||
| 567 | + mail.setSubject(IpUtils.getLocalIpAddress() +":路单日志数据"+date); | ||
| 568 | + mail.setContent("总数:" + (listGroup == null ? 0 : listGroup.size()) + "<br/>成功数:" + scount + "<br/>跳过数:" + ccount + "<br/>耗时:" + (System.currentTimeMillis() - start)); | ||
| 569 | + sendEmailController.sendMail(email, mail); | ||
| 570 | + } | ||
| 566 | logger.info("setLD-sendMail:邮件发送成功!"); | 571 | logger.info("setLD-sendMail:邮件发送成功!"); |
| 567 | } catch (Exception e) { | 572 | } catch (Exception e) { |
| 568 | e.printStackTrace(); | 573 | e.printStackTrace(); |
src/main/resources/application-prod.properties
| 1 | -server.port=9088 | ||
| 2 | -management.port= 9001 | ||
| 3 | -management.address= 127.0.0.1 | ||
| 4 | - | ||
| 5 | -spring.jpa.hibernate.ddl-auto= none | ||
| 6 | -spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy | ||
| 7 | -#DATABASE | ||
| 8 | -spring.jpa.database= MYSQL | ||
| 9 | -spring.jpa.show-sql= false | ||
| 10 | -spring.datasource.driver-class-name= com.mysql.jdbc.Driver | ||
| 11 | -spring.datasource.url= jdbc:mysql://192.168.168.171:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | ||
| 12 | -spring.datasource.username= root | ||
| 13 | -spring.datasource.password= root2jsp | ||
| 14 | -#DATASOURCE | ||
| 15 | -spring.datasource.max-active=100 | ||
| 16 | -spring.datasource.max-idle=8 | ||
| 17 | -spring.datasource.min-idle=8 | ||
| 18 | -spring.datasource.initial-size=5 | ||
| 19 | - | ||
| 20 | -spring.datasource.test-on-borrow=true | ||
| 21 | -spring.datasource.test-on-connect=true | ||
| 22 | -spring.datasource.test-on-return=true | ||
| 23 | -spring.datasource.test-while-idle=true | ||
| 24 | -spring.datasource.validation-query=select 1 | ||
| 25 | - | ||
| 26 | -## | ||
| 27 | -#222.66.0.204:5555 | ||
| 28 | -##\u5B9E\u65F6gps | ||
| 29 | -http.gps.real.url= http://192.168.168.171:8080/transport_server/rtgps/ | ||
| 30 | -##\u6D88\u606F\u4E0B\u53D1 | ||
| 31 | -http.send.directive = http://192.168.168.171:8080/transport_server/message/ | ||
| 32 | -## increment offset | ||
| 33 | -auto_increment_offset= -1 | 1 | +server.port=9088 |
| 2 | +management.port= 9001 | ||
| 3 | +management.address= 127.0.0.1 | ||
| 4 | + | ||
| 5 | +spring.jpa.hibernate.ddl-auto= none | ||
| 6 | +spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy | ||
| 7 | +#DATABASE | ||
| 8 | +spring.jpa.database= MYSQL | ||
| 9 | +spring.jpa.show-sql= false | ||
| 10 | +spring.datasource.driver-class-name= com.mysql.jdbc.Driver | ||
| 11 | +spring.datasource.url= jdbc:mysql://192.168.168.171:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | ||
| 12 | +spring.datasource.username= root | ||
| 13 | +spring.datasource.password= root2jsp | ||
| 14 | +#DATASOURCE | ||
| 15 | +spring.datasource.max-active=100 | ||
| 16 | +spring.datasource.max-idle=8 | ||
| 17 | +spring.datasource.min-idle=8 | ||
| 18 | +spring.datasource.initial-size=5 | ||
| 19 | + | ||
| 20 | +spring.datasource.test-on-borrow=true | ||
| 21 | +spring.datasource.test-on-connect=true | ||
| 22 | +spring.datasource.test-on-return=true | ||
| 23 | +spring.datasource.test-while-idle=true | ||
| 24 | +spring.datasource.validation-query=select 1 | ||
| 25 | + | ||
| 26 | +## | ||
| 27 | +#222.66.0.204:5555 | ||
| 28 | +##\u5B9E\u65F6gps | ||
| 29 | +http.gps.real.url= http://192.168.168.171:8080/transport_server/rtgps/ | ||
| 30 | +##\u6D88\u606F\u4E0B\u53D1 | ||
| 31 | +http.send.directive = http://192.168.168.171:8080/transport_server/message/ | ||
| 32 | +## increment offset | ||
| 33 | +auto_increment_offset= -1 | ||
| 34 | +## send waybill results | ||
| 35 | +waybill.emails= 113252620@qq.com,mhkyzd@163.com |