wang-hao-jie
2021-12-09 fdeaff15619f5f2e851f74f7b5e2b203b157856d
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java
@@ -5,12 +5,11 @@
import cn.exrick.xboot.core.common.utils.SecurityUtil;
import cn.exrick.xboot.core.common.vo.PageVo;
import cn.exrick.xboot.core.common.vo.Result;
import cn.exrick.xboot.core.entity.Department;
import cn.exrick.xboot.core.entity.User;
import cn.exrick.xboot.core.service.DepartmentService;
import cn.exrick.xboot.core.service.UserService;
import cn.exrick.xboot.your.entity.Area;
import cn.exrick.xboot.your.entity.AreaSection;
import cn.exrick.xboot.your.entity.OrderDetail;
import cn.exrick.xboot.your.entity.OrderTask;
import cn.exrick.xboot.your.entity.*;
import cn.exrick.xboot.your.service.*;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
@@ -59,6 +58,15 @@
    @Autowired
    private IAreaSectionService iAreaSectionService;
    @Autowired
    private ICarService iCarService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private IEventLogService iEventLogService;
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    @ApiOperation(value = "通过id获取")
    public Result<OrderTask> get(@PathVariable String id) {
@@ -67,12 +75,27 @@
        return new ResultUtil<OrderTask>().setData(orderTask);
    }
    public Area getArea(String userId){
        QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
        wrapper.eq("user_id",userId);
        Area area = iAreaService.getOne(wrapper);
        if(area==null){
            QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>();
            carQueryWrapper.eq("user_id",userId);
            Car one = iCarService.getOne(carQueryWrapper);
            QueryWrapper<Area> wrapper3 = new QueryWrapper<Area>();
            wrapper3.eq("user_id",one.getFollowUserId());
            area = iAreaService.getOne(wrapper3);
            return area;
        }
        return area;
    }
    @RequestMapping(value = "/getByUserId", method = RequestMethod.GET)
    @ApiOperation(value = "获取今日任务统计信息")
    public Result<Object> getAll() {
        QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
        wrapper.eq("user_id",securityUtil.getCurrUser().getId());
        Area area = iAreaService.getOne(wrapper);
        Area area = getArea(securityUtil.getCurrUser().getId());
        if(area==null){
            return ResultUtil.error("请联系管理员绑定片区配送员");
        }
@@ -90,9 +113,11 @@
        map.put("sum",sum);
        map.put("name","");
        if(list.size()>0){
            String areaSectionId = list.get(0).getAreaSectionId();
            OrderTask orderTask = list.get(0);
            String areaSectionId = orderTask.getAreaSectionId();
            AreaSection a = iAreaSectionService.getById(areaSectionId);
            map.put("name",a.getName());
            Area area2 = iAreaService.getById(orderTask.getAreaId());
            map.put("name",area2.getName()+a.getName());
            list.clear();
        }
        return new ResultUtil<Object>().setData(map);
@@ -101,9 +126,7 @@
    @RequestMapping(value = "/getTodayOrder", method = RequestMethod.GET)
    @ApiOperation(value = "获取今日任务详情")
    public Result<List<OrderTask>> getTodayOrder() {
        QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
        wrapper.eq("user_id",securityUtil.getCurrUser().getId());
        Area area = iAreaService.getOne(wrapper);
        Area area = getArea(securityUtil.getCurrUser().getId());
        if(area==null){
            return ResultUtil.error("请联系管理员绑定片区配送员");
        }
@@ -127,9 +150,7 @@
                return ResultUtil.error("此商户已配送");
            }
        }else{
            QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
            wrapper.eq("user_id",securityUtil.getCurrUser().getId());
            Area area = iAreaService.getOne(wrapper);
            Area area = getArea(securityUtil.getCurrUser().getId());
            if(area==null){
                return ResultUtil.error("请联系管理员绑定片区配送员");
            }
@@ -160,9 +181,7 @@
    @ApiOperation(value = "获取其它信息")
    public Result<Object> getTodayOtherInfo() {
        QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
        wrapper.eq("user_id",securityUtil.getCurrUser().getId());
        Area area = iAreaService.getOne(wrapper);
        Area area = getArea(securityUtil.getCurrUser().getId());
        if(area==null){
            return ResultUtil.error("请联系管理员绑定片区配送员");
        }
@@ -210,6 +229,15 @@
            }
        }
        map.put("content",content);
        map.put("lng","");
        map.put("lat","");
        String deptId = securityUtil.getCurrUser().getDepartmentId();
        if(StrUtil.isNotEmpty(deptId)){
            Department department = departmentService.get(deptId);
            map.put("lng",department.getLng());
            map.put("lat",department.getLat());
        }
        return new ResultUtil<Object>().setData(map);
    }
@@ -245,6 +273,13 @@
            }
        }
        iOrderTaskService.saveOrUpdate(orderTask);
        Car car = iCarService.getById(orderTask.getCarId());
        EventLog eventLog = new EventLog();
        eventLog.setCarNo(car.getCarNo());
        eventLog.setRefId(orderId);
        eventLog.setType(6);//6:配送完成
        iEventLogService.saveOrUpdate(eventLog);
        return ResultUtil.success("添加成功");
    }