From 08b6a55a3a111aaee9842999b85afa60b6d61dc3 Mon Sep 17 00:00:00 2001 From: houzhongjian <houzhongyi@126.com> Date: 星期四, 14 十一月 2024 15:29:38 +0800 Subject: [PATCH] 大华及海康摄像头截图功能开发 --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/impl/ImageServiceImpl.java | 108 +++++++++++++----------------------------------------- 1 files changed, 26 insertions(+), 82 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/impl/ImageServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/impl/ImageServiceImpl.java index 2d6c2d8..a095674 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/impl/ImageServiceImpl.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/video/service/impl/ImageServiceImpl.java @@ -2,26 +2,26 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.constant.Constant; -import com.iailab.framework.common.page.PageData; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.data.video.controller.admin.camera.vo.ImagePageReqVO; import com.iailab.module.data.video.dao.ImageDao; import com.iailab.module.data.video.dto.ImageDTO; -import com.iailab.module.data.video.entity.DataEntity; import com.iailab.module.data.video.entity.ImageEntity; +import com.iailab.module.data.video.entity.DataEntity; import com.iailab.module.data.video.service.ImageService; import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import javax.validation.Valid; import java.util.*; /** - * @author PanZhibao + * @author Houzhongjian * @Description * @createTime 2024年02月27日 */ @@ -29,12 +29,17 @@ public class ImageServiceImpl extends BaseServiceImpl<ImageDao, ImageEntity> implements ImageService { @Override - public PageData<ImageDTO> page(Map<String, Object> params) { - IPage<ImageEntity> page = baseDao.selectPage( - getPage(params, Constant.CREATE_DATE, false), - getWrapper(params) - ); - return getPageData(page, ImageDTO.class); + public PageResult<ImageDTO> getPage(ImagePageReqVO imagePageReqVO) { + PageResult<ImageEntity> pageResult = baseDao.selectPage(imagePageReqVO); + return BeanUtils.toBean(pageResult, ImageDTO.class); + } + + @Override + public List<ImageDTO> list(@Valid ImagePageReqVO imagePageReqVO) { + QueryWrapper<ImageEntity> queryWrapper = getWrapper(imagePageReqVO); + queryWrapper.orderByDesc(Constant.CREATE_DATE); + List<ImageEntity> list = baseDao.selectList(queryWrapper); + return ConvertUtils.sourceToTarget(list, ImageDTO.class); } @Override @@ -44,79 +49,11 @@ return ConvertUtils.sourceToTarget(entity, ImageDTO.class); } - private QueryWrapper<ImageEntity> getWrapper(Map<String, Object> params){ - String cameraId = (String)params.get("cameraId"); - String startTime = (String)params.get("startTime"); - String endTime = (String)params.get("endTime"); - - QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(cameraId), "camera_id", cameraId) - .ge(StringUtils.isNotBlank(startTime), "create_date", startTime) - .le(StringUtils.isNotBlank(endTime), "create_date", endTime); - - return wrapper; - } - - @Override - public List<DataEntity> getValueList(String cameraId, Date startTime, Date endTime) { - QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); - wrapper.eq( "camera_id", cameraId) - .ge( "create_date", startTime) - .le( "create_date", endTime) - .orderByAsc("create_date"); - List<DataEntity> result = new ArrayList<>(); - List<ImageEntity> list = baseDao.selectList(wrapper); - if (CollectionUtils.isEmpty(list)) { - return result; - } - list.forEach(item -> { - DataEntity dataEntity = new DataEntity(); - dataEntity.setDataValue(item.getImagePath()); - dataEntity.setTimeStamp(item.getCreateDate()); - result.add(dataEntity); - }); - return result; - } - - @Override - public String getUrl(String cameraId, String imagePath) { - String result = ""; - QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); - wrapper.eq( "camera_id", cameraId) - .eq( "image_path", imagePath) - .orderByDesc("create_date"); - List<ImageEntity> devImageEntities = baseDao.selectList(wrapper); - ImageEntity entity = new ImageEntity(); - if (ObjectUtils.isNotEmpty(devImageEntities)) { - entity = devImageEntities.get(0); - } - if (entity != null) { - return entity.getImageUrl(); - } - return result; - } - - @Override - public void save(ImageDTO dto) { - ImageEntity entity = ConvertUtils.sourceToTarget(dto, ImageEntity.class); - - //保存菜单 - insert(entity); - } - - @Override - public void update(ImageDTO dto) { - ImageEntity entity = ConvertUtils.sourceToTarget(dto, ImageEntity.class); - - //更新菜单 - updateById(entity); - } - @Override @DSTransactional(rollbackFor = Exception.class) - public void delete(String[] ids) { + public void delete(String id) { //删除菜单 - baseDao.deleteBatchIds(Arrays.asList(ids)); + baseDao.deleteById(id); } @Override @@ -132,4 +69,11 @@ return ConvertUtils.sourceToTarget(entity, ImageDTO.class); } + private QueryWrapper<ImageEntity> getWrapper(ImagePageReqVO imagePageReqVO){ + String cameraId = imagePageReqVO.getCameraId(); + QueryWrapper<ImageEntity> wrapper = new QueryWrapper<>(); + wrapper.eq( "camera_id", cameraId); + return wrapper; + } + } \ No newline at end of file -- Gitblit v1.9.3