|
|
@ -9,18 +9,18 @@ using Service.Cloud.Msg.Host.Resp;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Service.Cloud.Handler;
|
|
|
|
namespace Service.Cloud.Handler;
|
|
|
|
|
|
|
|
|
|
|
|
[Scope]
|
|
|
|
[Scope("InstancePerDependency")]
|
|
|
|
public class ChargerElectricityPriceModelHandler : IBaseHandler
|
|
|
|
public class ChargerElectricityPriceModelHandler : IBaseHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
private ElecPriceModelVersionRepository _versionRepository;
|
|
|
|
private ElecPriceModelVersionRepository _versionRepository{ get; set; }
|
|
|
|
private ElecPriceModelVersionDetailRepository _detailRepository;
|
|
|
|
private ElecPriceModelVersionDetailRepository _detailRepository{ get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public ChargerElectricityPriceModelHandler(ElecPriceModelVersionRepository elecPriceModelVersionRepository,
|
|
|
|
public ChargerElectricityPriceModelHandler(ElecPriceModelVersionRepository elecPriceModelVersionRepository,
|
|
|
|
ElecPriceModelVersionDetailRepository elecPriceModelVersionDetailRepository)
|
|
|
|
ElecPriceModelVersionDetailRepository elecPriceModelVersionDetailRepository)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this._versionRepository = elecPriceModelVersionRepository;
|
|
|
|
_versionRepository = elecPriceModelVersionRepository;
|
|
|
|
this._detailRepository = elecPriceModelVersionDetailRepository;
|
|
|
|
_detailRepository = elecPriceModelVersionDetailRepository;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool CanHandle(string cmd)
|
|
|
|
public bool CanHandle(string cmd)
|
|
|
@ -33,36 +33,38 @@ public class ChargerElectricityPriceModelHandler : IBaseHandler
|
|
|
|
SetChargePrice? priceModel = JsonConvert.DeserializeObject<SetChargePrice>(t);
|
|
|
|
SetChargePrice? priceModel = JsonConvert.DeserializeObject<SetChargePrice>(t);
|
|
|
|
if (priceModel != null)
|
|
|
|
if (priceModel != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ElecPriceModelVersion version = _versionRepository.QueryByClause(d => d.Version == priceModel.ceid);
|
|
|
|
|
|
|
|
|
|
|
|
ElecPriceModelVersion version = _versionRepository.QueryByClause(d => d.Version == priceModel.electricityId);
|
|
|
|
|
|
|
|
|
|
|
|
if (version == null)
|
|
|
|
if (version == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
version = new ElecPriceModelVersion
|
|
|
|
version = new ElecPriceModelVersion
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Version = priceModel.ceid
|
|
|
|
Version = priceModel.electricityId,
|
|
|
|
|
|
|
|
Ceid = priceModel.electricityId.ToString()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
version.StartTime = DateTime.Now;
|
|
|
|
version.StartTime = DateTime.Now;
|
|
|
|
version.EndTime = DateTime.Now.AddYears(10);
|
|
|
|
version.EndTime = DateTime.Now.AddYears(10);
|
|
|
|
_versionRepository.InsertOrUpdate(version);
|
|
|
|
_versionRepository.InsertOrUpdate(version);
|
|
|
|
|
|
|
|
|
|
|
|
List<Seg>? segs = priceModel.seg;
|
|
|
|
List<Seg>? segs = priceModel.timeList;
|
|
|
|
if (segs is { Count: > 0 })
|
|
|
|
if (segs is { Count: > 0 })
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<ElecPriceModelVersionDetail> versionDetails = segs.Select(d => new ElecPriceModelVersionDetail()
|
|
|
|
List<ElecPriceModelVersionDetail> versionDetails = segs.Select(d => new ElecPriceModelVersionDetail()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Version = version.Version,
|
|
|
|
Version = version.Version,
|
|
|
|
Price = (int)d.ep * 10000,
|
|
|
|
Price = d.price,
|
|
|
|
Type = d.pr,
|
|
|
|
Type = d.type,
|
|
|
|
StartHour = d.st.Hour,
|
|
|
|
StartHour = d.startTime.Hour,
|
|
|
|
StartMinute = d.st.Minute,
|
|
|
|
StartMinute = d.startTime.Minute,
|
|
|
|
StartSecond = d.st.Second,
|
|
|
|
StartSecond = d.startTime.Second,
|
|
|
|
EndHour = d.et.Hour,
|
|
|
|
EndHour = d.endTime.Hour,
|
|
|
|
EndMinute = d.et.Minute,
|
|
|
|
EndMinute = d.endTime.Minute,
|
|
|
|
EndSecond = d.et.Second
|
|
|
|
EndSecond = d.endTime.Second
|
|
|
|
}).ToList();
|
|
|
|
}).ToList();
|
|
|
|
_detailRepository.Insert(versionDetails);
|
|
|
|
_detailRepository.Insert(versionDetails);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetChargePriceRes resp = new SetChargePriceRes();
|
|
|
|
SetChargePriceRes resp = new SetChargePriceRes();
|
|
|
|
CloudClientMgr.CloudClient?.Publish(resp);
|
|
|
|
CloudClientMgr.CloudClient?.Publish(resp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|