123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package com.sinosoft.em.baobiao.rcbb.service;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.HashMap;
- import java.util.Map;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.ProduceMime;
- import com.formaction.Utils;
- import com.persistence.DbConnection;
- import com.sinosoft.em.alert.duty.records.vo.EcmEmDuty;
- import com.sinosoft.em.baobiao.xianlutingyun.dao.ReportJSCdao;
- @Path("/ReportJSCService/")
- public class ReportJSCService{
-
- @ProduceMime("application/json")
- @POST
- @Path("/query")
- public String query(String params){
- String comp_id=Utils.getParameter("comp_id", params)==null?"":Utils.getParameter("comp_id", params);
- //String report_id=Utils.getParameter("report_id", params)==null?"":Utils.getParameter("report_id", params);
- String report_type="5";
- ReportJSCdao rjsc=new ReportJSCdao();
- String result=rjsc.query(report_type, comp_id);
- return result;
- }
-
-
- @ProduceMime("application/json")
- @POST
- @Path("/chartdata")
- public String chartdata(String params){
- 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 + " +
- "case WHEN YH_TD_COUNT='' OR YH_TD_COUNT IS NULL THEN 0 ELSE YH_TD_COUNT END +" +
- "case WHEN TJYH_TD_COUNT='' OR TJYH_TD_COUNT IS NULL THEN 0 ELSE TJYH_TD_COUNT END +" +
- "case WHEN YJYH_TD_COUNT='' OR YJYH_TD_COUNT IS NULL THEN 0 ELSE YJYH_TD_COUNT END +" +
- "case WHEN EJYH_TD_COUNT='' OR EJYH_TD_COUNT IS NULL THEN 0 ELSE EJYH_TD_COUNT END -" +
- "case WHEN TQ_UNRECOVERED='' OR TQ_UNRECOVERED IS NULL THEN 0 ELSE TQ_UNRECOVERED END -" +
- "case WHEN YH_UNRECOVERED='' OR YH_UNRECOVERED IS NULL THEN 0 ELSE YH_UNRECOVERED END -" +
- "case WHEN TJYH_UNRECOVERED='' OR TJYH_UNRECOVERED IS NULL THEN 0 ELSE TJYH_UNRECOVERED END - " +
- "case WHEN YJYH_UNRECOVERED='' OR YJYH_UNRECOVERED IS NULL THEN 0 ELSE YJYH_UNRECOVERED END -" +
- "case WHEN EJYH_UNRECOVERED='' OR EJYH_UNRECOVERED IS NULL THEN 0 ELSE EJYH_UNRECOVERED END ) AS RECOVERED FROM " +
- "REPORT_GDSUNSHI_KEHUTD ,sys_department b where report_id in( " +
- "select fd_objectid from report_records b where updatedate in(" +
- "select max(updatedate) from report_records where report_type='5' and comp_id='C984DC9C294A486096C25FAA78C99AED')) and comp_id=b.dept_id ";
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
- Map<String,String> map=new HashMap<String,String>();
- String result="[";
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sqlSql);
- rs = pstm.executeQuery();
- while(rs.next()){
- System.out.println(rs.getString("COMP_NAME"));
- System.out.println(rs.getString("RECOVERED"));
- if(!rs.getString("RECOVERED").equals("0")){
- result+="['"+rs.getString("COMP_NAME")+"',"+rs.getString("RECOVERED")+"],";
- }
- }
- result=result.substring(0, result.lastIndexOf(','));
- result+="]";
- System.out.println(result);
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- rs.close();
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- // result="[['清远供电局',30],['江门供电局',30],['茂名供电局',30]]";
- return result;
- }
- @ProduceMime("application/json")
- @POST
- @Path("/mapdata")
- public String mapdata(String params){
- 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 + " +
- "case WHEN YH_TD_COUNT='' OR YH_TD_COUNT IS NULL THEN 0 ELSE YH_TD_COUNT END +" +
- "case WHEN TJYH_TD_COUNT='' OR TJYH_TD_COUNT IS NULL THEN 0 ELSE TJYH_TD_COUNT END +" +
- "case WHEN YJYH_TD_COUNT='' OR YJYH_TD_COUNT IS NULL THEN 0 ELSE YJYH_TD_COUNT END +" +
- "case WHEN EJYH_TD_COUNT='' OR EJYH_TD_COUNT IS NULL THEN 0 ELSE EJYH_TD_COUNT END ) AS POWERCUT,to_number(" +
- "case WHEN TQ_UNRECOVERED='' OR TQ_UNRECOVERED IS NULL THEN 0 ELSE TQ_UNRECOVERED END +" +
- "case WHEN YH_UNRECOVERED='' OR YH_UNRECOVERED IS NULL THEN 0 ELSE YH_UNRECOVERED END +" +
- "case WHEN TJYH_UNRECOVERED='' OR TJYH_UNRECOVERED IS NULL THEN 0 ELSE TJYH_UNRECOVERED END + " +
- "case WHEN YJYH_UNRECOVERED='' OR YJYH_UNRECOVERED IS NULL THEN 0 ELSE YJYH_UNRECOVERED END +" +
- "case WHEN EJYH_UNRECOVERED='' OR EJYH_UNRECOVERED IS NULL THEN 0 ELSE EJYH_UNRECOVERED END ) AS NORETURN FROM " +
- "REPORT_GDSUNSHI_KEHUTD ,sys_department b where report_id in( " +
- "select fd_objectid from report_records b where updatedate in(" +
- "select max(updatedate) from report_records where report_type='5' and comp_id='C984DC9C294A486096C25FAA78C99AED')) and comp_id=b.dept_id ";
- DbConnection dbConn = new DbConnection();
- Connection conn = null;
- PreparedStatement pstm = null;
- ResultSet rs = null;
- Map<String,String> map=new HashMap<String,String>();
- String result="[";
- try {
- conn = dbConn.getConnection();
- pstm = conn.prepareStatement(sqlSql);
- rs = pstm.executeQuery();
- while(rs.next()){
- System.out.println(rs.getString("COMP_NAME"));
- System.out.println(rs.getString("POWERCUT"));
- System.out.println(rs.getString("NORETURN"));
- result+="['"+rs.getString("COMP_NAME")+"',"+rs.getString("POWERCUT")+","+rs.getString("NORETURN")+"],";
-
- }
- result=result.substring(0, result.lastIndexOf(','));
- result+="]";
- System.out.println(result);
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- try {
- rs.close();
- pstm.close();
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- // result="[['清远供电局',30],['江门供电局',30],['茂名供电局',30]]";
- return result;
- }
-
- }
|