mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
feat: 添加智能摄像头及相关数据传输对象、实体、服务和控制器
This commit is contained in:
@@ -17,6 +17,7 @@ import cn.lihongjie.coal.spring.config.AliyunProperty;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.model.OSSObject;
|
||||
import com.aliyun.oss.model.PutObjectResult;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
@@ -194,7 +195,7 @@ public class FileService extends BaseService<FileEntity, FileRepository> {
|
||||
String objectUrl;
|
||||
try {
|
||||
|
||||
com.aliyun.oss.model.PutObjectResult objectResult =
|
||||
PutObjectResult objectResult =
|
||||
ossClient.putObject(
|
||||
aliyunProperty.getOSS().getBucketName(), objectKey, inputStream);
|
||||
} catch (Exception e) {
|
||||
@@ -222,6 +223,14 @@ public class FileService extends BaseService<FileEntity, FileRepository> {
|
||||
return objectUrl;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public FileDto upload(
|
||||
InputStream file,
|
||||
String name,
|
||||
String dir) {
|
||||
return upload(file, name, dir, null, null, null);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public FileDto upload(
|
||||
InputStream file,
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.smartCam.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.OrgScope;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.smartCam.dto.CreateSmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.dto.SmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.dto.UpdateSmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.service.SmartCamService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/smartCam")
|
||||
@SysLog(module = "智能摄像头")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class SmartCamController {
|
||||
@Autowired private SmartCamService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public SmartCamDto create(@RequestBody CreateSmartCamDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public SmartCamDto update(@RequestBody UpdateSmartCamDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public SmartCamDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<SmartCamDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.lihongjie.coal.smartCam.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class CreateSmartCamDto extends OrgCommonDto {
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private String supplier;
|
||||
|
||||
|
||||
@Comment("摄像头安装位置")
|
||||
private String location;
|
||||
|
||||
|
||||
|
||||
@Comment("摄像头方向")
|
||||
private String direction;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.lihongjie.coal.smartCam.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.SmartCamSupplierDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class SmartCamDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne private SmartCamSupplierDto supplier;
|
||||
|
||||
@Comment("摄像头安装位置")
|
||||
private String location;
|
||||
|
||||
@Comment("摄像头方向")
|
||||
private String direction;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.lihongjie.coal.smartCam.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class UpdateSmartCamDto extends OrgCommonDto {
|
||||
|
||||
@ManyToOne
|
||||
private String supplier;
|
||||
|
||||
|
||||
@Comment("摄像头安装位置")
|
||||
private String location;
|
||||
|
||||
|
||||
|
||||
@Comment("摄像头方向")
|
||||
private String direction;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.lihongjie.coal.smartCam.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.smartCamSupplier.entity.SmartCamSupplierEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_smartCam_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class SmartCamEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private SmartCamSupplierEntity supplier;
|
||||
|
||||
|
||||
@Comment("摄像头安装位置")
|
||||
private String location;
|
||||
|
||||
|
||||
|
||||
@Comment("摄像头方向")
|
||||
private String direction;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.lihongjie.coal.smartCam.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.smartCam.dto.CreateSmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.dto.SmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.dto.UpdateSmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.entity.SmartCamEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface SmartCamMapper
|
||||
extends BaseMapper<SmartCamEntity, SmartCamDto, CreateSmartCamDto, UpdateSmartCamDto> {}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.lihongjie.coal.smartCam.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.smartCam.entity.SmartCamEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface SmartCamRepository extends BaseRepository<SmartCamEntity> {
|
||||
@Query(
|
||||
"select exists (select 1 from SmartCamCarLicenseSnapshotDataEntity e where e.smartCam.id in :ids)")
|
||||
boolean isLinked(List<String> ids);
|
||||
|
||||
@Query("select e from SmartCamEntity e where e.code = :serialNumber")
|
||||
SmartCamEntity getBySerialNumber(@Param("serialNumber") String serialNumber);
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package cn.lihongjie.coal.smartCam.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.smartCam.dto.CreateSmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.dto.SmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.dto.UpdateSmartCamDto;
|
||||
import cn.lihongjie.coal.smartCam.entity.SmartCamEntity;
|
||||
import cn.lihongjie.coal.smartCam.mapper.SmartCamMapper;
|
||||
import cn.lihongjie.coal.smartCam.repository.SmartCamRepository;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class SmartCamService extends BaseService<SmartCamEntity, SmartCamRepository> {
|
||||
@Autowired private SmartCamRepository repository;
|
||||
|
||||
@Autowired private SmartCamMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public SmartCamDto create(CreateSmartCamDto request) {
|
||||
SmartCamEntity entity = mapper.toEntity(request);
|
||||
|
||||
if (repository.getBySerialNumber(entity.getCode()) != null) {
|
||||
throw new BizException("设备序列号已存在");
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public SmartCamDto update(UpdateSmartCamDto request) {
|
||||
SmartCamEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
SmartCamEntity smartCam = repository.getBySerialNumber(entity.getCode());
|
||||
if (smartCam != null && !smartCam.getId().equals(entity.getId())) {
|
||||
throw new BizException("设备序列号已存在");
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public SmartCamDto getById(String id) {
|
||||
SmartCamEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<SmartCamDto> list(CommonQuery query) {
|
||||
Page<SmartCamEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
public SmartCamEntity getBySerialNumber(String serialNumber) {
|
||||
|
||||
|
||||
return repository.getBySerialNumber(serialNumber);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package cn.lihongjie.coal.smartCamCarLicenseSnapshotData.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.*;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.CreateSmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.SmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.UpdateSmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.service.SmartCamCarLicenseSnapshotDataService;
|
||||
import cn.lihongjie.coal.submitToken.controller.SubmitTokenController;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/smartCamCarLicenseSnapshotData")
|
||||
@SysLog(module = "智能摄像头车牌抓拍")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class SmartCamCarLicenseSnapshotDataController {
|
||||
@Autowired private SmartCamCarLicenseSnapshotDataService service;
|
||||
@Autowired private SubmitTokenController submitTokenController;
|
||||
|
||||
@PostMapping("/create")
|
||||
public SmartCamCarLicenseSnapshotDataDto create(
|
||||
@RequestBody CreateSmartCamCarLicenseSnapshotDataDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public SmartCamCarLicenseSnapshotDataDto update(
|
||||
@RequestBody UpdateSmartCamCarLicenseSnapshotDataDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public SmartCamCarLicenseSnapshotDataDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<SmartCamCarLicenseSnapshotDataDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
@RateLimit(value = false)
|
||||
@SignCheck(value = false)
|
||||
@SubmitToken(value = false)
|
||||
@PostMapping("/saveEvent")
|
||||
public ResponseEntity<String> saveEvent(@RequestBody String json) {
|
||||
ObjectNode jsonNodes = this.service.saveEvent(json);
|
||||
|
||||
return ResponseEntity.ok(jsonNodes.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateSmartCamCarLicenseSnapshotDataDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,130 @@
|
||||
package cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.smartCam.dto.SmartCamDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SmartCamCarLicenseSnapshotDataDto extends OrgCommonDto {
|
||||
|
||||
@Comment("事件类型")
|
||||
private String operator;
|
||||
|
||||
@ManyToOne private SmartCamDto smartCam;
|
||||
|
||||
@Comment("设备序列号")
|
||||
private String serialNumber;
|
||||
|
||||
@Comment("平台ID")
|
||||
private String platformID;
|
||||
|
||||
@Comment("事件ID,对于同一个事件,ID相同")
|
||||
private int infoEventId;
|
||||
|
||||
@Comment("事件发生时间,符合ISO 8601时间格式,参考使用前必读ISO8601标准介绍的日期和时间的组合表示法")
|
||||
private String infoTime;
|
||||
|
||||
private LocalDateTime infoTimeObj;
|
||||
|
||||
@Comment("车牌属性")
|
||||
private int attriClass;
|
||||
|
||||
@Comment(
|
||||
"车辆颜色;0-起始无效值,1-黑色,2-白色,3-银灰,4-深灰,5-棕色,6-红色,7-橙色,8-黄色,9-绿色,10-青色,11-蓝色,12-粉色,13-紫色,14-香槟色")
|
||||
private int carAttriColor;
|
||||
|
||||
@Comment("车牌颜色名称")
|
||||
private String carAttriColorName;
|
||||
|
||||
@Comment("车辆方向(0-下行(车头面对摄像头);1-上行(车尾面对摄像头);其他值无效)")
|
||||
private int attriOrientation;
|
||||
|
||||
@Comment("车辆方向名称")
|
||||
private String attriOrientationName;
|
||||
|
||||
@Comment("车牌号码")
|
||||
private String number;
|
||||
|
||||
@Comment("车牌颜色;0-起始无效值,1-蓝牌,2-黄牌,3-黑牌,4-白牌,5-绿牌,6-渐变绿,7-黄绿,8-缺省")
|
||||
private int carLicenseAttriColor;
|
||||
|
||||
@Comment("车牌颜色名称")
|
||||
private String carLicenseAttriColorName;
|
||||
|
||||
@Comment("车牌单双排(1-单排;2-双排;其他值无效)")
|
||||
private int carLicenseRowNum;
|
||||
|
||||
@Comment("车牌单双排名称")
|
||||
private String carLicenseRowNumName;
|
||||
|
||||
@Comment("车牌坐标 左")
|
||||
private int carLicenseRectLeft;
|
||||
|
||||
@Comment("车牌坐标 右")
|
||||
private int carLicenseRectRight;
|
||||
|
||||
@Comment("车牌坐标 上")
|
||||
private int carLicenseRectTop;
|
||||
|
||||
@Comment("车牌坐标 下")
|
||||
private int carLicenseRectBottom;
|
||||
|
||||
@Comment("驶入方向(0-下行驶入;1-上行驶入;其他值无效)")
|
||||
private int driveEntryDrection;
|
||||
|
||||
@Comment("驶入方向名称")
|
||||
private String driveEntryDrectionName;
|
||||
|
||||
@Comment("车牌结果置信度")
|
||||
private int match;
|
||||
|
||||
@Comment("车牌图评分")
|
||||
private int score;
|
||||
|
||||
@Comment("车型坐标 左")
|
||||
private int carRectLeft;
|
||||
|
||||
@Comment("车型坐标 右")
|
||||
private int carRectRight;
|
||||
|
||||
@Comment("车型坐标 上")
|
||||
private int carRectTop;
|
||||
|
||||
@Comment("车型坐标 下")
|
||||
private int carRectBottom;
|
||||
|
||||
@Comment("车牌抓拍图片信息 图片宽度")
|
||||
private int captureImageWidth;
|
||||
|
||||
@Comment("车牌抓拍图片信息 图片高度")
|
||||
private int captureImageHeight;
|
||||
|
||||
@Comment("车牌抓拍图片信息 文件大小")
|
||||
private int captureImagePictureLength;
|
||||
|
||||
@Comment("车牌抓拍图片信息 原始图片MD5值")
|
||||
private String captureImagePictureMd5;
|
||||
|
||||
@Comment("车牌背景图片信息 图片宽度")
|
||||
private int backgroundImageWidth;
|
||||
|
||||
@Comment("车牌背景图片信息 图片高度")
|
||||
private int backgroundImageHeight;
|
||||
|
||||
@Comment("车牌背景图片信息 文件大小")
|
||||
private int backgroundImagePictureLength;
|
||||
|
||||
@Comment("车牌背景图片信息 原始图片MD5值")
|
||||
private String backgroundImagePictureMd5;
|
||||
|
||||
@ManyToOne private String captureImage;
|
||||
|
||||
@ManyToOne private String backgroundImage;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateSmartCamCarLicenseSnapshotDataDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,160 @@
|
||||
package cn.lihongjie.coal.smartCamCarLicenseSnapshotData.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.file.entity.FileEntity;
|
||||
import cn.lihongjie.coal.smartCam.entity.SmartCamEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 消息字段名称 字段类型 描述 是否必选 deviceinfo serialNumber string 设备序列号 是 platformID string 平台ID 否 info
|
||||
* eventId integer 事件ID,对于同一个事件,ID相同 是 time string 事件发生时间,符合ISO
|
||||
* 8601时间格式,参考使用前必读ISO8601标准介绍的日期和时间的组合表示法 是 carLicenseAttriInfo 车牌属性 AttriClass interger 车辆类型
|
||||
* 是 CarAttriColor interger
|
||||
* 车辆颜色;0-起始无效值,1-黑色,2-白色,3-银灰,4-深灰,5-棕色,6-红色,7-橙色,8-黄色,9-绿色,10-青色,11-蓝色,12-粉色,13-紫色,14-香槟色 是
|
||||
* AttriOrientation interger 车辆方向(0-下行(车头面对摄像头);1-上行(车尾面对摄像头);其他值无效) 是 Number string 车牌号码 是
|
||||
* CarLicenseAttriColor interger 车牌颜色;0-起始无效值,1-蓝牌,2-黄牌,3-黑牌,4-白牌,5-绿牌,6-渐变绿,7-黄绿,8-缺省 是
|
||||
* CarLicenseRowNum interger 车牌单双排(1-单排;2-双排;其他值无效) 是 CarLicenseRect struct 车牌坐标 是 Left
|
||||
* interger 左 是 Right interger 右 是 Top interger 上 是 Bottom interger 下 是 carAttriInfo
|
||||
* 车牌属性 DriveEntryDrection interger 驶入方向(0-下行驶入;1-上行驶入;其他值无效) 是 Match float 车牌结果置信度 是 Score
|
||||
* float 车牌图评分 是 CarRect 车型坐标 Left interger 左 是 Right interger 右 是 Top interger 上 是
|
||||
* Bottom interger 下 是 CaptureImage 车牌抓拍图片信息 width interger 图片宽度 是 height interger 图片高度
|
||||
* 是 pictureLength interger 文件大小 是 picture string 图片base64编码后字符串 是 base64PicLength interger
|
||||
* 图片base64编码后字符串长度 是 pictureMd5 string 原始图片MD5值 是 BackgroundImage 车牌背景图片信息 width interger
|
||||
* 图片宽度 是 height interger 图片高度 是 pictureLength interger 文件大小 是 picture string
|
||||
* 图片base64编码后字符串 是 base64PicLength interger 图片base64编码后字符串长度 是 pictureMd5 string 原始图片MD5值 是
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_smartCamCarLicenseSnapshotData_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class SmartCamCarLicenseSnapshotDataEntity extends OrgCommonEntity {
|
||||
|
||||
@Comment("事件类型")
|
||||
private String operator;
|
||||
|
||||
@ManyToOne private SmartCamEntity smartCam;
|
||||
|
||||
@Comment("设备序列号")
|
||||
private String serialNumber;
|
||||
|
||||
@Comment("平台ID")
|
||||
private String platformID;
|
||||
|
||||
@Comment("事件ID,对于同一个事件,ID相同")
|
||||
private int infoEventId;
|
||||
|
||||
@Comment("事件发生时间,符合ISO 8601时间格式,参考使用前必读ISO8601标准介绍的日期和时间的组合表示法")
|
||||
private String infoTime;
|
||||
|
||||
private LocalDateTime infoTimeObj;
|
||||
|
||||
@Comment("车牌属性")
|
||||
private int attriClass;
|
||||
|
||||
@Comment(
|
||||
"车辆颜色;0-起始无效值,1-黑色,2-白色,3-银灰,4-深灰,5-棕色,6-红色,7-橙色,8-黄色,9-绿色,10-青色,11-蓝色,12-粉色,13-紫色,14-香槟色")
|
||||
private int carAttriColor;
|
||||
|
||||
@Comment("车牌颜色名称")
|
||||
private String carAttriColorName;
|
||||
|
||||
@Comment("车辆方向(0-下行(车头面对摄像头);1-上行(车尾面对摄像头);其他值无效)")
|
||||
private int attriOrientation;
|
||||
|
||||
@Comment("车辆方向名称")
|
||||
private String attriOrientationName;
|
||||
|
||||
@Comment("车牌号码")
|
||||
private String number;
|
||||
|
||||
@Comment("车牌颜色;0-起始无效值,1-蓝牌,2-黄牌,3-黑牌,4-白牌,5-绿牌,6-渐变绿,7-黄绿,8-缺省")
|
||||
private int carLicenseAttriColor;
|
||||
|
||||
@Comment("车牌颜色名称")
|
||||
private String carLicenseAttriColorName;
|
||||
|
||||
@Comment("车牌单双排(1-单排;2-双排;其他值无效)")
|
||||
private int carLicenseRowNum;
|
||||
|
||||
@Comment("车牌单双排名称")
|
||||
private String carLicenseRowNumName;
|
||||
|
||||
@Comment("车牌坐标 左")
|
||||
private int carLicenseRectLeft;
|
||||
|
||||
@Comment("车牌坐标 右")
|
||||
private int carLicenseRectRight;
|
||||
|
||||
@Comment("车牌坐标 上")
|
||||
private int carLicenseRectTop;
|
||||
|
||||
@Comment("车牌坐标 下")
|
||||
private int carLicenseRectBottom;
|
||||
|
||||
@Comment("驶入方向(0-下行驶入;1-上行驶入;其他值无效)")
|
||||
private int driveEntryDrection;
|
||||
|
||||
@Comment("驶入方向名称")
|
||||
private String driveEntryDrectionName;
|
||||
|
||||
@Comment("车牌结果置信度")
|
||||
private int match;
|
||||
|
||||
@Comment("车牌图评分")
|
||||
private int score;
|
||||
|
||||
@Comment("车型坐标 左")
|
||||
private int carRectLeft;
|
||||
|
||||
@Comment("车型坐标 右")
|
||||
private int carRectRight;
|
||||
|
||||
@Comment("车型坐标 上")
|
||||
private int carRectTop;
|
||||
|
||||
@Comment("车型坐标 下")
|
||||
private int carRectBottom;
|
||||
|
||||
@Comment("车牌抓拍图片信息 图片宽度")
|
||||
private int captureImageWidth;
|
||||
|
||||
@Comment("车牌抓拍图片信息 图片高度")
|
||||
private int captureImageHeight;
|
||||
|
||||
@Comment("车牌抓拍图片信息 文件大小")
|
||||
private int captureImagePictureLength;
|
||||
|
||||
@Comment("车牌抓拍图片信息 原始图片MD5值")
|
||||
private String captureImagePictureMd5;
|
||||
|
||||
@Comment("车牌背景图片信息 图片宽度")
|
||||
private int backgroundImageWidth;
|
||||
|
||||
@Comment("车牌背景图片信息 图片高度")
|
||||
private int backgroundImageHeight;
|
||||
|
||||
@Comment("车牌背景图片信息 文件大小")
|
||||
private int backgroundImagePictureLength;
|
||||
|
||||
@Comment("车牌背景图片信息 原始图片MD5值")
|
||||
private String backgroundImagePictureMd5;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private FileEntity captureImage;
|
||||
|
||||
@ManyToOne
|
||||
private FileEntity backgroundImage;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.smartCamCarLicenseSnapshotData.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.CreateSmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.SmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.UpdateSmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.entity.SmartCamCarLicenseSnapshotDataEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface SmartCamCarLicenseSnapshotDataMapper
|
||||
extends BaseMapper<
|
||||
SmartCamCarLicenseSnapshotDataEntity,
|
||||
SmartCamCarLicenseSnapshotDataDto,
|
||||
CreateSmartCamCarLicenseSnapshotDataDto,
|
||||
UpdateSmartCamCarLicenseSnapshotDataDto> {}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.lihongjie.coal.smartCamCarLicenseSnapshotData.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.entity.SmartCamCarLicenseSnapshotDataEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface SmartCamCarLicenseSnapshotDataRepository
|
||||
extends BaseRepository<SmartCamCarLicenseSnapshotDataEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
package cn.lihongjie.coal.smartCamCarLicenseSnapshotData.service;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.file.dto.FileDto;
|
||||
import cn.lihongjie.coal.file.entity.FileEntity;
|
||||
import cn.lihongjie.coal.file.service.FileService;
|
||||
import cn.lihongjie.coal.smartCam.entity.SmartCamEntity;
|
||||
import cn.lihongjie.coal.smartCam.service.SmartCamService;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.CreateSmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.SmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.UpdateSmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.entity.SmartCamCarLicenseSnapshotDataEntity;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.mapper.SmartCamCarLicenseSnapshotDataMapper;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.repository.SmartCamCarLicenseSnapshotDataRepository;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class SmartCamCarLicenseSnapshotDataService
|
||||
extends BaseService<
|
||||
SmartCamCarLicenseSnapshotDataEntity, SmartCamCarLicenseSnapshotDataRepository> {
|
||||
@Autowired SmartCamService smartCamService;
|
||||
@Autowired ObjectMapper objectMapper;
|
||||
@Autowired FileService fileService;
|
||||
@PersistenceContext EntityManager em;
|
||||
@Autowired private SmartCamCarLicenseSnapshotDataRepository repository;
|
||||
@Autowired private SmartCamCarLicenseSnapshotDataMapper mapper;
|
||||
@Autowired private ConversionService conversionService;
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public SmartCamCarLicenseSnapshotDataDto create(
|
||||
CreateSmartCamCarLicenseSnapshotDataDto request) {
|
||||
SmartCamCarLicenseSnapshotDataEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public SmartCamCarLicenseSnapshotDataDto update(
|
||||
UpdateSmartCamCarLicenseSnapshotDataDto request) {
|
||||
SmartCamCarLicenseSnapshotDataEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public SmartCamCarLicenseSnapshotDataDto getById(String id) {
|
||||
SmartCamCarLicenseSnapshotDataEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<SmartCamCarLicenseSnapshotDataDto> list(CommonQuery query) {
|
||||
Page<SmartCamCarLicenseSnapshotDataEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public ObjectNode saveEvent(String json) {
|
||||
JsonNode rootNode = objectMapper.readTree(json);
|
||||
SmartCamCarLicenseSnapshotDataEntity entity = new SmartCamCarLicenseSnapshotDataEntity();
|
||||
|
||||
// Operator
|
||||
entity.setOperator(rootNode.path("operator").asText());
|
||||
|
||||
// Device Info
|
||||
JsonNode deviceInfoNode = rootNode.path("deviceInfo");
|
||||
entity.setSerialNumber(deviceInfoNode.path("serialNumber").asText());
|
||||
entity.setPlatformID(deviceInfoNode.path("platformID").asText());
|
||||
|
||||
// Event Info
|
||||
JsonNode infoNode = rootNode.path("info");
|
||||
entity.setInfoEventId(infoNode.path("eventId").asInt());
|
||||
entity.setInfoTime(infoNode.path("time").asText());
|
||||
|
||||
// ISO8601
|
||||
entity.setInfoTimeObj(
|
||||
LocalDateTime.parse(
|
||||
infoNode.path("time").asText(),
|
||||
DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmssXXX")));
|
||||
if (ObjectUtils.notEqual(entity.getOperator(), "CarLicenseSnapshot")) {
|
||||
|
||||
log.info("Event type is not CarLicenseSnapshot, ignore it {}", json);
|
||||
|
||||
return getAck(entity.getInfoEventId());
|
||||
}
|
||||
|
||||
SmartCamEntity smartCam = smartCamService.getBySerialNumber(entity.getSerialNumber());
|
||||
|
||||
if (smartCam == null) {
|
||||
log.error("SmartCam not found for serial number {}", entity.getSerialNumber());
|
||||
return getAck(entity.getInfoEventId());
|
||||
}
|
||||
|
||||
entity.setSmartCam(smartCam);
|
||||
|
||||
// Car License Attribute Info
|
||||
JsonNode carLicenseAttriInfoNode = infoNode.path("carLicenseAttriInfo");
|
||||
entity.setAttriClass(carLicenseAttriInfoNode.path("AttriClass").asInt());
|
||||
entity.setCarAttriColor(carLicenseAttriInfoNode.path("CarAttriColor").asInt());
|
||||
entity.setCarAttriColorName(
|
||||
translateCarAttriColor(carLicenseAttriInfoNode.path("CarAttriColor").asInt()));
|
||||
entity.setAttriOrientation(carLicenseAttriInfoNode.path("AttriOrientation").asInt());
|
||||
entity.setAttriOrientationName(
|
||||
translateAttriOrientation(
|
||||
carLicenseAttriInfoNode.path("AttriOrientation").asInt()));
|
||||
entity.setNumber(carLicenseAttriInfoNode.path("Number").asText());
|
||||
entity.setCarLicenseAttriColor(
|
||||
carLicenseAttriInfoNode.path("CarLicenseAttriColor").asInt());
|
||||
entity.setCarLicenseAttriColorName(
|
||||
translateCarLicenseAttriColor(
|
||||
carLicenseAttriInfoNode.path("CarLicenseAttriColor").asInt()));
|
||||
entity.setCarLicenseRowNum(carLicenseAttriInfoNode.path("CarLicenseRowNum").asInt());
|
||||
entity.setCarLicenseRowNumName(
|
||||
translateCarLicenseRowNum(
|
||||
carLicenseAttriInfoNode.path("CarLicenseRowNum").asInt()));
|
||||
|
||||
JsonNode carLicenseRectNode = carLicenseAttriInfoNode.path("CarLicenseRect");
|
||||
entity.setCarLicenseRectLeft(carLicenseRectNode.path("Left").asInt());
|
||||
entity.setCarLicenseRectRight(carLicenseRectNode.path("Right").asInt());
|
||||
entity.setCarLicenseRectTop(carLicenseRectNode.path("Top").asInt());
|
||||
entity.setCarLicenseRectBottom(carLicenseRectNode.path("Bottom").asInt());
|
||||
|
||||
// Car Attribute Info
|
||||
JsonNode carAttriInfoNode = infoNode.path("carAttriInfo");
|
||||
entity.setDriveEntryDrection(carAttriInfoNode.path("DriveEntryDrection").asInt());
|
||||
|
||||
entity.setDriveEntryDrectionName(
|
||||
translateDriveEntryDrection(carAttriInfoNode.path("DriveEntryDrection").asInt()));
|
||||
|
||||
entity.setMatch(carAttriInfoNode.path("Match").asInt());
|
||||
entity.setScore(carAttriInfoNode.path("Score").asInt());
|
||||
|
||||
JsonNode carRectNode = carAttriInfoNode.path("CarRect");
|
||||
entity.setCarRectLeft(carRectNode.path("Left").asInt());
|
||||
entity.setCarRectRight(carRectNode.path("Right").asInt());
|
||||
entity.setCarRectTop(carRectNode.path("Top").asInt());
|
||||
entity.setCarRectBottom(carRectNode.path("Bottom").asInt());
|
||||
|
||||
// Capture Image Info
|
||||
JsonNode captureImageNode = infoNode.path("CaptureImage");
|
||||
entity.setCaptureImageWidth(captureImageNode.path("width").asInt());
|
||||
entity.setCaptureImageHeight(captureImageNode.path("height").asInt());
|
||||
entity.setCaptureImagePictureLength(captureImageNode.path("pictureLength").asInt());
|
||||
entity.setCaptureImagePictureMd5(captureImageNode.path("pictureMd5").asText());
|
||||
|
||||
// Background Image Info
|
||||
JsonNode backgroundImageNode = infoNode.path("BackgroundImage");
|
||||
entity.setBackgroundImageWidth(backgroundImageNode.path("width").asInt());
|
||||
entity.setBackgroundImageHeight(backgroundImageNode.path("height").asInt());
|
||||
entity.setBackgroundImagePictureLength(backgroundImageNode.path("pictureLength").asInt());
|
||||
entity.setBackgroundImagePictureMd5(backgroundImageNode.path("pictureMd5").asText());
|
||||
|
||||
String captureBase64 =
|
||||
StringUtils.defaultIfBlank(captureImageNode.path("picture").asText(), "")
|
||||
.replace("data:image/jpg;base64,", "");
|
||||
|
||||
if (StringUtils.isNotEmpty(captureBase64)) {
|
||||
|
||||
FileDto captureDto =
|
||||
fileService.upload(
|
||||
new ByteArrayInputStream(Base64.decode(captureBase64)),
|
||||
entity.getNumber()
|
||||
+ "_"
|
||||
+ entity.getInfoTimeObj()
|
||||
.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
|
||||
+ "_"
|
||||
+ "plate",
|
||||
"car_license_snapshot");
|
||||
|
||||
entity.setCaptureImage(em.getReference(FileEntity.class, captureDto.getId()));
|
||||
}
|
||||
|
||||
// save backgroud image
|
||||
String backgroundBase64 =
|
||||
StringUtils.defaultIfBlank(backgroundImageNode.path("picture").asText(), "")
|
||||
.replace("data:image/jpg;base64,", "");
|
||||
|
||||
if (StringUtils.isNotEmpty(backgroundBase64)) {
|
||||
|
||||
FileDto backgroundDto =
|
||||
fileService.upload(
|
||||
new ByteArrayInputStream(Base64.decode(backgroundBase64)),
|
||||
entity.getNumber()
|
||||
+ "_"
|
||||
+ entity.getInfoTimeObj()
|
||||
.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
|
||||
+ "_"
|
||||
+ "bg",
|
||||
"car_license_snapshot");
|
||||
|
||||
entity.setBackgroundImage(em.getReference(FileEntity.class, backgroundDto.getId()));
|
||||
}
|
||||
|
||||
// Save entity to repository
|
||||
this.repository.save(entity);
|
||||
|
||||
// return {
|
||||
// "operator": "CarLicenseSnapshot-Ack",
|
||||
// "info": {
|
||||
// "eventID": 1
|
||||
// },
|
||||
// "result": {
|
||||
// "errorNo": 0,
|
||||
// "description": "ok"
|
||||
// }
|
||||
// }
|
||||
|
||||
// Acknowledge
|
||||
|
||||
ObjectNode objectNode = getAck(entity.getInfoEventId());
|
||||
|
||||
return objectNode;
|
||||
}
|
||||
|
||||
private @NotNull ObjectNode getAck(int infoEventId) {
|
||||
ObjectNode objectNode = objectMapper.createObjectNode();
|
||||
|
||||
objectNode.put("operator", "CarLicenseSnapshot-Ack");
|
||||
|
||||
ObjectNode infoNodeAck = objectMapper.createObjectNode();
|
||||
|
||||
infoNodeAck.put("eventID", infoEventId);
|
||||
|
||||
objectNode.set("info", infoNodeAck);
|
||||
|
||||
ObjectNode resultNode = objectMapper.createObjectNode();
|
||||
|
||||
resultNode.put("errorNo", 0);
|
||||
resultNode.put("description", "ok");
|
||||
|
||||
objectNode.set("result", resultNode);
|
||||
return objectNode;
|
||||
}
|
||||
|
||||
private String translateCarAttriColor(int carAttriColor) {
|
||||
// 车辆颜色;0-起始无效值,1-黑色,2-白色,3-银灰,4-深灰,5-棕色,6-红色,7-橙色,8-黄色,9-绿色,10-青色,11-蓝色,12-粉色,13-紫色,14-香槟色
|
||||
|
||||
switch (carAttriColor) {
|
||||
case 0:
|
||||
return "起始无效值";
|
||||
case 1:
|
||||
return "黑色";
|
||||
case 2:
|
||||
return "白色";
|
||||
case 3:
|
||||
return "银灰";
|
||||
case 4:
|
||||
return "深灰";
|
||||
case 5:
|
||||
return "棕色";
|
||||
case 6:
|
||||
return "红色";
|
||||
case 7:
|
||||
return "橙色";
|
||||
case 8:
|
||||
return "黄色";
|
||||
case 9:
|
||||
return "绿色";
|
||||
case 10:
|
||||
return "青色";
|
||||
case 11:
|
||||
return "蓝色";
|
||||
case 12:
|
||||
return "粉色";
|
||||
case 13:
|
||||
return "紫色";
|
||||
case 14:
|
||||
return "香槟色";
|
||||
default:
|
||||
return "无效";
|
||||
}
|
||||
}
|
||||
|
||||
private String translateAttriOrientation(int attriOrientation) {
|
||||
// 车辆方向(0-下行(车头面对摄像头);1-上行(车尾面对摄像头);其他值无效)
|
||||
|
||||
switch (attriOrientation) {
|
||||
case 0:
|
||||
return "下行(车头面对摄像头)";
|
||||
case 1:
|
||||
return "上行(车尾面对摄像头)";
|
||||
default:
|
||||
return "无效";
|
||||
}
|
||||
}
|
||||
|
||||
private String translateCarLicenseAttriColor(int carLicenseAttriColor) {
|
||||
// 车牌颜色;0-起始无效值,1-蓝牌,2-黄牌,3-黑牌,4-白牌,5-绿牌,6-渐变绿,7-黄绿,8-缺省
|
||||
|
||||
switch (carLicenseAttriColor) {
|
||||
case 0:
|
||||
return "起始无效值";
|
||||
case 1:
|
||||
return "蓝牌";
|
||||
case 2:
|
||||
return "黄牌";
|
||||
case 3:
|
||||
return "黑牌";
|
||||
case 4:
|
||||
return "白牌";
|
||||
case 5:
|
||||
return "绿牌";
|
||||
case 6:
|
||||
return "渐变绿";
|
||||
case 7:
|
||||
return "黄绿";
|
||||
case 8:
|
||||
return "缺省";
|
||||
default:
|
||||
return "无效";
|
||||
}
|
||||
}
|
||||
|
||||
private String translateCarLicenseRowNum(int carLicenseRowNum) {
|
||||
// 车牌单双排(1-单排;2-双排;其他值无效)
|
||||
|
||||
switch (carLicenseRowNum) {
|
||||
case 1:
|
||||
return "单排";
|
||||
case 2:
|
||||
return "双排";
|
||||
default:
|
||||
return "无效";
|
||||
}
|
||||
}
|
||||
|
||||
private String translateDriveEntryDrection(int driveEntryDrection) {
|
||||
|
||||
// 驶入方向(0-下行驶入;1-上行驶入;其他值无效)
|
||||
|
||||
switch (driveEntryDrection) {
|
||||
case 0:
|
||||
return "下行驶入";
|
||||
case 1:
|
||||
return "上行驶入";
|
||||
default:
|
||||
return "无效";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.smartCamSupplier.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.OrgScope;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.CreateSmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.SmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.UpdateSmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.service.SmartCamSupplierService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/smartCamSupplier")
|
||||
@SysLog(module = "智能摄像头厂家")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class SmartCamSupplierController {
|
||||
@Autowired private SmartCamSupplierService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public SmartCamSupplierDto create(@RequestBody CreateSmartCamSupplierDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public SmartCamSupplierDto update(@RequestBody UpdateSmartCamSupplierDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public SmartCamSupplierDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<SmartCamSupplierDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.smartCamSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateSmartCamSupplierDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.smartCamSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SmartCamSupplierDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.smartCamSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateSmartCamSupplierDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.lihongjie.coal.smartCamSupplier.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_smartCamSupplier_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class SmartCamSupplierEntity extends OrgCommonEntity {}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.smartCamSupplier.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.CreateSmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.SmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.UpdateSmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.entity.SmartCamSupplierEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface SmartCamSupplierMapper
|
||||
extends BaseMapper<
|
||||
SmartCamSupplierEntity,
|
||||
SmartCamSupplierDto,
|
||||
CreateSmartCamSupplierDto,
|
||||
UpdateSmartCamSupplierDto> {}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.lihongjie.coal.smartCamSupplier.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.smartCamSupplier.entity.SmartCamSupplierEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface SmartCamSupplierRepository extends BaseRepository<SmartCamSupplierEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.lihongjie.coal.smartCamSupplier.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.CreateSmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.SmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.dto.UpdateSmartCamSupplierDto;
|
||||
import cn.lihongjie.coal.smartCamSupplier.entity.SmartCamSupplierEntity;
|
||||
import cn.lihongjie.coal.smartCamSupplier.mapper.SmartCamSupplierMapper;
|
||||
import cn.lihongjie.coal.smartCamSupplier.repository.SmartCamSupplierRepository;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class SmartCamSupplierService
|
||||
extends BaseService<SmartCamSupplierEntity, SmartCamSupplierRepository> {
|
||||
@Autowired private SmartCamSupplierRepository repository;
|
||||
|
||||
@Autowired private SmartCamSupplierMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public SmartCamSupplierDto create(CreateSmartCamSupplierDto request) {
|
||||
SmartCamSupplierEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public SmartCamSupplierDto update(UpdateSmartCamSupplierDto request) {
|
||||
SmartCamSupplierEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public SmartCamSupplierDto getById(String id) {
|
||||
SmartCamSupplierEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<SmartCamSupplierDto> list(CommonQuery query) {
|
||||
Page<SmartCamSupplierEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.controller.SmartCamCarLicenseSnapshotDataController
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(SmartCamCarLicenseSnapshotDataController.class)
|
||||
def objectMapper = ioc.getBean(ObjectMapper.class) as ObjectMapper
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(params!=null ? objectMapper.convertValue(params, CommonQuery.class ) : new CommonQuery())
|
||||
|
||||
|
||||
19
src/main/resources/scripts/dict/enum/smartCamDict.groovy
Normal file
19
src/main/resources/scripts/dict/enum/smartCamDict.groovy
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.smartCam.controller.SmartCamController
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(SmartCamController.class)
|
||||
def objectMapper = ioc.getBean(ObjectMapper.class) as ObjectMapper
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(params!=null ? objectMapper.convertValue(params, CommonQuery.class ) : new CommonQuery())
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.smartCamSupplier.controller.SmartCamSupplierController
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(SmartCamSupplierController.class)
|
||||
def objectMapper = ioc.getBean(ObjectMapper.class) as ObjectMapper
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(params!=null ? objectMapper.convertValue(params, CommonQuery.class ) : new CommonQuery())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user