车闸对接前端,后端未实装
This commit is contained in:
@ -0,0 +1,114 @@
|
||||
package com.sipai.controller.jsyw;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/jsyw/vehicleGate")
|
||||
public class VehicleGateController {
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "/jsyw/vehicleGateList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "rows", required = false, defaultValue = "10") Integer rows) {
|
||||
String plateNo = safeStr(request.getParameter("plateNo")).toUpperCase(Locale.ROOT);
|
||||
String passDate = safeStr(request.getParameter("passDate"));
|
||||
String direction = safeStr(request.getParameter("direction"));
|
||||
String status = safeStr(request.getParameter("status"));
|
||||
|
||||
List<Map<String, Object>> mockRows = buildMockRows();
|
||||
List<Map<String, Object>> filteredRows = new ArrayList<Map<String, Object>>();
|
||||
int inCount = 0;
|
||||
int outCount = 0;
|
||||
int abnormalCount = 0;
|
||||
|
||||
for (Map<String, Object> item : mockRows) {
|
||||
String itemPlateNo = safeStr(item.get("plateNo")).toUpperCase(Locale.ROOT);
|
||||
String itemPassTime = safeStr(item.get("passTime"));
|
||||
String itemDirection = safeStr(item.get("direction"));
|
||||
String itemStatus = safeStr(item.get("status"));
|
||||
|
||||
boolean matchPlate = plateNo.isEmpty() || itemPlateNo.contains(plateNo);
|
||||
boolean matchDate = passDate.isEmpty() || itemPassTime.startsWith(passDate);
|
||||
boolean matchDirection = direction.isEmpty() || direction.equals(itemDirection);
|
||||
boolean matchStatus = status.isEmpty() || status.equals(itemStatus);
|
||||
if (matchPlate && matchDate && matchDirection && matchStatus) {
|
||||
filteredRows.add(item);
|
||||
if ("IN".equals(itemDirection)) {
|
||||
inCount++;
|
||||
} else if ("OUT".equals(itemDirection)) {
|
||||
outCount++;
|
||||
}
|
||||
if ("ABNORMAL".equals(itemStatus)) {
|
||||
abnormalCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int total = filteredRows.size();
|
||||
int pageStart = Math.max((page - 1) * rows, 0);
|
||||
int pageEnd = Math.min(pageStart + rows, total);
|
||||
List<Map<String, Object>> pageRows = new ArrayList<Map<String, Object>>();
|
||||
if (pageStart < pageEnd) {
|
||||
pageRows = filteredRows.subList(pageStart, pageEnd);
|
||||
}
|
||||
|
||||
JSONArray rowsJson = JSONArray.fromObject(pageRows);
|
||||
String result = "{"
|
||||
+ "\"total\":" + total + ","
|
||||
+ "\"rows\":" + rowsJson + ","
|
||||
+ "\"summaryInCount\":" + inCount + ","
|
||||
+ "\"summaryOutCount\":" + outCount + ","
|
||||
+ "\"summaryInsideCount\":" + (inCount - outCount) + ","
|
||||
+ "\"summaryAbnormalCount\":" + abnormalCount
|
||||
+ "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
private String safeStr(Object value) {
|
||||
return value == null ? "" : String.valueOf(value).trim();
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> buildMockRows() {
|
||||
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
|
||||
rows.add(buildRow("鲁A12345", "IN", "2026-03-03 08:12:21", "东门1号闸", "张三", "NORMAL", "自动识别放行"));
|
||||
rows.add(buildRow("鲁B66K88", "OUT", "2026-03-03 08:18:46", "东门1号闸", "李四", "NORMAL", "自动识别放行"));
|
||||
rows.add(buildRow("鲁C99871", "IN", "2026-03-03 08:27:19", "南门2号闸", "王五", "ABNORMAL", "车牌识别异常,人工放行"));
|
||||
rows.add(buildRow("鲁A77889", "IN", "2026-03-03 09:04:52", "北门1号闸", "赵六", "NORMAL", "自动识别放行"));
|
||||
rows.add(buildRow("鲁D22319", "OUT", "2026-03-03 09:19:11", "南门2号闸", "钱七", "NORMAL", "自动识别放行"));
|
||||
rows.add(buildRow("鲁E55120", "IN", "2026-03-03 10:03:35", "西门1号闸", "孙八", "NORMAL", "访客车辆"));
|
||||
rows.add(buildRow("鲁F90111", "OUT", "2026-03-03 10:16:05", "北门1号闸", "周九", "ABNORMAL", "未登记离场,值班确认"));
|
||||
rows.add(buildRow("鲁A0P365", "IN", "2026-03-03 10:42:30", "东门1号闸", "吴十", "NORMAL", "自动识别放行"));
|
||||
return rows;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildRow(String plateNo, String direction, String passTime, String gateName,
|
||||
String driverName, String status, String note) {
|
||||
Map<String, Object> row = new HashMap<String, Object>();
|
||||
row.put("plateNo", plateNo);
|
||||
row.put("direction", direction);
|
||||
row.put("passTime", passTime);
|
||||
row.put("gateName", gateName);
|
||||
row.put("driverName", driverName);
|
||||
row.put("status", status);
|
||||
row.put("note", note);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user