生成占桩订单

This commit is contained in:
2023-08-18 12:02:34 +08:00
parent 5bf5ffc3b7
commit 31c295ee90
7 changed files with 104 additions and 48 deletions

View File

@@ -1,22 +1,18 @@
package com.jsowell.api.uniapp;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.ImmutableMap;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.constant.Constants;
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;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.ykcCommond.RemoteControlGroundLockCommand;
import com.jsowell.pile.dto.GenerateOccupyOrderDTO;
import com.jsowell.pile.dto.QueryConnectorListDTO;
import com.jsowell.pile.dto.QueryStationDTO;
import com.jsowell.pile.dto.RemoteGroundLockDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
import com.jsowell.pile.vo.uniapp.GroundLockInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -149,33 +145,21 @@ public class PileController extends BaseController {
/**
* 远程遥控地锁指令 + 生成占桩订单
* @param command
* @return
*/
@PostMapping("/remoteGroundLock")
public RestApiResponse<?> remoteGroundLock(HttpServletRequest request, @RequestBody RemoteControlGroundLockCommand command) {
logger.info("遥控地锁指令 params:{}", JSONObject.toJSONString(command));
public RestApiResponse<?> remoteGroundLock(HttpServletRequest request, @RequestBody RemoteGroundLockDTO dto) {
logger.info("遥控地锁指令 params:{}", JSONObject.toJSONString(dto));
RestApiResponse<?> response = null;
try {
ykcPushCommandService.pushRemoteControlGroundLock(command);
if (StringUtils.equals(command.getOperate(), Constants.ONE)) {
// 升锁不生成占桩订单
return new RestApiResponse<>();
// 校验参数
if (StringUtils.isBlank(dto.getPileSn()) || StringUtils.isBlank(dto.getConnectorCode())
|| StringUtils.isBlank(dto.getOperate())) {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
}
// 获取memberId
String memberId = getMemberIdByAuthorization(request);
if (StringUtils.isEmpty(memberId)) {
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
}
GenerateOccupyOrderDTO dto = new GenerateOccupyOrderDTO();
dto.setMemberId(memberId);
dto.setPileSn(command.getPileSn());
dto.setConnectorCode(command.getConnectorCode());
// 生成占桩订单(草稿单)
String occupyOrderCode = orderPileOccupyService.generateOccupyPileOrder(dto);
if (StringUtils.isNotBlank(occupyOrderCode)) {
response = new RestApiResponse<>(ImmutableMap.of("occupyOrderCode", occupyOrderCode));
}
dto.setMemberId(getMemberIdByAuthorization(request));
orderPileOccupyService.remoteGroundLock(dto);
response = new RestApiResponse<>();
} catch (Exception e) {
logger.error("遥控地锁指令 error, ", e);
response = new RestApiResponse<>(e);