| New file |
| | |
| | | package cn.exrick.xboot.your.schedulings; |
| | | import cn.exrick.xboot.your.entity.Area; |
| | | import cn.exrick.xboot.your.entity.AreaSection; |
| | | import cn.exrick.xboot.your.entity.Customer; |
| | | import cn.exrick.xboot.your.entity.OrderTask; |
| | | import cn.exrick.xboot.your.service.IAreaSectionService; |
| | | import cn.exrick.xboot.your.service.IAreaService; |
| | | import cn.exrick.xboot.your.service.ICustomerService; |
| | | import cn.exrick.xboot.your.service.IOrderTaskService; |
| | | 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.ArrayList; |
| | | import java.util.List; |
| | | |
| | | //大屏配送分析 |
| | | @Component |
| | | public class StatisticPc2ScheduleImpl { |
| | | |
| | | @Autowired |
| | | private IAreaService iAreaService; |
| | | |
| | | @Autowired |
| | | private IAreaSectionService iAreaSectionService; |
| | | |
| | | @Autowired |
| | | private ICustomerService iCustomerService; |
| | | |
| | | @Autowired |
| | | private IOrderTaskService iOrderTaskService; |
| | | |
| | | @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); |
| | | } |
| | | |
| | | List<AreaSection> list2 = iAreaSectionService.list(); |
| | | for(AreaSection areaSection:list2){ |
| | | String id = areaSection.getId(); |
| | | QueryWrapper<Customer> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("area_section_id",id); |
| | | int count = iCustomerService.count(wrapper); |
| | | areaSection.setCustomerNum(count); |
| | | |
| | | List<OrderTask> orderTasks = iOrderTaskService.sumTime(id); |
| | | int sum = 0; |
| | | List<Integer> listTime = new ArrayList<>(); |
| | | for(OrderTask orderTask:orderTasks){ |
| | | sum+=orderTask.getTime(); |
| | | listTime.add(orderTask.getTime()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |