站外充电机

zw
tq 5 months ago
parent 62f78c0079
commit e5b932be78

@ -0,0 +1,22 @@
using System.Text;
using Newtonsoft.Json;
namespace Common.Util;
public static class HttpUtil
{
private static readonly HttpClient httpClient = new HttpClient();
public static async void SendPostRequest<T>(T data, string url)
{
string jsonStr = JsonConvert.SerializeObject(data);
var content = new StringContent(jsonStr, Encoding.UTF8, "application/json");
HttpResponseMessage response = await httpClient.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
await response.Content.ReadAsStringAsync();
}
}
}

@ -60,6 +60,14 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName = "charger_gun_no")]
public string ChargerGunNo { get; set; }
/// <summary>
/// Desc:站外充电枪编号,1枪或2枪
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "out_charger_gun_no")]
public string OutChargerGunNo { get; set; }
/// <summary>
/// 0站内充电 1站外充电
/// </summary>

@ -59,6 +59,14 @@ public class CloudConst
public static readonly string eqmStateEndLogInfoRes = "eqmStateEndLogInfoRes";
public static readonly string chargeDevDataInfo = "chargeDevDataInfo";
public static readonly string chargeDevDataInfoRes = "chargeDevDataInfoRes";
/// <summary>
/// 站外
/// </summary>
public static readonly string pileStartCharge = "pileStartCharge";
public static readonly string pileStartChargeRes = "pileStartChargeRes";
public static readonly string pileStopCharge = "pileStopCharge";
public static readonly string pileRealtimeRes = "pileRealtimeRes";
#endregion
}

@ -0,0 +1,27 @@
using System.Text;
using Common.Util;
using HybirdFrameworkCore.Autofac.Attribute;
using NewLife.Remoting;
using Newtonsoft.Json;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.OutCharger.Req;
namespace Service.Cloud.Handler.OutCharger;
[Scope("InstancePerDependency")]
public class PileStartChargeHandler : IBaseHandler
{
public bool CanHandle(string cmd)
{
return CloudConst.pileStartCharge == cmd;
}
public void Handle(string t)
{
PileStartCharge? pileStartCharge = JsonConvert.DeserializeObject<PileStartCharge>(t);
if (pileStartCharge != null)
{
HttpUtil.SendPostRequest(pileStartCharge, "http://127.0.0.1:5035/api/OutCharger/SendStartOutCharger");
}
}
}

@ -0,0 +1,26 @@
using System.Text;
using Common.Util;
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.OutCharger.Req;
namespace Service.Cloud.Handler.OutCharger;
[Scope("InstancePerDependency")]
public class PileStopChargeHandler : IBaseHandler
{
public bool CanHandle(string cmd)
{
return CloudConst.pileStopCharge == cmd;
}
public void Handle(string t)
{
PileStopCharge? pileStopCharge = JsonConvert.DeserializeObject<PileStopCharge>(t);
if (pileStopCharge != null)
{
HttpUtil.SendPostRequest(pileStopCharge, "http://127.0.0.1:5035/api/OutCharger/SendStartOutCharger");
}
}
}

@ -0,0 +1,50 @@
using Service.Cloud.Common;
namespace Service.Cloud.Msg.Cloud.OutCharger.Req;
/// <summary>
/// 9.2.1.1 云平台下发开始充电操作
/// </summary>
public class PileStartCharge : ICmd
{
/// <summary>
/// 换电站编码
/// 换电站唯一码
/// </summary>
public string sn { get; set; }
/// <summary>
/// 充电订单号
/// 云平台下发的充电订单编号,;当启动模式为本地主动启动(即插即充)时,该 值以 0 填充
/// </summary>
public string con { get; set; }
/// <summary>
/// 充电枪编号
/// 充电枪的唯一标识码
/// </summary>
public string pn { get; set; }
/// <summary>
/// 充电方式
/// 0自动充满为止1按电量
/// </summary>
public int ct { get; set; }
/// <summary>
/// 充电参数
/// 按充电方式判断除0外 电量:单位 kWh精确到 0.01 时间:单位 min精确到 0.01 金额:单位 元,精确到 0.01
/// </summary>
public string cp { get; set; }
/// <summary>
/// 启动类型
/// 0运营平台启动1APP 启动2: 本地启动
/// </summary>
public int st { get; set; }
public string GetCmd()
{
return CloudConst.pileStartCharge;
}
}

@ -0,0 +1,27 @@
using Service.Cloud.Common;
namespace Service.Cloud.Msg.Cloud.OutCharger.Req;
/// <summary>
/// 9.2.17 云端下发充电枪停止充电
/// </summary>
public class PileStopCharge : ICmd
{
/// <summary>
/// 换电站编码
/// 换电站唯一码
/// </summary>
public string sn { get; set; }
/// <summary>
/// 充电枪编号
/// 充电枪的唯一标识码
/// </summary>
public string pn { get; set; }
public string GetCmd()
{
return CloudConst.pileStopCharge;
}
}

@ -0,0 +1,34 @@
using Service.Cloud.Common;
namespace Service.Cloud.Msg.Host.Resp.OutCharger;
/// <summary>
/// 9.2.1.2 站控应答开始充电操作
/// </summary>
public class PileStartChargeResp : ICmd
{
/// <summary>
/// 执行结果
/// </summary>
public string? rs { get; set; }
/// <summary>
/// 充电订单号
/// </summary>
public string? con { get; set; }
/// <summary>
/// 充电枪编号
/// </summary>
public string? pn { get; set; }
/// <summary>
/// 故障码
/// </summary>
public string? ec { get; set; }
public string GetCmd()
{
return CloudConst.pileStartChargeRes;
}
}

@ -0,0 +1,24 @@
using Service.Cloud.Common;
namespace Service.Cloud.Msg.Host.Resp.OutCharger;
/// <summary>
/// 9.2.1.8 站控响应充电枪停止充电操作
/// </summary>
public class PileStopChargeResp : ICmd
{
/// <summary>
/// 充电枪ID
/// 0x01充电枪10x02充电枪20x03双枪充电;(0x00&0xFF无效)
/// </summary>
public string pn { get; set; }
/// <summary>
/// 启动结果 0 成功 1 设备已停机 0xFF 其他
/// </summary>
public string rs { get; set; }
public string GetCmd()
{
return CloudConst.pileRealtimeRes;
}
}

@ -0,0 +1,42 @@
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Cloud.Client;
using Service.Cloud.Msg.Host.Resp.OutCharger;
using Service.Init;
namespace WebStarter.Controllers;
/// <summary>
/// 站外充电机管理
/// </summary>
[Produces("application/json")]
[ApiController]
[Route("api/[controller]")]
public class OutChargerController
{
/// <summary>
/// 9.2.1.2 站控应答开始充电操作
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("ResStartOutCharger")]
public Result<bool> ResStartOutCharger([FromBody] PileStartChargeResp req)
{
CloudClientMgr.CloudClient?.Publish(req);
return Result<bool>.Success(true);
}
/// <summary>
/// 9.2.1.8 站控响应充电枪停止充电操作
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("ResStopOutCharger")]
public Result<bool> ResStopOutCharger([FromBody] PileStopChargeResp req)
{
CloudClientMgr.CloudClient?.Publish(req);
return Result<bool>.Success(true);
}
}

@ -45,3 +45,7 @@ ALTER TABLE swap_order_report_cloud ADD `upload_time` datetime DEFAULT NULL COM
-- 添加入仓时间
ALTER TABLE bin_info ADD `in_time` datetime DEFAULT NULL COMMENT "入仓时间" ;
-- 添加站外充电枪编号
ALTER TABLE charge_order ADD COLUMN out_charger_gun_no VARCHAR(255) COMMENT '站外充电枪编号,1枪或2枪';

Loading…
Cancel
Save