MobileAction.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. package com.happy.action;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.happy.Model.User;
  4. import com.happy.Until.ResponseUtil;
  5. import com.happy.service.MobService;
  6. import com.opensymphony.xwork2.ActionSupport;
  7. import org.apache.struts2.ServletActionContext;
  8. import org.apache.struts2.interceptor.ServletRequestAware;
  9. import javax.annotation.Resource;
  10. import javax.servlet.http.HttpServletRequest;
  11. import javax.servlet.http.HttpServletResponse;
  12. import java.util.List;
  13. public class MobileAction extends ActionSupport implements ServletRequestAware {
  14. private HttpServletRequest request;
  15. public HttpServletResponse response;
  16. @Resource
  17. public MobService mobService;
  18. public String sm_color;
  19. public String handler_state2;
  20. public int page; // 当前页
  21. public int rows;// 每页显示的行数rows
  22. public String iskey;
  23. public String ishot;
  24. public String istoken;
  25. public HttpServletRequest getRequest() {
  26. return request;
  27. }
  28. public void setRequest(HttpServletRequest request) {
  29. this.request = request;
  30. }
  31. public void setServletRequest(HttpServletRequest request) {
  32. this.request = request;
  33. }
  34. public HttpServletResponse getResponse() {
  35. return response;
  36. }
  37. public void setResponse(HttpServletResponse response) {
  38. this.response = response;
  39. }
  40. public String getSm_color() {
  41. return sm_color;
  42. }
  43. public void setSm_color(String sm_color) {
  44. this.sm_color = sm_color;
  45. }
  46. public String getHandler_state2() {
  47. return handler_state2;
  48. }
  49. public void setHandler_state2(String handler_state2) {
  50. this.handler_state2 = handler_state2;
  51. }
  52. public int getPage() {
  53. return page;
  54. }
  55. public void setPage(int page) {
  56. this.page = page;
  57. }
  58. public int getRows() {
  59. return rows;
  60. }
  61. public void setRows(int rows) {
  62. this.rows = rows;
  63. }
  64. public String getIskey() {
  65. return iskey;
  66. }
  67. public void setIskey(String iskey) {
  68. this.iskey = iskey;
  69. }
  70. public String getIshot() {
  71. return ishot;
  72. }
  73. public void setIshot(String ishot) {
  74. this.ishot = ishot;
  75. }
  76. public String getIstoken() {
  77. return istoken;
  78. }
  79. public void setIstoken(String istoken) {
  80. this.istoken = istoken;
  81. }
  82. // 处置详情
  83. public String queryHandler(){
  84. JSONObject resultJson = new JSONObject();
  85. StringBuilder sb = new StringBuilder("");
  86. if (handler_state2!=null){
  87. sb.append(" and handler_state2='").append(this.handler_state2).append("' ");
  88. }
  89. if (sm_color!=null){
  90. sb.append(" and sm_color='").append(this.sm_color).append("' ");
  91. }
  92. if (istoken!=null){
  93. sb.append(" and istoken='").append(this.istoken).append("' ");
  94. }
  95. if (iskey!=null){
  96. sb.append(" and iskey='").append(this.iskey).append("' ");
  97. }
  98. if (ishot!=null){
  99. sb.append(" and ishot='").append(this.ishot).append("' ");
  100. }
  101. int total = mobService.findUsersTotal(sb.toString()); // 查询表中的总记录数
  102. List<User> listPage = this.mobService.queryHandled(sb.toString(),page,rows);
  103. if (listPage == null) {
  104. resultJson.put("rows", "");
  105. resultJson.put("total", 0);
  106. } else {
  107. resultJson.put("rows", listPage);
  108. // int total = listAll.size();
  109. resultJson.put("total", total);// 总记录数
  110. int totalPage = total % rows == 0 ? (total / rows)
  111. : (total / rows) + 1;// 总页数
  112. resultJson.put("totalPage", totalPage);
  113. resultJson.put("currentPage", page);// 当前页
  114. resultJson.put("numPerPage", rows);// 每页数
  115. resultJson.put("nextPage", totalPage - page == 0 ? page : page + 1);// 下一页
  116. resultJson.put("previousPage", page - 0 == 1 ? page : page - 1);// 上一页
  117. resultJson.put("hasPreviousPage", true);// 有上一页
  118. resultJson.put("hasNextPage", true);// 有下一页
  119. resultJson.put("firstPage", true);// 首页
  120. resultJson.put("lastPage", true);// 尾页
  121. }
  122. ResponseUtil.writeJson(ServletActionContext.getResponse(),
  123. resultJson.toString());
  124. return null;
  125. }
  126. // 各状态处置详情统计
  127. public String queryHandlerTj() {
  128. JSONObject resultJson = mobService.queryDetailHandler();
  129. ResponseUtil.writeJson(ServletActionContext.getResponse(),
  130. resultJson.toString());
  131. return null;
  132. }
  133. // 近8天红黄码处置统计
  134. public String queryEightRed(){
  135. StringBuilder sb = new StringBuilder("");
  136. if (sm_color!=null){
  137. sb.append(" and sm_color='").append(this.sm_color).append("' ");
  138. }
  139. if (istoken!=null){
  140. sb.append(" and istoken='").append(this.istoken).append("' ");
  141. }
  142. if (iskey!=null){
  143. sb.append(" and iskey='").append(this.iskey).append("' ");
  144. }
  145. if (ishot!=null){
  146. sb.append(" and ishot='").append(this.ishot).append("' ");
  147. }
  148. JSONObject resultJson = mobService.queryEightRed(sb.toString());
  149. ResponseUtil.writeJson(ServletActionContext.getResponse(),
  150. resultJson.toString());
  151. return null;
  152. }
  153. // 近8天处置统计平均数
  154. public String queryEightAvg(){
  155. JSONObject resultJson = mobService.queryEightAvg();
  156. ResponseUtil.writeJson(ServletActionContext.getResponse(),
  157. resultJson.toString());
  158. return null;
  159. }
  160. }