|
@@ -1,11 +1,18 @@
|
|
|
package cn.hnthyy.thmz.common;
|
|
|
|
|
|
+import cn.hnthyy.thmz.entity.his.MzyRequest;
|
|
|
+import cn.hnthyy.thmz.service.his.MzyRequestService;
|
|
|
import cn.hnthyy.thmz.service.thmz.TokenService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 定时任务类
|
|
|
*/
|
|
@@ -17,6 +24,8 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
public class ScheduledService {
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private MzyRequestService mzyRequestService;
|
|
|
/**
|
|
|
* 每20分钟执行一次
|
|
|
*/
|
|
@@ -27,5 +36,34 @@ public class ScheduledService {
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 每天凌晨零点五分运行一次
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "5 0 0 * * *")
|
|
|
+ public void scheduled() {
|
|
|
+ process();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Scheduled(cron = "50 11 * * * *")
|
|
|
+ public void scheduledFull() {
|
|
|
+ process();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理入库数据
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private void process() {
|
|
|
+ List<MzyRequest> requests = mzyRequestService.queryMzyRequestByRequestDay(DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
|
|
|
+ //此时排班表数据没有同步过来,需要手动同步,以后排版系统重做后需要移除此功能
|
|
|
+ if(requests==null || requests.size()==0){
|
|
|
+ mzyRequestService.synchronizationRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|