d4c1ab9149632f112b6a7e3179f17614a71d1319.svn-base 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package com.sinosoft.em.baobiao.rcbb.service;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.util.HashMap;
  7. import java.util.Map;
  8. import javax.ws.rs.POST;
  9. import javax.ws.rs.Path;
  10. import javax.ws.rs.ProduceMime;
  11. import com.formaction.Utils;
  12. import com.persistence.DbConnection;
  13. import com.sinosoft.em.alert.duty.records.vo.EcmEmDuty;
  14. import com.sinosoft.em.baobiao.xianlutingyun.dao.ReportJSCdao;
  15. @Path("/ReportJSCService/")
  16. public class ReportJSCService{
  17. @ProduceMime("application/json")
  18. @POST
  19. @Path("/query")
  20. public String query(String params){
  21. String comp_id=Utils.getParameter("comp_id", params)==null?"":Utils.getParameter("comp_id", params);
  22. //String report_id=Utils.getParameter("report_id", params)==null?"":Utils.getParameter("report_id", params);
  23. String report_type="5";
  24. ReportJSCdao rjsc=new ReportJSCdao();
  25. String result=rjsc.query(report_type, comp_id);
  26. return result;
  27. }
  28. @ProduceMime("application/json")
  29. @POST
  30. @Path("/chartdata")
  31. public String chartdata(String params){
  32. String sqlSql = "select b.dept_name AS COMP_NAME , to_number(case WHEN TQ_TD_COUNT='' OR TQ_TD_COUNT IS NULL THEN 0 ELSE TQ_TD_COUNT END + " +
  33. "case WHEN YH_TD_COUNT='' OR YH_TD_COUNT IS NULL THEN 0 ELSE YH_TD_COUNT END +" +
  34. "case WHEN TJYH_TD_COUNT='' OR TJYH_TD_COUNT IS NULL THEN 0 ELSE TJYH_TD_COUNT END +" +
  35. "case WHEN YJYH_TD_COUNT='' OR YJYH_TD_COUNT IS NULL THEN 0 ELSE YJYH_TD_COUNT END +" +
  36. "case WHEN EJYH_TD_COUNT='' OR EJYH_TD_COUNT IS NULL THEN 0 ELSE EJYH_TD_COUNT END -" +
  37. "case WHEN TQ_UNRECOVERED='' OR TQ_UNRECOVERED IS NULL THEN 0 ELSE TQ_UNRECOVERED END -" +
  38. "case WHEN YH_UNRECOVERED='' OR YH_UNRECOVERED IS NULL THEN 0 ELSE YH_UNRECOVERED END -" +
  39. "case WHEN TJYH_UNRECOVERED='' OR TJYH_UNRECOVERED IS NULL THEN 0 ELSE TJYH_UNRECOVERED END - " +
  40. "case WHEN YJYH_UNRECOVERED='' OR YJYH_UNRECOVERED IS NULL THEN 0 ELSE YJYH_UNRECOVERED END -" +
  41. "case WHEN EJYH_UNRECOVERED='' OR EJYH_UNRECOVERED IS NULL THEN 0 ELSE EJYH_UNRECOVERED END ) AS RECOVERED FROM " +
  42. "REPORT_GDSUNSHI_KEHUTD ,sys_department b where report_id in( " +
  43. "select fd_objectid from report_records b where updatedate in(" +
  44. "select max(updatedate) from report_records where report_type='5' and comp_id='C984DC9C294A486096C25FAA78C99AED')) and comp_id=b.dept_id ";
  45. DbConnection dbConn = new DbConnection();
  46. Connection conn = null;
  47. PreparedStatement pstm = null;
  48. ResultSet rs = null;
  49. Map<String,String> map=new HashMap<String,String>();
  50. String result="[";
  51. try {
  52. conn = dbConn.getConnection();
  53. pstm = conn.prepareStatement(sqlSql);
  54. rs = pstm.executeQuery();
  55. while(rs.next()){
  56. System.out.println(rs.getString("COMP_NAME"));
  57. System.out.println(rs.getString("RECOVERED"));
  58. if(!rs.getString("RECOVERED").equals("0")){
  59. result+="['"+rs.getString("COMP_NAME")+"',"+rs.getString("RECOVERED")+"],";
  60. }
  61. }
  62. result=result.substring(0, result.lastIndexOf(','));
  63. result+="]";
  64. System.out.println(result);
  65. }catch(Exception e){
  66. e.printStackTrace();
  67. }finally{
  68. try {
  69. rs.close();
  70. pstm.close();
  71. conn.close();
  72. } catch (SQLException e) {
  73. e.printStackTrace();
  74. }
  75. }
  76. // result="[['清远供电局',30],['江门供电局',30],['茂名供电局',30]]";
  77. return result;
  78. }
  79. @ProduceMime("application/json")
  80. @POST
  81. @Path("/mapdata")
  82. public String mapdata(String params){
  83. String sqlSql = "select b.dept_name AS COMP_NAME , to_number(case WHEN TQ_TD_COUNT='' OR TQ_TD_COUNT IS NULL THEN 0 ELSE TQ_TD_COUNT END + " +
  84. "case WHEN YH_TD_COUNT='' OR YH_TD_COUNT IS NULL THEN 0 ELSE YH_TD_COUNT END +" +
  85. "case WHEN TJYH_TD_COUNT='' OR TJYH_TD_COUNT IS NULL THEN 0 ELSE TJYH_TD_COUNT END +" +
  86. "case WHEN YJYH_TD_COUNT='' OR YJYH_TD_COUNT IS NULL THEN 0 ELSE YJYH_TD_COUNT END +" +
  87. "case WHEN EJYH_TD_COUNT='' OR EJYH_TD_COUNT IS NULL THEN 0 ELSE EJYH_TD_COUNT END ) AS POWERCUT,to_number(" +
  88. "case WHEN TQ_UNRECOVERED='' OR TQ_UNRECOVERED IS NULL THEN 0 ELSE TQ_UNRECOVERED END +" +
  89. "case WHEN YH_UNRECOVERED='' OR YH_UNRECOVERED IS NULL THEN 0 ELSE YH_UNRECOVERED END +" +
  90. "case WHEN TJYH_UNRECOVERED='' OR TJYH_UNRECOVERED IS NULL THEN 0 ELSE TJYH_UNRECOVERED END + " +
  91. "case WHEN YJYH_UNRECOVERED='' OR YJYH_UNRECOVERED IS NULL THEN 0 ELSE YJYH_UNRECOVERED END +" +
  92. "case WHEN EJYH_UNRECOVERED='' OR EJYH_UNRECOVERED IS NULL THEN 0 ELSE EJYH_UNRECOVERED END ) AS NORETURN FROM " +
  93. "REPORT_GDSUNSHI_KEHUTD ,sys_department b where report_id in( " +
  94. "select fd_objectid from report_records b where updatedate in(" +
  95. "select max(updatedate) from report_records where report_type='5' and comp_id='C984DC9C294A486096C25FAA78C99AED')) and comp_id=b.dept_id ";
  96. DbConnection dbConn = new DbConnection();
  97. Connection conn = null;
  98. PreparedStatement pstm = null;
  99. ResultSet rs = null;
  100. Map<String,String> map=new HashMap<String,String>();
  101. String result="[";
  102. try {
  103. conn = dbConn.getConnection();
  104. pstm = conn.prepareStatement(sqlSql);
  105. rs = pstm.executeQuery();
  106. while(rs.next()){
  107. System.out.println(rs.getString("COMP_NAME"));
  108. System.out.println(rs.getString("POWERCUT"));
  109. System.out.println(rs.getString("NORETURN"));
  110. result+="['"+rs.getString("COMP_NAME")+"',"+rs.getString("POWERCUT")+","+rs.getString("NORETURN")+"],";
  111. }
  112. result=result.substring(0, result.lastIndexOf(','));
  113. result+="]";
  114. System.out.println(result);
  115. }catch(Exception e){
  116. e.printStackTrace();
  117. }finally{
  118. try {
  119. rs.close();
  120. pstm.close();
  121. conn.close();
  122. } catch (SQLException e) {
  123. e.printStackTrace();
  124. }
  125. }
  126. // result="[['清远供电局',30],['江门供电局',30],['茂名供电局',30]]";
  127. return result;
  128. }
  129. }