app试验管理、审查管理、检测报告管理、合格证管理

This commit is contained in:
hayu 2024-08-16 19:53:31 +08:00
parent 3220ec32c7
commit 308c11f75b
17 changed files with 149 additions and 65 deletions

21
pom.xml
View File

@ -37,6 +37,27 @@
<!-- </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>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>

View File

@ -107,13 +107,13 @@ public class ExperimentalAppController {
* 试验数据详情
*/
@PostMapping(value = "viewTestData")
@DecryptAndVerify(decryptedClass = ParamsAppDto.class)//加解密统一管理
@DecryptAndVerify(decryptedClass = ParamsAppDto.class)
public ServerResponse viewTestData(EncryptedReq<ParamsAppDto> 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<ParamsAppDto> data) {

View File

@ -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<ParamsDto> dto) {
public ServerResponse downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq<ParamsDto> dto) {
List<File> fileList = new ArrayList();
List<String> 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<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());
}
/**
* 第一行表头

View File

@ -263,10 +263,10 @@ public class TestReportManageAppController {
*/
@PostMapping(value = "downLoadExcelZip")
@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();
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("下载失败");
}

View File

@ -122,6 +122,7 @@ public interface CertificateAppDao {
/**
* 根据设备编码查询设备数量
* @param devCode
* @param sampleTools
* @return
*/
int getCountByDevCode(String devCode,String sampleTools);

View File

@ -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<Long> experItemsIds);
//
// /**
// * 查询试验设备数量
// *
// * @param experId
// * @return List<Sample>
// * @author cwchen
// * @date 2024/7/22 10:58
// */
// @MapKey("id")
// List<Map<String, String>> getExperDevItemsNum(Long experId);
/**
* 查询试验设备数量
*
* @param experId
* @return List<Sample>
* @author cwchen
* @date 2024/7/22 10:58
*/
List<String> getExperDevItemsNum(Long experId);
/**
* 判断是否处于审核流程中的数据

View File

@ -44,8 +44,7 @@ public interface PrimaryDataAppDao {
* @author cwchen
* @date 2024/7/22 10:58
*/
@MapKey("id")
List<Map<String, String>> getExperDevItemsNum(Long experId);
List<String> getExperDevItemsNum(Long experId);
/**
* 试验数据详情

View File

@ -129,6 +129,7 @@ public interface SamplesManageAppDao {
/**
* 根据设备编码查询设备数量
* @param devCode
* @param sampleTools
* @return
*/
int getCountByDevCode(String devCode,String sampleTools);

View File

@ -95,6 +95,11 @@ public class ExperimentalDetailAppVo {
*/
private String remarks;
/**
* 是否合格
*/
private Integer isHg;
/**
* 样品
*/

View File

@ -82,7 +82,8 @@ public interface TestReportManageAppService {
* 检测报告下载
* @param data
* @param response
* @param fileNameList
* @return
*/
void downLoadExcelZip(HttpServletResponse response, TestReportManageAppVo data, List<String> fileNameList);
ServerResponse downLoadExcelZip(HttpServletResponse response, TestReportManageAppVo data, List<String> fileNameList);
}

View File

@ -67,6 +67,20 @@ public class ExperimentalAppServiceImpl implements ExperimentalAppService {
List<ExperimentalDetailAppVo> list = new ArrayList<>();
try {
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) {
log.error(e.toString(), e);
}

View File

@ -57,16 +57,17 @@ public class PrimaryDataAppServiceImpl implements PrimaryDataAppService {
list = primaryDataAppDao.getDetailList(dto);
if (CollectionUtils.isNotEmpty(list)) {
for (ExperimentalDetailAppVo detailVo : list) {
// 样品试验结果样品数量送样总数
List<ExperimentalDetailAppVo.Sample> sampleList = new ArrayList<>();
if (detailVo.getExperId() != null) {
List<Map<String, String>> mapList = primaryDataAppDao.getExperDevItemsNum(detailVo.getExperId());
JSONArray jsonArray = new JSONArray();
jsonArray.addAll(mapList);
sampleList = jsonArray.toJavaList(ExperimentalDetailAppVo.Sample.class);
Integer isHg=0;
if (detailVo.getExperId()!=null){
List<String> mapList = primaryDataAppDao.getExperDevItemsNum(detailVo.getExperId());
for (String s : mapList){
if ("不合格".equals(s)){
isHg=1;
break;
}
detailVo.setSampleList(sampleList);
detailVo.setSampleQuantity(sampleList.size());
}
}
detailVo.setIsHg(isHg);
}
}
} catch (Exception e) {

View File

@ -9,10 +9,7 @@ import com.bonus.aqgqj.app.entity.TestReportManageAppVo;
import com.bonus.aqgqj.app.service.TestReportManageAppService;
import com.bonus.aqgqj.basis.entity.vo.*;
import com.bonus.aqgqj.basis.service.TestReportManageService;
import com.bonus.aqgqj.utils.DateTimeHelper;
import com.bonus.aqgqj.utils.ListHelper;
import com.bonus.aqgqj.utils.ServerResponse;
import com.bonus.aqgqj.utils.StringHelper;
import com.bonus.aqgqj.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
@ -46,9 +43,6 @@ import java.util.zip.ZipOutputStream;
@Service
public class TestReportManageAppServiceImpl implements TestReportManageAppService {
@Value("${file.windwos.upload_path}")
private String uploadPath;
@Resource
private TestReportManageAppDao testReportManageAppDao;
@ -231,10 +225,12 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
}
@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();
JSONArray jsonArray = JSONObject.parseArray(data.getParamsList());
List<TestReportManageAppVo> list = jsonArray.toJavaList(TestReportManageAppVo.class);
String fileNames="检测报告_" + System.currentTimeMillis()+".zip";
String outputZipFilePath = SystemUtils.getUploadPath()+ fileNames;
if (list != null && list.size() > 0) {
try {
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){
log.error("zip导出错误-异常信息", e);
}
}
return ServerResponse.createErroe("下载失败");
}
/**
@ -442,7 +441,8 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
AtomicInteger row = new AtomicInteger(5);
AtomicInteger cellNum = new AtomicInteger(0);
AtomicInteger serialNumber = new AtomicInteger(1); // 用于追踪序号
// 用于追踪序号
AtomicInteger serialNumber = new AtomicInteger(1);
if (ListHelper.isNotEmpty(devList)) {
devList.forEach(dev -> {
@ -497,7 +497,6 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
});
});
}
//
row.set(row.get() + 1);
Row row8= sheet.createRow(row.get());
Cell cell81 = row8.createCell(0);
@ -570,7 +569,7 @@ public class TestReportManageAppServiceImpl implements TestReportManageAppServic
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);
//生成文件夹
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());
}
}

View File

@ -63,9 +63,9 @@ public class SystemUtils {
public static String getUploadPath() {
String os = getSystem();
System.err.println("当前系统是=" + os);
if (os.equals("windows")) {
if ("windows".equals(os)) {
return windowsPath;
} else if (os.equals("linux")) {
} else if ("linux".equals(os)) {
return linuxPath;
} else {
return windowsPath;

View File

@ -525,9 +525,8 @@
SELECT id FROM tb_exper_items WHERE exper_id = #{id}
</select>
<!--查询试验设备数量-->
<select id="getExperDevItemsNum" resultType="java.util.Map">
SELECT dev_code AS devCode,
case is_hg WHEN '1' THEN '不合格'
<select id="getExperDevItemsNum" resultType="java.lang.String">
SELECT case is_hg WHEN '1' THEN '不合格'
WHEN '0' THEN '合格'
ELSE '不合格' END AS testResult
FROM tb_exper_dev

View File

@ -71,9 +71,8 @@
</select>
<!--查询试验设备数量-->
<select id="getExperDevItemsNum" resultType="java.util.Map">
SELECT dev_code AS devCode,
case is_hg WHEN '1' THEN '不合格'
<select id="getExperDevItemsNum" resultType="java.lang.String">
SELECT case is_hg WHEN '1' THEN '不合格'
WHEN '0' THEN '合格'
ELSE '不合格' END AS testResult
FROM tb_exper_dev

View File

@ -66,11 +66,12 @@
</insert>
<!--登录查询用户-->
<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,
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId
from sys_user t
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}
and t.del_flag = 0
</select>