• 报表后台数据处理


    //1.informix  数据库 更新表索引,提高查询效率。
    //update statistics for table year_decrsubjtotal
    
    1.生成raq中使用的datestart ,代码在form 表达中。
    	var d_s = form.datekey.value;
            	var d_start = d_s.substr(0,4);
            	var m = d_s.substr(5,2);
            	
    			if(m=='04' || m=='05' || m=='06'){
    				d_start = d_start+"-04-01";
    			}else if(m=='07' || m=='08' || m=='09'){
    				d_start = d_start+"-07-01";
    			}else if(m=='10' || m=='11' || m=='12'){
    				d_start = d_start+"-10-01";
    			}else{
    				d_start = d_start+"-01-01";
    			}
    			
    			form.datestart.value = d_start;
    			
    2.抽数据两种方式。
    	(1).cbsCard_No_tran_q.java( Object[] objs = (Object[]) maprst.get(ikey) 法) //16
    	String isql = "insert into card_no_tran_q(datekey,quarter," +
    						"deptid,dqfkd,qmkld,qmkslp," +
    						"ctrancx,ctrancxamt,ctranqx,ctranqxamt,ctranxf,ctranxfamt," +
    						"ctranzz,ctranqzzamt,atmsbcnt,ctranatm,ctranatmamt)" +
    						" VALUES('" + oDateKeyStr+ "','"+quarter+"',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    	
    	(2).cbsPaymentStruc_q.java(insert into * select * from 法)
    	sql = "delete from paymentStruc_q where year =" + i_year + " and quarter=" + i_quarter;
    			logger.info("sql=" + sql);
    			stm.executeUpdate(sql);
    			/* 根据paymentStruc表生成paymentStruc_q表 */
    			sql = "insert into paymentStruc_q (year,quarter,deptid,Itemid,qcnt,qamt) select " + i_year + "," + i_quarter + ",deptid,Itemid,sum(cnt),sum(amt) from paymentStruc where datekey>='"
    					+ Qbegin + "' and datekey<='" + date + "' group by deptid,Itemid";
    			logger.info("sql=" + sql);
    	(3).cbsBillBusiness_q6016(非数组法)
    	String sql= "select deptid,sum(case when subjid in ('80602','80604') then crcnt else 0 end) as zl1cnt,sum(case when subjid in ('80602','80604') then cramt else 0 end) as zl1amt, sum(case when"+
    				 " subjid in ('13010102','13010104') then decnt else 0 end) as zl2cnt,sum(case when subjid in ('13010102','13010104') then deamt else 0 end) as zl2amt,sum(case when subjid in"+
    				 " ('13010102','13010104') and datekey='"+date+"' then debal else 0 end) as zl2bal, sum(case when subjid in ('60201','60202') then crcnt else 0 end) as zl3cnt,sum(case when subjid in ('60201','60202') then"+
    				 " cramt else 0 end) as zl3amt,sum(case when subjid in ('60201','60202') and datekey='"+date+"' then crbal else 0 end) as zl3bal, sum(case when subjid in ('13010101','13010103') then decnt else 0 end) as"+
    				 " zl4cnt,sum(case when subjid in ('13010101','13010103') then deamt else 0 end) as zl4amt,sum(case when subjid in ('13010101','13010103') and datekey='"+date+"' then debal else 0 end) as zl4bal, sum(case"+
    				 " when subjid in ('20210111','20210112','20210113','20210114','20210311','20210312','20210313','20210314') then crcnt else 0 end) as zl5cnt,sum(case when subjid in"+
    				 " ('20210111','20210112','20210113','20210114','20210311','20210312','20210313','20210314') then cramt else 0 end) as zl5amt,sum(case when subjid in"+
    				 " ('20210111','20210112','20210113','20210114','20210311','20210312','20210313','20210314') and datekey='"+date+"' then crbal else 0 end) as zl5bal, sum(case when subjid in"+
    				 " ('20040201','20040202','20040203','20040204','20040211','20040212','20040213','20040214') then crcnt else 0 end) as zl6cnt,sum(case when subjid in"+
    				 " ('20040201','20040202','20040203','20040204','20040211','20040212','20040213','20040214') then cramt else 0 end) as zl6amt,sum(case when subjid in"+
    				 " ('20040201','20040202','20040203','20040204','20040211','20040212','20040213','20040214') and datekey='"+date+"' then crbal else 0 end) as zl6bal, sum(case when subjid in ('13037101','13037103') and datekey='"+date+"' then"+
    				 " debal else 0 end) as zl7bal from s_subjtotal_org where datekey>='"+Qbegin+"' and datekey<='"+date+"' group by deptid";
    				Statement stm = conn.createStatement();
    				String dsql = " DELETE FROM billbusiness_q WHERE year=" + y + " and quarter=" + quarter; // 清空数据
    				stm.executeUpdate(dsql);
    				int flag = 0;
    				String isql = "insert into billbusiness_q(year,quarter,deptid,zl,cnt1,amt1,cbal) VALUES(?,?,?,?,?,?,?)";
    				logger.debug("插入sql=" + isql);
    				System.out.println(isql);				
    				pst = conn.prepareStatement(isql);
    				ResultSet rs = stm.executeQuery(sql);
    				while (rs.next()) {
    					
    					pst.setInt(1, y);
    					pst.setInt(2, quarter);
    					pst.setString(3, rs.getString("deptid"));
    					pst.setString(4, "1");
    					pst.setInt(5, rs.getInt("zl1cnt"));
    					pst.setDouble(6, rs.getDouble("zl1amt"));
    					pst.setDouble(7,0);
    					pst.addBatch();
    					
    					pst.setInt(1, y);
    					pst.setInt(2, quarter);
    					pst.setString(3, rs.getString("deptid"));
    					pst.setString(4, "2");
    					pst.setInt(5, rs.getInt("zl2cnt"));
    					pst.setDouble(6, rs.getDouble("zl2amt"));
    					pst.setDouble(7, rs.getDouble("zl2bal"));
    					pst.addBatch();
    					
    					pst.setInt(1, y);
    					pst.setInt(2, quarter);
    					pst.setString(3, rs.getString("deptid"));
    					pst.setString(4, "3");
    					pst.setInt(5, rs.getInt("zl3cnt"));
    					pst.setDouble(6, rs.getDouble("zl3amt"));
    					pst.setDouble(7, rs.getDouble("zl3bal"));
    					pst.addBatch();
    					
    					pst.setInt(1, y);
    					pst.setInt(2, quarter);
    					pst.setString(3, rs.getString("deptid"));
    					pst.setString(4, "4");
    					pst.setInt(5, rs.getInt("zl4cnt"));
    					pst.setDouble(6, rs.getDouble("zl4amt"));
    					pst.setDouble(7, rs.getDouble("zl4bal"));
    					pst.addBatch();
    					
    					pst.setInt(1, y);
    					pst.setInt(2, quarter);
    					pst.setString(3, rs.getString("deptid"));
    					pst.setString(4, "5");
    					pst.setInt(5, rs.getInt("zl5cnt"));
    					pst.setDouble(6, rs.getDouble("zl5amt"));
    					pst.setDouble(7, rs.getDouble("zl5bal"));
    					pst.addBatch();
    					
    					pst.setInt(1, y);
    					pst.setInt(2, quarter);
    					pst.setString(3, rs.getString("deptid"));
    					pst.setString(4, "6");
    					pst.setInt(5, rs.getInt("zl6cnt"));
    					pst.setDouble(6, rs.getDouble("zl6amt"));
    					pst.setDouble(7, rs.getDouble("zl6bal"));
    					pst.addBatch();
    					
    					pst.setInt(1, y);
    					pst.setInt(2, quarter);
    					pst.setString(3, rs.getString("deptid"));
    					pst.setString(4, "7");
    					pst.setInt(5, 0);
    					pst.setDouble(6, 0);
    					pst.setDouble(7, rs.getDouble("zl7bal"));
    					pst.addBatch();
    					
    					flag = flag+7;
    					
    					if (flag == 30) {
    						flag = 0;
    						pst.executeBatch();
    					}
    				}
    				if (flag > 0)
    					pst.executeBatch();
    				rs.close();
    

      

  • 相关阅读:
    布隆过滤器(Bloom Filter)简要介绍
    利用skipList(跳表)来实现排序(待补充)
    rpc、socket、tcp/udp简要梳理
    微服务、rest/restful、springmvc、http简要梳理
    Kafka生产者producer简要总结
    相同数据源情况下,使用Kafka实时消费数据 vs 离线环境下全部落表后处理数据,结果存在差异
    kafka部分重要参数配置-broker端参数
    spring boot-- 三种启动方式
    spring boot --部署war到tomcat中
    阿里云服务上面部署redis + 本地Redis客户端连接方法
  • 原文地址:https://www.cnblogs.com/xrhou12326/p/3511617.html
Copyright © 2020-2023  润新知