main^2^2
黄海 11 months ago
parent c6fe6c3c32
commit 09214dd512

@ -3,7 +3,7 @@ spring:
mongodb:
uri: mongodb://yltcharge:yltcharge@dds-bp176c45f561f0041.mongodb.rds.aliyuncs.com:3717,dds-bp176c45f561f0042.mongodb.rds.aliyuncs.com:3717/yltcharge?replicaSet=mgset-36440453
datasource:
url: jdbc:mysql://rm-bp1ux6tuk49er80t9.mysql.rds.aliyuncs.com:3306/yltcharge?useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://rm-bp1ux6tuk49er80t9.mysql.rds.aliyuncs.com:3306/yltcharge?useUnicode=true&characterEncoding=UTF-8
username: ylt
password: Ycharge666
driver-class-name: com.mysql.jdbc.Driver

@ -3,7 +3,7 @@ spring:
mongodb:
uri: mongodb://ycharge:ycharge@dds-2vc0a87af9cfc5841.mongodb.cn-chengdu.rds.aliyuncs.com:3717,dds-2vc0a87af9cfc5842.mongodb.cn-chengdu.rds.aliyuncs.com:3717/ycharge
datasource:
url: jdbc:mysql://rm-2vchv2m4c8dn72884.mysql.cn-chengdu.rds.aliyuncs.com:3306/ycharge?useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://rm-2vchv2m4c8dn72884.mysql.cn-chengdu.rds.aliyuncs.com:3306/ycharge?useUnicode=true&characterEncoding=UTF-8
username: ycharge
password: Ycharge666
driver-class-name: com.mysql.jdbc.Driver
@ -74,8 +74,8 @@ aliyunvinapi:
wx:
config:
appId: wxf077d1a84a951991
appScrect: f159a92730247f7e574bd8c538ae6910
appId: wx9863e002c6a5f8bd
appScrect: ee9f5f214f2054f504544476ae542231
aliSms:
product: Dysmsapi

@ -31,7 +31,7 @@
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal</artifactId>
<version>5.1.9</version>
<version>5.2.1</version>
</dependency>
<dependency>

@ -0,0 +1,97 @@
package com.dsideal.ZhuQue.Util;
public class ResultVO {
private Integer code; //返回码
private String msg; //返回提示信息
private Object data; //返回数据
private boolean success;//是否成功
/**
*
* @param data
* @return
*/
public static ResultVO success(Object data){
ResultVO res = new ResultVO();
res.setCode(1000);
res.setSuccess(true);
res.setMsg("请求成功");
res.setData(data);
return res;
}
/**
*
* @param
* @return
*/
public static ResultVO success(){
ResultVO res = new ResultVO();
res.setCode(1000);
res.setSuccess(true);
res.setMsg("请求成功");
res.setData(null);
return res;
}
/**
*
* @param msg
* @param errorCode
* @return
*/
public static ResultVO custom(String msg, int errorCode){
ResultVO res = new ResultVO();
res.setCode(errorCode);
res.setSuccess(false);
res.setMsg(msg);
res.setData(null);
return res;
}
/**
*
* @param msg
* @param errorCode
* @param data
* @return
*/
public static ResultVO custom(String msg, int errorCode, Object data){
ResultVO res = new ResultVO();
res.setCode(errorCode);
res.setMsg(msg);
res.setData(data);
return res;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
}

@ -2,6 +2,7 @@ package com.dsideal.ZhuQue.Util;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Joiner;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@ -45,6 +46,30 @@ public class SignUtils {
return md5(temp).toUpperCase();
}
/**
*
*
* @param requestBody
* @param appSecret
* @return
*/
public static String paramsAnKuaiSign(JSONObject requestBody, String appSecret) {
TreeMap<String, String> params = new TreeMap<>();
requestBody.entrySet().stream().filter(
p -> p.getValue() != null
&& !(p.getValue() instanceof Map)
&& !(p.getValue() instanceof Iterable))
.forEach(p -> {
if (!p.getValue().equals("")) {
params.put(p.getKey(), p.getValue().toString());
}
});
//拼接appSecret
String temp = Joiner.on("&").withKeyValueSeparator("=").join(params).concat("&secret=").concat(appSecret);
String res = md5(temp);
return res;
}
/**
* md5 , mysql,JavaScriptmd5.
*

@ -6,6 +6,7 @@ import com.cybermkd.mongo.kit.MongoQuery;
import com.dsideal.ZhuQue.Interceptor.EmptyInterface;
import com.dsideal.ZhuQue.Interceptor.IsLoginInterface;
import com.dsideal.ZhuQue.Util.CommonUtil;
import com.dsideal.ZhuQue.Util.ResultVO;
import com.dsideal.ZhuQue.Util.SignUtils;
import com.dsideal.ZhuQue.Ylt.Model.YltModel;
import com.jfinal.aop.Before;
@ -23,7 +24,6 @@ import java.util.UUID;
public class YltController extends Controller {
Logger log = LoggerFactory.getLogger(YltController.class);
YltModel ym = new YltModel();
MongoQuery query = new MongoQuery();
/**
*
@ -31,14 +31,14 @@ public class YltController extends Controller {
* @param order_no
*/
@Before({POST.class})
@IsLoginInterface({})
public void isThirdPartyStation(String order_no) {
//@IsLoginInterface({})
// @PostMapping("/station/isThirdPartyStation")
public ResultVO isThirdPartyStation(String order_no) {
Record record = ym.getThirdPartyStation(order_no);
if (record == null) {
renderJson(CommonUtil.getRet(false, "不在合作的道闸车场内!"));
return;
return ResultVO.custom("不在合作的道闸车场内", -1);
}
renderJson(CommonUtil.getRet(true, "在合作的道闸车场内!"));
return ResultVO.success("在合作的道闸车场内");
}
/**
@ -46,32 +46,29 @@ public class YltController extends Controller {
*/
@Before({GET.class})
@IsLoginInterface({})
public void getCarList() {
// @PostMapping("/station/getCarList")
public ResultVO getCarList() {
//获取当前登录人员信息
Record user = ym.getUser(getRequest());
int userId = Integer.parseInt(user.get("userId"));
int userId = Integer.parseInt(getRequest().getHeader("userId"));
List<Record> list = ym.getCarList(userId);
renderJson(CommonUtil.getRet(list, true, "获取成功!"));
return ResultVO.success(list);
}
/**
* :
*/
@Before({POST.class})
@IsLoginInterface({})
@EmptyInterface({"order_no", "charge_plate_no"})
// 非指定闸机场地
// http://10.10.21.20:8888/ZhuQue/Ylt/SyncChargePilePay?order_no=2020092315154430479&charge_plate_no=吉A88888
// 科拓闸机场地
// http://10.10.21.20:8888/ZhuQue/Ylt/SyncChargePilePay?order_no=2022012911045715187&charge_plate_no=吉A88888
// 智门科技
// http://10.10.21.20:8888/ZhuQue/Ylt/SyncChargePilePay?order_no=2021040710440684484&charge_plate_no=吉A88888
public void SyncChargePilePay(String order_no, String charge_plate_no) { //订单号,车牌号
public ResultVO SyncChargePilePay(String order_no, String charge_plate_no) {
//模拟一下假的订单
order_no="2023010415453464446";
//根据订单号获取到第三方方面提供的车场信息
Record thirdPartyStation = ym.getThirdPartyStation(order_no);
if (thirdPartyStation == null) {
renderJson(CommonUtil.getRet(false, "检查到不是需要免费的道闸所在车场,无需发送减免消息!!"));
return;
return ResultVO.custom("检查到不是需要免费的道闸所在车场,无需发送减免消息!!", -1);
}
//请求地址
String url = thirdPartyStation.getStr("third_party_url");
@ -82,7 +79,7 @@ public class YltController extends Controller {
//闸机提供商
String name = thirdPartyStation.getStr("third_party_name");
//闸机所在车场ID
int parkId = thirdPartyStation.getInt("third_party_station_id");
String parkId = thirdPartyStation.getStr("third_party_station_id");
//最小充电费用
int mini_receivable_total_fee = thirdPartyStation.getInt("mini_receivable_total_fee");
//最小充电度数
@ -91,12 +88,11 @@ public class YltController extends Controller {
int freeMoney = thirdPartyStation.getInt("freeMoney");//免费0元
// 减免时长
int freeTime = thirdPartyStation.getInt("freeTime");//2小时
log.info("发现闸机提供商:" + name + ",parkId=" + parkId);
//log.info("发现闸机提供商:" + name + ",parkId=" + parkId);
//订单信息
Record ddRecord = ym.getOrderByNo(order_no);
String charge_begin_time = ddRecord.getStr("charge_begin_time");//充电开始时间
String charge_end_time = ddRecord.getStr("charge_end_time");//充电结束时间
int stationId = ddRecord.getInt("station_id");//电站ID
//获取车场名称
String stationName = ym.getStationById(stationId).getStr("station_name");
@ -117,15 +113,17 @@ public class YltController extends Controller {
//本地车场配置减免规则,根据充电时长换算
int freeType = 1;
JSONObject jo = new JSONObject();
//必须保证满足最低收费规则
if (totalMoney >= mini_receivable_total_fee && power >= mini_charge_ah) {
// 科拓闸机
if ("科拓".equals(name)) {
JSONObject jo = new JSONObject();
jo.put("appId", appId);
jo.put("parkId", parkId);
jo.put("serviceCode", "syncChargePilePay");
// 获取当前时间戳
String charge_begin_time = ddRecord.getStr("charge_begin_time");//充电开始时间
String charge_end_time = ddRecord.getStr("charge_end_time");//充电结束时间
long timestamp = System.currentTimeMillis();
jo.put("ts", timestamp);//每次请求附带当前时间戳(格林威治时间1970年01月01日00时00分00秒起至现在的总毫秒数)超过10S请求失效
jo.put("reqId", UUID.randomUUID().toString().toUpperCase());//每次请求的唯一标识如果是异步接口异步响应消息的reqId会与原请求的reqId一致。每次请求必须唯一
@ -154,10 +152,8 @@ public class YltController extends Controller {
.execute().body(); // 发送请求并获取响应体
//记录到数据库中闸机的流水记录
ym.recordDzLog(order_no, charge_plate_no, jo.toString(), result);
renderJson(CommonUtil.getRet(JSONObject.parseObject(result), true, "已经向科拓闸机平台发送了减免消息!"));
return;
return ResultVO.success(JSONObject.parseObject(result));
} else if ("智门科技".equals(name)) {
JSONObject jo = new JSONObject();
jo.put("Ver", 2);//协议版本
jo.put("Uid", UUID.randomUUID().toString().toUpperCase());//请求编号协议唯一码可使用uuid
jo.put("Timestamp", System.currentTimeMillis());//时间戳1970-01-01到现在的秒数
@ -170,7 +166,7 @@ public class YltController extends Controller {
dataJo.put("License", charge_plate_no);//车牌
dataJo.put("DiscountType", 2);//优惠类型为时长
dataJo.put("DiscountFee", 0);//优惠金额0分
dataJo.put("DiscountMinute", 60 * 2);//优惠分钟
dataJo.put("DiscountMinute", freeTime);//优惠分钟
jo.put("Data", dataJo);//请求数据 json
String result = HttpUtil.createPost(url)
.body(jo.toString()) // 将 JSON 对象转换为字符串作为请求正文
@ -178,10 +174,28 @@ public class YltController extends Controller {
.execute().body(); // 发送请求并获取响应体
//记录到数据库中闸机的流水记录
ym.recordDzLog(order_no, charge_plate_no, jo.toString(), result);
renderJson(CommonUtil.getRet(JSONObject.parseObject(result), true, "已经向智门科技闸机平台发送了减免消息!"));
return;
return ResultVO.success(JSONObject.parseObject(result));
} else if ("安快I".equals(name)) {
jo.put("parkNo", parkId);
jo.put("plate", charge_plate_no);//车牌号
jo.put("plate_color", 5);//车牌颜色,绿色
jo.put("coupon_type", 1);//1固定时长券
jo.put("couponName", "充电减免");
jo.put("coupon_value", freeTime);//卷面值 分钟 | 分
jo.put("appid", appId);//应用编号
jo.put("ts", System.currentTimeMillis() / 1000);//时间戳
jo.put("sign", SignUtils.paramsAnKuaiSign(jo, appSecret));//签名
// 发送 POST 请求并获取响应
String result = HttpUtil.createPost(url)
.body(jo.toString()) // 将 JSON 对象转换为字符串作为请求正文
.header("version", "1.0.0")
.header("Content-Type", "application/json") // 设置请求头,指明内容类型为 JSON
.execute().body(); // 发送请求并获取响应体
//记录到数据库中闸机的流水记录
ym.recordDzLog(order_no, charge_plate_no, jo.toString(), result);
return ResultVO.success(JSONObject.parseObject(result));
}
}
renderJson(CommonUtil.getRet(false, "发现了一个未知的闸机厂商,请联系开发人员!"));
return null;
}
}

@ -11,26 +11,21 @@ import com.jfinal.plugin.activerecord.Record;
import java.util.List;
public class YltModel {
/**
* JWTtoken
*
*
* @param request
* @param orderNo
* @return
*/
public Record getUser(HttpServletRequest request) {
//从Http请求头中获取Authorization
String Authorization = request.getHeader("Authorization");
String secret = JwtUtil.SECRET;
String token = Authorization.replaceFirst(JwtUtil.AUTHORIZATION_STARTER, "");
Claims cs = JwtUtil.getClaimsFromToken(token, secret);
String userId = cs.get("userId", String.class);
String phone = cs.get("phone", String.class);
Record record = new Record();
record.set("userId", userId);
record.set("phone", phone);
public Record getLastUnReportOrderByOrderNoTrack(String orderNo) {
//通过订单号查询订单轨迹
String sql = "select * from t_equipment_charge_order_track where order_no=? order by id desc limit 1;";
Record record = Db.findFirst(sql, orderNo);
return record;
}
/**
* ID
*
@ -38,7 +33,13 @@ public class YltModel {
* @return
*/
public Record getThirdPartyStation(String order_no) {
Record record = getOrderByNo(order_no);
//因为测试库与生产库是两个库,在生产库中产生的订单号,在测试库中是无法获取到的,所以先写死,再考虑与吴缤研究是否可以将
//中东港114
//驿来特充电站西点药业湛江路85
String sql = "select * from t_ext_dz_station where station_id=114";
Record record = Db.findFirst(sql);
//Record record = getOrderByNo(order_no);
if (record == null) {
return null;
}
@ -122,4 +123,5 @@ public class YltModel {
record.set("result", result);
Db.save("t_ext_dz_log", "order_no", record);
}
}

@ -1,6 +1,6 @@
# true 值支持热加载
undertow.devMode=false
undertow.port=8888
undertow.port=9000
undertow.host=0.0.0.0
#undertow.resourcePath=/usr/local/tomcat8/webapps/QingLong,classpath:static
undertow.resourcePath=D:/dsWork/QingLong/WebRoot,classpath:static
Loading…
Cancel
Save