AccountTask.java 1.99 KB
Newer Older
1 2 3 4 5 6 7 8
package track.task;


import common.model.TrackAccount4Web;
import common.repository.TrackAccount4WebRepository;
import org.springframework.beans.factory.annotation.Autowired;
import track.model.Account;
import track.repository.TrackAccountRepository;
manxiaoqiang committed
9
import track.service.TrackAccountFlowRestrictService;
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
import util.DateUtil;
import util.ValidateUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by mxq on 2017/12/25.
 */
public class AccountTask {

    @Autowired
    TrackAccountRepository trackAccountRepository;
    @Autowired
    TrackAccount4WebRepository trackAccount4WebRepository;
manxiaoqiang committed
25 26
    @Autowired
    TrackAccountFlowRestrictService trackAccountFlowRestrictService;
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

    public void task(){
        trackAccount4WebRepository.deleteAll();
        List<TrackAccount4Web> list = new ArrayList<>();
        List<Account> accountList = trackAccountRepository.findAllParent();
        String today = DateUtil.getBeforeDays(0);
        if(ValidateUtil.isValid(accountList)){
            for(Account ac : accountList){
                TrackAccount4Web account4Web = new TrackAccount4Web();
                    account4Web.setAccountId(ac.getId());
                    account4Web.setEmail(ac.getEmail());
                    account4Web.setCompany(ac.getCompany());
                    account4Web.setCreateDate(ac.getPubDate());
                    if(today.compareTo(ac.getPastDate()) > 0){
                        account4Web.setStatus("已过期");
                    }else{
                        account4Web.setStatus("已激活");
                    }
manxiaoqiang committed
45
                    account4Web.setTrack(trackAccountFlowRestrictService.findRestrictByAccount(ac));
46 47 48 49 50 51 52 53 54 55 56
                    account4Web.setPastDate(ac.getPastDate());
                    account4Web.setUser(ac.getName());
                    account4Web.setTell(ac.getPhone());
                    list.add(account4Web);
            }
        }
        if(ValidateUtil.isValid(list)){
            trackAccount4WebRepository.save(list);
        }
    }
}