package com.yh.saas.plugin.yiliangyiyun.controller;


import com.yh.saas.plugin.yiliangyiyun.entity.TranCarInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.TranProcessInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.TranTaskInfo;
import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
import com.yh.saas.plugin.yiliangyiyun.service.ITranCarInfoService;
import com.yh.saas.plugin.yiliangyiyun.service.ITranTaskInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 记录车次 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-05-31
 */
@RestController
@RequestMapping("/tranCarInfo")
public class TranCarInfoController {
    @Autowired
    private ITranCarInfoService tranCarInfoService;

    /**
     * 添加发车信息
     * @param tranCarInfo
     * @return
     */
    @PostMapping("/api/addTranTask")
    public String addTranTask(@RequestBody TranCarInfo tranCarInfo) throws ServiceException {
        return tranCarInfoService.addTranCar(tranCarInfo);
    }

    /**
     * 确认卸货
     * @param tranCarInfo
     * @return
     */
    @PostMapping("/api/confirmUnloading")
    public String confirmUnloading(@RequestBody TranCarInfo tranCarInfo){
        return tranCarInfoService.confirmUnloading(tranCarInfo.getId());
    }

    /**
     * 查发车数量
     * @param tranCarInfo
     * @return
     */
    @GetMapping("/api/selectTranCarInfoNum")
    public List<TranCarInfo> selectTranCarInfoNum(TranCarInfo tranCarInfo){
        return tranCarInfoService.selectTranCarInfoNum(tranCarInfo);
    }
    /**
     * 删除车辆
     * @param example
     */
    @PostMapping("/api/deleteTranCar")
    public void deleteTranCar(@RequestBody TranCarInfo example) {
        tranCarInfoService.deleteTranCar(example.getId());
    }
    /**
     * APP保存反馈
     * @param tranCarInfo
     * @return
     */
    @PostMapping("/api/feedbackTranCar")
    public String feedbackTranCar(@RequestBody TranCarInfo tranCarInfo) {
        return tranCarInfoService.feedbackTranCar(tranCarInfo);
    }

}

