hjl
2024-07-02 242725f795b4cca830421c07f714a3ec36af0add
ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/ChangeDispatchController.java
@@ -20,10 +20,7 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Arrays;
@@ -80,6 +77,17 @@
    /**
     * 订单改派详情
     *
     * @param changeDispatch 订单改派信息
     */
    @ApiOperation(value = "新增订单改派", tags = {"后台-系统设置-订单改派管理"})
    @PostMapping(value = "/save")
    public R<Boolean> save(@RequestBody ChangeDispatch changeDispatch) {
        return R.ok(changeDispatchService.save(changeDispatch));
    }
    /**
     * 订单改派详情
     *
     * @param id 订单改派id
     */
    @RequiresPermissions("reassignment_apply")
@@ -90,6 +98,23 @@
    })
    public R<ChangeDispatch> detail(@RequestParam Integer id) {
        return R.ok(changeDispatchService.getById(id));
    }
    /**
     * 订单改派详情 远程调用
     *
     * @param id 订单id
     */
    @GetMapping(value = "/one")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单改派id", name = "id", dataType = "Integer", required = true)
    })
    public R<ChangeDispatch> one(@RequestParam("id") Integer id) {
        ChangeDispatch changeDispatch = changeDispatchService.lambdaQuery()
                .eq(ChangeDispatch::getOrderId, id)
                .eq(ChangeDispatch::getState, Constants.ZERO)
                .one();
        return R.ok(changeDispatch);
    }
    /**
@@ -113,7 +138,7 @@
    /**
     * 订单改派师傅
     *
     * @param orderId  订单id
     * @param changeId 改派订单id
     * @param workerId 师傅id
     */
    @RequiresPermissions("reassignment_apply")
@@ -121,16 +146,16 @@
    @GetMapping(value = "/changeWorker")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "改派订单id", name = "changeId", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true),
            @ApiImplicitParam(value = "师傅id", name = "workerId", dataType = "Integer", required = true)
    })
    public R<String> changeWorker(@RequestParam Integer changeId, @RequestParam Integer orderId, @RequestParam Integer workerId) {
    public R<String> changeWorker(@RequestParam Integer changeId, @RequestParam Integer workerId) {
        ChangeDispatch changeDispatch = changeDispatchService.lambdaQuery().eq(ChangeDispatch::getId, changeId)
                .eq(ChangeDispatch::getIsDelete, 0).one();
        if (null == changeDispatch || Constants.ONE.equals(changeDispatch.getState())) {
            throw new GlobalException("改派申请不存在或已改派!");
        }
        Order order = orderService.lambdaQuery().eq(Order::getId, orderId).eq(Order::getIsDelete, 0).one();
        Order order = orderService.lambdaQuery().eq(Order::getId, changeDispatch.getOrderId())
                .eq(Order::getIsDelete, 0).one();
        if (null == order) {
            throw new GlobalException("订单不存在!");
        }
@@ -144,7 +169,7 @@
        if (null == masterWorker) {
            throw new GlobalException("服务人员信息异常!");
        }
        // 原订单状态改为 6:已改派
        // 原订单状态改为 5:已改派
        order.setState(Constants.FIVE);
        boolean orderUpdate = orderService.updateById(order);
        // 生成新订单信息