| | |
| | | |
| | | 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日 |
| | | */ |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |