|
@@ -1,7 +1,6 @@
|
|
|
package com.szwl.controller;
|
|
|
|
|
|
import com.szwl.service.TDepartmentService;
|
|
|
-import com.szwl.service.TShandeMchService;
|
|
|
import com.szwl.service.es.EsTCoinOrderService;
|
|
|
import com.szwl.service.es.EsTOrderService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -10,7 +9,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
+import java.net.InetAddress;
|
|
|
+import java.net.UnknownHostException;
|
|
|
import java.util.Calendar;
|
|
|
|
|
|
|
|
@@ -21,30 +21,50 @@ public class ScheduledService {
|
|
|
@Autowired
|
|
|
private TDepartmentService tDepartmentService;
|
|
|
@Autowired
|
|
|
- private TShandeMchService tShandeMchService;
|
|
|
- @Autowired
|
|
|
EsTCoinOrderService esTCoinOrderService;
|
|
|
@Autowired
|
|
|
EsTOrderService esTOrderService;
|
|
|
|
|
|
- //值日通知
|
|
|
-// @Scheduled(cron = "0 20 8 * * ?")
|
|
|
-// public void scheduled(){
|
|
|
-// Calendar calendar = Calendar.getInstance();
|
|
|
-// int number = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
-// if(number!=1){
|
|
|
-// tDepartmentService.onTime();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// @Scheduled(cron = "0 55 17 * * ?")
|
|
|
-// public void scheduled2(){
|
|
|
-// Calendar calendar = Calendar.getInstance();
|
|
|
-// int number = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
-// if(number!=1){
|
|
|
-// tDepartmentService.onTime2();
|
|
|
-// }
|
|
|
-// }
|
|
|
|
|
|
+ // 值日通知1
|
|
|
+ // 每天8:20执行一次
|
|
|
+ @Scheduled(cron = "0 20 8 * * ?")
|
|
|
+ public void scheduled() {
|
|
|
+ if(isDo()){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ int number = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ // 如果不是周日 1
|
|
|
+ if(number!=1){
|
|
|
+ tDepartmentService.onTime();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ private Boolean isDo() {
|
|
|
+ try {
|
|
|
+ String hostAddress = InetAddress.getLocalHost().getHostAddress();
|
|
|
+ // 弹性112.74.63.148服务器的私网ip
|
|
|
+ if(hostAddress.equals("10.0.0.153")){
|
|
|
+ return true;
|
|
|
+ }else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } catch (UnknownHostException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
+ // 值日通知2
|
|
|
+ // 每天17:55执行一次
|
|
|
+ @Scheduled(cron = "0 55 17 * * ?")
|
|
|
+ public void scheduled2(){
|
|
|
+ if(isDo()){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ int number = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ if(number!=1){
|
|
|
+ tDepartmentService.onTime2();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|