2024年5月29日 修复智慧教室人流量监测未上传到ftp的问题
This commit is contained in:
parent
bd01bab979
commit
f71fa463d8
|
@ -58,9 +58,7 @@ public class SFTPUtil {
|
||||||
public static void getChannelSftp(SftpConfig sftpConfig){
|
public static void getChannelSftp(SftpConfig sftpConfig){
|
||||||
try {
|
try {
|
||||||
if(sshSession == null){
|
if(sshSession == null){
|
||||||
if(sshSession == null){
|
getSession(sftpConfig);
|
||||||
getSession(sftpConfig);
|
|
||||||
}
|
|
||||||
Channel channel = sshSession.openChannel("sftp");
|
Channel channel = sshSession.openChannel("sftp");
|
||||||
channel.connect();
|
channel.connect();
|
||||||
sftp = (ChannelSftp) channel;
|
sftp = (ChannelSftp) channel;
|
||||||
|
@ -276,7 +274,7 @@ public class SFTPUtil {
|
||||||
* @param saveFile 存在本地的路径
|
* @param saveFile 存在本地的路径
|
||||||
*/
|
*/
|
||||||
public static Map<String,String> download(SftpConfig sftpConfig, String directory, String saveFile) {
|
public static Map<String,String> download(SftpConfig sftpConfig, String directory, String saveFile) {
|
||||||
Map<String,String> map = new HashMap<String,String>();
|
Map<String,String> map = new HashMap<>();
|
||||||
map.put("code","0");
|
map.put("code","0");
|
||||||
map.put("msg","下载成功");
|
map.put("msg","下载成功");
|
||||||
String[] df = getDirectoryAndFileName(directory);
|
String[] df = getDirectoryAndFileName(directory);
|
||||||
|
|
|
@ -1,47 +1,42 @@
|
||||||
package org.jeecg.modules.kc.detection.service.impl;
|
package org.jeecg.modules.kc.detection.service.impl;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.beust.jcommander.internal.Sets;
|
import com.beust.jcommander.internal.Sets;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
import org.jeecg.common.util.SFTPUtil;
|
||||||
|
import org.jeecg.common.util.SftpConfig;
|
||||||
import org.jeecg.modules.kc.detection.entity.KcDetectionDetailed;
|
import org.jeecg.modules.kc.detection.entity.KcDetectionDetailed;
|
||||||
import org.jeecg.modules.kc.detection.entity.KcDetectionMain;
|
import org.jeecg.modules.kc.detection.entity.KcDetectionMain;
|
||||||
import org.jeecg.modules.kc.detection.mapper.KcDetectionDetailedMapper;
|
import org.jeecg.modules.kc.detection.mapper.KcDetectionDetailedMapper;
|
||||||
import org.jeecg.modules.kc.detection.service.IKcDetectionDetailedService;
|
import org.jeecg.modules.kc.detection.service.IKcDetectionDetailedService;
|
||||||
import org.jeecg.modules.kc.detection.service.IKcDetectionMainService;
|
import org.jeecg.modules.kc.detection.service.IKcDetectionMainService;
|
||||||
import org.jeecg.modules.kc.jiaoshi.controller.KcZhihuijiaoshiController;
|
|
||||||
import org.jeecg.modules.kc.jiaoshi.entity.KcZhihuijiaoshi;
|
import org.jeecg.modules.kc.jiaoshi.entity.KcZhihuijiaoshi;
|
||||||
import org.jeecg.modules.kc.jiaoshi.service.IKcZhihuijiaoshiService;
|
import org.jeecg.modules.kc.jiaoshi.service.IKcZhihuijiaoshiService;
|
||||||
import org.jeecg.modules.kc.kcJieci.entity.KcJieci;
|
import org.jeecg.modules.kc.kcJieci.entity.KcJieci;
|
||||||
import org.jeecg.modules.kc.kcJieci.service.IKcJieciService;
|
import org.jeecg.modules.kc.kcJieci.service.IKcJieciService;
|
||||||
import org.jeecg.modules.kc.ktgl.controller.KcKetangbiaoController;
|
|
||||||
import org.jeecg.modules.kc.ktgl.entity.KcKetangbiao;
|
import org.jeecg.modules.kc.ktgl.entity.KcKetangbiao;
|
||||||
import org.jeecg.modules.kc.ktgl.service.IKcKetangbiaoService;
|
import org.jeecg.modules.kc.ktgl.service.IKcKetangbiaoService;
|
||||||
import org.jeecg.modules.tools.AuthService;
|
import org.jeecg.modules.tools.*;
|
||||||
import org.jeecg.modules.tools.CommonUtil;
|
|
||||||
import org.jeecg.modules.tools.DateUtils;
|
|
||||||
import org.jeecg.modules.tools.URLEncoder;
|
|
||||||
import org.jeecg.modules.tools.ffmpeg.FFmpegTools;
|
import org.jeecg.modules.tools.ffmpeg.FFmpegTools;
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.util.FileCopyUtils;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.stream.Collectors;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 教室人数检测-详细表
|
* @Description: 教室人数检测-详细表
|
||||||
|
@ -49,6 +44,7 @@ import java.util.stream.Collectors;
|
||||||
* @Date: 2024-05-07
|
* @Date: 2024-05-07
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class KcDetectionDetailedServiceImpl extends ServiceImpl<KcDetectionDetailedMapper, KcDetectionDetailed> implements IKcDetectionDetailedService {
|
public class KcDetectionDetailedServiceImpl extends ServiceImpl<KcDetectionDetailedMapper, KcDetectionDetailed> implements IKcDetectionDetailedService {
|
||||||
|
|
||||||
|
@ -70,6 +66,14 @@ public class KcDetectionDetailedServiceImpl extends ServiceImpl<KcDetectionDetai
|
||||||
@Resource
|
@Resource
|
||||||
private IKcJieciService jieciService;
|
private IKcJieciService jieciService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Global global;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SftpConfig sftpConfig;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Value(value = "${jeecg.path.upload}")
|
@Value(value = "${jeecg.path.upload}")
|
||||||
private String uploadpath;
|
private String uploadpath;
|
||||||
|
@ -141,7 +145,7 @@ public class KcDetectionDetailedServiceImpl extends ServiceImpl<KcDetectionDetai
|
||||||
String fileName;
|
String fileName;
|
||||||
File uploadpathFile = new File(uploadpath);
|
File uploadpathFile = new File(uploadpath);
|
||||||
String uploadpathFilePath = uploadpathFile.getPath();
|
String uploadpathFilePath = uploadpathFile.getPath();
|
||||||
File file = new File(uploadpathFilePath + File.separator + "videoScreenshot" + File.separator + ketangbiao.getXnxq() + File.separator + yearMonthStr + File.separator + x.getJsbh() + File.separator);
|
File file = new File(uploadpathFilePath + File.separator + "temp" + File.separator + "videoScreenshot" + File.separator + ketangbiao.getXnxq() + File.separator + yearMonthStr + File.separator + x.getJsbh() + File.separator);
|
||||||
String orgName = x.getPullUrl();// 获取文件名
|
String orgName = x.getPullUrl();// 获取文件名
|
||||||
orgName = CommonUtil.getFileName(orgName);
|
orgName = CommonUtil.getFileName(orgName);
|
||||||
if(orgName.lastIndexOf(".")!=-1){
|
if(orgName.lastIndexOf(".")!=-1){
|
||||||
|
@ -166,6 +170,23 @@ public class KcDetectionDetailedServiceImpl extends ServiceImpl<KcDetectionDetai
|
||||||
String miniOutImagePath = StringUtils.replace(outImagePath, uploadpathFilePath + File.separator, "");
|
String miniOutImagePath = StringUtils.replace(outImagePath, uploadpathFilePath + File.separator, "");
|
||||||
miniOutImagePath = StringUtils.replace(miniOutImagePath,"\\","/");
|
miniOutImagePath = StringUtils.replace(miniOutImagePath,"\\","/");
|
||||||
boolean isSuccess = _FFmpegTools.videoScreenshot(x.getPullUrl(), outImagePath);
|
boolean isSuccess = _FFmpegTools.videoScreenshot(x.getPullUrl(), outImagePath);
|
||||||
|
|
||||||
|
if(isSuccess){
|
||||||
|
//转存文件到ftp
|
||||||
|
//miniOutImagePath
|
||||||
|
if(StringUtils.equals(CommonConstant.UPLOAD_TYPE_SFTP, global.uploadType)){
|
||||||
|
//miniOutImagePath =
|
||||||
|
int index = miniOutImagePath.lastIndexOf("/");
|
||||||
|
String outImagePathDir = miniOutImagePath.substring(0,index);
|
||||||
|
String outImagePathName = miniOutImagePath.substring(index+1);
|
||||||
|
Map<String, String> res = SFTPUtil.upload(sftpConfig, false, outImagePathDir, outImagePath, outImagePathName );
|
||||||
|
if(!StringUtils.equals(res.get("code"),"0")){
|
||||||
|
log.error("上传文件出现错误:{}", res.get("msg"));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
//查找主表,
|
//查找主表,
|
||||||
QueryWrapper<KcDetectionMain> detectionMainQw = new QueryWrapper<>();
|
QueryWrapper<KcDetectionMain> detectionMainQw = new QueryWrapper<>();
|
||||||
|
|
||||||
|
|
|
@ -472,7 +472,13 @@ public class CommonController {
|
||||||
try{
|
try{
|
||||||
logger.info("/sys/common/static/SFTP下载 ..."+new Date());
|
logger.info("/sys/common/static/SFTP下载 ..."+new Date());
|
||||||
// SFTPUtil.writeFileToRes(sftpConfig,imgPath,response);
|
// SFTPUtil.writeFileToRes(sftpConfig,imgPath,response);
|
||||||
Map<String,String> map = SFTPUtil.download(sftpConfig,imgPath,getDownloadPath("temp"));
|
int index = imgPath.lastIndexOf("/");
|
||||||
|
String path = "temp";
|
||||||
|
if(index != -1){
|
||||||
|
path = imgPath.substring(0,index);
|
||||||
|
}
|
||||||
|
//TODO 不确定是否有问题,
|
||||||
|
Map<String,String> map = SFTPUtil.download(sftpConfig,imgPath,getDownloadPath(path));
|
||||||
if(!map.get("code").equals("0")){
|
if(!map.get("code").equals("0")){
|
||||||
response.setStatus(404);
|
response.setStatus(404);
|
||||||
throw new RuntimeException(map.get("msg"));
|
throw new RuntimeException(map.get("msg"));
|
||||||
|
|
Loading…
Reference in New Issue