| | |
| | | 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() throws IOException { |
| | | 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); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |