需求说明
客户需要按每个月固定的参数对报表数据进行计算,第一次查询手动录入参数,再次查询当月数据时自动带出此前保存的参数。需要实现参数录入保存和回显功能。
保存参数
数据库中创建保存参数的数据表
DROP TABLE "APPUSR"."EQM_RUN_TIME";
CREATE TABLE "APPUSR"."EQM_RUN_TIME" (
"YM" VARCHAR2(255 BYTE) NOT NULL ,
"TOTAL" NUMBER(20,3) ,
"JIA" NUMBER(20,3) ,
"YI" NUMBER(20,3) ,
"BING" NUMBER(20,3) ,
"DAYS" NUMBER(20,3)
)
TABLESPACE "GZDBDATA"
LOGGING
NOCOMPRESS
PCTFREE 10
INITRANS 1
STORAGE (
INITIAL 65536
NEXT 1048576
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
PARALLEL 1
NOCACHE
DISABLE ROW MOVEMENT
;
ALTER TABLE "APPUSR"."EQM_RUN_TIME" ADD CONSTRAINT "SYS_C00116035" PRIMARY KEY ("YM");
创建存储过程 P_EQM_RUN_TIME
CREATE OR REPLACE
PROCEDURE P_EQM_RUN_TIME
(yearM IN varchar2, days IN NUMBER, total IN NUMBER, jia IN NUMBER, yi IN NUMBER, bing IN NUMBER, ldays IN NUMBER, ltotal IN NUMBER, ljia IN NUMBER, lyi IN NUMBER, lbing IN number)
AS
lasty varchar2(50);
BEGIN
IF days IS NOT NULL and total IS NOT NULL AND jia IS NOT NULL AND yi IS NOT NULL AND bing IS NOT NULL
AND ldays IS NOT NULL AND ltotal IS NOT NULL AND ljia IS NOT NULL AND lyi IS NOT NULL AND lbing IS NOT NULL
THEN
select TO_CHAR(ADD_MONTHS(trunc(to_date(yearM,'yyyy-mm')),-12) ,'yyyy') INTO lasty from dual;
DELETE FROM eqm_run_time WHERE ym = yearM;
DELETE FROM eqm_run_time WHERE ym = lasty;
INSERT INTO eqm_run_time values(yearM,total,jia,yi,bing,days);
INSERT INTO eqm_run_time values (lasty, ltotal, ljia, lyi, lbing, ldays);
END IF;
END P_EQM_RUN_TIME;
设计参数模板
参数模板编辑框中输入参数,点击查询按钮后,将参数传递到报表模板。
报表模板参数列表:
报表模板中增加类型为存储过程的数据集,通过存储过程(P_EQM_RUN_TIME)将参数更新到数据库。
数据集:
回显参数
参数模板增加3、4行隐藏域,为每个参数增加对应的下拉框,类型为下拉数据集。
数据集ds2:
select * from eqm_run_time
为每个下拉数据集设置关联过滤,触发单位格为月份(G1)。选择月份后触发过滤,此时下拉框的值为当月各参数数据库中保存的值。
修改报表展示JSP页面
增加月份下拉日历选择事件 当选择月份后,获取参数下拉框的值,赋值给各参数编辑框,以实现编辑框的回显。
|