wang-hao-jie
2021-12-10 0837147172f82ca1abec71cfdb81ff63ee56cdfb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cn.exrick.xboot.your.schedulings;
import cn.exrick.xboot.your.entity.Area;
import cn.exrick.xboot.your.entity.Customer;
import cn.exrick.xboot.your.service.IAreaSectionService;
import cn.exrick.xboot.your.service.IAreaService;
import cn.exrick.xboot.your.service.ICustomerService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.io.IOException;
import java.util.List;
 
//大屏配送分析
@Component
public class CarScheduleImpl {
 
    @Autowired
    private IAreaService iAreaService;
 
    @Autowired
    private IAreaSectionService iAreaSectionService;
 
    @Autowired
    private ICustomerService iCustomerService;
 
    @Scheduled(cron="0 0 * * * ?")//每小时执行一次
    public void execute(){
        List<Area> list = iAreaService.list();
        for(Area area:list){
            QueryWrapper<Customer> wrapper = new QueryWrapper<>();
            wrapper.eq("area_id",area.getId());
            int count = iCustomerService.count(wrapper);
            area.setCustomerSum(count);
            iAreaService.saveOrUpdate(area);
        }
 
 
    }
}