package net.vtstar.zhongtong.avi.monitoring.controller;

import com.alibaba.fastjson.JSONObject;
import io.jsonwebtoken.lang.Assert;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.vtstar.utils.asserts.ParamAssert;
import net.vtstar.utils.domain.Return;
import net.vtstar.zhongtong.avi.monitoring.service.PDAService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(description = "PDA相关操作模块")
@RestController
@RequestMapping("/PDA")
public class PDAController {

    @Autowired
    private PDAService pdaService;

    @ApiOperation(value = "焊装车间钣金上撬请求")
    @PostMapping("/hanzhuang/bound")
    private Return hanZhuangBound(@RequestBody JSONObject json) {

        log.info(json.toJSONString());
        String vehicleNo = json.getString("vehicleNo");
        String busNo = json.getString("busNo");
        ParamAssert.notNull(vehicleNo,"param is null");
        ParamAssert.notNull(busNo,"param is null");
        pdaService.bound(vehicleNo,busNo);
        return Return.success();
    }

    @ApiOperation(value = "换撬请求")
    @PostMapping("/change/skid")
    private Return changeSkid(@RequestBody JSONObject json) {

        log.info(json.toJSONString());
        ParamAssert.notNull(json.get("orderNo"),"orderNo is null");
        ParamAssert.notNull(json.get("sourceStation"),"sourceStation is null");
        ParamAssert.notNull(json.get("sourceStation"),"sourceStation is null");
        return Return.success();
    }

    @ApiOperation(value = "返修车请求")
    @PostMapping("/repair")
    private Return repair(@RequestBody JSONObject json) {

        log.info(json.toJSONString());
        ParamAssert.notNull(json.get("busNo"),"param is null");
        return Return.success();
    }

    @ApiOperation(value = "电泳重新绑定电泳工单号")
    @PostMapping("/elec/bound/order")
    private Return elecBoundOrder(@RequestBody JSONObject json) {

        ParamAssert.notNull(json.get("sourceStation"),"sourceStation is null");
        ParamAssert.notNull(json.get("sourceStation"),"sourceStation is null");
        return Return.success(true);
    }
}
