报表求大虾优化或解决方案

 

private String getSQL(String strDate,String endDate){
		String sql = "select t.arlncd,t.fleetcd,sum(t.flightnum) flightnum,sum(t.incountry) incountry,sum(t.international) international,"
		             +" sum(t.transport) transport,sum(t.freight) freight,sum(t.pilotnum) pilotnum,sum(t.capnum) capnum,sum(t.capflytime) capflytime,"
		             +" sum(t.fonum) fonum,sum(t.foflytime) foflytime,sum(t.groupnum) groupnum,sum(t.mttime) mttime,sum(t.motime) motime,"
		             +" sum(t.segtime) segtime,sum(t.bttime) bttime,sum(t.botime) botime"
        +" from (select substr(fd.arlncd, 1, 3) arlncd,fd.fleetcd fleetcd,0 flightNum,0 incountry,0 international,case when fd.flighttype = 'B/W' or fd.flighttype = 'C/B' or"
	  			+" fd.flighttype = 'F/H' or fd.flighttype = 'W/Z' or fd.flighttype = 'Z/P' or fd.flighttype = 'Z/X' then fd.flytime else 0 end transport,"
	  			+" case when fd.flighttype = 'H/G' or fd.flighttype = 'H/Y' then fd.flytime else 0 end freight,0 pilotNum,0 capNum,0 capFlyTime,"
	  			+" 0 foNum,0 foFlyTime,0 groupnum,0 mtTime,0 moTime,0 segTime,0 btTime,0 boTime from pilotduty pd left join flyduty fd on pd.flyduty_id = fd.id"
	  			+" where fd.flighttype in ('H/G', 'H/Y', 'B/W', 'C/B', 'F/H', 'W/Z', 'Z/P', 'Z/X') and fd.strdt between to_date('"+strDate+"','YYYY-MM-DD') and to_date('"+endDate+"','YYYY-MM-DD')" 
	  			+" union all select substr(fd.arlncd, 1, 3) arlncd, fd.fleetcd fleetcd,0 flightNum,0 incountry,0 international,"
	  			+" 0 transport,0 freight,0 pilotNum,0 capNum,sum(decode(pd.identify, 'CAP', pd.flytime, 0)) capFlyTime,0 foNum,"
	  			+" sum(decode(pd.identify, 'F/O', pd.flytime, 'S/O', pd.flytime, 0)) foFlyTime,0 groupnum,0 mtTime,0 moTime,0 segTime,0 btTime,0 boTime"
  			+" from flyduty fd left join pilotduty pd on pd.flyduty_id = fd.id where (pd.identify = 'CAP' or pd.identify = 'F/O' or pd.identify = 'S/O')"
  			+" and fd.arlncd is not null and fd.fleetcd is not null and fd.strdt between to_date('"+strDate+"','YYYY-MM-DD') and to_date('"+endDate+"','YYYY-MM-DD')" 
  			+"  group by fd.arlncd, fd.fleetcd having fd.arlncd is not null"
  			+" union all"
  			+" select p.arlcd,p.fleetcd,0 flightNum,0 incountry,0 international,0 transport,0 freight,count(*) pilotNum,0 capNum,0 capFlyTime,0 foNum,"
  			+" 0 foFlyTime,0 groupnum,0 mtTime,0 moTime,0 segTime,0 btTime,0 boTime from (select substr(f.arlncd, 1, 3) arlcd, f.fleetcd"
  			+" from flyduty f where f.arlncd is not null and f.fleetcd is not null group by f.arlncd, f.fleetcd) p left join (select"
  			+" substr(registration_base_code,-4,3) arlcd,pt.fleet from post pt"
  			+" left join subranktype s on pt.subranktype_id = s.id left join person pn on pt.person_id = pn.id where type = '注册岗位'"
  			+" and s.fd_ind = '飞行员' and pn.deleted = 0 and pt.effdt <= to_date('"+endDate+"', 'YYYY-MM-DD') and (pt.expdt is null or pt.expdt>to_date('"+strDate+"', 'YYYY-MM-DD'))"
  			+" and pt.fleet is not null and pn.registration_base_code is not null) t on t.arlcd = p.arlcd"
  			+" where t.fleet like '%' || p.fleetcd || '%' group by p.arlcd, p.fleetcd"
  			+" union all"    
  			+" select p.arlcd, p.fleetcd,0 flightNum,0 incountry,0 international,0 transport,0 freight,0 pilotNum,count(*) capNum,0 capFlyTime,"
  			+" 0 foNum,0 foFlyTime,0 groupnum,0 mtTime,0 moTime,0 segTime,0 btTime,0 boTime from (select substr(f.arlncd, 1, 3) arlcd, f.fleetcd"
  			+" from flyduty f where f.arlncd is not null and f.fleetcd is not null group by f.arlncd, f.fleetcd) p left join (select"
  			+" substr(registration_base_code,-4,3) arlcd,pt.fleet from post pt left join subranktype s on pt.subranktype_id = s.id"
  			+" left join person pn on pt.person_id = pn.id where pt.type = '注册岗位' and s.rank_cd = 'CAP' or s.rank_cd = 'CAPT' and pn.deleted = 0"
  			+" and pt.effdt <= to_date('"+endDate+"', 'YYYY-MM-DD') and (pt.expdt is null or pt.expdt > to_date('"+strDate+"', 'YYYY-MM-DD'))"
  			+" and pt.fleet is not null) t on t.arlcd = p.arlcd where t.fleet like '%' || p.fleetcd || '%' group by p.arlcd, p.fleetcd"
  			+" union all"  
  			+" select p.arlcd,p.fleetcd,0 flightNum,0 incountry,0 international,0 transport,0 freight,0 pilotNum,0 capNum,0 capFlyTime,"
  			+" count(*) foNum,0 foFlyTime,0 groupnum,0 mtTime,0 moTime,0 segTime,0 btTime,0 boTime from (select substr(f.arlncd, 1, 3) arlcd, f.fleetcd fleetcd"
  			+" from flyduty f where f.arlncd is not null and f.fleetcd is not null group by f.arlncd, f.fleetcd) p left join (select"
  			+" substr(registration_base_code,-4,3) arlcd,pt.fleet from post pt left join subranktype s on pt.subranktype_id = s.id"
  			+" left join person pn on pt.person_id = pn.id where pt.type = '注册岗位' and s.rank_cd = 'FO' and pn.deleted = 0"
  			+" and pt.effdt <= to_date('"+endDate+"', 'YYYY-MM-DD') and (pt.expdt is null or pt.expdt > to_date('"+strDate+"', 'YYYY-MM-DD')) and pt.fleet is not null) t on t.arlcd = p.arlcd"
  			+" where t.fleet like '%' || p.fleetcd || '%' group by p.arlcd, p.fleetcd"
  			+" union all"
  			+" select tp.orgunitcoding arlncd,tp.fleetcd fleetcd,0 flightNum,0 incountry,0 international,0 transport,0 freight,0 pilotNum,0 capNum,0 capFlyTime,"
  			+" 0 foNum,0 foFlyTime,count(*) groupnum,sum(tf.teachertime) mtTime,sum(tf.observerstime) moTime,0 segTime,0 btTime,0 boTime"
  			+" from trainingplan tp left join trainingproject tg on tg.id = tp.trainingproject_id left join trainingsubject ts on ts.id = tg.trainingsubject_id"
  			+" left join trainingpersoninfo tf on tf.trainingplan_id = tp.id where ts.subjecttype = '模拟机训练'"
  			+" and tf.startdate_str between '"+strDate+"' and '"+endDate+"' group by tp.orgunitcoding, tp.fleetcd"
  			+" union all"
  			+" select tp.orgunitcoding arlncd,tp.fleetcd fleetcd,0 flightNum,0 incountry,0 international,0 transport,0 freight,0 pilotNum,0 capNum,0 capFlyTime,"
  			+" 0 foNum,0 foFlyTime,0 groupnum,0 mtTime,0 moTime,0 segTime,sum(tf.teachertime) btTime,sum(tf.observerstime) boTime from trainingplan tp"
  			+" left join trainingproject tg on tg.id = tp.trainingproject_id left join trainingpersoninfo tf on tf.trainingplan_id = tp.id"
  			+" where tg.isplacetraining = '是' and tf.startdate_str between '"+strDate+"' and '"+endDate+"' group by tp.orgunitcoding, tp.fleetcd"
  			+" union all"
  			+" select fd.fleetcd fleetcd,fd.arlncd arlncd,0 flightNum,0 incountry,0 international,0 transport,0 freight,0 pilotNum,0 capNum,"
  			+" 0 capFlyTime,0 foNum,0 foFlyTime,0 groupnum,0 mtTime,0 moTime,pd.segtimes segTime,0 btTime,0 boTime from pilotduty pd"
  			+" left join flyduty fd on pd.flyduty_id = fd.id where fd.flighttype = 'K/L' and fd.strdt between to_date('"+strDate+"', 'YYYY-MM-DD') and to_date('"+endDate+"', 'YYYY-MM-DD')"
  		    +" ) t group by t.arlncd,fleetcd";
		return sql.toUpperCase();
	}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1.按国人习惯的表格设计,未满一页自动以空表格补齐 (可选) 2.对预览窗口进行了重新设计,在预览时可重设边距及纸张(增加了用户调用页面设置等内容),更加美观和实用. 3.完全重写了PreparePrint过程,不再出现打印空页或有时不能完全打印数据等问题 4.新增部份函数和过程,可在预览时由最终用户通过拖动边框线立即永久性修改某一单元格宽. 5.修改了报表模板编辑器(再不需要EXE文件了,但任可编译CreportEdit工程得到CReportEdit.exe文件),与控件为一体,双击即可调用。pageNo有3种样式可选(第?页,第?/?页,第?-?页) 6.增加了数据表字段列表按健,可通过拖动字段自动填入模板单元格中. 7.增加了在模板中控制数值显示格式的功能,不用在字段属性中设置,由此也可不必再设置永久字段了。 8.更正了拆分单元格后,不能对齐的问题。 9.增加了在IDE中的预览和模板编辑器调用功能. 10.增加了两个函数,可实现每一页及整个表的每列汇总功能,各列的和还可做加减运算并将结果填入任意列中。 11.增加了图片功能(.bmp.jpg.ico类型均可),包括对数据库中的图像字段均可预览打印. 12.新增及完善了动态报表的支持功能,可对单个cell或成批cell进行设置或赋值. 13.将生成临时文件改为用内存流 14.增加了OnSetCellFont事件,可根据条件,动态设置报表中单元格字体和大小,如可将某记录中等于"张三"的字符用大字体显示打印. 15.实现非100%显示比例下编辑和拖动表格线修改单元格宽度等. 16.定义并显示打印上标和下标功能. 17.实现字符间距及行距自定义.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值