|  |  |  | 
|---|
|  |  |  | import cn.exrick.xboot.your.entity.*; | 
|---|
|  |  |  | import cn.exrick.xboot.your.service.*; | 
|---|
|  |  |  | import cn.hutool.core.bean.BeanUtil; | 
|---|
|  |  |  | import cn.hutool.core.util.StrUtil; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.scheduling.annotation.Scheduled; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ICustomerService iCustomerService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron="0 30 21 * * ?")//每晚下午9点半点执行 | 
|---|
|  |  |  | @Scheduled(cron="0 31 21 * * ?")//每晚下午9点半点执行 | 
|---|
|  |  |  | public void execute(){ | 
|---|
|  |  |  | String day = getDay(0); | 
|---|
|  |  |  | QueryWrapper<OrderTask> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | BeanUtil.copyProperties(orderTask,orderTask2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderTask2.setUserName(getUser(orderTask.getUserId())); | 
|---|
|  |  |  | orderTask2.setCustomerName(getCustomer(orderTask.getCustomerId())); | 
|---|
|  |  |  | //orderTask2.setCustomerName(getCustomer(orderTask.getCustomerId())); | 
|---|
|  |  |  | //orderTask2.setCustomerName(orderTask.getCustomerName()); | 
|---|
|  |  |  | list2.add(orderTask2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | iOrderTask2Service.saveBatch(list2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String getUser(String id){ | 
|---|
|  |  |  | User user = userService.get(id); | 
|---|
|  |  |  | if(user!=null){ | 
|---|
|  |  |  | return user.getNickname(); | 
|---|
|  |  |  | if(StrUtil.isNotEmpty(id)){ | 
|---|
|  |  |  | User user = userService.get(id); | 
|---|
|  |  |  | if(user!=null){ | 
|---|
|  |  |  | return user.getNickname(); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String getCustomer(String id){ | 
|---|
|  |  |  | Customer customer = iCustomerService.getById(id); | 
|---|
|  |  |  | if(customer!=null){ | 
|---|
|  |  |  | return customer.getName(); | 
|---|
|  |  |  | if(StrUtil.isNotEmpty(id)){ | 
|---|
|  |  |  | Customer customer = iCustomerService.getById(id); | 
|---|
|  |  |  | if(customer!=null){ | 
|---|
|  |  |  | return customer.getName(); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|