mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 预约充电
This commit is contained in:
@@ -14,6 +14,7 @@ import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import com.jsowell.pile.service.PileMerchantInfoService;
|
||||
import com.jsowell.pile.service.PileReservationInfoService;
|
||||
import com.jsowell.pile.vo.PileReservationInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.PersonPileConnectorSumInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.PersonPileRealTimeVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.PersonalPileInfoVO;
|
||||
@@ -429,5 +430,27 @@ public class PersonPileController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据充电桩查询预约状态
|
||||
* http://localhost:8080/uniapp/personalPile/queryReservationInfo
|
||||
*/
|
||||
@PostMapping("/queryReservationInfo")
|
||||
public RestApiResponse<?> queryReservationInfo(HttpServletRequest request, @RequestBody PileReservationDTO dto) {
|
||||
// logger.info("修改预约充电状态params:{}", dto);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PileReservationInfoVO vo = pileReservationInfoService.queryReservationInfo(dto);
|
||||
response = new RestApiResponse<>(vo);
|
||||
} catch (BusinessException e) {
|
||||
logger.error("根据充电桩查询预约状态error, params:{}", dto, e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("根据充电桩查询预约状态error, params:{}", dto, e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_QUERY_RESERVATION_STATUS_ERROR);
|
||||
}
|
||||
logger.info("根据充电桩查询预约状态params:{}, result:{}", dto, response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.jsowell.pile.util.SnUtils;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.transaction.dto.PileTransactionDTO;
|
||||
import com.jsowell.pile.transaction.service.TransactionService;
|
||||
import com.jsowell.pile.vo.PileReservedVO;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import com.jsowell.pile.vo.base.PileInfoVO;
|
||||
@@ -40,7 +39,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Time;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -399,7 +397,6 @@ public class PileService {
|
||||
if (basicInfo == null){
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_NO_CHARGING_ORDER_ERROR);
|
||||
}
|
||||
String orderCode = basicInfo.getOrderCode();
|
||||
// 根据订单号从redis中获取实时数据信息(默认时间倒叙排列,所以取第一条)
|
||||
List<RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(basicInfo.getTransactionCode());
|
||||
if (CollectionUtils.isEmpty(chargingRealTimeData)) {
|
||||
@@ -414,6 +411,8 @@ public class PileService {
|
||||
.instantCurrent(realTimeMonitorData.getOutputCurrent())
|
||||
.instantVoltage(realTimeMonitorData.getOutputVoltage())
|
||||
.instantPower(realTimeMonitorData.getOutputPower())
|
||||
.status(orderBasicInfo.getOrderStatus())
|
||||
.soc(realTimeMonitorData.getSOC())
|
||||
.build();
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -181,6 +181,8 @@ public enum ReturnCodeEnum {
|
||||
|
||||
CODE_PERSON_PILE_STOP_CHARGING_ERROR("00400018", "个人桩停止充电异常"),
|
||||
|
||||
CODE_QUERY_RESERVATION_STATUS_ERROR("00400019", "根据充电桩查询预约状态异常"),
|
||||
|
||||
/* 个人桩 end */
|
||||
|
||||
CODE_THIS_CARNO_HAS_BEEN_BINDING("00500001", "当前车牌号已经绑定,请检查!"),
|
||||
|
||||
@@ -28,6 +28,11 @@ public class PileReservationDTO {
|
||||
*/
|
||||
private String pileSn;
|
||||
|
||||
/**
|
||||
* 充电桩枪口编号
|
||||
*/
|
||||
private String pileConnectorCode;
|
||||
|
||||
/**
|
||||
* 开始时间 hh:mm:ss
|
||||
*/
|
||||
|
||||
@@ -34,4 +34,6 @@ public interface PileReservationInfoMapper {
|
||||
List<PileReservationInfo> findByMemberIdAndPileSn(@Param("memberId") String memberId, @Param("pileSn") String pileSn);
|
||||
|
||||
PileReservationInfo selectActiveReservationByPileConnectorCode(String pileConnectorCode);
|
||||
|
||||
PileReservationInfo selectByPileConnectorCode(String pileConnectorCode);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.jsowell.pile.dto.CreateReservedDTO;
|
||||
import com.jsowell.pile.dto.PersonPileStopChargingDTO;
|
||||
import com.jsowell.pile.dto.PileReservationDTO;
|
||||
import com.jsowell.pile.domain.PileReservationInfo;
|
||||
import com.jsowell.pile.vo.PileReservationInfoVO;
|
||||
|
||||
public interface PileReservationInfoService {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
@@ -68,5 +69,7 @@ public interface PileReservationInfoService {
|
||||
void updateReservation(PileReservationDTO dto);
|
||||
|
||||
void personPileStopCharging(PersonPileStopChargingDTO dto);
|
||||
|
||||
PileReservationInfoVO queryReservationInfo(PileReservationDTO dto);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ 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.vo.PileReservedVO;
|
||||
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;
|
||||
@@ -26,6 +26,7 @@ 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;
|
||||
@@ -69,6 +70,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);
|
||||
}
|
||||
|
||||
@@ -112,6 +118,10 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
return pileReservationInfoMapper.findByMemberIdAndPileSn(memberId, pileSn);
|
||||
}
|
||||
|
||||
public PileReservationInfo selectByPileConnectorCode(String pileConnectorCode) {
|
||||
return pileReservationInfoMapper.selectByPileConnectorCode(pileConnectorCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用预约/开启预约/启动预约
|
||||
*/
|
||||
@@ -300,11 +310,17 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
|
||||
@Override
|
||||
public int createReservation(CreateReservedDTO dto) {
|
||||
PileReservationInfo reservedInfo = new PileReservationInfo();
|
||||
reservedInfo.setMemberId(dto.getMemberId());
|
||||
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.ZERO); // 默认未生效
|
||||
reservedInfo.setStatus(Constants.ONE); // 默认生效
|
||||
// reservedInfo.setStartTime(DateUtils.parseDate(dto.getStartTime()));
|
||||
reservedInfo.setStartTime(Time.valueOf(dto.getStartTime()));
|
||||
// reservedInfo.setEndTime(DateUtils.parseDate(dto.getEndTime()));
|
||||
@@ -325,8 +341,8 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
reservedInfo.setReservationType("recurring");
|
||||
reservedInfo.setFreq("daily");
|
||||
|
||||
reservedInfo.setCreateBy(dto.getMemberId());
|
||||
this.insertSelective(reservedInfo);
|
||||
|
||||
this.insertOrUpdateSelective(reservedInfo);
|
||||
return reservedInfo.getId();
|
||||
}
|
||||
|
||||
@@ -344,15 +360,15 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
pageResponse.setPages(pageInfo.getPages());
|
||||
pageResponse.setTotal(pageInfo.getTotal());
|
||||
|
||||
List<PileReservedVO> resultList = Lists.newArrayList();
|
||||
List<PileReservationInfoVO> resultList = Lists.newArrayList();
|
||||
for (PileReservationInfo reservedInfo : pageInfo.getList()) {
|
||||
resultList.add(
|
||||
PileReservedVO.builder()
|
||||
.reservedId(reservedInfo.getId() + "")
|
||||
PileReservationInfoVO.builder()
|
||||
// .reservationId(reservedInfo.getId() + "")
|
||||
.pileSn(reservedInfo.getPileSn())
|
||||
.startTime(reservedInfo.getStartTime().toString())
|
||||
.endTime(reservedInfo.getEndTime().toString())
|
||||
.freq(reservedInfo.getFreq())
|
||||
// .freq(reservedInfo.getFreq())
|
||||
.status(reservedInfo.getStatus())
|
||||
.build()
|
||||
);
|
||||
@@ -399,6 +415,7 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
if (StringUtils.isNotBlank(dto.getStatus())) {
|
||||
pileReservationInfo.setStatus(dto.getStatus());
|
||||
}
|
||||
pileReservationInfo.setUpdateBy(dto.getMemberId());
|
||||
this.insertOrUpdateSelective(pileReservationInfo);
|
||||
}
|
||||
|
||||
@@ -414,5 +431,20 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PileReservationInfoVO queryReservationInfo(PileReservationDTO dto) {
|
||||
PileReservationInfo pileReservationInfo = pileReservationInfoMapper.selectByPileConnectorCode(dto.getPileConnectorCode());
|
||||
PileReservationInfoVO build = PileReservationInfoVO.builder()
|
||||
// .reservationId(pileReservationInfo.getId() + "")
|
||||
.pileSn(pileReservationInfo.getPileSn())
|
||||
.pileConnectorCode(pileReservationInfo.getPileConnectorCode())
|
||||
.startTime(pileReservationInfo.getStartTime().toString())
|
||||
.endTime(pileReservationInfo.getEndTime().toString())
|
||||
// .freq(pileReservationInfo.getFreq())
|
||||
.status(pileReservationInfo.getStatus())
|
||||
.build();
|
||||
return build;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,19 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class PileReservedVO {
|
||||
private String reservedId;
|
||||
public class PileReservationInfoVO {
|
||||
// private String reservationId;
|
||||
|
||||
/**
|
||||
* 充电桩编号
|
||||
*/
|
||||
private String pileSn;
|
||||
|
||||
/**
|
||||
* 充电桩枪口编号
|
||||
*/
|
||||
private String pileConnectorCode;
|
||||
|
||||
/**
|
||||
* 预约开始时间
|
||||
*/
|
||||
@@ -28,7 +33,7 @@ public class PileReservedVO {
|
||||
/**
|
||||
* 周期性预约的频率,对于单次预约,该字段可以为 NULL。可能的值包括 daily, weekly, monthly
|
||||
*/
|
||||
private String freq;
|
||||
// private String freq;
|
||||
|
||||
/**
|
||||
* 状态(0-未生效;1-生效)
|
||||
@@ -45,4 +45,14 @@ public class PersonPileRealTimeVO {
|
||||
* 实时功率
|
||||
*/
|
||||
private String instantPower;
|
||||
|
||||
/**
|
||||
* 枪口状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* soc
|
||||
*/
|
||||
private String soc;
|
||||
}
|
||||
|
||||
@@ -616,4 +616,12 @@
|
||||
and status = '1'
|
||||
and pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="selectByPileConnectorCode" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from pile_reservation_info
|
||||
where del_flag = '0'
|
||||
and pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user