Create Or Replace Function Get_Strarraylength
(
Str1 In Varchar2,--要分割的字符串
Split In Varchar2 --分隔符号
) Return Number Is --返回Number类型
Location Number;
Startstr Number;
Length Number;
str Varchar2(1024);
Begin
Str := Ltrim(Rtrim(Str1));
Location := Instr(Str, Split);
Length := 1;
While Location <> 0 Loop
Startstr := Location + 1;
Location := Instr(Str, Split, Startstr);
Length := Length + 1;
End Loop;
Return(Length);
End Get_Strarraylength;
-----------测试-----------------------------------------
Declare
Str Varchar2(20);
Split Varchar2(10);
Startstr Number;
Length Number;
Location Number;
nextstr Number;
seed Number;
indexstr Number;
Begin
Str := 'aaaaa|aaa|a';
Split := '|';
startstr:=1;
nextstr:=1;
seed:=length(split);
Location := Instr(Str, Split); --charindex
While Location <> 0 Loop
Startstr := Location + 1;
Location := Instr(Str, Split, Startstr);
Length := Length + 1;
End Loop;
Dbms_Output.Put_Line(Length);
End;
-----------------------------------------------------
Create Or Replace Function Get_StrArrayStrOfIndex
(
Str1 In Varchar2,--要分割的字符串
Split In Varchar2,--分隔符号
Indexstr In Number --取第几个元素
) Return Varchar2 Is
str Varchar(1024);
Startstr Number;
Location Number;
Nextstr Number;
Seed Number;
Begin
Str := Ltrim(Rtrim(Str1));
Startstr := 1;
Nextstr := 1;
Seed := Length(Split);
Location := Instr(Str, Split); --charindex
While Location <> 0 And Indexstr > Nextstr Loop
Startstr := Location + Seed;
Location := Instr(Str, Split, Startstr);
Nextstr := Nextstr + 1;
End Loop;
If Location = 0 Then
Location := Length(Str) + 1;
End If;
Return(Substr(Str, Startstr, Location - Startstr));
End;
--------------------test-------------------------------------
Declare
intyear Number;
intmonth Number;
period_id Number;
strType Number;
strTime Varchar2(20);
ostrTag Number;
peak Varchar2(100);
middle Varchar2(100);
valley Varchar2(100);
peak1 Varchar2(20);
middle1 Varchar2(20);
valley1 Varchar2(20);
nextstr Number;
hour Number;
mint Number;
Year_ Char(4);
Month_ Char(2);
fullminit Varchar2(2);
Begin
intyear:=2006;
intmonth:=12;
period_id:=95;
strType:=30;
hour:=trunc((period_id*15)/60);
mint:=(period_id*15) Mod 60;
fullminit:=to_char(mint);
If mint<10 Then
fullminit:='0'||fullminit;
End If;
dbms_output.put_line(fullminit);--
strTime:=to_char(hour)||':'||fullminit;
dbms_output.put_line(strTime);--
year_:=to_char(intyear);
month_:=to_char(intmonth);
ostrTag:=0;
Select SYS_PERIOD_PEAK,SYS_PERIOD_MID,SYS_PERIOD_VAL Into peak,middle,valley
From GBOSS.SYS_PERIOD_TYPE Where SYS_APP_ID=strType and year=year_ and month=month_;
peak:=replace(RTRIM(LTRIM(peak)),':','');
middle:=replace(RTRIM(LTRIM(middle)),':','');
valley:=replace(RTRIM(LTRIM(valley)),':','');
strTime:=replace(RTRIM(LTRIM(strTime)),':','');
dbms_output.put_line(peak||','||strTime);----
--处理Peak
nextstr:=1;
While nextstr<=Get_StrArrayLength(peak,'|') Loop
peak1:=Get_StrArrayStrOfIndex(peak,'|',nextstr);
If substr(peak1,1,1)='[' And substr(peak1,length(peak1),1)=']' Then
If to_number(strtime)>=to_number(substr(peak1,2,instr(peak1,'-')-2)) And
to_number(strtime)<=to_number(substr(peak1,instr(peak1,'-')+1,length(peak1)-instr(peak1,'-')-1)) Then
ostrtag:=1;
End If;
End If;
If substr(peak1,1,1)='[' And substr(peak1,length(peak1),1)=')' Then
If to_number(strtime)>=to_number(substr(peak1,2,instr(peak1,'-')-2)) And
to_number(strtime)<to_number(substr(peak1,instr(peak1,'-')+1,length(peak1)-instr(peak1,'-')-1)) Then
ostrtag:=1;
End If;
End If;
If substr(peak1,1,1)='(' And substr(peak1,length(peak1),1)=']' Then
If to_number(strtime)>to_number(substr(peak1,2,instr(peak1,'-')-2)) And
to_number(strtime)<=to_number(substr(peak1,instr(peak1,'-')+1,length(peak1)-instr(peak1,'-')-1)) Then
ostrtag:=1;
End If;
End If;
If substr(peak1,1,1)='(' And substr(peak1,length(peak1),1)=')' Then
If to_number(strtime)>to_number(substr(peak1,2,instr(peak1,'-')-2)) And
to_number(strtime)<to_number(substr(peak1,instr(peak1,'-')+1,length(peak1)-instr(peak1,'-')-1)) Then
ostrtag:=1;
End If;
End If;
nextstr:=nextstr+1;
End Loop;
--处理middle
nextstr:=1;
While ostrtag=0 And nextstr<=Get_StrArrayLength(middle,'|') Loop
middle1:=Get_StrArrayStrOfIndex(middle,'|',nextstr);
If substr(middle1,1,1)='[' And substr(middle1,length(middle1),1)=']' Then
If to_number(strtime)>=to_number(substr(middle1,2,instr(middle1,'-')-2)) And
to_number(strtime)<=to_number(substr(middle1,instr(middle1,'-')+1,length(middle1)-instr(middle1,'-')-1)) Then
ostrtag:=2;
End If;
End If;
If substr(middle1,1,1)='[' And substr(middle1,length(middle1),1)=')' Then
If to_number(strtime)>=to_number(substr(middle1,2,instr(middle1,'-')-2)) And
to_number(strtime)<to_number(substr(middle1,instr(middle1,'-')+1,length(middle1)-instr(middle1,'-')-1)) Then
ostrtag:=2;
End If;
End If;
If substr(middle1,1,1)='(' And substr(middle1,length(middle1),1)=']' Then
If to_number(strtime)>to_number(substr(middle1,2,instr(middle1,'-')-2)) And
to_number(strtime)<=to_number(substr(middle1,instr(middle1,'-')+1,length(middle1)-instr(middle1,'-')-1)) Then
ostrtag:=2;
End If;
End If;
If substr(middle1,1,1)='(' And substr(middle1,length(middle1),1)=')' Then
If to_number(strtime)>to_number(substr(middle1,2,instr(middle1,'-')-2)) And
to_number(strtime)<to_number(substr(middle1,instr(middle1,'-')+1,length(middle1)-instr(middle1,'-')-1)) Then
ostrtag:=2;
End If;
End If;
nextstr:=nextstr+1;
End Loop;
--处理valley
nextstr:=1;
While ostrtag=0 And nextstr<=Get_StrArrayLength(valley,'|') Loop
valley1:=Get_StrArrayStrOfIndex(valley,'|',nextstr);
If substr(valley1,1,1)='[' And substr(valley1,length(valley1),1)=']' Then
If to_number(strtime)>=to_number(substr(valley1,2,instr(valley1,'-')-2)) And
to_number(strtime)<=to_number(substr(valley1,instr(valley1,'-')+1,length(valley1)-instr(valley1,'-')-1)) Then
ostrtag:=3;
End If;
End If;
If substr(valley1,1,1)='[' And substr(valley1,length(valley1),1)=')' Then
If to_number(strtime)>=to_number(substr(valley1,2,instr(valley1,'-')-2)) And
to_number(strtime)<to_number(substr(valley1,instr(valley1,'-')+1,length(valley1)-instr(valley1,'-')-1)) Then
ostrtag:=3;
End If;
End If;
If substr(valley1,1,1)='(' And substr(valley1,length(valley1),1)=']' Then
If to_number(strtime)>to_number(substr(valley1,2,instr(valley1,'-')-2)) And
to_number(strtime)<=to_number(substr(valley1,instr(valley1,'-')+1,length(valley1)-instr(valley1,'-')-1)) Then
ostrtag:=3;
End If;
End If;
If substr(valley1,1,1)='(' And substr(valley1,length(valley1),1)=')' Then
If to_number(strtime)>to_number(substr(valley1,2,instr(valley1,'-')-2)) And
to_number(strtime)<to_number(substr(valley1,instr(valley1,'-')+1,length(valley1)-instr(valley1,'-')-1)) Then
ostrtag:=3;
End If;
End If;
nextstr:=nextstr+1;
End Loop;
dbms_output.put_line(ostrtag);
End;
-------------------------------------------------------------------
Create Or Replace Function Procgettagf
(
Intyear In Number,--年
Intmonth In Number,--月
Period_Id In Number,--时间段
Strtype In Number--应用类型
) Return Number Is
Strtime Varchar2(20);
Ostrtag Number;
Peak Varchar2(100);
Middle Varchar2(100);
Valley Varchar2(100);
Peak1 Varchar2(20);
Middle1 Varchar2(20);
Valley1 Varchar2(20);
Nextstr Number;
Hour Number;
Mint Number;
Year_ Char(4);
Month_ Char(2);
Fullminit Varchar2(2);
Begin
--intyear:=2006;
--intmonth:=12;
--period_id:=95;
--strType:=30;
Hour := Trunc((Period_Id * 15) / 60);
Mint := (Period_Id * 15) Mod 60;
Fullminit := To_Char(Mint);
If Mint < 10 Then
Fullminit := '0' || Fullminit;
End If;
Dbms_Output.Put_Line(Fullminit); --
Strtime := To_Char(Hour) || ':' || Fullminit;
Dbms_Output.Put_Line(Strtime); --
Year_ := To_Char(Intyear);
Month_ := To_Char(Intmonth);
Ostrtag := 0;
Select Sys_Period_Peak, Sys_Period_Mid, Sys_Period_Val
Into Peak, Middle, Valley
From Gboss.Sys_Period_Type
Where Sys_App_Id = Strtype And Year = Year_ And Month = Month_;
Peak := Replace(Rtrim(Ltrim(Peak)), ':', '');
Middle := Replace(Rtrim(Ltrim(Middle)), ':', '');
Valley := Replace(Rtrim(Ltrim(Valley)), ':', '');
Strtime := Replace(Rtrim(Ltrim(Strtime)), ':', '');
Dbms_Output.Put_Line(Peak || ',' || Strtime); ----
--处理Peak
Nextstr := 1;
While Nextstr <= Get_Strarraylength(Peak, '|') Loop
Peak1 := Get_Strarraystrofindex(Peak, '|', Nextstr);
If Substr(Peak1, 1, 1) = '[' And Substr(Peak1, Length(Peak1), 1) = ']' Then
If To_Number(Strtime) >= To_Number(Substr(Peak1, 2, Instr(Peak1, '-') - 2)) And
To_Number(Strtime) <= To_Number(Substr(Peak1, Instr(Peak1, '-') + 1, Length(Peak1) - Instr(Peak1, '-') - 1)) Then
Ostrtag := 1;
End If;
End If;
If Substr(Peak1, 1, 1) = '[' And Substr(Peak1, Length(Peak1), 1) = ')' Then
If To_Number(Strtime) >= To_Number(Substr(Peak1, 2, Instr(Peak1, '-') - 2)) And
To_Number(Strtime) < To_Number(Substr(Peak1, Instr(Peak1, '-') + 1, Length(Peak1) - Instr(Peak1, '-') - 1)) Then
Ostrtag := 1;
End If;
End If;
If Substr(Peak1, 1, 1) = '(' And Substr(Peak1, Length(Peak1), 1) = ']' Then
If To_Number(Strtime) > To_Number(Substr(Peak1, 2, Instr(Peak1, '-') - 2)) And
To_Number(Strtime) <= To_Number(Substr(Peak1, Instr(Peak1, '-') + 1, Length(Peak1) - Instr(Peak1, '-') - 1)) Then
Ostrtag := 1;
End If;
End If;
If Substr(Peak1, 1, 1) = '(' And Substr(Peak1, Length(Peak1), 1) = ')' Then
If To_Number(Strtime) > To_Number(Substr(Peak1, 2, Instr(Peak1, '-') - 2)) And
To_Number(Strtime) < To_Number(Substr(Peak1, Instr(Peak1, '-') + 1, Length(Peak1) - Instr(Peak1, '-') - 1)) Then
Ostrtag := 1;
End If;
End If;
Nextstr := Nextstr + 1;
End Loop;
--处理middle
Nextstr := 1;
While Ostrtag = 0 And Nextstr <= Get_Strarraylength(Middle, '|') Loop
Middle1 := Get_Strarraystrofindex(Middle, '|', Nextstr);
If Substr(Middle1, 1, 1) = '[' And Substr(Middle1, Length(Middle1), 1) = ']' Then
If To_Number(Strtime) >= To_Number(Substr(Middle1, 2, Instr(Middle1, '-') - 2)) And
To_Number(Strtime) <=
To_Number(Substr(Middle1, Instr(Middle1, '-') + 1, Length(Middle1) - Instr(Middle1, '-') - 1)) Then
Ostrtag := 2;
End If;
End If;
If Substr(Middle1, 1, 1) = '[' And Substr(Middle1, Length(Middle1), 1) = ')' Then
If To_Number(Strtime) >= To_Number(Substr(Middle1, 2, Instr(Middle1, '-') - 2)) And
To_Number(Strtime) <
To_Number(Substr(Middle1, Instr(Middle1, '-') + 1, Length(Middle1) - Instr(Middle1, '-') - 1)) Then
Ostrtag := 2;
End If;
End If;
If Substr(Middle1, 1, 1) = '(' And Substr(Middle1, Length(Middle1), 1) = ']' Then
If To_Number(Strtime) > To_Number(Substr(Middle1, 2, Instr(Middle1, '-') - 2)) And
To_Number(Strtime) <=
To_Number(Substr(Middle1, Instr(Middle1, '-') + 1, Length(Middle1) - Instr(Middle1, '-') - 1)) Then
Ostrtag := 2;
End If;
End If;
If Substr(Middle1, 1, 1) = '(' And Substr(Middle1, Length(Middle1), 1) = ')' Then
If To_Number(Strtime) > To_Number(Substr(Middle1, 2, Instr(Middle1, '-') - 2)) And
To_Number(Strtime) <
To_Number(Substr(Middle1, Instr(Middle1, '-') + 1, Length(Middle1) - Instr(Middle1, '-') - 1)) Then
Ostrtag := 2;
End If;
End If;
Nextstr := Nextstr + 1;
End Loop;
--处理valley
Nextstr := 1;
While Ostrtag = 0 And Nextstr <= Get_Strarraylength(Valley, '|') Loop
Valley1 := Get_Strarraystrofindex(Valley, '|', Nextstr);
If Substr(Valley1, 1, 1) = '[' And Substr(Valley1, Length(Valley1), 1) = ']' Then
If To_Number(Strtime) >= To_Number(Substr(Valley1, 2, Instr(Valley1, '-') - 2)) And
To_Number(Strtime) <=
To_Number(Substr(Valley1, Instr(Valley1, '-') + 1, Length(Valley1) - Instr(Valley1, '-') - 1)) Then
Ostrtag := 3;
End If;
End If;
If Substr(Valley1, 1, 1) = '[' And Substr(Valley1, Length(Valley1), 1) = ')' Then
If To_Number(Strtime) >= To_Number(Substr(Valley1, 2, Instr(Valley1, '-') - 2)) And
To_Number(Strtime) <
To_Number(Substr(Valley1, Instr(Valley1, '-') + 1, Length(Valley1) - Instr(Valley1, '-') - 1)) Then
Ostrtag := 3;
End If;
End If;
If Substr(Valley1, 1, 1) = '(' And Substr(Valley1, Length(Valley1), 1) = ']' Then
If To_Number(Strtime) > To_Number(Substr(Valley1, 2, Instr(Valley1, '-') - 2)) And
To_Number(Strtime) <=
To_Number(Substr(Valley1, Instr(Valley1, '-') + 1, Length(Valley1) - Instr(Valley1, '-') - 1)) Then
Ostrtag := 3;
End If;
End If;
If Substr(Valley1, 1, 1) = '(' And Substr(Valley1, Length(Valley1), 1) = ')' Then
If To_Number(Strtime) > To_Number(Substr(Valley1, 2, Instr(Valley1, '-') - 2)) And
To_Number(Strtime) <
To_Number(Substr(Valley1, Instr(Valley1, '-') + 1, Length(Valley1) - Instr(Valley1, '-') - 1)) Then
Ostrtag := 3;
End If;
End If;
Nextstr := Nextstr + 1;
End Loop;
Dbms_Output.Put_Line(Ostrtag);
Return(Ostrtag);
End;
分享到:
相关推荐
峰谷时段划分对含电动汽车配电系统负荷曲线的影响 峰谷时段划分是指根据电力系统的需求和驾驶习惯,合理地分配电动汽车的充电时段,以避免对电网的不利影响。该研究通过构建充电负荷对分时电价的响应模型,分析了...
该模型首先将城市用电区域分为四个区域:居民区、办公区、工业区、商业区,然后使用隶属度函数法研究区域分时电价峰谷时段划分方法。接着,基于弹性系数法建立电动汽车用户响应量对区域峰谷分时电价的响应关系。最后...
自动寻峰谷算法matlab实现,非常不错,大师实现
- 峰谷时段的划分和电价政策 - 各个时段内的用电量限制和电价范围 - 过度用电的处罚措施和收费标准 - 生产流程的优化和用电管理 - 应急预案以及电力供应中断时的应对策略 这些内容对于水泥厂来说是至关重要的,不仅...
在这个领域,家用智能峰谷电转换装置是一种创新的应用,旨在帮助家庭用户更加智能、经济地使用电力资源。 峰谷电价制度是电力部门为了调整电网负荷,鼓励用户在低谷时段用电,减轻高峰时段电网压力而实施的一种电价...
在上面的公式中,QJJ 代表峰谷线的计算结果,XVL 代表峰谷线的中位数,HSL 代表峰谷线的标准差,攻击和 LLJX 代表峰谷线的攻击力和均线计算结果。 三、猎击线(Hunt Line) 猎击线是一种技术指标,用于识别股票或...
在图像处理领域,图像分割是一项基础且重要的任务,它旨在将图像划分为多个具有不同特征的区域或对象。本文将详细探讨图像分割中的迭代、峰谷和半阈值算法,并结合VC++编程环境来理解这些算法的实现。 首先,我们来...
1. 输入电量数据:用户可以输入每日或每月的总用电量,软件会根据峰谷电时段划分,自动分配到相应的时段。 2. 计算电费:软件内置杭州市的峰谷电价标准,能精确计算出各时段的电费,以及总电费。 3. 时段分析:...
为了使储能系统达到最优的削峰填谷效果,提出一种计及负荷峰谷特性的储能调峰日前优化调度策略。根据调度日内的负荷曲线,以储能系统的额定容量与额定功率为约束条件,分别计算在调峰过程中所能达到的最高填谷功率线...
设计过程中,需要对峰谷用电的时间范围进行详细划分,并设定相应的开关机时间点。这通常涉及到对时间信息的处理,因此在设计时可能需要集成实时时钟(RTC)模块,确保单片机能够准确掌握当前的时间信息。此外,为了...
本指标公式是设计用于副图显示的一种名为“峰谷拉升力”的技术分析工具,旨在帮助用户识别股票的上涨潜力和下跌风险。以下是这个公式的主要组成部分及其背后的逻辑: 1. **拉升力 (RiseForce)**:此计算公式基于...
本文将深入探讨通达信指标公式源码中的“峰谷买卖指标”,并解释其如何帮助投资者识别潜在的买卖机会。 首先,我们来了解指标公式中的几个关键变量和函数。在技术分析中,识别价格的高低点至关重要,因为它们可以...
基于NSGA-II算法与峰谷分时电价策略的电动汽车充电负荷优化研究,Matlab ‖ 峰谷电价引导下电动汽车充电负荷优化-基于NSGA-II算法 关键词:电动汽车 充电负荷 NSGA-II算法 峰谷电价 参考文档:《基于峰谷分时电价...
基于NSGA-II算法与峰谷分时电价策略的电动汽车充电负荷优化研究,MATLAB代码:峰谷电价引导下电动汽车充电负荷优化-基于NSGA-II 关键词:电动汽车 充电负荷 NSGA-II算法 峰谷电价 参考文档:《基于峰谷分时电价引导...
基于NSGA-II算法和峰谷分时电价的电动汽车充电负荷优化研究:MATLAB仿真实践,基于NSGA-II算法和峰谷分时电价的电动汽车充电负荷优化研究:MATLAB仿真实践。,Matlab ‖ 峰谷电价引导下电动汽车充电负荷优化-基于NSGA-...
首先,从标题“精准峰谷线公式.pdf”可以推断,该文件可能是一份关于如何精确计算股票或其他金融资产图表中的峰和谷的技术文档。峰和谷是技术分析中的重要概念,代表了图表上价格的最高点(顶峰)和最低点(谷底),...
研究者们也注意到了,尽管当前峰谷分时电价的实施在一定程度上提升了用电负荷率和缓解了高峰期用电紧张的情况,但面对的实际问题也不容忽视,这些问题主要集中在峰谷时段的划分和合理的峰谷分时电价的制定上。...
"电动汽车有序充电的峰谷电价时段优化" 电动汽车有序充电的峰谷电价时段优化是指利用电动汽车有序充电来削减电网峰谷电价的差率,减少电网的负荷峰谷差率。该技术可以通过优化电动汽车的充电时间来实现电网峰谷电价...
基于NSGA-II算法的电动汽车充电负荷优化研究:峰谷电价下的模拟与验证,MATLAB下的电动汽车充电负荷优化策略:基于NSGA-II算法响应峰谷电价引导的研究,MATLAB代码:峰谷电价引导下电动汽车充电负荷优化-基于NSGA-II ...