Flex4 在advanceddatagrid组件中以“树形结构”显示数据

flex前台页面:

<?xml version="1.0" encoding="utf-8"?>
<ui:UIApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:ui="com.ydtf.ipcc.ui.*"
			   width="900" height="100%"
			   creationComplete="application1_creationCompleteHandler(event)">
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import com.ydtf.cloud.proto.Stat.Sqtj;
			import com.ydtf.cloud.proto.Stat.SqtjList;
			import com.ydtf.eccms.utility.NetHelper;
			import com.ydtf.ipcc.svc.ServiceCaller;
			import com.ydtf.ipcc.svc.ServiceInterface;
			
			import mx.collections.ArrayCollection;
			import mx.events.FlexEvent;
			
			[Bindable]
			private var inPatameter:Sqtj=new Sqtj();//查询参数
		
			[Bindable]
			private var dpFlat:ArrayCollection = new ArrayCollection();
			
			protected function application1_creationCompleteHandler(event:FlexEvent):void
			{
				callServer_sel(getInParameter());
			}
			
			private function getInParameter():Sqtj
			{
				inPatameter.kssj=tjsj.text+"000000";
				inPatameter.jzsj=jztjsj.text+"235959";
				return inPatameter;
			}
			private function callServer_sel(inParameter:Sqtj):void
			{		 
				var req:Sqtj=new Sqtj();
				req=inParameter;
				var rep:SqtjList=new SqtjList();
				ServiceInterface.addServiceUrl(NetHelper.getServiceURL());
				var sc:ServiceCaller =new ServiceCaller(ServiceInterface.getInstance());
				sc.protoCall2("com.ydtf.cloud.service.stat.StatService","querySqtj",req,rep,queryBack,null,"gbk");
			}
			
			private function queryBack(rep:SqtjList,obj:Object):void
			{
				dpFlat=handlerBack(rep.items);
				jg.source=dpFlat;
				jg.refresh();
				getDataADG();
			}
			
			private function handlerBack(array:Array):ArrayCollection
			{
				var sqtjAC:ArrayCollection=new ArrayCollection();
				for(var i:int=0;i<array.length;i++)
				{
					var obj:Object=new Object();
					obj.id=array[i].id;
					obj.tjlb=array[i].tjlb;
					
					obj.jgbm=array[i].jgbm;
					obj.sjjgbm=array[i].sjjgbm;
					obj.jgmc=array[i].jgmc;
					obj.sjjgmc=array[i].sjjgmc;
					
					obj.xjsqs=array[i].xjsqs;
					obj.xjtgs=array[i].xjtgs;
					obj.xjkts=array[i].xjkts;
					obj.xjtgl=(array[i].xjtgl).toFixed(2);
					
					obj.dzsqs=array[i].dzsqs;
					obj.dztgs=array[i].dztgs;
					obj.dztgl=(array[i].dztgl).toFixed(2);
					
					obj.ccsqs=array[i].ccsqs;
					obj.cctgs=array[i].cctgs;
					obj.cctgl=(array[i].cctgl).toFixed(2);
					
					obj.zmsqs=array[i].zmsqs;
					obj.zmtgs=array[i].zmtgs;
					obj.zmtgl=(array[i].zmtgl).toFixed(2);
					
					sqtjAC.addItem(obj);			
				}
				return sqtjAC;
			}
			
			
			protected function query_clickHandler(event:MouseEvent):void
			{
				callServer_sel(getInParameter());
			}
			
			private function modifyADG():void
			{
				var temp:Sqtj=new Sqtj();
				var obj:Object  = sqtj_ADG.selectedItem ;
			}
			
			public function getDataADG():void
			{
				var temp:Sqtj=new Sqtj();
				var obj:Object = sqtj_ADG.dataProvider.source.source;
			}
			
			public function summaryOfSummaryCalculationBegin(value:Object, field:SummaryField2):Object
			{
				var obj:Object=new Object();
				obj.xjtgl=1;
				return obj;
			}
			
			
		]]>
	</fx:Script>                                                                                     <s:VGroup width="100%" height="100%">
		<ui:UIAppControlBar width="100%" height="48" titleLabel="|资源服务申请统计"/>
		<s:HGroup>
			<s:Label paddingTop="4" text="开始时间"/>
			<mx:DateField id="tjsj" width="130" formatString="YYYYMMDD" textAlign="center"/>
			<s:Label paddingTop="4" text="截至时间"/>
			<mx:DateField id="jztjsj" width="130" formatString="YYYYMMDD" textAlign="center"/> 
			<s:Button label="查询" id="query" click="query_clickHandler(event)"/>
		</s:HGroup>
		<s:Scroller width="100%" height="100%">
			<s:VGroup width="100%" height="100%">
				<mx:AdvancedDataGrid id="sqtj_ADG" width="100%" height="100%" initialize="jg.refresh();" >
					<mx:dataProvider>
						<mx:GroupingCollection2 id="jg" source="{dpFlat}">
							<mx:Grouping>
								<mx:GroupingField name="sjjgmc">
									<mx:summaries>
										<mx:SummaryRow summaryPlacement="group">
											<mx:fields>
												<mx:SummaryField2 dataField="xjsqs" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="xjtgs" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="xjkts" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="xjtgl" summaryOperation="ISummaryCalculator"/>
												
												<mx:SummaryField2 dataField="dzsqs" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="dztgs" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="dztgl" summaryOperation="ISummaryCalculator"/>
												
												<mx:SummaryField2 dataField="ccsqs" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="cctgs" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="cctgl" summaryOperation="ISummaryCalculator"/>
												
												<mx:SummaryField2 dataField="zmsqs" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="zmtgs" summaryOperation="SUM"/>
												<mx:SummaryField2 dataField="zmtgl" summaryOperation="ISummaryCalculator"/>
											</mx:fields>
										</mx:SummaryRow>
									</mx:summaries>
								</mx:GroupingField>
							</mx:Grouping>
						</mx:GroupingCollection2>
					</mx:dataProvider>
					<mx:groupedColumns>						                        <mx:AdvancedDataGridColumn dataField="jgmc" headerText="机构名称"/>
						<mx:AdvancedDataGridColumnGroup headerText="虚机申请统计">
							<mx:AdvancedDataGridColumn dataField="xjsqs" headerText="申请数"/>
							<mx:AdvancedDataGridColumn dataField="xjtgs" headerText="通过数"/>
							<mx:AdvancedDataGridColumn dataField="xjkts" headerText="开通数"/>
							<mx:AdvancedDataGridColumn dataField="xjtgl" headerText="通过率(%)"/>
						</mx:AdvancedDataGridColumnGroup>
						<mx:AdvancedDataGridColumnGroup headerText="IP地址申请统计">
							<mx:AdvancedDataGridColumn dataField="dzsqs" headerText="申请数"/>
							<mx:AdvancedDataGridColumn dataField="dztgs" headerText="通过数"/>
							<mx:AdvancedDataGridColumn dataField="dztgl" headerText="通过率(%)"/>
						</mx:AdvancedDataGridColumnGroup>
						<mx:AdvancedDataGridColumnGroup headerText="存储申请统计">
							<mx:AdvancedDataGridColumn dataField="ccsqs" headerText="申请数"/>
							<mx:AdvancedDataGridColumn dataField="cctgs" headerText="通过数"/>
							<mx:AdvancedDataGridColumn dataField="cctgl" headerText="通过率(%)"/>
						</mx:AdvancedDataGridColumnGroup>
						<mx:AdvancedDataGridColumnGroup headerText="桌面申请统计">
							<mx:AdvancedDataGridColumn dataField="zmsqs" headerText="申请数"/>
							<mx:AdvancedDataGridColumn dataField="zmtgs" headerText="通过数"/>
							<mx:AdvancedDataGridColumn dataField="zmtgl" headerText="通过率(%)"/>
						</mx:AdvancedDataGridColumnGroup>
					</mx:groupedColumns>
				</mx:AdvancedDataGrid>
			</s:VGroup>
		</s:Scroller>
	</s:VGroup>
</ui:UIApplication>

java后台服务:

public SqtjList querySqtj(String strdata)  throws Exception 
	{
		Sqtj server = (Sqtj) MessageUtil.convert2Message(strdata,Sqtj.getDefaultInstance());
		SqtjList.Builder result = SqtjList.newBuilder();
		String kssj=server.getKssj();
		String jzsj=server.getJzsj();
		if(kssj=="")
		{
			kssj="00000000000000";
		}
		if(jzsj=="")
		{
			jzsj="99999999999999";
		}
		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet res = null; 
		String execSql="select org.*,"+
			"nvl(t1.xjsqs,0) xjsqs,"+
			"nvl(t2.xjkts,0) xjtgs,"+
			"nvl(t2.xjkts,0) xjkts,"+
			"nvl(t2.xjkts / t1.xjsqs,0) xjtgl,"+
			"0 dzsqs,0 dztgs,0 dztgl,0 ccsqs,0 cctgs,0 cctgl,"+
			"nvl(t3.zmsqs,0) zmsqs,"+
			"nvl(t4.zmtgs,0) zmtgs,"+
			"nvl(t4.zmtgs / t3.zmsqs,0) zmtgl "+
			"from (select d1.jgbm,d1.jgmc,d1.sjjgbm,d2.jgmc,d2.sjjgmc from "+
			"(select orgid jgbm,orgname jgmc,decode(parentdeptid,-1,0,parentdeptid)sjjgbm from sys_orginfo)d1,"+
			"(select orgid jgbm,orgname jgmc,decode(parentdeptid,-1,0,parentdeptid)sjjgbm from sys_orginfo)d2 "+
			"where d1.sjjgbm=d2.jgbm) org,"+
			"(select orgid jgbm, count(distinct transactionid) xjsqs "+
			"from flow_workflow_rec t "+
			"where t.applytime between ? and ? "+
			"group by orgid) t1,"+
			"(select orgid jgbm, count(distinct transactionid) xjkts "+
			"from flow_workflow_rec "+
			"where nodeid = 10000005 "+
			"and applytime between ? and ? "+
			"group by orgid) t2,"+
			"(select to_number(jgbm) jgbm, count(sqid) zmsqs "+
			"from mh_zmsq t "+
			"where t.sqsj between ? and ? "+
			"group by to_number(jgbm)) t3,"+
			"(select to_number(jgbm) jgbm, count(sqid) zmtgs "+
			"from mh_zmsq t "+
			"where ip is not null "+
			"and t.sqsj between ? and ? "+
			"group by to_number(jgbm)) t4 "+
			"where org.jgbm = t1.jgbm(+) "+
			"and org.jgbm = t2.jgbm(+) "+
			"and org.jgbm = t3.jgbm(+) "+
			"and org.jgbm = t4.jgbm(+)";
		try
		{		
				conn = dbPool.getConnection();
				ps = conn.prepareStatement(execSql);
				ps.setString(1, kssj);
				ps.setString(2, jzsj);
				ps.setString(3, kssj);
				ps.setString(4, jzsj);
				ps.setString(5, kssj);
				ps.setString(6, jzsj);
				ps.setString(7, kssj);
				ps.setString(8, jzsj);
				res = ps.executeQuery();
				while(res.next())
				{
					Sqtj.Builder sqtj = Sqtj.newBuilder();
					sqtj.setJgbm(res.getString("JGBM"));
					sqtj.setSjjgbm(res.getString("SJJGBM"));
					sqtj.setJgmc(res.getString("JGMC"));
					sqtj.setSjjgmc(res.getString("SJJGMC"));
					sqtj.setXjsqs(res.getInt("XJSQS"));
					sqtj.setXjtgs(res.getInt("XJTGS"));
					sqtj.setXjkts(res.getInt("XJKTS"));
					sqtj.setXjtgl(res.getFloat("XJTGL"));
					sqtj.setDzsqs(res.getInt("DZSQS"));
					sqtj.setDztgs(res.getInt("DZTGS"));
					sqtj.setDztgl(res.getFloat("DZTGL"));
					sqtj.setCcsqs(res.getInt("CCSQS"));
					sqtj.setCctgs(res.getInt("CCTGS"));
					sqtj.setCctgl(res.getFloat("CCTGL"));
					sqtj.setZmsqs(res.getInt("ZMSQS"));
					sqtj.setZmtgs(res.getInt("ZMTGS"));
					sqtj.setZmtgl(res.getFloat("ZMTGL"));
					result.addItems(sqtj);
				}
		}
		finally
		{		
			dbPool.dbClose(ps, res);
			if(conn != null)
				dbPool.closeConnection();
		}
		return result.build();		
	}

运行效果图:

Flex4 在advanceddatagrid组件中以“树形结构”显示数据_第1张图片

 

你可能感兴趣的:(树形结构,flex4)