liupeng 4 年 前
コミット
7a755fd63b

+ 0 - 1
code/sapparent/sapcms/src/main/resources/spring-content.xml

@@ -51,5 +51,4 @@
 		<!-- 去掉 JSESSIONID -->
 		<property name="sessionIdUrlRewritingEnabled" value="false" />
 	</bean>
-	<task:annotation-driven/>
 </beans>

+ 0 - 40
code/sapparent/sapservice/src/main/java/org/fouram/job/AutoCheckJob.java

@@ -1,40 +0,0 @@
-package org.fouram.job;
-
-import org.fouram.core.util.DateUtil;
-import org.fouram.core.util.LoggerUtil;
-import org.fouram.service.CheckTaskService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-@Service
-public class AutoCheckJob {
-
-	@Autowired
-	private CheckTaskService checkTaskService;
-
-	@Scheduled(cron = "0 30 10/2 * * ?")
-	@Transactional
-	public void executeJob1() {
-		LoggerUtil.info("executeJob1 : " + DateUtil.getTime());
-		checkTaskService.executeBiz(DateUtil.getDate());
-		LoggerUtil.info("executeJob1 : " + DateUtil.getTime());
-	}
-
-	@Scheduled(cron = "0 0 15/7 * * ?")
-	@Transactional
-	public void executeJob2() {
-		LoggerUtil.info("executeJob2 : " + DateUtil.getTime());
-		checkTaskService.executeBiz(DateUtil.getDate());
-		LoggerUtil.info("executeJob2 : " + DateUtil.getTime());
-	}
-
-	@Scheduled(cron = "0 0 20/12 * * ?")
-	@Transactional
-	public void executeJob3() {
-		LoggerUtil.info("executeJob3 : " + DateUtil.getTime());
-		checkTaskService.executeBiz(DateUtil.getDate());
-		LoggerUtil.info("executeJob3 : " + DateUtil.getTime());
-	}
-}

+ 19 - 16
code/sapparent/sapservice/src/main/java/org/fouram/service/CheckTaskService.java

@@ -1,5 +1,6 @@
 package org.fouram.service;
 
+import org.fouram.core.util.DateUtil;
 import org.fouram.core.util.LoggerUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -23,23 +24,25 @@ public class CheckTaskService {
 	private SapApprovalInfoService sapApprovalInfoService;
 
 	public void executeBiz(String checkinDay) {
-		String startDay = checkinDay;
-		String endDay = checkinDay;
-		try {
-			wxDepartService.saveDeparts();
-			wxUserService.saveUsers();
-			sapCheckService.saveCheckInOffOuts(startDay, endDay);
-			// 判断打卡记录小于10条记录认为是假期
-			if(sapCheckService.queryCheckInTotal() < 10) {
-				return;
+		if(DateUtil.getHour().equals("10") || DateUtil.getHour().equals("20")) {
+			String startDay = checkinDay;
+			String endDay = checkinDay;
+			try {
+				wxDepartService.saveDeparts();
+				wxUserService.saveUsers();
+				sapCheckService.saveCheckInOffOuts(startDay, endDay);
+				// 判断打卡记录小于10条记录认为是假期
+				if(sapCheckService.queryCheckInTotal() < 10) {
+					return;
+				}
+				sapCheckdateService.saveCheckout(startDay);
+				employeeTimeService.saveEmployeeTimes();
+				sapCheckOptionService.saveOptions(endDay);
+				sapApprovalInfoService.saveApprovalInfos(endDay.substring(0, 7));
+				sapCheckService.saveReportResultData(startDay, endDay);
+			} catch (Exception e) {
+				LoggerUtil.error(e);
 			}
-			sapCheckdateService.saveCheckout(startDay);
-			employeeTimeService.saveEmployeeTimes();
-			sapCheckOptionService.saveOptions(endDay);
-			sapApprovalInfoService.saveApprovalInfos(endDay.substring(0, 7));
-			sapCheckService.saveReportResultData(startDay, endDay);
-		} catch (Exception e) {
-			LoggerUtil.error(e);
 		}
 	}
 }

+ 36 - 0
code/sapparent/sapservice/src/main/resources/spring/quartz.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:context="http://www.springframework.org/schema/context"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
+	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
+	xsi:schemaLocation="
+	   http://www.springframework.org/schema/beans
+	   http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+	   http://www.springframework.org/schema/tx
+	   http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
+	   http://www.springframework.org/schema/aop
+	   http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
+	   http://www.springframework.org/schema/context
+	   http://www.springframework.org/schema/context/spring-context-4.3.xsd
+	   http://www.springframework.org/schema/mvc
+	   http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"
+	default-autowire="byName">
+
+	<bean id="syncCheckJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
+		<property name="targetObject" ref="checkTaskService" />  
+		<property name="targetMethod" value="executeBiz" />  
+		<property name="concurrent" value="false" />
+	</bean>
+	<bean id="syncCheckTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">  
+		<property name="jobDetail" ref="syncCheckJob" />
+		<property name="cronExpression" value="0 30 * * * ?" />
+	</bean>
+	
+	<bean id="schedulerFactorys" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
+		<property name="triggers">
+			<list>
+				<ref bean="syncCheckTrigger" />
+			</list>
+		</property>
+	</bean>
+</beans>