Commit 3119ff4e by manxiaoqiang

定时任务

parent 1695457b
......@@ -2,6 +2,9 @@ package tkio.task;
import common.model.Account4Web;
import common.repository.Account4WebRepository;
import common.task.SyncAppDataTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import tkio.model.Account;
import tkio.model.AccountRestrict4Web;
......@@ -23,6 +26,7 @@ import java.util.Map;
* Created by mxq on 2017/12/25.
*/
public class AccountTask {
private static Logger logger = LoggerFactory.getLogger(AccountTask.class);
@Autowired
AccountRepository accountRepository;
......@@ -40,6 +44,7 @@ public class AccountTask {
SalesManLeaderRepository salesManLeaderRepository;
public void task(){
logger.info("tkio task start :" + System.currentTimeMillis());
//清空前一天数据
account4WebRepository.deleteAll();
List<Account4Web> list = new ArrayList<>();
......@@ -47,6 +52,7 @@ public class AccountTask {
List<Account> accountValidList = accountRepository.findRootParentsUnPast(DateUtil.getBeforeDays(1));
if(ValidateUtil.isValid(accountValidList)){
for(Account ac : accountValidList){
try{
AccountRestrict4Web restrict4Web = accountFlowRestrictService.findRestrictByAccount(ac.getId());
Account4Web account4Web = new Account4Web();
account4Web.setAccountId(ac.getId());
......@@ -85,6 +91,10 @@ public class AccountTask {
account4Web.setTell(ac.getPhone());
account4Web.setBussinessMan(ac.getBussinessman());
list.add(account4Web);
} catch (Exception e){
logger.error("tkio task error :" + ac.getEmail());
}
}
}
//已过期的直接设置成过期
......@@ -113,5 +123,6 @@ public class AccountTask {
}
}
account4WebRepository.save(list);
logger.info("tkio task end :" + System.currentTimeMillis());
}
}
......@@ -12,7 +12,7 @@
<bean id="tkioAccountTask" class="tkio.task.AccountTask"></bean>
<task:scheduled-tasks>
<!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled ref="tkioAccountTask" method="task" cron="0 22 2 * * ?"/>
<task:scheduled ref="tkioAccountTask" method="task" cron="0 38 2 * * ?"/>
</task:scheduled-tasks>
<bean id="tkioNoticeTask" class="tkio.task.NoticeTask"></bean>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment