Commit ffc775aa by 叶立庆

【+】添加依赖

1 parent 5b3410e5
...@@ -29,6 +29,11 @@ ...@@ -29,6 +29,11 @@
<artifactId>google-collect</artifactId> <artifactId>google-collect</artifactId>
<version>snapshot-20080530</version> <version>snapshot-20080530</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package cn.com.glsx.evbusiness.api; package cn.com.glsx.evbusiness.api;
import cn.com.glsx.evbusiness.modules.model.ocpp16.RealTimeUploadData; import cn.com.glsx.evbusiness.modules.model.ocpp16.RealTimeUploadData;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
/** /**
...@@ -19,7 +21,7 @@ public interface DataInteractionFeignClient { ...@@ -19,7 +21,7 @@ public interface DataInteractionFeignClient {
* @param uploadData * @param uploadData
* @return * @return
*/ */
@GetMapping("/upload/real/time/data") @PostMapping("/upload/real/time/data")
Boolean uploadRealTimeData(@RequestParam("uploadData") RealTimeUploadData uploadData); Boolean uploadRealTimeData(@RequestParam("uploadData") RealTimeUploadData uploadData);
} }
package cn.com.glsx.evbusiness.modules.model.ocpp16;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Description 交易记录
* 功能 充电桩在网络正常情况下,主运发送结算账单,直到运营平台响应成账单上传成功(若未收到
* 0x40 回复间隔 30s 再重试一次,最多重试 3 次),收到账单结算成功,本账单在充电桩本地删
* 除。每次接收到启机命令并已执行启机过程,无论启机成功与否,都需在订单结束充电后生成
* 账单上传
* 样例报文 68 (起始标志) A2 (数据长度) 8001 (序列号域) 00 (加密标志) 3B (类型)
* 55031412782305012018061910262392(交易流水号)55031412782305(桩编码)01(枪号:1
* 枪)98B70E11100314(开始时间:2020-03-16 17:14:47)98B70E11100314(结束时间:2020-03-16
* 17:14:47)D0FB0100(尖单价:1.30000)00000000(尖电量:0)00000000(计损尖电量:0)
* 00000000(尖金额:0)D0FB0100(峰单价: 1.30000)00000000(峰电量:0)00000000(计损
* 峰电量:0)00000000(峰金额:0)D0FB0100(平单价: 1.30000)00000000(平电量:0)00000000
* (计损平电量:0)00000000(平金额:0)D0FB0100(谷单价: 1.30000)00000000(谷电量:
* 0)00000000(计损谷电量:0)00000000(谷金额:0)0000000000(电表总起值:0)0000000000
* (电表总止值:0)00000000(总电量:0)00000000(计损总电量:0)00000000(消费金额:
* 0)0000000000000000000000000000000000(VIN 码)02(交易标识:app 启动)98B70E11100314
* (交易时间:2020-03-16 17:14:47)00(停止原因:无)00000000D14B0A54(物理卡号:D14B0A54)
* 388C(帧校验域)
* @Author yelq
* @Date 2023/11/7-16:57
* @Version 1.0
*/
@Getter
@Setter
public class TransactionRecordsData implements Serializable {
/**
* 参数名称:交易流水号
* 数据类型:BCD码
* 长度(Byte):16
* 备注:见名词解释
*/
private String transactionSerialNumber;
/**
* 参数名称:桩编号
* 数据类型:BCD码
* 长度(Byte):7
* 备注:不足7位补0
*/
private String pileId;
/**
* 参数名称:枪号
* 数据类型:BCD码
* 长度(Byte):1
*/
private byte gunNumber;
/**
* 参数名称:开始时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private Date startTime;
/**
* 参数名称:结束时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private Date endTime;
/**
* 参数名称:尖单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(尖电费+尖服务费,见费率帧)
*/
private BigDecimal peakUnitPrice;
/**
* 参数名称:尖电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal peakElectricity;
/**
* 参数名称:计损尖电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal peakElectricityLoss;
/**
* 参数名称:尖金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal peakAmount;
/**
* 参数名称:峰单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(峰电费+峰服务费)
*/
private BigDecimal topUnitPrice;
/**
* 参数名称:峰电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal topElectricity;
/**
* 参数名称:计损峰电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal topElectricityLoss;
/**
* 参数名称:峰金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal topAmount;
/**
* 参数名称:平单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(平电费+平服务费)
*/
private BigDecimal flatUnitPrice;
/**
* 参数名称:平电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal flatElectricity;
/**
* 参数名称:计损平电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal flatElectricityLoss;
/**
* 参数名称:平金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal flatAmount;
/**
* 参数名称:谷单价
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后五位(谷电费+谷服务费)
*/
private BigDecimal valleyUnitPrice;
/**
* 参数名称:谷电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal valleyElectricity;
/**
* 参数名称:计损谷电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal valleyElectricityLoss;
/**
* 参数名称:谷金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal valleyAmount;
/**
* 参数名称:电表总起值
* 数据类型:BIN
* 长度(Byte):5
* 备注:精确到小数点后四位
*/
private BigDecimal totalStartValue;
/**
* 参数名称:电表总止值
* 数据类型:BIN
* 长度(Byte):5
* 备注:精确到小数点后四位
*/
private BigDecimal totalEndValue;
/**
* 参数名称:总电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal totalElectricity;
/**
* 参数名称:计损总电量
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位
*/
private BigDecimal totalElectricityLoss;
/**
* 参数名称:消费金额
* 数据类型:BIN
* 长度(Byte):4
* 备注:精确到小数点后四位,包含电费、服务费
*/
private BigDecimal totalAmount;
/**
* 参数名称:电动汽车唯一标识
* 数据类型:ASCII
* 长度(Byte):17
* 备注:VIN码,此处VIN码和充电时VIN码不同,正序直接上传,无需补0和反序
*/
private String vehicleIdentifier;
/**
* 参数名称:交易标识
* 数据类型:BIN
* 长度(Byte):1
* 备注:0x01:app启动 0x02:卡启动 0x04:离线卡启动 0x05: vin码启动充电
*/
private byte transactionIdentifier;
/**
* 参数名称:交易日期、时间
* 数据类型:BIN
* 长度(Byte):7
* 备注:CP56Time2a格式
*/
private Date transactionDateTime;
/**
* 参数名称:停止原因
* 数据类型:BIN
* 长度(Byte):1
* 备注:见附录11.1
*/
private byte stopReason;
/**
* 物理卡号
* 数据类型: (BIN码)
* 长度(Byte):8
* 备注:不足补零,桩与平台交互需使用的物理卡号
*/
private String physicalCardNumber;
}
...@@ -48,77 +48,78 @@ public class SSOUserInterceptor implements HandlerInterceptor { ...@@ -48,77 +48,78 @@ public class SSOUserInterceptor implements HandlerInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (handler instanceof HandlerMethod) {
boolean needLoginFlag = true; // 默认需要登录
HandlerMethod handlerMethod = (HandlerMethod) handler;
//##判断是否需要登录
// 1.先判断类上是否存在@NoLogin,@CheckSign注解[默认无需登录注解]
Class<?> targetBean = handlerMethod.getBeanType();
//验签无需登录校验
if (targetBean.isAnnotationPresent(CheckSign.class) || handlerMethod.hasMethodAnnotation(CheckSign.class)) {
return true;
}
if (targetBean.isAnnotationPresent(NoLogin.class)) {
// 如果存在,则根据注解的value()确定是否需要登录访问
NoLogin noLogin = targetBean.getAnnotation(NoLogin.class);
needLoginFlag = !noLogin.value();
}
// 2.再判断调用方法上是否存在@NoLogin注解[默认无需登录注解]
if (handlerMethod.hasMethodAnnotation(NoLogin.class)) {
// 如果存在,则根据注解的value()确定是否需要登录访问[方法覆盖类]
NoLogin noLogin = handlerMethod.getMethod().getAnnotation(NoLogin.class);
needLoginFlag = !noLogin.value();
}
// 3.需要登录访问则去验证token,反之,则通过
if (!needLoginFlag) {
return true;
}
//##判断是否登录
String token = request.getHeader(HttpHeaders.AUTHORIZATION);
// 1.判断请求是否携带token
if (StringUtils.isNotEmpty(token)) {
Session session = getSession(token);
if (session != null && session instanceof SimpleSession) {
SimpleSession simpleSession = SimpleSession.class.cast(session);
// 非空的情况下解析用户信息放入缓存中
Object user = simpleSession.getAttribute(USER_KEY);
if (user != null) {
try {
log.info("用户信息{}", JSONObject.toJSONString(user));
cn.com.glsx.evbusiness.config.RopThreadLocal.setLoginUser(user);
return true;
} catch (Exception e) {
log.error("rop a conversion user error:{}", e.getMessage(), e);
}
} else {
Object wechatUserInfo = simpleSession.getAttribute(WECHAT_USER_KEY);
if (wechatUserInfo != null) {
try {
log.info("小程序用户信息{}", JSONObject.toJSONString(wechatUserInfo));
cn.com.glsx.evbusiness.config.RopThreadLocal.setWechatLoginUserInfo(wechatUserInfo);
return true;
} catch (Exception e) {
log.error("rop a conversion user error:{}", e.getMessage(), e);
}
} else {
// 需要登录
needLogin(response);
return false;
}
}
}
}
// 需要登录
needLogin(response);
return false;
} else {
return true; return true;
} // if (handler instanceof HandlerMethod) {
// boolean needLoginFlag = true; // 默认需要登录
//
// HandlerMethod handlerMethod = (HandlerMethod) handler;
// //##判断是否需要登录
// // 1.先判断类上是否存在@NoLogin,@CheckSign注解[默认无需登录注解]
// Class<?> targetBean = handlerMethod.getBeanType();
//
// //验签无需登录校验
// if (targetBean.isAnnotationPresent(CheckSign.class) || handlerMethod.hasMethodAnnotation(CheckSign.class)) {
// return true;
// }
//
// if (targetBean.isAnnotationPresent(NoLogin.class)) {
// // 如果存在,则根据注解的value()确定是否需要登录访问
// NoLogin noLogin = targetBean.getAnnotation(NoLogin.class);
// needLoginFlag = !noLogin.value();
// }
//
// // 2.再判断调用方法上是否存在@NoLogin注解[默认无需登录注解]
// if (handlerMethod.hasMethodAnnotation(NoLogin.class)) {
// // 如果存在,则根据注解的value()确定是否需要登录访问[方法覆盖类]
// NoLogin noLogin = handlerMethod.getMethod().getAnnotation(NoLogin.class);
// needLoginFlag = !noLogin.value();
// }
// // 3.需要登录访问则去验证token,反之,则通过
// if (!needLoginFlag) {
// return true;
// }
//
// //##判断是否登录
// String token = request.getHeader(HttpHeaders.AUTHORIZATION);
// // 1.判断请求是否携带token
// if (StringUtils.isNotEmpty(token)) {
// Session session = getSession(token);
// if (session != null && session instanceof SimpleSession) {
// SimpleSession simpleSession = SimpleSession.class.cast(session);
// // 非空的情况下解析用户信息放入缓存中
// Object user = simpleSession.getAttribute(USER_KEY);
// if (user != null) {
// try {
// log.info("用户信息{}", JSONObject.toJSONString(user));
// cn.com.glsx.evbusiness.config.RopThreadLocal.setLoginUser(user);
// return true;
// } catch (Exception e) {
// log.error("rop a conversion user error:{}", e.getMessage(), e);
// }
// } else {
// Object wechatUserInfo = simpleSession.getAttribute(WECHAT_USER_KEY);
// if (wechatUserInfo != null) {
// try {
// log.info("小程序用户信息{}", JSONObject.toJSONString(wechatUserInfo));
// cn.com.glsx.evbusiness.config.RopThreadLocal.setWechatLoginUserInfo(wechatUserInfo);
// return true;
// } catch (Exception e) {
// log.error("rop a conversion user error:{}", e.getMessage(), e);
// }
// } else {
// // 需要登录
// needLogin(response);
// return false;
// }
// }
// }
// }
// // 需要登录
// needLogin(response);
// return false;
// } else {
// return true;
// }
} }
@Override @Override
......
...@@ -4,13 +4,12 @@ import cn.com.glsx.evbusiness.api.DataInteractionFeignClient; ...@@ -4,13 +4,12 @@ import cn.com.glsx.evbusiness.api.DataInteractionFeignClient;
import cn.com.glsx.evbusiness.modules.model.ocpp16.RealTimeUploadData; import cn.com.glsx.evbusiness.modules.model.ocpp16.RealTimeUploadData;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.glsx.plat.core.annotation.ResponseResultBody; import com.glsx.plat.core.annotation.ResponseResultBody;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @Description todo * @Description todo
...@@ -32,7 +31,7 @@ public class DataInteractionController implements DataInteractionFeignClient { ...@@ -32,7 +31,7 @@ public class DataInteractionController implements DataInteractionFeignClient {
*/ */
@Operation(summary = "FeignClient调用") @Operation(summary = "FeignClient调用")
@Override @Override
@GetMapping("/upload/real/time/data") @PostMapping("/upload/real/time/data")
public Boolean uploadRealTimeData(@RequestParam("uploadData") RealTimeUploadData uploadData) { public Boolean uploadRealTimeData(@RequestParam("uploadData") RealTimeUploadData uploadData) {
log.info("充电桩上传实时检测数据:{}", JSON.toJSONString(uploadData)); log.info("充电桩上传实时检测数据:{}", JSON.toJSONString(uploadData));
return true; return true;
......
package cn.com.glsx.evbusiness.modules.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @Description 充电订单
* @Author yelq
* @Date 2023/11/14-16:41
* @Version 1.0
*/
@Slf4j
@Service
public class ChargeOrderService {
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!