预约充电

This commit is contained in:
Guoqs
2024-06-20 13:54:38 +08:00
parent d632555869
commit af96ae4a1c
10 changed files with 413 additions and 288 deletions

View File

@@ -32,6 +32,11 @@ public class PileReservedInfo {
*/
private String pileSn;
/**
* 充电桩枪口编号
*/
private String pileConnectorCode;
/**
* 状态0-未生效1-生效)
*/

View File

@@ -20,6 +20,11 @@ public class CreateReservedDTO {
*/
private String pileSn;
/**
* 充电桩枪口编号
*/
private String pileConnectorCode;
/**
* 预约开始时间
*/

View File

@@ -116,6 +116,16 @@ public interface PileBasicInfoService {
*/
List<PileDetailVO> selectPileListByStationIds(List<Long> stationIdList);
/**
* 首次插枪
*/
public void firstPlugInCharger(String pileConnectorCode);
/**
* 首次拔枪
*/
public void firstUnplugCharger(String pileConnectorCode);
/**
* 通过桩编号查询站点id
* @param sn 桩编号

View File

@@ -32,9 +32,24 @@ public interface PileReservedInfoService {
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);
}

View File

@@ -82,18 +82,15 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
@Autowired
private SimCardService simCardService;
@Autowired
private PileSimInfoMapper pileSimInfoMapper;
@Autowired
private PileMerchantInfoMapper pileMerchantInfoMapper;
@Autowired
private RedisCache redisCache;
@Value("${baseurl.prefix}")
private String BASE_URL_PREFIX;
@Autowired
private PileReservedInfoService pileReservedInfoService;
/**
* 查询设备管理
*
@@ -460,6 +457,28 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
return pileInfoVOS;
}
/**
* 首次插枪
*
* @param pileConnectorCode
*/
@Override
public void firstPlugInCharger(String pileConnectorCode) {
// 下发预约指令
pileReservedInfoService.pushReservedByPileConnectorCode(pileConnectorCode);
}
/**
* 首次拔枪
*
* @param pileConnectorCode
*/
@Override
public void firstUnplugCharger(String pileConnectorCode) {
// 关闭仅执行一次的预约
pileReservedInfoService.cancelOneTimeReservation(pileConnectorCode);
}
/**
* 修改状态
* 用于登陆协议,心跳包协议,上传实时数据协议 更新状态的方法
@@ -476,10 +495,10 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
* 7.上传实时数据枪状态传0x03充电设置为【3-占用(充电中)】
*/
@Override
public void updateStatus(String frameType, String pileSn, String connectorCode, String status, String putGunType) {
public void updateStatus(String frameType, String pileSn, String connectorCode, String status, String isChargerPluggedIn) {
// 清缓存
cleanRedisCache(pileSn);
// log.info("updateStatus传参帧类型:{}, 桩编号:{}, 枪口号:{}, 状态:{}, 插拔枪:{}", "0x" + frameType, pileSn, connectorCode, status, putGunType);
// log.info("updateStatus传参帧类型:{}, 桩编号:{}, 枪口号:{}, 状态:{}, 插拔枪:{}", "0x" + frameType, pileSn, connectorCode, status, isChargerPluggedIn);
/*
0x01 登陆认证
登陆成功,把充电桩和枪口的状态都更新为【在线】
@@ -522,7 +541,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
*/
if (StringUtils.equals(frameType, BytesUtil.bcd2Str(YKCFrameTypeCode.UPLOAD_REAL_TIME_MONITOR_DATA_CODE.getBytes()))
|| StringUtils.equals(frameType, BytesUtil.bcd2Str(YKCFrameTypeCode.UPLOAD_REAL_TIME_MONITOR_DATA_OLD_VERSION_CODE.getBytes()))) {
// log.info("上传实时数据中的修改状态逻辑 桩号:{}, 枪号:{}, 枪状态{}, 是否插枪:{}", pileSn, connectorCode, status, putGunType);
// log.info("上传实时数据中的修改状态逻辑 桩号:{}, 枪号:{}, 枪状态{}, 是否插枪:{}", pileSn, connectorCode, status, isChargerPluggedIn);
/**
* 更新枪状态
* connectorStatus 桩传过来的枪口状态: 0x00离线 0x01故障 0x02空闲 0x03充电
@@ -535,7 +554,7 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
statusDataBase = PileConnectorDataBaseStatusEnum.FAULT.getValue();
} else if (StringUtils.equals(status, PileConnectorStatusEnum.FREE.getValue())) { // 空闲
//是否插枪 0x00否 0x01
if (StringUtils.equals(putGunType, Constants.ZERO_ONE)) {
if (StringUtils.equals(isChargerPluggedIn, Constants.ZERO_ONE)) {
// 空闲并插枪 设置为【占用(未充电)】
statusDataBase = PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue();
} else {

View File

@@ -3,7 +3,6 @@ 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.DateUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.dto.PileReservedDTO;
import org.springframework.stereotype.Service;
@@ -11,7 +10,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.sql.Time;
import java.time.LocalTime;
import java.util.Date;
import java.util.List;
import com.jsowell.pile.mapper.PileReservedInfoMapper;
@@ -118,7 +116,6 @@ public class PileReservedInfoServiceImpl implements PileReservedInfoService {
pileReservedInfoMapper.updateByPrimaryKeySelective(pileReservedInfo);
}
/**
* 校验时间是否重叠
* @param memberId
@@ -154,5 +151,14 @@ public class PileReservedInfoServiceImpl implements PileReservedInfoService {
throw new BusinessException(ReturnCodeEnum.CODE_UPDATE_RESERVED_STATUS_REFUSED);
}
}
/**
* 根据充电枪口编号发送指令
* @param pileConnectorCode
*/
@Override
public void pushReservedByPileConnectorCode(String pileConnectorCode) {
// 根据充电枪口编号查询正在生效中的预约
}
}

View File

@@ -7,6 +7,7 @@
<id column="id" jdbcType="INTEGER" property="id" />
<result column="member_id" jdbcType="VARCHAR" property="memberId" />
<result column="pile_sn" jdbcType="VARCHAR" property="pileSn" />
<result column="pile_connector_code" jdbcType="VARCHAR" property="pileConnectorCode" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="reserved_type" jdbcType="VARCHAR" property="reservedType" />
<result column="start_time" jdbcType="TIME" property="startTime" />
@@ -20,8 +21,8 @@
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, member_id, pile_sn, `status`, reserved_type, start_time, end_time, freq, create_by,
create_time, update_by, update_time, del_flag
id, 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
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
@@ -37,16 +38,16 @@
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservedInfo" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into pile_reserved_info (member_id, pile_sn, `status`,
reserved_type, start_time, end_time,
freq, create_by, create_time,
update_by, update_time, del_flag
)
values (#{memberId,jdbcType=VARCHAR}, #{pileSn,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{reservedType,jdbcType=VARCHAR}, #{startTime,jdbcType=TIME}, #{endTime,jdbcType=TIME},
#{freq,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=CHAR}
)
insert into pile_reserved_info (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)
values (#{memberId,jdbcType=VARCHAR}, #{pileSn,jdbcType=VARCHAR}, #{pileConnectorCode,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{reservedType,jdbcType=VARCHAR}, #{startTime,jdbcType=TIME},
#{endTime,jdbcType=TIME}, #{freq,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=CHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservedInfo" useGeneratedKeys="true">
<!--@mbg.generated-->
@@ -58,6 +59,9 @@
<if test="pileSn != null">
pile_sn,
</if>
<if test="pileConnectorCode != null">
pile_connector_code,
</if>
<if test="status != null">
`status`,
</if>
@@ -96,6 +100,9 @@
<if test="pileSn != null">
#{pileSn,jdbcType=VARCHAR},
</if>
<if test="pileConnectorCode != null">
#{pileConnectorCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
@@ -138,6 +145,9 @@
<if test="pileSn != null">
pile_sn = #{pileSn,jdbcType=VARCHAR},
</if>
<if test="pileConnectorCode != null">
pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
@@ -176,6 +186,7 @@
update pile_reserved_info
set member_id = #{memberId,jdbcType=VARCHAR},
pile_sn = #{pileSn,jdbcType=VARCHAR},
pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
reserved_type = #{reservedType,jdbcType=VARCHAR},
start_time = #{startTime,jdbcType=TIME},
@@ -202,6 +213,11 @@
when id = #{item.id,jdbcType=INTEGER} then #{item.pileSn,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="pile_connector_code = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.pileConnectorCode,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="`status` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
@@ -276,6 +292,13 @@
</if>
</foreach>
</trim>
<trim prefix="pile_connector_code = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.pileConnectorCode != null">
when id = #{item.id,jdbcType=INTEGER} then #{item.pileConnectorCode,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="`status` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.status != null">
@@ -355,15 +378,15 @@
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into pile_reserved_info
(member_id, pile_sn, `status`, reserved_type, start_time, end_time, freq, create_by,
create_time, update_by, update_time, del_flag)
(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)
values
<foreach collection="list" item="item" separator=",">
(#{item.memberId,jdbcType=VARCHAR}, #{item.pileSn,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR},
#{item.reservedType,jdbcType=VARCHAR}, #{item.startTime,jdbcType=TIME}, #{item.endTime,jdbcType=TIME},
#{item.freq,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP},
#{item.updateBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.delFlag,jdbcType=CHAR}
)
(#{item.memberId,jdbcType=VARCHAR}, #{item.pileSn,jdbcType=VARCHAR}, #{item.pileConnectorCode,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR}, #{item.reservedType,jdbcType=VARCHAR}, #{item.startTime,jdbcType=TIME},
#{item.endTime,jdbcType=TIME}, #{item.freq,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP},
#{item.delFlag,jdbcType=CHAR})
</foreach>
</insert>
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservedInfo" useGeneratedKeys="true">
@@ -375,6 +398,7 @@
</if>
member_id,
pile_sn,
pile_connector_code,
`status`,
reserved_type,
start_time,
@@ -393,6 +417,7 @@
</if>
#{memberId,jdbcType=VARCHAR},
#{pileSn,jdbcType=VARCHAR},
#{pileConnectorCode,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR},
#{reservedType,jdbcType=VARCHAR},
#{startTime,jdbcType=TIME},
@@ -411,6 +436,7 @@
</if>
member_id = #{memberId,jdbcType=VARCHAR},
pile_sn = #{pileSn,jdbcType=VARCHAR},
pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
reserved_type = #{reservedType,jdbcType=VARCHAR},
start_time = #{startTime,jdbcType=TIME},
@@ -436,6 +462,9 @@
<if test="pileSn != null">
pile_sn,
</if>
<if test="pileConnectorCode != null">
pile_connector_code,
</if>
<if test="status != null">
`status`,
</if>
@@ -478,6 +507,9 @@
<if test="pileSn != null">
#{pileSn,jdbcType=VARCHAR},
</if>
<if test="pileConnectorCode != null">
#{pileConnectorCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
@@ -520,6 +552,9 @@
<if test="pileSn != null">
pile_sn = #{pileSn,jdbcType=VARCHAR},
</if>
<if test="pileConnectorCode != null">
pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>