InoutCarparkController.java 4.05 KB
package com.bsth.controller;

import com.bsth.common.ResponseCode;
import com.bsth.entity.LsInoutSectionRoute;
import com.bsth.service.InoutCarparkService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("inout")
public class InoutCarparkController extends BaseController<LsInoutSectionRoute, Long>{

    private final static Logger logger = LoggerFactory.getLogger(InoutCarparkController.class);
	
	@Autowired
	InoutCarparkService inoutCarparkService;
    
    @RequestMapping(value = "/getStartEndByLine", method = RequestMethod.GET)
    public Map<String, Object> getStartEndByLine(@RequestParam("lineId")int lineId, @RequestParam("version")int version) {
    	return inoutCarparkService.getStartEndByLine(lineId, version);
    }

    @RequestMapping(value = "/getRouteByStartEnd", method = RequestMethod.GET)
    public Map<String, Object> getRouteByStartEnd(@RequestParam("lineId")int lineId, @RequestParam("version")int version, @RequestParam("start")String start, @RequestParam("end")String end) {
        return inoutCarparkService.getRouteByStartEnd(lineId, version, start, end);
    }

    /**
     * 新增路段信息
     *
     * @param map:<bsectionVector:折线百度坐标集合;dbType:圆坐标类型;descriptions:描述与说明;destroy:是否撤销;directions:方向;lineId:线路ID
     *
     * 			   lineCode :线路编码;roadCoding:道路编码;sectionCode:路段编码;sectionDistance:路段长度;sectionName:路段名称;sectionTime:路段时长;
     *
     * 			   sectionrouteCode:路段序号;speedLimit:路段限速>
     *
     * @return map<SUCCESS:成功;ERROR:异常>
     */
    @RequestMapping(value="sectionSave" , method = RequestMethod.POST)
    public Map<String, Object> sectionSave(@RequestParam Map<String, Object> map) {
        map.put("createBy", "");
        map.put("updateBy", "");
        return inoutCarparkService.sectionSave(map);
    }

    /**
     * @Description :TODO(编辑线路走向)
     *
     * @param map <sectionId:路段ID; sectionJSON:路段信息>
     *
     * @return Map<String, Object> <SUCCESS ; ERROR>
     */
    @RequestMapping(value="sectionUpdate" , method = RequestMethod.POST)
    public Map<String, Object> sectionUpdate(@RequestParam Map<String, Object> map) {

        map.put("updateBy", "");

        map.put("createBy", "");

        map.put("createDate", "");

        return inoutCarparkService.sectionUpdate(map);

    }

    /**
     * @param id //路段路由id
     * @Description: TODO(撤销路段)
     */
    @RequestMapping(value = "/destroy", method = RequestMethod.POST)
    public Map<String, Object> destroy(@RequestParam Map<String, Object> map) {
        return inoutCarparkService.destroy(map);
    }

    /**
     * 从历史轨迹做进场路径规划
     * @Description: TODO(撤销路段)
     */
    @RequestMapping(value = "/pathPlaningByHistory", method = RequestMethod.POST)
    public Map<String, Object> pathPlaningByHistory(@RequestParam Map<String, Object> map){
        Map<String, Object> result = new HashMap<>();
        result.put("status", ResponseCode.SUCCESS);
        try {
            String schId = (String)map.get("schId"), version = (String)map.get("version");
            if (StringUtils.isEmpty(schId) || StringUtils.isEmpty(version)) {
                throw new RuntimeException("无效的参数");
            }
            inoutCarparkService.pathPlaningByHistory(Long.parseLong(schId), Integer.parseInt(version));
        } catch (Exception e) {
            result.put("status", ResponseCode.ERROR);
            logger.error("路径规划异常", e);
        }

        return result;
    }
}