mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 后管生成个人桩时,生成密钥逻辑,并且绑定个人桩时增加密钥校验
This commit is contained in:
@@ -30,6 +30,7 @@ import com.jsowell.pile.vo.base.PileInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.*;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -113,7 +114,12 @@ public class PileService {
|
||||
// 组装pile_basic_info表数据
|
||||
basicInfo = new PileBasicInfo();
|
||||
basicInfo.setSn(sn); // sn号
|
||||
basicInfo.setBusinessType(BusinessTypeEnum.OPERATING_PILE.getValue()); // 经营类型 默认运营桩
|
||||
basicInfo.setBusinessType(dto.getChargerPileType()); // 经营类型 1-运营桩;2-个人桩
|
||||
if (StringUtils.equals(BusinessTypeEnum.INDIVIDUAL_PILE.getValue(), dto.getChargerPileType())) {
|
||||
// 个人桩生成一个八位的密钥(字母加数字)
|
||||
String secretKey = RandomStringUtils.randomAlphanumeric(8).toUpperCase(Locale.ROOT);
|
||||
basicInfo.setSecretKey(secretKey);
|
||||
}
|
||||
basicInfo.setSoftwareProtocol(dto.getSoftwareProtocol()); // 软件协议
|
||||
basicInfo.setMerchantId(Long.valueOf(dto.getMerchantId())); // 运营商id
|
||||
basicInfo.setStationId(Long.valueOf(dto.getStationId())); // 站点id
|
||||
@@ -245,7 +251,17 @@ public class PileService {
|
||||
// 说明已经被绑定过,抛出异常
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PILE_HAS_BEEN_BINDING_ERROR);
|
||||
}
|
||||
// 如果没被绑定,则此用户为管理员
|
||||
// 如果没被绑定,先校验桩密钥是否一致
|
||||
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(dto.getPileSn());
|
||||
if (pileBasicInfo == null) {
|
||||
// 未查到则说明没有此桩
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PILE_NOT_INFO);
|
||||
}
|
||||
if (!StringUtils.equals(pileBasicInfo.getSecretKey(), dto.getSecretKey())) {
|
||||
// 错误的密钥信息
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_SECRET_KEY_ERROR);
|
||||
}
|
||||
// 密钥正确,且桩未被绑定,则此用户为管理员
|
||||
pileMemberRelation.setMemberId(dto.getMemberId());
|
||||
pileMemberRelation.setType("1"); // 1-管理员
|
||||
return pileMemberRelationService.insertPileMemberRelation(pileMemberRelation);
|
||||
@@ -346,7 +362,7 @@ public class PileService {
|
||||
public PersonPileConnectorSumInfoVO getAccumulativeInfo(QueryPersonPileDTO dto) {
|
||||
List<PersonPileConnectorSumInfoVO> accumulativeInfo = orderBasicInfoService.getAccumulativeInfo(dto);
|
||||
if (CollectionUtils.isEmpty(accumulativeInfo)) {
|
||||
throw new BusinessException("00400011", "未查到相关订单信息!");
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
|
||||
}
|
||||
// BigDecimal sumChargingTime = BigDecimal.ZERO;
|
||||
// BigDecimal sumUsedElectricity = BigDecimal.ZERO;
|
||||
@@ -391,7 +407,7 @@ public class PileService {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<PersonPileConnectorSumInfoVO> accumulativeInfo = orderBasicInfoService.getAccumulativeInfo(dto);
|
||||
if (CollectionUtils.isEmpty(accumulativeInfo)) {
|
||||
throw new BusinessException("00400011", "未查到相关订单信息!");
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
|
||||
}
|
||||
PageInfo<PersonPileConnectorSumInfoVO> pageInfo = new PageInfo<>(accumulativeInfo);
|
||||
for (PersonPileConnectorSumInfoVO personPileConnectorSumInfoVO : pageInfo.getList()) {
|
||||
|
||||
Reference in New Issue
Block a user