소스 검색

上传文件

陈士柏 2 년 전
부모
커밋
6042bcbf73
1개의 변경된 파일270개의 추가작업 그리고 0개의 파일을 삭제
  1. 270 0
      bigData/src/com/happy/action2/crossAction.java

+ 270 - 0
bigData/src/com/happy/action2/crossAction.java

@@ -0,0 +1,270 @@
+package com.happy.action2;
+
+import com.alibaba.fastjson.JSONObject;
+import com.happy.Model.Manager.Gaosut;
+import com.happy.Model.User;
+import com.happy.Until.ResUtil;
+import com.happy.Until.ResponseUtil;
+import com.happy.Until.TimeExchange;
+import com.happy.service.CrossService;
+import com.happy.service.ManagerService;
+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 crossAction extends ActionSupport implements ServletRequestAware {
+
+    private HttpServletRequest request;
+    public HttpServletResponse response;
+
+    @Resource
+    public ManagerService managerService;
+    @Resource
+    public CrossService crossService;
+
+    public int page; // 当前页
+    public int rows;// 每页显示的行数rows
+    public String sm_place;
+    public String sm_date;
+
+    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 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 getSm_place() {
+        return sm_place;
+    }
+
+    public void setSm_place(String sm_place) {
+        this.sm_place = sm_place;
+    }
+
+    public String getSm_date() {
+        return sm_date;
+    }
+
+    public void setSm_date(String sm_date) {
+        this.sm_date = sm_date;
+    }
+
+    // 当日各高速口人数统计
+    public String queryGaosuDay(){
+        JSONObject resultJson = new JSONObject();
+        List<Gaosut> list = managerService.queryByDataAndPlace(0);
+        resultJson.put("code", 200);
+        resultJson.put("message", "返回成功");
+        resultJson.put("data", list);
+        ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                resultJson.toString());
+        return null;
+    }
+
+    // 各高速口累计人数统计
+    public String queryGaosuT(){
+        JSONObject resultJson = new JSONObject();
+        List<Gaosut> list = crossService.queryGaosuR();
+        resultJson.put("code", 200);
+        resultJson.put("message", "返回成功");
+        resultJson.put("data", list);
+        ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                resultJson.toString());
+        return null;
+    }
+
+    // 各高速口人员列表
+    public String queryUserList(){
+        JSONObject resultJson = new JSONObject();
+        if (sm_place==null){
+            resultJson.put("code", 500);
+            resultJson.put("message", "请传入路口名称");
+            ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                    resultJson.toString());
+            return null;
+        }
+        System.out.println("===="+sm_place);
+        int total = crossService.queryUserCrossCount(sm_place);// 查询表中的总记录数
+        List<User> listPage = crossService.queryUserByCross(sm_place,page, rows);// 查询分页
+
+        if (listPage == null) {
+            resultJson.put("rows", "");
+            resultJson.put("total", 0);
+        } else {
+            resultJson.put("code", 200);
+            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 queryDayT(){
+        JSONObject resultJson = new JSONObject();
+        List<Gaosut> list = crossService.querySumByDay();
+        resultJson.put("code", 200);
+        resultJson.put("message", "返回成功");
+        resultJson.put("data", list);
+        ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                resultJson.toString());
+        return null;
+    }
+
+    // 累计人口统计
+    public String queryT(){
+        JSONObject resultJson = new JSONObject();
+        List<Gaosut> list = crossService.querySum();
+        resultJson.put("code", 200);
+        resultJson.put("message", "返回成功");
+        resultJson.put("data", list);
+        ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                resultJson.toString());
+        return null;
+    }
+
+    // 人流趋势分析-日
+    public String queryLastDay(){
+        JSONObject resultJson = new JSONObject();
+        List<Gaosut> list = crossService.queryLastDay();
+        if (list==null){
+            resultJson.put("code", 500);
+            resultJson.put("message", "返回空");
+            resultJson.put("data", null);
+            ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                    resultJson.toString());
+            return null;
+        }
+        resultJson.put("code", 200);
+        resultJson.put("message", "返回成功");
+        resultJson.put("data", list);
+        ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                resultJson.toString());
+        return null;
+    }
+
+    // 人流趋势分析-月
+    public String queryLastMonth(){
+        JSONObject resultJson = new JSONObject();
+        List<Gaosut> list = crossService.queryLastMonth();
+        if (list==null){
+            resultJson.put("code", 500);
+            resultJson.put("message", "返回空");
+            resultJson.put("data", null);
+            ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                    resultJson.toString());
+            return null;
+        }
+        resultJson.put("code", 200);
+        resultJson.put("message", "返回成功");
+        resultJson.put("data", list);
+        ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                resultJson.toString());
+        return null;
+    }
+
+    // 人流趋势分析-年
+    public String queryLastYear(){
+        JSONObject resultJson = new JSONObject();
+        List<Gaosut> list = crossService.queryLastYear();
+        if (list==null){
+            resultJson.put("code", 500);
+            resultJson.put("message", "返回空");
+            resultJson.put("data", null);
+            ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                    resultJson.toString());
+            return null;
+        }
+        resultJson.put("code", 200);
+        resultJson.put("message", "返回成功");
+        resultJson.put("data", list);
+        ResponseUtil.writeJson(ServletActionContext.getResponse(),
+                resultJson.toString());
+        return null;
+    }
+
+    // 各路口详情
+    public String queryDetail(){
+        JSONObject resultJson = new JSONObject();
+        List<Gaosut> listT = crossService.queryTNum(sm_place);
+        List<Gaosut> listDay = crossService.queryDayNum(sm_place);
+
+        int total = crossService.queryUserDayCount(sm_place);// 查询表中的总记录数
+        List<User> listPage = crossService.queryUserByDay(sm_place,page, rows);// 查询分页
+        resultJson.put("dayStatis", listDay);
+        resultJson.put("totalStatis", listT);
+
+        if (listPage == null) {
+            resultJson.put("rows", "");
+            resultJson.put("total", 0);
+        } else {
+            resultJson.put("code", 200);
+            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;
+    }
+
+}