南瑞平台 controller类 并测试

This commit is contained in:
Lemon
2023-10-12 09:14:13 +08:00
parent aef44dcce9
commit 192cf56e84
11 changed files with 162 additions and 67 deletions

View File

@@ -1,10 +1,91 @@
package com.jsowell.thirdparty.nanrui;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.pile.domain.nanrui.NROrderInfo;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
import com.jsowell.thirdparty.nanrui.service.NRService;
import org.springframework.beans.factory.annotation.Autowired;
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;
import java.util.Map;
/**
* TODO
* 南瑞平台 controller
*
* @author Lemon
* @Date 2023/10/11 13:26
*/
public class NRController {
@Anonymous
@RestController
@RequestMapping("/nanrui")
public class NRController extends BaseController {
@Autowired
private NRService nrService;
/**
* 查询充电站信息
* @param dto
*/
@RequestMapping("/v1/query_stations_info")
public RestApiResponse<?> query_stations_info(@RequestBody QueryStationInfoDTO dto) {
logger.info("南瑞平台查询充电站信息 params:{}", JSON.toJSONString(dto));
RestApiResponse<?> response = null;
try {
Map<String, Object> map = nrService.query_stations_info(dto);
response = new RestApiResponse<>(map);
} catch (Exception e) {
logger.error("南瑞平台查询充电站信息 error", e);
response = new RestApiResponse<>(e);
}
logger.info("南瑞平台查询充电站信息 result:{}", response);
return response;
}
/**
* 查询设备接口状态
* @param dto
*/
@RequestMapping("/v1/query_station_status")
public RestApiResponse<?> query_station_status(@RequestBody QueryStationInfoDTO dto) {
logger.info("南瑞平台查询设备接口状态 params:{}", JSON.toJSONString(dto));
RestApiResponse<?> response = null;
try {
Map<String, Object> map = nrService.query_station_status(dto.getStationIds());
response = new RestApiResponse<>(map);
} catch (Exception e) {
logger.error("南瑞平台查询设备接口状态 error", e);
response = new RestApiResponse<>(e);
}
logger.info("南瑞平台查询设备接口状态 result:{}", response);
return response;
}
/**
* 查询设备接口状态
* @param dto
*/
@RequestMapping("/v1/query_order_info")
public RestApiResponse<?> query_order_info(@RequestBody NRQueryOrderDTO dto) {
logger.info("南瑞平台查询设备接口状态 params:{}", JSON.toJSONString(dto));
RestApiResponse<?> response = null;
try {
List<NROrderInfo> nrOrderInfos = nrService.query_order_info(dto);
response = new RestApiResponse<>(nrOrderInfos);
} catch (Exception e) {
logger.error("南瑞平台查询设备接口状态 error", e);
response = new RestApiResponse<>(e);
}
logger.info("南瑞平台查询设备接口状态 result:{}", response);
return response;
}
}