|
|
@@ -1,16 +1,19 @@
|
|
|
package cn.com.oa.controller;
|
|
|
|
|
|
+import cn.com.oa.model.CarInoutRecord;
|
|
|
+import cn.com.oa.model.dto.BarrierCameraAlarmDTO;
|
|
|
+import cn.com.oa.service.CarInoutRecordService;
|
|
|
import cn.com.v2.common.domain.AjaxResult;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
@@ -23,6 +26,9 @@ import java.util.Map;
|
|
|
@RequestMapping("/api/common")
|
|
|
public class CommonController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CarInoutRecordService carInoutRecordService;
|
|
|
+
|
|
|
@GetMapping("/weather")
|
|
|
public AjaxResult getWeather(@RequestParam(required = false) String latitude, @RequestParam(required = false) String longitude) {
|
|
|
if (latitude == null) {
|
|
|
@@ -42,4 +48,55 @@ public class CommonController {
|
|
|
public AjaxResult getDate() {
|
|
|
return AjaxResult.successData(200, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).put("msg","获取成功");
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/carin")
|
|
|
+ public AjaxResult carin(@RequestBody BarrierCameraAlarmDTO dto) throws JsonProcessingException {
|
|
|
+ CarInoutRecord record = new CarInoutRecord();
|
|
|
+ record.setDeviceIp(dto.getIpaddr());
|
|
|
+ record.setSerialNo(dto.getSerialno());
|
|
|
+ record.setLicensePlate(dto.getLicense());
|
|
|
+ record.setPlateConfidence(dto.getConfidence());
|
|
|
+ record.setRealPlate(dto.getRealplate());
|
|
|
+ record.setPlateColorType(dto.getColorType());
|
|
|
+ record.setVehicleId(dto.getVehicleId());
|
|
|
+ record.setWhitelistType(dto.getWhitelist());
|
|
|
+ record.setTimeStamp(dto.getTimeStamp());
|
|
|
+ record.setDirection(1);
|
|
|
+ if (carInoutRecordService.save(record)) {
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+ return AjaxResult.error();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/carout")
|
|
|
+ public AjaxResult carout(@RequestBody BarrierCameraAlarmDTO dto) throws JsonProcessingException {
|
|
|
+ CarInoutRecord record = new CarInoutRecord();
|
|
|
+ record.setDeviceIp(dto.getIpaddr());
|
|
|
+ record.setSerialNo(dto.getSerialno());
|
|
|
+ record.setLicensePlate(dto.getLicense());
|
|
|
+ record.setPlateConfidence(dto.getConfidence());
|
|
|
+ record.setRealPlate(dto.getRealplate());
|
|
|
+ record.setPlateColorType(dto.getColorType());
|
|
|
+ record.setVehicleId(dto.getVehicleId());
|
|
|
+ record.setWhitelistType(dto.getWhitelist());
|
|
|
+ record.setTimeStamp(dto.getTimeStamp());
|
|
|
+ record.setDirection(2);
|
|
|
+ if (carInoutRecordService.save(record)) {
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+ return AjaxResult.error();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/carinrecords")
|
|
|
+ public AjaxResult getCarInRecords() {
|
|
|
+ CarInoutRecord record = new CarInoutRecord();
|
|
|
+ record.setDirection(1);
|
|
|
+ Map<LocalDateTime, Map<Integer, List<CarInoutRecord>>> map = new HashMap<>();
|
|
|
+ for (int i = 0; i < 7; i++) {
|
|
|
+ record.setTimeStamp(LocalDateTime.now().minusDays(i));
|
|
|
+ map.put(record.getTimeStamp(), carInoutRecordService.getCarInRecordsByDateGroupByWhiteList(record));
|
|
|
+ }
|
|
|
+ return AjaxResult.successData(200, map);
|
|
|
+ }
|
|
|
+
|
|
|
}
|