9 files modified
1 files added
| | |
| | | */ |
| | | <T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data); |
| | | |
| | | <T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid,Long timestamp); |
| | | |
| | | ServiceReply publishServicesTopic(String sn, String method, Object data, String bid,Long timestamp); |
| | | |
| | | /** |
| | | * Used exclusively for sending messages for services, and does not set the received subtype. |
| | | * @param sn |
| | |
| | | |
| | | /** |
| | | * @author sean.zhou |
| | | * @date 2021/11/16 |
| | | * @version 0.1 |
| | | * @date 2021/11/16 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | |
| | | public void publish(String topic, CommonTopicResponse response) { |
| | | this.publish(topic, 1, response); |
| | | } |
| | | |
| | | public void sendRabbitMQ(String topic, Object data) { |
| | | try { |
| | | if (sendRabbitMQ) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public <T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid, Long timestamp) { |
| | | String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + sn + TopicConst.SERVICES_SUF; |
| | | ServiceReply reply = this.publishWithReply(ServiceReply.class, topic, |
| | | CommonTopicResponse.builder() |
| | | .tid(UUID.randomUUID().toString()) |
| | | .bid(StringUtils.hasText(bid) ? bid : UUID.randomUUID().toString()) |
| | | .timestamp(timestamp) |
| | | .method(method) |
| | | .data(Objects.requireNonNullElse(data, "")) |
| | | .build()); |
| | | if (Objects.isNull(clazz)) { |
| | | return reply; |
| | | } |
| | | // put together in "output" |
| | | if (Objects.nonNull(reply.getInfo())) { |
| | | reply.setOutput(mapper.convertValue(reply.getInfo(), clazz)); |
| | | } |
| | | if (Objects.nonNull(reply.getOutput())) { |
| | | reply.setOutput(mapper.convertValue(reply.getOutput(), clazz)); |
| | | } |
| | | return reply; |
| | | } |
| | | |
| | | @Override |
| | | public ServiceReply publishServicesTopic(String sn, String method, Object data, String bid, Long timestamp) { |
| | | return this.publishServicesTopic(null, sn, method, data, bid, timestamp); |
| | | } |
| | | |
| | | @Override |
| | | public ServiceReply publishServicesTopic(String sn, String method, Object data, String bid) { |
| | | return this.publishServicesTopic(null, sn, method, data, bid); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public <T> ServiceReply<T> publishRequestsTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid) { |
| | | public <T> ServiceReply<T> publishRequestsTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid) { |
| | | String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + sn + TopicConst.REQUESTS_SUF; |
| | | ServiceReply reply = this.publishWithReply(ServiceReply.class, topic, |
| | | CommonTopicResponse.builder() |
| | |
| | | |
| | | public static final String OSD_PREFIX = "osd" + DELIMITER; |
| | | |
| | | public static final String COMMANDS_PREFIX = "commands" + DELIMITER; |
| | | |
| | | public static final String MEDIA_FILE_PREFIX = "media_file" + DELIMITER; |
| | | |
| | | public static final String MEDIA_HIGHEST_PRIORITY_PREFIX = "media_highest_priority" + DELIMITER; |
| | |
| | | ResponseResult result = ResponseResult.success(); |
| | | result.setTraceid(bid); |
| | | |
| | | ServiceReply serviceReply = messageSenderService.publishServicesTopic(param.getSn(), param.getCmd().getCmd(), param.getData(),bid); |
| | | Long timestamp = System.currentTimeMillis(); |
| | | |
| | | //拍照事件存redis |
| | | RedisOpsUtils.hashSet(RedisConst.COMMANDS_PREFIX + param.getSn() + RedisConst.DELIMITER + bid,bid,timestamp); |
| | | |
| | | ServiceReply serviceReply = messageSenderService.publishServicesTopic(param.getSn(), param.getCmd().getCmd(), param.getData(),bid,timestamp); |
| | | return ResponseResult.CODE_SUCCESS != serviceReply.getResult() ? |
| | | ResponseResult.error(serviceReply.getResult(), "错误码:" + serviceReply.getResult()) |
| | | : result; |
| New file |
| | |
| | | package com.dji.sample.droneairport.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.dji.sample.common.model.ResponseResult; |
| | | import com.dji.sample.component.redis.RedisConst; |
| | | import com.dji.sample.component.redis.RedisOpsUtils; |
| | | import com.dji.sample.media.model.MediaFileEntity; |
| | | import com.dji.sample.media.service.IMediaService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @RequestMapping("/droneAirport/mediaApi") |
| | | @RestController |
| | | public class MediaApiController { |
| | | |
| | | @Autowired |
| | | private IMediaService mediaService; |
| | | |
| | | @GetMapping("{sn}/getMedia/{traceid}") |
| | | public ResponseResult getMedia(@PathVariable String sn, @PathVariable String traceid) { |
| | | |
| | | String timestamp = (Long)RedisOpsUtils.hashGet(RedisConst.COMMANDS_PREFIX + sn + RedisConst.DELIMITER + traceid,traceid) / 1000 * 1000 + ""; |
| | | MediaFileEntity entity = mediaService.getMediaFieByTid(timestamp); |
| | | String url = "https://wrj.shuixiongit.com/minio/cloud-bucket" + entity.getObjectKey(); |
| | | Map ret = new HashMap(); |
| | | ret.put("url", url); |
| | | ret.put("metadata", JSONObject.parseObject(entity.getMetadata().toString())); |
| | | return ResponseResult.success(ret); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | @Mapper |
| | | public interface IFileMapper extends BaseMapper<MediaFileEntity> { |
| | | Page<MediaFileEntity> getPage(@Param("page") Page<MediaFileEntity> mediaFileEntityPage, @Param("workspaceId") String workspaceId,@Param("query") MediaFileQueryParam mediaFileQueryParam); |
| | | |
| | | Page<MediaFileEntity> getPage(@Param("page") Page<MediaFileEntity> mediaFileEntityPage, @Param("workspaceId") String workspaceId, @Param("query") MediaFileQueryParam mediaFileQueryParam); |
| | | |
| | | Page<MediaJobDTO> mediaPage(@Param("page") Page<MediaJobDTO> mediaFileEntityPage, @Param("workspaceId") String workspaceId, @Param("param") SearchMediaParam param); |
| | | |
| | | |
| | | Page<MediaJobDTO> mediaDetail(Page<MediaJobDTO> mediaJobDTOPage, @Param("jobId") String jobId, @Param("fileAddress") String fileAddress); |
| | | |
| | | MediaFileEntity getMediaFieByTid(@Param("timestamp") String timestamp); |
| | | |
| | | } |
| | |
| | | </if> |
| | | ORDER BY type = '视频' DESC |
| | | </select> |
| | | |
| | | <select id="getMediaFieByTid" resultType="com.dji.sample.media.model.MediaFileEntity"> |
| | | SELECT * |
| | | FROM media_file |
| | | WHERE CAST(JSON_EXTRACT(metadata, '$.createdTime') AS UNSIGNED) >= #{timestamp} |
| | | ORDER BY CAST(JSON_EXTRACT(metadata, '$.createdTime') / 1000 AS UNSIGNED) ASC |
| | | LIMIT 1; |
| | | </select> |
| | | </mapper> |
| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | |
| | | private String userId; |
| | | |
| | | @TableField(value = "metadata", typeHandler = FastjsonTypeHandler.class) |
| | | @JsonFormat |
| | | private Object metadata; |
| | | |
| | | @TableField("examine") |
| | |
| | | |
| | | import com.dji.sample.common.model.PaginationData; |
| | | import com.dji.sample.media.model.FileUploadDTO; |
| | | import com.dji.sample.media.model.MediaFileEntity; |
| | | import com.dji.sample.media.model.MediaJobDTO; |
| | | import com.dji.sample.media.model.param.SearchMediaParam; |
| | | import com.dji.sample.wayline.model.dto.WaylineJobDTO; |
| | | import com.drew.imaging.ImageProcessingException; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.awt.*; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | |
| | | PaginationData<MediaJobDTO> mediaPage(String workspaceId, SearchMediaParam param); |
| | | |
| | | PaginationData<MediaJobDTO> mediaDetail(String jobId, Long page, Long pageSize); |
| | | |
| | | MediaFileEntity getMediaFieByTid(String timestamp); |
| | | } |
| | |
| | | |
| | | return receiver; |
| | | } |
| | | |
| | | @Override |
| | | public MediaFileEntity getMediaFieByTid(String timestamp) { |
| | | return mapper.getMediaFieByTid(timestamp); |
| | | } |
| | | } |