2023-03-04 16:29:55 +08:00
|
|
|
package com.jsowell.api.uniapp;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.jsowell.common.annotation.Anonymous;
|
|
|
|
|
import com.jsowell.common.core.controller.BaseController;
|
|
|
|
|
import com.jsowell.common.core.page.PageResponse;
|
|
|
|
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
|
|
|
|
import com.jsowell.common.response.RestApiResponse;
|
2023-08-04 09:57:48 +08:00
|
|
|
import com.jsowell.pile.domain.ykcCommond.RemoteControlGroundLockCommand;
|
2023-03-04 16:29:55 +08:00
|
|
|
import com.jsowell.pile.dto.QueryConnectorListDTO;
|
|
|
|
|
import com.jsowell.pile.dto.QueryStationDTO;
|
2023-08-05 13:15:02 +08:00
|
|
|
import com.jsowell.pile.service.IPileBasicInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
import com.jsowell.pile.service.IPileConnectorInfoService;
|
|
|
|
|
import com.jsowell.pile.service.IPileStationInfoService;
|
2023-08-04 09:57:48 +08:00
|
|
|
import com.jsowell.pile.service.YKCPushCommandService;
|
2023-08-05 13:15:02 +08:00
|
|
|
import com.jsowell.pile.vo.uniapp.GroundLockInfoVO;
|
2023-03-04 16:29:55 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2023-08-05 13:15:02 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
2023-08-05 13:15:02 +08:00
|
|
|
import java.util.List;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 充电桩相关接口
|
|
|
|
|
* 提供给小程序调用
|
|
|
|
|
*/
|
|
|
|
|
// 不登录直接访问
|
|
|
|
|
@Anonymous
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/uniapp/pile")
|
|
|
|
|
public class PileController extends BaseController {
|
|
|
|
|
|
2023-08-04 09:57:48 +08:00
|
|
|
@Autowired
|
|
|
|
|
private YKCPushCommandService ykcPushCommandService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPileStationInfoService pileStationInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPileConnectorInfoService pileConnectorInfoService;
|
|
|
|
|
|
2023-08-05 13:15:02 +08:00
|
|
|
@Autowired
|
|
|
|
|
private IPileBasicInfoService pileBasicInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询充电站信息列表(主页)
|
|
|
|
|
*
|
|
|
|
|
* http://localhost:8080/uniapp/pile/queryStationInfos
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/queryStationInfos")
|
|
|
|
|
public RestApiResponse<?> queryStationInfos(HttpServletRequest request, @RequestBody QueryStationDTO queryStationDTO) {
|
|
|
|
|
logger.info("查询充电站信息列表 param:{}", JSONObject.toJSONString(queryStationDTO));
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
PageResponse pageResponse = pileStationInfoService.uniAppQueryStationInfoList(queryStationDTO);
|
|
|
|
|
response = new RestApiResponse<>(pageResponse);
|
|
|
|
|
} catch (BusinessException e) {
|
|
|
|
|
logger.warn("查询充电站信息列表warn", e);
|
|
|
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("查询充电站信息列表异常 error", e);
|
|
|
|
|
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_STATION_INFO_ERROR);
|
|
|
|
|
}
|
|
|
|
|
logger.info("查询充电站信息列表 result:{}", JSONObject.toJSONString(response));
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过前端参数查询充电枪口列表
|
|
|
|
|
*
|
|
|
|
|
* http://localhost:8080/uniapp/pile/selectConnectorListByParams
|
|
|
|
|
*
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/selectConnectorListByParams")
|
|
|
|
|
public RestApiResponse<?> selectConnectorListByParams(HttpServletRequest request, @RequestBody QueryConnectorListDTO dto) {
|
|
|
|
|
logger.info("查询充电枪口列表 params:{}", JSONObject.toJSONString(dto));
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
PageResponse pageResponse = pileConnectorInfoService.getUniAppConnectorInfoListByParams(dto);
|
|
|
|
|
response = new RestApiResponse<>(pageResponse);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("查询充电枪口列表异常", e);
|
|
|
|
|
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_CONNECTOR_INFO_BY_STATION_ID_ERROR);
|
|
|
|
|
}
|
|
|
|
|
logger.info("查询充电枪口列表 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-24 11:08:59 +08:00
|
|
|
/**
|
|
|
|
|
* 根据充电站id查询枪口列表
|
|
|
|
|
* @param request
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/selectStationConnectorList")
|
|
|
|
|
public RestApiResponse<?> selectStationConnectorList(HttpServletRequest request, @RequestBody QueryConnectorListDTO dto) {
|
|
|
|
|
logger.info("查询充电枪口列表 params:{}", JSONObject.toJSONString(dto));
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
PageResponse pageResponse = pileConnectorInfoService.selectStationConnectorList(dto);
|
|
|
|
|
response = new RestApiResponse<>(pageResponse);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("查询充电枪口列表异常", e);
|
|
|
|
|
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_CONNECTOR_INFO_BY_STATION_ID_ERROR);
|
|
|
|
|
}
|
|
|
|
|
logger.info("查询充电枪口列表 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-04 09:57:48 +08:00
|
|
|
/**
|
|
|
|
|
* 远程遥控地锁指令
|
|
|
|
|
* @param command
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/remoteGroundLock")
|
|
|
|
|
public RestApiResponse<?> remoteGroundLock(@RequestBody RemoteControlGroundLockCommand command) {
|
|
|
|
|
logger.info("遥控地锁指令 params:{}", JSONObject.toJSONString(command));
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
ykcPushCommandService.pushRemoteControlGroundLock(command);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("遥控地锁指令 error, ", e);
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
}
|
|
|
|
|
logger.info("遥控地锁指令 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-05 13:15:02 +08:00
|
|
|
/**
|
|
|
|
|
* 获取地锁列表信息
|
|
|
|
|
* @param stationId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/getGroundLockInfo/{stationId}")
|
|
|
|
|
public RestApiResponse<?> getGroundLockInfo(@PathVariable("stationId") String stationId) {
|
|
|
|
|
logger.info("获取地锁列表信息 params:{}", stationId);
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
try {
|
|
|
|
|
List<GroundLockInfoVO> list = pileBasicInfoService.getGroundLockInfo(stationId);
|
|
|
|
|
response = new RestApiResponse<>(list);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("获取地锁列表信息 error, ", e);
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
}
|
|
|
|
|
logger.info("获取地锁列表信息 result:{}", response);
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
}
|