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

This commit is contained in:
hayu 2024-08-14 18:37:03 +08:00
parent 4dd1566fdb
commit 66652b9915
20 changed files with 2057 additions and 245 deletions

View File

@ -86,15 +86,15 @@ public class ExperimentalAppController {
public ServerResponse addTestData(EncryptedReq<TestAppVo> data) {
return service.addTestData(data.getData());
}
//
// @PostMapping(value = "editTestData")
// @DecryptAndVerify(decryptedClass = TestAppVo.class)//加解密统一管理
// @LogAnnotation(operModul = "试验详情管理", operation = "修改试验数据", operDesc = "业务级事件", operType = "修改")
// // @PreAuthorize("@pms.hasPermission('sys:experimentalTest:edit')")
// public ServerResponse editTestData(EncryptedReq<TestAppVo> data) {
// return service.editTestData(data.getData());
// }
//
@PostMapping(value = "editTestData")
@DecryptAndVerify(decryptedClass = TestAppVo.class)//加解密统一管理
@LogAnnotation(operModul = "试验详情管理", operation = "修改试验数据", operDesc = "业务级事件", operType = "修改")
// @PreAuthorize("@pms.hasPermission('sys:experimentalTest:edit')")
public ServerResponse editTestData(EncryptedReq<TestAppVo> data) {
return service.editTestData(data.getData());
}
// @PostMapping(value = "delTestData")
// @DecryptAndVerify(decryptedClass = ParamsAppDto.class)//加解密统一管理
// @LogAnnotation(operModul = "试验详情管理", operation = "删除试验数据", operDesc = "业务级事件", operType = "删除")

View File

@ -109,8 +109,8 @@ public class PrimaryDataAppController {
}
@PostMapping(value = "exportOriginalRecordExcel")
@DecryptAndVerify(decryptedClass = ParamsDto.class) // 加解密统一管理
public ResponseEntity<String> exportExcel(HttpServletRequest request, HttpServletResponse response, EncryptedReq<ParamsDto> dto) {
@DecryptAndVerify(decryptedClass = ParamsDto.class)
public ServerResponse exportExcel(EncryptedReq<ParamsDto> dto) {
try {
ServerResponse serverResponse = primaryDataAppService.viewTestData(dto.getData());
TestVo vo = (TestVo) serverResponse.getData();
@ -164,10 +164,10 @@ public class PrimaryDataAppController {
// 将字节数组编码为 Base64 字符串
String base64Excel = Base64.getEncoder().encodeToString(excelBytes);
// 返回 Base64 字符串
return ResponseEntity.ok(base64Excel);
return ServerResponse.createSuccess(base64Excel);
} catch (Exception e) {
log.error("excel文档导出错误-异常信息", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("导出错误");
return ServerResponse.createErroe("查看失败");
}
}
@ -183,7 +183,7 @@ public class PrimaryDataAppController {
* @date 2024/7/28 17:30
*/
@PostMapping(value = "downLoadExcelZip")
@DecryptAndVerify(decryptedClass = ParamsDto.class)//加解密统一管理
@DecryptAndVerify(decryptedClass = ParamsDto.class)
public void downLoadExcelZip(HttpServletRequest request, HttpServletResponse response, EncryptedReq<ParamsDto> dto) {
List<File> fileList = new ArrayList();
List<String> fileNameList = new ArrayList();

View File

@ -0,0 +1,265 @@
package com.bonus.aqgqj.app.controller;
import com.bonus.aqgqj.annotation.DecryptAndVerify;
import com.bonus.aqgqj.annotation.LogAnnotation;
import com.bonus.aqgqj.app.entity.TestReportManageAppVo;
import com.bonus.aqgqj.app.service.TestReportManageAppService;
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
import com.bonus.aqgqj.basis.entity.vo.ConfigItemsVo;
import com.bonus.aqgqj.basis.entity.vo.ExperDevVo;
import com.bonus.aqgqj.basis.entity.vo.TestVo;
import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.utils.DateTimeHelper;
import com.bonus.aqgqj.utils.ExcelStyleUtil;
import com.bonus.aqgqj.utils.ServerResponse;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import freemarker.template.Configuration;
import freemarker.template.Template;
import io.swagger.annotations.Api;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 检测报告管理
* @author hay
*/
@Api(tags = "检测报告管理")
@RestController
@RequestMapping("/app/testReport/")
public class TestReportManageAppController {
private static final Logger log = LoggerFactory.getLogger("adminLogger");
@Autowired
private TestReportManageAppService service;
@PostMapping(value = "getList")
@DecryptAndVerify(decryptedClass = TestReportManageAppVo.class)
@LogAnnotation(operModul = "检测报告管理-检测报告管理", operation = "查询用列表", operDesc = "业务级事件",operType="查询")
// @PreAuthorize("@pms.hasPermission('sys:testReport:query')" )
public ServerResponse listUsers(EncryptedReq<TestReportManageAppVo> data) {
PageHelper.startPage(data.getData().getPage(), data.getData().getLimit());
try {
List<TestReportManageAppVo> list = service.list(data.getData());
PageInfo<TestReportManageAppVo> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccessPage(pageInfo,data.getData().getPage(),data.getData().getLimit());
} catch (Exception e) {
log.error(e.toString(),e);
}
return ServerResponse.createErrorPage(data.getData().getPage(),data.getData().getLimit());
}
@PostMapping(value = "getDetailsList")
@DecryptAndVerify(decryptedClass = TestReportManageAppVo.class)
@LogAnnotation(operModul = "检测报告管理-检测报告管理详情", operation = "查询用列表", operDesc = "业务级事件",operType="查询")
// @PreAuthorize("@pms.hasPermission('sys:testReport:query')" )
public ServerResponse getDetailsList(EncryptedReq<TestReportManageAppVo> data) {
PageHelper.startPage(data.getData().getPage(), data.getData().getLimit());
try {
List<TestReportManageAppVo> list = service.getDetailsList(data.getData());
PageInfo<TestReportManageAppVo> pageInfo = new PageInfo<>(list);
return ServerResponse.createSuccessPage(pageInfo,data.getData().getPage(),data.getData().getLimit());
} catch (Exception e) {
log.error(e.toString(),e);
}
return ServerResponse.createErrorPage(data.getData().getPage(),data.getData().getLimit());
}
@PostMapping(value = "all")
@LogAnnotation(operModul = "检测报告管理", operation = "查询所有工器具", operDesc = "业务级事件",operType="查询")
public ServerResponse getAll() {
try {
List<TestReportManageAppVo> list = service.listTools();
return ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
@PostMapping(value = "allCustomName")
@LogAnnotation(operModul = "检测报告管理", operation = "查询所有单位", operDesc = "业务级事件",operType="查询")
public ServerResponse getAllCustomName() {
try {
List<TestReportManageAppVo> list = service.getAllCustomName();
return ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
@PostMapping(value = "getTeamSelected")
@LogAnnotation(operModul = "检测报告管理", operation = "查询所有班组", operDesc = "业务级事件",operType="查询")
public ServerResponse getToolsSelected() {
try {
List<TestReportManageAppVo> list = service.getTeamSelected();
return ServerResponse.createSuccess(list);
}catch (Exception e){
log.error(e.toString(),e);
}
return ServerResponse.createErroe("操作失败");
}
@PostMapping(value = "viewTestData")
@DecryptAndVerify(decryptedClass = TestReportManageAppVo.class)
@LogAnnotation(operModul = "检测报告管理", operation = "试验数据详情", operDesc = "业务级事件", operType = "查询")
public ServerResponse viewTestData(EncryptedReq<TestReportManageAppVo> data) {
return service.viewTestData(data.getData());
}
/**
* 下载合格证--word
*/
@GetMapping("/downloadReport")
public void downloadReport(HttpServletRequest request, HttpServletResponse response){
// 处理请求参数
TestReportManageAppVo vo = new TestReportManageAppVo();
vo.setId(Integer.valueOf(request.getParameter("id")));
vo.setDepartmentId(Integer.valueOf(request.getParameter("departmentId")));
vo.setSampleTools(request.getParameter("sampleTools"));
vo.setIsHg(request.getParameter("isHg"));
TestReportManageAppVo bean = service.downloadCertificateList(vo);
// 准备数据
Map<String, Object> map = new HashMap<>();
map.put("submitLocation", isNull(bean.getSubmitLocation()));
map.put("sampleTools", isNull(bean.getSampleTools()));
map.put("devModule", isNull(bean.getDevModule()));
map.put("devCode", isNull(bean.getDevCode()));
map.put("experTime", isNull(bean.getExperTime()));
map.put("nextExperTime", isNull(bean.getNextExperTime()));
map.put("experUser", isNull(bean.getExperUser()));
map.put("isHg", isNull(bean.getIsHg()));
map.put("customName", isNull(bean.getCustomName()));
Configuration cfg = new Configuration(Configuration.getVersion());
cfg.setClassForTemplateLoading(this.getClass(), "/temple");
File tempFile = null;
OutputStream out = null;
FileInputStream fis = null;
try {
// 设置响应头
response.setCharacterEncoding("utf-8");
response.setContentType("application/msword");
response.setHeader("Content-Disposition", "attachment;filename="
.concat(String.valueOf(URLEncoder.encode("合格证" + DateTimeHelper.getNowDMS() + ".doc", "UTF-8"))));
// 创建临时文件
tempFile = createDoc(map, cfg.getTemplate("certificate.ftl"));
// 读取文件并写入响应
fis = new FileInputStream(tempFile);
out = response.getOutputStream();
byte[] buffer = new byte[512];
int bytesToRead;
while ((bytesToRead = fis.read(buffer)) != -1) {
out.write(buffer, 0, bytesToRead);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
// 释放资源
try {
if (fis != null) {
fis.close();
}
if (out != null) {
out.flush();
out.close();
}
// 删除临时文件
if (tempFile != null && tempFile.exists()) {
tempFile.delete();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
/**
* 创建临时word文件
*/
private File createDoc(Map<String, Object> map, Template template) {
File f = null;
try {
// 创建临时文件
f = File.createTempFile("certificate_", ".doc");
Writer w = new OutputStreamWriter(new FileOutputStream(f), "utf-8");
template.process(map, w);
w.close();
} catch (Exception ex) {
ex.printStackTrace();
}
return f;
}
/**
* 判断字符串是否为空或者null如果是则返回''否则返回原字符串
*/
public static String isNull(String str) {
if (str == null || "".equals(str)) {
return "";
}
return str;
}
/**
* 一级页面--检测报告打包下载
*/
@GetMapping("/download")
public ResponseEntity<FileSystemResource> downloadFile(HttpServletRequest request) {
File tempZipFile = null;
try {
// Return the ZIP file
return service.downloadFile(request, tempZipFile);
} catch (IOException e) {
e.printStackTrace();
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}finally {
// Ensure the temporary file is deleted if not already done
if (tempZipFile != null && tempZipFile.exists()) {
tempZipFile.delete();
}
}
}
/**
* 检测报告附页Excel文件生成转base64
*/
@PostMapping(value = "testReportExcelBase64")
@DecryptAndVerify(decryptedClass = TestReportManageAppVo.class)
public ServerResponse testReportExcelBase64(EncryptedReq<TestReportManageAppVo> bean) {
return service.testReportExcelBase64(bean.getData());
}
}

View File

@ -109,4 +109,12 @@ public interface ExamineAppMapper {
* @date 2024/7/30 18:50
*/
String getExperIsErValue(@Param("type") int type,@Param("id") Long id);
/**
* 根据sampleId查询试验id
* @param id
* @param audtiStatus
* @return
*/
List<ExperimentalAppVo> getDetailIdBySampleId(@Param("id") Long id,@Param("audtiStatus") String audtiStatus);
}

View File

@ -169,7 +169,7 @@ public interface ExperimentalAppMapper {
* @author cwchen
* @date 2024/7/21 19:48
*/
void addExperDevItem(List<ExperDevItemVo> experDevItemVos);
void addExperDevItem(List<ExperDevItemAppVo> experDevItemVos);
/**
* 试验数据详情
@ -242,46 +242,46 @@ public interface ExperimentalAppMapper {
*/
List<ExperDevAppVo> getExperDev(ParamsAppDto dto);
// /**
// * 修改试验信息数据
// *
// * @param vo
// * @return void
// * @author cwchen
// * @date 2024/7/22 0:02
// */
// void updateExper(TestAppVo vo);
//
// /**
// * 获取试验样品设备ID
// *
// * @param id
// * @return List<Long>
// * @author cwchen
// * @date 2024/7/22 0:18
// */
// List<Long> getExperDevIds(Long id);
//
// /**
// * 获取设备试验项信息ID
// *
// * @param list
// * @return List<Long>
// * @author cwchen
// * @date 2024/7/22 0:18
// */
// List<Long> getExperDevItems(List<Long> list);
//
// /**
// * 删除试验依据
// *
// * @param id
// * @return void
// * @author cwchen
// * @date 2024/7/22 0:24
// */
// void delConfigBasis(Long id);
//
/**
* 修改试验信息数据
*
* @param vo
* @return void
* @author cwchen
* @date 2024/7/22 0:02
*/
void updateExper(TestAppVo vo);
/**
* 获取试验样品设备ID
*
* @param id
* @return List<Long>
* @author cwchen
* @date 2024/7/22 0:18
*/
List<Long> getExperDevIds(Long id);
/**
* 获取设备试验项信息ID
*
* @param list
* @return List<Long>
* @author cwchen
* @date 2024/7/22 0:18
*/
List<Long> getExperDevItems(List<Long> list);
/**
* 删除试验依据
*
* @param id
* @return void
* @author cwchen
* @date 2024/7/22 0:24
*/
void delConfigBasis(Long id);
// /**
// * 删除试验设备
// *
@ -291,37 +291,37 @@ public interface ExperimentalAppMapper {
// * @date 2024/7/22 0:24
// */
// void delExperConfigDev(Long id);
//
// /**
// * 删除试验样品设备
// *
// * @param id
// * @return void
// * @author cwchen
// * @date 2024/7/22 0:24
// */
// void delExperDev(Long id);
//
// /**
// * 删除设备试验项信息
// *
// * @param list
// * @return void
// * @author cwchen
// * @date 2024/7/22 0:24
// */
// void delExperDevItems(List<Long> list);
//
// /**
// * 删除设备试验项数据
// *
// * @param list
// * @return void
// * @author cwchen
// * @date 2024/7/22 0:24
// */
// void delExperDevItem(List<Long> list);
//
/**
* 删除试验样品设备
*
* @param id
* @return void
* @author cwchen
* @date 2024/7/22 0:24
*/
void delExperDev(Long id);
/**
* 删除设备试验项信息
*
* @param list
* @return void
* @author cwchen
* @date 2024/7/22 0:24
*/
void delExperDevItems(List<Long> list);
/**
* 删除设备试验项数据
*
* @param list
* @return void
* @author cwchen
* @date 2024/7/22 0:24
*/
void delExperDevItem(List<Long> list);
// /**
// * 删除试验信息
// *
@ -372,16 +372,16 @@ public interface ExperimentalAppMapper {
// */
// @MapKey("id")
// List<Map<String, String>> getExperDevItemsNum(Long experId);
//
// /**
// * 判断是否处于审核流程中的数据
// *
// * @param id
// * @return int
// * @author cwchen
// * @date 2024/7/22 14:13
// */
// int isCheck(Long id);
/**
* 判断是否处于审核流程中的数据
*
* @param id
* @return int
* @author cwchen
* @date 2024/7/22 14:13
*/
int isCheck(Long id);
/**
* 判断提交数据中是否存在流程数据或者存在待试验项
@ -396,12 +396,12 @@ public interface ExperimentalAppMapper {
/**
* 更新收样表中的状态为待审阅
*
* @param list
* @param id
* @return void
* @author cwchen
* @date 2024/7/22 15:33
*/
void updateSampleStatus(List<Long> list);
void updateSampleStatus(Long id);
/**
* 更新试验表中数据为待审阅
@ -447,4 +447,11 @@ public interface ExperimentalAppMapper {
* @param vo
*/
void updateExperMony(TestAppVo vo);
/**
* 获取是否全部提交审阅
* @param id
* @return int
*/
int isAllSubmit(Long id);
}

View File

@ -0,0 +1,129 @@
package com.bonus.aqgqj.app.dao;
import com.bonus.aqgqj.app.entity.TestReportManageAppVo;
import com.bonus.aqgqj.basis.entity.vo.ConfigItemVo;
import com.bonus.aqgqj.basis.entity.vo.ConfigItemsVo;
import com.bonus.aqgqj.basis.entity.vo.ExperBasisVo;
import com.bonus.aqgqj.basis.entity.vo.ExperDevVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* @author hay
*/
@Mapper
public interface TestReportManageAppDao {
/**
* 查询列表
* @param bean
* @return
*/
List<TestReportManageAppVo> list(TestReportManageAppVo bean);
/**
* 获取工器具
* @param id
* @return
*/
String getSampleTools(Integer id);
/**
* 获取详情列表
* @param data
* @return
*/
List<TestReportManageAppVo> getDetailsList(TestReportManageAppVo data);
/**
* 获取工器具
* @return
*/
List<TestReportManageAppVo> listTools();
/**
* 获取所有单位名称
* @return
*/
List<TestReportManageAppVo> getAllCustomName();
/**
* 获取设备编码
* @param nowDate
* @return
*/
String selectCustomerCode(String nowDate);
/**
* 获取班组
* @return
*/
List<TestReportManageAppVo> getTeamSelected();
/**
* 获取当前年月 报告编号
* @param nowDate
* @return
*/
String getReportCode(String nowDate);
/**
* 修改报告编号
* @param dto
* @return
*/
int updateReportCode(TestReportManageAppVo dto);
/**
* 获取设备编号与结果
* @param dto
* @return
*/
@MapKey("devCode")
List<Map<String, String>> getExperDevItems(TestReportManageAppVo dto);
/**
* 试验项信息
* @param dto
* @return
*/
List<ConfigItemsVo> getExperItems(TestReportManageAppVo dto);
/**
* 试验项内容信息
* @param id
* @return
*/
List<ConfigItemVo> getExperItem(Long id);
/**
* 试验样品设备
* @param dto
* @return
*/
List<ExperDevVo> getExperDev(TestReportManageAppVo dto);
/**
* 试验依据信息
* @param dto
* @return
*/
List<ExperBasisVo> getConfigBasis(TestReportManageAppVo dto);
/**
* 获取试验信息
* @param dto
* @return
*/
TestReportManageAppVo getTestData(TestReportManageAppVo dto);
/**
* 获取证书列表
* @param data
* @return
*/
TestReportManageAppVo downloadCertificateList(TestReportManageAppVo data);
}

View File

@ -25,6 +25,8 @@ public class ExperDevAppVo {
@NotNull(message = "收样设备id不能为空", groups = {Query.class})
private Long devId;
private String devTypeName;
/**客户自编号*/
@NotBlank(message = "客户自编号不能为空", groups = {Query.class})
@Length(max = 32, message = "编号字符长度不能超过32", groups = {Query.class})

View File

@ -0,0 +1,27 @@
package com.bonus.aqgqj.app.entity;
import lombok.Data;
/**
* @className:ExperDevItemVo
* @author:cwchen
* @date:2024-07-21-19:03
* @version:1.0
* @description:设备试验项内容数据-vo
*/
@Data
public class ExperDevItemAppVo {
/**id*/
private Long id;
/**试验项id*/
private Long itemsId;
/**试验内容id*/
private Long itemId;
/**实验设备id*/
private Long devId;
/** 试验项目名称*/
private String itemName;
/**试验项值*/
private String itemVal;
}

View File

@ -17,6 +17,12 @@ public class ExperimentalAppVo {
* id
*/
private Long id;
/**
* 试验id
*/
private String ids;
/**
* 送样单位
*/

View File

@ -62,9 +62,24 @@ public class ExperimentalDetailAppVo {
private String causeOfRejection;
/**
* 状态
* 状态 默认0 (实验完成)待提交 1 待审阅 2 待审核 3 待审批 4 审批通过
*/
private String status;
private Integer status;
/**
* 审核状态 0 待审核 1审核通过 2 审阅不通过 3审核不同过 4审批未通过
*/
private Integer auditStatus;
/**
* 是否二次审阅 null:不是 1.
*/
private Integer isEr;
/**
* 状态结果 待提交待审阅待重新审阅
*/
private String statusResult;
/**
* 试验人员

View File

@ -0,0 +1,235 @@
package com.bonus.aqgqj.app.entity;
import com.bonus.aqgqj.base.entity.PageEntity;
import com.bonus.aqgqj.basis.entity.vo.ConfigItemsVo;
import com.bonus.aqgqj.basis.entity.vo.ExperBasisVo;
import com.bonus.aqgqj.basis.entity.vo.ExperDevVo;
import com.bonus.aqgqj.basis.entity.vo.ExperimentalDetailVo;
import lombok.Data;
import java.util.List;
/**
* 工器具个体管理
* @author hay
*/
@Data
public class TestReportManageAppVo extends PageEntity {
private static final long serialVersionUID = -6525908145032868837L;
private Integer id;
private String ids;
/**
* 名称
*/
private String name;
/**
* 送样单位id
*/
private Integer customId;
/**
* 送样单位
*/
private String customName;
/**
* 送样部门id
*/
private Integer departmentId;
/**
* 送样部门
*/
private String sampleDepartment;
/**
* 送样人
*/
private String sampleUser;
/**
* 送样时间
*/
private String sampleTime;
/**
* 送样设备id
*/
private Integer sampleToolsId;
/**
* 送样设备
*/
private String sampleTools;
/**
* 收样人
*/
private String collectSamplesUser;
/**
* 收样时间
*/
private String collectSamplesTime;
/**
* 班组Id
*/
private Integer teamId;
/**
* 班组
*/
private String teamName;
/**
* 设备编号 (手填/扫码)
*/
private String devCode;
/**
* 设备类型编码
*/
private String devTypeCode;
/**
* 客户自编号设备编码--自动生成
*/
private String customerCode;
/**
* 生产厂家
*/
private String factoryName;
/**
* 生产日期
*/
private String manufactureDate;
/**
* 设备规格
*/
private String devModule;
/**
* 试验日期
*/
private String experTime;
/**
* 下次试验日期
*/
private String nextExperTime;
/**
* 试验人员
*/
private String experUser;
/**
* 试验结论
*/
private String experConclu;
/**
* 关键字
*/
private String keyWord;
private String paramsList;
/**
* 创建人
*/
private Integer createBy;
/**
* 试验项内容数量
*/
private Integer experItemNum;
/**
* 样品数量
*/
private Integer devNum;
/**
* 报告编号
*/
private String reportCode;
/**
* 是否合格
*/
private String isHg;
/**
* 检测时间
*/
private String detectionTime;
private List<ExperimentalDetailVo.Sample> sampleList;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
/**
* 备注
*/
private String remarks;
/**
* 试验标准
*/
private String experStand;
/**
* 检测设备
*/
private String devTypeName;
/**
* 技术要求
*/
private String technicalRequirements;
/**
* 试验依据
*/
private List<ExperBasisVo> basisVos;
/**
* 试验项
*/
private List<ConfigItemsVo> configItemsVos;
/**
* 试验样品设备list
*/
private List<ExperDevVo> experDevVos;
/**
* 实验地点
*/
private String submitLocation;
/**
* 生成时间
*/
private String createTime;
}

View File

@ -53,17 +53,17 @@ public interface ExperimentalAppService {
* @date 2024/7/20 15:42
*/
ServerResponse addTestData(TestAppVo data);
//
// /**
// * 修改试验数据
// *
// * @param data
// * @return ServerResponse
// * @author cwchen
// * @date 2024/7/21 20:06
// */
// ServerResponse editTestData(TestAppVo data);
//
/**
* 修改试验数据
*
* @param data
* @return ServerResponse
* @author cwchen
* @date 2024/7/21 20:06
*/
ServerResponse editTestData(TestAppVo data);
// /**
// * 删除试验数据
// *

View File

@ -0,0 +1,86 @@
package com.bonus.aqgqj.app.service;
import com.bonus.aqgqj.app.entity.TestReportManageAppVo;
import com.bonus.aqgqj.utils.ServerResponse;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* 检测报告管理
* @author hay
*/
public interface TestReportManageAppService {
/**
* 查询列表
* @param bean
* @return
*/
List<TestReportManageAppVo> list(TestReportManageAppVo bean);
/**
* 详情列表
* @param data
* @return
*/
List<TestReportManageAppVo> getDetailsList(TestReportManageAppVo data);
/**
* 工器具列表
* @return
*/
List<TestReportManageAppVo> listTools();
/**
* 单位列表
* @return
*/
List<TestReportManageAppVo> getAllCustomName();
/**
* 获取所有班组数据
* @return
*/
List<TestReportManageAppVo> getTeamSelected();
/**
* 试验数据详情
* @param data
* @return
*/
ServerResponse viewTestData(TestReportManageAppVo data);
/**
* 合格证下载
* @param data
* @return
*/
TestReportManageAppVo downloadCertificateList(TestReportManageAppVo data);
/**
* 检测报告下载
* @param data
* @return
*/
ServerResponse download(TestReportManageAppVo data);
/**
* 检测报告下载
* @param request
* @param tempZipFile
* @throws IOException
* @return
*/
ResponseEntity<FileSystemResource> downloadFile(HttpServletRequest request, File tempZipFile) throws IOException;
/**
* 检测报告附页Excel文件生成转base64
* @param data
* @return
*/
ServerResponse testReportExcelBase64(TestReportManageAppVo data);
}

View File

@ -52,6 +52,17 @@ public class ExamineAppServiceImpl implements ExamineAppService {
List<ExperimentalAppVo> list = new ArrayList<>();
try {
list = mapper.getList(dto);
if (list.size() > 0) {
//查询详情里需要审核的id
for (int i = 0; i < list.size(); i++) {
ExperimentalAppVo experimentalAppVo = list.get(i);
if ("待重新审阅".equals(experimentalAppVo.getAudtiStatus())) {
experimentalAppVo.setAudtiStatus("待审阅");
}
List<ExperimentalAppVo> list1 = mapper.getDetailIdBySampleId(experimentalAppVo.getId(),experimentalAppVo.getAudtiStatus());
list.get(i).setIds(list1.get(0).getIds());
}
}
} catch (Exception e) {
log.error(e.toString(), e);
}

View File

@ -171,7 +171,7 @@ public class ExperimentalAppServiceImpl implements ExperimentalAppService {
for (ExperDevItemsAppVo experDevItemsVo : experDevItemsVos) {
// 添加设备试验项信息
mapper.addExperDevItems(experDevItemsVo);
List<ExperDevItemVo> experDevItemVos = setExperDevItemList(vo.getExperDevVos().get(i), vo, experDevItemsVo);
List<ExperDevItemAppVo> experDevItemVos = setExperDevItemList(vo.getExperDevVos().get(i), vo, experDevItemsVo);
// 添加设备试验项数据
mapper.addExperDevItem(experDevItemVos);
}
@ -193,94 +193,94 @@ public class ExperimentalAppServiceImpl implements ExperimentalAppService {
return ServerResponse.createBySuccessMsg("操作成功");
}
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public ServerResponse editTestData(TestAppVo vo) {
// try {
// if (vo.getId() == null) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "参数不完整");
// }
// if (!SystemUtils.isExperimentalTeam()) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法修改试验数据");
// }
// // 处于审核流程中的数据无法进行修改
// int isCheck = mapper.isCheck(vo.getId());
// if (isCheck > 0) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "处于审核流程中的数据或者试验完成的数据无法进行修改");
// }
// // 整体数据校验数据
// String validResult = validatorsUtils.valid(vo, TestAppVo.Query.class);
// if (StringUtils.isNotBlank(validResult)) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, validResult);
// }
// if (!validatorsDate(vo)) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "下次试验日期不能早于试验日期");
// }
// String result = validatorsParams(vo.getParamsData());
// if (StringUtils.isNotBlank(result)) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, result);
// }
// TestAppVo testAppVo = handleConfigItem(vo);
// if (testAppVo == null) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "参数异常");
// }
// // 试验主要设备试验依据试验项校验
// String result2 = singleValidators(testAppVo);
// if (StringUtils.isNotBlank(result2)) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, result2);
// }
// //论实验全部金额
// BigDecimal allMony= new BigDecimal("0");
// //获取试验项金额
// BigDecimal bigDecimal = new BigDecimal("0");
// for (ConfigItemsVo configItemsVo : vo.getConfigItemsVos()) {
// // 添加试验项数据
// BigDecimal amount = new BigDecimal(configItemsVo.getAmount());
// bigDecimal=bigDecimal.add(amount);
// }
// // 删除试验依据试验样品设备设备试验项信息设备试验项数据
// List<Long> experDevIds = mapper.getExperDevIds(vo.getId());
// List<Long> experDevItemsIds = mapper.getExperDevItems(experDevIds);
// mapper.delConfigBasis(vo.getId());
// mapper.delExperDev(vo.getId());
// if (CollectionUtils.isNotEmpty(experDevIds)) {
// mapper.delExperDevItems(experDevIds);
// }
// if (CollectionUtils.isNotEmpty(experDevItemsIds)) {
// mapper.delExperDevItem(experDevItemsIds);
// }
// // 修改试验信息数据
// mapper.updateExper(vo);
// // 添加试验依据信息数据
// mapper.addConfigBasis(vo.getBasisVos(), vo.getId());
// for (int i = 0; i < vo.getExperDevVos().size(); i++) {
// ExperDevVo experDevVo = vo.getExperDevVos().get(i);
// experDevVo.setIsHg(setHgData(experDevVo.getDevData()));
// // 添加试验样品数据
// BigDecimal amount= new BigDecimal(experDevVo.getAmount());
// allMony=allMony.add(bigDecimal).add(amount);
// experDevVo.setExperAmount(bigDecimal.toString());
// mapper.addExperDev(experDevVo, vo.getId());
// List<ExperDevItemsVo> experDevItemsVos = setExperDevItemsList(vo.getExperDevVos().get(i), vo);
// for (ExperDevItemsVo experDevItemsVo : experDevItemsVos) {
//
// mapper.addExperDevItems(experDevItemsVo);
// List<ExperDevItemVo> experDevItemVos = setExperDevItemList(vo.getExperDevVos().get(i), vo, experDevItemsVo);
// // 添加设备试验项数据
// mapper.addExperDevItem(experDevItemVos);
// }
// }
// vo.setAllMoney(allMony.toString());
// mapper.updateExperMony(vo);
// } catch (Exception e) {
// log.error(e.toString(), e);
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "操作失败");
// }
// return ServerResponse.createBySuccessMsg("操作成功");
// }
//
@Override
@Transactional(rollbackFor = Exception.class)
public ServerResponse editTestData(TestAppVo vo) {
try {
if (vo.getId() == null) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "参数不完整");
}
if (!SystemUtils.isExperimentalTeam()) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法修改试验数据");
}
// 处于审核流程中的数据无法进行修改
int isCheck = mapper.isCheck(vo.getId());
if (isCheck > 0) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "处于审核流程中的数据或者试验完成的数据无法进行修改");
}
// 整体数据校验数据
String validResult = validatorsUtils.valid(vo, TestAppVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, validResult);
}
if (!validatorsDate(vo)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "下次试验日期不能早于试验日期");
}
String result = validatorsParams(vo.getParamsData());
if (StringUtils.isNotBlank(result)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, result);
}
TestAppVo testAppVo = handleConfigItem(vo);
if (testAppVo == null) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "参数异常");
}
// 试验主要设备试验依据试验项校验
String result2 = singleValidators(testAppVo);
if (StringUtils.isNotBlank(result2)) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, result2);
}
//论实验全部金额
BigDecimal allMony= new BigDecimal("0");
//获取试验项金额
BigDecimal bigDecimal = new BigDecimal("0");
for (ConfigItemsAppVo configItemsVo : vo.getConfigItemsVos()) {
// 添加试验项数据
BigDecimal amount = new BigDecimal(configItemsVo.getAmount());
bigDecimal=bigDecimal.add(amount);
}
// 删除试验依据试验样品设备设备试验项信息设备试验项数据
List<Long> experDevIds = mapper.getExperDevIds(vo.getId());
List<Long> experDevItemsIds = mapper.getExperDevItems(experDevIds);
mapper.delConfigBasis(vo.getId());
mapper.delExperDev(vo.getId());
if (CollectionUtils.isNotEmpty(experDevIds)) {
mapper.delExperDevItems(experDevIds);
}
if (CollectionUtils.isNotEmpty(experDevItemsIds)) {
mapper.delExperDevItem(experDevItemsIds);
}
// 修改试验信息数据
mapper.updateExper(vo);
// 添加试验依据信息数据
mapper.addConfigBasis(vo.getBasisVos(), vo.getId());
for (int i = 0; i < vo.getExperDevVos().size(); i++) {
ExperDevAppVo experDevVo = vo.getExperDevVos().get(i);
experDevVo.setIsHg(setHgData(experDevVo.getDevData()));
// 添加试验样品数据
BigDecimal amount= new BigDecimal(experDevVo.getAmount());
allMony=allMony.add(bigDecimal).add(amount);
experDevVo.setExperAmount(bigDecimal.toString());
mapper.addExperDev(experDevVo, vo.getId());
List<ExperDevItemsAppVo> experDevItemsVos = setExperDevItemsList(vo.getExperDevVos().get(i), vo);
for (ExperDevItemsAppVo experDevItemsVo : experDevItemsVos) {
mapper.addExperDevItems(experDevItemsVo);
List<ExperDevItemAppVo> experDevItemVos = setExperDevItemList(vo.getExperDevVos().get(i), vo, experDevItemsVo);
// 添加设备试验项数据
mapper.addExperDevItem(experDevItemVos);
}
}
vo.setAllMoney(allMony.toString());
mapper.updateExperMony(vo);
} catch (Exception e) {
log.error(e.toString(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "操作失败");
}
return ServerResponse.createBySuccessMsg("操作成功");
}
// @Override
// @Transactional(rollbackFor = Exception.class)
// public ServerResponse delTestData(ParamsAppDto dto) {
@ -352,23 +352,38 @@ public class ExperimentalAppServiceImpl implements ExperimentalAppService {
@Transactional(rollbackFor = Exception.class)
public ServerResponse commitCheckTestData(ParamsAppDto dto) {
try {
// 判断是否提交空数据
if (dto.getIds() == null || dto.getIds().length == 0) {
if (dto.getId() == null || dto.getIds() == null || dto.getIds().length == 0) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "未提交审查数据");
}
if (!SystemUtils.isExperimentalTeam()) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法提交审查数据");
}
// 判断提交数据中是否存在流程数据或者存在待试验项
List<Long> list = Arrays.asList(dto.getIds());
int result = mapper.isNotEditData(list);
if (result > 0) {
return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "提交数据中存在待试验项或处于审核流程或已试验结束");
}
// 更新收样表中的状态为待审阅
mapper.updateSampleStatus(list);
// 更新试验表中数据为待审阅
//先更新tb_exper表中数据为待审阅
mapper.updateExperStatus(list);
//在查询tb_exper中是否全部为待审阅
int res = mapper.isAllSubmit(dto.getId());
if (res<=0){
//如果全部为待审阅更新收样表中的状态为待审阅
mapper.updateSampleStatus(dto.getId());
}
// // 判断是否提交空数据
// if (dto.getIds() == null || dto.getIds().length == 0) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "未提交审查数据");
// }
// if (!SystemUtils.isExperimentalTeam()) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "非试验班组,无法提交审查数据");
// }
// // 判断提交数据中是否存在流程数据或者存在待试验项
// List<Long> list = Arrays.asList(dto.getIds());
// int result = mapper.isNotEditData(list);
// if (result > 0) {
// return ServerResponse.createByErrorMsg(HttpStatus.ERROR, "提交数据中存在待试验项或处于审核流程或已试验结束");
// }
// // 更新收样表中的状态为待审阅
// mapper.updateSampleStatus(list);
// // 更新试验表中数据为待审阅
// mapper.updateExperStatus(list);
} catch (Exception e) {
log.error(e.toString(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@ -548,15 +563,15 @@ public class ExperimentalAppServiceImpl implements ExperimentalAppService {
* @author cwchen
* @date 2024/7/21 19:17
*/
public List<ExperDevItemVo> setExperDevItemList(ExperDevAppVo experDevVo, TestAppVo vo, ExperDevItemsAppVo experDevItemsVo) {
List<ExperDevItemVo> experDevItemList = new ArrayList<>();
public List<ExperDevItemAppVo> setExperDevItemList(ExperDevAppVo experDevVo, TestAppVo vo, ExperDevItemsAppVo experDevItemsVo) {
List<ExperDevItemAppVo> experDevItemList = new ArrayList<>();
int index = 0;
for (int i = 0; i < vo.getConfigItemsVos().size(); i++) {
ConfigItemsAppVo configItemsVo = vo.getConfigItemsVos().get(i);
List<ExperDevItemVo> experDevItemVos = new ArrayList<>();
List<ExperDevItemAppVo> experDevItemVos = new ArrayList<>();
for (int j = 0; j < configItemsVo.getItemList().size(); j++) {
ConfigItemAppVo configItemVo = configItemsVo.getItemList().get(j);
ExperDevItemVo experDevItemVo = new ExperDevItemVo();
ExperDevItemAppVo experDevItemVo = new ExperDevItemAppVo();
experDevItemVo.setItemsId(configItemsVo.getId());
experDevItemVo.setItemId(configItemVo.getId());
experDevItemVo.setDevId(experDevItemsVo.getId());

View File

@ -0,0 +1,682 @@
package com.bonus.aqgqj.app.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.bonus.aqgqj.app.dao.TestReportManageAppDao;
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 lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* @description 检测报告管理
* @author hay
*/
@Slf4j
@Service
public class TestReportManageAppServiceImpl implements TestReportManageAppService {
@Resource
private TestReportManageAppDao testReportManageAppDao;
/**
* 查询列表
* @param bean
* @return
*/
@Override
public List<TestReportManageAppVo> list(TestReportManageAppVo bean) {
List<TestReportManageAppVo> list = testReportManageAppDao.list(bean);
return list;
}
/**
* 查询详情列表
* @param data
* @return
*/
@Override
public List<TestReportManageAppVo> getDetailsList(TestReportManageAppVo data) {
List<TestReportManageAppVo> list = testReportManageAppDao.getDetailsList(data);
//如果没有报告编号需要生成报告编号
for (TestReportManageAppVo dto : list){
//将每条数据下的设备编号试验结果加进去
List<ExperimentalDetailVo.Sample> sampleList = new ArrayList<>();
List<Map<String, String>> mapList = testReportManageAppDao.getExperDevItems(dto);
JSONArray jsonArray = new JSONArray();
jsonArray.addAll(mapList);
sampleList = jsonArray.toJavaList(ExperimentalDetailVo.Sample.class);
dto.setSampleList(sampleList);
if (StringHelper.isEmpty(dto.getReportCode())){
//生成报告编号
String reportCode = generateReportCode(dto);
dto.setReportCode(reportCode);
}
}
return list;
}
/**
* 生成报告编号
* 报告编号生成规则ML/BG-YYYY-MMNNN-DD-QQ
* ML/BG:明丽/报告
* YYYY年份4位数字表示报告生成的年份
* MM月份2位数字表示报告生成的月份
* NNN报告序号每个月从001开始递增生成每月的序号重新计数
* DD部门的随机排序2位数字每个部门内部的随机编号
* QQ数量2位数字表示报告中设备的数量
* @param dto
* @return
*/
private String generateReportCode(TestReportManageAppVo dto) {
//获取当前年 yyyy
String nowYear = DateTimeHelper.getNowYear();
//获取当前月 MM
String nowMonth = DateTimeHelper.getNowMonths();
//查询当前年月的序号
String code = testReportManageAppDao.getReportCode(nowYear+"-"+nowMonth);
if (StringHelper.isNotEmpty(code)){
int num = Integer.parseInt(code);
num++;
code = "ML/BG-"+nowYear+"-"+nowMonth+String.format("%03d",num)+"-00-"+String.format("%02d",dto.getDevNum());
}else {
code = "ML/BG-"+nowYear+"-"+nowMonth+"001"+"-00-"+String.format("%02d",dto.getDevNum());
}
//将生成的报告编号保存到数据库
dto.setReportCode(code);
int res = testReportManageAppDao.updateReportCode(dto);
return code;
}
@Override
public List<TestReportManageAppVo> listTools() {
List<TestReportManageAppVo> list = testReportManageAppDao.listTools();
return list;
}
/**
* 查询所有单位列表
* @return
*/
@Override
public List<TestReportManageAppVo> getAllCustomName() {
return testReportManageAppDao.getAllCustomName();
}
/**
* 查询所有班组
* @return
*/
@Override
public List<TestReportManageAppVo> getTeamSelected() {
return testReportManageAppDao.getTeamSelected();
}
@Override
public ServerResponse viewTestData(TestReportManageAppVo dto) {
TestReportManageAppVo testVo = new TestReportManageAppVo();
try {
testVo= testReportManageAppDao.getTestData(dto);
List<ExperBasisVo> experBasisVos = testReportManageAppDao.getConfigBasis(dto);
List<ConfigItemsVo> configItemsVos = testReportManageAppDao.getExperItems(dto);
for (ConfigItemsVo configItemsVo : configItemsVos) {
List<ConfigItemVo> configItemVos = testReportManageAppDao.getExperItem(configItemsVo.getId());
configItemsVo.setItemList(configItemVos);
}
List<ExperDevVo> experDevVos = testReportManageAppDao.getExperDev(dto);
testVo.setBasisVos(experBasisVos);
testVo.setConfigItemsVos(configItemsVos);
testVo.setExperDevVos(experDevVos);
return ServerResponse.createSuccess(testVo);
} catch (Exception e) {
e.printStackTrace();
return ServerResponse.createSuccess("");
}
}
@Override
public TestReportManageAppVo downloadCertificateList(TestReportManageAppVo data) {
return testReportManageAppDao.downloadCertificateList(data);
}
@Override
public ServerResponse download(TestReportManageAppVo data) {
//根据选择的id获取详情数据
TestReportManageAppVo bean = new TestReportManageAppVo();
bean.setId(data.getId());
List<TestReportManageAppVo> list = getDetailsList(bean);
//查询详情里所有数据的检测报告
for (TestReportManageAppVo dto : list){
//根据试验id设备类型是否合格部门id来查询每个检测报告
ServerResponse serverResponse = viewTestData(dto);
if (serverResponse.isSuccess()){
File zipFile = new File("检测报告_"+DateTimeHelper.getNowDMS()+".zip");
try (FileOutputStream fos = new FileOutputStream(zipFile);
ZipOutputStream zos = new ZipOutputStream(fos)) {
TestReportManageAppVo testVo = (TestReportManageAppVo) serverResponse.getData();
//将数据传给检测报告生成的方法
try {
generateReport(testVo,zos);
} catch (Exception e){
e.printStackTrace();
}
}catch (IOException e){
e.printStackTrace();
}
}
}
return null;
}
@Override
public ResponseEntity<FileSystemResource> downloadFile(HttpServletRequest request, File tempZipFile) throws IOException {
String ids = request.getParameter("ids");
if (StringHelper.isNotEmpty(ids)) {
String fileNames="检测报告_" + DateTimeHelper.getNowDMS();
tempZipFile = File.createTempFile(fileNames, ".zip");
tempZipFile.deleteOnExit();
try (FileOutputStream fos = new FileOutputStream(tempZipFile);
ZipOutputStream zos = new ZipOutputStream(fos)) {
//拆分用逗号分隔的数据
String[] idsArray = ids.split(",");
for (String id : idsArray) {
TestReportManageAppVo dto = new TestReportManageAppVo();
dto.setId(Integer.parseInt(id));
//查询每条数据里面的详细数据
List<TestReportManageAppVo> list = getDetailsList(dto);
//查询详情里所有数据的检测报告
for (TestReportManageAppVo dtos : list) {
//根据试验id设备类型是否合格部门id来查询每个检测报告
ServerResponse serverResponse = viewTestData(dtos);
if (serverResponse.isSuccess()) {
TestReportManageAppVo testVo = (TestReportManageAppVo) serverResponse.getData();
log.info("sj--->{}", testVo);
//生成检测报告
generateReport(testVo, zos);
}
}
}
}
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileNames+".zip");
return new ResponseEntity<>(new FileSystemResource(tempZipFile), headers, HttpStatus.OK);
}
return null;
}
/**
* 检测报告附页Excel文件生成转base64
*/
@Override
public ServerResponse testReportExcelBase64(TestReportManageAppVo data) {
//根据试验id设备类型是否合格部门id来查询检测报告
ServerResponse serverResponse = viewTestData(data);
if (serverResponse.isSuccess()) {
TestReportManageAppVo testVo = (TestReportManageAppVo) serverResponse.getData();
//将数据传给检测报告生成的方法
try {
String base64Excel = generateReport(testVo,null);
// 返回 Base64 字符串
return ServerResponse.createSuccess(base64Excel);
} catch (Exception e) {
e.printStackTrace();
}
}
return ServerResponse.createErroe("查看失败");
}
/**
* 生成检测报告
*/
public String generateReport(TestReportManageAppVo bean,ZipOutputStream zos) throws IOException {
//先计算出总共有多少列和动态生成的有多少列
//总列数
int totalNum = 0;
//动态生成的列数
int trendsNum = 0;
//获取所有检测项目
List<ConfigItemsVo> configItemsVos = bean.getConfigItemsVos();
for (ConfigItemsVo configItemsVo : configItemsVos){
List<ConfigItemVo> itemList = configItemsVo.getItemList();
trendsNum += itemList.size();
}
List<ExperBasisVo> basisVos = bean.getBasisVos();
String yj="";
for (int i = 0; i < basisVos.size(); i++){
yj+=(i + 1)+""+basisVos.get(i).getBasisName() + "\n";
}
totalNum = trendsNum + 6;
List<ExperDevVo> devList=bean.getExperDevVos();
XSSFWorkbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("检测报告");
// 创建样式
XSSFCellStyle style = workbook.createCellStyle();
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 设置每列的宽度为20个字符的宽度
int widthInCharacters = 15;
int columnCount = totalNum;
for (int i = 0; i < columnCount; i++) {
// 1/256字符的宽度单位
sheet.setColumnWidth(i, widthInCharacters * 256);
}
//第一行
Row row1 = sheet.createRow(0);
//单元格-创建第一个头
Cell cell11 = row1.createCell(0);
cell11.setCellValue(bean.getSampleTools()+"检测报告附页");
//合并全部列
addMergedRegion(0,0,0,totalNum-1,sheet);
// 应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(0, 0, 0, totalNum-1), style);
cell11.setCellStyle(style);
//第二行
Row row2 = sheet.createRow(1);
Cell cell21 = row2.createCell(0);
cell21.setCellValue("报告编号");
cell21.setCellStyle(style);
//计算占用行数
int num21=(totalNum-4)/2;
Cell cell22 = row2.createCell(1);
addMergedRegion(1,1,1,num21,sheet);
// 应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(1, 1, 1, num21), style);
cell22.setCellValue(bean.getReportCode());
cell22.setCellStyle(style);
Cell cell23 = row2.createCell(num21+1);
cell23.setCellValue("收样日期");
cell23.setCellStyle(style);
Cell cell24 = row2.createCell(num21+2);
cell24.setCellValue(bean.getCollectSamplesTime());
addMergedRegion(1,1,num21+2,totalNum-3,sheet);
// 应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(1,1,num21+2,totalNum-3), style);
cell24.setCellStyle(style);
Cell cell25 = row2.createCell(totalNum-2);
cell25.setCellValue("样品数量");
cell25.setCellStyle(style);
Cell cell26= row2.createCell(totalNum-1);
cell26.setCellValue(bean.getDevNum());
cell26.setCellStyle(style);
//第三行
Row row3 = sheet.createRow(2);
Cell cell31 = row3.createCell(0);
cell31.setCellValue("检测设备");
cell31.setCellStyle(style);
Cell cell32 = row3.createCell(1);
cell32.setCellValue(bean.getDevTypeName());
cell32.setCellStyle(style);
addMergedRegion(2,2,1,totalNum-1,sheet);
// 应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(2,2,1,totalNum-1), style);
//第四行
Row row4= sheet.createRow(3);
Cell cell41 = row4.createCell(0);
cell41.setCellValue("检测依据");
cell41.setCellStyle(style);
Cell cell42 = row4.createCell(1);
cell42.setCellValue(yj);
cell42.setCellStyle(style);
addMergedRegion(3,3,1,totalNum-1,sheet);
// 应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(3,3,1,totalNum-1), style);
//第5行 //第六行
Row row5= sheet.createRow(4);
Row row6= sheet.createRow(5);
//第五行//第六号合并
Cell cell51 = row5.createCell(0);
cell51.setCellValue("序号");
cell51.setCellStyle(style);
addMergedRegion(4,5,0,0,sheet);
// 应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(4,5,0,0), style);
Cell cell52 = row5.createCell(1);
cell52.setCellValue("样品编号");
cell52.setCellStyle(style);
addMergedRegion(4,5,1,1,sheet);
//应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(4,5,1,1), style);
Cell cell53 = row5.createCell(2);
cell53.setCellValue("样品信息");
cell53.setCellStyle(style);
addMergedRegion(4,4,2,5,sheet);
//应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(4,4,2,5), style);
//第六行固定数据
Cell cell62= row6.createCell(2);
cell62.setCellStyle(style);
cell62.setCellValue("客户自编号");
Cell cell63 = row6.createCell(3);
cell63.setCellStyle(style);
cell63.setCellValue("生成厂家");
Cell cell64 = row6.createCell(4);
cell64.setCellStyle(style);
cell64.setCellValue("生产日期");
Cell cell65 = row6.createCell(5);
cell65.setCellStyle(style);
cell65.setCellValue("规格型号");
//第五第六号非固定数据
AtomicInteger num= new AtomicInteger(5);
AtomicInteger rowNums= new AtomicInteger(5);
configItemsVos.forEach(vo->{
List<ConfigItemVo> childList=vo.getItemList();
int rowNum=childList.size();
num.set(num.get() + 1);
Cell cell54 = row5.createCell(num.get());
cell54.setCellValue(vo.getExperTypeName());
cell54.setCellStyle(style);
addMergedRegion(4,4,num.get(),num.get()+rowNum-1,sheet);
//应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(4,4,num.get(),num.get()+rowNum-1), style);
num.addAndGet(rowNum-1);
childList.forEach(child->{
rowNums.set(rowNums.get() + 1);
Cell cell4 = row6.createCell(rowNums.get());
cell4.setCellStyle(style);
cell4.setCellValue(child.getItemName());
});
});
AtomicInteger row = new AtomicInteger(5);
AtomicInteger cellNum = new AtomicInteger(0);
AtomicInteger serialNumber = new AtomicInteger(1); // 用于追踪序号
if (ListHelper.isNotEmpty(devList)) {
devList.forEach(dev -> {
row.set(row.get() + 1);
cellNum.set(0); // 每次处理新行时重置 cellNum
Row row7 = sheet.createRow(row.get());
// 创建序号列
Cell row71 = row7.createCell(cellNum.get());
row71.setCellValue(serialNumber.get()); // 设置序号
row71.setCellStyle(style);
cellNum.set(cellNum.get() + 1);
// 更新序号
serialNumber.set(serialNumber.get() + 1);
// 处理其他列
Cell row72 = row7.createCell(cellNum.get());
row72.setCellValue(dev.getCustomerCode());
row72.setCellStyle(style);
cellNum.set(cellNum.get() + 1);
Cell row73 = row7.createCell(cellNum.get());
row73.setCellValue(dev.getDevCode());
row73.setCellStyle(style);
cellNum.set(cellNum.get() + 1);
Cell row74 = row7.createCell(cellNum.get());
row74.setCellValue(dev.getManufacturer());
row74.setCellStyle(style);
cellNum.set(cellNum.get() + 1);
Cell row75 = row7.createCell(cellNum.get());
row75.setCellValue(dev.getManufactureDate());
row75.setCellStyle(style);
cellNum.set(cellNum.get() + 1);
Cell row76 = row7.createCell(cellNum.get());
row76.setCellValue(dev.getDevModule());
row76.setCellStyle(style);
cellNum.set(cellNum.get() + 1);
String val = dev.getDevData();
JSONArray jsonArray = JSON.parseArray(val);
jsonArray.forEach(json -> {
Cell row77 = row7.createCell(cellNum.get());
row77.setCellValue(json.toString());
row77.setCellStyle(style);
cellNum.set(cellNum.get() + 1);
});
});
}
//
row.set(row.get() + 1);
Row row8= sheet.createRow(row.get());
Cell cell81 = row8.createCell(0);
cell81.setCellValue("技术要求");
cell81.setCellStyle(style);
Cell cell82 = row8.createCell(1);
cell82.setCellValue(bean.getExperStand());
cell82.setCellStyle(style);
addMergedRegion(row.get(),row.get(),1,totalNum-1,sheet);
//应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(row.get(),row.get(),1,totalNum-1), style);
row.set(row.get() + 1);
Row row9= sheet.createRow(row.get());
Cell cell91 = row9.createCell(0);
cell91.setCellValue("检测结论");
cell91.setCellStyle(style);
Cell cell92 = row9.createCell(1);
cell92.setCellValue(bean.getExperConclu());
cell92.setCellStyle(style);
addMergedRegion(row.get(),row.get(),1,totalNum-1,sheet);
//应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(row.get(),row.get(),1,totalNum-1), style);
row.set(row.get() + 1);
Row row10= sheet.createRow(row.get());
Cell cell101 = row10.createCell(0);
cell101.setCellValue("备注");
cell101.setCellStyle(style);
Cell cell102 = row10.createCell(1);
cell102.setCellValue(bean.getRemarks());
cell102.setCellStyle(style);
addMergedRegion(row.get(),row.get(),1,totalNum-1,sheet);
//应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(row.get(),row.get(),1,totalNum-1), style);
row.set(row.get() + 1);
Row row11= sheet.createRow(row.get());
Cell cell111 = row11.createCell(0);
cell111.setCellValue("检测日期");
cell111.setCellStyle(style);
Cell cell112 = row11.createCell(1);
cell112.setCellValue(bean.getExperTime());
cell112.setCellStyle(style);
int num112=(totalNum-2)/2;
addMergedRegion(row.get(),row.get(),1,num112,sheet);
//应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(row.get(),row.get(),1,num112), style);
Cell cell113 = row11.createCell(num112+1);
cell113.setCellValue("下次检测日期");
cell113.setCellStyle(style);
Cell cell114= row11.createCell(num112+2);
cell114.setCellValue(bean.getNextExperTime());
cell114.setCellStyle(style);
addMergedRegion(row.get(),row.get(),num112+2,totalNum-1,sheet);
//应用边框到合并区域
applyBordersToMergedRegion(sheet, new CellRangeAddress(row.get(),row.get(),num112+2,totalNum-1), style);
if (zos!=null){
// 保存到 ZIP 文件
ByteArrayOutputStream baos = new ByteArrayOutputStream();
workbook.write(baos);
if (StringHelper.isNotEmpty(bean.getReportCode())){
//将字符串中ML/BG-去除
bean.setReportCode(bean.getReportCode().replace("ML/BG-",""));
}
ZipEntry entry = new ZipEntry("检测报告_" + bean.getReportCode() + "_"+DateTimeHelper.getNowDMS()+".xlsx");
zos.putNextEntry(entry);
zos.write(baos.toByteArray());
zos.closeEntry();
workbook.close();
return null;
}else {
// Excel 文档写入字节数组
ByteArrayOutputStream baos = new ByteArrayOutputStream();
workbook.write(baos);
baos.close();
byte[] excelBytes = baos.toByteArray();
// 将字节数组编码为 Base64 字符串
String base64Excel = Base64.getEncoder().encodeToString(excelBytes);
// 返回 Base64 字符串
return base64Excel;
}
}
/**
* 单元格样式--居中
*/
public static XSSFCellStyle centerStyle(XSSFWorkbook workbook){
XSSFCellStyle commonStyle = workbook.createCellStyle();
commonStyle.setBorderTop(BorderStyle.THIN);
commonStyle.setBorderBottom(BorderStyle.THIN);
commonStyle.setBorderLeft(BorderStyle.THIN);
commonStyle.setBorderRight(BorderStyle.THIN);
// 左右居中
commonStyle.setAlignment(HorizontalAlignment.CENTER);
// 上下居中
commonStyle.setVerticalAlignment(VerticalAlignment.CENTER);
commonStyle.setLocked(true);
// 自动换行
commonStyle.setWrapText(false);
return commonStyle;
}
/** 应用边框到合并区域
*
* @param sheet
* @param range
* @param style
*/
// 应用边框到合并区域
private static void applyBordersToMergedRegion(Sheet sheet, CellRangeAddress range, CellStyle style) {
int firstRow = range.getFirstRow();
int lastRow = range.getLastRow();
int firstCol = range.getFirstColumn();
int lastCol = range.getLastColumn();
// 遍历合并区域的所有单元格并设置边框
for (int row = firstRow; row <= lastRow; row++) {
Row xssfRow = sheet.getRow(row);
if (xssfRow == null) {
xssfRow = sheet.createRow(row);
}
for (int col = firstCol; col <= lastCol; col++) {
Cell cell = xssfRow.getCell(col);
if (cell == null) {
cell = xssfRow.createCell(col);
}
cell.setCellStyle(style);
}
}
}
/**
* 合并单元格
* @param startRow 开始行
* @param endRow 结束行
* @param startCol 开始列
* @param endCol 结束列
* @param sheet 创建的sheet页
*/
public static void addMergedRegion(int startRow,int endRow,int startCol,int endCol,Sheet sheet){
CellRangeAddress cra = new CellRangeAddress(startRow,endRow,startCol,endCol);
sheet.addMergedRegion(cra);
}
/**
* 设备编号--自动生成
* 生成规则YYMMDDNNNN
* YYMMDD年月日
* NNNN 当天收样的流水号采用四位数字从0001开始每天重新计数
*/
private String customerCodeRule() {
String nowDate = DateTimeHelper.getNowYMD();
//查询本日收样流水号
String customerCode = testReportManageAppDao.selectCustomerCode(nowDate);
if (StringHelper.isNotEmpty(customerCode)) {
// 将字符串转换为整数
int num = Integer.parseInt(customerCode);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是四位数不足四位则在前面补0
customerCode = String.format("%04d", num);
} else {
customerCode = "0001";
}
String code = nowDate + customerCode;
return code;
}
}

View File

@ -85,12 +85,16 @@
<if test="roleCode=='administrators'">
AND process_status IN (1,2,3) AND audti_status = 0
</if>
GROUP BY ts.id
ORDER BY FIELD(audtiStatus, '待审阅','待重新审阅','待审核','待审批') DESC,ts.sample_date DESC
</select>
<!--审查详情列表-->
<select id="getDetailList" resultType="com.bonus.aqgqj.app.entity.ExperimentalDetailAppVo">
SELECT * FROM (
SELECT ANY_VALUE(tsd.sample_id) AS sampleId,
ANY_VALUE(te.status) as `status`,
ANY_VALUE(te.audit_status) as auditStatus,
ANY_VALUE(te.is_er) as isEr,
ANY_VALUE(tsd.dev_type_name) AS devTypeName,
tsd.dev_type_code AS devTypeCode,
GROUP_CONCAT(DISTINCT tsd.dev_module SEPARATOR '、' ) as devModule,
@ -109,7 +113,7 @@
WHEN ANY_VALUE(te.status) = 3 AND ANY_VALUE(te.audit_status) = 4 THEN '审批不通过'
WHEN ANY_VALUE(te.status) = 4 AND ANY_VALUE(te.audit_status) = 1 THEN '试验完成'
ELSE '待试验'
END AS status
END AS statusResult
FROM tb_sample_device tsd
LEFT JOIN tb_exper te ON tsd.sample_id = te.sample_id AND tsd.dev_type_code = te.dev_type_code AND te.del_flag =
0
@ -128,7 +132,7 @@
</if>
GROUP BY tsd.dev_type_code
) a
ORDER BY FIELD(a.status, '审阅不通过','审核不通过','审批不通过','待提交','待审阅','待重新审阅','待审核','待审批','试验完成'),a.testTime
ORDER BY FIELD(a.statusResult, '审阅不通过','审核不通过','审批不通过','待提交','待审阅','待重新审阅','待审核','待审批','试验完成'),a.testTime
DESC
</select>
<!--查询试验设备数量-->
@ -146,13 +150,13 @@
UNION ALL
SELECT COUNT(*) FROM tb_exper WHERE sample_id = #{sampleId} AND del_flag = 0
<if test="auditType == 1">
AND status = 2 AND audit_status = 0
AND status >1
</if>
<if test="auditType == 2">
AND status = 3 AND audit_status = 0
AND status > 2
</if>
<if test="auditType == 3">
AND status = 4 AND audit_status = 1
AND status >3
</if>
UNION ALL
SELECT COUNT(*) FROM tb_exper WHERE sample_id = #{sampleId} AND del_flag = 0
@ -175,4 +179,33 @@
SELECT is_er FROM tb_sample WHERE id = #{id}
</if>
</select>
<select id="getDetailIdBySampleId" resultType="com.bonus.aqgqj.app.entity.ExperimentalAppVo">
SELECT GROUP_CONCAT(a.experId) as ids
FROM (SELECT ANY_VALUE(tsd.sample_id) AS sampleId,
ANY_VALUE(te.id) AS experId,
CASE
WHEN ANY_VALUE(te.status) = 0 AND ANY_VALUE(te.audit_status) = 0 THEN '待提交'
WHEN ANY_VALUE(te.status) = 1 AND ANY_VALUE(te.audit_status) = 0 AND
ANY_VALUE(te.is_er) IS NULL THEN '待审阅'
WHEN ANY_VALUE(te.status) = 1 AND ANY_VALUE(te.audit_status) = 0 AND ANY_VALUE(te.is_er) = '1'
THEN '待审阅'
WHEN ANY_VALUE(te.status) = 1 AND ANY_VALUE(te.audit_status) = 2 THEN '审阅不通过'
WHEN ANY_VALUE(te.status) = 2 AND ANY_VALUE(te.audit_status) = 0 THEN '待审核'
WHEN ANY_VALUE(te.status) = 2 AND ANY_VALUE(te.audit_status) = 3 THEN '审核不通过'
WHEN ANY_VALUE(te.status) = 3 AND ANY_VALUE(te.audit_status) = 0 THEN '待审批'
WHEN ANY_VALUE(te.status) = 3 AND ANY_VALUE(te.audit_status) = 4 THEN '审批不通过'
WHEN ANY_VALUE(te.status) = 4 AND ANY_VALUE(te.audit_status) = 1 THEN '试验完成'
ELSE '待试验'
END AS status
FROM tb_sample_device tsd
LEFT JOIN tb_exper te
ON tsd.sample_id = te.sample_id AND tsd.dev_type_code = te.dev_type_code AND
te.del_flag = 0
WHERE tsd.sample_id = #{id}
AND tsd.del_falg = 0
GROUP BY tsd.dev_type_code) a
WHERE a.`status` = #{audtiStatus}
GROUP BY a.sampleId
</select>
</mapper>

View File

@ -190,15 +190,12 @@
<!--更新收样表中的状态为待审阅-->
<update id="updateSampleStatus">
UPDATE tb_sample SET audti_status = 0,process_status = 1,remarks = null
WHERE id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
WHERE id =#{id}
</update>
<!--更新试验表中数据为待审阅-->
<update id="updateExperStatus">
UPDATE tb_exper SET status = 1,audit_status = 0,audit_user_name = null,audit_time = null,audit_remakr = null
WHERE sample_id IN
WHERE id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
@ -322,9 +319,11 @@
<!--试验详情列表-->
<select id="getDetailList" resultType="com.bonus.aqgqj.app.entity.ExperimentalDetailAppVo">
SELECT *
FROM (SELECT
MAX(tsd.id) as id,
ANY_VALUE(tsd.sample_id) AS sampleId,
FROM (SELECT MAX(tsd.id) as id,
ANY_VALUE(tsd.sample_id) AS sampleId,
ANY_VALUE(te.status) as `status`,
ANY_VALUE(te.audit_status) as auditStatus,
ANY_VALUE(te.is_er) as isEr,
GROUP_CONCAT(DISTINCT tsd.dev_module SEPARATOR '、' ) as devModule,
ANY_VALUE(tsd.dev_type_name) AS devTypeName,
tsd.dev_type_code AS devTypeCode,
@ -346,7 +345,7 @@
WHEN ANY_VALUE(te.status) = 3 AND ANY_VALUE(te.audit_status) = 4 THEN '审批不通过'
WHEN ANY_VALUE(te.status) = 4 AND ANY_VALUE(te.audit_status) = 1 THEN '试验完成'
ELSE '待试验'
END AS status
END AS statusResult
FROM tb_sample_device tsd
LEFT JOIN tb_exper te
ON tsd.sample_id = te.sample_id AND tsd.dev_type_code = te.dev_type_code AND
@ -355,7 +354,8 @@
WHERE tsd.sample_id = #{id}
AND tsd.del_falg = 0
GROUP BY tsd.dev_type_code) a
ORDER BY FIELD(a.STATUS, '审阅不通过', '审核不通过', '审批不通过', '待提交', '待审阅', '待重新审阅', '待审核',
ORDER BY FIELD(a.statusResult, '审阅不通过', '审核不通过', '审批不通过', '待提交', '待审阅', '待重新审阅',
'待审核',
'待审批', '试验完成'),
a.testTime DESC
</select>
@ -470,21 +470,23 @@
</select>
<!--试验样品设备-->
<select id="getExperDev" resultType="com.bonus.aqgqj.app.entity.ExperDevAppVo">
SELECT id,
exper_id AS experId,
dev_code AS devCode,
manufacturer,
manufacture_date AS manufactureDate,
dev_module AS devModule,
dev_status AS devStatus,
dev_data AS devData,
amount,
remarks,
department_id AS departmentId,
dev_id AS devId
FROM tb_exper_dev
WHERE exper_id = #{id}
ORDER BY id
SELECT ted.id,
ted.exper_id AS experId,
te.dev_type_name as devTypeName,
ted.dev_code AS devCode,
ted.manufacturer,
ted.manufacture_date AS manufactureDate,
ted.dev_module AS devModule,
ted.dev_status AS devStatus,
ted.dev_data AS devData,
ted.amount,
ted.remarks,
ted.department_id AS departmentId,
ted.dev_id AS devId
FROM tb_exper_dev ted
LEFT JOIN tb_exper te on te.id=ted.exper_id and te.del_flag=0
WHERE ted.exper_id = #{id}
ORDER BY ted.id
</select>
<!--获取试验样品设备ID-->
<select id="getExperDevIds" resultType="java.lang.Long">
@ -592,4 +594,22 @@
WHERE items_id = #{id} AND del_flage = 0
ORDER BY item_num
</select>
<select id="isAllSubmit" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM (SELECT *
FROM (SELECT ANY_VALUE(te.status) as `status`,
ANY_VALUE(te.audit_status) as auditStatus,
ANY_VALUE(te.is_er) as isEr,
ANY_VALUE(te.id) AS experId
FROM tb_sample_device tsd
LEFT JOIN tb_exper te
ON tsd.sample_id = te.sample_id AND tsd.dev_type_code = te.dev_type_code AND
te.del_flag = 0
LEFT JOIN sys_user su2 ON te.update_user = su2.id AND su2.del_flag = 0
WHERE tsd.sample_id = #{id}
AND tsd.del_falg = 0
GROUP BY tsd.dev_type_code) a
WHERE a.experId is null
or (a.`status`!=0 and a.auditStatus>1)) b
</select>
</mapper>

View File

@ -44,7 +44,9 @@
and dept_id = 1
</select>
<select id="getDicts" resultType="com.bonus.aqgqj.base.entity.SelectEntity">
SELECT sd2.dict_value AS value,
SELECT
sd2.id,
sd2.dict_value AS value,
sd2.dict_name AS name
FROM sys_distinct sd
LEFT JOIN sys_distinct sd2 ON sd.id = sd2.p_id AND sd2.del_flag = 0

View File

@ -0,0 +1,269 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.aqgqj.app.dao.TestReportManageAppDao">
<update id="updateReportCode">
INSERT INTO tb_certificate
(`code`, `exper_id`, `dev_type`, `is_hg`, `department`, `create_time`)
values (#{reportCode},
#{id},
#{sampleTools},
#{isHg},
#{sampleDepartment},
NOW())
</update>
<select id="list" resultType="com.bonus.aqgqj.app.entity.TestReportManageAppVo">
SELECT
aa.sample_id as id,
tc.custom_name as customName,
DATE_FORMAT(aa.update_time, '%Y-%m-%d') as createTime,
aa.sampleTools,
aa.devNum,
tt.team_name as teamName
FROM
(
SELECT
te.sample_id,
MAX(te.update_time) as update_time,
GROUP_CONCAT( DISTINCT te.dev_type_name SEPARATOR '、' ) AS sampleTools,
SUM(te.dev_num) as devNum
FROM
tb_exper te
WHERE
te.del_flag = 0
and `status`=4
and audit_status=1
<if test="sampleTools != null and sampleTools != ''">
and te.dev_type_name like concat('%',#{sampleTools}, '%')
</if>
GROUP BY
sample_id
) aa
LEFT JOIN tb_sample ts on aa.sample_id=ts.id and ts.del_flag=0
LEFT JOIN tb_custom tc on tc.id=ts.custom_id and tc.del_flag=0
LEFT JOIN tb_team tt on tt.id=ts.team_id and tt.del_flag=0
where 1=1
<if test="keyWord != null and keyWord != ''">
AND (
tc.custom_name like concat('%', #{keyWord}, '%') OR
tt.team_name like concat('%', #{keyWord}, '%')
)
</if>
<if test="startTime != null and endTime!=''">
AND (
DATE_FORMAT(aa.update_time, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
)
</if>
</select>
<select id="getSampleTools" resultType="java.lang.String">
SELECT GROUP_CONCAT(aa.dev_type_name SEPARATOR '、') AS sampleTools
FROM (SELECT DISTINCT tsd.dev_type_name
FROM tb_sample_device tsd
LEFT JOIN tb_sample ts ON ts.id = tsd.sample_id
WHERE tsd.sample_id = #{id}
AND tsd.del_falg = '0') aa
</select>
<select id="getDetailsList" resultType="com.bonus.aqgqj.app.entity.TestReportManageAppVo">
SELECT
aa.*,
tc.`code` as reportCode
FROM
(
SELECT
te.id,
tsd.dev_type_name as sampleTools,
ted.department_id as departmentId,
tc.custom_name as sampleDepartment,
GROUP_CONCAT( DISTINCT tsd.dev_module SEPARATOR '、' ) as devModule,
COUNT(ted.id) as devNum,
ted.is_hg as isHg,
te.create_time as detectionTime
FROM
tb_exper te
LEFT JOIN tb_exper_dev ted on te.id=ted.exper_id
LEFT JOIN tb_sample_device tsd on tsd.id=ted.dev_id and tsd.del_falg=0
LEFT JOIN tb_custom tc on tc.id=ted.department_id and tc.del_flag=0
WHERE
te.sample_id=#{id}
<if test="sampleTools != null and sampleTools != ''">
and tsd.dev_type_name like concat('%',#{sampleTools}, '%')
</if>
<if test="startTime != null and endTime!=''">
AND DATE_FORMAT(te.create_time, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
</if>
GROUP BY tsd.dev_type_name,tsd.department_id,ted.is_hg
)aa
LEFT JOIN tb_certificate tc on tc.exper_id=aa.id and tc.dev_type=aa.sampleTools
and tc.is_hg=aa.isHg and tc.department=aa.sampleDepartment
where 1=1
<if test="keyWord != null and keyWord != ''">
AND (
aa.sampleDepartment like concat('%', #{keyWord}, '%') OR
tc.`code` like concat('%', #{keyWord}, '%')
)
</if>
</select>
<select id="listTools" resultType="com.bonus.aqgqj.app.entity.TestReportManageAppVo">
select
id,
dict_name as name
from
sys_distinct
where
p_id = 92
and del_flag = 0
</select>
<select id="getAllCustomName" resultType="com.bonus.aqgqj.app.entity.TestReportManageAppVo">
SELECT
id,
custom_name AS name
FROM
tb_custom
WHERE
del_flag = 0
and custom_status=0
</select>
<select id="selectCustomerCode" resultType="java.lang.String">
SELECT
SUBSTRING( customer_code, - 4 ) AS CODE
FROM
tb_sample_device
WHERE
SUBSTRING( customer_code, 1, 8 )= #{nowDate}
ORDER BY
customer_code DESC
LIMIT 1
</select>
<select id="getTeamSelected" resultType="com.bonus.aqgqj.app.entity.TestReportManageAppVo">
SELECT id,
team_name AS name
FROM tb_team
WHERE del_flag = 0
</select>
<select id="getReportCode" resultType="java.lang.String">
SELECT SUBSTRING(`code`, 14, 3) AS reportCode
FROM tb_certificate
WHERE SUBSTRING(`code`, 7, 7) = #{nowDate}
ORDER BY SUBSTRING( `code`, 14, 3 ) DESC LIMIT 1
</select>
<select id="getExperDevItems" resultType="java.util.Map">
SELECT ted.dev_code as devCode,
case ted.is_hg
WHEN '1' THEN '不合格'
WHEN '0' THEN '合格'
ELSE '不合格' END AS testResult
FROM tb_exper_dev ted
LEFT JOIN tb_exper te on te.id = ted.exper_id
WHERE ted.exper_id = #{id}
and ted.is_hg = #{isHg}
and ted.department_id = #{departmentId}
and te.dev_type_name = #{sampleTools}
</select>
<select id="getExperItems" resultType="com.bonus.aqgqj.basis.entity.vo.ConfigItemsVo">
SELECT id,
exper_type_code AS experTypeCode,
exper_type_name AS experTypeName,
exper_num AS experNum,
items_sort AS itemsSort,
amount
FROM tb_exper_items
WHERE exper_id = #{id}
ORDER BY items_sort
</select>
<select id="getExperItem" resultType="com.bonus.aqgqj.basis.entity.vo.ConfigItemVo">
SELECT id,
items_id AS itemId,
item_sort AS itemNum,
item_name AS itemName
FROM tb_exper_item
WHERE items_id = #{id}
ORDER BY item_sort
</select>
<select id="getExperDev" resultType="com.bonus.aqgqj.basis.entity.vo.ExperDevVo">
SELECT ted.id,
ted.exper_id AS experId,
tsd.customer_code as customerCode,
ted.dev_code AS devCode,
ted.manufacturer,
ted.manufacture_date AS manufactureDate,
tsd.dev_module AS devModule,
ted.dev_status AS devStatus,
ted.dev_data AS devData,
ted.amount,
ted.remarks,
ted.department_id AS departmentId
FROM tb_exper_dev ted
LEFT JOIN tb_sample_device tsd on tsd.id=ted.dev_id and tsd.del_falg=0
WHERE ted.exper_id = #{id}
and ted.is_hg = #{isHg}
and ted.department_id = #{departmentId}
and tsd.dev_type_name = #{sampleTools}
ORDER BY ted.id
</select>
<select id="getConfigBasis" resultType="com.bonus.aqgqj.basis.entity.vo.ExperBasisVo">
SELECT id,
exper_id AS configId,
exper_basis_name AS basisName
FROM tb_config_basis WHERE exper_id = #{id}
</select>
<select id="getTestData" resultType="com.bonus.aqgqj.app.entity.TestReportManageAppVo">
SELECT
te.id,
te.dev_type_name as sampleTools,
tc.`code` as reportCode,
te.sample_date as collectSamplesTime,
COUNT(ted.id) as devNum,
te.exper_dev as devTypeName,
te.exper_stand as experStand,
te.exper_conclu as experConclu,
te.remarsk as remarks,
te.exper_time as experTime,
te.next_exper_time as nextExperTime
FROM
tb_exper_dev ted
LEFT JOIN tb_exper te on te.id=ted.exper_id and te.del_flag=0
LEFT JOIN tb_custom tcs on tcs.id=ted.department_id and tcs.del_flag=0
LEFT JOIN tb_certificate tc on tc.exper_id=ted.exper_id and tc.is_hg=ted.is_hg and tc.department=tcs.custom_name and te.dev_type_name=tc.dev_type
WHERE
ted.exper_id=#{id}
and ted.is_hg=#{isHg}
and department_id=#{departmentId}
and te.dev_type_name=#{sampleTools}
GROUP BY ted.exper_id
</select>
<select id="downloadCertificateList" resultType="com.bonus.aqgqj.app.entity.TestReportManageAppVo">
SELECT
te.id,
te.submit_location as submitLocation,
te.dev_type_name AS sampleTools,
GROUP_CONCAT( DISTINCT te.dev_module SEPARATOR '、' ) AS devModule,
GROUP_CONCAT( DISTINCT ted.dev_code SEPARATOR '、' ) AS devCode,
te.exper_time AS experTime,
te.next_exper_time AS nextExperTime,
su.user_name as experUser,
CASE
ted.is_hg
WHEN 0 THEN
'合格'
WHEN 1 THEN
'不合格' ELSE ''
END isHg,
tc.custom_name AS customName
FROM
tb_exper_dev ted
LEFT JOIN tb_exper te on te.id=ted.exper_id and te.del_flag=0
LEFT JOIN tb_custom tc ON tc.id = ted.department_id
AND tc.del_flag = 0
LEFT JOIN sys_user su ON su.id = te.create_user
AND su.del_flag = 0
WHERE
ted.exper_id=#{id}
and ted.is_hg=#{isHg}
and department_id=#{departmentId}
and te.dev_type_name=#{sampleTools}
GROUP BY ted.exper_id
LIMIT 1
</select>
</mapper>