Merge branch 'qtz3' of SH-Arbitrate/Arbitrate-Backend into dev
This commit was merged in pull request #299.
This commit is contained in:
+10
@@ -337,6 +337,16 @@ public class CaseApplicationController extends BaseController {
|
|||||||
return success(caseApplicationselect);
|
return success(caseApplicationselect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载案件压缩包
|
||||||
|
*/
|
||||||
|
@PostMapping("/downloadCaseZipFile")
|
||||||
|
public AjaxResult downloadCaseZipFile(@Validated @RequestBody CaseApplication caseApplication) {
|
||||||
|
|
||||||
|
CaseAttach caseAttach = caseApplicationService.downloadCaseZipFile(caseApplication);
|
||||||
|
return success(caseAttach);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送房间号短信
|
* 发送房间号短信
|
||||||
|
|||||||
+2
@@ -133,4 +133,6 @@ public interface ICaseApplicationService {
|
|||||||
AjaxResult creatTrialRecordnew(ArbitrateRecord arbitrateRecord);
|
AjaxResult creatTrialRecordnew(ArbitrateRecord arbitrateRecord);
|
||||||
|
|
||||||
AjaxResult editCaseApplicationDefineval(CaseApplication caseApplication);
|
AjaxResult editCaseApplicationDefineval(CaseApplication caseApplication);
|
||||||
|
|
||||||
|
CaseAttach downloadCaseZipFile(CaseApplication caseApplication);
|
||||||
}
|
}
|
||||||
|
|||||||
+123
@@ -44,6 +44,7 @@ import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
|
|||||||
import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
|
import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
|
||||||
import com.ruoyi.wisdomarbitrate.utils.SignAward;
|
import com.ruoyi.wisdomarbitrate.utils.SignAward;
|
||||||
import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
|
import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
|
||||||
|
import com.ruoyi.wisdomarbitrate.utils.ZipFileUtils;
|
||||||
import com.tencentyun.TLSSigAPIv2;
|
import com.tencentyun.TLSSigAPIv2;
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
@@ -78,6 +79,7 @@ import java.util.function.Function;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import static com.ruoyi.common.core.domain.AjaxResult.error;
|
import static com.ruoyi.common.core.domain.AjaxResult.error;
|
||||||
import static com.ruoyi.common.core.domain.AjaxResult.success;
|
import static com.ruoyi.common.core.domain.AjaxResult.success;
|
||||||
@@ -2620,6 +2622,127 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
|||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public CaseAttach downloadCaseZipFile(CaseApplication caseApplication) {
|
||||||
|
caseApplication.setAnnexType(12);
|
||||||
|
CaseAttach caseAttach = new CaseAttach();
|
||||||
|
List<CaseAttach> caseAttachs = caseAttachMapper.queryCaseAttachList( caseApplication);
|
||||||
|
if(caseAttachs!=null&&caseAttachs.size()>0){
|
||||||
|
caseAttach = caseAttachs.get(0);
|
||||||
|
|
||||||
|
String annexName = caseAttach.getAnnexName();
|
||||||
|
String prefix = "/profile";
|
||||||
|
int startIndex = annexName.indexOf(prefix);
|
||||||
|
if(startIndex!=-1) {
|
||||||
|
startIndex += prefix.length();
|
||||||
|
|
||||||
|
String annexPath = "/uploadPath" + annexName.substring(startIndex);
|
||||||
|
caseAttach.setAnnexPath(annexPath);
|
||||||
|
}
|
||||||
|
int startIndexnew = annexName.lastIndexOf("/");
|
||||||
|
if (startIndexnew != -1) {
|
||||||
|
String annexNamenew = annexName.substring(startIndexnew + 1);
|
||||||
|
caseAttach.setAnnexName(annexNamenew);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
CaseApplication caseApplicationsel = new CaseApplication();
|
||||||
|
caseApplicationsel.setId(caseApplication.getId());
|
||||||
|
List<Integer> annexTypeList = new ArrayList<>();
|
||||||
|
annexTypeList.add(1);
|
||||||
|
annexTypeList.add(2);
|
||||||
|
annexTypeList.add(3);
|
||||||
|
annexTypeList.add(6);
|
||||||
|
annexTypeList.add(7);
|
||||||
|
annexTypeList.add(9);
|
||||||
|
annexTypeList.add(11);
|
||||||
|
caseApplicationsel.setAnnexTypeList(annexTypeList);
|
||||||
|
List<CaseAttach> caseAttachList = caseAttachMapper.queryCaseAttachList( caseApplicationsel);
|
||||||
|
if(caseAttachList!=null&&caseAttachList.size()>0){
|
||||||
|
List<String> pathList = new ArrayList<>();
|
||||||
|
for (CaseAttach caseAttach1 : caseAttachList) {
|
||||||
|
String annexName = caseAttach1.getAnnexName();
|
||||||
|
String annexPathsel = caseAttach1.getAnnexPath();
|
||||||
|
String prefix = "/profile";
|
||||||
|
int startIndex = annexName.indexOf(prefix);
|
||||||
|
if(startIndex!=-1) {
|
||||||
|
startIndex += prefix.length();
|
||||||
|
|
||||||
|
String annexPath = "/uploadPath" + annexName.substring(startIndex);
|
||||||
|
String path = "/home/ruoyi" + annexPath;
|
||||||
|
pathList.add(path);
|
||||||
|
}else if(annexPathsel.contains(annexName)){
|
||||||
|
pathList.add(annexPathsel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//将案件相关附件压缩zip文件
|
||||||
|
if(pathList!=null&&pathList.size()>0){
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
String year = Integer.toString(now.getYear());
|
||||||
|
String month = String.format("%02d", now.getMonthValue());
|
||||||
|
String day = String.format("%02d", now.getDayOfMonth());
|
||||||
|
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
||||||
|
// String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
||||||
|
String fileName = UUID.randomUUID().toString().replace("-", "") + ".zip";
|
||||||
|
File saveFolder = new File(saveFolderPath);
|
||||||
|
if (!saveFolder.exists()) {
|
||||||
|
saveFolder.mkdirs();
|
||||||
|
}
|
||||||
|
String zipFileOutPath = saveFolderPath + "/" + fileName;
|
||||||
|
try {
|
||||||
|
|
||||||
|
FileOutputStream zfous = new FileOutputStream(zipFileOutPath);
|
||||||
|
ZipOutputStream zipFileOutstream = new ZipOutputStream(zfous);
|
||||||
|
|
||||||
|
for (String pathstr : pathList) {
|
||||||
|
FileInputStream fis1 = new FileInputStream(pathstr);
|
||||||
|
ZipFileUtils.zipFile(pathstr, fis1, zipFileOutstream);
|
||||||
|
}
|
||||||
|
zipFileOutstream.close();
|
||||||
|
zfous.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存压缩文件附件
|
||||||
|
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
||||||
|
// String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
||||||
|
String savePath = "/home/ruoyi/uploadPath/upload";
|
||||||
|
caseAttach = CaseAttach.builder()
|
||||||
|
.caseAppliId(caseApplication.getId())
|
||||||
|
.annexName(saveName)
|
||||||
|
.annexPath(savePath)
|
||||||
|
.annexType(12)
|
||||||
|
.build();
|
||||||
|
int i = caseAttachMapper.save(caseAttach);
|
||||||
|
|
||||||
|
String annexName = caseAttach.getAnnexName();
|
||||||
|
String prefix = "/profile";
|
||||||
|
int startIndex = annexName.indexOf(prefix);
|
||||||
|
if(startIndex!=-1) {
|
||||||
|
startIndex += prefix.length();
|
||||||
|
|
||||||
|
String annexPath = "/uploadPath" + annexName.substring(startIndex);
|
||||||
|
caseAttach.setAnnexPath(annexPath);
|
||||||
|
}
|
||||||
|
int startIndexnew = annexName.lastIndexOf("/");
|
||||||
|
if (startIndexnew != -1) {
|
||||||
|
String annexNamenew = annexName.substring(startIndexnew + 1);
|
||||||
|
caseAttach.setAnnexName(annexNamenew);
|
||||||
|
}
|
||||||
|
|
||||||
|
return caseAttach;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return caseAttach;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CaseApplication selectSignSealUrl(CaseApplication caseApplication) throws EsignDemoException {
|
public CaseApplication selectSignSealUrl(CaseApplication caseApplication) throws EsignDemoException {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|||||||
@@ -4,40 +4,34 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
public class ZipFileUtils {
|
public class ZipFileUtils {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String filePath1 = "/path/to/file1.txt";
|
String file1 = "F:\\testZip\\123.pdf";
|
||||||
String filePath2 = "/path/to/file2.txt";
|
String file2 = "F:\\testZip\\456.png";
|
||||||
|
String zipFileOutPath = "F:\\testZip\\outputfile123.zip";
|
||||||
// ZIP文件的输出路径
|
|
||||||
String zipOutPath = "/path/to/output.zip";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileOutputStream fous = new FileOutputStream(zipOutPath);
|
FileOutputStream zfous = new FileOutputStream(zipFileOutPath);
|
||||||
ZipOutputStream zipOutstream = new ZipOutputStream(fous);
|
ZipOutputStream zipFileOutstream = new ZipOutputStream(zfous);
|
||||||
FileInputStream fis1 = new FileInputStream(filePath1);
|
FileInputStream fis1 = new FileInputStream(file1);
|
||||||
FileInputStream fis2 = new FileInputStream(filePath2);
|
FileInputStream fis2 = new FileInputStream(file2);
|
||||||
|
zipFile(file1, fis1, zipFileOutstream);
|
||||||
zipFile(filePath1, fis1, zipOutstream);
|
zipFile(file2, fis2, zipFileOutstream);
|
||||||
|
|
||||||
zipFile(filePath2, fis2, zipOutstream);
|
|
||||||
|
|
||||||
|
zipFileOutstream.close();
|
||||||
|
zfous.close();
|
||||||
System.out.println("文件成功打包成ZIP文件!");
|
System.out.println("文件成功打包成ZIP文件!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void zipFile(String zipfilePath, FileInputStream zipFileinsteam, ZipOutputStream zipfileOut)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void zipFile(String zipfilePath, FileInputStream zipFileinsteam, ZipOutputStream zipfileOut)
|
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ZipEntry zipfileEntry = new ZipEntry(new File(zipfilePath).getName());
|
ZipEntry zipfileEntry = new ZipEntry(new File(zipfilePath).getName());
|
||||||
zipfileOut.putNextEntry(zipfileEntry);
|
zipfileOut.putNextEntry(zipfileEntry);
|
||||||
|
|||||||
Reference in New Issue
Block a user