wangpx 9 месяцев назад
Родитель
Сommit
d923ea5b52

+ 21 - 0
src/main/java/cn/com/oa/mapper/CarInoutRecordMapper.java

@@ -0,0 +1,21 @@
+package cn.com.oa.mapper;
+
+import cn.com.oa.model.CarInoutRecord;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import java.util.List;
+
+/**
+* @author tianx
+* @description 针对表【car_inout_record(车辆进出识别记录表)】的数据库操作Mapper
+* @createDate 2025-07-07 16:56:19
+* @Entity cn.com.oa.model.CarInoutRecord
+*/
+public interface CarInoutRecordMapper extends BaseMapper<CarInoutRecord> {
+
+    List<CarInoutRecord> getCarInRecordsByDateGroupByWhiteList(CarInoutRecord record);
+}
+
+
+
+

+ 159 - 0
src/main/java/cn/com/oa/model/CarInoutRecord.java

@@ -0,0 +1,159 @@
+package cn.com.oa.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 车辆进出识别记录表
+ * @TableName car_inout_record
+ */
+@TableName(value ="car_inout_record")
+@Data
+public class CarInoutRecord implements Serializable {
+    /**
+     * 主键,自增ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 识别设备的IP地址
+     */
+    private String deviceIp;
+
+    /**
+     * 设备的序列号
+     */
+    private String serialNo;
+
+    /**
+     * 识别到的车牌号码
+     */
+    private String licensePlate;
+
+    /**
+     * 车牌识别的置信度(0-100)
+     */
+    private Integer plateConfidence;
+
+    /**
+     * 是否是真实车牌(true表示是真实车牌)
+     */
+    private Boolean realPlate;
+
+    /**
+     * 车牌颜色类型(如1-蓝、2-黄、3-白、4-黑、5-绿、6-黄绿、7-白绿、99-其他)
+     */
+    private Integer plateColorType;
+
+    /**
+     * 识别方式(如地感触发、雷达、视频等)
+     */
+    private Integer triggerType;
+
+    /**
+     * 车辆行驶方向(0-未知,1-进,2-出)
+     */
+    private Integer direction;
+
+    /**
+     * 车辆识别ID,用于车辆唯一标识
+     */
+    private Long vehicleId;
+
+    /**
+     * 白名单类型(0-无,1-临时车,2-免费车)
+     */
+    private Integer whitelistType;
+
+    /**
+     * 识别时间戳(秒)
+     */
+    private LocalDateTime timeStamp;
+
+    /**
+     * 记录创建时间
+     */
+    private Date createTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        CarInoutRecord other = (CarInoutRecord) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getDeviceIp() == null ? other.getDeviceIp() == null : this.getDeviceIp().equals(other.getDeviceIp()))
+            && (this.getSerialNo() == null ? other.getSerialNo() == null : this.getSerialNo().equals(other.getSerialNo()))
+            && (this.getLicensePlate() == null ? other.getLicensePlate() == null : this.getLicensePlate().equals(other.getLicensePlate()))
+            && (this.getPlateConfidence() == null ? other.getPlateConfidence() == null : this.getPlateConfidence().equals(other.getPlateConfidence()))
+            && (this.getRealPlate() == null ? other.getRealPlate() == null : this.getRealPlate().equals(other.getRealPlate()))
+            && (this.getPlateColorType() == null ? other.getPlateColorType() == null : this.getPlateColorType().equals(other.getPlateColorType()))
+            && (this.getTriggerType() == null ? other.getTriggerType() == null : this.getTriggerType().equals(other.getTriggerType()))
+            && (this.getDirection() == null ? other.getDirection() == null : this.getDirection().equals(other.getDirection()))
+            && (this.getVehicleId() == null ? other.getVehicleId() == null : this.getVehicleId().equals(other.getVehicleId()))
+            && (this.getWhitelistType() == null ? other.getWhitelistType() == null : this.getWhitelistType().equals(other.getWhitelistType()))
+            && (this.getTimeStamp() == null ? other.getTimeStamp() == null : this.getTimeStamp().equals(other.getTimeStamp()))
+            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getDeviceIp() == null) ? 0 : getDeviceIp().hashCode());
+        result = prime * result + ((getSerialNo() == null) ? 0 : getSerialNo().hashCode());
+        result = prime * result + ((getLicensePlate() == null) ? 0 : getLicensePlate().hashCode());
+        result = prime * result + ((getPlateConfidence() == null) ? 0 : getPlateConfidence().hashCode());
+        result = prime * result + ((getRealPlate() == null) ? 0 : getRealPlate().hashCode());
+        result = prime * result + ((getPlateColorType() == null) ? 0 : getPlateColorType().hashCode());
+        result = prime * result + ((getTriggerType() == null) ? 0 : getTriggerType().hashCode());
+        result = prime * result + ((getDirection() == null) ? 0 : getDirection().hashCode());
+        result = prime * result + ((getVehicleId() == null) ? 0 : getVehicleId().hashCode());
+        result = prime * result + ((getWhitelistType() == null) ? 0 : getWhitelistType().hashCode());
+        result = prime * result + ((getTimeStamp() == null) ? 0 : getTimeStamp().hashCode());
+        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", deviceIp=").append(deviceIp);
+        sb.append(", serialNo=").append(serialNo);
+        sb.append(", licensePlate=").append(licensePlate);
+        sb.append(", plateConfidence=").append(plateConfidence);
+        sb.append(", realPlate=").append(realPlate);
+        sb.append(", plateColorType=").append(plateColorType);
+        sb.append(", triggerType=").append(triggerType);
+        sb.append(", direction=").append(direction);
+        sb.append(", vehicleId=").append(vehicleId);
+        sb.append(", whitelistType=").append(whitelistType);
+        sb.append(", timeStamp=").append(timeStamp);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 15 - 0
src/main/java/cn/com/oa/model/FaceRecord.java

@@ -0,0 +1,15 @@
+package cn.com.oa.model;
+
+import lombok.Data;
+
+/**
+ * @author: wangpx
+ * @date: 2025-07-08 15:05
+ */
+@Data
+public class FaceRecord {
+    String personName;
+    String face;
+    String serialNo;
+    String createTime;
+}

+ 217 - 0
src/main/java/cn/com/oa/model/dto/BarrierCameraAlarmDTO.java

@@ -0,0 +1,217 @@
+package cn.com.oa.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+
+@Data
+public class BarrierCameraAlarmDTO {
+
+    @JsonProperty("AlarmInfoPlate")
+    private AlarmInfoPlate alarmInfoPlate;
+
+    @Data
+    public static class AlarmInfoPlate {
+        private int channel;
+        private String deviceName;
+        private String ipaddr;
+        private int openflag;
+
+        @JsonProperty("enterprie_name")
+        private String enterprie_name;
+
+        @JsonProperty("uniform_credit_code")
+        private String uniform_credit_code;
+
+        private String serialno;
+
+        @JsonProperty("result")
+        private Result result;
+    }
+    @Data
+    public static class Result {
+
+        @JsonProperty("PlateResult")
+        private PlateResult plateResult;
+    }
+
+    @Data
+    public static class PlateResult {
+        private int bright;
+        private int carBright;
+        private int carColor;
+        private int colorType;
+        private int colorValue;
+        private int confidence;
+        private int direction;
+        private String license;
+
+        @JsonProperty("plate_encryption_state")
+        private int plate_encryption_state;
+
+        @JsonProperty("Whitelist")
+        private int whitelist;
+
+        @JsonProperty("location")
+        private Location location;
+
+        @JsonProperty("timeStamp")
+        private TimeStamp timeStamp;
+
+        private int timeUsed;
+        private int triggerType;
+        private int type;
+        private double speed;
+
+        @JsonProperty("radarSpeed")
+        private RadarSpeed radarSpeed;
+
+        private long vehicleId;
+        private boolean realplate;
+        private int retryflag;
+    }
+
+    @Data
+    public static class Location {
+
+        @JsonProperty("RECT")
+        private Rect rect;
+    }
+
+    @Data
+    public static class Rect {
+        private int left;
+        private int top;
+        private int right;
+        private int bottom;
+    }
+
+    @Data
+    public static class TimeStamp {
+
+        @JsonProperty("Timeval")
+        private Timeval timeval;
+    }
+
+    @Data
+    public static class Timeval {
+        private long sec;
+        private int usec;
+    }
+
+    @Data
+    public static class RadarSpeed {
+
+        @JsonProperty("Speed")
+        private Speed speed;
+    }
+
+    @Data
+    private static class Speed {
+
+        @JsonProperty("PerHour")
+        private double perHour;
+
+        @JsonProperty("Direction")
+        private int direction;
+    }
+
+    // AlarmInfoPlate 层字段
+    public int getChannel() {
+        return alarmInfoPlate != null ? alarmInfoPlate.channel : 0;
+    }
+
+    public String getDeviceName() {
+        return alarmInfoPlate != null ? alarmInfoPlate.deviceName : null;
+    }
+
+    public String getIpaddr() {
+        return alarmInfoPlate != null ? alarmInfoPlate.ipaddr : null;
+    }
+
+    public int getOpenflag() {
+        return alarmInfoPlate != null ? alarmInfoPlate.openflag : 0;
+    }
+
+    public String getEnterprie_name() {
+        return alarmInfoPlate != null ? alarmInfoPlate.enterprie_name : null;
+    }
+
+    public String getUniform_credit_code() {
+        return alarmInfoPlate != null ? alarmInfoPlate.uniform_credit_code : null;
+    }
+
+    public String getSerialno() {
+        return alarmInfoPlate != null ? alarmInfoPlate.serialno : null;
+    }
+
+    // PlateResult 层字段
+    public String getLicense() {
+        return alarmInfoPlate != null
+                && alarmInfoPlate.result != null
+                && alarmInfoPlate.result.plateResult != null
+                ? alarmInfoPlate.result.plateResult.license
+                : null;
+    }
+
+    public int getConfidence() {
+        return alarmInfoPlate != null
+                && alarmInfoPlate.result != null
+                && alarmInfoPlate.result.plateResult != null
+                ? alarmInfoPlate.result.plateResult.confidence
+                : 0;
+    }
+
+    public boolean getRealplate() {
+        return alarmInfoPlate != null
+                && alarmInfoPlate.result != null
+                && alarmInfoPlate.result.plateResult != null
+                ? alarmInfoPlate.result.plateResult.realplate
+                : false;
+    }
+
+    public int getColorType() {
+        return alarmInfoPlate != null
+                && alarmInfoPlate.result != null
+                && alarmInfoPlate.result.plateResult != null
+                ? alarmInfoPlate.result.plateResult.colorType
+                : 99;
+    }
+
+    public long getVehicleId() {
+        return alarmInfoPlate != null
+                && alarmInfoPlate.result != null
+                && alarmInfoPlate.result.plateResult != null
+                ? alarmInfoPlate.result.plateResult.vehicleId
+                : 0;
+    }
+
+    public int getWhitelist() {
+        return alarmInfoPlate != null
+                && alarmInfoPlate.result != null
+                && alarmInfoPlate.result.plateResult != null
+                ? alarmInfoPlate.result.plateResult.whitelist
+                : 0;
+    }
+
+    public LocalDateTime getTimeStamp() {
+        if (alarmInfoPlate != null
+                && alarmInfoPlate.result != null
+                && alarmInfoPlate.result.plateResult != null
+                && alarmInfoPlate.result.plateResult.timeStamp != null
+                && alarmInfoPlate.result.plateResult.timeStamp.timeval != null) {
+
+            long sec = alarmInfoPlate.result.plateResult.timeStamp.timeval.sec;
+            int usec = alarmInfoPlate.result.plateResult.timeStamp.timeval.usec;
+
+            // 创建 Instant(支持纳秒)→ LocalDateTime(指定时区)
+            Instant instant = Instant.ofEpochSecond(sec, usec * 1000L); // usec 是微秒,需转换为纳秒
+            return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+        }
+        return null;
+    }
+
+}

+ 16 - 0
src/main/java/cn/com/oa/service/CarInoutRecordService.java

@@ -0,0 +1,16 @@
+package cn.com.oa.service;
+
+import cn.com.oa.model.CarInoutRecord;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author tianx
+* @description 针对表【car_inout_record(车辆进出识别记录表)】的数据库操作Service
+* @createDate 2025-07-07 16:56:19
+*/
+public interface CarInoutRecordService extends IService<CarInoutRecord> {
+    Map<Integer, List<CarInoutRecord>> getCarInRecordsByDateGroupByWhiteList(CarInoutRecord record);
+}

+ 52 - 0
src/main/java/cn/com/oa/service/impl/CarInoutRecordServiceImpl.java

@@ -0,0 +1,52 @@
+package cn.com.oa.service.impl;
+
+import cn.com.oa.mapper.CarInoutRecordMapper;
+import cn.com.oa.model.CarInoutRecord;
+import cn.com.oa.service.CarInoutRecordService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author tianx
+* @description 针对表【car_inout_record(车辆进出识别记录表)】的数据库操作Service实现
+* @createDate 2025-07-07 16:56:19
+*/
+@Service
+public class CarInoutRecordServiceImpl extends ServiceImpl<CarInoutRecordMapper, CarInoutRecord>
+    implements CarInoutRecordService{
+
+    @Override
+    public Map<Integer, List<CarInoutRecord>> getCarInRecordsByDateGroupByWhiteList(CarInoutRecord record) {
+        HashMap<Integer, List<CarInoutRecord>> map = new HashMap<>();
+        // 免费车
+        Integer free = 2;
+        // 临时车
+        Integer temp = 1;
+        // 入库
+        Integer in = 1;
+//        CarInoutRecord freeRecord = new CarInoutRecord();
+//        freeRecord.setWhitelistType(free);
+//        freeRecord.setDirection(in);
+//        freeRecord.setTimeStamp(record.getTimeStamp());
+        record.setWhitelistType(free);
+        List<CarInoutRecord> freeList = this.baseMapper.getCarInRecordsByDateGroupByWhiteList(record);
+        System.out.println(freeList.getClass());
+        map.put(free, freeList);
+//        CarInoutRecord tempRecord = new CarInoutRecord();
+//        tempRecord.setWhitelistType(temp);
+//        tempRecord.setDirection(in);
+//        tempRecord.setTimeStamp(record.getTimeStamp());
+        record.setWhitelistType(temp);
+        List<CarInoutRecord> tempList = this.baseMapper.getCarInRecordsByDateGroupByWhiteList(record);
+        map.put(temp, tempList);
+        return map;
+    }
+}
+
+
+
+

+ 38 - 0
src/main/resources/mapper/oa/CarInoutRecordMapper.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.oa.mapper.CarInoutRecordMapper">
+
+    <resultMap id="BaseResultMap" type="cn.com.oa.model.CarInoutRecord">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="deviceIp" column="device_ip" jdbcType="VARCHAR"/>
+            <result property="serialNo" column="serial_no" jdbcType="VARCHAR"/>
+            <result property="licensePlate" column="license_plate" jdbcType="VARCHAR"/>
+            <result property="plateConfidence" column="plate_confidence" jdbcType="INTEGER"/>
+            <result property="realPlate" column="real_plate" jdbcType="TINYINT"/>
+            <result property="plateColorType" column="plate_color_type" jdbcType="INTEGER"/>
+            <result property="triggerType" column="trigger_type" jdbcType="INTEGER"/>
+            <result property="direction" column="direction" jdbcType="INTEGER"/>
+            <result property="vehicleId" column="vehicle_id" jdbcType="BIGINT"/>
+            <result property="whitelistType" column="whitelist_type" jdbcType="INTEGER"/>
+            <result property="timeStamp" column="time_stamp" jdbcType="TIMESTAMP"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        select id,device_ip,serial_no,
+        license_plate,plate_confidence,real_plate,
+        plate_color_type,trigger_type,direction,
+        vehicle_id,whitelist_type,time_stamp,
+        create_time from car_inout_record
+    </sql>
+    <select id="getCarInRecordsByDateGroupByWhiteList" parameterType="CarInoutRecord" resultType="cn.com.oa.model.CarInoutRecord">
+        <include refid="Base_Column_List"/>
+        WHERE direction = #{direction}
+        AND whitelist_type = #{whitelistType}
+        AND DATE(time_stamp) = DATE(#{timeStamp})
+        ORDER BY license_plate
+    </select>
+
+</mapper>