现在的位置: 首页 > 综合 > 正文

about work at seven

2013年08月28日 ⁄ 综合 ⁄ 共 6000字 ⁄ 字号 评论关闭
  1. -------------------------------------2008.7.23 四级疾病统计 -------------------------------------------------------
  2. /********************************************** 一级数据统计 ************************************************/
  3. //没有加入时间 
  4. select mc,sum(cou) as cous ,yiji from (
  5. select  f.mc,i.cou,f.yiji
  6. from 
  7. (select e.sanji,h.cou  from csm_icd_jblx e,
  8. (select b.mc,count(a.zd) as cou,b.flid
  9.  FROM ywb_mz_bingli a,csm_icd_10  b
  10. where  a.zd=b.mc  and a.siteid='4114210102'
  11. group by b.mc) h
  12. where e.id=h.flid) i,csm_icd_jblx f
  13. where substring(i.sanji,1,5)=f.yiji
  14. union all 
  15. SELECT c.mc,count(a.zd),c.yiji
  16.  FROM ywb_mz_bingli a,csm_icd_jblx c
  17. where  a.zd=c.mc 
  18.            and  c.yiji<>'' and c.yiji is not null and c.erji<>'' and c.erji is not null 
  19.           and c.sanji<>'' and c.sanji is not null
  20. group by c.mc
  21. union all 
  22. select f.mc,h.cou,f.yiji
  23. from (
  24. SELECT c.mc,count(a.zd) as cou,substring(c.erji,1,5) as yiji
  25.  FROM ywb_mz_bingli a,csm_icd_jblx c
  26. where  a.zd=c.mc 
  27.            and c.erji<>'' and c.erji is not null
  28.           and (c.sanji='' or c.sanji is null)
  29.  group by c.mc) h,csm_icd_jblx f
  30. where h.yiji=f.yiji
  31. union all 
  32. select f.mc,h.cou,f.yiji
  33. from (
  34. SELECT c.mc,count(a.zd) as cou,substring(c.sanji,1,5) as yiji
  35.  FROM ywb_mz_bingli a,csm_icd_jblx c
  36. where  a.zd=c.mc 
  37.            and c.sanji <>'' and c.sanji is not null
  38.  group by c.mc) h,csm_icd_jblx f
  39. where  h.yiji=f.yiji
  40. )  as t group by mc order by cous desc
  41. /********************************************** 二级数据统计 ************************************************/
  42. //根据一级找二级数据 
  43. select mc,sum(cou) as cous ,erji  from (
  44. select  f.mc,i.cou,f.erji
  45. from 
  46. (select e.sanji,h.cou
  47.  from csm_icd_jblx e,(select b.mc,count(a.zd) as cou,b.flid
  48.  FROM ywb_mz_bingli a,csm_icd_10  b
  49. where  a.zd=b.mc and a.jzrq between '2008-01-01' and '2008-07-23'   and a.siteid='4114210102'
  50. group by b.mc) h
  51. where e.id=h.flid) i,csm_icd_jblx f
  52. where substring(i.sanji,1,9)=f.erji
  53. union all
  54. SELECT c.mc,count(a.zd) as cou,c.erji
  55.  FROM ywb_mz_bingli a,csm_icd_jblx c
  56. where  a.zd=c.mc and a.jzrq between '2008-01-01' and '2008-07-23' 
  57.            and c.erji<>'' and c.erji is not null
  58.           and (c.sanji='' or c.sanji is null)
  59.  group by c.mc
  60. union all
  61. select f.mc,h.cou,f.erji
  62. from (
  63. SELECT c.mc,count(a.zd) as cou,substring(c.sanji,1,9) as erji
  64.  FROM ywb_mz_bingli a,csm_icd_jblx c
  65. where  a.zd=c.mc and a.jzrq between '2008-01-01' and '2008-07-23' 
  66.            and c.sanji <>'' and c.sanji is not null
  67.  group by c.mc) h,csm_icd_jblx f
  68. where  h.erji=f.erji
  69. )as t  where substring(erji,1,5)='a0015' group by mc order by cous desc
  70. /********************************************** 三级数据统计 ************************************************/
  71. //根据二级找三级 
  72. select mc,sum(cou) as cous ,sanji,id  from (
  73. select e.mc,h.cou,e.sanji,e.id
  74.  from csm_icd_jblx e,(select b.mc,count(a.zd) as cou,b.flid
  75.  FROM ywb_mz_bingli a,csm_icd_10  b
  76. where  a.zd=b.mc and a.jzrq between '2008-01-01' and '2008-07-23'   and a.siteid='4114210102'
  77. group by b.mc) h
  78. where e.id=h.flid and substring(sanji,1,9)='a00150005'
  79. union all
  80. SELECT c.mc,count(a.zd) as cou,c.id,c.sanji
  81.  FROM ywb_mz_bingli a,csm_icd_jblx c
  82. where  a.zd=c.mc and a.jzrq between '2008-01-01' and '2008-07-23' 
  83.            and c.sanji <>'' and c.sanji is not null and substring(sanji,1,9)='a00150005'
  84.      group by c.mc
  85. )
  86. as t  group by mc order by cous desc
  87. /********************************************** 三级数据统计 ************************************************/
  88. //根据三级找四级 
  89. SELECT b.mc,count(a.zd) as cou
  90.  FROM ywb_mz_bingli a,csm_icd_10  b
  91. where  a.zd=b.mc  and a.jzrq between '2008-01-01' and '2008-07-23'   and a.siteid='4114210102' and b.flid='141'
  92. group by b.mc
  93. order by cou desc
  94. ----------------------------------------------------------------------------------------------------------------------
  95. <1> DAO中使用return this.getSession().createSQLQuery(sql).list();方法执行纯sql,偶尔会有问题发生,type不支持,故改用JDBC方式统计数据,使用方法如下
  96.    /**
  97.      *  根据sql查询rs返回
  98.      */
  99.     public ResultSet findDataByConditon(String sql){
  100.         ResultSet rs=null;
  101.         try {
  102.             rs=this.getSession()
  103.             .connection()
  104.             .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)
  105.             .executeQuery(sql);
  106.         } catch (DataAccessResourceFailureException e) {    
  107.             e.printStackTrace();
  108.         } catch (HibernateException e) {
  109.             e.printStackTrace();
  110.         } catch (IllegalStateException e) {
  111.             e.printStackTrace();
  112.         } catch (SQLException e) {
  113.             e.printStackTrace();
  114.         }
  115.         return rs;
  116.     }
  117. <2> 在新的集合中加入ResultSet中数据...(threesick_rs为ResultSet对象)
  118.     new_list.add(new Object[]{threesick_rs.getString(1),threesick_rs.getString(2)});
  119. <3> 当使用纯sql查回数据带count,sum之类数据时,取其中的值...
  120.     页面中取:
  121.             <c:forEach var="record" items="${jb_list}" varStatus="status">${record[0]}</forEach>
  122.     类中取:    
  123.             for(int i=0;i<jb_list.size();i++){
  124.                 String sums = ((Object [])jb_list.get(i))[1].toString();
  125.                 befsum+=Integer.parseInt(sums);
  126.             }
  127. <4> 在统计图中使用下拉列表切换时: 使用js
  128. 先引入js:
  129. <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.2.6.pack.js"></script>
  130.            
  131. <script type="text/javascript">
  132. function changeImageType()
  133. {
  134.    var tjt=document.getElementById("tjtype").value;
  135.    var tjlx=document.getElementById("tjlx").value;
  136.    if(tjt=='zzt'){
  137.        $.get("<%=request.getContextPath()%>/ajax/mytj/jb/search/fourdata.do?begindate=${param.begindate}&enddate=${param.enddate}&seltype=${seltype}",{},function(data){document.getElementById("chartPhoto").src="<%=request.getContextPath()%>/view/mztj/jb/image.do?method=fourSickBar&tjlx="+tjlx;});  
  138.    }
  139.    if(tjt=='bzt'){
  140.        $.get("<%=request.getContextPath()%>/ajax/mytj/jb/search/fourdata.do?begindate=${param.begindate}&enddate=${param.enddate}&seltype=${seltype}",{},function(data){document.getElementById("chartPhoto").src="<%=request.getContextPath()%>/view/mztj/jb/image.do?method=fourSickPie&tjlx="+tjlx;});  
  141.    }
  142. }
  143. </script>
  144. <5> 使用ResultSet数据时,如果使用两次,那么在第二次取数据之前一定要将游标指回,否则数据丢失.
  145.     threesick_rs.beforeFirst();
  146.     
  147. <6> c标签格式化日期
  148. <fmt:formatDate pattern="yyyy-MM-dd" value="${record.mzbl.jzrq}" /> 

抱歉!评论已关闭.