main^2
黄海 11 months ago
parent c1ea714544
commit 6bf82e50e2

@ -0,0 +1,8 @@
package com.dsideal.ZhuQue.Test;
public class TestKeTuo {
public static void main(String[] args) {
}
}

@ -797,6 +797,10 @@ public class CommonUtil {
dictList.add(record);
return getRet(dictList, success, message);
}
public static Kv getRet(boolean success, String message) {
List<Record> dictList = new ArrayList<>();
return getRet(dictList, success, message);
}
public static Kv getRet(List<Record> dictList, boolean success, String message) {
Kv kv = Kv.by("code", 1000);

@ -1,5 +1,8 @@
package com.dsideal.ZhuQue.Ylt.Controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.dsideal.ZhuQue.Interceptor.IsLoginInterface;
import com.dsideal.ZhuQue.Util.CommonUtil;
import com.dsideal.ZhuQue.Ylt.Model.YltModel;
@ -7,14 +10,20 @@ import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.Record;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class YltController extends Controller {
YltModel ym = new YltModel();
private static Logger log = LoggerFactory.getLogger(YltController.class);
public List<Record> getAll() {
List<Record> list = new ArrayList<>();
@ -97,4 +106,104 @@ public class YltController extends Controller {
record.set("phone", phone);
renderJson(CommonUtil.getRet(record, true, "保存成功!"));
}
/**
* :
*/
//@Before({POST.class})
//@IsLoginInterface({})
// 非指定闸机场地
// http://10.10.21.20:8888/ZhuQue/Ylt/SyncChargePilePay?order_id=1
// 科拓闸机场地
// http://10.10.21.20:8888/ZhuQue/Ylt/SyncChargePilePay?order_id=248933
public void SyncChargePilePay(int order_id) {
//根据订单号获取到第三方方面提供的车场信息
Record thirdPartyStation = ym.getThirdPartyStation(order_id);
if (thirdPartyStation == null) {
Record record = new Record();
renderJson(CommonUtil.getRet(record, false, "检查到不是需要免费的道闸所在车场,无需发送减免消息!!"));
return;
}
//请求地址
String url = thirdPartyStation.getStr("third_party_url");
//与科拓对接对方平台分配的我司平台ID
String appId = thirdPartyStation.getStr("third_party_appId");
//与科拓对接,对方平台分配的我司平台秘钥
String key = thirdPartyStation.getStr("third_party_key");
//闸机提供商
String name = thirdPartyStation.getStr("third_party_name");
//闸机所在车场ID
int parkId = thirdPartyStation.getInt("third_party_station_id");
log.info("发现闸机提供商:" + name + ",parkId=" + parkId);
//订单信息
Record dingDanRecord = ym.getOrderById(order_id);
String charge_plate_no = dingDanRecord.getStr("charge_plate_no");//车牌号
String charge_begin_time = dingDanRecord.getStr("charge_begin_time");//充电开始时间
String charge_end_time = dingDanRecord.getStr("charge_end_time");//充电结束时间
int stationId = dingDanRecord.getInt("station_id");//电站ID
//获取车场名称
String stationName = ym.getStationById(String.valueOf(stationId)).getStr("station_name");
//设备号
int deviceId = dingDanRecord.getInt("equipment_id");//充电桩ID
//充电桩名称
String deviceName = ym.getEquipmentById(deviceId).getStr("equipment_name");
//车位号
String spaceNo = dingDanRecord.getInt("connector_id").toString();
//充电量
String power = dingDanRecord.getDouble("charge_ah").toString();
//电费
int elecMoney = (int) (dingDanRecord.getDouble("receivable_electric_fee") * 100);
//服务费
int seviceMoney = (int) (dingDanRecord.getDouble("receivable_service_fee") * 100);
//总费用
int totalMoney = (int) (dingDanRecord.getDouble("receivable_total_fee") * 100);
//本地车场配置减免规则,根据充电时长换算
int freeType = 1;
int freeMoney = 0;//免费0元
int freeTime = 2 * 60 * 60;//2小时
//
if ("科拓".equals(name)) {
JSONObject jo = new JSONObject();
jo.put("appId", appId);
jo.put("key", key);
jo.put("parkId", parkId);
jo.put("serviceCode", "syncChargePilePay");
// 获取当前时间戳
long timestamp = System.currentTimeMillis();
jo.put("ts", timestamp);//每次请求附带当前时间戳(格林威治时间1970年01月01日00时00分00秒起至现在的总毫秒数)超过10S请求失效
jo.put("reqId", UUID.randomUUID().toString().toUpperCase());//每次请求的唯一标识如果是异步接口异步响应消息的reqId会与原请求的reqId一致。每次请求必须唯一
jo.put("orderNo", String.valueOf(order_id));//订单号
jo.put("plateNo", charge_plate_no);//车牌号
jo.put("startTime", charge_begin_time);//开始时间
jo.put("endTime", charge_end_time);//结束时间
jo.put("stationId", stationId);//电站ID
jo.put("stationName", stationName);//电站名称
jo.put("deviceId", deviceId);//充电桩ID
jo.put("deviceName", deviceName);//充电桩名称
jo.put("spaceNo", spaceNo);//位置ID
jo.put("power", power);//充电量
jo.put("elecMoney", elecMoney);//电费
jo.put("seviceMoney", seviceMoney);//服务费
jo.put("totalMoney", totalMoney);//总费用
jo.put("freeType", freeType);
jo.put("freeMoney", freeMoney);
jo.put("freeTime", freeTime);
jo.put("version","v6.x");//请求头版本号
// 发送 POST 请求并获取响应
String result = HttpUtil.createPost(url)
.body(jo.toString()) // 将 JSON 对象转换为字符串作为请求正文
.header("Content-Type", "application/json") // 设置请求头,指明内容类型为 JSON
.execute().body(); // 发送请求并获取响应体
// 打印结果
System.out.println(result);
renderJson(CommonUtil.getRet(new Record(), true,
"已经向科拓闸机平台发送了减免消息!"));
return;
}
renderJson(CommonUtil.getRet(new Record(), false,
"发现了一个未知的闸机厂商,请联系开发人员!"));
}
}

@ -1,6 +1,7 @@
package com.dsideal.ZhuQue.Ylt.Model;
import com.dsideal.ZhuQue.Util.JwtUtil;
import com.jfinal.plugin.activerecord.Db;
import io.jsonwebtoken.Claims;
import javax.servlet.http.HttpServletRequest;
@ -27,4 +28,68 @@ public class YltModel {
record.set("phone", phone);
return record;
}
/**
* ID
*
* @param order_id
* @return
*/
public Record getThirdPartyStation(int order_id) {
Record record = getOrderById(order_id);
if (record == null) {
return null;
}
int station_id = record.getInt("station_id");
Record stationRecord = getKtStation(station_id);
return stationRecord;
}
/**
* ID
*
* @param order_id
* @return
*/
public Record getOrderById(int order_id) {
String sql = "select * from t_equipment_charge_order where id=?";
Record record = Db.findFirst(sql, order_id);
return record;
}
/**
* ID
*
* @param station_id
* @return
*/
public Record getKtStation(int station_id) {
String sql = "select * from t_ext_ketuo_station where station_id=?";
Record record = Db.findFirst(sql, station_id);
return record;
}
/**
* ID
*
* @param station_id
* @return
*/
public Record getStationById(String station_id) {
String sql = "select * from t_station where id=?";
Record record = Db.findFirst(sql, station_id);
return record;
}
/**
*
*
* @param equipment_id
* @return
*/
public Record getEquipmentById(int equipment_id) {
String sql = "select * from t_equipment where id=?";
Record record = Db.findFirst(sql, equipment_id);
return record;
}
}

@ -3,8 +3,8 @@ driverClassName=com.mysql.jdbc.Driver
user=root
password=DsideaL147258369
jdbcUrl=jdbc:mysql://10.10.14.210:22066/yltcharge?useUnicode=true&characterEncoding=GBK&useSSL=false
# redis
redis_ip=10.10.14.210
redis_port=6379
redis_password=ylt#redis

Loading…
Cancel
Save