Accomplishing the query_equip_auth
This commit is contained in:
parent
6e629a841b
commit
194e9bb493
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -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<EquipAuthRequest> 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<String, Object> 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<String, Object> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<EtOrderMapping, String>,
|
||||||
|
QueryByExampleExecutor<EtOrderMapping>, JpaSpecificationExecutor<EtOrderMapping> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<XhpcStationInternetBlacklist, Long>,
|
||||||
|
QueryByExampleExecutor<XhpcStationInternetBlacklist>, JpaSpecificationExecutor<XhpcStationInternetBlacklist> {
|
||||||
|
|
||||||
|
|
||||||
|
Optional<XhpcStationInternetBlacklist> findByChargingStationIdAndInternetUserId(Long stationId, String substring);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user