mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-15 03:27:59 +08:00
update 地锁逻辑修改
This commit is contained in:
@@ -48,7 +48,7 @@ public class PileController extends BaseController {
|
||||
|
||||
/**
|
||||
* 查询充电站信息列表(主页)
|
||||
*
|
||||
* <p>
|
||||
* http://localhost:8080/uniapp/pile/queryStationInfos
|
||||
*/
|
||||
@PostMapping("/queryStationInfos")
|
||||
@@ -80,6 +80,7 @@ public class PileController extends BaseController {
|
||||
/**
|
||||
* 通过站点id查询计费模板列表
|
||||
* http://localhost:8080/uniapp/pile/queryBillingPrice/{stationId}
|
||||
*
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
@@ -100,7 +101,7 @@ public class PileController extends BaseController {
|
||||
|
||||
/**
|
||||
* 通过前端参数查询充电枪口列表
|
||||
*
|
||||
* <p>
|
||||
* http://localhost:8080/uniapp/pile/selectConnectorListByParams
|
||||
*
|
||||
* @param dto
|
||||
@@ -123,6 +124,7 @@ public class PileController extends BaseController {
|
||||
|
||||
/**
|
||||
* 根据充电站id查询枪口列表
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
@@ -159,8 +161,11 @@ public class PileController extends BaseController {
|
||||
dto.setMemberId(getMemberIdByAuthorization(request));
|
||||
orderPileOccupyService.remoteGroundLock(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.error("遥控地锁指令 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("遥控地锁指令 error, ", e);
|
||||
logger.error("遥控地锁指令 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("遥控地锁指令 result:{}", response);
|
||||
|
||||
@@ -35,6 +35,9 @@ public class CacheConstants {
|
||||
// 地锁数据
|
||||
public static final String GROUND_LOCK_DATA = "ground_lock_data:";
|
||||
|
||||
// 地锁订单数据
|
||||
public static final String GROUND_LOCK_OCCUPY_ORDER = "ground_lock_occupy_order:";
|
||||
|
||||
// 根据站点id查询充电桩列表
|
||||
public static final String GET_PILE_LIST_BY_STATION_ID = "get_pile_list_by_station_id:";
|
||||
|
||||
|
||||
@@ -122,6 +122,9 @@ public enum ReturnCodeEnum {
|
||||
|
||||
CODE_GET_FIRST_LEVEL_MERCHANT_BY_APP_ID("00100058", "根据小程序appId未查询到一级运营商信息"),
|
||||
|
||||
// 地锁存在未完成的占桩订单
|
||||
CODE_HAS_OCCUPY_PILE_ORDER_ERROR("00100059", "当前地锁存在未完成的占桩订单"),
|
||||
|
||||
/* 个人桩 start */
|
||||
|
||||
CODE_PILE_HAS_BEEN_BINDING_ERROR("00400001", "此桩已被绑定,请联系管理员!"),
|
||||
|
||||
@@ -174,5 +174,8 @@ public class GroundLockDataUploadHandler extends AbstractHandler{
|
||||
// 关闭占桩订单
|
||||
orderPileOccupyService.closeOccupyPileOrder(pileSn, connectorCode);
|
||||
}
|
||||
|
||||
String occupyOrderKey = CacheConstants.GROUND_LOCK_OCCUPY_ORDER + pileSn + connectorCode;
|
||||
redisCache.deleteObject(occupyOrderKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.adapay.service.AdapayService;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.DelFlagEnum;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.uniapp.OccupyOrderPayStatusEnum;
|
||||
@@ -70,6 +72,9 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
@Autowired
|
||||
private OrderPileOccupyService orderPileOccupyService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public int deleteByPrimaryKey(Integer id) {
|
||||
return orderPileOccupyMapper.deleteByPrimaryKey(id);
|
||||
@@ -166,6 +171,13 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
String memberId = dto.getMemberId();
|
||||
String pileSn = dto.getPileSn();
|
||||
String connectorCode = dto.getConnectorCode();
|
||||
|
||||
String redisKey = CacheConstants.GROUND_LOCK_OCCUPY_ORDER + pileSn + connectorCode;
|
||||
String cacheObject = redisCache.getCacheObject(redisKey);
|
||||
if (StringUtils.isNotBlank(cacheObject)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_HAS_OCCUPY_PILE_ORDER_ERROR);
|
||||
}
|
||||
|
||||
// 创建占桩订单
|
||||
OrderPileOccupy orderPileOccupy = new OrderPileOccupy();
|
||||
String occupyCode = "OP" + IdUtils.getOrderCode();
|
||||
@@ -184,6 +196,9 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
orderPileOccupy.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
||||
orderPileOccupyMapper.insertSelective(orderPileOccupy);
|
||||
|
||||
// 放缓存
|
||||
redisCache.setCacheObject(redisKey, occupyCode, CacheConstants.cache_expire_time_10d);
|
||||
|
||||
return orderPileOccupy.getOccupyCode();
|
||||
}
|
||||
|
||||
@@ -381,27 +396,29 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
* @return
|
||||
*/
|
||||
public OrderPileOccupy getOccupiedOrder(String pileSn, String connectorCode) {
|
||||
OrderPileOccupy result = null;
|
||||
|
||||
// 查缓存中的占桩订单编号
|
||||
String redisKey = CacheConstants.GROUND_LOCK_OCCUPY_ORDER + pileSn + connectorCode;
|
||||
String orderCode = redisCache.getCacheObject(redisKey);
|
||||
if (StringUtils.isNotBlank(orderCode)) {
|
||||
result = queryByOccupyCode(orderCode);
|
||||
} else {
|
||||
List<OrderPileOccupy> list = orderPileOccupyMapper.queryOccupiedOrder(pileSn, connectorCode);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
if (list.size() > 1) {
|
||||
List<Integer> collect = list.stream().map(OrderPileOccupy::getId).collect(Collectors.toList());
|
||||
log.info("根据pileSn:{}, connectorCode:{}, 查询出多条占桩中的占桩订单, ids:{}", pileSn, connectorCode, collect);
|
||||
}
|
||||
return list.get(0);
|
||||
result = list.get(0);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remoteGroundLock(RemoteGroundLockDTO dto) {
|
||||
log.info("控制地锁升降并生成占桩订单 params:{}", JSON.toJSONString(dto));
|
||||
// 控制地锁升降
|
||||
RemoteControlGroundLockCommand command = new RemoteControlGroundLockCommand();
|
||||
command.setPileSn(dto.getPileSn());
|
||||
command.setConnectorCode(dto.getConnectorCode());
|
||||
command.setOperate(dto.getOperate());
|
||||
ykcPushCommandService.pushRemoteControlGroundLock(command);
|
||||
|
||||
// 如果是降锁生成占桩订单
|
||||
if (StringUtils.equals(dto.getOperate(), Constants.ZERO)) {
|
||||
// 生成占桩订单
|
||||
@@ -412,6 +429,13 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
// 生成占桩订单(草稿单)
|
||||
orderPileOccupyService.generateOccupyPileOrder(generateOccupyOrderDTO);
|
||||
}
|
||||
|
||||
// 控制地锁升降
|
||||
RemoteControlGroundLockCommand command = new RemoteControlGroundLockCommand();
|
||||
command.setPileSn(dto.getPileSn());
|
||||
command.setConnectorCode(dto.getConnectorCode());
|
||||
command.setOperate(dto.getOperate());
|
||||
ykcPushCommandService.pushRemoteControlGroundLock(command);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -465,10 +489,12 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
// 查询草稿状态的占桩订单
|
||||
OrderPileOccupy draftOccupyOrder = getDraftOccupyOrder(pileSn, connectorCode);
|
||||
// 关闭草稿订单
|
||||
if (draftOccupyOrder != null) {
|
||||
draftOccupyOrder.setStatus(Constants.ONE);
|
||||
draftOccupyOrder.setPayStatus(Constants.TWO);
|
||||
updateByPrimaryKey(draftOccupyOrder);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 支付占桩订单
|
||||
|
||||
Reference in New Issue
Block a user