Commit 8e4adb6c by manxiaoqiang

2

parent cea61169
......@@ -16,6 +16,9 @@ public interface AccountRepository extends JpaRepository<Account, Long> {
@Query(value = "select root_parent from account where id=?1", nativeQuery = true)
BigInteger findRootParentByAccountId(Long accountId);
@Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and DATE_FORMAT(pub_date,'%Y-%m-%d') = ?1", nativeQuery = true)
List<Account> findRootParentsByPubDate(String date);
@Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and past_date > ?1", nativeQuery = true)
List<Account> findRootParentsUnPast(String today);
......
package tkio.task;
import common.model.Contract;
import common.repository.ContractRepository;
import dic.ContractTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import tkio.model.Account;
import tkio.repository.AccountRepository;
import util.DateUtil;
import util.ValidateUtil;
import java.util.ArrayList;
import java.util.List;
/**
* Created by mxq on 2018/4/23.
*/
public class AccountCheck {
@Autowired
AccountRepository accountRepository;
@Autowired
ContractRepository contractRepository;
public void task(){
List<Account> accountList = accountRepository.findRootParentsByPubDate(DateUtil.getBeforeDays(30));
if(ValidateUtil.isValid(accountList)){
List<Account> list = new ArrayList<>();
for(Account a: accountList){
List<Contract> contractList = contractRepository.findByPlatformAndEmail("tkio", a.getEmail(), ContractTypeEnum.MAIN.getKey());
if(null == contractList){
a.setStatus(0);
list.add(a);
}
if(ValidateUtil.isValid(list)){
accountRepository.save(list);
}
}
}
}
}
......@@ -22,6 +22,9 @@ public interface IOAccountRepository extends JpaRepository<Account, Long> {
@Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and past_date < ?1", nativeQuery = true)
List<Account> findRootParentsPast(String today);
@Query(value = "SELECT * from account where is_super_user is true and `status` = 1 and DATE_FORMAT(pub_date,'%Y-%m-%d') = ?1", nativeQuery = true)
List<Account> findRootParentsByPubDate(String date);
@Query(value = "SELECT * from account where is_super_user is true and `status` = 0", nativeQuery = true)
List<Account> findRootParentsForidin();
......
package userio.task;
import common.model.Contract;
import common.repository.ContractRepository;
import dic.ContractTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import userio.model.Account;
import userio.repository.IOAccountRepository;
import util.DateUtil;
import util.ValidateUtil;
import java.util.ArrayList;
import java.util.List;
/**
* Created by mxq on 2018/4/23.
*/
public class IOAccountCheck {
@Autowired
IOAccountRepository accountRepository;
@Autowired
ContractRepository contractRepository;
public void task(){
List<Account> accountList = accountRepository.findRootParentsByPubDate(DateUtil.getBeforeDays(30));
if(ValidateUtil.isValid(accountList)){
List<Account> list = new ArrayList<>();
for(Account a: accountList){
List<Contract> contractList = contractRepository.findByPlatformAndEmail("io", a.getEmail(), ContractTypeEnum.MAIN.getKey());
if(null == contractList){
a.setStatus(0);
list.add(a);
}
if(ValidateUtil.isValid(list)){
accountRepository.save(list);
}
}
}
}
}
......@@ -51,4 +51,16 @@
<task:scheduled ref="ioAccountTask" method="task" cron="0 10 10 * * ?"/>
</task:scheduled-tasks>
<bean id="ioAccountTaskCheck" class="userio.task.IOAccountCheck"></bean>
<task:scheduled-tasks>
<!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled ref="ioAccountTaskCheck" method="task" cron="0 10 10 * * ?"/>
</task:scheduled-tasks>
<bean id="accountTaskCheck" class="tkio.task.AccountCheck"></bean>
<task:scheduled-tasks>
<!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled ref="accountTaskCheck" method="task" cron="0 10 10 * * ?"/>
</task:scheduled-tasks>
</beans>
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