|
@@ -3,19 +3,25 @@ package com.taais.biz.service.impl;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
import java.nio.file.Paths;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.mybatisflex.core.paginate.Page;
|
|
import com.mybatisflex.core.paginate.Page;
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
|
+import com.taais.biz.constant.BizConstant;
|
|
|
|
+import com.taais.biz.domain.*;
|
|
import com.taais.biz.domain.ToInfrared;
|
|
import com.taais.biz.domain.ToInfrared;
|
|
-import com.taais.biz.domain.Video2image;
|
|
|
|
import com.taais.biz.domain.bo.ToInfraredBo;
|
|
import com.taais.biz.domain.bo.ToInfraredBo;
|
|
|
|
+import com.taais.biz.domain.bo.ToInfraredStartResultBo;
|
|
|
|
+import com.taais.biz.domain.bo.VideoStableStartResultBo;
|
|
import com.taais.biz.domain.vo.ToInfraredVo;
|
|
import com.taais.biz.domain.vo.ToInfraredVo;
|
|
import com.taais.biz.mapper.ToInfraredMapper;
|
|
import com.taais.biz.mapper.ToInfraredMapper;
|
|
import com.taais.biz.service.IToInfraredService;
|
|
import com.taais.biz.service.IToInfraredService;
|
|
|
|
+import com.taais.biz.utils.ZipUtils;
|
|
import com.taais.common.core.config.TaaisConfig;
|
|
import com.taais.common.core.config.TaaisConfig;
|
|
import com.taais.common.core.constant.Constants;
|
|
import com.taais.common.core.constant.Constants;
|
|
|
|
+import com.taais.common.core.core.domain.CommonResult;
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
import com.taais.common.core.utils.StringUtils;
|
|
import com.taais.common.core.utils.StringUtils;
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
@@ -25,12 +31,13 @@ import com.taais.system.domain.vo.SysOssVo;
|
|
import com.taais.system.service.ISysOssService;
|
|
import com.taais.system.service.ISysOssService;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
|
|
import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
|
|
import static com.taais.biz.domain.table.ToInfraredTableDef.TO_INFRARED;
|
|
import static com.taais.biz.domain.table.ToInfraredTableDef.TO_INFRARED;
|
|
-import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtension;
|
|
|
|
|
|
+import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 可见光转红外Service业务层处理
|
|
* 可见光转红外Service业务层处理
|
|
@@ -40,6 +47,12 @@ import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtens
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToInfrared> implements IToInfraredService {
|
|
public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToInfrared> implements IToInfraredService {
|
|
|
|
+ @Value("${server.to_infrared_start_url}")
|
|
|
|
+ private String to_infrared_start_url;
|
|
|
|
+
|
|
|
|
+ @Value("${server.to_infrared_stop_url}")
|
|
|
|
+ private String to_infrared_stop_url;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private ISysOssService ossService;
|
|
private ISysOssService ossService;
|
|
|
|
|
|
@@ -188,4 +201,72 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
|
|
return this.removeByIds(Arrays.asList(ids));
|
|
return this.removeByIds(Arrays.asList(ids));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public CommonResult start(Long id) {
|
|
|
|
+ ToInfrared toInfrared = getById(id);
|
|
|
|
+
|
|
|
|
+ SysOssVo inputOssEntity = ossService.getById(toInfrared.getInputOssId());
|
|
|
|
+
|
|
|
|
+ String filePath = inputOssEntity.getFileName();
|
|
|
|
+ String localPath = TaaisConfig.getProfile();
|
|
|
|
+ String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
|
|
|
|
+
|
|
|
|
+ String fileName = StringUtils.substringAfterLast(filePath, "/");
|
|
|
|
+ String fileName_without_suffix = removeFileExtension(fileName);
|
|
|
|
+
|
|
|
|
+ Path path = Paths.get(resourcePath);
|
|
|
|
+ Path inputPath = path.resolveSibling(fileName_without_suffix + "_images");
|
|
|
|
+ Path outputPath = path.resolveSibling(fileName_without_suffix + "_stable");
|
|
|
|
+
|
|
|
|
+ makeDir(inputPath.toString());
|
|
|
|
+ makeDir(outputPath.toString());
|
|
|
|
+
|
|
|
|
+ ZipUtils.unzip(resourcePath, inputPath.toString());
|
|
|
|
+
|
|
|
|
+ toInfrared.setInputPath(inputPath.toString());
|
|
|
|
+ toInfrared.setOutputPath(outputPath.toString());
|
|
|
|
+
|
|
|
|
+ toInfrared.setStartTime(new Date());
|
|
|
|
+
|
|
|
|
+ HttpResponseEntity responseEntity = sendPostMsg(to_infrared_start_url, toInfrared);
|
|
|
|
+ if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
|
|
|
|
+ toInfrared.setStatus(BizConstant.VideoStatus.RUNNING);
|
|
|
|
+ updateById(toInfrared);
|
|
|
|
+ return CommonResult.success("任务开始成功,请等待完成");
|
|
|
|
+ } else {
|
|
|
|
+ return CommonResult.fail("任务开始失败,请检查!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CommonResult stop(Long id) {
|
|
|
|
+ ToInfrared toInfrared = getById(id);
|
|
|
|
+
|
|
|
|
+ HttpResponseEntity responseEntity = sendPostMsg(to_infrared_stop_url, toInfrared);
|
|
|
|
+ if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
|
|
|
|
+ toInfrared.setStatus(BizConstant.VideoStatus.INTERRUPTED);
|
|
|
|
+ updateById(toInfrared);
|
|
|
|
+ return CommonResult.fail("终止任务成功");
|
|
|
|
+ } else {
|
|
|
|
+ return CommonResult.fail("终止任务失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CommonResult getResult(ToInfraredStartResultBo toInfraredStartResultBo) {
|
|
|
|
+ Long id = toInfraredStartResultBo.getId();
|
|
|
|
+ String status = toInfraredStartResultBo.getStatus();
|
|
|
|
+ String msg = toInfraredStartResultBo.getMsg();
|
|
|
|
+ ToInfrared toInfrared = getById(id);
|
|
|
|
+ toInfrared.setLog(msg);
|
|
|
|
+ toInfrared.setStatus("200".equals(status) ? BizConstant.VideoStatus.END : BizConstant.VideoStatus.FAILED);
|
|
|
|
+ toInfrared.setEndTime(new Date());
|
|
|
|
+ try {
|
|
|
|
+ toInfrared.setCostSecond((toInfrared.getEndTime().getTime() - toInfrared.getStartTime().getTime()) / 1000);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ toInfrared.setCostSecond(null);
|
|
|
|
+ }
|
|
|
|
+ updateById(toInfrared);
|
|
|
|
+ return CommonResult.success();
|
|
|
|
+ }
|
|
}
|
|
}
|