From 194e9bb493909bb0b1afd9578bdca42a9f2a37b2 Mon Sep 17 00:00:00 2001 From: little-cat-sweet <2116400472@qq.com> Date: Tue, 19 Oct 2021 18:22:55 +0800 Subject: [PATCH] Accomplishing the query_equip_auth --- .../domain/XhpcOperatorInternetBlacklist.java | 109 ++++++++++++++++++ .../domain/XhpcStationInternetBlacklist.java | 56 +++++++++ .../com/xhpc/evcs/dto/EquipAuthResponse.java | 30 +++++ .../evcs/api/QueryEquipAuthController.java | 66 +++++++++++ .../evcs/jpa/QueryEquipAuthRepository.java | 20 ++++ ...hpcStationInternetBlacklistRepository.java | 17 +++ 6 files changed, 298 insertions(+) create mode 100644 evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcOperatorInternetBlacklist.java create mode 100644 evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcStationInternetBlacklist.java create mode 100644 evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/EquipAuthResponse.java create mode 100644 evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryEquipAuthController.java create mode 100644 evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/jpa/QueryEquipAuthRepository.java create mode 100644 evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/jpa/XhpcStationInternetBlacklistRepository.java diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcOperatorInternetBlacklist.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcOperatorInternetBlacklist.java new file mode 100644 index 00000000..8be6e368 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcOperatorInternetBlacklist.java @@ -0,0 +1,109 @@ +package com.xhpc.evcs.domain; + +import javax.persistence.*; +import java.time.Instant; + +@Table(name = "xhpc_operator_internet_blacklist") +@Entity +public class XhpcOperatorInternetBlacklist { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "xhpc_operator_internet_blacklist_id", nullable = false) + private Long id; + + @Column(name = "operator_id", nullable = false) + private Long operatorId; + + @Column(name = "internet_user_id", nullable = false) + private Long internetUserId; + + @Column(name = "status") + private Integer status; + + @Column(name = "create_time") + private Instant createTime; + + @Column(name = "create_by", length = 30) + private String createBy; + + @Column(name = "update_time") + private Instant updateTime; + + @Column(name = "update_by", length = 30) + private String updateBy; + + @Column(name = "remark") + private String remark; + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + public Instant getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Instant updateTime) { + this.updateTime = updateTime; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Instant getCreateTime() { + return createTime; + } + + public void setCreateTime(Instant createTime) { + this.createTime = createTime; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Long getInternetUserId() { + return internetUserId; + } + + public void setInternetUserId(Long internetUserId) { + this.internetUserId = internetUserId; + } + + public Long getOperatorId() { + return operatorId; + } + + public void setOperatorId(Long operatorId) { + this.operatorId = operatorId; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} \ No newline at end of file diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcStationInternetBlacklist.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcStationInternetBlacklist.java new file mode 100644 index 00000000..f188e484 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcStationInternetBlacklist.java @@ -0,0 +1,56 @@ +package com.xhpc.evcs.domain; + +import com.xhpc.common.core.web.domain.BaseEntity; + +import javax.persistence.*; + +@Table(name = "xhpc_station_internet_blacklist") +@Entity +public class XhpcStationInternetBlacklist extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "xhpc_station_internet_blacklist_id", nullable = false) + private Long id; + + @Column(name = "internet_user_id") + private String internetUserId; + + @Column(name = "charging_station_id") + private Long chargingStationId; + + @Column(name = "status") + private Integer status; + + public Integer getStatus() { + return status; + } + + public void setChargingStationId(Long chargingStationId) { + this.chargingStationId = chargingStationId; + } + + public void setStatus(Integer status) { + this.status = status; + } + + + public String getInternetUserId() { + return internetUserId; + } + + public void setInternetUserId(String internetUserId) { + this.internetUserId = internetUserId; + } + + public Long getChargingStationId() { + return chargingStationId; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} \ No newline at end of file diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/EquipAuthResponse.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/EquipAuthResponse.java new file mode 100644 index 00000000..0acf8f36 --- /dev/null +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/EquipAuthResponse.java @@ -0,0 +1,30 @@ +package com.xhpc.evcs.dto; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * program: ruoyi + * User: HongYun + * Date:2021-10-18 15 + */ +@Getter +@Setter +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, + setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +public class EquipAuthResponse { + + @JsonProperty("EquipAuthSeq") + String equipAuthSeq; + + @JsonProperty("ConnectorID") + String connectorId; + + @JsonProperty("SuccStat") + Integer succStat; + + @JsonProperty("FailReason") + Integer failReason; +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryEquipAuthController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryEquipAuthController.java new file mode 100644 index 00000000..9bd6ee0b --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/QueryEquipAuthController.java @@ -0,0 +1,66 @@ +package com.xhpc.evcs.api; + +import com.xhpc.evcs.domain.XhpcStationInternetBlacklist; +import com.xhpc.evcs.dto.CommonRequest; +import com.xhpc.evcs.dto.CommonResponse; +import com.xhpc.evcs.dto.EquipAuthRequest; +import com.xhpc.evcs.dto.EquipAuthResponse; +import com.xhpc.evcs.jpa.XhpcStationInternetBlacklistRepository; +import com.xhpc.evcs.utils.JSONUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; + +/** + * program: ruoyi + * User: HongYun + * Date:2021-10-18 15 + */ + +@RestController +public class QueryEquipAuthController extends CoreDispatcher { + + @Autowired + private XhpcStationInternetBlacklistRepository xhpcStationInternetBlacklistRepo; + + @PostMapping(value = "/v1/queryEquipAuth") + public CommonResponse queryEquipAuth(@RequestBody CommonRequest commonRequest) throws Exception { + + CommonResponse resp = new CommonResponse(); + EquipAuthResponse equipAuthResponse = new EquipAuthResponse(); + EquipAuthRequest equipAuthRequest = JSONUtil.readParams(commonRequest.getData(), EquipAuthRequest.class); + String equipAuthSeq = equipAuthRequest.getEquipAuthSeq(); + String connectorId = equipAuthRequest.getConnectorId(); + equipAuthResponse.setEquipAuthSeq(equipAuthSeq); + equipAuthResponse.setConnectorId(connectorId); + String pileId = connectorId.substring(0, connectorId.length() - 2); + Map pileDataModel = REDIS.getCacheMap("pile:" + pileId); + Long stationId = Long.parseLong(pileDataModel.get("stationId").toString()); + XhpcStationInternetBlacklist xhpcStationInternetBlacklist = xhpcStationInternetBlacklistRepo.findByChargingStationIdAndInternetUserId(stationId, equipAuthSeq.substring(0, 10)).orElse(null); + resp.setRet("0"); + if (null != xhpcStationInternetBlacklist) { + equipAuthResponse.setSuccStat(1); + equipAuthResponse.setFailReason(2); + resp.setMsg("auth denied"); + } else { + equipAuthResponse.setSuccStat(0); + Map realTimeTerminalData = REDIS.getCacheMap("gun:".concat(connectorId)); + String terminalStatus = (String) realTimeTerminalData.get("vehicleGunStatus"); + if ("否".equals(terminalStatus)) { + resp.setMsg("gun is not plugging"); + equipAuthResponse.setFailReason(1); + } else { + resp.setMsg("success"); + equipAuthResponse.setFailReason(0); + } + + } + resp.setData(JSONUtil.toJSONString(equipAuthResponse)); + return resp; + } +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/jpa/QueryEquipAuthRepository.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/jpa/QueryEquipAuthRepository.java new file mode 100644 index 00000000..b2cdb86a --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/jpa/QueryEquipAuthRepository.java @@ -0,0 +1,20 @@ +package com.xhpc.evcs.jpa; + +import com.xhpc.evcs.domain.EtOrderMapping; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.query.QueryByExampleExecutor; +import org.springframework.stereotype.Repository; + +/** + * program: ruoyi + * User: HongYun + * Date:2021-10-18 16 + */ + +@Repository +public interface QueryEquipAuthRepository extends JpaRepository, + QueryByExampleExecutor, JpaSpecificationExecutor { + + +} diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/jpa/XhpcStationInternetBlacklistRepository.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/jpa/XhpcStationInternetBlacklistRepository.java new file mode 100644 index 00000000..8d33baf5 --- /dev/null +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/jpa/XhpcStationInternetBlacklistRepository.java @@ -0,0 +1,17 @@ +package com.xhpc.evcs.jpa; + +import com.xhpc.evcs.domain.XhpcStationInternetBlacklist; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.query.QueryByExampleExecutor; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface XhpcStationInternetBlacklistRepository extends JpaRepository, + QueryByExampleExecutor, JpaSpecificationExecutor { + + + Optional findByChargingStationIdAndInternetUserId(Long stationId, String substring); +}