mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 占桩订单相关接口
This commit is contained in:
@@ -32,7 +32,7 @@ public class OccupyOrderController extends BaseController {
|
||||
private OrderPileOccupyService orderPileOccupyService;
|
||||
|
||||
/**
|
||||
* 查询站点占桩费率
|
||||
* todo 查询站点占桩费率
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
@@ -81,7 +81,12 @@ public class OccupyOrderController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
// 查询占桩订单列表页
|
||||
/**
|
||||
* 查询占桩订单列表页
|
||||
* https://api.jsowellcloud.com/uniapp/occupyOrder/getOccupyOrderInfo
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getOccupyOrderInfo")
|
||||
public RestApiResponse<?> getOccupyOrderInfo(HttpServletRequest request) {
|
||||
// 获取memberId
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
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;
|
||||
@@ -9,6 +11,7 @@ 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.service.*;
|
||||
@@ -45,6 +48,9 @@ public class PileController extends BaseController {
|
||||
@Autowired
|
||||
private IPileMerchantInfoService pileMerchantInfoService;
|
||||
|
||||
@Autowired
|
||||
private OrderPileOccupyService orderPileOccupyService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电站信息列表(主页)
|
||||
@@ -142,16 +148,34 @@ public class PileController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程遥控地锁指令
|
||||
* 远程遥控地锁指令 + 生成占桩订单
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/remoteGroundLock")
|
||||
public RestApiResponse<?> remoteGroundLock(@RequestBody RemoteControlGroundLockCommand command) {
|
||||
public RestApiResponse<?> remoteGroundLock(HttpServletRequest request, @RequestBody RemoteControlGroundLockCommand command) {
|
||||
logger.info("遥控地锁指令 params:{}", JSONObject.toJSONString(command));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
ykcPushCommandService.pushRemoteControlGroundLock(command);
|
||||
if (StringUtils.equals(command.getOperate(), Constants.ONE)) {
|
||||
// 升锁不生成占桩订单
|
||||
return new RestApiResponse<>();
|
||||
}
|
||||
// 获取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));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("遥控地锁指令 error, ", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
|
||||
@@ -10,6 +10,7 @@ public enum OrderPileOccupyStatusEnum {
|
||||
OCCUPIED("0", "占桩中"),
|
||||
ORDER_COMPLETE("1", "订单完成"),
|
||||
ORDER_HANG_UP("2", "订单挂起"),
|
||||
DRAFT_ORDER("9", "草稿单"),
|
||||
;
|
||||
|
||||
private String code;
|
||||
|
||||
@@ -4,12 +4,19 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import com.jsowell.pile.domain.OrderPileOccupy;
|
||||
import com.jsowell.pile.service.OrderPileOccupyService;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 充电桩返回遥控地锁升锁与降锁数据(上行)
|
||||
*
|
||||
@@ -19,6 +26,11 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RemoteControlGroundLockResponseHandler extends AbstractHandler{
|
||||
|
||||
@Autowired
|
||||
private OrderPileOccupyService orderPileOccupyService;
|
||||
|
||||
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.CHARGING_PILE_RESPOND_GROUND_LOCK_LIFTING_CODE.getBytes());
|
||||
|
||||
@Override
|
||||
@@ -56,7 +68,21 @@ public class RemoteControlGroundLockResponseHandler extends AbstractHandler{
|
||||
|
||||
log.info("===充电桩返回遥控地锁升锁与降锁数据(上行)=== result: 桩编号:{}, 枪号:{}, 地锁控制返回标志:( 1, 鉴权成功; 0, 鉴权失败){}",
|
||||
pileSn, connectorCode, controlResult);
|
||||
|
||||
|
||||
if (StringUtils.equals(controlResult, "01")) {
|
||||
// 鉴权成功
|
||||
}
|
||||
// 查出占桩订单,将开始时间set进订单信息
|
||||
OrderPileOccupy orderInfo = orderPileOccupyService.getOrderInfoByPile(pileSn, connectorCode);
|
||||
if (orderInfo == null) {
|
||||
return null;
|
||||
}
|
||||
if (Objects.isNull(orderInfo.getStartTime())) {
|
||||
orderInfo.setStartTime(DateUtils.getNowDate());
|
||||
// 修改数据库
|
||||
orderPileOccupyService.updateByPrimaryKey(orderInfo);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,4 +91,12 @@ public interface OrderPileOccupyMapper {
|
||||
* @return
|
||||
*/
|
||||
List<OrderPileOccupyVO> getOccupyOrderInfo(String memberId);
|
||||
|
||||
/**
|
||||
* 根据桩编号、枪口号查询最近一条占桩订单
|
||||
* @param pileSn
|
||||
* @param connectorCode
|
||||
* @return
|
||||
*/
|
||||
OrderPileOccupy getOrderInfoByPile(@Param("pileSn") String pileSn, @Param("connectorCode") String connectorCode);
|
||||
}
|
||||
@@ -58,4 +58,12 @@ public interface OrderPileOccupyService{
|
||||
* @return
|
||||
*/
|
||||
List<OrderPileOccupyVO> getOccupyOrderInfo(String memberId);
|
||||
|
||||
/**
|
||||
* 根据桩编号、枪口号查询最近一条占桩订单
|
||||
* @param pileSn
|
||||
* @param connectorCode
|
||||
* @return
|
||||
*/
|
||||
OrderPileOccupy getOrderInfoByPile(String pileSn, String connectorCode);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
String occupyCode = "OP" + IdUtils.getOrderCode();
|
||||
orderPileOccupy.setOccupyCode(occupyCode);
|
||||
orderPileOccupy.setMemberId(memberId);
|
||||
orderPileOccupy.setStatus(Constants.ZERO); // 占桩中
|
||||
orderPileOccupy.setStatus(OrderPileOccupyStatusEnum.DRAFT_ORDER.getCode()); // 占桩中
|
||||
orderPileOccupy.setPayStatus(Constants.ZERO); // 未支付
|
||||
orderPileOccupy.setPileSn(pileSn);
|
||||
PileInfoVO pileInfoVO = pileBasicInfoService.selectPileInfoBySn(pileSn);
|
||||
@@ -147,7 +147,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
}
|
||||
orderPileOccupy.setConnectorCode(connectorCode);
|
||||
orderPileOccupy.setPileConnectorCode(pileSn + connectorCode);
|
||||
orderPileOccupy.setStartTime(DateUtils.getNowDate());
|
||||
// orderPileOccupy.setStartTime(DateUtils.getNowDate());
|
||||
orderPileOccupy.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
||||
orderPileOccupyMapper.insertSelective(orderPileOccupy);
|
||||
|
||||
@@ -287,5 +287,16 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据桩编号、枪口号查询最近一条占桩订单
|
||||
* @param pileSn
|
||||
* @param connectorCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OrderPileOccupy getOrderInfoByPile(String pileSn, String connectorCode) {
|
||||
return orderPileOccupyMapper.getOrderInfoByPile(pileSn, connectorCode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -844,7 +844,7 @@
|
||||
t1.status,
|
||||
t1.station_id as stationId,
|
||||
t2.station_name as stationName,
|
||||
t1.start_time as startime,
|
||||
t1.start_time as startTime,
|
||||
t1.end_time as endTime,
|
||||
t1.pay_status as payStatus,
|
||||
t1.order_amount as orderAmount
|
||||
@@ -854,4 +854,18 @@
|
||||
where
|
||||
member_id = #{memberId,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="getOrderInfoByPile" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from
|
||||
order_pile_occupy
|
||||
where
|
||||
pile_sn = #{pileSn,jdbcType=VARCHAR}
|
||||
and
|
||||
connector_code = #{connectorCode,jdbcType=VARCHAR}
|
||||
order by
|
||||
create_time DESC
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user