diff --git a/jsowell-admin/src/main/java/com/jsowell/service/PileService.java b/jsowell-admin/src/main/java/com/jsowell/service/PileService.java index e812773c8..05ca0a5b6 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/PileService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/PileService.java @@ -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 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 accumulativeInfo = orderBasicInfoService.getAccumulativeInfo(dto); if (CollectionUtils.isEmpty(accumulativeInfo)) { - throw new BusinessException("00400011", "未查到相关订单信息!"); + throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL); } PageInfo pageInfo = new PageInfo<>(accumulativeInfo); for (PersonPileConnectorSumInfoVO personPileConnectorSumInfoVO : pageInfo.getList()) { diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/ykc/ReturnCodeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/ykc/ReturnCodeEnum.java index 76068b7b5..8118061f5 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/ykc/ReturnCodeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/ykc/ReturnCodeEnum.java @@ -115,6 +115,12 @@ public enum ReturnCodeEnum { CODE_USER_BINDING_CARNO_ERROR("00500002", "用户绑定车牌号异常"), CODE_USER_UNBIND_CARNO_ERROR("00500003", "用户解绑车牌号异常"), + + CODE_QUERY_ORDER_INFO_IS_NULL("00400011", "未查到相关订单信息!"), + + CODE_PILE_NOT_INFO("00400012", "未查到该该桩的信息,请检查!"), + + CODE_SECRET_KEY_ERROR("00400013", "填写的桩密钥有误,请检查!"), ; private String value; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/domain/PileBasicInfo.java b/jsowell-pile/src/main/java/com/jsowell/pile/domain/PileBasicInfo.java index b5d954a4a..111b48bb9 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/domain/PileBasicInfo.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/domain/PileBasicInfo.java @@ -40,6 +40,12 @@ public class PileBasicInfo extends BaseEntity { @Excel(name = "经营类型", readConverterExp = "1=-运营桩;2-个人桩") private String businessType; + /** + * 个人桩密钥(八位,字母数字组合) + */ + @Excel(name = "个人桩密钥") + private String secretKey; + /** * 软件协议(1-云快充;2-永联) */ @@ -190,12 +196,21 @@ public class PileBasicInfo extends BaseEntity { return delFlag; } + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.JSON_STYLE) .append("id", getId()) .append("sn", getSn()) .append("businessType", getBusinessType()) + .append("secretKey", getSecretKey()) .append("softwareProtocol", getSoftwareProtocol()) .append("productionDate", getProductionDate()) .append("licenceId", getLicenceId()) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/BatchCreatePileDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/BatchCreatePileDTO.java index 627ecd2d6..33c9485f3 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/BatchCreatePileDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/BatchCreatePileDTO.java @@ -51,4 +51,10 @@ public class BatchCreatePileDTO { * 备注 */ private String remark; + + /** + * 经营类型 + * 1-运营桩;2-个人桩 + */ + private String chargerPileType; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/PileMemberBindingDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/PileMemberBindingDTO.java index 6b498570a..8187a46bd 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/PileMemberBindingDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/PileMemberBindingDTO.java @@ -15,6 +15,11 @@ public class PileMemberBindingDTO { */ private String pileSn; + /** + * 个人桩密钥 + */ + private String secretKey; + /** * 手机号 */ diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml index d574432d8..3add17688 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml @@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - id, sn, business_type, software_protocol, production_date, licence_id, model_id, sim_id, + id, sn, business_type, secret_key, software_protocol, production_date, licence_id, model_id, sim_id, merchant_id, station_id, fault_reason, create_by, create_time, update_by, update_time, del_flag, remark @@ -40,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and sn = #{sn} and business_type = #{businessType} + and secret_key = #{secretKey} and software_protocol = #{softwareProtocol} and licence_id = #{licenceId} @@ -67,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sn, business_type, + secret_key, software_protocol, production_date, licence_id, @@ -85,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{sn}, #{businessType}, + #{secretKey}, #{softwareProtocol}, #{productionDate}, #{licenceId}, @@ -107,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sn = #{sn}, business_type = #{businessType}, + secret_key = #{secretKey}, software_protocol = #{softwareProtocol}, production_date = #{productionDate}, licence_id = #{licenceId}, @@ -189,13 +194,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into pile_basic_info - (sn, business_type, software_protocol, production_date, licence_id, model_id, sim_id, + (sn, business_type, secret_key, software_protocol, production_date, licence_id, model_id, sim_id, merchant_id, station_id, fault_reason, create_by, update_by, del_flag, remark) values ( #{item.sn,jdbcType=VARCHAR}, #{item.businessType,jdbcType=VARCHAR}, + #{item.secretKey,jdbcType=VARCHAR}, #{item.softwareProtocol,jdbcType=VARCHAR}, #{item.productionDate,jdbcType=TIMESTAMP}, #{item.licenceId,jdbcType=BIGINT}, diff --git a/jsowell-ui/src/views/pile/basic/index.vue b/jsowell-ui/src/views/pile/basic/index.vue index 43a39648e..2f5e35eef 100644 --- a/jsowell-ui/src/views/pile/basic/index.vue +++ b/jsowell-ui/src/views/pile/basic/index.vue @@ -259,6 +259,7 @@ placeholder="请选择桩类型" > +