|
|
@ -18,7 +18,6 @@ package me.zhengjie.modules.formdata.service.impl;
|
|
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
|
|
import com.aliyun.oss.OSS;
|
|
|
|
import com.aliyun.oss.OSS;
|
|
|
|
import com.aliyun.oss.OSSClientBuilder;
|
|
|
|
import com.aliyun.oss.OSSClientBuilder;
|
|
|
|
import com.aliyun.oss.model.PutObjectResult;
|
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import me.zhengjie.modules.formdata.domain.Formdata;
|
|
|
|
import me.zhengjie.modules.formdata.domain.Formdata;
|
|
|
@ -31,8 +30,8 @@ import me.zhengjie.modules.uploadnew.listener.EasyExcelListener;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.ExcelDataDTO;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.ExcelDataDTO;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.OosDTO;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.OosDTO;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.WavDTO;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.dto.WavDTO;
|
|
|
|
import me.zhengjie.modules.uploadnew.task.TransFormDataTask;
|
|
|
|
|
|
|
|
import me.zhengjie.modules.uploadnew.service.impl.BuildPathUtils;
|
|
|
|
import me.zhengjie.modules.uploadnew.service.impl.BuildPathUtils;
|
|
|
|
|
|
|
|
import me.zhengjie.modules.uploadnew.task.TransFormDataTask;
|
|
|
|
import me.zhengjie.utils.FileUtil;
|
|
|
|
import me.zhengjie.utils.FileUtil;
|
|
|
|
import me.zhengjie.utils.PageUtil;
|
|
|
|
import me.zhengjie.utils.PageUtil;
|
|
|
|
import me.zhengjie.utils.QueryHelp;
|
|
|
|
import me.zhengjie.utils.QueryHelp;
|
|
|
@ -49,7 +48,10 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.*;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
|
|
|
|
|
|
|
@ -154,15 +156,16 @@ public class FormdataServiceImpl implements FormdataService {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
InputStream inputStream = file.getInputStream();
|
|
|
|
InputStream inputStream = file.getInputStream();
|
|
|
|
EasyExcelListener listener = new EasyExcelListener();
|
|
|
|
EasyExcelListener listener = new EasyExcelListener();
|
|
|
|
EasyExcelFactory.read(inputStream, ExcelDataDTO.class, listener).sheet().doRead();
|
|
|
|
// 忽略首行
|
|
|
|
|
|
|
|
EasyExcelFactory.read(inputStream, ExcelDataDTO.class, listener).sheet().headRowNumber(1).doRead();
|
|
|
|
//获取到解析后的数据
|
|
|
|
//获取到解析后的数据
|
|
|
|
formData = listener.getData();
|
|
|
|
formData = listener.getData();
|
|
|
|
// 2. 把解析后的结果进行入库
|
|
|
|
// 2. 把解析后的结果进行入库
|
|
|
|
formdataRepository.saveAll(formData);
|
|
|
|
formdataRepository.saveAll(formData);
|
|
|
|
return formdataMapper.toDto(formData);
|
|
|
|
return formdataMapper.toDto(formData);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("解析失败");
|
|
|
|
log.error("数据入库失败 , ");
|
|
|
|
throw new RuntimeException("");
|
|
|
|
throw new RuntimeException("error : {} -> ", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -174,11 +177,11 @@ public class FormdataServiceImpl implements FormdataService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String parseMediaFileToLocal(MultipartFile file) {
|
|
|
|
public String parseMediaFileToLocal(MultipartFile file) {
|
|
|
|
// todo 存储音频压缩文件到指定目录下 每次上传以 2021-8-5 为 文件名进行记录 每次记录一天的 并保存记录
|
|
|
|
// 存储音频压缩文件到指定目录下 每次上传以 2021-8-5 为 文件名进行记录 每次记录一天的 并保存记录
|
|
|
|
//文件名
|
|
|
|
//文件名
|
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
|
//文件保存地址
|
|
|
|
//文件保存地址
|
|
|
|
String path = buildPathUtils.buildFilePath();
|
|
|
|
String path = buildPathUtils.buildFilePath(fileName);
|
|
|
|
OutputStream os = null;
|
|
|
|
OutputStream os = null;
|
|
|
|
InputStream inputStream = null;
|
|
|
|
InputStream inputStream = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -208,7 +211,7 @@ public class FormdataServiceImpl implements FormdataService {
|
|
|
|
os.close();
|
|
|
|
os.close();
|
|
|
|
inputStream.close();
|
|
|
|
inputStream.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
log.error("ERROR FormdataServiceImpl|parseMediaFileToLocal ",e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
return path;
|
|
|
@ -232,7 +235,7 @@ public class FormdataServiceImpl implements FormdataService {
|
|
|
|
//上传路径
|
|
|
|
//上传路径
|
|
|
|
String newFileName = buildPathUtils.buildFileOosPath(subFixFile);
|
|
|
|
String newFileName = buildPathUtils.buildFileOosPath(subFixFile);
|
|
|
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
|
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
|
|
PutObjectResult putObjectResult = ossClient.putObject(bucketName, newFileName, wavDTO.getLine());
|
|
|
|
ossClient.putObject(bucketName, newFileName, wavDTO.getLine());
|
|
|
|
ossClient.shutdown();
|
|
|
|
ossClient.shutdown();
|
|
|
|
OosDTO oosDTO = toBean(info, newFileName);
|
|
|
|
OosDTO oosDTO = toBean(info, newFileName);
|
|
|
|
//发送下游
|
|
|
|
//发送下游
|
|
|
@ -247,7 +250,7 @@ public class FormdataServiceImpl implements FormdataService {
|
|
|
|
List<WavDTO> wavDTOS = new ArrayList<>();
|
|
|
|
List<WavDTO> wavDTOS = new ArrayList<>();
|
|
|
|
String zipFileName = null;
|
|
|
|
String zipFileName = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream(), Charset.forName("GBK"));
|
|
|
|
ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream(), Charset.defaultCharset());
|
|
|
|
BufferedInputStream bs = new BufferedInputStream(zipInputStream);
|
|
|
|
BufferedInputStream bs = new BufferedInputStream(zipInputStream);
|
|
|
|
ZipEntry zipEntry;
|
|
|
|
ZipEntry zipEntry;
|
|
|
|
byte[] bytes = null;
|
|
|
|
byte[] bytes = null;
|
|
|
@ -262,7 +265,7 @@ public class FormdataServiceImpl implements FormdataService {
|
|
|
|
wavDTOS.add(wavDTO);
|
|
|
|
wavDTOS.add(wavDTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("读取部署包文件内容失败,请确认部署包格式正确:" + zipFileName, e);
|
|
|
|
log.error("读取部署包文件内容失败,请确认部署包格式正确: {} ", zipFileName, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return wavDTOS;
|
|
|
|
return wavDTOS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|