云平台开发

master
smartwyy 6 months ago
parent aec1e0e624
commit 50d25c2699

@ -0,0 +1,167 @@
using SqlSugar;
namespace Entity.DbModel.Station
{
///<summary>
///预约订单表
///</summary>
[SugarTable("amt_order_info")]
public partial class AmtOrderInfo
{
public AmtOrderInfo()
{
}
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public long Id { get; set; }
/// <summary>
/// Desc:换电站编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "sn")]
public string Sn { get; set; }
/// <summary>
/// Desc:车辆编码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "car_no")]
public string CarNo { get; set; }
/// <summary>
/// Desc:预约单号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "order_no")]
public string? OrderNo { get; set; }
/// <summary>
/// Desc:车辆vim码
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "vin")]
public string Vin { get; set; }
/// <summary>
/// Desc:预约电池类型编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "battery_type")]
public string BatteryType { get; set; }
/// <summary>
/// Desc:预约电池编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "battery_nos")]
public string BatteryNos { get; set; }
/// <summary>
/// Desc:预约数量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "batnum")]
public int? Batnum { get; set; }
/// <summary>
/// Desc:预约电池锁仓仓号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "bin_nos")]
public string BinNos { get; set; }
/// <summary>
/// Desc:预约时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "start_time")]
public DateTime? StartTime { get; set; }
/// <summary>
/// Desc:预约到期时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "end_time")]
public DateTime? EndTime { get; set; }
/// <summary>
/// Desc:预约单状态1预约成功2预约取消3预约失败4换电完成5换电失败6换电中7预约过期
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "status")]
public byte? Status { get; set; }
/// <summary>
/// Desc:取消时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "cancel_time")]
public DateTime? CancelTime { get; set; }
/// <summary>
/// Desc:换电完成时间
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "swap_finish_time")]
public DateTime? SwapFinishTime { get; set; }
/// <summary>
/// Desc:换电订单编号
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "swap_order_no")]
public string SwapOrderNo { get; set; }
/// <summary>
/// Desc:创建人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "created_by")]
public string CreatedBy { get; set; }
/// <summary>
/// Desc:创建时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "created_time")]
public DateTime? CreatedTime { get; set; }
/// <summary>
/// Desc:更新人
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "updated_by")]
public string UpdatedBy { get; set; }
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "updated_time")]
public DateTime? UpdatedTime { get; set; }
}
}

@ -47,6 +47,14 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="name")]
public string Name {get;set;}
/// <summary>
/// Desc:在位状态0-不在位1-在位2-无效
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="exists")]
public int? Exists {get;set;}
/// <summary>
/// Desc:电池编号
/// Default:
@ -183,6 +191,14 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="updated_by")]
public string UpdatedBy {get;set;}
/// <summary>
/// Desc:最后结束充电时间 结束充电后更新
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="last_charge_finish_time")]
public DateTime? LastChargeFinishTime {get;set;}
/// <summary>
/// Desc:更新时间
/// Default:CURRENT_TIMESTAMP
@ -191,18 +207,5 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="updated_time")]
public DateTime? UpdatedTime {get;set;}
/// <summary>
/// 电池是否在为
/// 0:不在位 1在位 2无效
/// </summary>
[SugarColumn(ColumnName="exists")]
public int? Exists { get; set; }
/// <summary>
/// 最后结束充电的时间
/// </summary>
[SugarColumn(ColumnName="last_charge_finish_time")]
public DateTime? LastChargeFinishTime { get; set; }
}
}

@ -63,6 +63,22 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="charger_gun_no")]
public string ChargerGunNo {get;set;}
/// <summary>
/// Desc:0站内充电 1站外充电
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="charge_mode")]
public int? ChargeMode {get;set;}
/// <summary>
/// Desc:1站控启动 2本地启动
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="start_mode")]
public int? StartMode {get;set;}
/// <summary>
/// Desc:充电开始时间
/// Default:
@ -101,7 +117,7 @@ namespace Entity.DbModel.Station
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="charge_time_count")]
public string ChargeTimeCount {get;set;}
public int? ChargeTimeCount {get;set;}
/// <summary>
/// Desc:充电电量
@ -111,6 +127,14 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="elec_count")]
public decimal? ElecCount {get;set;}
/// <summary>
/// Desc:交流电表量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_elec_count")]
public decimal? AcElecCount {get;set;}
/// <summary>
/// Desc:充电开始交流表电量
/// Default:
@ -183,6 +207,38 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="valley_elec_count")]
public decimal? ValleyElecCount {get;set;}
/// <summary>
/// Desc:尖时段交流电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_sharp_elec_count")]
public decimal? AcSharpElecCount {get;set;}
/// <summary>
/// Desc:峰时段交流电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_peak_elec_count")]
public decimal? AcPeakElecCount {get;set;}
/// <summary>
/// Desc:平时段交流电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_flat_elec_count")]
public decimal? AcFlatElecCount {get;set;}
/// <summary>
/// Desc:谷时段交流电量
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="ac_valley_elec_count")]
public decimal? AcValleyElecCount {get;set;}
/// <summary>
/// Desc:电价版本号
/// Default:
@ -239,5 +295,13 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName="updated_time")]
public DateTime? UpdatedTime {get;set;}
/// <summary>
/// Desc:云平台充电订单
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName="cloud_sn")]
public string CloudSn {get;set;}
}
}

@ -112,15 +112,66 @@ public class ModbusTcpMaster
return null;
}
public byte[]? BatchRead(int registerNo, int length)
public byte[]? BatchReadHolderRegister(int registerNo, int length)
{
OperateResult<byte[]> result = ModbusTcpNet.Read("x=3;" + registerNo, (ushort)length);
if (result.IsSuccess) return result.Content;
return null;
}
public byte[]? BatchReadInputRegister(int registerNo, int length)
{
OperateResult<byte[]> result = ModbusTcpNet.Read("x=4;" + registerNo, (ushort)length);
if (result.IsSuccess) return result.Content;
return null;
}
/// <summary>
/// 读取线圈,需要指定起始地址,如果富文本地址不指定,默认使用的功能码是 0x01<br />
/// To read the coil, you need to specify the start address. If the rich text address is not specified, the default function code is 0x01.
/// </summary>
/// <param name="address">起始地址,格式为"1234"</param>
/// <returns>带有成功标志的bool对象</returns>
public OperateResult<bool> ReadCoil(string address) => ModbusTcpNet.ReadBool(address);
/// <summary>
/// 批量的读取线圈,需要指定起始地址,读取长度,如果富文本地址不指定,默认使用的功能码是 0x01<br />
/// For batch reading coils, you need to specify the start address and read length. If the rich text address is not specified, the default function code is 0x01.
/// </summary>
/// <param name="address">起始地址,格式为"1234"</param>
/// <param name="length">读取长度</param>
/// <returns>带有成功标志的bool数组对象</returns>
public OperateResult<bool[]> ReadCoil(string address, ushort length)
{
return ModbusTcpNet.ReadBool(address, length);
}
/// <summary>
/// 读取输入线圈,需要指定起始地址,如果富文本地址不指定,默认使用的功能码是 0x02<br />
/// To read the input coil, you need to specify the start address. If the rich text address is not specified, the default function code is 0x02.
/// </summary>
/// <param name="address">起始地址,格式为"1234"</param>
/// <returns>带有成功标志的bool对象</returns>
public OperateResult<bool> ReadDiscrete(string address)
{
return ModbusTcpNet.ReadDiscrete(address);
}
/// <summary>
/// 批量的读取输入点,需要指定起始地址,读取长度,如果富文本地址不指定,默认使用的功能码是 0x02<br />
/// To read input points in batches, you need to specify the start address and read length. If the rich text address is not specified, the default function code is 0x02
/// </summary>
/// <param name="address">起始地址,格式为"1234"</param>
/// <param name="length">读取长度</param>
/// <returns>带有成功标志的bool数组对象</returns>
public OperateResult<bool[]> ReadDiscrete(string address, ushort length)
{
return ModbusTcpNet.ReadDiscrete(address, length);
}
public bool WriteValue<T>(ModbusProperty<T> property)
{
var value = property.Value;

@ -30,6 +30,6 @@ public class ModbusSession
public byte[]? Read(int registerNo, int length)
{
return ModbusTcpMaster.BatchRead(registerNo, length);
return ModbusTcpMaster.BatchReadHolderRegister(registerNo, length);
}
}

@ -0,0 +1,13 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Station;
[Scope("SingleInstance")]
public class AmtOrderInfoRepository : BaseRepository<AmtOrderInfo>
{
public AmtOrderInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
}

@ -18,9 +18,9 @@ public class CloudConst
public static readonly string setStBaseInfo = "setStBaseInfo";
public static readonly string setStBaseInfoRes = "setStBaseInfoRes";
public static readonly string devList = "devList";
public static readonly string setServiceRes = "setServiceRes";
public static readonly string devListRep = "devListRep";
public static readonly string setService = "setService";
public static readonly string setServiceRes = "setServiceRes";
public static readonly string setOpTime = "setOpTime";
public static readonly string setOpTimeRes = "setOpTimeRes";
public static readonly string setOpModel = "setOpModel";

@ -1,16 +1,56 @@
using HybirdFrameworkCore.Autofac.Attribute;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using Newtonsoft.Json;
using Repository.Station;
using Service.Cloud.Common;
using Service.Cloud.Msg.Cloud.Req;
using Service.Cloud.Msg.Host.Resp;
using Service.Execute.Enum;
using Service.Init;
namespace Service.Cloud.Handler;
[Scope("InstancePerDependency")]
public class AmtBatHandler : IBaseHandler
{
private BinInfoRepository _binInfoRepository;
private AmtOrderInfoRepository _amtOrderInfoRepository;
public AmtBatHandler(BinInfoRepository binInfoRepository, AmtOrderInfoRepository amtOrderInfoRepository)
{
_binInfoRepository = binInfoRepository;
_amtOrderInfoRepository = amtOrderInfoRepository;
}
public void Handle(string t)
{
AmtBatRes abRes = new AmtBatRes();
abRes.rs = 3;
AmtBat? amtBat = JsonConvert.DeserializeObject<AmtBat>(t);
if (amtBat != null)
{
int count = _amtOrderInfoRepository.GetCount(it =>
it.CarNo == amtBat.cn && it.Status == (byte)InfoEnum.AmtOrderStatus.Success);
if (count > 0)
{
abRes.rs = 1;
}
else
{
AmtOrderInfo amtOrderInfo = new AmtOrderInfo()
{
Sn = StaticStationInfo.StationNo,
CarNo = amtBat.cn,
Batnum = amtBat.bm,
BatteryType = amtBat.bn,
StartTime = amtBat.at,
EndTime = amtBat.at.AddMinutes(amtBat.am)
};
}
}
}
public bool CanHandle(string cmd)

@ -4,11 +4,29 @@ namespace Service.Cloud.Msg.Cloud.Req;
public class AmtBat : ICmd
{
/// <summary>
/// station no
/// </summary>
public string sn { get; set; }
/// <summary>
/// car no
/// </summary>
public string cn { get; set; }
/// <summary>
/// 电池型号编号
/// </summary>
public string bn { get; set; }
/// <summary>
/// battery count
/// </summary>
public int bm { get; set; }
/// <summary>
/// 预约时间
/// </summary>
public DateTime at { get; set; }
/// <summary>
/// 锁定时长 单位:分钟
/// </summary>
public int am { get; set; }
public string GetCmd()
{

@ -10,7 +10,7 @@ namespace Service.Cloud.Msg.Cloud.Req
/// <summary>
/// 3.2.3.1 后台服务器下发换电站的基础信息
/// </summary>
public class DeliverBasicInformation
public class SetStBaseInfo
{
/// <summary>
/// 电站编码

@ -4,6 +4,9 @@ namespace Service.Cloud.Msg.Host.Resp;
public class AmtBatRes : ICmd
{
/// <summary>
/// 1:预约电池失败; 2:换电站无电池可预约; 3:预约成功;
/// </summary>
public int rs { get; set; }
public string GetCmd()

@ -10,7 +10,7 @@ namespace Service.Cloud.Msg.Host.Resp
/// <summary>
/// 3.2.5.2 换电站应答后台服务器下发换电站的可服务状态设置
/// </summary>
public class ServiceableStateResp
public class SetServiceRes
{
/// <summary>
/// 应答结果

@ -10,7 +10,7 @@ namespace Service.Cloud.Msg.Host.Resp
/// <summary>
/// 3.2.3.2 换电站应答后台服务器下发换电站的基础信息
/// </summary>
public class DeliverBasicInformationResp
public class SetStBaseInfoRes
{
/// <summary>
/// 应答结果

@ -81,13 +81,13 @@ namespace Service
PlcStaticInfo.PlcInfos.TryGetValue(sn, out PlcInfo plcInfo);
if (plcInfo != null)
{
var bytes01 = master.BatchRead(1, 115);
var bytes01 = master.BatchReadHolderRegister(1, 115);
if (bytes01 != null)
{
ModbusDecoder.Decode<HostToPlc>(bytes01, plcInfo.hostToPlc);
}
var bytes02 = master.BatchRead(201, 222);
var bytes02 = master.BatchReadHolderRegister(201, 222);
if (bytes02 != null)
{
ModbusDecoder.Decode<PlcToHost>(bytes02, plcInfo.plcToHost);
@ -129,7 +129,7 @@ namespace Service
#endregion
}
var bytes03 = master.BatchRead(701, 10);
var bytes03 = master.BatchReadHolderRegister(701, 10);
if (bytes03 != null)
{
ModbusDecoder.Decode<PlcFault>(bytes03, plcInfo.plcFault);

@ -1,5 +1,4 @@
using Autofac;
using Entity.Constant;
using HybirdFrameworkCore.Autofac;
using Service.Station;
using Service.System;

@ -204,6 +204,7 @@ namespace Service.System
string newValue = Convert.ToString(value);
Dictionary.AddOrUpdate(key, newValue, (s, s1) => newValue);
redisHelper.SetKeyValueStr(key, newValue);
SysConfig sysConfig = _sysConfigRep.QueryByClause(i => i.GroupCode == keys[0] && i.Code == keys[1]);
if (sysConfig == null)

Loading…
Cancel
Save