mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-07-25 15:17:06 +08:00
feat(smartCamWhiteList): 新增智能摄像头白名单功能
- 添加 SmartCamWhiteList 相关的控制器、DTO、实体类、映射器、仓库和服务 - 在比较逻辑中增加白名单过滤,忽略白名单中的车牌号- 新增白名单数据字典脚本
This commit is contained in:
@@ -15,6 +15,8 @@ import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.HumanModifyRequest;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.dto.SmartCamCarLicenseSnapshotDataDto;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.entity.SmartCamCarLicenseSnapshotDataEntity;
|
||||
import cn.lihongjie.coal.smartCamCarLicenseSnapshotData.service.SmartCamCarLicenseSnapshotDataService;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.repository.SmartCamWhiteListRepository;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.service.SmartCamWhiteListService;
|
||||
import cn.lihongjie.coal.weightDeviceData.entity.WeightDeviceDataEntity;
|
||||
import cn.lihongjie.coal.weightDeviceData.repository.WeightDeviceDataRepository;
|
||||
|
||||
@@ -39,6 +41,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -56,6 +60,10 @@ public class SmartCamCarDataService
|
||||
@Autowired WeightDeviceDataRepository weightDeviceDataRepository;
|
||||
|
||||
@Autowired SmartCamCarLicenseSnapshotDataService smartCamCarLicenseSnapshotDataService;
|
||||
@Autowired
|
||||
SmartCamWhiteListRepository smartCamWhiteListRepository;
|
||||
@Autowired
|
||||
private SmartCamWhiteListService smartCamWhiteListService;
|
||||
|
||||
public CompareResult compare(CompareRequest request) {
|
||||
|
||||
@@ -99,10 +107,18 @@ public class SmartCamCarDataService
|
||||
}
|
||||
});
|
||||
|
||||
Set<String> whiteList = smartCamWhiteListRepository.searchAllByOrganizationId(Ctx.activeOrganizationId()).stream()
|
||||
.map(x -> x.getCarNumber())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Map<String, CompareResult.CarInfo> carInfoMap = new HashMap<>();
|
||||
|
||||
for (SmartCamCarDataEntity camDatum : camData) {
|
||||
|
||||
if (whiteList.contains(camDatum.getNumber())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (carInfoMap.containsKey(camDatum.getNumber())) {
|
||||
CompareResult.CarInfo carInfo = carInfoMap.get(camDatum.getNumber());
|
||||
|
||||
@@ -127,6 +143,10 @@ public class SmartCamCarDataService
|
||||
|
||||
for (WeightDeviceDataEntity weightDatum : weightData) {
|
||||
|
||||
if (whiteList.contains(weightDatum.getPlateNo())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (carInfoMap.containsKey(weightDatum.getPlateNo())) {
|
||||
|
||||
CompareResult.CarInfo carInfo = carInfoMap.get(weightDatum.getPlateNo());
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.smartCamWhiteList.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.smartCamWhiteList.dto.CreateSmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.dto.SmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.dto.UpdateSmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.service.SmartCamWhiteListService;
|
||||
|
||||
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("/smartCamWhiteList")
|
||||
@SysLog(module = "")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class SmartCamWhiteListController {
|
||||
@Autowired private SmartCamWhiteListService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public SmartCamWhiteListDto create(@RequestBody CreateSmartCamWhiteListDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public SmartCamWhiteListDto update(@RequestBody UpdateSmartCamWhiteListDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public SmartCamWhiteListDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<SmartCamWhiteListDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.lihongjie.coal.smartCamWhiteList.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateSmartCamWhiteListDto extends OrgCommonDto {
|
||||
|
||||
private String carNumber;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.lihongjie.coal.smartCamWhiteList.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SmartCamWhiteListDto extends OrgCommonDto {
|
||||
|
||||
private String carNumber;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.lihongjie.coal.smartCamWhiteList.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateSmartCamWhiteListDto extends OrgCommonDto {
|
||||
private String carNumber;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.lihongjie.coal.smartCamWhiteList.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_smartCamWhiteList_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class SmartCamWhiteListEntity extends OrgCommonEntity {
|
||||
|
||||
private String carNumber;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.smartCamWhiteList.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.smartCamWhiteList.dto.CreateSmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.dto.SmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.dto.UpdateSmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.entity.SmartCamWhiteListEntity;
|
||||
|
||||
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 SmartCamWhiteListMapper
|
||||
extends BaseMapper<
|
||||
SmartCamWhiteListEntity,
|
||||
SmartCamWhiteListDto,
|
||||
CreateSmartCamWhiteListDto,
|
||||
UpdateSmartCamWhiteListDto> {}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.lihongjie.coal.smartCamWhiteList.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.entity.SmartCamWhiteListEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface SmartCamWhiteListRepository extends BaseRepository<SmartCamWhiteListEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
|
||||
long countByCarNumberAndOrganizationId(String carNumber, String organizationId);
|
||||
|
||||
List<SmartCamWhiteListEntity> searchAllByOrganizationId(String s);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package cn.lihongjie.coal.smartCamWhiteList.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.smartCamWhiteList.dto.CreateSmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.dto.SmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.dto.UpdateSmartCamWhiteListDto;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.entity.SmartCamWhiteListEntity;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.mapper.SmartCamWhiteListMapper;
|
||||
import cn.lihongjie.coal.smartCamWhiteList.repository.SmartCamWhiteListRepository;
|
||||
|
||||
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 SmartCamWhiteListService
|
||||
extends BaseService<SmartCamWhiteListEntity, SmartCamWhiteListRepository> {
|
||||
@Autowired private SmartCamWhiteListRepository repository;
|
||||
|
||||
@Autowired private SmartCamWhiteListMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public SmartCamWhiteListDto create(CreateSmartCamWhiteListDto request) {
|
||||
SmartCamWhiteListEntity entity = mapper.toEntity(request);
|
||||
|
||||
long cnt = this.repository.countByCarNumberAndOrganizationId(
|
||||
request.getCarNumber(), request.getOrganizationId());
|
||||
|
||||
if (cnt > 0) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public SmartCamWhiteListDto update(UpdateSmartCamWhiteListDto request) {
|
||||
SmartCamWhiteListEntity 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 SmartCamWhiteListDto getById(String id) {
|
||||
SmartCamWhiteListEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<SmartCamWhiteListDto> list(CommonQuery query) {
|
||||
Page<SmartCamWhiteListEntity> 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.smartCamWhiteList.controller.SmartCamWhiteListController
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(SmartCamWhiteListController.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