系统管理-基础设置接口

master
lch 6 months ago
parent ae304687a3
commit b414860582

@ -0,0 +1,13 @@
namespace Entity.Api.Req;
public class SetBusinessHoursReq
{
/// <summary>
/// 营业时间:开始时间
/// </summary>
public string BusinessStartHours { get; set; }
/// <summary>
/// 营业时间:结束时间
/// </summary>
public string BusinessEndHours { get; set; }
}

@ -0,0 +1,9 @@
namespace Entity.Api.Req;
public class SetChargingOperationModeReq
{
/// <summary>
/// 充电模式 0手动充电1自动充电
/// </summary>
public int ChargeType { get; set; }
}

@ -14,10 +14,10 @@ namespace Entity.Api.Req
/// <summary> /// <summary>
/// 日 灯光开启时间 /// 日 灯光开启时间
/// </summary> /// </summary>
public string StartTime { get; set; } public string LightDayStartTime { get; set; }
/// <summary> /// <summary>
/// 日 灯光关闭时间 /// 日 灯光关闭时间
/// </summary> /// </summary>
public string EndTime { get; set; } public string LightDayEndTime { get; set; }
} }
} }

@ -0,0 +1,13 @@
namespace Entity.Api.Req;
public class SetReplacementStrategyReq
{
/// <summary>
/// 换电标准SOC
/// </summary>
public float SwapSoc { get; set; }
/// <summary>
/// 充电标准SOC
/// </summary>
public float FullSoc { get; set; }
}

@ -0,0 +1,9 @@
namespace Entity.Api.Req;
public class SetSwitchingOperaModeReq
{
/// <summary>
/// 换电运营模式1:自动2:手动
/// </summary>
public int SwapType { get; set; }
}

@ -0,0 +1,37 @@
namespace Entity.Api.Resp;
public class BaseSetStationConfigInfo
{
/// <summary>
/// 灯光日间时间:开始时间
/// </summary>
public string LigthStartTime { get; set; }
/// <summary>
/// 灯光日间时间:结束时间
/// </summary>
public string LigthEndTime { get; set; }
/// <summary>
/// 换电策略换电标准Soc
/// </summary>
public int SetSwapSoc { get; set; }
/// <summary>
/// 换电策略充电标准Soc
/// </summary>
public int SetFullSoc { get; set; }
/// <summary>
/// 营业时间:开始时间
/// </summary>
public string BusinessStartHours { get; set; }
/// <summary>
/// 营业时间:结束时间
/// </summary>
public string BusinessEndHours{ get; set; }
/// <summary>
/// 充电运营模式0-手动 1-自动
/// </summary>
public int ChargeType{ get; set; }
/// <summary>
/// 换电运营模式1-自动 2-手动
/// </summary>
public int SwapType{ get; set; }
}

@ -181,6 +181,26 @@ public class StationParamConst
#endregion 换电站基础信息 #endregion 换电站基础信息
#region 系统管理-基础设置
//提交灯光日间时间
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 系统管理-基础设置
//选包策略中最后结束充电时间需要>此值 //选包策略中最后结束充电时间需要>此值
public static readonly string SwapFinishChargeTime = "Station.SwapFinishChargeTime"; public static readonly string SwapFinishChargeTime = "Station.SwapFinishChargeTime";

@ -30,22 +30,36 @@ namespace Entity.DbModel.Station
/// </summary> /// </summary>
[SugarColumn(ColumnName="version")] [SugarColumn(ColumnName="version")]
public int Version {get;set;} public int Version {get;set;}
/// <summary> /// <summary>
/// Desc:开始时间 /// 开始时间:小时
/// Default:
/// Nullable:True
/// </summary> /// </summary>
[SugarColumn(ColumnName="start_time")] [SugarColumn(ColumnName = "start_hour")]
public DateTime? StartTime {get;set;} public int StartHour { get; set; }
/// <summary> /// <summary>
/// Desc:结束时间 /// 开始时间:分组
/// Default: /// </summary>
/// Nullable:True [SugarColumn(ColumnName = "start_minute")]
public int StartMinute { get; set; }
/// <summary>
/// 开始时间:秒
/// </summary> /// </summary>
[SugarColumn(ColumnName="end_time")] [SugarColumn(ColumnName = "start_second")]
public DateTime? EndTime {get;set;} public int StartSecond { get; set; }
/// <summary>
/// 结束时间:小时
/// </summary>
[SugarColumn(ColumnName = "end_hour")]
public int EndHour { get; set; }
/// <summary>
/// 结束时间:分钟
/// </summary>
[SugarColumn(ColumnName = "end_minute")]
public int EndMinute { get; set; }
/// <summary>
/// 结束时间:秒
/// </summary>
[SugarColumn(ColumnName = "end_second")]
public int EndSecond { get; set; }
/// <summary> /// <summary>
/// Desc:价格;以分为单位存储 /// Desc:价格;以分为单位存储
@ -94,6 +108,21 @@ namespace Entity.DbModel.Station
/// </summary> /// </summary>
[SugarColumn(ColumnName="updated_time")] [SugarColumn(ColumnName="updated_time")]
public DateTime? UpdatedTime {get;set;} public DateTime? UpdatedTime {get;set;}
/// <summary>
/// 判断一个时间段是否包含另一个时间段(包括开始和结束时间的秒数)
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public bool Contains(ElecPriceModelVersionDetail other)
{
return (other.StartHour < EndHour ||
(other.StartHour == EndHour && other.StartMinute < EndMinute) ||
(other.StartHour == EndHour && other.StartMinute == EndMinute && other.StartSecond <= EndSecond)) &&
(other.EndHour > StartHour ||
(other.EndHour == StartHour && other.EndMinute > StartMinute) ||
(other.EndHour == StartHour && other.EndMinute == StartMinute && other.EndSecond >= StartSecond));
}
} }
} }

@ -53,8 +53,12 @@ public class ChargerElectricityPriceModelHandler : IBaseHandler
Version = version.Version, Version = version.Version,
Price = (int)d.ep * 10000, Price = (int)d.ep * 10000,
Type = d.pr, Type = d.pr,
StartTime = d.st, StartHour = d.st.Hour,
EndTime = d.et StartMinute = d.st.Minute,
StartSecond = d.st.Second,
EndHour = d.et.Hour,
EndMinute = d.et.Minute,
EndSecond = d.et.Second
}).ToList(); }).ToList();
_detailRepository.Insert(versionDetails); _detailRepository.Insert(versionDetails);
} }

@ -342,7 +342,7 @@ public class PlcMgr
/// <summary> /// <summary>
/// 消防移仓 /// 消防移仓
/// </summary> /// </summary>
/// <param name="entrySelection">入仓位选择0-无操作、1-缓存位舱位号、2-20电池存储仓位</param> /// <param name="entrySelection">入仓位选择</param>
/// <returns></returns> /// <returns></returns>
public static bool FireProtectionRelocation(ushort entrySelection) public static bool FireProtectionRelocation(ushort entrySelection)
{ {

@ -0,0 +1,16 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using Repository.Station;
namespace Service.Station;
[Scope("SingleInstance")]
public class ElecPriceModelVersionDetailServices : BaseServices<ElecPriceModelVersionDetail>
{
ElecPriceModelVersionDetailRepository _elecPriceModelVersionDetailRepository;
public ElecPriceModelVersionDetailServices(ElecPriceModelVersionDetailRepository dal)
{
_elecPriceModelVersionDetailRepository = dal;
BaseDal = dal;
}
}

@ -3,10 +3,15 @@ using Microsoft.AspNetCore.Mvc;
using System.ComponentModel; using System.ComponentModel;
using System.Text; using System.Text;
using System; using System;
using System.Reflection;
using Entity.Api.Resp; using Entity.Api.Resp;
using Entity.DbModel.Station;
using Entity.DbModel.System.SysBaseObject;
using HybirdFrameworkCore.Entity; using HybirdFrameworkCore.Entity;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Service.Station;
using Service.System;
namespace WebStarter.Controllers.BasicConfig namespace WebStarter.Controllers.BasicConfig
{ {
@ -17,6 +22,14 @@ namespace WebStarter.Controllers.BasicConfig
[Route("api/[controller]")] [Route("api/[controller]")]
public class BaseConfigController public class BaseConfigController
{ {
private readonly SysConfigService _sysConfigService;
private readonly ElecPriceModelVersionDetailServices _elecPriceModelVersionDetailServices;
public BaseConfigController(SysConfigService sysConfigService, ElecPriceModelVersionDetailServices elecPriceModelVersionDetailServices)
{
_sysConfigService = sysConfigService;
_elecPriceModelVersionDetailServices = elecPriceModelVersionDetailServices;
}
#region RFID配置 #region RFID配置
// /// <summary> // /// <summary>
// /// 预览 // /// 预览
@ -110,14 +123,192 @@ namespace WebStarter.Controllers.BasicConfig
// } // }
#endregion RFID配置 #endregion RFID配置
/// <summary>
/// 获取换电策略设置 、灯光日间时间、充电运营模式、营业时间段、换电运营模式
/// </summary>
[HttpPost("BaseSetStationConfigInfo")]
public async Task<Result<BaseSetStationConfigInfo>> BaseSetStationConfigInfo()
{
BaseSetStationConfigInfo stationBaseInfoResp = new BaseSetStationConfigInfo();
List<SysConfig> 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;
}
}
return Result<BaseSetStationConfigInfo>.Success(stationBaseInfoResp);
}
/// <summary>
/// 提交换电策略设置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("SetReplacementStrategy")]
public async Task<Result<bool>> SetReplacementStrategy([FromBody] SetReplacementStrategyReq input)
{
bool setResult = SetConfigPorperty(input);
return Result<bool>.Success(setResult);
}
/// <summary> /// <summary>
/// 日间时间设置 /// 日间时间设置
/// </summary> /// </summary>
[HttpPost("SetDaytime")] [HttpPost("SetDaytime")]
public async Task<Result<bool>> SetDaytime([FromBody] SetDayTimeReq input) public async Task<Result<bool>> SetDaytime([FromBody] SetDayTimeReq input)
{ {
bool setResult = SetConfigPorperty(input);
return Result<bool>.Success(setResult);
}
/// <summary>
/// 充电运营模式 0手动充电1自动充电
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("SetChargingOperationMode")]
public async Task<Result<bool>> SetChargingOperationMode([FromBody] SetChargingOperationModeReq input)
{
bool setResult = SetConfigPorperty(input);
return Result<bool>.Success(setResult);
}
/// <summary>
/// 营业时间设置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("SetBusinessHours")]
public async Task<Result<bool>> SetBusinessHours([FromBody] SetBusinessHoursReq input)
{
bool setResult = SetConfigPorperty(input);
return Result<bool>.Success(setResult);
}
/// <summary>
/// 换电运营模式1:自动2:手动
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("SetSwitchingOperaModeReq")]
public async Task<Result<bool>> SetSwitchingOperationMode([FromBody] SetSwitchingOperaModeReq input)
{
bool setResult = SetConfigPorperty(input);
return Result<bool>.Success(setResult);
}
/// <summary>
/// 查询电价信息
/// </summary>
/// <param name="version">版本号</param>
/// <returns></returns>
[HttpGet("GetStationElecPriceInfoList/{version}")]
public async Task<Result<List<ElecPriceModelVersionDetail>>> GetStationElecPriceInfoList(int version)
{
var data = await _elecPriceModelVersionDetailServices.QueryListByClauseAsync(u => u.Version == version);
return Result<List<ElecPriceModelVersionDetail>>.Success(data);
}
/// <summary>
/// 增加电价信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost("AddStationElecPriceInfoList")]
public async Task<Result<bool>> AddStationElecPriceInfoList([FromBody] List<ElecPriceModelVersionDetail> model)
{
if (null==model||model.Count==0)
{
Result<bool>.Fail("参数不能为空");
}
var queryByClauseAsync = _elecPriceModelVersionDetailServices.QueryByClauseAsync(u => u.Version == model[0].Version);
if(queryByClauseAsync!=null)
await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version ==model[0].Version);
if (TimeListIfContains(model))
{
await _elecPriceModelVersionDetailServices.InsertAsync(model);
return Result<bool>.Success(true);
}
return Result<bool>.Fail("时间区间重复请检查");
}
return Result<bool>.Success();
/// <summary>
/// 修改电价信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost("UpdateStationElecPriceInfo")]
public async Task<Result<bool>> UpdateStationElecPriceInfo([FromBody] List<ElecPriceModelVersionDetail> model)
{
if (null==model||model.Count==0)
{
Result<bool>.Fail("参数不能为空");
}
var queryByClauseAsync = _elecPriceModelVersionDetailServices.QueryByClauseAsync(u => u.Version == model[0].Version);
if(queryByClauseAsync!=null)
await _elecPriceModelVersionDetailServices.DeleteAsync(i => i.Version ==model[0].Version);
if (TimeListIfContains(model))
{
await _elecPriceModelVersionDetailServices.InsertAsync(model);
return Result<bool>.Success(true);
}
return Result<bool>.Fail("时间区间重复请检查");
}
/// <summary>
/// List中判断一个时间段是否包含另一个时间段包括开始和结束时间的秒数
/// </summary>
/// <param name="timePeriods"></param>
/// <returns></returns>
public bool TimeListIfContains(List<ElecPriceModelVersionDetail> timePeriods)
{
bool hasOverlap = false;
for (int i = 0; i < timePeriods.Count; i++)
{
for (int j = i + 1; j < timePeriods.Count; j++)
{
if (timePeriods[i].Contains(timePeriods[j]) || timePeriods[j].Contains(timePeriods[i]))
{
hasOverlap = true;
return hasOverlap;
}
}
}
return hasOverlap;
}
/// <summary>
/// 设置类属性
/// </summary>
/// <param name="t"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public bool SetConfigPorperty<T>(T t)
{
bool setResult = false;
PropertyInfo[] props = typeof(T).GetProperties();
foreach (PropertyInfo fieldInfo in props)
{
string newConstConfigInfo = "Station" + "." + fieldInfo.Name;
object getContent = fieldInfo.GetValue(t);
if (getContent != null)
setResult = _sysConfigService.Set(newConstConfigInfo, getContent);
}
return setResult;
} }
} }
} }

@ -126,7 +126,7 @@ public class SwapMonitorController : ControllerBase
[HttpPost("AllLightsOff")] [HttpPost("AllLightsOff")]
public async Task<Result<bool>> AllLightsOff() public async Task<Result<bool>> AllLightsOff()
{ {
return Result<bool>.Success(PlcMgr.AllLightsOff()); return PlcMgr.AllLightsOff()? Result<bool>.Success(true):Result<bool>.Fail();
} }
/// <summary> /// <summary>
@ -136,16 +136,16 @@ public class SwapMonitorController : ControllerBase
[HttpPost("AllLightsOn")] [HttpPost("AllLightsOn")]
public async Task<Result<bool>> AllLightsOn() public async Task<Result<bool>> AllLightsOn()
{ {
return Result<bool>.Success(PlcMgr.AllLightsOn()); return PlcMgr.AllLightsOn()? Result<bool>.Success(true):Result<bool>.Fail();
} }
/// <summary> /// <summary>
/// /// 得到现在灯光状态
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost("GetNowLightsOn")] [HttpPost("GetNowLightsOn")]
public async Task<Result<ushort>> GetNowLightsOn() public async Task<Result<ushort>> GetNowLightsOn()
{ {
return Result<ushort>.Success(PlcMgr.GetNowLightsOn()); return Result<ushort>.Success(PlcMgr.GetNowLightsOn());
} }
/// <summary> /// <summary>

Loading…
Cancel
Save