diff --git a/Entity/Api/Req/SetSwitchingOperaModeReq.cs b/Entity/Api/Req/SetSwitchingOperaModeReq.cs index 7fd4296..955b7ca 100644 --- a/Entity/Api/Req/SetSwitchingOperaModeReq.cs +++ b/Entity/Api/Req/SetSwitchingOperaModeReq.cs @@ -5,5 +5,5 @@ public class SetSwitchingOperaModeReq /// /// 换电运营模式:1:自动;2:手动 /// - public int SwapType { get; set; } + public int SwapWay { get; set; } } \ No newline at end of file diff --git a/Entity/Api/Req/StationConfigReq.cs b/Entity/Api/Req/StationConfigReq.cs new file mode 100644 index 0000000..5010d72 --- /dev/null +++ b/Entity/Api/Req/StationConfigReq.cs @@ -0,0 +1,39 @@ +namespace Entity.Api.Req; + +public class StationConfigReq +{ + /// + /// 换电soc + /// + public int SwapSoc { get; set; } + + /// + /// 充电运营模式:/// 0-关闭 1-开启 + /// + public byte AutoChargeEnabled { get; set; } + + + /// + /// 换电运营模式:1-自动 2-手动 + /// + public int StationWay { get; set; } + + /// + /// 电价模型板 版本号 + /// + public int Ceid { get; set; } + + /// + /// 运营版本号 + /// + /// + public string Oid { get; set; } + + /// + /// 选包策略: 充电结束时间大于SwapFinishChargeTime分钟的可以被选包 + /// + /// + public int SwapFinishChargeTime { get; set; } + + public int StationStatus { get; set; } +} \ No newline at end of file diff --git a/Entity/Api/Resp/BaseSetStationConfigInfo.cs b/Entity/Api/Resp/BaseSetStationConfigInfo.cs deleted file mode 100644 index 6cbb07c..0000000 --- a/Entity/Api/Resp/BaseSetStationConfigInfo.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace Entity.Api.Resp; - -public class BaseSetStationConfigInfo -{ - /// - /// 灯光日间时间:开始时间 - /// - public string LigthStartTime { get; set; } - /// - /// 灯光日间时间:结束时间 - /// - public string LigthEndTime { get; set; } - /// - /// 换电策略:换电标准Soc - /// - public int SetSwapSoc { get; set; } - /// - /// 换电策略:充电标准Soc - /// - public int SetFullSoc { get; set; } - /// - /// 营业时间:开始时间 - /// - public string BusinessStartHours { get; set; } - /// - /// 营业时间:结束时间 - /// - public string BusinessEndHours{ get; set; } - /// - /// 充电运营模式:0-手动 1-自动 - /// - public int ChargeType{ get; set; } - /// - /// 换电运营模式:1-自动 2-手动 - /// - public int SwapType{ get; set; } - /// - /// 电价模型板 版本号 0-数据库不存在 尖峰平谷版本 - /// - public int Version{ get; set; } -} \ No newline at end of file diff --git a/Entity/Api/Resp/StationBaseInfoResp.cs b/Entity/Api/Resp/StationBaseInfoResp.cs index 35f35e4..3cb5e8d 100644 --- a/Entity/Api/Resp/StationBaseInfoResp.cs +++ b/Entity/Api/Resp/StationBaseInfoResp.cs @@ -62,7 +62,7 @@ namespace Entity.Api.Resp /// /// 换电站状态: 1:营运中 2:歇业中 3:设备维护状态 4:暂停营业 /// - public sbyte Status { get; set; } + public int StationStatus { get; set; } /// /// 投放时间 /// diff --git a/Entity/Api/Resp/StationConfigResp.cs b/Entity/Api/Resp/StationConfigResp.cs new file mode 100644 index 0000000..2a2e309 --- /dev/null +++ b/Entity/Api/Resp/StationConfigResp.cs @@ -0,0 +1,40 @@ +namespace Entity.Api.Resp; + +public class StationConfigResp +{ + /// + /// 换电soc + /// + public int SwapSoc { get; set; } + + /// + /// 充电运营模式:/// 0-关闭 1-开启 + /// + public byte AutoChargeEnabled { get; set; } + + + /// + /// 换电运营模式:1-自动 2-手动 + /// + public int StationWay { get; set; } + + /// + /// 电价模型板 版本号 + /// + public int Ceid { get; set; } + + /// + /// 运营版本号 + /// + /// + public string Oid { get; set; } + + /// + /// 选包策略: 充电结束时间大于SwapFinishChargeTime分钟的可以被选包 + /// + /// + public int SwapFinishChargeTime { get; set; } + + + public int StationStatus { get; set; } +} \ No newline at end of file diff --git a/Entity/Constant/StationParamConst.cs b/Entity/Constant/StationParamConst.cs index 35921d5..bdd1f9b 100644 --- a/Entity/Constant/StationParamConst.cs +++ b/Entity/Constant/StationParamConst.cs @@ -64,10 +64,7 @@ public class StationParamConst /// public static readonly string Sevstatus = "Station.Sevstatus"; - /// - /// 换电站状态: 1:营运中 2:歇业中 3:设备维护状态 4:暂停营业 - /// - public static readonly string Status = "Station.Status"; + /// /// 投放时间 @@ -185,18 +182,8 @@ public class StationParamConst //提交灯光日间时间 public static readonly string SetLightDayStartTime = "Station.LightDayStartTime"; public static readonly string SetLightDayEndTime = "Station.LightDayEndTime"; - //换电策略设置:换电标准SOC - public static readonly string SetSwapSoc = "Station.SwapSoc"; - //换电策略设置:充电标准SOC - public static readonly string SetFullSoc = "Station.FullSoc"; - //充电运营模式: 0:手动充电;1:自动充电 - public static readonly string ChargeType = "Station.ChargeType"; - //换电运营模式:1:自动;2:手动 - public static readonly string SwapType = "Station.SwapType"; - //营业时间:开始时间 - public static readonly string BusinessStartHours = "Station.BusinessStartHours"; - //营业时间:结束时间 - public static readonly string BusinessEndHours = "Station.BusinessEndHours"; + + #endregion 系统管理-基础设置 @@ -212,7 +199,9 @@ public class StationParamConst public static readonly string ChargePower = "Station.ChargePower"; public static readonly string AutoChargeEnabled = "Station.AutoChargeEnabled"; public static readonly string Eid = "Station.Eid"; + //运营模型 public static readonly string Oid = "Station.Oid"; + //电价模型 public static readonly string Ceid = "Station.Ceid"; public static readonly string StationStatus = "Station.StationStatus"; diff --git a/Repository/Station/BinInfoRepository.cs b/Repository/Station/BinInfoRepository.cs index 816a277..ddba4a1 100644 --- a/Repository/Station/BinInfoRepository.cs +++ b/Repository/Station/BinInfoRepository.cs @@ -19,7 +19,7 @@ public class BinInfoRepository : BaseRepository /// StaticStationInfo.SwapSoc /// StaticStationInfo.SwapFinishChargeTime /// - public SelectPackDto SelectPack(string swapSoc, string swapFinishChargeTime) + public SelectPackDto SelectPack(int swapSoc, int swapFinishChargeTime) { SelectPackDto selectPackDto = new() { @@ -44,7 +44,7 @@ public class BinInfoRepository : BaseRepository } - list = list.Where(i => i.Soc != null && i.Soc > int.Parse(swapSoc)).ToList(); + list = list.Where(i => i.Soc != null && i.Soc > swapSoc).ToList(); if (list.Count <= 0 && cacheBinBattery == null) { selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOfSoc; @@ -53,7 +53,7 @@ public class BinInfoRepository : BaseRepository list = list.Where(i => i.LastChargeFinishTime != null && new TimeSpan(DateTime.Now.Ticks - i.LastChargeFinishTime.ToDateTime().Ticks) - .TotalMinutes > int.Parse(swapFinishChargeTime)).ToList(); + .TotalMinutes > swapFinishChargeTime).ToList(); if (list.Count <= 0 && cacheBinBattery == null) { selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOf3Minute; diff --git a/Service/Cloud/Handler/ParameterAcquisitionHandler.cs b/Service/Cloud/Handler/ParameterAcquisitionHandler.cs index 262013f..18a67d9 100644 --- a/Service/Cloud/Handler/ParameterAcquisitionHandler.cs +++ b/Service/Cloud/Handler/ParameterAcquisitionHandler.cs @@ -22,7 +22,7 @@ public class ParameterAcquisitionHandler : IBaseHandler if (req != null) { ParameterAcquisitionResp resp = new ParameterAcquisitionResp(); - resp.chsoc = Char.Parse(StaticStationInfo.SwapSoc); + resp.chsoc = Convert.ToChar(StaticStationInfo.SwapSoc); resp.eid = StaticStationInfo.Eid; resp.oid = StaticStationInfo.Oid; resp.ceid = StaticStationInfo.Ceid; diff --git a/Service/Cloud/Handler/SetConfigurationParametersHandler.cs b/Service/Cloud/Handler/SetConfigurationParametersHandler.cs index d9bb61d..5e0127c 100644 --- a/Service/Cloud/Handler/SetConfigurationParametersHandler.cs +++ b/Service/Cloud/Handler/SetConfigurationParametersHandler.cs @@ -22,7 +22,7 @@ public class SetConfigurationParametersHandler : IBaseHandler if (setConfigurationParameters != null) { char chsoc = setConfigurationParameters.chsoc; - StaticStationInfo.SwapSoc = chsoc.ToString(); + StaticStationInfo.SwapSoc = chsoc.ToInt(); StaticStationInfo.Eid = setConfigurationParameters.eid; StaticStationInfo.Oid = setConfigurationParameters.oid; StaticStationInfo.Ceid = setConfigurationParameters.ceid; diff --git a/Service/Execute/Mgr/CommonMgr.cs b/Service/Execute/Mgr/CommonMgr.cs index 4f8de43..146960b 100644 --- a/Service/Execute/Mgr/CommonMgr.cs +++ b/Service/Execute/Mgr/CommonMgr.cs @@ -132,8 +132,8 @@ public class CommonMgr && UpBin.AmtLock == (int)InfoEnum.AmtBatLockStatus.Lock && new TimeSpan(DateTime.Now.Ticks - UpBin.LastChargeFinishTime.ToDateTime() .Ticks) - .TotalMinutes > int.Parse(StaticStationInfo.SwapFinishChargeTime) && - UpBin.Soc > int.Parse(StaticStationInfo.SwapSoc); + .TotalMinutes > StaticStationInfo.SwapFinishChargeTime && + UpBin.Soc > StaticStationInfo.SwapSoc; if (!CanSwap) { orderBatteryInfo.CanSwap = InfoEnum.SelectBinStatusInfo.AmtError; diff --git a/Service/Init/StaticStationInfo.cs b/Service/Init/StaticStationInfo.cs index af82bea..e8adfbb 100644 --- a/Service/Init/StaticStationInfo.cs +++ b/Service/Init/StaticStationInfo.cs @@ -11,62 +11,65 @@ namespace Service.Init; /// public class StaticStationInfo { - - public static int StationStatus { get => int.Parse(Resolve(StationParamConst.StationStatus)); set => Set(StationParamConst.StationStatus, value); } + public static string OperationStartTime { get => Resolve(StationParamConst.OperationStartTime); set => Set(StationParamConst.OperationStartTime, value); } + public static string OperationEndTime { get => Resolve(StationParamConst.OperationEndTime); set => Set(StationParamConst.OperationEndTime, value); } + public static int StationWay { get => int.Parse(Resolve(StationParamConst.StationWay)); set => Set(StationParamConst.StationWay, value); } + public static int StationModel { - get =>int.Parse( Resolve(StationParamConst.StationModel)); + get => int.Parse(Resolve(StationParamConst.StationModel)); set => Set(StationParamConst.StationModel, value); } - + + public static string StationName { get => Resolve(StationParamConst.StationName); set => Set(StationParamConst.StationName, value); } - public static string StationNo { get => Resolve(StationParamConst.StationNo); set => Set(StationParamConst.StationNo, value); } + public static string StationSn { get => Resolve(StationParamConst.StationSn); set => Set(StationParamConst.StationSn, value); } - - public static string SwapFinishChargeTime + + public static int SwapFinishChargeTime { - get => Resolve(StationParamConst.SwapFinishChargeTime); + get => int.Parse(Resolve(StationParamConst.SwapFinishChargeTime)); set => Set(StationParamConst.SwapFinishChargeTime, value); } - - public static string SwapSoc + + public static int SwapSoc { - get => Resolve(StationParamConst.SwapSoc); + get => int.Parse(Resolve(StationParamConst.SwapSoc)); set => Set(StationParamConst.SwapSoc, value); } @@ -78,24 +81,30 @@ public class StaticStationInfo set => Set(StationParamConst.Eid, value); } + /// + /// 运营版本号 + /// + public static string Oid { get => Resolve(StationParamConst.Oid); set => Set(StationParamConst.Oid, value); } + public static int Ceid { get => int.Parse(Resolve(StationParamConst.Ceid)); set => Set(StationParamConst.Ceid, value); } - public static byte ChargeSoc + public static byte ChargeSoc { get => byte.Parse(Resolve(StationParamConst.ChargeSoc)); set => Set(StationParamConst.ChargeSoc, value); } - + + public static float ChargePower { get => float.Parse(Resolve(StationParamConst.ChargePower)); @@ -110,10 +119,8 @@ public class StaticStationInfo get => byte.Parse(Resolve(StationParamConst.AutoChargeEnabled)); set => Set(StationParamConst.AutoChargeEnabled, value); } - #endregion - #region cloud @@ -133,6 +140,7 @@ public class StaticStationInfo { return 33000; } + return int.Parse(port); } set => Set(StationParamConst.CloudServerPort, value); diff --git a/Service/Station/MonitorService.cs b/Service/Station/MonitorService.cs index e8ec5d5..ba00688 100644 --- a/Service/Station/MonitorService.cs +++ b/Service/Station/MonitorService.cs @@ -69,11 +69,11 @@ public class MonitorService BatteryTotalCount = binInfos.Count, UsingSwapBatteryCount = binInfos.Select(i => i.ChargeStatus == 2 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock && - i.Soc > int.Parse(StaticStationInfo.SwapSoc) && + i.Soc > StaticStationInfo.SwapSoc && new TimeSpan(DateTime.Now.Ticks - i.LastChargeFinishTime.ToDateTime().Ticks) .TotalMinutes > - int.Parse(StaticStationInfo.SwapFinishChargeTime)).Count() + StaticStationInfo.SwapFinishChargeTime).Count() } }; diff --git a/WebStarter/Controllers/BasicConfig/BaseConfigController.cs b/WebStarter/Controllers/BasicConfig/BaseConfigController.cs index f46c424..17f2805 100644 --- a/WebStarter/Controllers/BasicConfig/BaseConfigController.cs +++ b/WebStarter/Controllers/BasicConfig/BaseConfigController.cs @@ -10,6 +10,7 @@ using Entity.DbModel.System.SysBaseObject; using HybirdFrameworkCore.Entity; using Microsoft.VisualBasic; using Newtonsoft.Json.Linq; +using Service.Init; using Service.Station; using Service.System; @@ -133,105 +134,44 @@ namespace WebStarter.Controllers.BasicConfig /// /// 获取换电策略设置 、灯光日间时间、充电运营模式、营业时间段、换电运营模式 /// - [HttpPost("BaseSetStationConfigInfo")] - public async Task> BaseSetStationConfigInfo() + [HttpPost("StationBaseConfig")] + public async Task> StationBaseConfig() { - BaseSetStationConfigInfo stationBaseInfoResp = new BaseSetStationConfigInfo(); - List sysConfigs = await _sysConfigService.GetGroupList("Station"); - foreach (var item in sysConfigs) - { - switch (item.Code) - { - case "LightDayStartTime": - stationBaseInfoResp.LigthStartTime = item.Value; - break; - case "LightDayEndTime": - stationBaseInfoResp.LigthEndTime = item.Value; - break; - case "SwapSoc": - stationBaseInfoResp.SetSwapSoc = Convert.ToInt32(item.Value); - break; - case "FullSoc": - stationBaseInfoResp.SetFullSoc = Convert.ToInt32(item.Value); - break; - case "ChargeType": - stationBaseInfoResp.ChargeType = Convert.ToInt32(item.Value); - break; - case "SwapType": - stationBaseInfoResp.SwapType = Convert.ToInt32(item.Value); - break; - case "BusinessStartHours": - stationBaseInfoResp.BusinessStartHours = item.Value; - break; - case "BusinessEndHours": - stationBaseInfoResp.BusinessEndHours = item.Value; - break; - } - } + StationConfigResp stationBaseRespResp = new StationConfigResp(); - stationBaseInfoResp.Version = await _elecPriceModelVersionService.GetNowVersion(); - return Result.Success(stationBaseInfoResp); - } + stationBaseRespResp.SwapSoc = StaticStationInfo.SwapSoc; - /// - /// 提交换电策略设置 - /// - /// - /// - [HttpPost("SetReplacementStrategy")] - public async Task> SetReplacementStrategy([FromBody] SetReplacementStrategyReq input) - { - bool setResult = SetConfigPorperty(input); - return Result.Success(setResult); - } + stationBaseRespResp.SwapFinishChargeTime = StaticStationInfo.SwapFinishChargeTime; - /// - /// 日间时间设置 - /// - [HttpPost("SetDaytime")] - public async Task> SetDaytime([FromBody] SetDayTimeReq input) - { - bool setResult = SetConfigPorperty(input); - return Result.Success(setResult); - } + stationBaseRespResp.StationWay = StaticStationInfo.StationWay; - /// - /// 充电运营模式 0:手动充电;1:自动充电 - /// - /// - /// - [HttpPost("SetChargingOperationMode")] - public async Task> SetChargingOperationMode([FromBody] SetChargingOperationModeReq input) - { - bool setResult = SetConfigPorperty(input); - return Result.Success(setResult); - } + stationBaseRespResp.Ceid = StaticStationInfo.Ceid; + stationBaseRespResp.AutoChargeEnabled = StaticStationInfo.AutoChargeEnabled; + stationBaseRespResp.Oid = StaticStationInfo.Oid; + stationBaseRespResp.StationStatus = StaticStationInfo.StationStatus; - /// - /// 营业时间设置 - /// - /// - /// - [HttpPost("SetBusinessHours")] - public async Task> SetBusinessHours([FromBody] SetBusinessHoursReq input) - { - bool setResult = SetConfigPorperty(input); - return Result.Success(setResult); + return Result.Success(stationBaseRespResp); } + /// - /// 换电运营模式:1:自动;2:手动 + /// 提交换电策略设置 /// /// /// - [HttpPost("SetSwitchingOperaModeReq")] - public async Task> SetSwitchingOperationMode([FromBody] SetSwitchingOperaModeReq input) + [HttpPost("SetStationConfig")] + public async Task> SetStationConfig([FromBody] StationConfigReq input) { - bool setResult = SetConfigPorperty(input); - return Result.Success(setResult); + StaticStationInfo.SwapSoc = input.SwapSoc; + StaticStationInfo.StationStatus = input.StationStatus; + StaticStationInfo.SwapFinishChargeTime = input.SwapFinishChargeTime; + + StaticStationInfo.AutoChargeEnabled = input.AutoChargeEnabled; + return Result.Success(); } + /// /// 查询电价信息 /// @@ -248,12 +188,13 @@ namespace WebStarter.Controllers.BasicConfig elecPriceModelVersionDetailResps.Add(new ElecPriceModelVersionDetailResp() { Version = item.Version, - StartTime = new TimeSpan(item.StartHour,item.StartMinute,item.StartSecond), - EndTime = new TimeSpan(item.EndHour,item.EndMinute,item.EndSecond), + StartTime = new TimeSpan(item.StartHour, item.StartMinute, item.StartSecond), + EndTime = new TimeSpan(item.EndHour, item.EndMinute, item.EndSecond), Price = item.Price, Type = item.Price }); } + return Result>.Success(elecPriceModelVersionDetailResps); } @@ -263,13 +204,14 @@ namespace WebStarter.Controllers.BasicConfig /// /// [HttpPost("AddStationElecPriceInfoList")] - public async Task> AddStationElecPriceInfoList([FromBody] List model) + public async Task> AddStationElecPriceInfoList( + [FromBody] List model) { if (null == model || model.Count == 0) { Result.Fail("参数不能为空"); } - + List elecPriceModelVersionDetails = new List(); foreach (var item in model) { @@ -286,12 +228,13 @@ namespace WebStarter.Controllers.BasicConfig Type = item.Type }); } - - List modelFromDbs = await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version); + + List modelFromDbs = + await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version); if (modelFromDbs != null) { modelFromDbs.AddRange(elecPriceModelVersionDetails); - if ( TimeListIfContains(modelFromDbs)) + if (TimeListIfContains(modelFromDbs)) { await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails); return Result.Success(true); @@ -300,26 +243,28 @@ namespace WebStarter.Controllers.BasicConfig return Result.Fail("时间区间重复请检查"); } - + /// /// 更新电价信息 /// /// /// [HttpPost("UpdateStationElecPriceInfoList")] - public async Task> UpdateStationElecPriceInfoList([FromBody] List model) + public async Task> UpdateStationElecPriceInfoList( + [FromBody] List model) { if (null == model || model.Count == 0) { Result.Fail("参数不能为空"); } - - List modelFromDbs = await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version); + + List modelFromDbs = + await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == model[0].Version); if (modelFromDbs != null) { await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version == model[0].Version); } - + List elecPriceModelVersionDetails = new List(); foreach (var item in model) { @@ -337,11 +282,12 @@ namespace WebStarter.Controllers.BasicConfig }); } - if ( TimeListIfContains(elecPriceModelVersionDetails)) + if (TimeListIfContains(elecPriceModelVersionDetails)) { await _elecPriceModelVersionDetailServices.InsertAsync(elecPriceModelVersionDetails); return Result.Success(true); } + return Result.Fail("时间区间重复请检查"); } diff --git a/WebStarter/Controllers/SwapMonitorController.cs b/WebStarter/Controllers/SwapMonitorController.cs index 60d7598..7102d55 100644 --- a/WebStarter/Controllers/SwapMonitorController.cs +++ b/WebStarter/Controllers/SwapMonitorController.cs @@ -214,4 +214,16 @@ public class SwapMonitorController : ControllerBase StaticStationInfo.StationWay = (int)StationConstant.StationWay.Auto; return Result.Success(); } + + /// + /// 切换成 营业状态 + /// 换电站状态: 1:营运中 2:歇业中 3:设备维护状态 4:暂停营业 + /// + [HttpPost("HandoverStationStatus/{status}")] + public Result HandoverStationStatus(int status) + { + StaticStationInfo.StationStatus = status; + + return Result.Success(); + } } \ No newline at end of file diff --git a/WebStarter/Controllers/System/SysConfigController.cs b/WebStarter/Controllers/System/SysConfigController.cs index c852e3a..6b7572d 100644 --- a/WebStarter/Controllers/System/SysConfigController.cs +++ b/WebStarter/Controllers/System/SysConfigController.cs @@ -16,6 +16,7 @@ using Service.System; using SqlSugar; using System.ComponentModel.DataAnnotations; using System.Reflection; +using Service.Init; namespace WebStarter.Controllers.System { @@ -113,7 +114,7 @@ namespace WebStarter.Controllers.System case "Operatetionstime": stationBaseInfoResp.Operatetionstime = item.Value; break; case "Sevstatus": stationBaseInfoResp.Sevstatus = Convert.ToSByte(item.Value); break; case "Operatetionetime": stationBaseInfoResp.Operatetionetime = item.Value; break; - case "Status": stationBaseInfoResp.Status = Convert.ToSByte(item.Value); break; + case "StationStatus": stationBaseInfoResp.StationStatus = StaticStationInfo.StationStatus; break; case "LaunchTime": stationBaseInfoResp.LaunchTime = item.Value; break; case "ContactWay": stationBaseInfoResp.ContactWay = item.Value; break; case "Principal": stationBaseInfoResp.Principal = item.Value; break;