| | |
| | | import com.iailab.framework.web.core.util.WebFrameworkUtils; |
| | | import com.iailab.module.data.mq.consumer.ImageMessage; |
| | | import com.iailab.module.data.video.controller.admin.camera.vo.CameraPageReqVO; |
| | | import com.iailab.module.data.video.dahua.DHSavePath; |
| | | import com.iailab.module.data.video.config.VideoConfiguration; |
| | | import com.iailab.module.data.video.dao.CameraDao; |
| | | import com.iailab.module.data.video.dao.ImageDao; |
| | | import com.iailab.module.data.video.dto.CameraDTO; |
| | |
| | | import com.iailab.module.data.video.service.CameraService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | */ |
| | | @Service |
| | | public class CameraServiceImpl extends BaseServiceImpl<CameraDao, CameraEntity> implements CameraService { |
| | | |
| | | @Value("${video.capture-dir}") |
| | | public String captureDir; |
| | | |
| | | @Resource |
| | | private CameraDao cameraDao; |
| | |
| | | public void dealCapture(Map<String, String> params) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | Date captureDate = calendar.getTime(); |
| | | CameraDTO devCamera = getByCode(params.get("cmdSerial")); |
| | | String strFileName = params.get("strFileName"); |
| | | String brand = params.get("brand"); |
| | | String capturePath = ""; |
| | | String routingKey = ""; |
| | | switch (brand) { |
| | | case "DH": |
| | | capturePath = VideoConfiguration.staticDhCapturePath; |
| | | routingKey = ImageMessage.DAHUA_ROUTING_KEY; |
| | | break; |
| | | case "HK": |
| | | capturePath = VideoConfiguration.staticHkCapturePath; |
| | | routingKey = ImageMessage.HIKVISION_ROUTING_KEY; |
| | | break; |
| | | } |
| | | String imagePath = strFileName.replace("\\", "/"); |
| | | String imageUrl = imagePath.replace(DHSavePath.capturePath, ""); |
| | | String imageUrl = imagePath.replace(capturePath, ""); |
| | | ImageEntity image = new ImageEntity(); |
| | | image.setCameraId(devCamera.getId()); |
| | | image.setImagePath(imagePath); |
| | | image.setImageUrl("/Capture/" + imageUrl); |
| | | image.setImageUrl(capturePath.replace(captureDir, "") + imageUrl); |
| | | image.setCreateDate(captureDate); |
| | | imageDao.insert(image); |
| | | //存入rabbitmq消息队列,等待模型处理 |
| | | String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | ImageMessage imageMessage = new ImageMessage(); |
| | | imageMessage.setMessageId(image.getId()); |
| | | imageMessage.setCreateTime(createTime); |
| | | imageMessage.setImageDTO(BeanUtils.toBean(image, ImageDTO.class)); |
| | | rabbitTemplate.convertAndSend(ImageMessage.EXCHANGE, ImageMessage.ROUTING_KEY, imageMessage); |
| | | // rabbitTemplate.convertAndSend("topic.image", imageMap); |
| | | sendRabbitMQMessage(image, routingKey); |
| | | } |
| | | |
| | | @Override |
| | | public void setStatus(String id, Integer status) { |
| | | CameraEntity cameraEntity = new CameraEntity(); |
| | | cameraEntity.setId(id); |
| | | cameraEntity.setStatus(status); |
| | | baseDao.updateById(cameraEntity); |
| | | } |
| | | |
| | | private QueryWrapper<CameraEntity> getWrapper(CameraPageReqVO cameraPageReqVO){ |
| | |
| | | |
| | | @Override |
| | | @DSTransactional(rollbackFor = Exception.class) |
| | | public void delete(String[] ids) { |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | public void delete(String id) { |
| | | baseDao.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return baseDao.selectCount(queryWrapper); |
| | | } |
| | | |
| | | // 发送rabbitMQ消息 |
| | | private void sendRabbitMQMessage(ImageEntity image, String routingKey) { |
| | | String createTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | ImageMessage imageMessage = new ImageMessage(); |
| | | imageMessage.setMessageId(image.getId()); |
| | | imageMessage.setCreateTime(createTime); |
| | | imageMessage.setImageDTO(BeanUtils.toBean(image, ImageDTO.class)); |
| | | rabbitTemplate.convertAndSend(ImageMessage.EXCHANGE, routingKey, imageMessage); |
| | | } |
| | | |
| | | } |