app试验管理、审查管理、检测报告管理、合格证管理
This commit is contained in:
parent
3220ec32c7
commit
308c11f75b
21
pom.xml
21
pom.xml
|
|
@ -37,6 +37,27 @@
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.apache.poi</groupId>-->
|
||||||
|
<!-- <artifactId>poi-ooxml</artifactId>-->
|
||||||
|
<!-- <version>5.2.0</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>layout</artifactId>
|
||||||
|
<version>7.1.16</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>itextpdf</artifactId>
|
||||||
|
<version>5.5.12</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>forms</artifactId>
|
||||||
|
<version>7.1.16</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -107,13 +107,13 @@ public class ExperimentalAppController {
|
||||||
* 试验数据详情
|
* 试验数据详情
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "viewTestData")
|
@PostMapping(value = "viewTestData")
|
||||||
@DecryptAndVerify(decryptedClass = ParamsAppDto.class)//加解密统一管理
|
@DecryptAndVerify(decryptedClass = ParamsAppDto.class)
|
||||||
public ServerResponse viewTestData(EncryptedReq<ParamsAppDto> data) {
|
public ServerResponse viewTestData(EncryptedReq<ParamsAppDto> data) {
|
||||||
return service.viewTestData(data.getData());
|
return service.viewTestData(data.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "commitCheckTestData")
|
@PostMapping(value = "commitCheckTestData")
|
||||||
@DecryptAndVerify(decryptedClass = ParamsAppDto.class)//加解密统一管理
|
@DecryptAndVerify(decryptedClass = ParamsAppDto.class)
|
||||||
@LogAnnotation(operModul = "试验管理", operation = "提交审查数据", operDesc = "业务级事件", operType = "提交审查")
|
@LogAnnotation(operModul = "试验管理", operation = "提交审查数据", operDesc = "业务级事件", operType = "提交审查")
|
||||||
// @PreAuthorize("@pms.hasPermission('sys:experimentalTest:commitCheck')")
|
// @PreAuthorize("@pms.hasPermission('sys:experimentalTest:commitCheck')")
|
||||||
public ServerResponse commitCheckTestData(EncryptedReq<ParamsAppDto> data) {
|
public ServerResponse commitCheckTestData(EncryptedReq<ParamsAppDto> data) {
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,15 @@ import com.bonus.aqgqj.annotation.DecryptAndVerify;
|
||||||
import com.bonus.aqgqj.annotation.LogAnnotation;
|
import com.bonus.aqgqj.annotation.LogAnnotation;
|
||||||
import com.bonus.aqgqj.app.entity.ExperimentalAppVo;
|
import com.bonus.aqgqj.app.entity.ExperimentalAppVo;
|
||||||
import com.bonus.aqgqj.app.entity.ExperimentalDetailAppVo;
|
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.entity.dto.ParamsAppDto;
|
||||||
import com.bonus.aqgqj.app.service.PrimaryDataAppService;
|
import com.bonus.aqgqj.app.service.PrimaryDataAppService;
|
||||||
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
|
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
|
||||||
import com.bonus.aqgqj.basis.entity.vo.*;
|
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.system.vo.EncryptedReq;
|
||||||
import com.bonus.aqgqj.utils.ExcelStyleUtil;
|
import com.bonus.aqgqj.utils.ExcelStyleUtil;
|
||||||
import com.bonus.aqgqj.utils.FileUtil;
|
import com.bonus.aqgqj.utils.FileUtil;
|
||||||
import com.bonus.aqgqj.utils.ServerResponse;
|
import com.bonus.aqgqj.utils.ServerResponse;
|
||||||
|
import com.bonus.aqgqj.utils.SystemUtils;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
|
@ -32,19 +30,13 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
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.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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
@ -65,8 +57,6 @@ public class PrimaryDataAppController {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("adminLogger");
|
private static final Logger log = LoggerFactory.getLogger("adminLogger");
|
||||||
|
|
||||||
@Value("${file.windwos.upload_path}")
|
|
||||||
private String uploadPath;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PrimaryDataAppService primaryDataAppService;
|
private PrimaryDataAppService primaryDataAppService;
|
||||||
|
|
@ -164,8 +154,6 @@ public class PrimaryDataAppController {
|
||||||
return ServerResponse.createErroe("查看失败");
|
return ServerResponse.createErroe("查看失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量下载原始记录压缩文件
|
* 批量下载原始记录压缩文件
|
||||||
*
|
*
|
||||||
|
|
@ -178,12 +166,13 @@ public class PrimaryDataAppController {
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "downLoadExcelZip")
|
@PostMapping(value = "downLoadExcelZip")
|
||||||
@DecryptAndVerify(decryptedClass = ParamsDto.class)
|
@DecryptAndVerify(decryptedClass = ParamsDto.class)
|
||||||
public void downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq<ParamsDto> dto) {
|
public ServerResponse downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq<ParamsDto> dto) {
|
||||||
List<File> fileList = new ArrayList();
|
List<File> fileList = new ArrayList();
|
||||||
List<String> fileNameList = new ArrayList();
|
List<String> fileNameList = new ArrayList();
|
||||||
|
String fileNames="检测原始记录_" + System.currentTimeMillis()+".zip";
|
||||||
|
String outputZipFilePath = SystemUtils.getUploadPath()+ fileNames;
|
||||||
try {
|
try {
|
||||||
Long[] ids = dto.getData().getIds();
|
Long[] ids = dto.getData().getIds();
|
||||||
ParamsDto paramsDto = new ParamsDto();
|
|
||||||
if (ids != null && ids.length > 0) {
|
if (ids != null && ids.length > 0) {
|
||||||
for (int h = 0; h < ids.length; h++) {
|
for (int h = 0; h < ids.length; h++) {
|
||||||
String excelModelPath = createExcelModel(ids[h]);
|
String excelModelPath = createExcelModel(ids[h]);
|
||||||
|
|
@ -192,8 +181,10 @@ public class PrimaryDataAppController {
|
||||||
fileNameList.add(excelModelPath);
|
fileNameList.add(excelModelPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
downloadZip(response, fileList);
|
// downloadZip(response, fileList);
|
||||||
|
zipFiles(fileList, outputZipFilePath);
|
||||||
}
|
}
|
||||||
|
return ServerResponse.createSuccess("statics/"+fileNames);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("zip导出错误-异常信息", e);
|
log.error("zip导出错误-异常信息", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -203,6 +194,7 @@ public class PrimaryDataAppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ServerResponse.createErroe("下载失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createExcelModel(Long experId) {
|
public String createExcelModel(Long experId) {
|
||||||
|
|
@ -246,7 +238,7 @@ public class PrimaryDataAppController {
|
||||||
}
|
}
|
||||||
sheet = handleNineRow(vo, sheet, commonStyle2, rowNum++, hbNum);
|
sheet = handleNineRow(vo, sheet, commonStyle2, rowNum++, hbNum);
|
||||||
sheet = handleTenRow(vo, sheet, commonStyle, 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);
|
File file = new File(fileName);
|
||||||
//生成文件夹
|
//生成文件夹
|
||||||
if (!file.getParentFile().exists()) {
|
if (!file.getParentFile().exists()) {
|
||||||
|
|
@ -265,6 +257,7 @@ public class PrimaryDataAppController {
|
||||||
// 设置响应头信息,指定下载的文件名为"files.zip"
|
// 设置响应头信息,指定下载的文件名为"files.zip"
|
||||||
response.setContentType("application/zip");
|
response.setContentType("application/zip");
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=files.zip");
|
response.setHeader("Content-Disposition", "attachment; filename=files.zip");
|
||||||
|
response.setHeader("code","200");
|
||||||
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
|
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
|
||||||
for (File file : filesToZip) {
|
for (File file : filesToZip) {
|
||||||
try (FileInputStream fis = new FileInputStream(file)) {
|
try (FileInputStream fis = new FileInputStream(file)) {
|
||||||
|
|
@ -282,6 +275,30 @@ public class PrimaryDataAppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void zipFiles(List<File> 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第一行表头
|
* 第一行表头
|
||||||
|
|
|
||||||
|
|
@ -263,10 +263,10 @@ public class TestReportManageAppController {
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "downLoadExcelZip")
|
@PostMapping(value = "downLoadExcelZip")
|
||||||
@DecryptAndVerify(decryptedClass = TestReportManageAppVo.class)
|
@DecryptAndVerify(decryptedClass = TestReportManageAppVo.class)
|
||||||
public void downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq<TestReportManageAppVo> dto) {
|
public ServerResponse downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq<TestReportManageAppVo> dto) {
|
||||||
List<String> fileNameList = new ArrayList();
|
List<String> fileNameList = new ArrayList();
|
||||||
try {
|
try {
|
||||||
service.downLoadExcelZip(response, dto.getData(),fileNameList);
|
return service.downLoadExcelZip(response, dto.getData(),fileNameList);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("zip导出错误-异常信息", e);
|
log.error("zip导出错误-异常信息", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -276,6 +276,7 @@ public class TestReportManageAppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ServerResponse.createErroe("下载失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ public interface CertificateAppDao {
|
||||||
/**
|
/**
|
||||||
* 根据设备编码查询设备数量
|
* 根据设备编码查询设备数量
|
||||||
* @param devCode
|
* @param devCode
|
||||||
|
* @param sampleTools
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int getCountByDevCode(String devCode,String sampleTools);
|
int getCountByDevCode(String devCode,String sampleTools);
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ public interface ExperimentalAppMapper {
|
||||||
* 添加试验项内容
|
* 添加试验项内容
|
||||||
*
|
*
|
||||||
* @param configItemVo
|
* @param configItemVo
|
||||||
|
* @param experId
|
||||||
* @return void
|
* @return void
|
||||||
* @author cwchen
|
* @author cwchen
|
||||||
* @date 2024/7/21 17:28
|
* @date 2024/7/21 17:28
|
||||||
|
|
@ -361,17 +362,16 @@ public interface ExperimentalAppMapper {
|
||||||
// * @date 2024/7/22 0:36
|
// * @date 2024/7/22 0:36
|
||||||
// */
|
// */
|
||||||
// void delExperItem(List<Long> experItemsIds);
|
// void delExperItem(List<Long> experItemsIds);
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 查询试验设备数量
|
* 查询试验设备数量
|
||||||
// *
|
*
|
||||||
// * @param experId
|
* @param experId
|
||||||
// * @return List<Sample>
|
* @return List<Sample>
|
||||||
// * @author cwchen
|
* @author cwchen
|
||||||
// * @date 2024/7/22 10:58
|
* @date 2024/7/22 10:58
|
||||||
// */
|
*/
|
||||||
// @MapKey("id")
|
List<String> getExperDevItemsNum(Long experId);
|
||||||
// List<Map<String, String>> getExperDevItemsNum(Long experId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否处于审核流程中的数据
|
* 判断是否处于审核流程中的数据
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,7 @@ public interface PrimaryDataAppDao {
|
||||||
* @author cwchen
|
* @author cwchen
|
||||||
* @date 2024/7/22 10:58
|
* @date 2024/7/22 10:58
|
||||||
*/
|
*/
|
||||||
@MapKey("id")
|
List<String> getExperDevItemsNum(Long experId);
|
||||||
List<Map<String, String>> getExperDevItemsNum(Long experId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 试验数据详情
|
* 试验数据详情
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ public interface SamplesManageAppDao {
|
||||||
/**
|
/**
|
||||||
* 根据设备编码查询设备数量
|
* 根据设备编码查询设备数量
|
||||||
* @param devCode
|
* @param devCode
|
||||||
|
* @param sampleTools
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int getCountByDevCode(String devCode,String sampleTools);
|
int getCountByDevCode(String devCode,String sampleTools);
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,11 @@ public class ExperimentalDetailAppVo {
|
||||||
*/
|
*/
|
||||||
private String remarks;
|
private String remarks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否合格
|
||||||
|
*/
|
||||||
|
private Integer isHg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 样品
|
* 样品
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,8 @@ public interface TestReportManageAppService {
|
||||||
* 检测报告下载
|
* 检测报告下载
|
||||||
* @param data
|
* @param data
|
||||||
* @param response
|
* @param response
|
||||||
|
* @param fileNameList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void downLoadExcelZip(HttpServletResponse response, TestReportManageAppVo data, List<String> fileNameList);
|
ServerResponse downLoadExcelZip(HttpServletResponse response, TestReportManageAppVo data, List<String> fileNameList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,20 @@ public class ExperimentalAppServiceImpl implements ExperimentalAppService {
|
||||||
List<ExperimentalDetailAppVo> list = new ArrayList<>();
|
List<ExperimentalDetailAppVo> list = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
list = mapper.getDetailList(dto);
|
list = mapper.getDetailList(dto);
|
||||||
|
for (ExperimentalDetailAppVo experimentalDetailAppVo : list){
|
||||||
|
Integer isHg=0;
|
||||||
|
if (experimentalDetailAppVo.getExperId()!=null){
|
||||||
|
//查询个试验设备是否合格
|
||||||
|
List<String> mapList = mapper.getExperDevItemsNum(experimentalDetailAppVo.getExperId());
|
||||||
|
for (String s : mapList){
|
||||||
|
if ("不合格".equals(s)){
|
||||||
|
isHg=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
experimentalDetailAppVo.setIsHg(isHg);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.toString(), e);
|
log.error(e.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,16 +57,17 @@ public class PrimaryDataAppServiceImpl implements PrimaryDataAppService {
|
||||||
list = primaryDataAppDao.getDetailList(dto);
|
list = primaryDataAppDao.getDetailList(dto);
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
for (ExperimentalDetailAppVo detailVo : list) {
|
for (ExperimentalDetailAppVo detailVo : list) {
|
||||||
// 样品试验结果、样品数量、送样总数
|
Integer isHg=0;
|
||||||
List<ExperimentalDetailAppVo.Sample> sampleList = new ArrayList<>();
|
if (detailVo.getExperId()!=null){
|
||||||
if (detailVo.getExperId() != null) {
|
List<String> mapList = primaryDataAppDao.getExperDevItemsNum(detailVo.getExperId());
|
||||||
List<Map<String, String>> mapList = primaryDataAppDao.getExperDevItemsNum(detailVo.getExperId());
|
for (String s : mapList){
|
||||||
JSONArray jsonArray = new JSONArray();
|
if ("不合格".equals(s)){
|
||||||
jsonArray.addAll(mapList);
|
isHg=1;
|
||||||
sampleList = jsonArray.toJavaList(ExperimentalDetailAppVo.Sample.class);
|
break;
|
||||||
}
|
}
|
||||||
detailVo.setSampleList(sampleList);
|
}
|
||||||
detailVo.setSampleQuantity(sampleList.size());
|
}
|
||||||
|
detailVo.setIsHg(isHg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,7 @@ import com.bonus.aqgqj.app.entity.TestReportManageAppVo;
|
||||||
import com.bonus.aqgqj.app.service.TestReportManageAppService;
|
import com.bonus.aqgqj.app.service.TestReportManageAppService;
|
||||||
import com.bonus.aqgqj.basis.entity.vo.*;
|
import com.bonus.aqgqj.basis.entity.vo.*;
|
||||||
import com.bonus.aqgqj.basis.service.TestReportManageService;
|
import com.bonus.aqgqj.basis.service.TestReportManageService;
|
||||||
import com.bonus.aqgqj.utils.DateTimeHelper;
|
import com.bonus.aqgqj.utils.*;
|
||||||
import com.bonus.aqgqj.utils.ListHelper;
|
|
||||||
import com.bonus.aqgqj.utils.ServerResponse;
|
|
||||||
import com.bonus.aqgqj.utils.StringHelper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
|
@ -46,9 +43,6 @@ import java.util.zip.ZipOutputStream;
|
||||||
@Service
|
@Service
|
||||||
public class TestReportManageAppServiceImpl implements TestReportManageAppService {
|
public class TestReportManageAppServiceImpl implements TestReportManageAppService {
|
||||||
|
|
||||||
@Value("${file.windwos.upload_path}")
|
|
||||||
private String uploadPath;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestReportManageAppDao testReportManageAppDao;
|
private TestReportManageAppDao testReportManageAppDao;
|
||||||
|
|
||||||
|
|
@ -231,10 +225,12 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downLoadExcelZip(HttpServletResponse response, TestReportManageAppVo data,List<String> fileNameList) {
|
public ServerResponse downLoadExcelZip(HttpServletResponse response, TestReportManageAppVo data,List<String> fileNameList) {
|
||||||
List<File> fileList = new ArrayList();
|
List<File> fileList = new ArrayList();
|
||||||
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
|
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
|
||||||
List<TestReportManageAppVo> list = jsonArray.toJavaList(TestReportManageAppVo.class);
|
List<TestReportManageAppVo> list = jsonArray.toJavaList(TestReportManageAppVo.class);
|
||||||
|
String fileNames="检测报告_" + System.currentTimeMillis()+".zip";
|
||||||
|
String outputZipFilePath = SystemUtils.getUploadPath()+ fileNames;
|
||||||
if (list != null && list.size() > 0) {
|
if (list != null && list.size() > 0) {
|
||||||
try {
|
try {
|
||||||
for (TestReportManageAppVo testReportManageAppVo : list) {
|
for (TestReportManageAppVo testReportManageAppVo : list) {
|
||||||
|
|
@ -251,11 +247,14 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
downloadZip(response, fileList);
|
// downloadZip(response, fileList);
|
||||||
|
zipFiles(fileList, outputZipFilePath);
|
||||||
|
return ServerResponse.createSuccess("statics/"+fileNames);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("zip导出错误-异常信息", e);
|
log.error("zip导出错误-异常信息", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ServerResponse.createErroe("下载失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -442,7 +441,8 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
|
||||||
|
|
||||||
AtomicInteger row = new AtomicInteger(5);
|
AtomicInteger row = new AtomicInteger(5);
|
||||||
AtomicInteger cellNum = new AtomicInteger(0);
|
AtomicInteger cellNum = new AtomicInteger(0);
|
||||||
AtomicInteger serialNumber = new AtomicInteger(1); // 用于追踪序号
|
// 用于追踪序号
|
||||||
|
AtomicInteger serialNumber = new AtomicInteger(1);
|
||||||
|
|
||||||
if (ListHelper.isNotEmpty(devList)) {
|
if (ListHelper.isNotEmpty(devList)) {
|
||||||
devList.forEach(dev -> {
|
devList.forEach(dev -> {
|
||||||
|
|
@ -497,7 +497,6 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//
|
|
||||||
row.set(row.get() + 1);
|
row.set(row.get() + 1);
|
||||||
Row row8= sheet.createRow(row.get());
|
Row row8= sheet.createRow(row.get());
|
||||||
Cell cell81 = row8.createCell(0);
|
Cell cell81 = row8.createCell(0);
|
||||||
|
|
@ -570,7 +569,7 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
|
||||||
|
|
||||||
|
|
||||||
if (type==1){
|
if (type==1){
|
||||||
String fileName = uploadPath + "检测报告_" + bean.getReportCode() + "_"+DateTimeHelper.getNowDMS()+".xlsx";
|
String fileName =SystemUtils.getUploadPath() + "检测报告_" + bean.getReportCode() + "_"+DateTimeHelper.getNowDMS()+".xlsx";
|
||||||
File file = new File(fileName);
|
File file = new File(fileName);
|
||||||
//生成文件夹
|
//生成文件夹
|
||||||
if (!file.getParentFile().exists()) {
|
if (!file.getParentFile().exists()) {
|
||||||
|
|
@ -715,4 +714,29 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void zipFiles(List<File> 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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,9 @@ public class SystemUtils {
|
||||||
public static String getUploadPath() {
|
public static String getUploadPath() {
|
||||||
String os = getSystem();
|
String os = getSystem();
|
||||||
System.err.println("当前系统是=" + os);
|
System.err.println("当前系统是=" + os);
|
||||||
if (os.equals("windows")) {
|
if ("windows".equals(os)) {
|
||||||
return windowsPath;
|
return windowsPath;
|
||||||
} else if (os.equals("linux")) {
|
} else if ("linux".equals(os)) {
|
||||||
return linuxPath;
|
return linuxPath;
|
||||||
} else {
|
} else {
|
||||||
return windowsPath;
|
return windowsPath;
|
||||||
|
|
|
||||||
|
|
@ -525,9 +525,8 @@
|
||||||
SELECT id FROM tb_exper_items WHERE exper_id = #{id}
|
SELECT id FROM tb_exper_items WHERE exper_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
<!--查询试验设备数量-->
|
<!--查询试验设备数量-->
|
||||||
<select id="getExperDevItemsNum" resultType="java.util.Map">
|
<select id="getExperDevItemsNum" resultType="java.lang.String">
|
||||||
SELECT dev_code AS devCode,
|
SELECT case is_hg WHEN '1' THEN '不合格'
|
||||||
case is_hg WHEN '1' THEN '不合格'
|
|
||||||
WHEN '0' THEN '合格'
|
WHEN '0' THEN '合格'
|
||||||
ELSE '不合格' END AS testResult
|
ELSE '不合格' END AS testResult
|
||||||
FROM tb_exper_dev
|
FROM tb_exper_dev
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,8 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--查询试验设备数量-->
|
<!--查询试验设备数量-->
|
||||||
<select id="getExperDevItemsNum" resultType="java.util.Map">
|
<select id="getExperDevItemsNum" resultType="java.lang.String">
|
||||||
SELECT dev_code AS devCode,
|
SELECT case is_hg WHEN '1' THEN '不合格'
|
||||||
case is_hg WHEN '1' THEN '不合格'
|
|
||||||
WHEN '0' THEN '合格'
|
WHEN '0' THEN '合格'
|
||||||
ELSE '不合格' END AS testResult
|
ELSE '不合格' END AS testResult
|
||||||
FROM tb_exper_dev
|
FROM tb_exper_dev
|
||||||
|
|
|
||||||
|
|
@ -66,11 +66,12 @@
|
||||||
</insert>
|
</insert>
|
||||||
<!--登录查询用户-->
|
<!--登录查询用户-->
|
||||||
<select id="getUser" parameterType="String" resultType="com.bonus.aqgqj.model.SysUser">
|
<select id="getUser" parameterType="String" resultType="com.bonus.aqgqj.model.SysUser">
|
||||||
select t.id,t.user_name as username,t.login_name as loginName,t.phone,
|
select t.id,t.user_name as username,t.login_name as loginName,t.phone,t.org_id as orgId,so.org_name as orgName,
|
||||||
t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser,
|
t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser,
|
||||||
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId
|
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId
|
||||||
from sys_user t
|
from sys_user t
|
||||||
LEFT JOIN sys_role sr ON t.role_id = sr.role_id AND sr.del_flag = 0
|
LEFT JOIN sys_role sr ON t.role_id = sr.role_id AND sr.del_flag = 0
|
||||||
|
left join sys_org so ON so.org_id = t.org_id and so.del_flag = 0
|
||||||
where t.login_name = #{username}
|
where t.login_name = #{username}
|
||||||
and t.del_flag = 0
|
and t.del_flag = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue