新增 车位相机信息表以及相机解析信息逻辑

This commit is contained in:
Lemon
2023-12-11 09:00:58 +08:00
parent 5e4c8c7f84
commit a98a36f04f
10 changed files with 995 additions and 147 deletions

View File

@@ -0,0 +1,98 @@
package com.jsowell.web.controller.pile;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jsowell.common.annotation.Log;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.core.domain.AjaxResult;
import com.jsowell.common.enums.BusinessType;
import com.jsowell.pile.domain.PileCameraInfo;
import com.jsowell.pile.service.IPileCameraInfoService;
import com.jsowell.common.util.poi.ExcelUtil;
import com.jsowell.common.core.page.TableDataInfo;
/**
* 【请填写功能名称】Controller
*
* @author jsowell
* @date 2023-12-09
*/
@RestController
@RequestMapping("/pile/info")
public class PileCameraInfoController extends BaseController {
@Autowired
private IPileCameraInfoService pileCameraInfoService;
/**
* 查询【请填写功能名称】列表
*/
@PreAuthorize("@ss.hasPermi('pile:info:list')")
@GetMapping("/list")
public TableDataInfo list(PileCameraInfo pileCameraInfo) {
startPage();
List<PileCameraInfo> list = pileCameraInfoService.selectPileCameraInfoList(pileCameraInfo);
return getDataTable(list);
}
/**
* 导出【请填写功能名称】列表
*/
@PreAuthorize("@ss.hasPermi('pile:info:export')")
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, PileCameraInfo pileCameraInfo) {
List<PileCameraInfo> list = pileCameraInfoService.selectPileCameraInfoList(pileCameraInfo);
ExcelUtil<PileCameraInfo> util = new ExcelUtil<PileCameraInfo>(PileCameraInfo.class);
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
* 获取【请填写功能名称】详细信息
*/
@PreAuthorize("@ss.hasPermi('pile:info:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(pileCameraInfoService.selectPileCameraInfoById(id));
}
/**
* 新增【请填写功能名称】
*/
@PreAuthorize("@ss.hasPermi('pile:info:add')")
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody PileCameraInfo pileCameraInfo) {
return toAjax(pileCameraInfoService.insertPileCameraInfo(pileCameraInfo));
}
/**
* 修改【请填写功能名称】
*/
@PreAuthorize("@ss.hasPermi('pile:info:edit')")
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody PileCameraInfo pileCameraInfo) {
return toAjax(pileCameraInfoService.updatePileCameraInfo(pileCameraInfo));
}
/**
* 删除【请填写功能名称】
*/
@PreAuthorize("@ss.hasPermi('pile:info:remove')")
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(pileCameraInfoService.deletePileCameraInfoByIds(ids));
}
}

View File

@@ -36,10 +36,10 @@ spring:
druid:
# 主库数据源
master:
#url: jdbc:mysql://192.168.2.2:3306/jsowell_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
#username: jsowell_dev
url: jdbc:mysql://192.168.2.2:3306/jsowell_prd_copy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: jsowell_prd_copy
url: jdbc:mysql://192.168.2.2:3306/jsowell_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: jsowell_dev
# url: jdbc:mysql://192.168.2.2:3306/jsowell_prd_copy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: jsowell_prd_copy
password: 123456
# 从库数据源
slave:

View File

@@ -194,6 +194,11 @@ public class CacheConstants {
*/
public static final String YCBC_TOKEN_BY_OPERATORID = "yong_cheng_bo_che_token_by_operatorId:";
/**
* 相机拍摄入场/出场照片
*/
public static final String CAMERA_IMAGE_BY_PLATE_NUMBER = "CAMERA_IMAGE_BY_PLATE_NUMBER_";
/**
* 桩硬件故障
*/

View File

@@ -0,0 +1,206 @@
package com.jsowell.pile.domain;
import com.jsowell.common.annotation.Excel;
import com.jsowell.common.core.domain.BaseEntity;
import lombok.Builder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 【请填写功能名称】对象 pile_camera_info
*
* @author jsowell
* @date 2023-12-09
*/
@Builder
public class PileCameraInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* 设备名称
*/
@Excel(name = "设备名称")
private String deviceName;
/**
* 设备IP地址
*/
@Excel(name = "设备IP地址")
private String deviceIp;
/**
* 设备sn号
*/
@Excel(name = "设备sn号")
private String deviceSn;
/**
* 车牌号
*/
@Excel(name = "车牌号")
private String plateNumber;
/**
* 车位状态
* 01入场02在场04出场08空场10车位异常(=="跨车位报警"和"视频遮挡"时==)20延迟上报出场(预留)40合并出入场(预留)80预入场(预留)100预出场(预留)200入场修正(预留)
*/
@Excel(name = "车位状态 01入场02在场04出场08空场10车位异常(=='跨车位报警'和'视频遮挡'时==)20延迟上报出场(预留)40合并出入场(预留)80预入场(预留)100预出场(预留)200入场修正(预留)")
private String parkingState;
/**
* 车位id
*/
@Excel(name = "车位id")
private Integer zoneId;
/**
* 车位名
*/
@Excel(name = "车位名")
private String zoneName;
/**
* 车牌颜色0:未知;1:蓝色;2:黄色;3:白色;4:黑色;5:绿色;
*/
@Excel(name = "车牌颜色", readConverterExp = "0=:未知;1:蓝色;2:黄色;3:白色;4:黑色;5:绿色;")
private Integer color;
/**
* 车牌类型0:未知车牌1:蓝牌小汽车2:黑牌小汽车3:单排黄牌4:双排黄牌(大车尾牌,农用车)5:警车车牌6:武警车牌7:个性化车牌8:单排军车牌;
* 9:双排军车牌10:使馆车牌11:香港进出中国大陆车牌12:农用车牌13:教练车牌14:澳门进出中国大陆车牌15:双层武警车牌16:武警总队车牌17:双层武警总队车牌18:民航车牌19:新能源车牌20:新能源车牌大21:应急22:领馆
*
*/
@Excel(name = "车牌类型", readConverterExp = "0=:未知车牌1:蓝牌小汽车2:黑牌小汽车3:单排黄牌4:双排黄牌(大车尾牌,农用车)5:警车车牌6:武警车牌7:个性化车牌8:单排军车牌; 9:双排军车牌10:使馆车牌11:香港进出中国大陆车牌12:农用车牌13:教练车牌14:澳门进出中国大陆车牌15:双层武警车牌16:武警总队车牌17:双层武警总队车牌18:民航车牌19:新能源车牌20:新能源车牌大21:应急22:领馆 ")
private Integer plateType;
/**
* 图片base64编码
*/
@Excel(name = "图片base64编码")
private String image;
/**
* $column.columnComment
*/
private String delFlag;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceIp(String deviceIp) {
this.deviceIp = deviceIp;
}
public String getDeviceIp() {
return deviceIp;
}
public void setDeviceSn(String deviceSn) {
this.deviceSn = deviceSn;
}
public String getDeviceSn() {
return deviceSn;
}
public void setPlateNumber(String plateNumber) {
this.plateNumber = plateNumber;
}
public String getPlateNumber() {
return plateNumber;
}
public void setParkingState(String parkingState) {
this.parkingState = parkingState;
}
public String getParkingState() {
return parkingState;
}
public void setZoneId(Integer zoneId) {
this.zoneId = zoneId;
}
public Integer getZoneId() {
return zoneId;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public String getZoneName() {
return zoneName;
}
public void setColor(Integer color) {
this.color = color;
}
public Integer getColor() {
return color;
}
public void setPlateType(Integer plateType) {
this.plateType = plateType;
}
public Integer getPlateType() {
return plateType;
}
public void setImage(String image) {
this.image = image;
}
public String getImage() {
return image;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getDelFlag() {
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
.append("id", getId())
.append("deviceName", getDeviceName())
.append("deviceIp", getDeviceIp())
.append("deviceSn", getDeviceSn())
.append("plateNumber", getPlateNumber())
.append("parkingState", getParkingState())
.append("zoneId", getZoneId())
.append("zoneName", getZoneName())
.append("color", getColor())
.append("plateType", getPlateType())
.append("image", getImage())
.append("createTime", getCreateTime())
.append("delFlag", getDelFlag())
.toString();
}
}

View File

@@ -81,20 +81,7 @@ public class CameraIdentifyResultsDTO {
@JSONField(name = "product_h")
private ProductH productH;
/**
* 车位信息对象
*/
private Parking parking;
/**
* 车牌信息对象
*/
private Plate plate;
/**
* 识别信息对象
*/
private Reco reco;
@Data
@@ -208,6 +195,22 @@ public class CameraIdentifyResultsDTO {
@JSONField(name = "car_pos")
private CarPos carPos;
/**
* 车位信息对象
*/
private Parking parking;
/**
* 车牌信息对象
*/
private Plate plate;
/**
* 识别信息对象
*/
private Reco reco;
@Data
private static class CarPos{
/**
@@ -224,32 +227,10 @@ public class CameraIdentifyResultsDTO {
*/
private Integer pos;
}
}
@Data
public static class Parking{
private Loc loc;
@Data
private static class Loc{
/**
* 坐标点
*/
@JSONField(name = "point")
private List<Point> pointList;
/**
* 坐标点个数
*/
@JSONField(name = "point_num")
private Integer pointNum;
/**
* 标点坐标系尺寸
*/
@JSONField(name = "reco_zone_size_factor")
private RecoZoneSizeFactor recoZoneSizeFactor;
public static class Parking{
private Loc loc;
/**
* 车位状态
@@ -280,117 +261,144 @@ public class CameraIdentifyResultsDTO {
@JSONField(name = "zone_name")
private String zoneName;
@Data
private static class Point{
// 点x坐标
private Integer x;
// 点y坐标
private Integer y;
}
@Data
private static class RecoZoneSizeFactor{
/**
* 坐标点坐标系尺寸高度
*/
@JSONField(name = "factor_h")
private Integer factorH;
private static class Loc{
/**
* 坐标点坐标系尺寸宽度
* 坐标点
*/
@JSONField(name = "factor_w")
private Integer factorW;
@JSONField(name = "point")
private List<Point> pointList;
/**
* 坐标点个数
*/
@JSONField(name = "point_num")
private Integer pointNum;
/**
* 标点坐标系尺寸
*/
@JSONField(name = "reco_zone_size_factor")
private RecoZoneSizeFactor recoZoneSizeFactor;
@Data
private static class Point{
// 点x坐标
private Integer x;
// 点y坐标
private Integer y;
}
@Data
private static class RecoZoneSizeFactor{
/**
* 坐标点坐标系尺寸高度
*/
@JSONField(name = "factor_h")
private Integer factorH;
/**
* 坐标点坐标系尺寸宽度
*/
@JSONField(name = "factor_w")
private Integer factorW;
}
}
}
@Data
public static class Plate{
/**
* 车牌颜色
*
* 0:未知;
* 1:蓝色;
* 2:黄色;
* 3:白色;
* 4:黑色;
* 5:绿色;
*/
private Integer color;
// 车牌置信度
private Integer confidence;
private Loc loc;
/**
* 车牌
* UTF8后再BASE64编码
* 如果有车牌:真实车牌号
* 如果有车无牌:无牌车
* 如果无车无牌:__无__
* 非机动车:非机动车
*/
private String plate;
/**
* 车牌类型
*
* 0:未知车牌
* 1:蓝牌小汽车
* 2:黑牌小汽车
* 3:单排黄牌
* 4:双排黄牌(大车尾牌,农用车)
* 5:警车车牌
* 6:武警车牌
* 7:个性化车牌
* 8:单排军车牌
* 9:双排军车牌
* 10:使馆车牌
* 11:香港进出中国大陆车牌
* 12:农用车牌
* 13:教练车牌
* 14:澳门进出中国大陆车牌
* 15:双层武警车牌
* 16:武警总队车牌
* 17:双层武警总队车牌
* 18:民航车牌
* 19:新能源车牌
* 20:新能源车牌大
* 21:应急
* 22:领馆
*/
private Integer type;
}
@Data
private static class Reco{
/**
* 识别组id
*/
@JSONField(name = "group_id")
private Integer groupId;
/**
* 识别标志
*/
@JSONField(name = "reco_flag")
private Integer recoFlag;
/**
* 识别id
*/
@JSONField(name = "reco_id")
private Integer recoId;
/**
* 识别时间(字符串格式时间)
*/
@JSONField(name = "reco_time")
private String recoTime;
}
}
@Data
public static class Plate{
/**
* 车牌颜色
*
* 0:未知;
* 1:蓝色;
* 2:黄色;
* 3:白色;
* 4:黑色;
* 5:绿色;
*/
private Integer color;
// 车牌置信度
private Integer confidence;
private Loc loc;
/**
* 车牌
* UTF8后再BASE64编码
* 如果有车牌:真实车牌号
* 如果有车无牌:无牌车
* 如果无车无牌:__无__
* 非机动车:非机动车
*/
private String plate;
/**
* 车牌类型
*
* 0:未知车牌
* 1:蓝牌小汽车
* 2:黑牌小汽车
* 3:单排黄牌
* 4:双排黄牌(大车尾牌,农用车)
* 5:警车车牌
* 6:武警车牌
* 7:个性化车牌
* 8:单排军车牌
* 9:双排军车牌
* 10:使馆车牌
* 11:香港进出中国大陆车牌
* 12:农用车牌
* 13:教练车牌
* 14:澳门进出中国大陆车牌
* 15:双层武警车牌
* 16:武警总队车牌
* 17:双层武警总队车牌
* 18:民航车牌
* 19:新能源车牌
* 20:新能源车牌大
* 21:应急
* 22:领馆
*/
private Integer type;
}
@Data
public static class Reco{
/**
* 识别组id
*/
@JSONField(name = "group_id")
private Integer groupId;
/**
* 识别标志
*/
@JSONField(name = "reco_flag")
private Integer recoFlag;
/**
* 识别id
*/
@JSONField(name = "reco_id")
private Integer recoId;
/**
* 识别时间(字符串格式时间)
*/
@JSONField(name = "reco_time")
private String recoTime;
}

View File

@@ -0,0 +1,63 @@
package com.jsowell.pile.mapper;
import java.util.List;
import com.jsowell.pile.domain.PileCameraInfo;
import org.springframework.stereotype.Repository;
/**
* 【请填写功能名称】Mapper接口
*
* @author jsowell
* @date 2023-12-09
*/
@Repository
public interface PileCameraInfoMapper {
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public PileCameraInfo selectPileCameraInfoById(Long id);
/**
* 查询【请填写功能名称】列表
*
* @param pileCameraInfo 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<PileCameraInfo> selectPileCameraInfoList(PileCameraInfo pileCameraInfo);
/**
* 新增【请填写功能名称】
*
* @param pileCameraInfo 【请填写功能名称】
* @return 结果
*/
public int insertPileCameraInfo(PileCameraInfo pileCameraInfo);
/**
* 修改【请填写功能名称】
*
* @param pileCameraInfo 【请填写功能名称】
* @return 结果
*/
public int updatePileCameraInfo(PileCameraInfo pileCameraInfo);
/**
* 删除【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
public int deletePileCameraInfoById(Long id);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deletePileCameraInfoByIds(Long[] ids);
}

View File

@@ -0,0 +1,61 @@
package com.jsowell.pile.service;
import java.util.List;
import com.jsowell.pile.domain.PileCameraInfo;
/**
* 【请填写功能名称】Service接口
*
* @author jsowell
* @date 2023-12-09
*/
public interface IPileCameraInfoService {
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public PileCameraInfo selectPileCameraInfoById(Long id);
/**
* 查询【请填写功能名称】列表
*
* @param pileCameraInfo 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<PileCameraInfo> selectPileCameraInfoList(PileCameraInfo pileCameraInfo);
/**
* 新增【请填写功能名称】
*
* @param pileCameraInfo 【请填写功能名称】
* @return 结果
*/
public int insertPileCameraInfo(PileCameraInfo pileCameraInfo);
/**
* 修改【请填写功能名称】
*
* @param pileCameraInfo 【请填写功能名称】
* @return 结果
*/
public int updatePileCameraInfo(PileCameraInfo pileCameraInfo);
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】主键集合
* @return 结果
*/
public int deletePileCameraInfoByIds(Long[] ids);
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
public int deletePileCameraInfoById(Long id);
}

View File

@@ -0,0 +1,89 @@
package com.jsowell.pile.service.impl;
import java.util.List;
import com.jsowell.common.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jsowell.pile.mapper.PileCameraInfoMapper;
import com.jsowell.pile.domain.PileCameraInfo;
import com.jsowell.pile.service.IPileCameraInfoService;
/**
* 【请填写功能名称】Service业务层处理
*
* @author jsowell
* @date 2023-12-09
*/
@Service
public class PileCameraInfoServiceImpl implements IPileCameraInfoService {
@Autowired
private PileCameraInfoMapper pileCameraInfoMapper;
/**
* 查询【请填写功能名称】
*
* @param id 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
@Override
public PileCameraInfo selectPileCameraInfoById(Long id) {
return pileCameraInfoMapper.selectPileCameraInfoById(id);
}
/**
* 查询【请填写功能名称】列表
*
* @param pileCameraInfo 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public List<PileCameraInfo> selectPileCameraInfoList(PileCameraInfo pileCameraInfo) {
return pileCameraInfoMapper.selectPileCameraInfoList(pileCameraInfo);
}
/**
* 新增【请填写功能名称】
*
* @param pileCameraInfo 【请填写功能名称】
* @return 结果
*/
@Override
public int insertPileCameraInfo(PileCameraInfo pileCameraInfo) {
pileCameraInfo.setCreateTime(DateUtils.getNowDate());
return pileCameraInfoMapper.insertPileCameraInfo(pileCameraInfo);
}
/**
* 修改【请填写功能名称】
*
* @param pileCameraInfo 【请填写功能名称】
* @return 结果
*/
@Override
public int updatePileCameraInfo(PileCameraInfo pileCameraInfo) {
return pileCameraInfoMapper.updatePileCameraInfo(pileCameraInfo);
}
/**
* 批量删除【请填写功能名称】
*
* @param ids 需要删除的【请填写功能名称】主键
* @return 结果
*/
@Override
public int deletePileCameraInfoByIds(Long[] ids) {
return pileCameraInfoMapper.deletePileCameraInfoByIds(ids);
}
/**
* 删除【请填写功能名称】信息
*
* @param id 【请填写功能名称】主键
* @return 结果
*/
@Override
public int deletePileCameraInfoById(Long id) {
return pileCameraInfoMapper.deletePileCameraInfoById(id);
}
}

View File

@@ -0,0 +1,216 @@
<?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="com.jsowell.pile.mapper.PileCameraInfoMapper">
<resultMap type="com.jsowell.pile.domain.PileCameraInfo" id="PileCameraInfoResult">
<result property="id" column="id"/>
<result property="deviceName" column="device_name"/>
<result property="deviceIp" column="device_ip"/>
<result property="deviceSn" column="device_sn"/>
<result property="plateNumber" column="plate_number"/>
<result property="parkingState" column="parking_state"/>
<result property="zoneId" column="zone_id"/>
<result property="zoneName" column="zone_name"/>
<result property="color" column="color"/>
<result property="plateType" column="plate_type"/>
<result property="image" column="image"/>
<result property="createTime" column="create_time"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<sql id="selectPileCameraInfoVo">
select id,
device_name,
device_ip,
device_sn,
plate_number,
parking_state,
zone_id,
zone_name,
color,
plate_type,
image,
create_time,
del_flag
from pile_camera_info
</sql>
<select id="selectPileCameraInfoList" parameterType="com.jsowell.pile.domain.PileCameraInfo" resultMap="PileCameraInfoResult">
<include refid="selectPileCameraInfoVo"/>
<where>
<if test="deviceName != null and deviceName != ''">
and device_name like concat('%', #{deviceName}, '%')
</if>
<if test="deviceIp != null and deviceIp != ''">
and device_ip = #{deviceIp}
</if>
<if test="deviceSn != null and deviceSn != ''">
and device_sn = #{deviceSn}
</if>
<if test="plateNumber != null and plateNumber != ''">
and plate_number = #{plateNumber}
</if>
<if test="parkingState != null and parkingState != ''">
and parking_state = #{parkingState}
</if>
<if test="zoneId != null">
and zone_id = #{zoneId}
</if>
<if test="zoneName != null and zoneName != ''">
and zone_name like concat('%', #{zoneName}, '%')
</if>
<if test="color != null">
and color = #{color}
</if>
<if test="plateType != null">
and plate_type = #{plateType}
</if>
<if test="image != null and image != ''">
and image = #{image}
</if>
</where>
</select>
<select id="selectPileCameraInfoById" parameterType="Long" resultMap="PileCameraInfoResult">
<include refid="selectPileCameraInfoVo"/>
where id = #{id}
</select>
<insert id="insertPileCameraInfo" parameterType="com.jsowell.pile.domain.PileCameraInfo" useGeneratedKeys="true" keyProperty="id">
insert into pile_camera_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceName != null">
device_name,
</if>
<if test="deviceIp != null">
device_ip,
</if>
<if test="deviceSn != null">
device_sn,
</if>
<if test="plateNumber != null">
plate_number,
</if>
<if test="parkingState != null">
parking_state,
</if>
<if test="zoneId != null">
zone_id,
</if>
<if test="zoneName != null">
zone_name,
</if>
<if test="color != null">
color,
</if>
<if test="plateType != null">
plate_type,
</if>
<if test="image != null">
image,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="delFlag != null">
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null">
#{deviceName},
</if>
<if test="deviceIp != null">
#{deviceIp},
</if>
<if test="deviceSn != null">
#{deviceSn},
</if>
<if test="plateNumber != null">
#{plateNumber},
</if>
<if test="parkingState != null">
#{parkingState},
</if>
<if test="zoneId != null">
#{zoneId},
</if>
<if test="zoneName != null">
#{zoneName},
</if>
<if test="color != null">
#{color},
</if>
<if test="plateType != null">
#{plateType},
</if>
<if test="image != null">
#{image},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="delFlag != null">
#{delFlag},
</if>
</trim>
</insert>
<update id="updatePileCameraInfo" parameterType="com.jsowell.pile.domain.PileCameraInfo">
update pile_camera_info
<trim prefix="SET" suffixOverrides=",">
<if test="deviceName != null">
device_name = #{deviceName},
</if>
<if test="deviceIp != null">
device_ip = #{deviceIp},
</if>
<if test="deviceSn != null">
device_sn = #{deviceSn},
</if>
<if test="plateNumber != null">
plate_number = #{plateNumber},
</if>
<if test="parkingState != null">
parking_state = #{parkingState},
</if>
<if test="zoneId != null">
zone_id = #{zoneId},
</if>
<if test="zoneName != null">
zone_name = #{zoneName},
</if>
<if test="color != null">
color = #{color},
</if>
<if test="plateType != null">
plate_type = #{plateType},
</if>
<if test="image != null">
image = #{image},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="delFlag != null">
del_flag = #{delFlag},
</if>
</trim>
where id = #{id}
</update>
<delete id="deletePileCameraInfoById" parameterType="Long">
delete
from pile_camera_info
where id = #{id}
</delete>
<delete id="deletePileCameraInfoByIds" parameterType="String">
delete
from pile_camera_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -1,16 +1,20 @@
package com.jsowell.thirdparty.camera.service;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.PileCameraInfo;
import com.jsowell.pile.dto.camera.CameraIdentifyResultsDTO;
import com.jsowell.pile.service.IPileCameraInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 相机管理系统 Service
@@ -24,22 +28,120 @@ public class CameraService {
@Autowired
private RedisCache redisCache;
@Autowired
private IPileCameraInfoService pileCameraInfoService;
public void receiveIdentifyResults(JSONObject jsonObject) {
// 区分入场和出场
// Integer parking_state = jsonObject.getJSONObject("parking").getInteger("parking_state");
// if (parking_state == 1) {
// // 入场
// String parkingState = "ENTRY";
// vehicleEntry(jsonObject, parkingState);
// }
// if (parking_state == 2) {
// // 在场
// }
// if (parking_state == 4) {
// // 出场
// }
saveInfo2DataBase(jsonObject);
}
/**
* 车辆入场
* @param jsonObject
*/
private void vehicleEntry(JSONObject jsonObject, String parkingState) {
// 先将车牌图片信息存入缓存
// boolean result = saveCarPicture2Redis(jsonObject, parkingState);
// 将信息存数据库
saveInfo2DataBase(jsonObject);
}
private boolean saveInfo2DataBase(JSONObject jsonObject) {
// 车牌信息
CameraIdentifyResultsDTO.ProductH.Plate plate = JSONObject.parseObject(jsonObject.getJSONObject("product_h").getJSONObject("plate").toJSONString(),
CameraIdentifyResultsDTO.ProductH.Plate.class);
if (plate == null) {
return false;
}
// 停车位信息
CameraIdentifyResultsDTO.ProductH.Parking parking = JSONObject.parseObject(jsonObject.getJSONObject("product_h").getJSONObject("parking").toJSONString(),
CameraIdentifyResultsDTO.ProductH.Parking.class);
if (parking == null) {
return false;
}
// 设备信息
CameraIdentifyResultsDTO.DeviceInfo deviceInfo = JSONObject.parseObject(jsonObject.getJSONObject("device_info").toJSONString(),
CameraIdentifyResultsDTO.DeviceInfo.class);
if (deviceInfo == null) {
return false;
}
// 获取背景图片
JSONArray bgImgs = jsonObject.getJSONArray("bg_img");
List<CameraIdentifyResultsDTO.BgImg> bgImgList = bgImgs.toList(CameraIdentifyResultsDTO.BgImg.class);
if (CollectionUtils.isEmpty(bgImgList)) {
return;
return false;
}
// Base64解密
String plateNumber = Base64.decodeStr(plate.getPlate());
String zoneName = Base64.decodeStr(parking.getZoneName());
for (CameraIdentifyResultsDTO.BgImg bgImg : bgImgList) {
PileCameraInfo pileCameraInfo = PileCameraInfo.builder()
.deviceName(deviceInfo.getDevName())
.deviceIp(deviceInfo.getIp())
.deviceSn(deviceInfo.getSn())
.plateNumber(plateNumber)
.parkingState(String.valueOf(parking.getParkingState()))
.zoneId(parking.getZoneId())
.zoneName(zoneName)
.color(plate.getColor())
.plateType(plate.getType())
.image(bgImg.getImage())
.build();
// 插入数据库
pileCameraInfoService.insertPileCameraInfo(pileCameraInfo);
}
return true;
}
/**
* 将车辆图片信息存入缓存
* @param jsonObject
*/
private boolean saveCarPicture2Redis(JSONObject jsonObject, String parkingState) {
// 获取车牌号
String plateNumber = jsonObject.getJSONObject("plate").getString("plate");
if (StringUtils.isBlank(plateNumber)) {
return false;
}
// 获取背景图片
JSONArray bgImgs = jsonObject.getJSONArray("bg_img");
List<CameraIdentifyResultsDTO.BgImg> bgImgList = bgImgs.toList(CameraIdentifyResultsDTO.BgImg.class);
if (CollectionUtils.isEmpty(bgImgList)) {
return false;
}
for (CameraIdentifyResultsDTO.BgImg bgImg : bgImgList) {
String image = bgImg.getImage(); // 图片的 base64 编码
String key = bgImg.getKey(); // 索引id
String redisKey = "receiveCameraImageByKey_" + key;
// 根据索引id存入缓存
redisCache.setCacheObject(redisKey, image, 10, TimeUnit.HOURS);
// String key = bgImg.getKey(); // 索引id
// key: 前缀 + 车牌号 + 日期 + 入场/出场状态
String redisKey = CacheConstants.CAMERA_IMAGE_BY_PLATE_NUMBER + plateNumber + "_" + DateUtils.getDate() + "_" + parkingState;
// 存入缓存
// TODO 暂时永久保存
redisCache.setCacheObject(redisKey, image);
}
return true;
}
}