package com.steerinfo.dil.controller;

/**
 * @ author    :TXF
 * @ time      :2021/9/4 9:32
 */

import com.steerinfo.dil.service.impl.DropDownServiceImpl;
import com.steerinfo.dil.util.BaseRESTfulController;
import com.steerinfo.framework.controller.RESTfulResult;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.type.YearTypeHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/${api.version}/dropDown")
public class DropDownController extends BaseRESTfulController {

    //********************************运输计划下拉框接口******************************************

    @Autowired
    DropDownServiceImpl dropDownService;

    @ApiOperation(value="查询所有的批次")
    @GetMapping("/getDilBatch")
    public RESTfulResult getDilBatch(){
        List<Map<String, Object>> batch = dropDownService.getDilBatch();
        return success(batch);
    }

    @ApiOperation(value="查询所有的承运商")
    @GetMapping("/getCarrier")
    public RESTfulResult getRailPlan(){
        List<Map<String, Object>> carrier = dropDownService.getCarrier();
        return success(carrier);
    }

    @ApiOperation(value="查询所有的作业路径")
    @GetMapping("/getLine")
    public RESTfulResult getLine(){
        List<Map<String, Object>> line = dropDownService.getLine();
        return success(line);
    }

    @ApiOperation(value="查询所有的仓库")
    @GetMapping("/getWarehouse")
    public RESTfulResult getWarehouse(@PathParam("type") Integer type){
        Map<String, Object> map = new HashMap<>();
        if(type != null){
            map.put("type", type);
        }
        List<Map<String, Object>> warehouse = dropDownService.getWarehouse(map);
        return success(warehouse);
    }

    @ApiOperation(value="查询所有的门岗")
    @GetMapping("/getGatepost")
    public RESTfulResult getGatepost(){
        List<Map<String, Object>> gatepost = dropDownService.getGatepost();
        return success(gatepost);
    }

    @ApiOperation(value="查询所有的采购订单号")
    @GetMapping("/getAPO")
    public RESTfulResult getAPO(){
        List<Map<String, Object>> APO = dropDownService.getAPO();
        return success(APO);
    }

    @ApiOperation(value="查询特定所有的物资")
    @GetMapping("/getFuMaterial/{type}")
    public RESTfulResult getFuMaterial(@PathVariable("type")Integer type){
        List<Map<String, Object>> material = dropDownService.getFuMaterial(type);
        return success(material);
    }

    @ApiOperation(value="查询所有的辅料车辆")
    @GetMapping("/getFuCapacityId")
    public RESTfulResult getFuCapacityId(){
        List<Map<String, Object>> capacityId = dropDownService.getFuCapacityId();
        return success(capacityId);
    }

    @ApiOperation(value="查询所有的港口")
    @GetMapping("/getPort")
    public RESTfulResult getPort(){
        List<Map<String, Object>> port = dropDownService.getPort();
        return success(port);
    }

    @ApiOperation(value="查询所有的月台")
    @GetMapping("/getPlatformId")
    public RESTfulResult getPlatformId(){
        List<Map<String, Object>> port = dropDownService.getPlatformId();
        return success(port);
    }
    //内转物流下拉框
    @ApiOperation(value="查询装货地点")
    @GetMapping("/getLoadedPlace")
    public RESTfulResult getLoadedPlace(){
        List<Map<String, Object>> loadedPlace = dropDownService.getLoadedPlace();
        return success(loadedPlace);
    }

    @ApiOperation(value="查询外轮船名")
    @GetMapping("/getForeignName")
    public RESTfulResult getForeignName(){
        List<Map<String, Object>> foreignName = dropDownService.getForeignName();
        return success(foreignName);
    }

    @ApiOperation(value="查询卸货点")
    @GetMapping("/getUnloadPoint/{type}")
    public RESTfulResult getUnloadPoint(@PathVariable("type") Integer type){
        List<Map<String, Object>> mes = dropDownService.getUnloadPoint(type);
        return success(mes);
    }
}