mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-08 03:50:13 +08:00
update 地锁逻辑修改
This commit is contained in:
85
jsowell-admin/src/test/java/Test.java
Normal file
85
jsowell-admin/src/test/java/Test.java
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @program: com.cjml.service.partitem
|
||||||
|
* @description:
|
||||||
|
* @author: dc
|
||||||
|
* @create: 2023-09-09 13:46
|
||||||
|
**/
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<Category> testList = Lists.newArrayList();
|
||||||
|
testList.add(new Category("100-50-10", 100, 50, 10));
|
||||||
|
testList.add(new Category("110-30-8", 110, 30, 8));
|
||||||
|
testList.add(new Category("0-10-12", 0, 10, 12));
|
||||||
|
|
||||||
|
testList = testList.stream().sorted(
|
||||||
|
Comparator.comparing(Category::getCategoryGroupSort, Comparator.reverseOrder())
|
||||||
|
.thenComparing(Category::getCategorySort, Comparator.reverseOrder())
|
||||||
|
.thenComparing(Category::getPartSort)
|
||||||
|
)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
System.out.println(testList.get(0).getCategoryName());
|
||||||
|
System.out.println(testList.get(1).getCategoryName());
|
||||||
|
System.out.println(testList.get(2).getCategoryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Category {
|
||||||
|
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
private int categoryGroupSort;
|
||||||
|
|
||||||
|
private int categorySort;
|
||||||
|
|
||||||
|
private int partSort;
|
||||||
|
|
||||||
|
public Category() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Category(String categoryName, int categoryGroupSort, int categorySort, int partSort) {
|
||||||
|
this.categoryName = categoryName;
|
||||||
|
this.categoryGroupSort = categoryGroupSort;
|
||||||
|
this.categorySort = categorySort;
|
||||||
|
this.partSort = partSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategoryName() {
|
||||||
|
return categoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryName(String categoryName) {
|
||||||
|
this.categoryName = categoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCategoryGroupSort() {
|
||||||
|
return categoryGroupSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryGroupSort(int categoryGroupSort) {
|
||||||
|
this.categoryGroupSort = categoryGroupSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCategorySort() {
|
||||||
|
return categorySort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategorySort(int categorySort) {
|
||||||
|
this.categorySort = categorySort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPartSort() {
|
||||||
|
return partSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPartSort(int partSort) {
|
||||||
|
this.partSort = partSort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jsowell.netty.handler;
|
package com.jsowell.netty.handler;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.jsowell.common.constant.CacheConstants;
|
import com.jsowell.common.constant.CacheConstants;
|
||||||
import com.jsowell.common.core.domain.ykc.GroundLockData;
|
import com.jsowell.common.core.domain.ykc.GroundLockData;
|
||||||
@@ -89,24 +90,6 @@ public class GroundLockDataUploadHandler extends AbstractHandler{
|
|||||||
byte[] waitingUseByteArr = BytesUtil.copyBytes(msgBody, 12, 4);
|
byte[] waitingUseByteArr = BytesUtil.copyBytes(msgBody, 12, 4);
|
||||||
String waitingUse = BytesUtil.bcd2Str(waitingUseByteArr);
|
String waitingUse = BytesUtil.bcd2Str(waitingUseByteArr);
|
||||||
|
|
||||||
// 封装到对象中
|
|
||||||
GroundLockData data = GroundLockData.builder()
|
|
||||||
.pileSn(pileSn)
|
|
||||||
.connectorCode(connectorCode)
|
|
||||||
.parkingLockStatus(parkingLockStatus)
|
|
||||||
.parkingStatus(parkingStatus)
|
|
||||||
.groundLockElectric(groundLockElectric)
|
|
||||||
.alarmStatus(alarmStatus)
|
|
||||||
.time(DateUtils.getTime())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// 地锁信息放缓存中 缓存10分钟
|
|
||||||
String redisKey = CacheConstants.GROUND_LOCK_DATA + pileSn + connectorCode;
|
|
||||||
redisCache.setCacheObject(redisKey, data, CacheConstants.cache_expire_time_10m);
|
|
||||||
|
|
||||||
log.info("[===地锁数据上送===] result: 桩编码:{}, 枪号:{}, 车位锁状态:{}, 车位状态:{}, 地锁电量状态:{}, 报警状态:{}",
|
|
||||||
pileSn, connectorCode, parkingLockStatus, parkingStatus, groundLockElectric, alarmStatus);
|
|
||||||
|
|
||||||
if (StringUtils.equals(parkingLockStatus, "55")) {
|
if (StringUtils.equals(parkingLockStatus, "55")) {
|
||||||
log.info("0x61地锁数据,车位锁状态:升锁到位状态");
|
log.info("0x61地锁数据,车位锁状态:升锁到位状态");
|
||||||
if (StringUtils.equals(parkingStatus, "00")) {
|
if (StringUtils.equals(parkingStatus, "00")) {
|
||||||
@@ -126,6 +109,24 @@ public class GroundLockDataUploadHandler extends AbstractHandler{
|
|||||||
} else {
|
} else {
|
||||||
log.info("0x61地锁数据,车位锁状态:未到位状态");
|
log.info("0x61地锁数据,车位锁状态:未到位状态");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 封装到对象中
|
||||||
|
GroundLockData data = GroundLockData.builder()
|
||||||
|
.pileSn(pileSn)
|
||||||
|
.connectorCode(connectorCode)
|
||||||
|
.parkingLockStatus(parkingLockStatus)
|
||||||
|
.parkingStatus(parkingStatus)
|
||||||
|
.groundLockElectric(groundLockElectric)
|
||||||
|
.alarmStatus(alarmStatus)
|
||||||
|
.time(DateUtils.getTime())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 地锁信息放缓存中 缓存10分钟
|
||||||
|
String redisKey = CacheConstants.GROUND_LOCK_DATA + pileSn + connectorCode;
|
||||||
|
redisCache.setCacheObject(redisKey, data, CacheConstants.cache_expire_time_10m);
|
||||||
|
|
||||||
|
log.info("[===地锁数据上送===] result: 桩编码:{}, 枪号:{}, 车位锁状态:{}, 车位状态:{}, 地锁电量状态:{}, 报警状态:{}",
|
||||||
|
pileSn, connectorCode, parkingLockStatus, parkingStatus, groundLockElectric, alarmStatus);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +144,7 @@ public class GroundLockDataUploadHandler extends AbstractHandler{
|
|||||||
orderInfo.setStartTime(DateUtils.getNowDate());
|
orderInfo.setStartTime(DateUtils.getNowDate());
|
||||||
orderInfo.setPayStatus(OccupyOrderPayStatusEnum.UN_PAY.getCode());
|
orderInfo.setPayStatus(OccupyOrderPayStatusEnum.UN_PAY.getCode());
|
||||||
// 修改数据库
|
// 修改数据库
|
||||||
log.info("降锁成功,修改订单状态");
|
log.info("降锁成功,修改订单状态:{}", JSON.toJSONString(orderInfo));
|
||||||
orderPileOccupyService.updateByPrimaryKeySelective(orderInfo);
|
orderPileOccupyService.updateByPrimaryKeySelective(orderInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,6 +153,17 @@ public class GroundLockDataUploadHandler extends AbstractHandler{
|
|||||||
* 升锁成功时调用
|
* 升锁成功时调用
|
||||||
*/
|
*/
|
||||||
private void raiseTheGroundLock(String pileSn, String connectorCode) {
|
private void raiseTheGroundLock(String pileSn, String connectorCode) {
|
||||||
|
// 两种情况 1是没有停车,地锁自动升起;2是停车完成地锁升起
|
||||||
|
boolean stopFlag = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (stopFlag) {
|
||||||
|
// 停止占桩订单计时
|
||||||
orderPileOccupyService.stopOccupyPileOrder(pileSn, connectorCode);
|
orderPileOccupyService.stopOccupyPileOrder(pileSn, connectorCode);
|
||||||
|
} else {
|
||||||
|
// 关闭占桩订单
|
||||||
|
orderPileOccupyService.closeOccupyPileOrder(pileSn, connectorCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.jsowell.common.core.page.PageResponse;
|
|||||||
import com.jsowell.pile.domain.OrderPileOccupy;
|
import com.jsowell.pile.domain.OrderPileOccupy;
|
||||||
import com.jsowell.pile.dto.*;
|
import com.jsowell.pile.dto.*;
|
||||||
import com.jsowell.pile.vo.uniapp.OccupyOrderDetailVO;
|
import com.jsowell.pile.vo.uniapp.OccupyOrderDetailVO;
|
||||||
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -105,4 +104,6 @@ public interface OrderPileOccupyService{
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int updateOrderInfoForWeb(MakeOrderFreeDTO dto);
|
int updateOrderInfoForWeb(MakeOrderFreeDTO dto);
|
||||||
|
|
||||||
|
void closeOccupyPileOrder(String pileSn, String connectorCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,8 +196,6 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stopOccupyPileOrder(String pileSn, String connectorCode) {
|
public void stopOccupyPileOrder(String pileSn, String connectorCode) {
|
||||||
// 两种情况 1是没有停车,地锁自动升起;2是停车完成地锁升起
|
|
||||||
|
|
||||||
// 根据充电站sn和枪口号,查询占桩中的占桩订单
|
// 根据充电站sn和枪口号,查询占桩中的占桩订单
|
||||||
OrderPileOccupy orderPileOccupy = getOccupiedOrder(pileSn, connectorCode);
|
OrderPileOccupy orderPileOccupy = getOccupiedOrder(pileSn, connectorCode);
|
||||||
if (orderPileOccupy == null) {
|
if (orderPileOccupy == null) {
|
||||||
@@ -462,6 +460,16 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeOccupyPileOrder(String pileSn, String connectorCode) {
|
||||||
|
// 查询草稿状态的占桩订单
|
||||||
|
OrderPileOccupy draftOccupyOrder = getDraftOccupyOrder(pileSn, connectorCode);
|
||||||
|
// 关闭草稿订单
|
||||||
|
draftOccupyOrder.setStatus(Constants.ONE);
|
||||||
|
draftOccupyOrder.setPayStatus(Constants.TWO);
|
||||||
|
updateByPrimaryKey(draftOccupyOrder);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 支付占桩订单
|
* 支付占桩订单
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user