diff --git a/pom.xml b/pom.xml
index c18b21e..26543b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,27 @@
+
+
+
+
+
+
+ com.itextpdf
+ layout
+ 7.1.16
+
+
+ com.itextpdf
+ itextpdf
+ 5.5.12
+
+
+ com.itextpdf
+ forms
+ 7.1.16
+
+
com.squareup.okhttp3
okhttp
diff --git a/src/main/java/com/bonus/aqgqj/app/controller/ExperimentalAppController.java b/src/main/java/com/bonus/aqgqj/app/controller/ExperimentalAppController.java
index 2d2b98a..085b277 100644
--- a/src/main/java/com/bonus/aqgqj/app/controller/ExperimentalAppController.java
+++ b/src/main/java/com/bonus/aqgqj/app/controller/ExperimentalAppController.java
@@ -107,13 +107,13 @@ public class ExperimentalAppController {
* 试验数据详情
*/
@PostMapping(value = "viewTestData")
- @DecryptAndVerify(decryptedClass = ParamsAppDto.class)//加解密统一管理
+ @DecryptAndVerify(decryptedClass = ParamsAppDto.class)
public ServerResponse viewTestData(EncryptedReq data) {
return service.viewTestData(data.getData());
}
@PostMapping(value = "commitCheckTestData")
- @DecryptAndVerify(decryptedClass = ParamsAppDto.class)//加解密统一管理
+ @DecryptAndVerify(decryptedClass = ParamsAppDto.class)
@LogAnnotation(operModul = "试验管理", operation = "提交审查数据", operDesc = "业务级事件", operType = "提交审查")
// @PreAuthorize("@pms.hasPermission('sys:experimentalTest:commitCheck')")
public ServerResponse commitCheckTestData(EncryptedReq data) {
diff --git a/src/main/java/com/bonus/aqgqj/app/controller/PrimaryDataAppController.java b/src/main/java/com/bonus/aqgqj/app/controller/PrimaryDataAppController.java
index 7b8fee2..835b520 100644
--- a/src/main/java/com/bonus/aqgqj/app/controller/PrimaryDataAppController.java
+++ b/src/main/java/com/bonus/aqgqj/app/controller/PrimaryDataAppController.java
@@ -6,17 +6,15 @@ import com.bonus.aqgqj.annotation.DecryptAndVerify;
import com.bonus.aqgqj.annotation.LogAnnotation;
import com.bonus.aqgqj.app.entity.ExperimentalAppVo;
import com.bonus.aqgqj.app.entity.ExperimentalDetailAppVo;
-import com.bonus.aqgqj.app.entity.SamplesManageAppVo;
import com.bonus.aqgqj.app.entity.dto.ParamsAppDto;
import com.bonus.aqgqj.app.service.PrimaryDataAppService;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.*;
-import com.bonus.aqgqj.primaryData.dao.PrimaryDataDao;
-import com.bonus.aqgqj.primaryData.service.PrimaryDataService;
import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.ExcelStyleUtil;
import com.bonus.aqgqj.utils.FileUtil;
import com.bonus.aqgqj.utils.ServerResponse;
+import com.bonus.aqgqj.utils.SystemUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
@@ -32,19 +30,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
-import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
@@ -65,8 +57,6 @@ public class PrimaryDataAppController {
private static final Logger log = LoggerFactory.getLogger("adminLogger");
- @Value("${file.windwos.upload_path}")
- private String uploadPath;
@Autowired
private PrimaryDataAppService primaryDataAppService;
@@ -164,8 +154,6 @@ public class PrimaryDataAppController {
return ServerResponse.createErroe("查看失败");
}
}
-
-
/**
* 批量下载原始记录压缩文件
*
@@ -178,12 +166,13 @@ public class PrimaryDataAppController {
*/
@PostMapping(value = "downLoadExcelZip")
@DecryptAndVerify(decryptedClass = ParamsDto.class)
- public void downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq dto) {
+ public ServerResponse downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq dto) {
List fileList = new ArrayList();
List fileNameList = new ArrayList();
+ String fileNames="检测原始记录_" + System.currentTimeMillis()+".zip";
+ String outputZipFilePath = SystemUtils.getUploadPath()+ fileNames;
try {
Long[] ids = dto.getData().getIds();
- ParamsDto paramsDto = new ParamsDto();
if (ids != null && ids.length > 0) {
for (int h = 0; h < ids.length; h++) {
String excelModelPath = createExcelModel(ids[h]);
@@ -192,8 +181,10 @@ public class PrimaryDataAppController {
fileNameList.add(excelModelPath);
}
}
- downloadZip(response, fileList);
+// downloadZip(response, fileList);
+ zipFiles(fileList, outputZipFilePath);
}
+ return ServerResponse.createSuccess("statics/"+fileNames);
} catch (Exception e) {
log.error("zip导出错误-异常信息", e);
} finally {
@@ -203,6 +194,7 @@ public class PrimaryDataAppController {
}
}
}
+ return ServerResponse.createErroe("下载失败");
}
public String createExcelModel(Long experId) {
@@ -246,7 +238,7 @@ public class PrimaryDataAppController {
}
sheet = handleNineRow(vo, sheet, commonStyle2, rowNum++, hbNum);
sheet = handleTenRow(vo, sheet, commonStyle, rowNum++, hbNum);
- String fileName = uploadPath + vo.getDevTypeName() + "检测原始记录_" + System.currentTimeMillis() + ".xlsx";
+ String fileName = SystemUtils.getUploadPath() + vo.getDevTypeName() + "检测原始记录_" + System.currentTimeMillis() + ".xlsx";
File file = new File(fileName);
//生成文件夹
if (!file.getParentFile().exists()) {
@@ -265,6 +257,7 @@ public class PrimaryDataAppController {
// 设置响应头信息,指定下载的文件名为"files.zip"
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment; filename=files.zip");
+ response.setHeader("code","200");
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
for (File file : filesToZip) {
try (FileInputStream fis = new FileInputStream(file)) {
@@ -282,6 +275,30 @@ public class PrimaryDataAppController {
}
}
+ public void zipFiles(List filesToZip, String outputZipFilePath) throws IOException {
+ File outputFile = new File(outputZipFilePath);
+ try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(outputFile))) {
+ for (File file : filesToZip) {
+ try (FileInputStream fis = new FileInputStream(file)) {
+ ZipEntry zipEntry = new ZipEntry(file.getName());
+ zos.putNextEntry(zipEntry);
+
+ byte[] buffer = new byte[1024];
+ int len;
+ while ((len = fis.read(buffer)) > 0) {
+ zos.write(buffer, 0, len);
+ }
+ }
+ }
+ zos.closeEntry();
+ } catch (IOException e) {
+ // 处理异常,例如记录日志
+ e.printStackTrace();
+ }
+ // 可以在这里添加额外的逻辑,比如检查文件是否成功创建
+ System.out.println("ZIP文件已保存到: " + outputFile.getAbsolutePath());
+ }
+
/**
* 第一行表头
diff --git a/src/main/java/com/bonus/aqgqj/app/controller/TestReportManageAppController.java b/src/main/java/com/bonus/aqgqj/app/controller/TestReportManageAppController.java
index 3714ee5..8a343b7 100644
--- a/src/main/java/com/bonus/aqgqj/app/controller/TestReportManageAppController.java
+++ b/src/main/java/com/bonus/aqgqj/app/controller/TestReportManageAppController.java
@@ -263,10 +263,10 @@ public class TestReportManageAppController {
*/
@PostMapping(value = "downLoadExcelZip")
@DecryptAndVerify(decryptedClass = TestReportManageAppVo.class)
- public void downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq dto) {
+ public ServerResponse downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq dto) {
List fileNameList = new ArrayList();
try {
- service.downLoadExcelZip(response, dto.getData(),fileNameList);
+ return service.downLoadExcelZip(response, dto.getData(),fileNameList);
} catch (Exception e) {
log.error("zip导出错误-异常信息", e);
} finally {
@@ -276,6 +276,7 @@ public class TestReportManageAppController {
}
}
}
+ return ServerResponse.createErroe("下载失败");
}
diff --git a/src/main/java/com/bonus/aqgqj/app/dao/CertificateAppDao.java b/src/main/java/com/bonus/aqgqj/app/dao/CertificateAppDao.java
index c2ed5b9..7b8908e 100644
--- a/src/main/java/com/bonus/aqgqj/app/dao/CertificateAppDao.java
+++ b/src/main/java/com/bonus/aqgqj/app/dao/CertificateAppDao.java
@@ -122,6 +122,7 @@ public interface CertificateAppDao {
/**
* 根据设备编码查询设备数量
* @param devCode
+ * @param sampleTools
* @return
*/
int getCountByDevCode(String devCode,String sampleTools);
diff --git a/src/main/java/com/bonus/aqgqj/app/dao/ExperimentalAppMapper.java b/src/main/java/com/bonus/aqgqj/app/dao/ExperimentalAppMapper.java
index 4591eb4..95b6df5 100644
--- a/src/main/java/com/bonus/aqgqj/app/dao/ExperimentalAppMapper.java
+++ b/src/main/java/com/bonus/aqgqj/app/dao/ExperimentalAppMapper.java
@@ -134,6 +134,7 @@ public interface ExperimentalAppMapper {
* 添加试验项内容
*
* @param configItemVo
+ * @param experId
* @return void
* @author cwchen
* @date 2024/7/21 17:28
@@ -361,17 +362,16 @@ public interface ExperimentalAppMapper {
// * @date 2024/7/22 0:36
// */
// void delExperItem(List experItemsIds);
-//
-// /**
-// * 查询试验设备数量
-// *
-// * @param experId
-// * @return List
-// * @author cwchen
-// * @date 2024/7/22 10:58
-// */
-// @MapKey("id")
-// List