wang-hao-jie
2022-04-18 86c3614c6780b3214ad70ec51011da077113022b
最新版本
5个文件已修改
1个文件已添加
315 ■■■■ 已修改文件
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AreaController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTask2Controller.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/pc/StatisticController.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderTask2.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/HistoryOrder.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/OrderDealScheduleImpl.java 142 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/AreaController.java
@@ -43,7 +43,8 @@
    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
    @ApiOperation(value = "获取全部数据")
    public Result<List<Area>> getAll() {
        QueryWrapper<Area> wrapper = new QueryWrapper<>();
        wrapper.orderByAsc("name");
        List<Area> list = iAreaService.list();
        return new ResultUtil<List<Area>>().setData(list);
    }
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTask2Controller.java
@@ -49,9 +49,21 @@
    @RequestMapping(value = "/getByPage", method = RequestMethod.GET)
    @ApiOperation(value = "分页获取")
    public Result<IPage<OrderTask2>> getByPage(PageVo page) {
        IPage<OrderTask2> data = iOrderTask2Service.page(PageUtil.initMpPage(page));
    public Result<IPage<OrderTask2>> getByPage(PageVo page,String sendDate,String userName,String customerName,Integer status) {
        QueryWrapper<OrderTask2> wrapper = new QueryWrapper<>();
        if(StrUtil.isNotEmpty(sendDate)){
            wrapper.eq("send_date",sendDate);
        }
        if(StrUtil.isNotEmpty(userName)){
            wrapper.like("user_name","%"+userName+"%");
        }
        if(StrUtil.isNotEmpty(customerName)){
            wrapper.like("customer_name","%"+customerName+"%");
        }
        if(status!=null){
            wrapper.eq("status",status);
        }
        IPage<OrderTask2> data = iOrderTask2Service.page(PageUtil.initMpPage(page),wrapper);
        return new ResultUtil<IPage<OrderTask2>>().setData(data);
    }
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/pc/StatisticController.java
@@ -5,12 +5,15 @@
import cn.exrick.xboot.core.common.utils.ResultUtil;
import cn.exrick.xboot.core.common.vo.PageVo;
import cn.exrick.xboot.core.common.vo.Result;
import cn.exrick.xboot.core.entity.User;
import cn.exrick.xboot.core.service.UserService;
import cn.exrick.xboot.your.entity.*;
import cn.exrick.xboot.your.service.*;
import cn.exrick.xboot.your.util.HaiKangPost;
import cn.exrick.xboot.your.vo.AlarmVo;
import cn.exrick.xboot.your.vo.PreviewURLsVo;
import cn.exrick.xboot.your.vo.TalkURLsVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
@@ -20,9 +23,11 @@
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -66,7 +71,10 @@
    private ICustomerService iCustomerService;
    @Autowired
    private ICustomerReceiveService iCustomerReceiveService;
    private IOrderTask2Service iOrderTask2Service;
    @Autowired
    private UserService userService;
    @Autowired
    private IDuoZhengService iDuoZhengService;
@@ -338,4 +346,44 @@
        map.put("children",childrens);
        return new ResultUtil<Object>().setData(map);
    }
    @RequestMapping(value = "/test", method = RequestMethod.GET)
    @ApiOperation(value = "测试接口,没用")
    public String test(){
        List<OrderTask> list = iOrderTaskService.list();
        List<OrderTask2> list2 = new ArrayList<>();
        for(OrderTask orderTask:list){
            OrderTask2 orderTask2 = new OrderTask2();
            BeanUtil.copyProperties(orderTask,orderTask2);
            if(orderTask.getUserId()!=null){
                orderTask2.setUserName(getUser(orderTask.getUserId()));
            }
            if(orderTask.getCustomerId()!=null){
                orderTask2.setCustomerName(getCustomer(orderTask.getCustomerId()));
            }
            list2.add(orderTask2);
        }
        iOrderTask2Service.saveBatch(list2);
        return list.size()+"ok";
    }
    private String getUser(String id){
        User user = userService.get(id);
        if(user!=null){
            return user.getNickname();
        }else{
            return null;
        }
    }
    private String getCustomer(String id){
        Customer customer = iCustomerService.getById(id);
        if(customer!=null){
            return customer.getName();
        }else{
            return null;
        }
    }
}
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/entity/OrderTask2.java
@@ -28,7 +28,7 @@
@TableName("t_order_task2")
@ApiModel(value = "订单任务历史表")
public class OrderTask2 extends XbootBaseEntity {
    //只存放配送完的订单
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "订单号")
@@ -100,33 +100,18 @@
    @ApiModelProperty(value = "耗时 毫秒")
    private int time;
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "商户名称")
    private String customerName;
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "商户")
    private Customer customer;
    @ApiModelProperty(value = "配送人")
    private String userName;
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "车牌号")
    private String carNo;
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "区域名称")
    private String areaName;
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "分段名称")
    private String areaSectionName;
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "订单详情")
    private List<OrderDetail> orderDetails;
}
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/HistoryOrder.java
New file
@@ -0,0 +1,81 @@
package cn.exrick.xboot.your.schedulings;
import cn.exrick.xboot.core.entity.User;
import cn.exrick.xboot.core.service.UserService;
import cn.exrick.xboot.your.entity.*;
import cn.exrick.xboot.your.service.*;
import cn.hutool.core.bean.BeanUtil;
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.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
//同步历史数据
@Component
public class HistoryOrder{
    @Autowired
    private IOrderTaskService iOrderTaskService;
    @Autowired
    private IOrderTask2Service iOrderTask2Service;
    @Autowired
    private UserService userService;
    @Autowired
    private ICustomerService iCustomerService;
    @Scheduled(cron="0 30 21 * * ?")//每晚下午9点半点执行
    public void execute(){
        String day = getDay(0);
        QueryWrapper<OrderTask> wrapper = new QueryWrapper<>();
        wrapper.eq("send_Date",day);
        List<OrderTask> list = iOrderTaskService.list(wrapper);
        List<OrderTask2> list2 = new ArrayList<>();
        for(OrderTask orderTask:list){
            OrderTask2 orderTask2 = new OrderTask2();
            BeanUtil.copyProperties(orderTask,orderTask2);
            orderTask2.setUserName(getUser(orderTask.getUserId()));
            orderTask2.setCustomerName(getCustomer(orderTask.getCustomerId()));
            list2.add(orderTask2);
        }
        iOrderTask2Service.saveBatch(list2);
    }
    private String getUser(String id){
        User user = userService.get(id);
        if(user!=null){
            return user.getNickname();
        }else{
            return null;
        }
    }
    private String getCustomer(String id){
        Customer customer = iCustomerService.getById(id);
        if(customer!=null){
            return customer.getName();
        }else{
            return null;
        }
    }
    private String getDay(int day){
        Date dNow = new Date();   //当前时间
        Calendar calendar = Calendar.getInstance(); //得到日历
        calendar.setTime(dNow);//把当前时间赋给日历
        calendar.add(Calendar.DAY_OF_MONTH, day);  //设置为前n天
        Date dBefore = calendar.getTime();   //得到前一天的时间
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式
        String defaultStartDate = sdf.format(dBefore);
        return defaultStartDate;
    }
}
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/OrderDealScheduleImpl.java
@@ -1,71 +1,71 @@
package cn.exrick.xboot.your.schedulings;
import cn.exrick.xboot.your.entity.*;
import cn.exrick.xboot.your.service.*;
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.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
//删除历史数据
@Component
public class OrderDealScheduleImpl {
    @Autowired
    private IOrderTaskOriginalService iOrderTaskOriginalService;
    @Autowired
    private IOrderDetailOriginalService iOrderDetailOriginalService;
    @Autowired
    private IOrderTaskService iOrderTaskService;
    @Autowired
    private IOrderDetailService iOrderDetailService;
    @Autowired
    private IDuoZhengService iDuoZhengService;
    @Scheduled(cron="0 0 21 * * ?")//每晚下午9点执行
    //@Scheduled(cron="0 33 17 * * ?")//测试
    public void execute(){
        String day = getDay(-8);
        QueryWrapper<OrderTask> wrapper = new QueryWrapper<>();
        wrapper.lt("send_Date",day);
        iOrderTaskService.remove(wrapper);
        QueryWrapper<OrderDetail> wrapper2 = new QueryWrapper<>();
        wrapper2.lt("create_time",day+" 00:00:00");
        iOrderDetailService.remove(wrapper2);
        String day2 = getDay(-30);
        QueryWrapper<OrderTaskOriginal> wrapper3 = new QueryWrapper<>();
        wrapper3.lt("create_time",day2+" 00:00:00");
        iOrderTaskOriginalService.remove(wrapper3);
        QueryWrapper<OrderDetailOriginal> wrapper4 = new QueryWrapper<>();
        wrapper4.lt("create_time",day2+" 00:00:00");
        iOrderDetailOriginalService.remove(wrapper4);
        QueryWrapper<DuoZheng> wrapper5 = new QueryWrapper<>();
        iDuoZhengService.remove(wrapper5);
        List<DuoZheng> list = iDuoZhengService.getYiHuDuoZheng();
        iDuoZhengService.saveBatch(list);
    }
    private String getDay(int day){
        Date dNow = new Date();   //当前时间
        Calendar calendar = Calendar.getInstance(); //得到日历
        calendar.setTime(dNow);//把当前时间赋给日历
        calendar.add(Calendar.DAY_OF_MONTH, day);  //设置为前n天
        Date dBefore = calendar.getTime();   //得到前一天的时间
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式
        String defaultStartDate = sdf.format(dBefore);
        return defaultStartDate;
    }
}
//package cn.exrick.xboot.your.schedulings;
//import cn.exrick.xboot.your.entity.*;
//import cn.exrick.xboot.your.service.*;
//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.text.SimpleDateFormat;
//import java.util.Calendar;
//import java.util.Date;
//import java.util.List;
//
////删除历史数据
//@Component
//public class OrderDealScheduleImpl {
//
//    @Autowired
//    private IOrderTaskOriginalService iOrderTaskOriginalService;
//
//    @Autowired
//    private IOrderDetailOriginalService iOrderDetailOriginalService;
//
//    @Autowired
//    private IOrderTaskService iOrderTaskService;
//
//    @Autowired
//    private IOrderDetailService iOrderDetailService;
//
//    @Autowired
//    private IDuoZhengService iDuoZhengService;
//
//    @Scheduled(cron="0 0 21 * * ?")//每晚下午9点执行
//    //@Scheduled(cron="0 33 17 * * ?")//测试
//    public void execute(){
//        String day = getDay(-15);
//        QueryWrapper<OrderTask> wrapper = new QueryWrapper<>();
//        wrapper.lt("send_Date",day);
//        iOrderTaskService.remove(wrapper);
//
//        QueryWrapper<OrderDetail> wrapper2 = new QueryWrapper<>();
//        wrapper2.lt("create_time",day+" 00:00:00");
//        iOrderDetailService.remove(wrapper2);
//
//        String day2 = getDay(-30);
//        QueryWrapper<OrderTaskOriginal> wrapper3 = new QueryWrapper<>();
//        wrapper3.lt("create_time",day2+" 00:00:00");
//        iOrderTaskOriginalService.remove(wrapper3);
//
//        QueryWrapper<OrderDetailOriginal> wrapper4 = new QueryWrapper<>();
//        wrapper4.lt("create_time",day2+" 00:00:00");
//        iOrderDetailOriginalService.remove(wrapper4);
//
//        QueryWrapper<DuoZheng> wrapper5 = new QueryWrapper<>();
//        iDuoZhengService.remove(wrapper5);
//
//        List<DuoZheng> list = iDuoZhengService.getYiHuDuoZheng();
//        iDuoZhengService.saveBatch(list);
//    }
//
//    private String getDay(int day){
//        Date dNow = new Date();   //当前时间
//        Calendar calendar = Calendar.getInstance(); //得到日历
//        calendar.setTime(dNow);//把当前时间赋给日历
//        calendar.add(Calendar.DAY_OF_MONTH, day);  //设置为前n天
//        Date dBefore = calendar.getTime();   //得到前一天的时间
//        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式
//        String defaultStartDate = sdf.format(dBefore);
//        return defaultStartDate;
//    }
//}