Commit 8a933c23 by xmh

运维服务:

1. <feat> 可以一次上传多个录像文件
1 parent c8aa9e36
...@@ -8,13 +8,13 @@ package com.viontech.fanxing.commons.constant; ...@@ -8,13 +8,13 @@ package com.viontech.fanxing.commons.constant;
*/ */
public enum TaskStatus { public enum TaskStatus {
/** 未部署 */
AWAIT(0),
/** 运行中 */ /** 运行中 */
RUNNING(1), RUNNING(1),
/** 暂停 */ /** 暂停 */
PAUSE(2), PAUSE(2),
/** 等待执行 */ /** 无法运行 */
AWAIT(0),
/** 资源不足 */
CAN_NOT_RUN(4); CAN_NOT_RUN(4);
public int val; public int val;
......
...@@ -8,7 +8,6 @@ import java.util.List; ...@@ -8,7 +8,6 @@ import java.util.List;
public class ChannelVo extends ChannelVoBase { public class ChannelVo extends ChannelVoBase {
private MultipartFile file;
private Boolean tree; private Boolean tree;
public ChannelVo() { public ChannelVo() {
...@@ -27,13 +26,4 @@ public class ChannelVo extends ChannelVoBase { ...@@ -27,13 +26,4 @@ public class ChannelVo extends ChannelVoBase {
this.tree = tree; this.tree = tree;
return this; return this;
} }
public MultipartFile getFile() {
return file;
}
public ChannelVo setFile(MultipartFile file) {
this.file = file;
return this;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -15,6 +15,7 @@ import com.viontech.fanxing.ops.service.adapter.ChannelTagService; ...@@ -15,6 +15,7 @@ import com.viontech.fanxing.ops.service.adapter.ChannelTagService;
import com.viontech.keliu.util.JsonMessageUtil; import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
...@@ -87,8 +88,8 @@ public class ChannelController extends ChannelBaseController { ...@@ -87,8 +88,8 @@ public class ChannelController extends ChannelBaseController {
} }
@PostMapping("/video/upload") @PostMapping("/video/upload")
public Object uploadVideo(ChannelVo channelVo) { public Object uploadVideo(@RequestParam List<MultipartFile> files, @RequestParam(required = false) List<Long> tags) {
Channel channel = channelService.uploadVideo(channelVo); channelService.uploadVideo(files, tags);
return JsonMessageUtil.getSuccessJsonMsg(channel); return JsonMessageUtil.getSuccessJsonMsg("success");
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,7 @@ import com.viontech.fanxing.commons.base.BaseService; ...@@ -5,6 +5,7 @@ import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.Channel; import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.vo.ChannelVo; import com.viontech.fanxing.commons.vo.ChannelVo;
import com.viontech.fanxing.commons.vo.DictCodeVo; import com.viontech.fanxing.commons.vo.DictCodeVo;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
...@@ -14,6 +15,6 @@ public interface ChannelService extends BaseService<Channel> { ...@@ -14,6 +15,6 @@ public interface ChannelService extends BaseService<Channel> {
List<DictCodeVo> channelOrg(List<Channel> channels); List<DictCodeVo> channelOrg(List<Channel> channels);
Channel uploadVideo(ChannelVo channelVo); void uploadVideo(List<MultipartFile> files, List<Long> tags);
} }
\ No newline at end of file \ No newline at end of file
...@@ -182,8 +182,8 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -182,8 +182,8 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Channel uploadVideo(ChannelVo channelVo) { public void uploadVideo(List<MultipartFile> files, List<Long> tags) {
MultipartFile file = channelVo.getFile(); for (MultipartFile file : files) {
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
String basePath = vionConfig.getImage().getPath() + File.separator + "uploadVideo" + File.separator; String basePath = vionConfig.getImage().getPath() + File.separator + "uploadVideo" + File.separator;
String extension = FilenameUtils.getExtension(originalFilename); String extension = FilenameUtils.getExtension(originalFilename);
...@@ -202,20 +202,17 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -202,20 +202,17 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
long videoLength = video.length(); long videoLength = video.length();
long mbSize = videoLength / 1024 / 1024; long mbSize = videoLength / 1024 / 1024;
List<Long> tags = channelVo.getTags(); Channel channel = new Channel();
channelVo.setUnid(unid); channel.setUnid(unid);
channelVo.setChannelUnid(unid); channel.setChannelUnid(unid);
channelVo.setDeviceUnid(unid); channel.setDeviceUnid(unid);
channelVo.setName(originalFilename); channel.setName(originalFilename);
channelVo.setStreamPath(video.getPath()); channel.setStreamPath(video.getPath());
channelVo.setType(ChannelType.FILE.value); channel.setType(ChannelType.FILE.value);
channelVo.setStreamType(ChannelType.STREAM_FILE.value); channel.setStreamType(ChannelType.STREAM_FILE.value);
channelVo.setPort(Math.toIntExact(mbSize)); channel.setPort(Math.toIntExact(mbSize));
Channel channel = this.insertSelective(channelVo); channel = this.insertSelective(channel);
channel = selectByPrimaryKey(channel.getId());
channelVo = new ChannelVo(channel);
channelVo.setTags(tags);
if (tags != null && tags.size() > 0) { if (tags != null && tags.size() > 0) {
for (Long tagId : tags) { for (Long tagId : tags) {
ChannelTag channelTag = new ChannelTag(); ChannelTag channelTag = new ChannelTag();
...@@ -224,6 +221,6 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -224,6 +221,6 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
channelTagService.insertSelective(channelTag); channelTagService.insertSelective(channelTag);
} }
} }
return channelVo; }
} }
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!