birt动态参数的处理

本例实现根据用户选择不同的查询条件查询显示报表。
按我的报表业务来演示。
我的报表要查询条件是起始时间,结束时间,站点,有票,没票,55以上,55以下
分别设置报表参数对应这几个查询条件。start,end,station,ticketed,unticketed,up55t,below55t
其中有票,没票,55以上,55以下只能选择一种情况
页面代码我就不写了,大概就是如果选择哪个就设置哪个值为1,
在报表的数据集的script里写上:
var condition = "and 1=1 order by Weight desc";
var start = reportContext.getParameterValue("start");
var end = reportContext.getParameterValue("end");
var ticket = reportContext.getParameterValue("ticketed");
var unticket = reportContext.getParameterValue("unticketed");
var up55t = reportContext.getParameterValue("up55t");
var below55t = reportContext.getParameterValue("below55t");
var st = reportContext.getParameterValue("station");
var station = "and DetectionStationNo = '"+ st +"'";

if(st == "all"){
 station = "and 1=1";
}


if(ticket==1){
condition = " and VehClass=1 order by Weight desc";
}
if(unticket==1){
condition = " and VehClass=0 order by Weight desc ";
}
if(up55t==1){
condition = " and Weight>55000  order by OverPercent desc";
}
if(below55t==1){
condition = " and not Weight>=55000 order by Weight desc";
}
然后就是this.queryText =" ... .." + condition;


当然有时候我们可能是一种情况就是选择一类,也可以选择全部,比如上面的站点,可能选择所有站点,那就在页面如果用户选择全部,就个特定值过来,我是指定如果是全部,就不加这个条件,1=1
大概就这些,大家自己试试。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的Flappy Bird游戏的Python代码: ```python import pygame import random # 初始化Pygame pygame.init() # 创建屏幕 screen = pygame.display.set_mode((288, 512)) # 设置标题 pygame.display.set_caption('Flappy Bird') # 加载图像 background_image = pygame.image.load('assets/background.png').convert() base_image = pygame.image.load('assets/base.png').convert_alpha() bird_images = [pygame.image.load('assets/bird-downflap.png').convert_alpha(), pygame.image.load('assets/bird-midflap.png').convert_alpha(), pygame.image.load('assets/bird-upflap.png').convert_alpha()] pipe_images = {'top': pygame.image.load('assets/pipe-top.png').convert_alpha(), 'bottom': pygame.image.load('assets/pipe-bottom.png').convert_alpha()} # 设置游戏参数 gravity = 0.25 bird_movement = 0 bird_rect = bird_images[0].get_rect(center=(50, 256)) pipe_list = [] SPAWNPIPE = pygame.USEREVENT pygame.time.set_timer(SPAWNPIPE, 1200) pipe_heights = [200, 300, 400] # 设置分数 score = 0 font = pygame.font.Font('04B_19.ttf', 40) # 游戏循环 while True: # 处理事件 for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: bird_movement = 0 bird_movement -= 6 if event.type == SPAWNPIPE: pipe_height = random.choice(pipe_heights) bottom_pipe = pipe_images['bottom'].get_rect(midtop=(350, pipe_height)) top_pipe = pipe_images['top'].get_rect(midbottom=(350, pipe_height - 150)) pipe_list.append(bottom_pipe) pipe_list.append(top_pipe) # 移动背景 screen.blit(background_image, (0, 0)) # 移动管道 for pipe in pipe_list: if pipe.right < 0: pipe_list.remove(pipe) pipe.centerx -= 5 screen.blit(pipe_images['bottom'], pipe) flipped_pipe = pygame.transform.flip(pipe_images['top'], False, True) screen.blit(flipped_pipe, pipe.topright) # 移动鸟 bird_movement += gravity bird_rect.centery += bird_movement screen.blit(bird_images[(pygame.time.get_ticks() // 100) % 3], bird_rect) # 检测碰撞 for pipe in pipe_list: if bird_rect.colliderect(pipe): pygame.quit() exit() # 更新分数 for pipe in pipe_list: if pipe.centerx == bird_rect.centerx: score += 1 break score_surface = font.render(str(score), True, (255, 255, 255)) score_rect = score_surface.get_rect(center=(144, 50)) screen.blit(score_surface, score_rect) # 移动地面 screen.blit(base_image, (0, 450)) # 更新屏幕 pygame.display.update() ``` 注意:在运行此代码之前,需要将相关图像文件放置在名为“assets”的文件夹中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值