mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-29 15:39:59 +08:00
Merge branch 'dev' of http://192.168.2.46:8099/jsowell/jsowell-charger-web into dev
This commit is contained in:
@@ -282,6 +282,26 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
orderPileOccupyMapper.updateByPrimaryKeySelective(orderPileOccupy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int retryCalculateOccupyPileOrderAmount(String occupyCode) {
|
||||
OrderPileOccupy orderPileOccupy = queryByOccupyCode(occupyCode);
|
||||
// 计算金额
|
||||
BigDecimal orderAmount = calculateOccupyPileOrderAmount(orderPileOccupy);
|
||||
|
||||
if (orderAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 需要支付金额,订单挂起
|
||||
orderPileOccupy.setStatus(Constants.TWO); // 2-订单挂起
|
||||
} else {
|
||||
// 订单金额为0
|
||||
orderPileOccupy.setPayStatus(Constants.TWO); // 2-无需支付
|
||||
orderPileOccupy.setStatus(Constants.ONE); // 1-订单完成
|
||||
}
|
||||
orderPileOccupy.setOrderAmount(orderAmount);
|
||||
// 更新数据库
|
||||
int i = orderPileOccupyMapper.updateByPrimaryKeySelective(orderPileOccupy);
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算占桩订单金额
|
||||
* calculateTheAmountOfTheOccupancyOrder
|
||||
@@ -325,8 +345,8 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
dto.setStartTime(DateUtils.formatDateTime(startTime));
|
||||
dto.setEndTime(DateUtils.formatDateTime(endTime));
|
||||
List<OrderListVO> orderListVOS = orderBasicInfoService.queryOrderByOccupyTime(dto);
|
||||
log.info("查询会员在占用时段内有没有充电订单, 占桩订单编号:{}, 占桩开始时间:{}, 占桩结束时间:{}, result:{}",
|
||||
occupyCode, DateUtils.formatDateTime(startTime), DateUtils.formatDateTime(endTime), JSON.toJSONString(orderListVOS));
|
||||
log.info("查询会员在占用时段内有没有充电订单, 占桩订单编号:{}, memberId:{}, stationId:{}, 占桩开始时间:{}, 占桩结束时间:{}, result:{}",
|
||||
occupyCode, orderPileOccupy.getMemberId(), orderPileOccupy.getStationId(), DateUtils.formatDateTime(startTime), DateUtils.formatDateTime(endTime), JSON.toJSONString(orderListVOS));
|
||||
/*
|
||||
计算充电时长
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -82,8 +83,7 @@ public class PersonalChargingRecordServiceImpl implements PersonalChargingRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理个人桩充电记录
|
||||
*
|
||||
* 收到交易记录时, 处理个人桩充电记录
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
@@ -133,4 +133,48 @@ public class PersonalChargingRecordServiceImpl implements PersonalChargingRecord
|
||||
personalChargingRecordMapper.insertOrUpdateSelective(chargingRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键启动时, 处理个人桩充电记录
|
||||
* @param orderBasicInfo
|
||||
*/
|
||||
@Override
|
||||
public void processPersonalChargingRecord(OrderBasicInfo orderBasicInfo) {
|
||||
// 根据交易流水号查询,如果数据库没有就入库
|
||||
PersonalChargingRecord chargingRecord = new PersonalChargingRecord();
|
||||
|
||||
// 处理数据
|
||||
chargingRecord.setTransactionCode(orderBasicInfo.getTransactionCode());
|
||||
chargingRecord.setStatus(Constants.ONE);
|
||||
chargingRecord.setMemberId(orderBasicInfo.getMemberId());
|
||||
chargingRecord.setStationId(orderBasicInfo.getStationId());
|
||||
chargingRecord.setMerchantId(orderBasicInfo.getMerchantId());
|
||||
chargingRecord.setPileSn(orderBasicInfo.getPileSn());
|
||||
chargingRecord.setConnectorCode(orderBasicInfo.getConnectorCode());
|
||||
chargingRecord.setPileConnectorCode(orderBasicInfo.getPileConnectorCode());
|
||||
chargingRecord.setLogicCard(orderBasicInfo.getLogicCard());
|
||||
chargingRecord.setVinCode(orderBasicInfo.getVinCode());
|
||||
chargingRecord.setStartMode(orderBasicInfo.getStartMode());
|
||||
chargingRecord.setPlateNumber(orderBasicInfo.getPlateNumber());
|
||||
chargingRecord.setChargeStartTime(orderBasicInfo.getChargeStartTime());
|
||||
chargingRecord.setChargeEndTime(orderBasicInfo.getChargeEndTime());
|
||||
chargingRecord.setStartType(orderBasicInfo.getStartType());
|
||||
chargingRecord.setReservationStartTime(orderBasicInfo.getReservedStartTime());
|
||||
chargingRecord.setReservationEndTime(orderBasicInfo.getReservedEndTime());
|
||||
chargingRecord.setStartSoc(orderBasicInfo.getStartSoc());
|
||||
chargingRecord.setEndSoc(null);
|
||||
// BigDecimal sharpUsedElectricity = new BigDecimal(data.getSharpUsedElectricity());
|
||||
// chargingRecord.setSharpUsedElectricity(sharpUsedElectricity);
|
||||
// BigDecimal peakUsedElectricity = new BigDecimal(data.getPeakUsedElectricity());
|
||||
// chargingRecord.setPeakUsedElectricity(peakUsedElectricity);
|
||||
// BigDecimal flatUsedElectricity = new BigDecimal(data.getFlatUsedElectricity());
|
||||
// chargingRecord.setFlatUsedElectricity(flatUsedElectricity);
|
||||
// BigDecimal valleyUsedElectricity = new BigDecimal(data.getValleyUsedElectricity());
|
||||
// chargingRecord.setValleyUsedElectricity(valleyUsedElectricity);
|
||||
// BigDecimal totalUsedElectricity = sharpUsedElectricity.add(peakUsedElectricity).add(flatUsedElectricity).add(valleyUsedElectricity);
|
||||
// chargingRecord.setTotalUsedElectricity(totalUsedElectricity);
|
||||
// chargingRecord.setReason(data.getStopReasonMsg());
|
||||
// 创建或更新
|
||||
personalChargingRecordMapper.insertOrUpdateSelective(chargingRecord);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.domain.PileConnectorInfo;
|
||||
import com.jsowell.pile.domain.PileModelInfo;
|
||||
import com.jsowell.pile.domain.PileSimInfo;
|
||||
import com.jsowell.pile.dto.IndexQueryDTO;
|
||||
import com.jsowell.pile.dto.QueryPileDTO;
|
||||
import com.jsowell.pile.dto.ReplaceMerchantStationDTO;
|
||||
import com.jsowell.pile.dto.StartPersonPileDTO;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.mapper.PileBasicInfoMapper;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
|
||||
@@ -37,6 +34,7 @@ import com.jsowell.pile.vo.uniapp.customer.GroundLockInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.PersonalPileInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.PileConnectorDetailVO;
|
||||
import com.jsowell.pile.vo.web.*;
|
||||
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
@@ -89,6 +87,9 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
||||
@Autowired
|
||||
private PileReservationInfoService pileReservationInfoService;
|
||||
|
||||
@Autowired
|
||||
private WxAppletRemoteService wxAppletRemoteService;
|
||||
|
||||
/**
|
||||
* 查询设备管理
|
||||
*
|
||||
@@ -1211,4 +1212,13 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
||||
String orderCode = orderLogic.startPersonalPileCharging(dto);
|
||||
return orderCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预约充电启动结果
|
||||
*/
|
||||
@Override
|
||||
public void startupResult(ReservationChargingStartupResult chargingStartupResult) {
|
||||
// 小程序通知
|
||||
wxAppletRemoteService.reservationStartupResultSendMsg();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.PileMemberRelation;
|
||||
import com.jsowell.pile.mapper.PileMemberRelationMapper;
|
||||
import com.jsowell.pile.service.PileConnectorInfoService;
|
||||
@@ -108,10 +110,12 @@ public class PileMemberRelationServiceImpl implements PileMemberRelationService
|
||||
|
||||
@Override
|
||||
public List<PileMemberRelation> selectPileMemberRelationByPileSn(String pileSn) {
|
||||
if (StringUtils.isBlank(pileSn)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
PileMemberRelation pileMemberRelation = new PileMemberRelation();
|
||||
pileMemberRelation.setPileSn(pileSn);
|
||||
return selectPileMemberRelationList(pileMemberRelation);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
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.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.PileMemberRelation;
|
||||
import com.jsowell.pile.domain.ykcCommond.ReservationChargingCommand;
|
||||
import com.jsowell.pile.dto.CreateReservedDTO;
|
||||
import com.jsowell.pile.dto.PersonPileStopChargingDTO;
|
||||
import com.jsowell.pile.dto.PileReservationDTO;
|
||||
import com.jsowell.pile.dto.StartPersonPileDTO;
|
||||
import com.jsowell.pile.service.MemberPlateNumberRelationService;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import com.jsowell.pile.service.PileRemoteService;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.PileReservationInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.MemberPlateNumberVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -20,15 +28,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.jsowell.pile.mapper.PileReservationInfoMapper;
|
||||
import com.jsowell.pile.domain.PileReservationInfo;
|
||||
import com.jsowell.pile.service.PileReservationInfoService;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -46,6 +56,12 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
@Autowired
|
||||
private MemberPlateNumberRelationService memberPlateNumberRelationService;
|
||||
|
||||
@Autowired
|
||||
private PileMemberRelationService pileMemberRelationService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public int deleteByPrimaryKey(Integer id) {
|
||||
return pileReservationInfoMapper.deleteByPrimaryKey(id);
|
||||
@@ -63,6 +79,11 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
|
||||
@Override
|
||||
public int insertOrUpdateSelective(PileReservationInfo record) {
|
||||
if (record.getId() == null) {
|
||||
record.setCreateTime(DateUtils.getNowDate());
|
||||
} else {
|
||||
record.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
return pileReservationInfoMapper.insertOrUpdateSelective(record);
|
||||
}
|
||||
|
||||
@@ -106,24 +127,28 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
return pileReservationInfoMapper.findByMemberIdAndPileSn(memberId, pileSn);
|
||||
}
|
||||
|
||||
public PileReservationInfo selectByPileConnectorCode(String pileConnectorCode) {
|
||||
return pileReservationInfoMapper.selectByPileConnectorCode(pileConnectorCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用预约/开启预约/启动预约
|
||||
*/
|
||||
@Override
|
||||
public void activateReserved(PileReservationDTO dto) {
|
||||
// 查询其他生效中的预约
|
||||
List<PileReservationInfo> infoList = pileReservationInfoMapper.findByMemberIdAndPileSnAndStatus(dto.getMemberId(), dto.getPileSn(), "1");
|
||||
if (CollectionUtils.isNotEmpty(infoList)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_RESERVATION_ALREADY_EXISTS_ERROR);
|
||||
}
|
||||
// List<PileReservationInfo> infoList = pileReservationInfoMapper.findByMemberIdAndPileSnAndStatus(dto.getMemberId(), dto.getPileSn(), "1");
|
||||
// if (CollectionUtils.isNotEmpty(infoList)) {
|
||||
// throw new BusinessException(ReturnCodeEnum.CODE_RESERVATION_ALREADY_EXISTS_ERROR);
|
||||
// }
|
||||
|
||||
PileReservationInfo pileReservationInfo = pileReservationInfoMapper.selectByPrimaryKey(Integer.parseInt(dto.getReservedId()));
|
||||
if (pileReservationInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (!StringUtils.equals(dto.getMemberId(), pileReservationInfo.getMemberId())) {
|
||||
return;
|
||||
}
|
||||
// if (!StringUtils.equals(dto.getMemberId(), pileReservationInfo.getMemberId())) {
|
||||
// return;
|
||||
// }
|
||||
pileReservationInfo.setStatus(Constants.ONE);
|
||||
// 保存之前,校验时间是否重叠
|
||||
int i = saveReservation(pileReservationInfo);
|
||||
@@ -151,6 +176,7 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
.connectorCode(pileReservationInfo.getPileConnectorCode().replace(pileReservationInfo.getPileSn(), ""))
|
||||
.operation("01")
|
||||
.reservationType(type)
|
||||
.verifyIdentity(pileReservationInfo.getVerifyIdentity())
|
||||
.vin1(vinCodes.get(0))
|
||||
.vin2(vinCodes.get(1))
|
||||
.vin3(vinCodes.get(2))
|
||||
@@ -171,9 +197,9 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
if (pileReservationInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (!StringUtils.equals(dto.getMemberId(), pileReservationInfo.getMemberId())) {
|
||||
return;
|
||||
}
|
||||
// if (!StringUtils.equals(dto.getMemberId(), pileReservationInfo.getMemberId())) {
|
||||
// return;
|
||||
// }
|
||||
// 校验通过可以修改预约
|
||||
pileReservationInfo.setStatus(Constants.ZERO);
|
||||
int i = pileReservationInfoMapper.updateByPrimaryKeySelective(pileReservationInfo);
|
||||
@@ -201,6 +227,7 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
.connectorCode(pileReservationInfo.getPileConnectorCode().replace(pileReservationInfo.getPileSn(), ""))
|
||||
.operation("02")
|
||||
.reservationType(type)
|
||||
.verifyIdentity(pileReservationInfo.getVerifyIdentity())
|
||||
.vin1(vinCodes.get(0))
|
||||
.vin2(vinCodes.get(1))
|
||||
.vin3(vinCodes.get(2))
|
||||
@@ -291,5 +318,217 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
pileReservationInfo.setDelFlag(DelFlagEnum.DELETE.getValue());
|
||||
pileReservationInfoMapper.updateByPrimaryKey(pileReservationInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createReservation(CreateReservedDTO dto) {
|
||||
PileReservationInfo reservedInfo = selectByPileConnectorCode(dto.getPileConnectorCode());
|
||||
if (reservedInfo == null) {
|
||||
reservedInfo = new PileReservationInfo();
|
||||
reservedInfo.setCreateBy(dto.getMemberId());
|
||||
} else {
|
||||
reservedInfo.setUpdateBy(dto.getMemberId());
|
||||
}
|
||||
reservedInfo.setMemberId(dto.getMemberId());
|
||||
reservedInfo.setPileSn(dto.getPileSn());
|
||||
reservedInfo.setPileConnectorCode(dto.getPileConnectorCode());
|
||||
reservedInfo.setStatus(Constants.ONE); // 默认生效
|
||||
// reservedInfo.setStartTime(DateUtils.parseDate(dto.getStartTime()));
|
||||
reservedInfo.setStartTime(Time.valueOf(dto.getStartTime()));
|
||||
// reservedInfo.setEndTime(DateUtils.parseDate(dto.getEndTime()));
|
||||
if (StringUtils.isNotBlank(dto.getEndTime())) {
|
||||
reservedInfo.setEndTime(Time.valueOf(dto.getEndTime()));
|
||||
}
|
||||
|
||||
// 2024年7月25日14点36分, 此段代码注释掉, 采用默认设置
|
||||
// if (StringUtils.isNotBlank(dto.getFreq())) {
|
||||
// reservedInfo.setReservationType("recurring");
|
||||
// reservedInfo.setFreq(dto.getFreq());
|
||||
// } else {
|
||||
// reservedInfo.setReservationType("single");
|
||||
// reservedInfo.setFreq(null);
|
||||
// }
|
||||
|
||||
// 默认每天
|
||||
reservedInfo.setReservationType("recurring");
|
||||
reservedInfo.setFreq("daily");
|
||||
|
||||
this.insertOrUpdateSelective(reservedInfo);
|
||||
return reservedInfo.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResponse queryReservationList(PileReservationDTO dto) {
|
||||
int pageNo = dto.getPageNo() == null ? Constants.one : dto.getPageNo();
|
||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||
PageHelper.startPage(pageNo, pageSize);
|
||||
List<PileReservationInfo> list = this.getReservationsByMemberIdAndPileSn(dto.getMemberId(), dto.getPileSn());
|
||||
PageInfo<PileReservationInfo> pageInfo = new PageInfo<>(list);
|
||||
|
||||
PageResponse pageResponse = new PageResponse();
|
||||
pageResponse.setPageNum(pageInfo.getPageNum());
|
||||
pageResponse.setPageSize(pageInfo.getPageSize());
|
||||
pageResponse.setPages(pageInfo.getPages());
|
||||
pageResponse.setTotal(pageInfo.getTotal());
|
||||
|
||||
List<PileReservationInfoVO> resultList = Lists.newArrayList();
|
||||
for (PileReservationInfo reservedInfo : pageInfo.getList()) {
|
||||
resultList.add(
|
||||
PileReservationInfoVO.builder()
|
||||
// .reservationId(reservedInfo.getId() + "")
|
||||
.pileSn(reservedInfo.getPileSn())
|
||||
.startTime(reservedInfo.getStartTime().toString())
|
||||
.endTime(reservedInfo.getEndTime().toString())
|
||||
// .freq(reservedInfo.getFreq())
|
||||
.status(reservedInfo.getStatus())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
pageResponse.setList(resultList);
|
||||
return pageResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改预约状态
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void updateReservationStatus(PileReservationDTO dto) {
|
||||
if (StringUtils.equals(dto.getStatus(), Constants.ZERO)) {
|
||||
// 停用
|
||||
this.deactivateReserved(dto);
|
||||
} else if (StringUtils.equals(dto.getStatus(), Constants.ONE)) {
|
||||
// 启用
|
||||
this.activateReserved(dto);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改预约充电信息
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void updateReservation(PileReservationDTO dto) {
|
||||
PileReservationInfo pileReservationInfo = pileReservationInfoMapper.selectByPrimaryKey(Integer.valueOf(dto.getReservedId()));
|
||||
if (pileReservationInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作
|
||||
* 0x01:启动 0x02:取消 0x03:修改
|
||||
*/
|
||||
String operation = "03";
|
||||
|
||||
if (StringUtils.isNotBlank(dto.getStartTime())) {
|
||||
pileReservationInfo.setStartTime(Time.valueOf(dto.getStartTime()));
|
||||
operation = "03";
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getEndTime())) {
|
||||
pileReservationInfo.setEndTime(Time.valueOf(dto.getEndTime()));
|
||||
operation = "03";
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getStatus())) {
|
||||
pileReservationInfo.setStatus(dto.getStatus());
|
||||
if (StringUtils.equals(dto.getStatus(), Constants.ZERO)) {
|
||||
// 停用
|
||||
operation = "02";
|
||||
} else if (StringUtils.equals(dto.getStatus(), Constants.ONE)) {
|
||||
// 启用
|
||||
operation = "01";
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getVerifyIdentity())) {
|
||||
pileReservationInfo.setVerifyIdentity(dto.getVerifyIdentity());
|
||||
}
|
||||
pileReservationInfo.setUpdateBy(dto.getMemberId());
|
||||
this.insertOrUpdateSelective(pileReservationInfo);
|
||||
|
||||
// 查询会员的绑定vin列表 2024年7月30日11点04分 以当前请求会员的VIN为准
|
||||
List<MemberPlateNumberVO> plateNumberVOList = memberPlateNumberRelationService.selectMemberPlateNumberRelation(dto.getMemberId());
|
||||
List<String> vinCodes = Lists.newArrayList();
|
||||
int count = 0;
|
||||
for (MemberPlateNumberVO vo : plateNumberVOList) {
|
||||
if (count < 3 && StringUtils.isNotBlank(vo.getVinCode())) {
|
||||
vinCodes.add(vo.getVinCode());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
// 如果 vinCodes 的数量少于 3,用 "0" 补足
|
||||
while (vinCodes.size() < 3) {
|
||||
vinCodes.add("");
|
||||
}
|
||||
|
||||
String type = StringUtils.equals(pileReservationInfo.getReservationType(), "single") ? "00" : "01";
|
||||
|
||||
// 发送指令
|
||||
ReservationChargingCommand command = ReservationChargingCommand.builder()
|
||||
.transactionCode(Constants.ILLEGAL_TRANSACTION_CODE)
|
||||
.pileSn(pileReservationInfo.getPileSn())
|
||||
.connectorCode(pileReservationInfo.getPileConnectorCode().replace(pileReservationInfo.getPileSn(), ""))
|
||||
.operation(operation)
|
||||
.reservationType(type)
|
||||
.verifyIdentity(pileReservationInfo.getVerifyIdentity())
|
||||
.vin1(vinCodes.get(0))
|
||||
.vin2(vinCodes.get(1))
|
||||
.vin3(vinCodes.get(2))
|
||||
.reservedStartTime(pileReservationInfo.getStartTime().toLocalTime())
|
||||
.reservedEndTime(pileReservationInfo.getEndTime().toLocalTime())
|
||||
.amount(Constants.WHITELIST_DEFAULT_AMOUNT)
|
||||
.build();
|
||||
pileRemoteService.reservationCharging(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人桩停止充电
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void personPileStopCharging(PersonPileStopChargingDTO dto) {
|
||||
String pileConnectorCode = dto.getPileConnectorCode();
|
||||
String pileSn = StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2);
|
||||
String connectorCode = StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2, pileConnectorCode.length());
|
||||
// 查询个人桩信息
|
||||
List<PileMemberRelation> pileMemberRelations = pileMemberRelationService.selectPileMemberRelationByPileSn(pileSn);
|
||||
Map<String, List<String>> listMap = pileMemberRelations.stream()
|
||||
.collect(Collectors.groupingBy(PileMemberRelation::getType, Collectors.mapping(PileMemberRelation::getMemberId, Collectors.toList())));
|
||||
log.info("个人桩:{}, 使用者信息:{}", pileConnectorCode, JSON.toJSONString(listMap));
|
||||
// 发送请求的用户有没有权限停止充电
|
||||
boolean stopFlag = false;
|
||||
List<String> pileManager = listMap.get("1");
|
||||
List<String> pileUsers = listMap.get("2");
|
||||
|
||||
if (CollectionUtils.isNotEmpty(pileManager) && CollectionUtils.containsAny(pileManager, dto.getMemberId())) {
|
||||
log.info("memberId:() 为管理员");
|
||||
stopFlag = true;
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(pileUsers) && CollectionUtils.containsAny(pileUsers, dto.getMemberId())) {
|
||||
log.info("memberId:() 为用户");
|
||||
stopFlag = true;
|
||||
}
|
||||
|
||||
if (stopFlag) {
|
||||
String pileIsChargingKey = CacheConstants.PILE_IS_CHARGING + pileSn + connectorCode;
|
||||
String redisResult = redisCache.getCacheObject(pileIsChargingKey);
|
||||
// 发送停止充电指令
|
||||
log.info("发送停止指令, pileSn:{}, connectorCode:{}, transactionCode:{}", pileSn, connectorCode, redisResult);
|
||||
pileRemoteService.remoteStopCharging(pileSn, connectorCode, redisResult);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PileReservationInfoVO queryReservationInfo(PileReservationDTO dto) {
|
||||
PileReservationInfo pileReservationInfo = pileReservationInfoMapper.selectByPileConnectorCode(dto.getPileConnectorCode());
|
||||
PileReservationInfoVO build = PileReservationInfoVO.builder()
|
||||
.reservedId(pileReservationInfo.getId() + "")
|
||||
.pileSn(pileReservationInfo.getPileSn())
|
||||
.pileConnectorCode(pileReservationInfo.getPileConnectorCode())
|
||||
.startTime(pileReservationInfo.getStartTime().toString())
|
||||
.endTime(pileReservationInfo.getEndTime().toString())
|
||||
.verifyIdentity(pileReservationInfo.getVerifyIdentity())
|
||||
// .freq(pileReservationInfo.getFreq())
|
||||
.status(pileReservationInfo.getStatus())
|
||||
.build();
|
||||
return build;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ 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;
|
||||
|
||||
@@ -59,7 +58,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_RESTART_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_CONTROL_START_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_STOP_CHARGING_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVE_CHARGING_CODE.getBytes())
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_CODE.getBytes())
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -183,7 +182,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送停止ch
|
||||
* 发送停止充电
|
||||
*
|
||||
* @param command
|
||||
*/
|
||||
@@ -254,7 +253,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
|
||||
// push消息
|
||||
boolean result = this.push(msg, pileSn, YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_CODE);
|
||||
log.info("=====平台下发指令===== pileSn:{}, 下发二维码,地址为:{}", pileSn, qrCodePrefix);
|
||||
log.info("【=====平台下发指令=====】 pileSn:{}, 下发二维码,地址为:{}", pileSn, qrCodePrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,7 +329,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
|
||||
// 额定功率
|
||||
String ratedPower = pileModelInfoVO.getRatedPower();
|
||||
int i = Integer.parseInt(ratedPower);
|
||||
// int i = Integer.parseInt(ratedPower);
|
||||
|
||||
// byte[] ratedPowerByteArr = Base64.getDecoder().decode(ratedPower);
|
||||
byte[] ratedPowerByteArr = BytesUtil.ensureLength(Constants.zeroByteArray, 2);
|
||||
@@ -506,6 +505,10 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
String reservationType = command.getReservationType();
|
||||
byte[] reservationTypeByteArr = BytesUtil.str2Bcd(reservationType);
|
||||
|
||||
// 身份验证
|
||||
String verifyIdentity = command.getVerifyIdentity();
|
||||
byte[] verifyIdentityByteArr = BytesUtil.str2Bcd(verifyIdentity);
|
||||
|
||||
// VIN1
|
||||
String vin1 = command.getVin1();
|
||||
byte[] vin1ByteArr = BytesUtil.str2Asc(vin1);
|
||||
@@ -533,12 +536,12 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
|
||||
// 拼装msg信息
|
||||
byte[] msg = Bytes.concat(transactionCodeArr, pileSnByteArr, connectorCodeByteArr, operateByteArr,
|
||||
reservationTypeByteArr, vin1ByteArr, vin2ByteArr, vin3ByteArr,
|
||||
reservationTypeByteArr, verifyIdentityByteArr, vin1ByteArr, vin2ByteArr, vin3ByteArr,
|
||||
reservedStartTimeByteArr, reservedEndTimeByteArr, amountByteArr);
|
||||
|
||||
this.push(msg, pileSn, YKCFrameTypeCode.RESERVE_CHARGING_CODE);
|
||||
this.push(msg, pileSn, YKCFrameTypeCode.RESERVATION_CHARGING_CODE);
|
||||
|
||||
log.info("=====平台下发指令=====: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
|
||||
transactionCode, pileSn, connectorCode, operation, DateUtils.formatDateTime(reservedStartTime), DateUtils.formatDateTime(reservedEndTime), amount);
|
||||
log.info("【=====平台下发指令=====】: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
|
||||
transactionCode, pileSn, connectorCode, operation, verifyIdentity, DateUtils.formatDateTime(reservedStartTime), DateUtils.formatDateTime(reservedEndTime), amount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user