| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- package com.happy.action;
- import com.alibaba.fastjson.JSONObject;
- import com.happy.Model.User;
- import com.happy.Until.ResponseUtil;
- import com.happy.service.MobService;
- import com.opensymphony.xwork2.ActionSupport;
- import org.apache.struts2.ServletActionContext;
- import org.apache.struts2.interceptor.ServletRequestAware;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.util.List;
- public class MobileAction extends ActionSupport implements ServletRequestAware {
- private HttpServletRequest request;
- public HttpServletResponse response;
- @Resource
- public MobService mobService;
- public String sm_color;
- public String handler_state2;
- public int page; // 当前页
- public int rows;// 每页显示的行数rows
- public String iskey;
- public String ishot;
- public String istoken;
- public HttpServletRequest getRequest() {
- return request;
- }
- public void setRequest(HttpServletRequest request) {
- this.request = request;
- }
- public void setServletRequest(HttpServletRequest request) {
- this.request = request;
- }
- public HttpServletResponse getResponse() {
- return response;
- }
- public void setResponse(HttpServletResponse response) {
- this.response = response;
- }
- public String getSm_color() {
- return sm_color;
- }
- public void setSm_color(String sm_color) {
- this.sm_color = sm_color;
- }
- public String getHandler_state2() {
- return handler_state2;
- }
- public void setHandler_state2(String handler_state2) {
- this.handler_state2 = handler_state2;
- }
- public int getPage() {
- return page;
- }
- public void setPage(int page) {
- this.page = page;
- }
- public int getRows() {
- return rows;
- }
- public void setRows(int rows) {
- this.rows = rows;
- }
- public String getIskey() {
- return iskey;
- }
- public void setIskey(String iskey) {
- this.iskey = iskey;
- }
- public String getIshot() {
- return ishot;
- }
- public void setIshot(String ishot) {
- this.ishot = ishot;
- }
- public String getIstoken() {
- return istoken;
- }
- public void setIstoken(String istoken) {
- this.istoken = istoken;
- }
- // 处置详情
- public String queryHandler(){
- JSONObject resultJson = new JSONObject();
- StringBuilder sb = new StringBuilder("");
- if (handler_state2!=null){
- sb.append(" and handler_state2='").append(this.handler_state2).append("' ");
- }
- if (sm_color!=null){
- sb.append(" and sm_color='").append(this.sm_color).append("' ");
- }
- if (istoken!=null){
- sb.append(" and istoken='").append(this.istoken).append("' ");
- }
- if (iskey!=null){
- sb.append(" and iskey='").append(this.iskey).append("' ");
- }
- if (ishot!=null){
- sb.append(" and ishot='").append(this.ishot).append("' ");
- }
- int total = mobService.findUsersTotal(sb.toString()); // 查询表中的总记录数
- List<User> listPage = this.mobService.queryHandled(sb.toString(),page,rows);
- if (listPage == null) {
- resultJson.put("rows", "");
- resultJson.put("total", 0);
- } else {
- resultJson.put("rows", listPage);
- // int total = listAll.size();
- resultJson.put("total", total);// 总记录数
- int totalPage = total % rows == 0 ? (total / rows)
- : (total / rows) + 1;// 总页数
- resultJson.put("totalPage", totalPage);
- resultJson.put("currentPage", page);// 当前页
- resultJson.put("numPerPage", rows);// 每页数
- resultJson.put("nextPage", totalPage - page == 0 ? page : page + 1);// 下一页
- resultJson.put("previousPage", page - 0 == 1 ? page : page - 1);// 上一页
- resultJson.put("hasPreviousPage", true);// 有上一页
- resultJson.put("hasNextPage", true);// 有下一页
- resultJson.put("firstPage", true);// 首页
- resultJson.put("lastPage", true);// 尾页
- }
- ResponseUtil.writeJson(ServletActionContext.getResponse(),
- resultJson.toString());
- return null;
- }
- // 各状态处置详情统计
- public String queryHandlerTj() {
- JSONObject resultJson = mobService.queryDetailHandler();
- ResponseUtil.writeJson(ServletActionContext.getResponse(),
- resultJson.toString());
- return null;
- }
- // 近8天红黄码处置统计
- public String queryEightRed(){
- StringBuilder sb = new StringBuilder("");
- if (sm_color!=null){
- sb.append(" and sm_color='").append(this.sm_color).append("' ");
- }
- if (istoken!=null){
- sb.append(" and istoken='").append(this.istoken).append("' ");
- }
- if (iskey!=null){
- sb.append(" and iskey='").append(this.iskey).append("' ");
- }
- if (ishot!=null){
- sb.append(" and ishot='").append(this.ishot).append("' ");
- }
- JSONObject resultJson = mobService.queryEightRed(sb.toString());
- ResponseUtil.writeJson(ServletActionContext.getResponse(),
- resultJson.toString());
- return null;
- }
- // 近8天处置统计平均数
- public String queryEightAvg(){
- JSONObject resultJson = mobService.queryEightAvg();
- ResponseUtil.writeJson(ServletActionContext.getResponse(),
- resultJson.toString());
- return null;
- }
- }
|