f25eecf283e09d3133d2a0947e71045b05fe1edb.svn-base 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package com.sinosoft.lz.system.focusControl.service;
  2. import java.io.UnsupportedEncodingException;
  3. import java.sql.SQLException;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import java.util.Map;
  7. import javax.ws.rs.POST;
  8. import javax.ws.rs.Path;
  9. import javax.ws.rs.ProduceMime;
  10. import org.jfree.util.Log;
  11. import com.formaction.Utils;
  12. import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
  13. import com.sinosoft.lz.system.focusControl.dao.FocusControl;
  14. @Path("/FocusControlServer/")
  15. public class FocusControlServer {
  16. @POST
  17. @ProduceMime("application/json")
  18. @Path("/query/")
  19. public String query(String params){
  20. StringBuffer sql=new StringBuffer();
  21. ORGTemplate org = new ORGTemplate();
  22. List<Map<String,String>> list = new ArrayList<Map<String,String>>();
  23. int total=0;
  24. String firstPageNum="";
  25. try {
  26. params = java.net.URLDecoder.decode(params, "UTF-8");
  27. System.out.println(params);
  28. firstPageNum = Utils.getParameter("pager.pageNo", params) == null ? "0" : Utils
  29. .getParameter("pager.pageNo", params);
  30. String limit = Utils.getParameter("pager.pageSize", params) == null ? "10" : Utils
  31. .getParameter("pager.pageSize", params);
  32. String name=Utils.getParameter("codename", params) ;
  33. sql.append("select TOP "+(Integer.parseInt(firstPageNum)-1)*Integer.parseInt(limit)+","+(Integer.parseInt(limit))+" * , (select count(1) from app_data_value) total from app_data_value order by gathertime desc \n");
  34. if(name!=null){
  35. sql.append("where code='"+name+"' \n");
  36. }
  37. System.out.println("123123"+sql.toString());
  38. list = org.query(sql.toString());
  39. } catch (SQLException e) {
  40. e.printStackTrace();
  41. } catch (UnsupportedEncodingException e) {
  42. // TODO Auto-generated catch block
  43. e.printStackTrace();
  44. }
  45. Log.info(org.listToString(list));
  46. if(list.size()>0){
  47. System.out.println(list.get(0).get("TOTAL"));
  48. total=Integer.parseInt(list.get(0).get("TOTAL"));
  49. }
  50. return "{\"pager.totalRows\":"+total+",\"pager.pageNo\":"+Integer.parseInt(firstPageNum)+","+"\"rows\":["+org.listToString(list)+"]}";
  51. }
  52. @POST
  53. @ProduceMime("application/json")
  54. @Path("/query1/")
  55. public String query1(String params){
  56. StringBuffer sql=new StringBuffer();
  57. ORGTemplate org = new ORGTemplate();
  58. List<Map<String,String>> list = new ArrayList<Map<String,String>>();
  59. int total=0;
  60. String firstPageNum="";
  61. try {
  62. params = java.net.URLDecoder.decode(params, "UTF-8");
  63. String name=Utils.getParameter("codename", params) ;
  64. sql.append("select * , (select count(1) from app_data_value where code='"+name+"') total from app_data_value where code='"+name+"' order by gathertime desc \n");
  65. System.out.println(sql.toString());
  66. list = org.query(sql.toString());
  67. if(list.size()>0){
  68. System.out.println(list.get(0).get("TOTAL"));
  69. total=Integer.parseInt(list.get(0).get("TOTAL"));
  70. }
  71. } catch (SQLException e) {
  72. e.printStackTrace();
  73. } catch (UnsupportedEncodingException e) {
  74. // TODO Auto-generated catch block
  75. e.printStackTrace();
  76. }
  77. Log.info(org.listToString(list));
  78. return "{\"pager.totalRows\":"+total+",\"pager.pageNo\":"+1+","+"\"rows\":["+org.listToString(list)+"]}";
  79. }
  80. @POST
  81. @ProduceMime("application/json")
  82. @Path("/personquery/")
  83. public String personquery(String params){
  84. ORGTemplate org = new ORGTemplate();
  85. List<Map<String,String>> list = new ArrayList<Map<String,String>>();
  86. try {
  87. params=java.net.URLDecoder.decode(params, "UTF-8");
  88. String date=Utils.getParameter("date", params) == null ? "0" : Utils.getParameter("date", params);
  89. String date2=date+" 23:59:59";
  90. String sql="select * from app_user_list where gathertime between ? and ? ";
  91. System.out.println(date+",,"+",,"+date2+sql);
  92. list=org.query(sql, date,date2);
  93. } catch (UnsupportedEncodingException e) {
  94. // TODO Auto-generated catch block
  95. e.printStackTrace();
  96. } catch (SQLException e) {
  97. // TODO Auto-generated catch block
  98. e.printStackTrace();
  99. }
  100. System.out.println(org.listToString(list));
  101. return "{\"rows\":["+org.listToString(list)+"]}";
  102. }
  103. @POST
  104. @ProduceMime("application/json")
  105. @Path("/query2/")
  106. public String query2(){
  107. FocusControl foc=new FocusControlService();
  108. foc.getDataRegisterUsers();
  109. foc.getOnlineUsers();
  110. foc.getSessionConnect();
  111. foc.getAccessTimes();
  112. foc.getFirstLoginUsers();
  113. foc.getDataLoginUsers();
  114. foc.getDataLoginUsersTimes();
  115. foc.getDataLoginList();
  116. foc.LoginResponseTime();
  117. foc.waitToDo();
  118. return "";
  119. }
  120. }