wang-hao-jie
2022-08-25 59feba9fab96f893003137eae393ed646ec07c0e
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/HistoryOrder.java
@@ -4,6 +4,7 @@
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;
@@ -31,7 +32,7 @@
    @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<>();
@@ -44,25 +45,34 @@
            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;
        }