[1078] 完善立即拍摄的结果查询和下载
This commit is contained in:
@@ -2,7 +2,11 @@ package com.genersoft.iot.vmp.jt1078.bean;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Schema(description = "多媒体检索项数据")
|
||||
public class JTMediaDataInfo {
|
||||
|
||||
@@ -31,46 +35,6 @@ public class JTMediaDataInfo {
|
||||
return jtMediaEventInfo;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getEventCode() {
|
||||
return eventCode;
|
||||
}
|
||||
|
||||
public void setEventCode(int eventCode) {
|
||||
this.eventCode = eventCode;
|
||||
}
|
||||
|
||||
public int getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public void setChannelId(int channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public JTPositionBaseInfo getPositionBaseInfo() {
|
||||
return positionBaseInfo;
|
||||
}
|
||||
|
||||
public void setPositionBaseInfo(JTPositionBaseInfo positionBaseInfo) {
|
||||
this.positionBaseInfo = positionBaseInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTMediaDataInfo{" +
|
||||
|
||||
@@ -5,7 +5,11 @@ import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Schema(description = "存储多媒体数据")
|
||||
public class JTQueryMediaDataCommand {
|
||||
|
||||
@@ -49,54 +53,6 @@ public class JTQueryMediaDataCommand {
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getChanelId() {
|
||||
return chanelId;
|
||||
}
|
||||
|
||||
public void setChanelId(int chanelId) {
|
||||
this.chanelId = chanelId;
|
||||
}
|
||||
|
||||
public int getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setEvent(int event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Integer getDelete() {
|
||||
return delete;
|
||||
}
|
||||
|
||||
public void setDelete(Integer delete) {
|
||||
this.delete = delete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTQueryMediaDataCommand{" +
|
||||
|
||||
@@ -4,8 +4,11 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "拍摄命令参数")
|
||||
public class JTShootingCommand {
|
||||
|
||||
|
||||
@@ -419,7 +419,7 @@ public class JT1078Controller {
|
||||
|
||||
@Operation(summary = "JT-查询终端参数", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "phoneNumber", description = "设备手机号", required = true)
|
||||
@GetMapping("/config")
|
||||
@GetMapping("/config/get")
|
||||
public JTDeviceConfig config(String phoneNumber, String[] params){
|
||||
|
||||
log.info("[JT-查询终端参数] phoneNumber:{}", phoneNumber);
|
||||
@@ -429,7 +429,7 @@ public class JT1078Controller {
|
||||
@Operation(summary = "JT-设置终端参数", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "phoneNumber", description = "设备编号", required = true)
|
||||
@Parameter(name = "config", description = "终端参数", required = true)
|
||||
@PostMapping("/set-config")
|
||||
@PostMapping("/config/set")
|
||||
public void setConfig(@RequestBody SetConfigParam config){
|
||||
|
||||
log.info("[JT-设置终端参数] 参数: {}", config.toString());
|
||||
@@ -898,7 +898,7 @@ public class JT1078Controller {
|
||||
@Operation(summary = "JT-单条存储多媒体数据上传", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "phoneNumber", description = "设备编号", required = true)
|
||||
@Parameter(name = "mediaId", description = "多媒体ID", required = true)
|
||||
@GetMapping("/media/upload/one")
|
||||
@GetMapping("/media/upload/one/upload")
|
||||
public void uploadOneMedia(HttpServletResponse response, String phoneNumber, Long mediaId){
|
||||
|
||||
log.info("[JT-单条存储多媒体数据上传] 设备编号: {}, 多媒体ID: {}", phoneNumber, mediaId );
|
||||
@@ -906,7 +906,24 @@ public class JT1078Controller {
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
service.uploadOneMedia(phoneNumber, mediaId, outputStream);
|
||||
service.uploadOneMedia(phoneNumber, mediaId, outputStream, false);
|
||||
}catch (Exception e) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "JT-单条存储多媒体数据删除", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "phoneNumber", description = "设备编号", required = true)
|
||||
@Parameter(name = "mediaId", description = "多媒体ID", required = true)
|
||||
@GetMapping("/media/upload/one/delete")
|
||||
public void deleteOneMedia(HttpServletResponse response, String phoneNumber, Long mediaId){
|
||||
|
||||
log.info("[JT-单条存储多媒体数据上传] 设备编号: {}, 多媒体ID: {}", phoneNumber, mediaId );
|
||||
Assert.notNull(mediaId, "缺少通道编号");
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
service.uploadOneMedia(phoneNumber, mediaId, outputStream, true);
|
||||
}catch (Exception e) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
@@ -3,7 +3,11 @@ package com.genersoft.iot.vmp.jt1078.controller.bean;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTQueryMediaDataCommand;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTShootingCommand;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Schema(description = "存储多媒体数据参数")
|
||||
public class QueryMediaDataParam {
|
||||
|
||||
@@ -19,38 +23,6 @@ public class QueryMediaDataParam {
|
||||
@Schema(description = "存储多媒体数据参数")
|
||||
private JTQueryMediaDataCommand queryMediaDataCommand;
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public JTQueryMediaDataCommand getQueryMediaDataCommand() {
|
||||
return queryMediaDataCommand;
|
||||
}
|
||||
|
||||
public void setQueryMediaDataCommand(JTQueryMediaDataCommand queryMediaDataCommand) {
|
||||
this.queryMediaDataCommand = queryMediaDataCommand;
|
||||
}
|
||||
|
||||
public int getDelete() {
|
||||
return delete;
|
||||
}
|
||||
|
||||
public void setDelete(int delete) {
|
||||
this.delete = delete;
|
||||
}
|
||||
|
||||
public Long getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(Long mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "QueryMediaDataParam{" +
|
||||
|
||||
@@ -2,6 +2,11 @@ package com.genersoft.iot.vmp.jt1078.controller.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTShootingCommand;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Schema(description = "摄像头立即拍摄命令参数")
|
||||
public class ShootingParam {
|
||||
|
||||
@@ -11,22 +16,6 @@ public class ShootingParam {
|
||||
@Schema(description = "拍摄命令参数")
|
||||
private JTShootingCommand shootingCommand;
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public JTShootingCommand getShootingCommand() {
|
||||
return shootingCommand;
|
||||
}
|
||||
|
||||
public void setShootingCommand(JTShootingCommand shootingCommand) {
|
||||
this.shootingCommand = shootingCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ShootingParam{" +
|
||||
|
||||
@@ -33,20 +33,20 @@ public class J0801 extends Re {
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
JTMediaEventInfo mediaEventInfo = JTMediaEventInfo.decode(buf);
|
||||
log.info("[JT-多媒体数据上传]: {}", mediaEventInfo);
|
||||
// try {
|
||||
// if (mediaEventInfo.getMediaData() != null) {
|
||||
// File file = new File("/home/lin/source.jpg");
|
||||
// if (file.exists()) {
|
||||
// file.delete();
|
||||
// }
|
||||
// FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
// fileOutputStream.write(mediaEventInfo.getMediaData());
|
||||
// fileOutputStream.flush();
|
||||
// fileOutputStream.close();
|
||||
// }
|
||||
// }catch (Exception e) {
|
||||
// log.error("[JT-多媒体数据上传] 写入文件异常", e);
|
||||
// }
|
||||
try {
|
||||
if (mediaEventInfo.getMediaData() != null) {
|
||||
File file = new File("/home/lin/source.jpg");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
fileOutputStream.write(mediaEventInfo.getMediaData());
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error("[JT-多媒体数据上传] 写入文件异常", e);
|
||||
}
|
||||
SessionManager.INSTANCE.response(header.getPhoneNumber(), "0801", null, mediaEventInfo);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public interface Ijt1078Service {
|
||||
|
||||
void snap(String phoneNumber, int channelId, ServletOutputStream outputStream);
|
||||
|
||||
void uploadOneMedia(String phoneNumber, Long mediaId, ServletOutputStream outputStream);
|
||||
void uploadOneMedia(String phoneNumber, Long mediaId, ServletOutputStream outputStream, boolean delete);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -807,11 +807,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadOneMedia(String phoneNumber, Long mediaId, ServletOutputStream outputStream) {
|
||||
public void uploadOneMedia(String phoneNumber, Long mediaId, ServletOutputStream outputStream, boolean delete) {
|
||||
log.info("[JT-单条存储多媒体数据上传] 媒体编号: {}, 设备编号: {}", mediaId, phoneNumber);
|
||||
J8805 j8805 = new J8805();
|
||||
j8805.setMediaId(mediaId);
|
||||
j8805.setDelete(1);
|
||||
j8805.setDelete(delete ? 1 : 0);
|
||||
log.info("[JT-单条存储多媒体数据上传] 请求上传,媒体编号: {}, 设备编号: {}", mediaId, phoneNumber);
|
||||
JTMediaEventInfo mediaEventInfo = (JTMediaEventInfo)jt1078Template.uploadMediaDataForSingle(phoneNumber, j8805, 600);
|
||||
if (mediaEventInfo == null) {
|
||||
|
||||
@@ -215,7 +215,7 @@ export function stopPlayback(params) {
|
||||
export function queryConfig(phoneNumber) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/jt1078/config',
|
||||
url: '/api/jt1078/config/get',
|
||||
params: {
|
||||
phoneNumber: phoneNumber
|
||||
}
|
||||
@@ -224,7 +224,7 @@ export function queryConfig(phoneNumber) {
|
||||
export function setConfig(data) {
|
||||
return request({
|
||||
method: 'post',
|
||||
url: '/api/jt1078/set-config',
|
||||
url: '/api/jt1078/config/set',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="showDialog"
|
||||
:destroy-on-close="true"
|
||||
:append-to-body="true"
|
||||
@close="close()"
|
||||
>
|
||||
<div id="shared" style="height: 45rem; overflow: auto">
|
||||
|
||||
@@ -200,7 +200,6 @@ export default {
|
||||
search: function() {
|
||||
this.mediaDataInfoList = []
|
||||
this.queryLoading = true
|
||||
console.log(this.timeRange)
|
||||
this.$store.dispatch('jtDevice/queryMediaData', {
|
||||
phoneNumber: this.phoneNumber,
|
||||
queryMediaDataCommand: {
|
||||
@@ -226,10 +225,10 @@ export default {
|
||||
this.$refs.position.openDialog(row.positionBaseInfo)
|
||||
},
|
||||
download: function(row) {
|
||||
this.$message.success('已申请截图,完成后自动下载', { closed: true })
|
||||
this.$message.success('下载请求已发送', { closed: true })
|
||||
// 文件下载地址
|
||||
const baseUrl = window.baseUrl ? window.baseUrl : ''
|
||||
const fileUrl = ((process.env.NODE_ENV === 'development') ? process.env.VUE_APP_BASE_API : baseUrl) + `/api/jt1078/media/upload/one?phoneNumber=${this.phoneNumber}&mediaId=${row.id}`
|
||||
const fileUrl = ((process.env.NODE_ENV === 'development') ? process.env.VUE_APP_BASE_API : baseUrl) + `/api/jt1078/media/upload/one/upload?phoneNumber=${this.phoneNumber}&mediaId=${row.id}`
|
||||
let controller = new AbortController()
|
||||
let signal = controller.signal
|
||||
// 设置请求头
|
||||
@@ -247,7 +246,19 @@ export default {
|
||||
// 创建一个虚拟的链接元素,模拟点击下载
|
||||
const link = document.createElement('a')
|
||||
link.href = window.URL.createObjectURL(blob)
|
||||
link.download = `${this.device.phoneNumber}-${row.channelId}-${dayjs().format('YYYYMMDDHHmmss')}.jpg` // 设置下载文件名,替换filename.ext为实际的文件名和扩展名
|
||||
let suffix = 'jpg'
|
||||
switch (row.type){
|
||||
case 0:
|
||||
suffix = 'jpg'
|
||||
break
|
||||
case 1:
|
||||
suffix = 'mp3'
|
||||
break
|
||||
case 2:
|
||||
suffix = 'mp4'
|
||||
break
|
||||
}
|
||||
link.download = `${row.id}.${suffix}` // 设置下载文件名,替换filename.ext为实际的文件名和扩展名
|
||||
document.body.appendChild(link)
|
||||
// 模拟点击
|
||||
link.click()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<el-dialog
|
||||
v-el-drag-dialog
|
||||
title="立即拍摄"
|
||||
width="60%"
|
||||
width="65%"
|
||||
top="2rem"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="showDialog"
|
||||
@@ -73,8 +73,14 @@
|
||||
<el-checkbox v-model="showImageConfig">高级配置</el-checkbox>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-left: 2rem; text-align: right" >
|
||||
<el-button type="primary" :loading="queryLoading" icon="el-icon-search" @click="shooting()" >
|
||||
执行
|
||||
<el-button v-if="!commandType" type="danger" icon="el-icon-video-camera" @click="stopRecord()" >
|
||||
停止录像
|
||||
</el-button>
|
||||
<el-button v-if="!commandType" type="primary" icon="el-icon-video-camera" @click="shooting()" >
|
||||
开始录像
|
||||
</el-button>
|
||||
<el-button v-if="commandType" type="primary" icon="el-icon-camera" @click="shooting()" >
|
||||
拍照
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -186,6 +192,29 @@ export default {
|
||||
message: '消息已经下发'
|
||||
})
|
||||
})
|
||||
},
|
||||
stopRecord: function() {
|
||||
this.$store.dispatch('jtDevice/shooting', {
|
||||
phoneNumber: this.phoneNumber,
|
||||
shootingCommand: {
|
||||
chanelId: this.chanelId,
|
||||
command: 0,
|
||||
time: 0,
|
||||
save: 1,
|
||||
resolvingPower: 0xff,
|
||||
quality: 0,
|
||||
brightness: 0,
|
||||
contrastRatio: 0,
|
||||
saturation: 0,
|
||||
chroma: 0
|
||||
}
|
||||
})
|
||||
.then( data => {
|
||||
this.$message.success({
|
||||
showClose: true,
|
||||
message: '消息已经下发'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user