mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
充电桩预约功能
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.jsowell.pile.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CreateReservedDTO {
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 充电桩编号
|
||||
*/
|
||||
private String pileSn;
|
||||
|
||||
/**
|
||||
* 预约开始时间
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 预约结束时间
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 周期性预约的频率,对于单次预约,该字段可以为 NULL。可能的值包括 daily, weekly, monthly
|
||||
*/
|
||||
private String freq;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("memberId", memberId)
|
||||
.append("pileSn", pileSn)
|
||||
.append("startTime", startTime)
|
||||
.append("endTime", endTime)
|
||||
.append("freq", freq)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.jsowell.pile.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PileReservedDTO {
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 预约id
|
||||
*/
|
||||
private String reservedId;
|
||||
|
||||
/**
|
||||
* 状态 (0-停用;1-启用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("memberId", memberId)
|
||||
.append("reservedId", reservedId)
|
||||
.append("status", status)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.jsowell.pile.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jsowell.pile.dto.PileReservedDTO;
|
||||
import com.jsowell.pile.domain.PileReservedInfo;
|
||||
|
||||
public interface PileReservedInfoService {
|
||||
@@ -31,9 +32,9 @@ public interface PileReservedInfoService {
|
||||
|
||||
List<PileReservedInfo> getReservationsByMemberIdAndPileSn(String memberId, String pileSn);
|
||||
|
||||
void activateReservation(int reservationId);
|
||||
void activateReserved(PileReservedDTO dto);
|
||||
|
||||
void deactivateReservation(int reservationId);
|
||||
void deactivateReserved(PileReservedDTO dto);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.PileReservedDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -81,29 +83,36 @@ public class PileReservedInfoServiceImpl implements PileReservedInfoService {
|
||||
|
||||
/**
|
||||
* 启用预约
|
||||
* @param reservationId
|
||||
*/
|
||||
@Override
|
||||
public void activateReservation(int reservationId) {
|
||||
PileReservedInfo pileReservedInfo = pileReservedInfoMapper.selectByPrimaryKey(reservationId);
|
||||
if (pileReservedInfo != null) {
|
||||
pileReservedInfo.setStatus(Constants.ONE);
|
||||
// pileReservedInfoMapper.updateByPrimaryKeySelective(pileReservedInfo);
|
||||
saveReservation(pileReservedInfo);
|
||||
public void activateReserved(PileReservedDTO dto) {
|
||||
PileReservedInfo pileReservedInfo = pileReservedInfoMapper.selectByPrimaryKey(Integer.parseInt(dto.getReservedId()));
|
||||
if (pileReservedInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (!StringUtils.equals(dto.getMemberId(), pileReservedInfo.getMemberId())) {
|
||||
return;
|
||||
}
|
||||
pileReservedInfo.setStatus(Constants.ONE);
|
||||
// 保存之前,校验时间是否重叠
|
||||
saveReservation(pileReservedInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用预约
|
||||
* @param reservationId
|
||||
*/
|
||||
@Override
|
||||
public void deactivateReservation(int reservationId) {
|
||||
PileReservedInfo pileReservedInfo = pileReservedInfoMapper.selectByPrimaryKey(reservationId);
|
||||
if (pileReservedInfo != null) {
|
||||
pileReservedInfo.setStatus(Constants.ZERO);
|
||||
pileReservedInfoMapper.updateByPrimaryKeySelective(pileReservedInfo);
|
||||
public void deactivateReserved(PileReservedDTO dto) {
|
||||
PileReservedInfo pileReservedInfo = pileReservedInfoMapper.selectByPrimaryKey(Integer.parseInt(dto.getReservedId()));
|
||||
if (pileReservedInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (!StringUtils.equals(dto.getMemberId(), pileReservedInfo.getMemberId())) {
|
||||
return;
|
||||
}
|
||||
// 校验通过可以修改预约
|
||||
pileReservedInfo.setStatus(Constants.ZERO);
|
||||
pileReservedInfoMapper.updateByPrimaryKeySelective(pileReservedInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user