liujie
2023-05-24 0c9e25aff0133d05bdaca55d1369eb90342b0b05
src/main/java/com/stylefeng/guns/modular/system/controller/OrderController.java
@@ -1,5 +1,6 @@
package com.stylefeng.guns.modular.system.controller;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.modular.system.model.*;
@@ -141,8 +142,24 @@
        return new SuccessTip(orderInfo);
    }
    @ApiOperation(value = "订单详情--修改reference numbers",notes="订单详情--修改reference numbers")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/updateReference")
    @ResponseBody
    public Object updateReference( TGoods tGoods) {
        boolean b = goodsService.updateById(tGoods);
        return new SuccessTip();
    }
    @ApiOperation(value = "获取运输安排",notes="获取运输安排")
    @Resource
    private TTransportationService tTransportationService;
    @Resource
    private TPowerUnitsService powerUnitsService;
    @ApiOperation(value = "卡车公司-获取运输安排",notes="卡车公司-获取运输安排")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"),
@@ -172,26 +189,43 @@
        if(driverIdOne!=null){
            driverIds.add(driverIdOne);
        }
        List<TDriver> tDrivers = driverService.selectList(new EntityWrapper<TDriver>().in("id", driverIds));
        for (TDriver tDriver : tDrivers) {
        transportInfo.setShipmentDate(tOrder.getShipmentDate());
        List<TTransportation> tTransportations = tTransportationService.selectList(new EntityWrapper<TTransportation>().eq("order_id", orderId).in("driver_id", driverIds).orderBy("type"));
        for (TTransportation tDriver : tTransportations) {
            OrderDriverInfo orderDriverInfo = new OrderDriverInfo();
            orderDriverInfo.setId(tDriver.getId());
            orderDriverInfo.setTime(tOrder.getShipmentDate());
            // TODO 创建司机没有email  phone
            orderDriverInfo.setContactEmail(null);
            orderDriverInfo.setContactName(tDriver.getDriverName());
            orderDriverInfo.setContactPhone(null);
            orderDriverInfo.setDriverId(tDriver.getDriverId());
            if(tDriver.getId().equals(sDriverIdOne)&&tDriver.getType()==2){
                orderDriverInfo.setPickUp(tDriver.getPickDate());
            }
            if(tDriver.getId().equals(driverid) &&tDriver.getType()==3){
                orderDriverInfo.setEmptyDate(tDriver.getEmptyDate());
            }
            if(tDriver.getId().equals(driverIdOne) &&tDriver.getType()==4){
                orderDriverInfo.setReturnDate(tDriver.getReturnDate());
            }
            orderDriverInfo.setContactEmail(tDriver.getEmail());
            orderDriverInfo.setContactName(tDriver.getName());
            orderDriverInfo.setContactPhone(tDriver.getPhone());
            orderDriverInfo.setTPowerUnits(powerUnitsService.selectById(tDriver.getPowerUnit()));
            orderDriverInfo.setChassiess(powerUnitsService.selectById(tDriver.getChassises()));
            // TODO 第三方  目前不知道对接那个
            orderDriverInfo.setAppointmentNumber(null);
            orderDriverInfos.add(orderDriverInfo);
        }
        transportInfo.setTruckCompany(tOrder.getTruckCompany());
        transportInfo.setPickupTime(tOrder.getPickupTimeTruck());
        transportInfo.setStreetTurn(tOrder.getStreetTurn());
        transportInfo.setList(orderDriverInfos);
        Integer examSite = tOrder.getExamSite();
        if(Objects.nonNull(examSite)){
            TExamSite tExamSite = examSiteService.selectById(examSite);
            transportInfo.setAddress(tExamSite.getAddress());
            transportInfo.setContactEmail(tExamSite.getContactEmail());
            transportInfo.setContactName(tExamSite.getContactName());
            transportInfo.setContactName(tExamSite.getContactPhone());
            transportInfo.setExamSiteName(tExamSite.getExamSiteName());
            transportInfo.setZipCode(tExamSite.getZipCode());
        }
@@ -274,6 +308,220 @@
    public Object getOrderLog(Long orderId,int pageNumber,int pageSize){
        Page<TOrderLog> tOrderLogPage = new Page<>(pageNumber, pageSize);
        Page<TOrderLog> page = orderLogService.selectPage(tOrderLogPage, new EntityWrapper<TOrderLog>().eq("order_id", orderId).orderBy("create_time",false));
        return new SuccessTip(page);
    }
    @ApiOperation(value = "卡车公司--安排司机",notes="卡车公司--安排司机")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType     = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/selectDriver")
    @ResponseBody
    public Object selectDriver(@RequestBody CompanySelectDriverDto companySelectDriverDto){
        try {
            Long orderId = companySelectDriverDto.getOrderId();
            // 找出这个订单
            TOrder tOrder = orderService.selectById(orderId);
            List<TTransportation> list = companySelectDriverDto.getList();
            tOrder.setsDriverid(list.get(0).getDriverId());
            tOrder.setsDriverIdOne(list.get(1).getDriverId());
            if(companySelectDriverDto.getStreetTurn()==1){
                tOrder.seteDriverid(list.get(2).getDriverId());
                tOrder.seteDriverIdOne(list.get(3).getDriverId());
            }
            tOrder.setTruckCompany(companySelectDriverDto.getTruckCompany());
            tOrder.setPickupTimeTruck(companySelectDriverDto.getPickupTime());
            tOrder.setStreetTurn(companySelectDriverDto.getStreetTurn());
            companySelectDriverDto.getList().forEach(e->e.setOrderId(orderId));
            // 添加司机信息
            tTransportationService.insertBatch(companySelectDriverDto.getList());
            // 更改订单信息
            orderService.updateById(tOrder);
            return new SuccessTip();
        }catch (Exception e){
            e.printStackTrace();
        }
        return new ErrorTip(500,"ERROR");
    }
    @ApiOperation(value = "卡车公司--修改安排司机(多个)",notes="卡车公司--修改安排司机(多个)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType     = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/updateDriver")
    @ResponseBody
    public Object updateDriver(@RequestBody CompanySelectDriverDto companySelectDriverDto){
        try {
            Long orderId = companySelectDriverDto.getOrderId();
            // 找出这个订单
            TOrder tOrder = orderService.selectById(orderId);
            List<TTransportation> list = companySelectDriverDto.getList();
            list.forEach(e->e.setOrderId(companySelectDriverDto.getOrderId()));
            tOrder.setsDriverid(list.get(0).getDriverId());
            tOrder.setsDriverIdOne(list.get(1).getDriverId());
            if(companySelectDriverDto.getStreetTurn()==1){
                tOrder.seteDriverid(list.get(2).getDriverId());
                tOrder.seteDriverIdOne(list.get(3).getDriverId());
            }
            tOrder.setTruckCompany(companySelectDriverDto.getTruckCompany());
            tOrder.setPickupTimeTruck(companySelectDriverDto.getPickupTime());
            tOrder.setStreetTurn(companySelectDriverDto.getStreetTurn());
            // 删除原来的司机信息
            tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId));
            // 添加新司机信息
            tTransportationService.insertBatch(list);
            // 更改订单信息
            orderService.updateById(tOrder);
            return new SuccessTip();
        }catch (Exception e){
            e.printStackTrace();
        }
        return new ErrorTip(500,"ERROR");
    }
    @ApiOperation(value = "卡车公司--修改安排司机(单个)",notes="卡车公司--修改安排司机(单个)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType     = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/updateDriverSingle")
    @ResponseBody
    public Object updateDriverSingle(@RequestBody CompanySelectDriverSingleDto companySelectDriverSingleDto){
        try {
            Long orderId = companySelectDriverSingleDto.getOrderId();
            // 找出这个订单
            TOrder tOrder = orderService.selectById(orderId);
            TTransportation list = companySelectDriverSingleDto.getList();
            list.setOrderId(companySelectDriverSingleDto.getOrderId());
            Integer type = companySelectDriverSingleDto.getType();
            if(type==1){
                tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.getsDriverid()).eq("type",1));
                tOrder.setsDriverid(list.getDriverId());
            }else if(type==2){
                tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.getsDriverIdOne()).eq("type",2));
                tOrder.setsDriverIdOne(list.getDriverId());
            }else if(type==3){
                tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.geteDriverid()).eq("type",3));
                tOrder.seteDriverid(list.getDriverId());
            }else {
                tTransportationService.delete(new EntityWrapper<TTransportation>().eq("order_id",orderId).eq("driver_id",tOrder.geteDriverIdOne()).eq("type",4));
                tOrder.seteDriverIdOne(list.getDriverId());
            }
            tTransportationService.insert(list);
            // 删除原来的司机信息
            // 更改订单信息
            orderService.updateById(tOrder);
            return new SuccessTip();
        }catch (Exception e){
            e.printStackTrace();
        }
        return new ErrorTip(500,"ERROR");
    }
    @Resource
    private TYardService yardService;
    @ApiOperation(value = "卡车公司--点击定位(场地/码头)",notes="卡车公司--点击定位(场地/码头)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType     = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/getLocation")
    @ResponseBody
    public Object getLocation(@RequestBody CompanyLocationDto companyLocationDto){
        try {
            Long orderId = companyLocationDto.getOrderId();
            // 找出这个订单
            TOrder tOrder = orderService.selectById(orderId);
            Integer type = companyLocationDto.getType();
            if(type==2){
                TTransportation tTransportation = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", orderId).eq("driver_id", tOrder.getsDriverIdOne()).eq("type",2));
                if(tTransportation!=null){
                    Integer yardId = tTransportation.getYardId();
                    TYard tYard = yardService.selectById(yardId);
                    return new SuccessTip(tYard);
                }
            }else if(type==3){
                TTransportation tTransportation = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", orderId).eq("driver_id", tOrder.geteDriverid()).eq("type",3));
                if(tTransportation!=null) {
                    Integer yardId = tTransportation.getYardId();
                    TYard tYard = yardService.selectById(yardId);
                    return new SuccessTip(tYard);
                }
            }else if(type==4){
                TTransportation tTransportation = tTransportationService.selectOne(new EntityWrapper<TTransportation>().eq("order_id", orderId).eq("driver_id", tOrder.geteDriverIdOne()).eq("type",4));
                if(tTransportation!=null) {
                    Integer portId = tTransportation.getPortId();
                    TPort tPort = portService.selectById(portId);
                    return new SuccessTip(tPort);
                }
            }
            return new ErrorTip(5001,"not found");
        }catch (Exception e){
            e.printStackTrace();
        }
        return new ErrorTip(500,"ERROR");
    }
    @ApiOperation(value = "运输安排---选择公司司机",notes="运输安排---选择公司司机")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType     = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int"),
            @ApiImplicitParam(name = "id", value = "当前公司id", required = true, dataType = "int"),
    })
    @GetMapping(value = "/getDriverSelect")
    @ResponseBody
    public Object getDriverSelect(int pageNumber,int pageSize,int id){
        Page<TDriver> tDriverPage = new Page<>(pageNumber, pageSize);
        Page<TDriver> tDriverPage1 = driverService.selectPage(tDriverPage, new EntityWrapper<TDriver>().eq("is_carriers", 1).eq("company_id", id).eq("remove", 0));
        ArrayList<TDriverSelectVo> tDriverSelectVos = new ArrayList<>();
        List<TDriver> records = tDriverPage1.getRecords();
        records.forEach(e->{
            TDriverSelectVo tDriverSelectVo = new TDriverSelectVo();
            BeanUtil.copyProperties(e,tDriverSelectVo);
            tDriverSelectVos.add(tDriverSelectVo);
        });
        Page<TDriverSelectVo> page = new Page<>();
        BeanUtil.copyProperties(tDriverPage1,page);
        page.setRecords(tDriverSelectVos);
        return new SuccessTip(page);
    }
    @ApiOperation(value = "运输安排---承运商选择司机",notes="运输安排---承运商选择司机")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType     = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int"),
            @ApiImplicitParam(name = "id", value = "承运商ud", required = true, dataType = "int"),
    })
    @GetMapping(value = "/getDriverSelectFromCarriers")
    @ResponseBody
    public Object getDriverSelectFromCarriers(int pageNumber,int pageSize,int id){
        Page<TDriver> tDriverPage = new Page<>(pageNumber, pageSize);
        Page<TDriver> tDriverPage1 = driverService.selectPage(tDriverPage, new EntityWrapper<TDriver>().eq("is_carriers", 2).eq("carriers_id", id).eq("remove", 0));
        ArrayList<TDriverSelectVo> tDriverSelectVos = new ArrayList<>();
        List<TDriver> records = tDriverPage1.getRecords();
        records.forEach(e->{
            TDriverSelectVo tDriverSelectVo = new TDriverSelectVo();
            BeanUtil.copyProperties(e,tDriverSelectVo);
            tDriverSelectVos.add(tDriverSelectVo);
        });
        Page<TDriverSelectVo> page = new Page<>();
        BeanUtil.copyProperties(tDriverPage1,page);
        page.setRecords(tDriverSelectVos);
        return new SuccessTip(page);
    }
@@ -396,7 +644,6 @@
        TOrder tOrder = orderService.selectById(orderId);
        // 根据订单获取报价
        map.put("invoice",tOrder.getInvoiceNumber());
        map.put("pickUpDate",tOrder.getShipmentDate());
        map.put("returnDate",tOrder.getOrderOkTime());