长庆项目day3

This commit is contained in:
ovo 2024-10-19 20:44:33 +08:00
parent e6aa88d552
commit 6a7d0bb746
15 changed files with 252 additions and 184 deletions

View File

@ -245,6 +245,15 @@
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>3.1.0</version> <!-- 检查最新版本 -->
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.arcsoft.face</groupId>-->
<!-- <artifactId>arcsoft-sdk-face</artifactId>-->

View File

@ -8,6 +8,6 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
public class PeronType {
private int labelId;
private int type;
private String name;
}

View File

@ -65,16 +65,6 @@ public class CqMemberController {
// 创建分页对象
Page<TenPersonEntity> pageRequest = new Page<>(page, size);
/* QueryWrapper<TenPersonEntity> queryWrapper = new QueryWrapper<>();
// 假设你想按名字进行筛选name 为数据库中的字段名
if (!unitName.isEmpty()){
queryWrapper.eq("cell_name", unitName);
}
queryWrapper.orderByDesc("upload_time");*/
// 使用 MyBatis-Plus 提供的分页查询
IPage<TenPersonEntity> pageResult = cqMemberMapper.selectPage(pageRequest, null);
@ -380,7 +370,7 @@ public class CqMemberController {
}else{
tenPersonEntity.setGender(2);
}
tenPersonEntity.setIc(visitorDto.getIdCard());
tenPersonEntity.setIdCard(visitorDto.getIdCard());
tenPersonEntity.setMobile(visitorDto.getPhone());
tenPersonEntity.setOrgImageTemp(visitorDto.getFacePhotoUrl());
tenPersonEntity.setIsProtectDevice(visitorDto.getIsProtectDevice());

View File

@ -1,26 +1,22 @@
package net.shapelight.modules.iCq.controller.video;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.R;
import net.shapelight.modules.face.rtsp.RtspFrameGrabber;
import net.shapelight.modules.iCq.controller.video.dto.UpdateVideoDto;
import net.shapelight.modules.iCq.controller.video.dto.UploadVideoDto;
import net.shapelight.modules.iCq.controller.video.vo.Unit;
import net.shapelight.modules.iCq.dal.dataobject.video.TenSafeVideoEntity;
import net.shapelight.modules.iCq.dal.mysql.video.CqFileMapper;
import net.shapelight.modules.iCq.dal.mysql.video.CqSafeVideoMapper;
import net.shapelight.modules.iCq.service.video.CqSafeVideoServiceImpl;
import net.shapelight.modules.ten.dao.TenCellDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Date;
import java.util.List;
/**
@ -32,115 +28,82 @@ import java.util.List;
@RequiredArgsConstructor
public class CqSafeVideoController {
private static String BUCKET_NAME = "cqyt";
private final MinioConfig minioConfig;
private final CqSafeVideoServiceImpl cqSafeVideoService;
private final CqSafeVideoMapper cqSafeVideoMapper;
private final CqFileMapper cqFileMapper;
private final TenCellDao cqCellMapper;
@Autowired
private RtspFrameGrabber rtspFrameGrabber;
@GetMapping("/getTopUnits")
@GetMapping("/getCells")
@ApiOperation(value = "获取单位列表")
public R getTopUnits() {
List<Unit> queryUnit = cqSafeVideoMapper.queryUnit();
return R.ok().put("data", queryUnit);
public R getCells() {
return R.ok()
.put("data", cqSafeVideoService.getCellInfos())
.put("total", cqSafeVideoService.getCellInfos().size());
}
@PostMapping("/insert")
@ApiOperation(value = "新增视频接口")
public R insert(@RequestBody UploadVideoDto uploadVideoDto) throws IOException {
TenSafeVideoEntity tenSafeVideoEntity = new TenSafeVideoEntity();
tenSafeVideoEntity.setName(cqFileMapper.selectByFileId(uploadVideoDto.getFileId()).getFileName());
/* tenSafeVideoEntity.setCellId(cqSafeVideoMapper.runTheNameById(uploadVideoDto.getUnitName()));
tenSafeVideoEntity.setCellName(uploadVideoDto.getUnitName());*/
tenSafeVideoEntity.setCellId(uploadVideoDto.getUnitId());
tenSafeVideoEntity.setCellName(cqSafeVideoMapper.findTheNameById(uploadVideoDto.getUnitId()));
tenSafeVideoEntity.setUploadId(uploadVideoDto.getUploaderId());
tenSafeVideoEntity.setUploadName(uploadVideoDto.getUploader());
tenSafeVideoEntity.setUploadTime(new Date());
tenSafeVideoEntity.setUrl(cqFileMapper.selectByFileId(uploadVideoDto.getFileId()).getFileUrl());
tenSafeVideoEntity.setPlayCount(0);
tenSafeVideoEntity.setFileId(uploadVideoDto.getFileId());
if (cqSafeVideoMapper.insert(tenSafeVideoEntity) == 1) {
if (cqSafeVideoService.insert(uploadVideoDto) == 1) {
return R.ok();
} else {
return R.error();
}
}
@GetMapping("/list")
@ApiOperation(value = "列表视频接口")
public R list(@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
String unitId) {
// 创建分页对象
Page<TenSafeVideoEntity> pageRequest = new Page<>(page, size);
QueryWrapper<TenSafeVideoEntity> queryWrapper = new QueryWrapper<>();
// 假设你想按名字进行筛选name 为数据库中的字段名
if (unitId != null && !unitId.isEmpty()){
queryWrapper.eq("cell_id", unitId);
}
queryWrapper.orderByDesc("upload_time");
// 使用 MyBatis-Plus 提供的分页查询
IPage<TenSafeVideoEntity> pageResult = cqSafeVideoMapper.selectPage(pageRequest, queryWrapper);
List<TenSafeVideoEntity> list = pageResult.getRecords();
/* for (TenSafeVideoEntity tenSafeVideoEntity : list) {
tenSafeVideoEntity.setCellName(cqSafeVideoMapper.findsTheParentId(tenSafeVideoEntity.getCellId()) + "/" +
tenSafeVideoEntity.getCellName());
}*/
return R.ok().put("data", list).put("total", pageResult.getTotal());
String cellId) {
List<TenSafeVideoEntity> list = cqSafeVideoService.list(page, size, cellId);
return R.ok()
.put("data", list)
.put("total", list.size());
}
@DeleteMapping("/delete/{id}")
@ApiOperation(value = "删除视频接口")
public R delete(@PathVariable Long id) {
if (cqSafeVideoMapper.deleteById(id) == 1) {
if (cqSafeVideoService.delete(id)) {
return R.ok();
} else {
}else {
return R.error();
}
}
//修改
@PostMapping("/update")
@PutMapping("/update")
@ApiOperation(value = "更新视频接口")
public R update(@RequestBody UpdateVideoDto updateVideoDto) {
TenSafeVideoEntity tenSafeVideoEntity = new TenSafeVideoEntity();
tenSafeVideoEntity.setName(cqFileMapper.selectByFileId(updateVideoDto.getFileId()).getFileName());
tenSafeVideoEntity.setId(updateVideoDto.getVideoId());
/* tenSafeVideoEntity.setCellId(cqSafeVideoMapper.runTheNameById(updateVideoDto.getUnitName()));
tenSafeVideoEntity.setCellName(updateVideoDto.getUnitName());*/
tenSafeVideoEntity.setCellId(updateVideoDto.getUnitId());
tenSafeVideoEntity.setCellName(cqSafeVideoMapper.findTheNameById(updateVideoDto.getUnitId()));
tenSafeVideoEntity.setUploadTime(new Date());
tenSafeVideoEntity.setUrl(cqFileMapper.selectByFileId(updateVideoDto.getFileId()).getFileUrl());
tenSafeVideoEntity.setFileId(updateVideoDto.getFileId());
if (cqSafeVideoMapper.updateById(tenSafeVideoEntity) == 1) {
if (cqSafeVideoService.update(updateVideoDto) == 1) {
return R.ok();
} else {
return R.error();
}
}
@GetMapping("/inquireVideo")
@ApiOperation(value = "条件查询视频接口")
public R inquireVideo(@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size,
String unitId, String videoName, String uploader){
System.out.println("uploader + 上传人 = " + uploader);
List<TenSafeVideoEntity> list = cqSafeVideoMapper.relatedQuery(unitId, videoName, uploader);
return R.ok().put("data", list);
@RequestParam(required = false) String cellId,
@RequestParam(required = false) String videoName,
@RequestParam(required = false) String uploadName){
List<TenSafeVideoEntity> tenSafeVideoEntities =
cqSafeVideoService.inquireVideo(cellId, videoName, uploadName);
return R.ok()
.put("data", tenSafeVideoEntities)
.put("total",tenSafeVideoEntities.size());
}
@GetMapping("/singleFind")
public R singleFind(int videoId){
TenSafeVideoEntity tenSafeVideoEntity = cqSafeVideoMapper.selectById(videoId);
@ -154,7 +117,6 @@ public class CqSafeVideoController {
return R.ok();
}
@PostMapping("/face/recognition")
public R aWatchStart(@RequestParam("image") MultipartFile image, @RequestParam String cellId) {
rtspFrameGrabber.recognition(image,cellId);

View File

@ -4,7 +4,16 @@ import lombok.Data;
@Data
public class UpdateVideoDto {
/**
* 文件id
*/
private String fileId;
/**
* 视频id
*/
private Long videoId;
private String unitId;
/**
* 单位id
*/
private Long cellId;
}

View File

@ -1,13 +1,29 @@
package net.shapelight.modules.iCq.controller.video.dto;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class UploadVideoDto {
/**
* 文件id
*/
private String fileId;
private String uploader;
private Long uploaderId;
private String unitId;
/**
* 上传人姓名
*/
private String uploadName;
/**
* 上传人id
*/
private Long uploadId;
/**
* 单位id
*/
private Long cellId;
}

View File

@ -0,0 +1,26 @@
package net.shapelight.modules.iCq.controller.video.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class VideoQueryDto {
/**
* 单位id
*/
private String cellId;
/**
* 视频名称
*/
private String videoName;
/**
* 上传人姓名
*/
private String uploadName;
}

View File

@ -1,14 +1,22 @@
package net.shapelight.modules.iCq.controller.video.vo;
//前端查询部门返回Vo
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
//单位返回Vo
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Unit {
private String orgId;
@Accessors(chain = true)
public class CellVo {
/**
* 部门Id
*/
private Long cellId;
/**
* 部门名称
*/
private String name;
}

View File

@ -1,5 +1,7 @@
package net.shapelight.modules.iCq.dal.dataobject.video;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
@ -15,9 +17,24 @@ import java.util.Date;
@TableName("ten_file")
public class FileEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 文件id
*/
@TableId
private String fileId;
private String fileName;
private String fileUrl;
/**
* 文件名称
*/
@TableField("file_name")
private String name;
/**
* 文件url
*/
@TableField("file_url")
private String url;
/**
* 文件上传时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date uploadTime;
}

View File

@ -30,7 +30,7 @@ public class TenSafeVideoEntity implements Serializable {
/**
* 单位ID
*/
private String cellId;
private Long cellId;
/**
* 单位名称

View File

@ -2,41 +2,14 @@ package net.shapelight.modules.iCq.dal.mysql.video;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.shapelight.modules.iCq.controller.video.vo.Unit;
import net.shapelight.modules.iCq.dal.dataobject.video.TenSafeVideoEntity;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface CqSafeVideoMapper extends BaseMapper<TenSafeVideoEntity> {
/**
* 查询 单位 信息(名称 id)
* @return
*/
List<Unit> queryUnit();
/**
* 根据单位id查询单位名称
* @param unitName 单位名称
* @return
*/
Long runTheNameById(String unitName);
//目前没用 明天测试 待删除
String findsTheParentId(Long id);
//目前没用 明天测试 待删除
List<Long> queryHighestLevelUnit();
//目前没用 明天测试 待删除
List<String> queryChildUnit(String name);
List<TenSafeVideoEntity> relatedQuery(String unitId, String videoName, String uploader);
String findTheNameById(String unitId);
String findTheNameById(long cellId);
}

View File

@ -1,4 +1,5 @@
package net.shapelight.modules.iCq.service.video;
public interface CqSafeVideoService {
//接口声明
}

View File

@ -0,0 +1,108 @@
package net.shapelight.modules.iCq.service.video;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import net.shapelight.common.utils.R;
import net.shapelight.modules.iCq.controller.video.dto.UpdateVideoDto;
import net.shapelight.modules.iCq.controller.video.dto.UploadVideoDto;
import net.shapelight.modules.iCq.controller.video.dto.VideoQueryDto;
import net.shapelight.modules.iCq.controller.video.vo.CellVo;
import net.shapelight.modules.iCq.dal.dataobject.video.FileEntity;
import net.shapelight.modules.iCq.dal.dataobject.video.TenSafeVideoEntity;
import net.shapelight.modules.iCq.dal.mysql.video.CqFileMapper;
import net.shapelight.modules.iCq.dal.mysql.video.CqSafeVideoMapper;
import net.shapelight.modules.ten.dao.TenCellDao;
import net.shapelight.modules.ten.entity.TenCellEntity;
import org.modelmapper.ModelMapper;
import org.modelmapper.TypeMap;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class CqSafeVideoServiceImpl {
private final TenCellDao cqCellMapper;
private final CqFileMapper cqFileMapper;
private final CqSafeVideoMapper cqSafeVideoMapper;
/**
* 获取部门信息
* @return
*/
public List<CellVo> getCellInfos() {
return cqCellMapper.selectList(new QueryWrapper<>()).stream()
.map(cell -> {
CellVo cellVo = new CellVo();
BeanUtils.copyProperties(cell, cellVo);
return cellVo;
})
.collect(Collectors.toList());
}
public int insert(UploadVideoDto uploadVideoDto) {
TenSafeVideoEntity tenSafeVideoEntity = new TenSafeVideoEntity();
BeanUtils.copyProperties(uploadVideoDto, tenSafeVideoEntity);
BeanUtils.copyProperties(cqFileMapper.selectById(uploadVideoDto.getFileId()), tenSafeVideoEntity);
tenSafeVideoEntity.setCellName(cqCellMapper.selectOne(new QueryWrapper<TenCellEntity>()
.select("name")
.eq("cell_id", uploadVideoDto.getCellId())).getName());
tenSafeVideoEntity.setPlayCount(0);
return cqSafeVideoMapper.insert(tenSafeVideoEntity);
}
public List<TenSafeVideoEntity> list(int page, int size, String cellId) {
Page<TenSafeVideoEntity> pageRequest = new Page<>(page, size);
QueryWrapper<TenSafeVideoEntity> queryWrapper = new QueryWrapper<>();
if (cellId != null && !cellId.isEmpty()){
queryWrapper.eq("cell_id", cellId);
}
queryWrapper.orderByDesc("upload_time");
IPage<TenSafeVideoEntity> pageResult = cqSafeVideoMapper.selectPage(pageRequest, queryWrapper);
return pageResult.getRecords();
}
public boolean delete(Long id) {
return (cqSafeVideoMapper.deleteById(id) == 1);
}
public int update(UpdateVideoDto updateVideoDto) {
TenSafeVideoEntity tenSafeVideoEntity = new TenSafeVideoEntity();
FileEntity fileEntity = cqFileMapper.selectById(updateVideoDto.getFileId());
BeanUtils.copyProperties(fileEntity, tenSafeVideoEntity);
tenSafeVideoEntity.setId(updateVideoDto.getVideoId());
tenSafeVideoEntity.setCellId(updateVideoDto.getCellId());
tenSafeVideoEntity.setCellName(cqCellMapper.selectById(updateVideoDto.getCellId()).getName());
tenSafeVideoEntity.setUploadTime(new Date());
return cqSafeVideoMapper.updateById(tenSafeVideoEntity);
}
public List<TenSafeVideoEntity> inquireVideo(String cellId, String videoName, String uploadName) {
VideoQueryDto queryDto = new VideoQueryDto();
queryDto.setCellId(cellId)
.setVideoName(videoName)
.setUploadName(uploadName);
QueryWrapper<TenSafeVideoEntity> queryWrapper = new QueryWrapper<>();
if (queryDto.getCellId() != null && !queryDto.getCellId().isEmpty()) {
queryWrapper.eq("cell_id", queryDto.getCellId());
}
if (queryDto.getVideoName() != null && !queryDto.getVideoName().isEmpty()) {
queryWrapper.like("name", queryDto.getVideoName());
}
if (queryDto.getUploadName() != null && !queryDto.getUploadName().isEmpty()) {
queryWrapper.eq("upload_name", queryDto.getUploadName());
}
queryWrapper.orderByDesc("upload_time");
return cqSafeVideoMapper.selectList(queryWrapper);
}
}

View File

@ -262,6 +262,9 @@ public class TenPersonController extends AbstractController {
params.put("cellId", scope.getCellId().toString());
}
params.put("personType", Constant.PERSON_TYPE_GUEST);
PageUtils page = tenPersonService.queryPage(params);
// Date now = new Date();
// for (TenPersonEntity guest : (List<TenPersonEntity>)page.getList()) {

View File

@ -3,64 +3,10 @@
<mapper namespace="net.shapelight.modules.iCq.dal.mysql.video.CqSafeVideoMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="net.shapelight.modules.changqing.entity.TenSafeVideoEntity" id="tenSafeVideoMap">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="cellId" column="cell_id"/>
<result property="cellName" column="cell_name"/>
<result property="uploadId" column="upload_id"/>
<result property="uploadName" column="upload_name"/>
<result property="uploadTime" column="upload_time"/>
<result property="url" column="url"/>
<result property="playTime" column="play_time"/>
<result property="playCount" column="play_count"/>
</resultMap>
<select id="queryHighestLevelUnit" resultType="java.lang.Long">
SELECT cell_id from ten_cell WHERE delete_flag = 0
</select>
<select id="queryUnit" resultType="net.shapelight.modules.iCq.controller.video.vo.Unit">
SELECT org_id, name
FROM ten_cell
WHERE delete_flag = 0
</select>
<select id="queryChildUnit" resultType="java.lang.String">
SELECT name FROM ten_cell_dept WHERE
parent_id = (SELECT dept_id FROM ten_cell_dept WHERE name = #{name})
and delete_flag = 0
</select>
<select id="runTheNameById" resultType="java.lang.Long">
SELECT dept_id FROM ten_cell_dept WHERE name = #{name} and delete_flag = 0
</select>
<select id="findsTheParentId" resultType="java.lang.String">
SELECT name
FROM ten_cell_dept d1
WHERE EXISTS (
SELECT 1
FROM ten_cell_dept d2
WHERE d2.dept_id = #{id} AND d2.parent_id = d1.dept_id
) AND d1.delete_flag = 0;
</select>
<select id="relatedQuery" resultType="net.shapelight.modules.iCq.dal.dataobject.video.TenSafeVideoEntity">
SELECT *
FROM ten_safe_video
WHERE 1 = 1
<if test="unitId != null and unitId != ''">
AND cell_id = #{unitId}
</if>
<if test="videoName != null and videoName != ''">
AND name LIKE CONCAT('%', #{videoName}, '%')
</if>
<if test="uploader != null and uploader != ''">
AND upload_name = #{uploader}
</if>
ORDER BY upload_time DESC
</select>
<select id="findTheNameById" resultType="java.lang.String">
SELECT name FROM ten_cell WHERE org_id = #{unitId} and delete_flag = 0
SELECT name FROM ten_cell WHERE cell_id = #{cellId} and delete_flag = 0
</select>
</mapper>