Browse Source

怡海能达发邮件项目,处理重发问题

zhoudw 6 years ago
parent
commit
96c6022b88

+ 24 - 0
src/main/java/com/uas/eis/core/config/MyWebAppInitializer.java

@@ -0,0 +1,24 @@
+package com.uas.eis.core.config;
+
+import org.springframework.web.WebApplicationInitializer;
+import org.springframework.web.context.support.XmlWebApplicationContext;
+import org.springframework.web.servlet.DispatcherServlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRegistration;
+
+/**
+ * Created by zdw
+ * 2019-04-22 11:25.
+ */
+public class MyWebAppInitializer implements WebApplicationInitializer {
+
+    @Override
+    public void onStartup(ServletContext container) {
+        XmlWebApplicationContext appContext = new XmlWebApplicationContext();
+        appContext.setConfigLocation("application.properties");
+        ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(appContext));
+//        dispatcher.setLoadOnStartup(1);
+        dispatcher.addMapping("/");
+    }
+}

+ 5 - 0
src/main/java/com/uas/eis/service/SendArbillmailService.java

@@ -8,4 +8,9 @@ public interface SendArbillmailService {
 
     public void send_abillmail();
 
+    public void send_abillmailbymaster_sz();
+
+    public void send_abillmailbymaster_hk();
+
+
 }

+ 6 - 9
src/main/java/com/uas/eis/serviceImpl/SendArbillmailServiceImpl.java

@@ -25,6 +25,7 @@ public class SendArbillmailServiceImpl implements SendArbillmailService{
 
     public void send_abillmail() {
         send_abillmailbymaster_sz();
+
         send_abillmailbymaster_hk();
     }
 
@@ -54,11 +55,9 @@ public class SendArbillmailServiceImpl implements SendArbillmailService{
             Object total=baseDao.queryForObject("select to_char(sum(RESAMOUNT), 'FM9,999,999,999,999,999,999,999,990.00')  from UNFULLCOLLECT_VIEW where CU_SELLERNAME = '"+emrs.getString("name")+"' or CU_SERVICENAME = '"+emrs.getString("name")+"'",String.class);
             message.append("<tr><th><font color=\"red\">合计<font></th><th></th><th></th><th></th><th align=\"right\"><font color=\"red\">"+total.toString()+"<font></th></tr>");
             message.append("</table><p><font color=\"red\">如有疑问请联系系统维护人员,谢谢!</font></p><p><font color=\"red\">日期:"+ DateUtil.format(new Date(),"yyyy-MM-dd")+"</font></p>");
-
-            message.append("<p>正式抄送:"+ccman.toString()+"</p>");
-
             //            sendMailService.sendSysMail("应收款到期7天提醒("+emrs.getString("name")+")",message.toString(),emrs.getString("mail"),ccman.toString(),null);
-            sendMailService.sendSysMail("应收款到期7天提醒("+emrs.getString("name")+")",message.toString(),"396996717@qq.com","727300463@qq.com;xiaolu.ding@hi-mantech.com",null);
+            sendMailService.sendSysMail("应收款到期7天提醒("+emrs.getString("name")+")",message.toString(),"396996717@qq.com","geek94@qq.com;zdw941008@sina.com",null);
+//            System.out.println("应收款到期7天提醒("+emrs.getString("name")+")");
 //            System.out.println(emrs.getString("mail"));
 //			System.out.println(ccman.toString());
 //			System.out.println(message);
@@ -94,11 +93,9 @@ public class SendArbillmailServiceImpl implements SendArbillmailService{
             Object total_rmb=baseDao.queryForObject("select to_char(sum(RESAMOUNT_RMB), 'FM9,999,999,999,999,999,999,999,990.00')  from UNFULLCOLLECT_VIEW where CU_SELLERNAME = '"+emrs.getString("name")+"' or CU_SERVICENAME = '"+emrs.getString("name")+"'",String.class);
             message.append("<tr><th><font color=\"red\">合计<font></th><th></th><th></th><th></th><th></th><th align=\"right\"><font color=\"red\">"+total.toString()+"<font></th><th align=\"right\"><font color=\"red\">" + total_rmb.toString() + "<font></th></tr>");
             message.append("</table><p><font color=\"red\">如有疑问请联系系统维护人员,谢谢!</font></p><p><font color=\"red\">日期:"+ DateUtil.format(new Date(),"yyyy-MM-dd")+"</font></p>");
-
-            message.append("<p>正式抄送:"+ccman.toString()+"</p>");
-
-            //            sendMailService.sendSysMail("应收款到期7天提醒("+emrs.getString("name")+")",message.toString(),emrs.getString("mail"),ccman.toString(),null);
-            sendMailService.sendSysMail("应收款到期7天提醒("+emrs.getString("name")+")",message.toString(),"396996717@qq.com","727300463@qq.com;xiaolu.ding@hi-mantech.com",null);
+            //sendMailService.sendSysMail("应收款到期7天提醒("+emrs.getString("name")+")",message.toString(),emrs.getString("mail"),ccman.toString(),null);
+            sendMailService.sendSysMail("应收款到期7天提醒("+emrs.getString("name")+")",message.toString(),"396996717@qq.com","geek94@qq.com;zdw941008@sina.com",null);
+//            System.out.println("应收款到期7天提醒("+emrs.getString("name")+")");
 //            System.out.println(emrs.getString("mail"));
 //            System.out.println(ccman.toString());
 //            System.out.println(message);

+ 2 - 2
src/main/java/com/uas/eis/serviceImpl/SendMailServciceImpl.java

@@ -55,7 +55,7 @@ public class SendMailServciceImpl implements SendMailService {
 	 * @param files
 	 * 			附件
 	 */
-	public  void sendSysMail(String title, String context,String tomail,String ccmail,List<String> files){
+	public synchronized  void sendSysMail(String title, String context,String tomail,String ccmail,List<String> files){
 		String regex = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$";
 		String email= Mail.SetEmail;
 		String password=Mail.SetEmailPassword;
@@ -136,7 +136,7 @@ public class SendMailServciceImpl implements SendMailService {
                 }
 			}
 			mailSender.send(mimeMessage);
-			logger.info("邮件--"+title+",发送给:"+tomail+",抄送给:"+tomail+" 发送成功!");
+			logger.info("邮件--"+title+",发送给:"+tomail+",抄送给:"+ccmail+" 发送成功!");
 		} catch (Exception e) {
 			if(e instanceof MailSendException){
 				logger.error(error.toString());

+ 7 - 5
src/main/java/com/uas/eis/task/ArbillTask.java

@@ -14,11 +14,13 @@ public class ArbillTask {
     @Autowired
     SendArbillmailService sendArbillmailService;
 
+    @Scheduled(cron = "0 10 14 * * ?")
+    public void sendArbill_sz() {
+        sendArbillmailService.send_abillmailbymaster_sz();
+    }
 
-
-//    @Scheduled(cron = "0 40 17 * * ?")
-    @Scheduled(cron = "0 0 9 * * ?")
-    public void sendArbill() {
-        sendArbillmailService.send_abillmail();
+    @Scheduled(cron = "0 15 14 * * ?")
+    public void sendArbill_hk() {
+        sendArbillmailService.send_abillmailbymaster_hk();
     }
 }

+ 24 - 0
src/main/resources/application.properties

@@ -0,0 +1,24 @@
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driverClassName=oracle.jdbc.OracleDriver
+spring.datasource.username=DATACENTER
+spring.datasource.password=select!#%*(
+#spring.datasource.url=jdbc:oracle:thin:@sz.hi-mantech.com:1521:orcl
+spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
+spring.datasource.initialSize=10
+spring.datasource.maxActive=80
+spring.datasource.minIdle=10
+spring.datasource.maxWait=60000
+spring.datasource.testOnBorrow=true
+spring.datasource.testOnReturn=false
+spring.datasource.testWhileIdle=true
+spring.datasource.validationQuery=SELECT 1 FROM DUAL
+spring.datasource.timeBetweenEvictionRunsMillis=60000
+spring.datasource.minEvictableIdleTimeMillis=300000
+spring.datasource.poolPreparedStatements=true
+spring.datasource.maxPoolPreparedStatementPerConnectionSize=80
+spring.datasource.filters=stat
+spring.datasource.removeAbandoned=true
+spring.datasource.removeAbandonedTimeout=1800
+logging.level.org.hibernate.type=trace
+server.tomcat.uri-encoding=UTF-8
+server.port=8009

+ 0 - 52
src/main/resources/application.yml

@@ -1,52 +0,0 @@
-spring:
-    datasource:
-        type: com.alibaba.druid.pool.DruidDataSource
-        driverClassName: oracle.jdbc.OracleDriver
-        username: DATACENTER
-        password: select!#%*(
-#        url: jdbc:oracle:thin:@sz.hi-mantech.com:1521:orcl
-        url: jdbc:oracle:thin:@127.0.0.1:1521:orcl
-        initialSize: 10
-        maxActive: 80
-        minIdle: 10
-        maxWait: 60000
-        testOnBorrow: true
-        testOnReturn: false
-        testWhileIdle: true
-        validationQuery: SELECT 1 FROM DUAL
-        timeBetweenEvictionRunsMillis: 60000
-        minEvictableIdleTimeMillis: 300000
-        poolPreparedStatements: true
-        maxPoolPreparedStatementPerConnectionSize: 80
-        filters: stat
-        removeAbandoned: true
-        removeAbandonedTimeout: 1800
-    http:
-        encoding:
-            force: true
-            charset: UTF-8
-            enabled: true
-    message:
-        encoding: UTF-8
-    jpa:
-      show-sql: false
-      hibernate:
-        ddl-auto: update
-      database: oracle
-
-server:
-    tomcat:
-        uri_encoding: UTF-8
-    port: 8008
-    context-path: /EIS
-action:
-    api_action: /EIS/api
-    public_actions: /EIS/logout,/EIS/hello1
-logging:
-  level:
-    org:
-      hibernate:
-        type: trace
-
-SECURITY_KEY: 435aMe9L5itTrckY35kfcOQvPkBGZtGo
-KEEP: 86400000

+ 10 - 0
src/test/java/com/uas/eis/UasEisApplicationTests.java

@@ -1,6 +1,7 @@
 package com.uas.eis;
 
 import com.uas.eis.dao.BaseDao;
+import com.uas.eis.service.SendArbillmailService;
 import com.uas.eis.service.SendMailService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -16,10 +17,19 @@ public class UasEisApplicationTests {
 	private BaseDao baseDao;
 	@Autowired
 	private SendMailService sendMailService;
+	@Autowired
+	private SendArbillmailService sendArbillmailService;
+
+
 
 	@Test
 	public void contextLoads() {
 		sendMailService.sendSysMail("test","test","396996717@qq.com","727300463@qq.com;xiaolu.ding@hi-mantech.com",null);
 	}
 
+	@Test
+	public void test(){
+		sendArbillmailService.send_abillmail();
+	}
+
 }