mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-17 12:38:29 +08:00
update 修改充电桩信息
This commit is contained in:
@@ -578,6 +578,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||||||
return formatDateTime(date);
|
return formatDateTime(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String formatDateTime(LocalTime localTime) {
|
||||||
|
if (localTime == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return localTime.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
|
|||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,18 +41,43 @@ public class ReservationChargingCommand {
|
|||||||
private String operation;
|
private String operation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始时间
|
* 预约类型
|
||||||
|
* 0x00:单次0x01:周期
|
||||||
*/
|
*/
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
private String reservationType;
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
||||||
private Date reservedStartTime;
|
/**
|
||||||
|
* vin1
|
||||||
|
*/
|
||||||
|
private String vin1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vin2
|
||||||
|
*/
|
||||||
|
private String vin2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vin3
|
||||||
|
*/
|
||||||
|
private String vin3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
* 2024年6月28日15点21分 改为时分秒
|
||||||
|
*/
|
||||||
|
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
// private Date reservedStartTime;
|
||||||
|
private LocalTime reservedStartTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束时间
|
* 结束时间
|
||||||
|
* 2024年6月28日15点21分 改为时分秒
|
||||||
*/
|
*/
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date reservedEndTime;
|
// private Date reservedEndTime;
|
||||||
|
private LocalTime reservedEndTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动金额
|
* 启动金额
|
||||||
|
|||||||
@@ -120,12 +120,12 @@ public interface PileBasicInfoService {
|
|||||||
/**
|
/**
|
||||||
* 首次插枪
|
* 首次插枪
|
||||||
*/
|
*/
|
||||||
public void firstPlugInCharger(String pileConnectorCode);
|
void firstPlugInCharger(String pileConnectorCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首次拔枪
|
* 首次拔枪
|
||||||
*/
|
*/
|
||||||
public void firstUnplugCharger(String pileConnectorCode);
|
void firstUnplugCharger(String pileConnectorCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过桩编号查询站点id
|
* 通过桩编号查询站点id
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public interface SettleOrderReportService {
|
|||||||
|
|
||||||
int deleteByPrimaryKey(Integer id);
|
int deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
int insert(SettleOrderReport record);
|
// int insert(SettleOrderReport record);
|
||||||
|
|
||||||
int insertOrUpdate(SettleOrderReport record);
|
int insertOrUpdate(SettleOrderReport record);
|
||||||
|
|
||||||
|
|||||||
@@ -3119,20 +3119,20 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
/**
|
/**
|
||||||
* 异步发送预约充电指令
|
* 异步发送预约充电指令
|
||||||
*/
|
*/
|
||||||
if (StringUtils.equals(orderInfo.getStartType(), StartTypeEnum.RESERVED.getValue())) {
|
// if (StringUtils.equals(orderInfo.getStartType(), StartTypeEnum.RESERVED.getValue())) {
|
||||||
ReservationChargingCommand command = ReservationChargingCommand.builder()
|
// ReservationChargingCommand command = ReservationChargingCommand.builder()
|
||||||
.transactionCode(orderInfo.getTransactionCode())
|
// .transactionCode(orderInfo.getTransactionCode())
|
||||||
.pileSn(orderInfo.getPileSn())
|
// .pileSn(orderInfo.getPileSn())
|
||||||
.connectorCode(orderInfo.getConnectorCode())
|
// .connectorCode(orderInfo.getConnectorCode())
|
||||||
.operation(BytesUtil.bcd2Str(new byte[]{0x01}))
|
// .operation(BytesUtil.bcd2Str(new byte[]{0x01}))
|
||||||
.reservedStartTime(orderInfo.getReservedStartTime())
|
// .reservedStartTime(orderInfo.getReservedStartTime())
|
||||||
.reservedEndTime(orderInfo.getReservedEndTime())
|
// .reservedEndTime(orderInfo.getReservedEndTime())
|
||||||
.amount(new BigDecimal(Constants.FIVE_HUNDRED))
|
// .amount(new BigDecimal(Constants.FIVE_HUNDRED))
|
||||||
.build();
|
// .build();
|
||||||
// 发送预约充电指令
|
// // 发送预约充电指令
|
||||||
logger.info("订单:{}支付成功, 发送预约充电指令, command:{}", dto.getOrderCode(), JSON.toJSONString(command));
|
// logger.info("订单:{}支付成功, 发送预约充电指令, command:{}", dto.getOrderCode(), JSON.toJSONString(command));
|
||||||
pileRemoteService.reservationCharging(command);
|
// pileRemoteService.reservationCharging(command);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (OrderStatusEnum.STAY_RETROACTIVE_AMOUNT.getValue().equals(orderInfo.getOrderStatus())) {
|
if (OrderStatusEnum.STAY_RETROACTIVE_AMOUNT.getValue().equals(orderInfo.getOrderStatus())) {
|
||||||
// 如果订单状态是待补缴,表示已经停止充电了,需要补缴费用,补缴完成订单状态改为订单完成,设置结算时间
|
// 如果订单状态是待补缴,表示已经停止充电了,需要补缴费用,补缴完成订单状态改为订单完成,设置结算时间
|
||||||
|
|||||||
@@ -582,28 +582,6 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
|||||||
// 保存到redis
|
// 保存到redis
|
||||||
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + realTimeMonitorData.getPileConnectorCode() + "_" + realTimeMonitorData.getTransactionCode();
|
String redisKey = CacheConstants.PILE_REAL_TIME_MONITOR_DATA + realTimeMonitorData.getPileConnectorCode() + "_" + realTimeMonitorData.getTransactionCode();
|
||||||
|
|
||||||
// 拿到所有数据取出最后一条数据,对比数据变化
|
|
||||||
// Map<Object, Object> map = redisCache.hmget(redisKey);
|
|
||||||
// if (map != null && !map.isEmpty()) {
|
|
||||||
// List<String> keyList = map.keySet().stream()
|
|
||||||
// .map(x -> (String) x)
|
|
||||||
// .sorted(Comparator.reverseOrder()) // 对keyList排序 时间倒序
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// if (CollectionUtils.isNotEmpty(keyList)) {
|
|
||||||
// // index为0是最新的时间
|
|
||||||
// String lastTime = keyList.get(0);
|
|
||||||
// // 取出最新的数据
|
|
||||||
// Object lastData = map.get(lastTime);
|
|
||||||
// RealTimeMonitorData data = JSONObject.parseObject((String) lastData, RealTimeMonitorData.class);
|
|
||||||
// if (Objects.nonNull(data)) {
|
|
||||||
// // 如果已充金额相同,则return
|
|
||||||
// if (StringUtils.equals(data.getChargingAmount(), realTimeMonitorData.getChargingAmount())) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 设置接收到实时数据的时间
|
// 设置接收到实时数据的时间
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
realTimeMonitorData.setDateTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now));
|
realTimeMonitorData.setDateTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now));
|
||||||
|
|||||||
@@ -109,7 +109,10 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
|||||||
}
|
}
|
||||||
pileReservationInfo.setStatus(Constants.ONE);
|
pileReservationInfo.setStatus(Constants.ONE);
|
||||||
// 保存之前,校验时间是否重叠
|
// 保存之前,校验时间是否重叠
|
||||||
saveReservation(pileReservationInfo);
|
int i = saveReservation(pileReservationInfo);
|
||||||
|
if (i > 0) {
|
||||||
|
// TODO 发送指令
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +129,10 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
|||||||
}
|
}
|
||||||
// 校验通过可以修改预约
|
// 校验通过可以修改预约
|
||||||
pileReservationInfo.setStatus(Constants.ZERO);
|
pileReservationInfo.setStatus(Constants.ZERO);
|
||||||
pileReservationInfoMapper.updateByPrimaryKeySelective(pileReservationInfo);
|
int i = pileReservationInfoMapper.updateByPrimaryKeySelective(pileReservationInfo);
|
||||||
|
if (i > 0) {
|
||||||
|
// TODO 发送指令
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,9 +163,9 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveReservation(PileReservationInfo reservation) {
|
public int saveReservation(PileReservationInfo reservation) {
|
||||||
if (isTimeSlotAvailable(reservation.getMemberId(), reservation.getPileSn(), reservation.getStartTime(), reservation.getEndTime(), reservation.getId())) {
|
if (isTimeSlotAvailable(reservation.getMemberId(), reservation.getPileSn(), reservation.getStartTime(), reservation.getEndTime(), reservation.getId())) {
|
||||||
this.updateByPrimaryKeySelective(reservation);
|
return this.updateByPrimaryKeySelective(reservation);
|
||||||
} else {
|
} else {
|
||||||
throw new BusinessException(ReturnCodeEnum.CODE_UPDATE_RESERVED_STATUS_REFUSED);
|
throw new BusinessException(ReturnCodeEnum.CODE_UPDATE_RESERVED_STATUS_REFUSED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -453,10 +453,10 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
|||||||
return settleOrderReportMapper.deleteByPrimaryKey(id);
|
return settleOrderReportMapper.deleteByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public int insert(SettleOrderReport record) {
|
// public int insert(SettleOrderReport record) {
|
||||||
return settleOrderReportMapper.insert(record);
|
// return settleOrderReportMapper.insert(record);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertOrUpdate(SettleOrderReport record) {
|
public int insertOrUpdate(SettleOrderReport record) {
|
||||||
@@ -471,6 +471,12 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertOrUpdateSelective(SettleOrderReport record) {
|
public int insertOrUpdateSelective(SettleOrderReport record) {
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
|
if (record.getId() == null) {
|
||||||
|
record.setCreateTime(nowDate);
|
||||||
|
} else {
|
||||||
|
record.setUpdateTime(nowDate);
|
||||||
|
}
|
||||||
return settleOrderReportMapper.insertOrUpdateSelective(record);
|
return settleOrderReportMapper.insertOrUpdateSelective(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,19 +730,18 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
List<String> list = Lists.newArrayList(
|
List<String> list = Lists.newArrayList(
|
||||||
"17.56",
|
"0.06",
|
||||||
"26.13",
|
"0.06",
|
||||||
"11.79",
|
"0.09",
|
||||||
"34.80",
|
"0.06",
|
||||||
"12.72",
|
"0.05",
|
||||||
"18.03",
|
"0.09",
|
||||||
"19.80",
|
"0.02",
|
||||||
"66.76",
|
"0.18",
|
||||||
"15.27",
|
"0.10",
|
||||||
"37.50",
|
"0.03",
|
||||||
"28.45",
|
"0.06",
|
||||||
"24.81",
|
"0.11");
|
||||||
"16.75");
|
|
||||||
|
|
||||||
// 总手续费
|
// 总手续费
|
||||||
BigDecimal totalFeeAmount = BigDecimal.ZERO;
|
BigDecimal totalFeeAmount = BigDecimal.ZERO;
|
||||||
@@ -744,11 +749,11 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
|||||||
|
|
||||||
for (String s : list) {
|
for (String s : list) {
|
||||||
BigDecimal settleAmount = new BigDecimal(s);
|
BigDecimal settleAmount = new BigDecimal(s);
|
||||||
BigDecimal feeAmount = settleAmount.multiply(new BigDecimal(Constants.FEE_RATES)).setScale(2, RoundingMode.UP);
|
BigDecimal fee = settleAmount.multiply(new BigDecimal(Constants.FEE_RATES)).setScale(2, RoundingMode.UP);
|
||||||
// 交易金额 = 结算金额 - 手续费
|
// 交易金额 = 结算金额 - 手续费
|
||||||
BigDecimal tradeAmount = settleAmount.subtract(feeAmount);
|
BigDecimal tradeAmount = settleAmount.subtract(fee);
|
||||||
|
|
||||||
totalFeeAmount = totalFeeAmount.add(feeAmount);
|
totalFeeAmount = totalFeeAmount.add(fee);
|
||||||
totalTradeAmount = totalTradeAmount.add(tradeAmount);
|
totalTradeAmount = totalTradeAmount.add(tradeAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,14 +761,14 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
|||||||
System.out.println("总交易金额" + totalTradeAmount);
|
System.out.println("总交易金额" + totalTradeAmount);
|
||||||
|
|
||||||
|
|
||||||
BigDecimal settleAmount = new BigDecimal("330.37");
|
// BigDecimal settleAmount = new BigDecimal("330.37");
|
||||||
// 计算手续费 = 结算金额 * 0.55%
|
// // 计算手续费 = 结算金额 * 0.55%
|
||||||
BigDecimal fee = settleAmount.multiply(new BigDecimal(Constants.FEE_RATES));
|
// BigDecimal fee = settleAmount.multiply(new BigDecimal(Constants.FEE_RATES));
|
||||||
SplitSettleAmountVO resultVO = new SplitSettleAmountVO();
|
// SplitSettleAmountVO resultVO = new SplitSettleAmountVO();
|
||||||
resultVO.setSettleAmount(settleAmount);
|
// resultVO.setSettleAmount(settleAmount);
|
||||||
resultVO.setFeeAmount(fee);
|
// resultVO.setFeeAmount(fee);
|
||||||
resultVO.setTradeAmount(settleAmount.subtract(fee));
|
// resultVO.setTradeAmount(settleAmount.subtract(fee));
|
||||||
System.out.println(JSON.toJSONString(resultVO));
|
// System.out.println(JSON.toJSONString(resultVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,12 @@ import io.netty.channel.ChannelFuture;
|
|||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.aspectj.weaver.ast.Var;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -499,13 +501,39 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
|||||||
String operation = command.getOperation();
|
String operation = command.getOperation();
|
||||||
byte[] operateByteArr = BytesUtil.str2Bcd(operation);
|
byte[] operateByteArr = BytesUtil.str2Bcd(operation);
|
||||||
|
|
||||||
|
// 预约方式
|
||||||
|
String reservationType = command.getReservationType();
|
||||||
|
byte[] reservationTypeByteArr = BytesUtil.str2Bcd(reservationType);
|
||||||
|
|
||||||
|
// VIN1
|
||||||
|
String vin1 = command.getVin1();
|
||||||
|
if (StringUtils.isBlank(vin1)) {
|
||||||
|
vin1 = Constants.ZERO;
|
||||||
|
}
|
||||||
|
byte[] vin1ByteArr = BytesUtil.str2Bcd(vin1);
|
||||||
|
vin1ByteArr = BytesUtil.checkLengthAndBehindAppendZero(vin1ByteArr, 17);
|
||||||
|
|
||||||
|
String vin2 = command.getVin2();
|
||||||
|
if (StringUtils.isBlank(vin2)) {
|
||||||
|
vin2 = Constants.ZERO;
|
||||||
|
}
|
||||||
|
byte[] vin2ByteArr = BytesUtil.str2Bcd(vin2);
|
||||||
|
vin2ByteArr = BytesUtil.checkLengthAndBehindAppendZero(vin2ByteArr, 17);
|
||||||
|
|
||||||
|
String vin3 = command.getVin3();
|
||||||
|
if (StringUtils.isBlank(vin3)) {
|
||||||
|
vin3 = Constants.ZERO;
|
||||||
|
}
|
||||||
|
byte[] vin3ByteArr = BytesUtil.str2Bcd(vin3);
|
||||||
|
vin3ByteArr = BytesUtil.checkLengthAndBehindAppendZero(vin3ByteArr, 17);
|
||||||
|
|
||||||
// 开始时间
|
// 开始时间
|
||||||
Date reservedStartTime = command.getReservedStartTime();
|
LocalTime reservedStartTime = command.getReservedStartTime();
|
||||||
byte[] reservedStartTimeByteArr = Cp56Time2aUtil.date2Hbyte(reservedStartTime);
|
byte[] reservedStartTimeByteArr = BytesUtil.createByteArray((byte) reservedStartTime.getHour(), (byte) reservedStartTime.getMinute());
|
||||||
|
|
||||||
// 结束时间
|
// 结束时间
|
||||||
Date reservedEndTime = command.getReservedEndTime();
|
LocalTime reservedEndTime = command.getReservedEndTime();
|
||||||
byte[] reservedEndTimeByteArr = Cp56Time2aUtil.date2Hbyte(reservedEndTime);
|
byte[] reservedEndTimeByteArr = BytesUtil.createByteArray((byte) reservedEndTime.getHour(), (byte) reservedEndTime.getMinute());
|
||||||
|
|
||||||
// 启动金额
|
// 启动金额
|
||||||
BigDecimal amount = command.getAmount();
|
BigDecimal amount = command.getAmount();
|
||||||
@@ -513,6 +541,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
|||||||
|
|
||||||
// 拼装msg信息
|
// 拼装msg信息
|
||||||
byte[] msg = Bytes.concat(transactionCodeArr, pileSnByteArr, connectorCodeByteArr, operateByteArr,
|
byte[] msg = Bytes.concat(transactionCodeArr, pileSnByteArr, connectorCodeByteArr, operateByteArr,
|
||||||
|
reservationTypeByteArr, vin1ByteArr, vin2ByteArr, vin3ByteArr,
|
||||||
reservedStartTimeByteArr, reservedEndTimeByteArr, amountByteArr);
|
reservedStartTimeByteArr, reservedEndTimeByteArr, amountByteArr);
|
||||||
|
|
||||||
this.push(msg, pileSn, YKCFrameTypeCode.RESERVE_CHARGING_CODE);
|
this.push(msg, pileSn, YKCFrameTypeCode.RESERVE_CHARGING_CODE);
|
||||||
|
|||||||
Reference in New Issue
Block a user