mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-17 05:39:50 +08:00
预约充电
This commit is contained in:
@@ -89,7 +89,7 @@ public class PileService {
|
|||||||
private PileRemoteService pileRemoteService;
|
private PileRemoteService pileRemoteService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileReservedInfoService pileReservedInfoService;
|
private PileReservationInfoService pileReservationInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备信息
|
* 查询设备信息
|
||||||
@@ -564,15 +564,15 @@ public class PileService {
|
|||||||
public void updateReservedStatus(PileReservedDTO dto) {
|
public void updateReservedStatus(PileReservedDTO dto) {
|
||||||
if (StringUtils.equals(dto.getStatus(), Constants.ZERO)) {
|
if (StringUtils.equals(dto.getStatus(), Constants.ZERO)) {
|
||||||
// 停用
|
// 停用
|
||||||
pileReservedInfoService.deactivateReserved(dto);
|
pileReservationInfoService.deactivateReserved(dto);
|
||||||
} else if (StringUtils.equals(dto.getStatus(), Constants.ONE)) {
|
} else if (StringUtils.equals(dto.getStatus(), Constants.ONE)) {
|
||||||
// 启用
|
// 启用
|
||||||
pileReservedInfoService.activateReserved(dto);
|
pileReservationInfoService.activateReserved(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int createReserved(CreateReservedDTO dto) {
|
public int createReserved(CreateReservedDTO dto) {
|
||||||
PileReservedInfo reservedInfo = new PileReservedInfo();
|
PileReservationInfo reservedInfo = new PileReservationInfo();
|
||||||
reservedInfo.setMemberId(dto.getMemberId());
|
reservedInfo.setMemberId(dto.getMemberId());
|
||||||
reservedInfo.setPileSn(dto.getPileSn());
|
reservedInfo.setPileSn(dto.getPileSn());
|
||||||
reservedInfo.setPileConnectorCode(dto.getPileConnectorCode());
|
reservedInfo.setPileConnectorCode(dto.getPileConnectorCode());
|
||||||
@@ -589,7 +589,7 @@ public class PileService {
|
|||||||
reservedInfo.setFreq(null);
|
reservedInfo.setFreq(null);
|
||||||
}
|
}
|
||||||
reservedInfo.setCreateBy(dto.getMemberId());
|
reservedInfo.setCreateBy(dto.getMemberId());
|
||||||
pileReservedInfoService.insertSelective(reservedInfo);
|
pileReservationInfoService.insertSelective(reservedInfo);
|
||||||
return reservedInfo.getId();
|
return reservedInfo.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,8 +597,8 @@ public class PileService {
|
|||||||
int pageNo = dto.getPageNo() == null ? Constants.one : dto.getPageNo();
|
int pageNo = dto.getPageNo() == null ? Constants.one : dto.getPageNo();
|
||||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||||
PageHelper.startPage(pageNo, pageSize);
|
PageHelper.startPage(pageNo, pageSize);
|
||||||
List<PileReservedInfo> list = pileReservedInfoService.getReservationsByMemberIdAndPileSn(dto.getMemberId(), dto.getPileSn());
|
List<PileReservationInfo> list = pileReservationInfoService.getReservationsByMemberIdAndPileSn(dto.getMemberId(), dto.getPileSn());
|
||||||
PageInfo<PileReservedInfo> pageInfo = new PageInfo<>(list);
|
PageInfo<PileReservationInfo> pageInfo = new PageInfo<>(list);
|
||||||
|
|
||||||
PageResponse pageResponse = new PageResponse();
|
PageResponse pageResponse = new PageResponse();
|
||||||
pageResponse.setPageNum(pageInfo.getPageNum());
|
pageResponse.setPageNum(pageInfo.getPageNum());
|
||||||
@@ -607,7 +607,7 @@ public class PileService {
|
|||||||
pageResponse.setTotal(pageInfo.getTotal());
|
pageResponse.setTotal(pageInfo.getTotal());
|
||||||
|
|
||||||
List<PileReservedVO> resultList = Lists.newArrayList();
|
List<PileReservedVO> resultList = Lists.newArrayList();
|
||||||
for (PileReservedInfo reservedInfo : pageInfo.getList()) {
|
for (PileReservationInfo reservedInfo : pageInfo.getList()) {
|
||||||
resultList.add(
|
resultList.add(
|
||||||
PileReservedVO.builder()
|
PileReservedVO.builder()
|
||||||
.reservedId(reservedInfo.getId() + "")
|
.reservedId(reservedInfo.getId() + "")
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import lombok.experimental.SuperBuilder;
|
|||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class PileReservedInfo {
|
public class PileReservationInfo {
|
||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.jsowell.pile.mapper;
|
||||||
|
|
||||||
|
import com.jsowell.pile.domain.PileReservationInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
public interface PileReservationInfoMapper {
|
||||||
|
int deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
int insert(PileReservationInfo record);
|
||||||
|
|
||||||
|
int insertOrUpdate(PileReservationInfo record);
|
||||||
|
|
||||||
|
int insertOrUpdateSelective(PileReservationInfo record);
|
||||||
|
|
||||||
|
int insertSelective(PileReservationInfo record);
|
||||||
|
|
||||||
|
PileReservationInfo selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
int updateByPrimaryKeySelective(PileReservationInfo record);
|
||||||
|
|
||||||
|
int updateByPrimaryKey(PileReservationInfo record);
|
||||||
|
|
||||||
|
int updateBatch(List<PileReservationInfo> list);
|
||||||
|
|
||||||
|
int updateBatchSelective(List<PileReservationInfo> list);
|
||||||
|
|
||||||
|
int batchInsert(@Param("list") List<PileReservationInfo> list);
|
||||||
|
|
||||||
|
List<PileReservationInfo> findByMemberIdAndPileSnAndStatus(@Param("memberId") String memberId, @Param("pileSn") String pileSn, @Param("status") String status);
|
||||||
|
|
||||||
|
List<PileReservationInfo> findByMemberIdAndPileSn(@Param("memberId") String memberId, @Param("pileSn") String pileSn);
|
||||||
|
}
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package com.jsowell.pile.mapper;
|
|
||||||
|
|
||||||
import com.jsowell.pile.domain.PileReservedInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
public interface PileReservedInfoMapper {
|
|
||||||
int deleteByPrimaryKey(Integer id);
|
|
||||||
|
|
||||||
int insert(PileReservedInfo record);
|
|
||||||
|
|
||||||
int insertOrUpdate(PileReservedInfo record);
|
|
||||||
|
|
||||||
int insertOrUpdateSelective(PileReservedInfo record);
|
|
||||||
|
|
||||||
int insertSelective(PileReservedInfo record);
|
|
||||||
|
|
||||||
PileReservedInfo selectByPrimaryKey(Integer id);
|
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(PileReservedInfo record);
|
|
||||||
|
|
||||||
int updateByPrimaryKey(PileReservedInfo record);
|
|
||||||
|
|
||||||
int updateBatch(List<PileReservedInfo> list);
|
|
||||||
|
|
||||||
int updateBatchSelective(List<PileReservedInfo> list);
|
|
||||||
|
|
||||||
int batchInsert(@Param("list") List<PileReservedInfo> list);
|
|
||||||
|
|
||||||
List<PileReservedInfo> findByMemberIdAndPileSnAndStatus(@Param("memberId") String memberId, @Param("pileSn") String pileSn, @Param("status") String status);
|
|
||||||
|
|
||||||
List<PileReservedInfo> findByMemberIdAndPileSn(@Param("memberId") String memberId, @Param("pileSn") String pileSn);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.jsowell.pile.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jsowell.pile.dto.PileReservedDTO;
|
||||||
|
import com.jsowell.pile.domain.PileReservationInfo;
|
||||||
|
|
||||||
|
public interface PileReservationInfoService {
|
||||||
|
int deleteByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
int insert(PileReservationInfo record);
|
||||||
|
|
||||||
|
int insertOrUpdate(PileReservationInfo record);
|
||||||
|
|
||||||
|
int insertOrUpdateSelective(PileReservationInfo record);
|
||||||
|
|
||||||
|
int insertSelective(PileReservationInfo record);
|
||||||
|
|
||||||
|
PileReservationInfo selectByPrimaryKey(Integer id);
|
||||||
|
|
||||||
|
int updateByPrimaryKeySelective(PileReservationInfo record);
|
||||||
|
|
||||||
|
int updateByPrimaryKey(PileReservationInfo record);
|
||||||
|
|
||||||
|
int updateBatch(List<PileReservationInfo> list);
|
||||||
|
|
||||||
|
int batchInsert(List<PileReservationInfo> list);
|
||||||
|
|
||||||
|
int updateBatchSelective(List<PileReservationInfo> list);
|
||||||
|
|
||||||
|
List<PileReservationInfo> getReservationsByMemberIdAndPileSn(String memberId, String pileSn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动预约
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
void activateReserved(PileReservedDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭预约
|
||||||
|
* @param dto
|
||||||
|
*/
|
||||||
|
void deactivateReserved(PileReservedDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据充电枪口编号发送预约指令
|
||||||
|
* @param pileConnectorCode
|
||||||
|
*/
|
||||||
|
void pushReservedByPileConnectorCode(String pileConnectorCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拔枪时,根据充电桩枪口编号关闭仅一次的预约
|
||||||
|
* @param pileConnectorCode
|
||||||
|
*/
|
||||||
|
void cancelOneTimeReservation(String pileConnectorCode);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.jsowell.pile.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.jsowell.pile.dto.PileReservedDTO;
|
|
||||||
import com.jsowell.pile.domain.PileReservedInfo;
|
|
||||||
|
|
||||||
public interface PileReservedInfoService {
|
|
||||||
|
|
||||||
|
|
||||||
int deleteByPrimaryKey(Integer id);
|
|
||||||
|
|
||||||
int insert(PileReservedInfo record);
|
|
||||||
|
|
||||||
int insertOrUpdate(PileReservedInfo record);
|
|
||||||
|
|
||||||
int insertOrUpdateSelective(PileReservedInfo record);
|
|
||||||
|
|
||||||
int insertSelective(PileReservedInfo record);
|
|
||||||
|
|
||||||
PileReservedInfo selectByPrimaryKey(Integer id);
|
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(PileReservedInfo record);
|
|
||||||
|
|
||||||
int updateByPrimaryKey(PileReservedInfo record);
|
|
||||||
|
|
||||||
int updateBatch(List<PileReservedInfo> list);
|
|
||||||
|
|
||||||
int batchInsert(List<PileReservedInfo> list);
|
|
||||||
|
|
||||||
int updateBatchSelective(List<PileReservedInfo> list);
|
|
||||||
|
|
||||||
List<PileReservedInfo> getReservationsByMemberIdAndPileSn(String memberId, String pileSn);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启动预约
|
|
||||||
* @param dto
|
|
||||||
*/
|
|
||||||
void activateReserved(PileReservedDTO dto);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关闭预约
|
|
||||||
* @param dto
|
|
||||||
*/
|
|
||||||
void deactivateReserved(PileReservedDTO dto);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据充电枪口编号发送预约指令
|
|
||||||
* @param pileConnectorCode
|
|
||||||
*/
|
|
||||||
void pushReservedByPileConnectorCode(String pileConnectorCode);
|
|
||||||
|
|
||||||
void cancelOneTimeReservation(String pileConnectorCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -25,8 +25,6 @@ import com.jsowell.pile.dto.IndexQueryDTO;
|
|||||||
import com.jsowell.pile.dto.QueryPileDTO;
|
import com.jsowell.pile.dto.QueryPileDTO;
|
||||||
import com.jsowell.pile.dto.ReplaceMerchantStationDTO;
|
import com.jsowell.pile.dto.ReplaceMerchantStationDTO;
|
||||||
import com.jsowell.pile.mapper.PileBasicInfoMapper;
|
import com.jsowell.pile.mapper.PileBasicInfoMapper;
|
||||||
import com.jsowell.pile.mapper.PileMerchantInfoMapper;
|
|
||||||
import com.jsowell.pile.mapper.PileSimInfoMapper;
|
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.thirdparty.ConnectorInfo;
|
import com.jsowell.pile.thirdparty.ConnectorInfo;
|
||||||
import com.jsowell.pile.thirdparty.EquipmentInfo;
|
import com.jsowell.pile.thirdparty.EquipmentInfo;
|
||||||
@@ -89,7 +87,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
|||||||
private String BASE_URL_PREFIX;
|
private String BASE_URL_PREFIX;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileReservedInfoService pileReservedInfoService;
|
private PileReservationInfoService pileReservationInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备管理
|
* 查询设备管理
|
||||||
@@ -465,7 +463,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
|||||||
@Override
|
@Override
|
||||||
public void firstPlugInCharger(String pileConnectorCode) {
|
public void firstPlugInCharger(String pileConnectorCode) {
|
||||||
// 下发预约指令
|
// 下发预约指令
|
||||||
pileReservedInfoService.pushReservedByPileConnectorCode(pileConnectorCode);
|
pileReservationInfoService.pushReservedByPileConnectorCode(pileConnectorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -476,7 +474,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
|||||||
@Override
|
@Override
|
||||||
public void firstUnplugCharger(String pileConnectorCode) {
|
public void firstUnplugCharger(String pileConnectorCode) {
|
||||||
// 关闭仅执行一次的预约
|
// 关闭仅执行一次的预约
|
||||||
pileReservedInfoService.cancelOneTimeReservation(pileConnectorCode);
|
pileReservationInfoService.cancelOneTimeReservation(pileConnectorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
package com.jsowell.pile.service.impl;
|
||||||
|
|
||||||
|
import com.jsowell.common.constant.Constants;
|
||||||
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||||
|
import com.jsowell.common.exception.BusinessException;
|
||||||
|
import com.jsowell.common.util.StringUtils;
|
||||||
|
import com.jsowell.pile.dto.PileReservedDTO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.sql.Time;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jsowell.pile.mapper.PileReservationInfoMapper;
|
||||||
|
import com.jsowell.pile.domain.PileReservationInfo;
|
||||||
|
import com.jsowell.pile.service.PileReservationInfoService;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PileReservationInfoServiceImpl implements PileReservationInfoService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PileReservationInfoMapper pileReservationInfoMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteByPrimaryKey(Integer id) {
|
||||||
|
return pileReservationInfoMapper.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insert(PileReservationInfo record) {
|
||||||
|
return pileReservationInfoMapper.insert(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertOrUpdate(PileReservationInfo record) {
|
||||||
|
return pileReservationInfoMapper.insertOrUpdate(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertOrUpdateSelective(PileReservationInfo record) {
|
||||||
|
return pileReservationInfoMapper.insertOrUpdateSelective(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertSelective(PileReservationInfo record) {
|
||||||
|
return pileReservationInfoMapper.insertSelective(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PileReservationInfo selectByPrimaryKey(Integer id) {
|
||||||
|
return pileReservationInfoMapper.selectByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateByPrimaryKeySelective(PileReservationInfo record) {
|
||||||
|
return pileReservationInfoMapper.updateByPrimaryKeySelective(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateByPrimaryKey(PileReservationInfo record) {
|
||||||
|
return pileReservationInfoMapper.updateByPrimaryKey(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateBatch(List<PileReservationInfo> list) {
|
||||||
|
return pileReservationInfoMapper.updateBatch(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchInsert(List<PileReservationInfo> list) {
|
||||||
|
return pileReservationInfoMapper.batchInsert(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateBatchSelective(List<PileReservationInfo> list) {
|
||||||
|
return pileReservationInfoMapper.updateBatchSelective(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PileReservationInfo> getReservationsByMemberIdAndPileSn(String memberId, String pileSn) {
|
||||||
|
return pileReservationInfoMapper.findByMemberIdAndPileSn(memberId, pileSn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用预约
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void activateReserved(PileReservedDTO dto) {
|
||||||
|
PileReservationInfo pileReservationInfo = pileReservationInfoMapper.selectByPrimaryKey(Integer.parseInt(dto.getReservedId()));
|
||||||
|
if (pileReservationInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(dto.getMemberId(), pileReservationInfo.getMemberId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pileReservationInfo.setStatus(Constants.ONE);
|
||||||
|
// 保存之前,校验时间是否重叠
|
||||||
|
saveReservation(pileReservationInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用预约
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deactivateReserved(PileReservedDTO dto) {
|
||||||
|
PileReservationInfo pileReservationInfo = pileReservationInfoMapper.selectByPrimaryKey(Integer.parseInt(dto.getReservedId()));
|
||||||
|
if (pileReservationInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(dto.getMemberId(), pileReservationInfo.getMemberId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 校验通过可以修改预约
|
||||||
|
pileReservationInfo.setStatus(Constants.ZERO);
|
||||||
|
pileReservationInfoMapper.updateByPrimaryKeySelective(pileReservationInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验时间是否重叠
|
||||||
|
* @param memberId
|
||||||
|
* @param pileSn
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
|
* @param reservationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isTimeSlotAvailable(String memberId, String pileSn, Time startTime, Time endTime, Integer reservationId) {
|
||||||
|
List<PileReservationInfo> reservations = pileReservationInfoMapper.findByMemberIdAndPileSnAndStatus(memberId, pileSn, "1");
|
||||||
|
LocalTime newStartTime = startTime.toLocalTime();
|
||||||
|
LocalTime newEndTime = endTime.toLocalTime();
|
||||||
|
|
||||||
|
for (PileReservationInfo res : reservations) {
|
||||||
|
if (res.getId().equals(reservationId)) {
|
||||||
|
continue; // Skip the current reservation if updating
|
||||||
|
}
|
||||||
|
LocalTime existingStartTime = res.getStartTime().toLocalTime();
|
||||||
|
LocalTime existingEndTime = res.getEndTime().toLocalTime();
|
||||||
|
|
||||||
|
if (newStartTime.isBefore(existingEndTime) && newEndTime.isAfter(existingStartTime)) {
|
||||||
|
return false; // Time slot overlaps
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveReservation(PileReservationInfo reservation) {
|
||||||
|
if (isTimeSlotAvailable(reservation.getMemberId(), reservation.getPileSn(), reservation.getStartTime(), reservation.getEndTime(), reservation.getId())) {
|
||||||
|
this.updateByPrimaryKeySelective(reservation);
|
||||||
|
} else {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_UPDATE_RESERVED_STATUS_REFUSED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据充电枪口编号发送指令
|
||||||
|
* @param pileConnectorCode
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void pushReservedByPileConnectorCode(String pileConnectorCode) {
|
||||||
|
// 根据充电枪口编号查询正在生效中的预约
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拔枪时,根据充电桩枪口编号关闭仅一次的预约
|
||||||
|
* @param pileConnectorCode
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cancelOneTimeReservation(String pileConnectorCode) {
|
||||||
|
// 根据充电枪口编号查询仅一次正在生效中的预约
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
package com.jsowell.pile.service.impl;
|
|
||||||
|
|
||||||
import com.jsowell.common.constant.Constants;
|
|
||||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
|
||||||
import com.jsowell.common.exception.BusinessException;
|
|
||||||
import com.jsowell.common.util.StringUtils;
|
|
||||||
import com.jsowell.pile.dto.PileReservedDTO;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.sql.Time;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.jsowell.pile.mapper.PileReservedInfoMapper;
|
|
||||||
import com.jsowell.pile.domain.PileReservedInfo;
|
|
||||||
import com.jsowell.pile.service.PileReservedInfoService;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class PileReservedInfoServiceImpl implements PileReservedInfoService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PileReservedInfoMapper pileReservedInfoMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int deleteByPrimaryKey(Integer id) {
|
|
||||||
return pileReservedInfoMapper.deleteByPrimaryKey(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int insert(PileReservedInfo record) {
|
|
||||||
return pileReservedInfoMapper.insert(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int insertOrUpdate(PileReservedInfo record) {
|
|
||||||
return pileReservedInfoMapper.insertOrUpdate(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int insertOrUpdateSelective(PileReservedInfo record) {
|
|
||||||
return pileReservedInfoMapper.insertOrUpdateSelective(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int insertSelective(PileReservedInfo record) {
|
|
||||||
return pileReservedInfoMapper.insertSelective(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PileReservedInfo selectByPrimaryKey(Integer id) {
|
|
||||||
return pileReservedInfoMapper.selectByPrimaryKey(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int updateByPrimaryKeySelective(PileReservedInfo record) {
|
|
||||||
return pileReservedInfoMapper.updateByPrimaryKeySelective(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int updateByPrimaryKey(PileReservedInfo record) {
|
|
||||||
return pileReservedInfoMapper.updateByPrimaryKey(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int updateBatch(List<PileReservedInfo> list) {
|
|
||||||
return pileReservedInfoMapper.updateBatch(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int batchInsert(List<PileReservedInfo> list) {
|
|
||||||
return pileReservedInfoMapper.batchInsert(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int updateBatchSelective(List<PileReservedInfo> list) {
|
|
||||||
return pileReservedInfoMapper.updateBatchSelective(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<PileReservedInfo> getReservationsByMemberIdAndPileSn(String memberId, String pileSn) {
|
|
||||||
return pileReservedInfoMapper.findByMemberIdAndPileSn(memberId, pileSn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启用预约
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 禁用预约
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验时间是否重叠
|
|
||||||
* @param memberId
|
|
||||||
* @param pileSn
|
|
||||||
* @param startTime
|
|
||||||
* @param endTime
|
|
||||||
* @param reservationId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isTimeSlotAvailable(String memberId, String pileSn, Time startTime, Time endTime, Integer reservationId) {
|
|
||||||
List<PileReservedInfo> reservations = pileReservedInfoMapper.findByMemberIdAndPileSnAndStatus(memberId, pileSn, "1");
|
|
||||||
LocalTime newStartTime = startTime.toLocalTime();
|
|
||||||
LocalTime newEndTime = endTime.toLocalTime();
|
|
||||||
|
|
||||||
for (PileReservedInfo res : reservations) {
|
|
||||||
if (res.getId().equals(reservationId)) {
|
|
||||||
continue; // Skip the current reservation if updating
|
|
||||||
}
|
|
||||||
LocalTime existingStartTime = res.getStartTime().toLocalTime();
|
|
||||||
LocalTime existingEndTime = res.getEndTime().toLocalTime();
|
|
||||||
|
|
||||||
if (newStartTime.isBefore(existingEndTime) && newEndTime.isAfter(existingStartTime)) {
|
|
||||||
return false; // Time slot overlaps
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveReservation(PileReservedInfo reservation) {
|
|
||||||
if (isTimeSlotAvailable(reservation.getMemberId(), reservation.getPileSn(), reservation.getStartTime(), reservation.getEndTime(), reservation.getId())) {
|
|
||||||
this.updateByPrimaryKeySelective(reservation);
|
|
||||||
} else {
|
|
||||||
throw new BusinessException(ReturnCodeEnum.CODE_UPDATE_RESERVED_STATUS_REFUSED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据充电枪口编号发送指令
|
|
||||||
* @param pileConnectorCode
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void pushReservedByPileConnectorCode(String pileConnectorCode) {
|
|
||||||
// 根据充电枪口编号查询正在生效中的预约
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.jsowell.pile.mapper.PileReservedInfoMapper">
|
<mapper namespace="com.jsowell.pile.mapper.PileReservationInfoMapper">
|
||||||
<resultMap id="BaseResultMap" type="com.jsowell.pile.domain.PileReservedInfo">
|
<resultMap id="BaseResultMap" type="com.jsowell.pile.domain.PileReservationInfo">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
<!--@Table pile_reserved_info-->
|
<!--@Table pile_reservation_info-->
|
||||||
<id column="id" jdbcType="INTEGER" property="id" />
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
<result column="member_id" jdbcType="VARCHAR" property="memberId" />
|
<result column="member_id" jdbcType="VARCHAR" property="memberId" />
|
||||||
<result column="pile_sn" jdbcType="VARCHAR" property="pileSn" />
|
<result column="pile_sn" jdbcType="VARCHAR" property="pileSn" />
|
||||||
@@ -28,17 +28,17 @@
|
|||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
from pile_reserved_info
|
from pile_reservation_info
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</select>
|
</select>
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
delete from pile_reserved_info
|
delete from pile_reservation_info
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservedInfo" useGeneratedKeys="true">
|
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservationInfo" useGeneratedKeys="true">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
insert into pile_reserved_info (member_id, pile_sn, pile_connector_code,
|
insert into pile_reservation_info (member_id, pile_sn, pile_connector_code,
|
||||||
`status`, reserved_type, start_time,
|
`status`, reserved_type, start_time,
|
||||||
end_time, freq, create_by,
|
end_time, freq, create_by,
|
||||||
create_time, update_by, update_time,
|
create_time, update_by, update_time,
|
||||||
@@ -49,9 +49,9 @@
|
|||||||
#{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
|
#{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
|
||||||
#{delFlag,jdbcType=CHAR})
|
#{delFlag,jdbcType=CHAR})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservedInfo" useGeneratedKeys="true">
|
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservationInfo" useGeneratedKeys="true">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
insert into pile_reserved_info
|
insert into pile_reservation_info
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="memberId != null">
|
<if test="memberId != null">
|
||||||
member_id,
|
member_id,
|
||||||
@@ -135,9 +135,9 @@
|
|||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.PileReservedInfo">
|
<update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.PileReservationInfo">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
update pile_reserved_info
|
update pile_reservation_info
|
||||||
<set>
|
<set>
|
||||||
<if test="memberId != null">
|
<if test="memberId != null">
|
||||||
member_id = #{memberId,jdbcType=VARCHAR},
|
member_id = #{memberId,jdbcType=VARCHAR},
|
||||||
@@ -181,9 +181,9 @@
|
|||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKey" parameterType="com.jsowell.pile.domain.PileReservedInfo">
|
<update id="updateByPrimaryKey" parameterType="com.jsowell.pile.domain.PileReservationInfo">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
update pile_reserved_info
|
update pile_reservation_info
|
||||||
set member_id = #{memberId,jdbcType=VARCHAR},
|
set member_id = #{memberId,jdbcType=VARCHAR},
|
||||||
pile_sn = #{pileSn,jdbcType=VARCHAR},
|
pile_sn = #{pileSn,jdbcType=VARCHAR},
|
||||||
pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
|
pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
|
||||||
@@ -201,7 +201,7 @@
|
|||||||
</update>
|
</update>
|
||||||
<update id="updateBatch" parameterType="java.util.List">
|
<update id="updateBatch" parameterType="java.util.List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
update pile_reserved_info
|
update pile_reservation_info
|
||||||
<trim prefix="set" suffixOverrides=",">
|
<trim prefix="set" suffixOverrides=",">
|
||||||
<trim prefix="member_id = case" suffix="end,">
|
<trim prefix="member_id = case" suffix="end,">
|
||||||
<foreach collection="list" index="index" item="item">
|
<foreach collection="list" index="index" item="item">
|
||||||
@@ -276,7 +276,7 @@
|
|||||||
</update>
|
</update>
|
||||||
<update id="updateBatchSelective" parameterType="java.util.List">
|
<update id="updateBatchSelective" parameterType="java.util.List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
update pile_reserved_info
|
update pile_reservation_info
|
||||||
<trim prefix="set" suffixOverrides=",">
|
<trim prefix="set" suffixOverrides=",">
|
||||||
<trim prefix="member_id = case" suffix="end,">
|
<trim prefix="member_id = case" suffix="end,">
|
||||||
<foreach collection="list" index="index" item="item">
|
<foreach collection="list" index="index" item="item">
|
||||||
@@ -377,7 +377,7 @@
|
|||||||
</update>
|
</update>
|
||||||
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
|
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
insert into pile_reserved_info
|
insert into pile_reservation_info
|
||||||
(member_id, pile_sn, pile_connector_code, `status`, reserved_type, start_time, end_time,
|
(member_id, pile_sn, pile_connector_code, `status`, reserved_type, start_time, end_time,
|
||||||
freq, create_by, create_time, update_by, update_time, del_flag)
|
freq, create_by, create_time, update_by, update_time, del_flag)
|
||||||
values
|
values
|
||||||
@@ -389,9 +389,9 @@
|
|||||||
#{item.delFlag,jdbcType=CHAR})
|
#{item.delFlag,jdbcType=CHAR})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservedInfo" useGeneratedKeys="true">
|
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservationInfo" useGeneratedKeys="true">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
insert into pile_reserved_info
|
insert into pile_reservation_info
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
id,
|
id,
|
||||||
@@ -449,9 +449,9 @@
|
|||||||
del_flag = #{delFlag,jdbcType=CHAR},
|
del_flag = #{delFlag,jdbcType=CHAR},
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservedInfo" useGeneratedKeys="true">
|
<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservationInfo" useGeneratedKeys="true">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
insert into pile_reserved_info
|
insert into pile_reservation_info
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
id,
|
id,
|
||||||
@@ -591,7 +591,7 @@
|
|||||||
<select id="findByMemberIdAndPileSnAndStatus" resultMap="BaseResultMap">
|
<select id="findByMemberIdAndPileSnAndStatus" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
from pile_reserved_info
|
from pile_reservation_info
|
||||||
where del_flag = '0'
|
where del_flag = '0'
|
||||||
and member_id = #{memberId,jdbcType=VARCHAR}
|
and member_id = #{memberId,jdbcType=VARCHAR}
|
||||||
and pile_sn = #{pileSn,jdbcType=VARCHAR}
|
and pile_sn = #{pileSn,jdbcType=VARCHAR}
|
||||||
@@ -601,7 +601,7 @@
|
|||||||
<select id="findByMemberIdAndPileSn" resultMap="BaseResultMap">
|
<select id="findByMemberIdAndPileSn" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
from pile_reserved_info
|
from pile_reservation_info
|
||||||
where del_flag = '0'
|
where del_flag = '0'
|
||||||
and member_id = #{memberId,jdbcType=VARCHAR}
|
and member_id = #{memberId,jdbcType=VARCHAR}
|
||||||
and pile_sn = #{pileSn,jdbcType=VARCHAR}
|
and pile_sn = #{pileSn,jdbcType=VARCHAR}
|
||||||
Reference in New Issue
Block a user