mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
update 修改充电桩信息
This commit is contained in:
@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -40,18 +41,43 @@ public class ReservationChargingCommand {
|
||||
private String operation;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
* 预约类型
|
||||
* 0x00:单次0x01:周期
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date reservedStartTime;
|
||||
private String reservationType;
|
||||
|
||||
/**
|
||||
* 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")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date reservedEndTime;
|
||||
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
// 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
|
||||
|
||||
@@ -83,7 +83,7 @@ public interface SettleOrderReportService {
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(SettleOrderReport record);
|
||||
// int insert(SettleOrderReport record);
|
||||
|
||||
int insertOrUpdate(SettleOrderReport record);
|
||||
|
||||
|
||||
@@ -3119,20 +3119,20 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
/**
|
||||
* 异步发送预约充电指令
|
||||
*/
|
||||
if (StringUtils.equals(orderInfo.getStartType(), StartTypeEnum.RESERVED.getValue())) {
|
||||
ReservationChargingCommand command = ReservationChargingCommand.builder()
|
||||
.transactionCode(orderInfo.getTransactionCode())
|
||||
.pileSn(orderInfo.getPileSn())
|
||||
.connectorCode(orderInfo.getConnectorCode())
|
||||
.operation(BytesUtil.bcd2Str(new byte[]{0x01}))
|
||||
.reservedStartTime(orderInfo.getReservedStartTime())
|
||||
.reservedEndTime(orderInfo.getReservedEndTime())
|
||||
.amount(new BigDecimal(Constants.FIVE_HUNDRED))
|
||||
.build();
|
||||
// 发送预约充电指令
|
||||
logger.info("订单:{}支付成功, 发送预约充电指令, command:{}", dto.getOrderCode(), JSON.toJSONString(command));
|
||||
pileRemoteService.reservationCharging(command);
|
||||
}
|
||||
// if (StringUtils.equals(orderInfo.getStartType(), StartTypeEnum.RESERVED.getValue())) {
|
||||
// ReservationChargingCommand command = ReservationChargingCommand.builder()
|
||||
// .transactionCode(orderInfo.getTransactionCode())
|
||||
// .pileSn(orderInfo.getPileSn())
|
||||
// .connectorCode(orderInfo.getConnectorCode())
|
||||
// .operation(BytesUtil.bcd2Str(new byte[]{0x01}))
|
||||
// .reservedStartTime(orderInfo.getReservedStartTime())
|
||||
// .reservedEndTime(orderInfo.getReservedEndTime())
|
||||
// .amount(new BigDecimal(Constants.FIVE_HUNDRED))
|
||||
// .build();
|
||||
// // 发送预约充电指令
|
||||
// logger.info("订单:{}支付成功, 发送预约充电指令, command:{}", dto.getOrderCode(), JSON.toJSONString(command));
|
||||
// pileRemoteService.reservationCharging(command);
|
||||
// }
|
||||
|
||||
if (OrderStatusEnum.STAY_RETROACTIVE_AMOUNT.getValue().equals(orderInfo.getOrderStatus())) {
|
||||
// 如果订单状态是待补缴,表示已经停止充电了,需要补缴费用,补缴完成订单状态改为订单完成,设置结算时间
|
||||
|
||||
@@ -582,28 +582,6 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
||||
// 保存到redis
|
||||
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();
|
||||
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);
|
||||
// 保存之前,校验时间是否重叠
|
||||
saveReservation(pileReservationInfo);
|
||||
int i = saveReservation(pileReservationInfo);
|
||||
if (i > 0) {
|
||||
// TODO 发送指令
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +129,10 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
}
|
||||
// 校验通过可以修改预约
|
||||
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;
|
||||
}
|
||||
|
||||
public void saveReservation(PileReservationInfo reservation) {
|
||||
public int saveReservation(PileReservationInfo reservation) {
|
||||
if (isTimeSlotAvailable(reservation.getMemberId(), reservation.getPileSn(), reservation.getStartTime(), reservation.getEndTime(), reservation.getId())) {
|
||||
this.updateByPrimaryKeySelective(reservation);
|
||||
return this.updateByPrimaryKeySelective(reservation);
|
||||
} else {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_UPDATE_RESERVED_STATUS_REFUSED);
|
||||
}
|
||||
|
||||
@@ -453,10 +453,10 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
||||
return settleOrderReportMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(SettleOrderReport record) {
|
||||
return settleOrderReportMapper.insert(record);
|
||||
}
|
||||
// @Override
|
||||
// public int insert(SettleOrderReport record) {
|
||||
// return settleOrderReportMapper.insert(record);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int insertOrUpdate(SettleOrderReport record) {
|
||||
@@ -471,6 +471,12 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
||||
|
||||
@Override
|
||||
public int insertOrUpdateSelective(SettleOrderReport record) {
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
if (record.getId() == null) {
|
||||
record.setCreateTime(nowDate);
|
||||
} else {
|
||||
record.setUpdateTime(nowDate);
|
||||
}
|
||||
return settleOrderReportMapper.insertOrUpdateSelective(record);
|
||||
}
|
||||
|
||||
@@ -724,19 +730,18 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = Lists.newArrayList(
|
||||
"17.56",
|
||||
"26.13",
|
||||
"11.79",
|
||||
"34.80",
|
||||
"12.72",
|
||||
"18.03",
|
||||
"19.80",
|
||||
"66.76",
|
||||
"15.27",
|
||||
"37.50",
|
||||
"28.45",
|
||||
"24.81",
|
||||
"16.75");
|
||||
"0.06",
|
||||
"0.06",
|
||||
"0.09",
|
||||
"0.06",
|
||||
"0.05",
|
||||
"0.09",
|
||||
"0.02",
|
||||
"0.18",
|
||||
"0.10",
|
||||
"0.03",
|
||||
"0.06",
|
||||
"0.11");
|
||||
|
||||
// 总手续费
|
||||
BigDecimal totalFeeAmount = BigDecimal.ZERO;
|
||||
@@ -744,11 +749,11 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
||||
|
||||
for (String s : list) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -756,14 +761,14 @@ public class SettleOrderReportServiceImpl implements SettleOrderReportService {
|
||||
System.out.println("总交易金额" + totalTradeAmount);
|
||||
|
||||
|
||||
BigDecimal settleAmount = new BigDecimal("330.37");
|
||||
// 计算手续费 = 结算金额 * 0.55%
|
||||
BigDecimal fee = settleAmount.multiply(new BigDecimal(Constants.FEE_RATES));
|
||||
SplitSettleAmountVO resultVO = new SplitSettleAmountVO();
|
||||
resultVO.setSettleAmount(settleAmount);
|
||||
resultVO.setFeeAmount(fee);
|
||||
resultVO.setTradeAmount(settleAmount.subtract(fee));
|
||||
System.out.println(JSON.toJSONString(resultVO));
|
||||
// BigDecimal settleAmount = new BigDecimal("330.37");
|
||||
// // 计算手续费 = 结算金额 * 0.55%
|
||||
// BigDecimal fee = settleAmount.multiply(new BigDecimal(Constants.FEE_RATES));
|
||||
// SplitSettleAmountVO resultVO = new SplitSettleAmountVO();
|
||||
// resultVO.setSettleAmount(settleAmount);
|
||||
// resultVO.setFeeAmount(fee);
|
||||
// resultVO.setTradeAmount(settleAmount.subtract(fee));
|
||||
// System.out.println(JSON.toJSONString(resultVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.aspectj.weaver.ast.Var;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -499,13 +501,39 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
String operation = command.getOperation();
|
||||
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();
|
||||
byte[] reservedStartTimeByteArr = Cp56Time2aUtil.date2Hbyte(reservedStartTime);
|
||||
LocalTime reservedStartTime = command.getReservedStartTime();
|
||||
byte[] reservedStartTimeByteArr = BytesUtil.createByteArray((byte) reservedStartTime.getHour(), (byte) reservedStartTime.getMinute());
|
||||
|
||||
// 结束时间
|
||||
Date reservedEndTime = command.getReservedEndTime();
|
||||
byte[] reservedEndTimeByteArr = Cp56Time2aUtil.date2Hbyte(reservedEndTime);
|
||||
LocalTime reservedEndTime = command.getReservedEndTime();
|
||||
byte[] reservedEndTimeByteArr = BytesUtil.createByteArray((byte) reservedEndTime.getHour(), (byte) reservedEndTime.getMinute());
|
||||
|
||||
// 启动金额
|
||||
BigDecimal amount = command.getAmount();
|
||||
@@ -513,6 +541,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
|
||||
// 拼装msg信息
|
||||
byte[] msg = Bytes.concat(transactionCodeArr, pileSnByteArr, connectorCodeByteArr, operateByteArr,
|
||||
reservationTypeByteArr, vin1ByteArr, vin2ByteArr, vin3ByteArr,
|
||||
reservedStartTimeByteArr, reservedEndTimeByteArr, amountByteArr);
|
||||
|
||||
this.push(msg, pileSn, YKCFrameTypeCode.RESERVE_CHARGING_CODE);
|
||||
|
||||
Reference in New Issue
Block a user