package com.prolog.rdc.tms.controller;

import com.alibaba.fastjson.JSONObject;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.vo.AMapVO;
import com.prolog.rdc.tms.service.AMapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 
 *
 * 地图接口控制层
 *
 * @className :AMapController
 * @author :fanzw
 * @creationTime :2022/11/08
 * @description :
 *
 * @modifier :fanzw
 * @modifyTime :2022/11/08
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Slf4j
@Api(tags = "地图接口调用")
@RestController
@RequestMapping("/aMap")
public class AMapController {

	@Autowired
	private AMapService service;

	@UserLog("获取驾驶路径规划")
	@ApiOperation(value = "获取驾驶路径规划", notes = "获取驾驶路径规划")
	@PostMapping("/getDrivingRouting")
	public RestMessage<Object> getDrivingRoutingExecute(@RequestBody List<AMapVO> vos) {
		try {
			log.info("======获取驾驶路径规划接口调用开始:{}", JSONObject.toJSONString(vos));
			service.getDrivingRouting(vos);
			log.info("======获取驾驶路径规划接口调用结束======");
			return RestMessage.newInstance(true, "获取驾驶路径规划成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			log.info("======获取驾驶路径规划异常:{}", e.getMessage());
			return RestMessage.newInstance(false, "获取驾驶路径规划失败:" + e.getMessage(), null);
		}
	}
}
