mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-17 08:18:34 +08:00
绑定蓝牙桩
This commit is contained in:
@@ -77,6 +77,34 @@ public class PersonPileController extends BaseController {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定个人桩信息(蓝牙)
|
||||||
|
* <p>
|
||||||
|
* http://localhost:8080/uniapp/personalPile/pileMemberBindingForBT
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping("/pileMemberBindingForBT")
|
||||||
|
public RestApiResponse<?> pileMemberBindingForBT(HttpServletRequest request, @RequestBody PileMemberBindingDTO dto) {
|
||||||
|
logger.info("绑定个人桩信息(蓝牙) params:{}", JSON.toJSONString(dto));
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
String memberId = getMemberIdByAuthorization(request);
|
||||||
|
dto.setMemberId(memberId);
|
||||||
|
int i = pileService.pileMemberBindingForBT(dto);
|
||||||
|
response = new RestApiResponse<>(i);
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
logger.error("绑定个人桩信息(蓝牙) error,", e);
|
||||||
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||||
|
} catch (Exception exception) {
|
||||||
|
logger.error("绑定个人桩信息(蓝牙) error,", exception);
|
||||||
|
response = new RestApiResponse<>(ReturnCodeEnum.CODE_BINDING_PERSONAL_PILE_ERROR);
|
||||||
|
}
|
||||||
|
logger.info("绑定个人桩信息(蓝牙) result:{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户解绑个人桩
|
* 用户解绑个人桩
|
||||||
* http://localhost:8080/uniapp/personalPile/userUnbindPile
|
* http://localhost:8080/uniapp/personalPile/userUnbindPile
|
||||||
@@ -140,9 +168,6 @@ public class PersonPileController extends BaseController {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过memberId查个人桩列表
|
* 通过memberId查个人桩列表
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -412,7 +412,38 @@ public class PileService {
|
|||||||
return pileMemberRelationService.insertPileMemberRelation(pileMemberRelation);
|
return pileMemberRelationService.insertPileMemberRelation(pileMemberRelation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户绑定个人桩(蓝牙)
|
||||||
|
*/
|
||||||
|
public int pileMemberBindingForBT(PileMemberBindingDTO dto) {
|
||||||
|
// 判断桩是否为个人桩
|
||||||
|
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(dto.getPileSn());
|
||||||
|
if (pileBasicInfo == null) {
|
||||||
|
// 未查到则说明没有此桩
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_PILE_NOT_INFO);
|
||||||
|
}
|
||||||
|
String businessType = pileBasicInfo.getBusinessType();
|
||||||
|
if (!StringUtils.equals(BusinessTypeEnum.INDIVIDUAL_PILE.getValue(), businessType)){
|
||||||
|
// 不一致则此桩不是个人桩
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_THIS_PILE_NOT_PERSONAL_PILE);
|
||||||
|
}
|
||||||
|
// 初始化个人桩预约信息
|
||||||
|
pileReservationInfoService.initPersonalPileReservation(dto.getPileSn(), null);
|
||||||
|
// 检查桩是否已经被绑定
|
||||||
|
PileMemberRelation pileMemberRelation = new PileMemberRelation();
|
||||||
|
pileMemberRelation.setPileSn(dto.getPileSn());
|
||||||
|
List<PileMemberRelation> list = pileMemberRelationService.selectPileMemberRelationList(pileMemberRelation);
|
||||||
|
if (CollectionUtils.isNotEmpty(list)){
|
||||||
|
// 说明已经被绑定过,抛出异常
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_PILE_HAS_BEEN_BINDING_ERROR);
|
||||||
|
}
|
||||||
|
// 保存绑定关系
|
||||||
|
pileMemberRelation.setMemberId(dto.getMemberId());
|
||||||
|
pileMemberRelation.setType(Constants.ONE); // 1-管理员
|
||||||
|
pileMemberRelation.setDeviceName(dto.getDeviceName());
|
||||||
|
pileMemberRelation.setDeviceId(dto.getDeviceId());
|
||||||
|
return pileMemberRelationService.insertPileMemberRelation(pileMemberRelation);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 用户解绑个人桩
|
* 用户解绑个人桩
|
||||||
* @param dto
|
* @param dto
|
||||||
|
|||||||
@@ -34,6 +34,16 @@ public class PileMemberRelation extends BaseEntity
|
|||||||
@Excel(name = "会员id")
|
@Excel(name = "会员id")
|
||||||
private String memberId;
|
private String memberId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备id 蓝牙桩
|
||||||
|
*/
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称 蓝牙桩
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
/** 身份类型(1-管理员,2-用户) */
|
/** 身份类型(1-管理员,2-用户) */
|
||||||
@Excel(name = "身份类型", readConverterExp = "1=-管理员,2-用户")
|
@Excel(name = "身份类型", readConverterExp = "1=-管理员,2-用户")
|
||||||
private String type;
|
private String type;
|
||||||
|
|||||||
@@ -39,4 +39,14 @@ public class PileMemberBindingDTO {
|
|||||||
* 一级运营商id
|
* 一级运营商id
|
||||||
*/
|
*/
|
||||||
private String firstLevelMerchantId;
|
private String firstLevelMerchantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备id
|
||||||
|
*/
|
||||||
|
private String deviceId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -891,24 +891,25 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
|||||||
if(CollectionUtils.isEmpty(list)){
|
if(CollectionUtils.isEmpty(list)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PersonalPileInfoVO personalPileInfoVO : list) {
|
for (PersonalPileInfoVO personalPileInfoVO : list) {
|
||||||
String pileSn = personalPileInfoVO.getPileSn();
|
String pileSn = personalPileInfoVO.getPileSn();
|
||||||
|
|
||||||
// 获取桩状态
|
// 获取桩状态
|
||||||
Map<String, String> pileStatus = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileSn));
|
Map<String, String> pileStatus = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileSn));
|
||||||
personalPileInfoVO.setPileStatus(pileStatus.get(pileSn));
|
personalPileInfoVO.setPileStatus(pileStatus.get(pileSn));
|
||||||
personalPileInfoVO.setPileStatusDesc(PileStatusEnum.getStatusDesc(pileStatus.get(pileSn)));
|
personalPileInfoVO.setPileStatusDesc(PileStatusEnum.getStatusDesc(pileStatus.get(pileSn)));
|
||||||
if (StringUtils.equals("1", personalPileInfoVO.getType())) {
|
// if (StringUtils.equals(Constants.ONE, personalPileInfoVO.getType())) {
|
||||||
personalPileInfoVO.setType("管理员用户");
|
// personalPileInfoVO.setType("管理员用户");
|
||||||
}else {
|
// }else {
|
||||||
personalPileInfoVO.setType("普通用户");
|
// personalPileInfoVO.setType("普通用户");
|
||||||
}
|
// }
|
||||||
if (StringUtils.equals("1", personalPileInfoVO.getSpeedType())) {
|
personalPileInfoVO.setType(StringUtils.equals(Constants.ONE, personalPileInfoVO.getType()) ? "管理员用户" : "普通用户");
|
||||||
personalPileInfoVO.setSpeedType("快充");
|
// if (StringUtils.equals(Constants.ONE, personalPileInfoVO.getSpeedType())) {
|
||||||
}else {
|
// personalPileInfoVO.setSpeedType("快充");
|
||||||
personalPileInfoVO.setSpeedType("慢充");
|
// }else {
|
||||||
}
|
// personalPileInfoVO.setSpeedType("慢充");
|
||||||
|
// }
|
||||||
|
personalPileInfoVO.setSpeedType(StringUtils.equals(Constants.ONE, personalPileInfoVO.getSpeedType()) ? "快充" : "慢充");
|
||||||
|
personalPileInfoVO.setConnectionType(StringUtils.isNotBlank(personalPileInfoVO.getDeviceId()) ? "BT" : "4G");
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,4 +64,14 @@ public class PersonalPileInfoVO {
|
|||||||
* 枪口数量
|
* 枪口数量
|
||||||
*/
|
*/
|
||||||
private String connectorNum;
|
private String connectorNum;
|
||||||
|
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电桩连接类型
|
||||||
|
* 4G/BT
|
||||||
|
*/
|
||||||
|
private String connectionType;
|
||||||
}
|
}
|
||||||
@@ -330,6 +330,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
t1.pile_sn as pileSn,
|
t1.pile_sn as pileSn,
|
||||||
t1.member_id as memberId,
|
t1.member_id as memberId,
|
||||||
t1.type,
|
t1.type,
|
||||||
|
t1.device_name as deviceName,
|
||||||
|
t1.device_id as deviceId,
|
||||||
t3.model_name as modelName,
|
t3.model_name as modelName,
|
||||||
t3.rated_power as ratedPower,
|
t3.rated_power as ratedPower,
|
||||||
t3.rated_current as ratedCurrent,
|
t3.rated_current as ratedCurrent,
|
||||||
|
|||||||
@@ -8,16 +8,20 @@
|
|||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="pileSn" column="pile_sn" />
|
<result property="pileSn" column="pile_sn" />
|
||||||
<result property="memberId" column="member_id" />
|
<result property="memberId" column="member_id" />
|
||||||
|
<result property="deviceName" column="device_name"/>
|
||||||
|
<result property="deviceId" column="device_id"/>
|
||||||
<result property="type" column="type" />
|
<result property="type" column="type" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectPileMemberRelationVo">
|
<sql id="selectPileMemberRelationVo">
|
||||||
select id, pile_sn, member_id, type, create_time from pile_member_relation
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from pile_member_relation
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, pile_sn, member_id, type, create_time
|
id, pile_sn, member_id, device_name, device_id, type, create_time
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectPileMemberRelationList" parameterType="com.jsowell.pile.domain.PileMemberRelation" resultMap="PileMemberRelationResult">
|
<select id="selectPileMemberRelationList" parameterType="com.jsowell.pile.domain.PileMemberRelation" resultMap="PileMemberRelationResult">
|
||||||
@@ -39,11 +43,15 @@
|
|||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="pileSn != null">pile_sn,</if>
|
<if test="pileSn != null">pile_sn,</if>
|
||||||
<if test="memberId != null">member_id,</if>
|
<if test="memberId != null">member_id,</if>
|
||||||
|
<if test="deviceName != null">device_name,</if>
|
||||||
|
<if test="deviceId != null">device_id,</if>
|
||||||
<if test="type != null">type,</if>
|
<if test="type != null">type,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="pileSn != null">#{pileSn},</if>
|
<if test="pileSn != null">#{pileSn},</if>
|
||||||
<if test="memberId != null">#{memberId},</if>
|
<if test="memberId != null">#{memberId},</if>
|
||||||
|
<if test="deviceName != null">#{deviceName},</if>
|
||||||
|
<if test="deviceId != null">#{deviceId},</if>
|
||||||
<if test="type != null">#{type},</if>
|
<if test="type != null">#{type},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
Reference in New Issue
Block a user