update
This commit is contained in:
@@ -187,6 +187,11 @@
|
|||||||
<artifactId>poi-ooxml-full</artifactId>
|
<artifactId>poi-ooxml-full</artifactId>
|
||||||
<version>5.2.3</version>
|
<version>5.2.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@@ -222,8 +222,13 @@ public class TestRecordController {
|
|||||||
|
|
||||||
@ApiOperation("生成检验记录-贵阳禁毒")
|
@ApiOperation("生成检验记录-贵阳禁毒")
|
||||||
@GetMapping("/inspectionRecord")
|
@GetMapping("/inspectionRecord")
|
||||||
public R inspectionRecord(String entrustId, String materialType) throws Exception {
|
public R inspectionRecord(String businessId, String materialType) throws Exception {
|
||||||
return inspectRecordService.buildInspectionRecord(entrustId, materialType);
|
return inspectRecordService.buildInspectionRecord(businessId, materialType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("预览检验记录-贵阳禁毒")
|
||||||
|
@GetMapping("/previewRecord")
|
||||||
|
public void previewRecord(String businessId, String materialType, HttpServletResponse response) throws Exception {
|
||||||
|
inspectRecordService.previewInspectionRecord(businessId, materialType, response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package digital.laboratory.platform.inspection.service;
|
|||||||
|
|
||||||
import digital.laboratory.platform.common.core.util.R;
|
import digital.laboratory.platform.common.core.util.R;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ChenJiangBao
|
* @author ChenJiangBao
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@@ -12,9 +14,11 @@ public interface InspectRecordService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成检验记录-贵阳禁毒
|
* 生成检验记录-贵阳禁毒
|
||||||
* @param entrustId 委托id
|
* @param businessId 委托id
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
R buildInspectionRecord(String entrustId, String materialType) throws Exception;
|
R buildInspectionRecord(String businessId, String materialType) throws Exception;
|
||||||
|
|
||||||
|
void previewInspectionRecord(String businessId, String materialType, HttpServletResponse servletResponse) throws Exception;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package digital.laboratory.platform.inspection.service.impl;
|
package digital.laboratory.platform.inspection.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
@@ -10,6 +10,7 @@ import com.deepoove.poi.config.Configure;
|
|||||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||||
import com.deepoove.poi.xwpf.NiceXWPFDocument;
|
import com.deepoove.poi.xwpf.NiceXWPFDocument;
|
||||||
import digital.laboratory.platform.common.core.util.R;
|
import digital.laboratory.platform.common.core.util.R;
|
||||||
|
import digital.laboratory.platform.common.feign.RemoteWord2PDFService;
|
||||||
import digital.laboratory.platform.common.oss.service.OssFile;
|
import digital.laboratory.platform.common.oss.service.OssFile;
|
||||||
import digital.laboratory.platform.inspection.dto.TestRecordSampleDataDocDTO;
|
import digital.laboratory.platform.inspection.dto.TestRecordSampleDataDocDTO;
|
||||||
import digital.laboratory.platform.inspection.entity.TestRecordInstrument;
|
import digital.laboratory.platform.inspection.entity.TestRecordInstrument;
|
||||||
@@ -27,11 +28,14 @@ import digital.laboratory.platform.inspetion.api.entity.TargetObject;
|
|||||||
import digital.laboratory.platform.inspetion.api.entity.TestRecord;
|
import digital.laboratory.platform.inspetion.api.entity.TestRecord;
|
||||||
import digital.laboratory.platform.sys.entity.Drug;
|
import digital.laboratory.platform.sys.entity.Drug;
|
||||||
import digital.laboratory.platform.sys.enums.entrust.EntrustBiologyType;
|
import digital.laboratory.platform.sys.enums.entrust.EntrustBiologyType;
|
||||||
|
import feign.Response;
|
||||||
import org.apache.commons.io.output.ByteArrayOutputStream;
|
import org.apache.commons.io.output.ByteArrayOutputStream;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.mock.web.MockMultipartFile;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -70,24 +74,50 @@ public class InspectRecordServiceImpl implements InspectRecordService {
|
|||||||
@Resource
|
@Resource
|
||||||
private TestRecordSampledataExpandService testRecordSampledataExpandService;
|
private TestRecordSampledataExpandService testRecordSampledataExpandService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RemoteWord2PDFService remoteWord2PDFService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成检验记录-贵阳禁毒
|
* 生成检验记录-贵阳禁毒
|
||||||
*
|
*
|
||||||
* @param entrustId 委托id
|
* @param businessId 委托id
|
||||||
* @param materialType 标注当前委托的检材是尿液还是毛发
|
* @param materialType 标注当前委托的检材是尿液还是毛发
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public R buildInspectionRecord(String entrustId, String materialType) throws Exception {
|
public R buildInspectionRecord(String businessId, String materialType) throws Exception {
|
||||||
EntrustInfo entrustInfo = entrustInfoService.getById(entrustId);
|
EntrustInfo entrustInfo = entrustInfoService.getById(businessId);
|
||||||
if (entrustInfo == null) {
|
if (entrustInfo == null) {
|
||||||
return R.ok(false, "委托信息不存在!");
|
return R.ok(false, "委托信息不存在!");
|
||||||
}
|
}
|
||||||
if (entrustInfo.getBusinessType().equals(BusinessType.BOINT_CASE.getBusinessType())) {
|
if (entrustInfo.getBusinessType().equals(BusinessType.BOINT_CASE.getBusinessType())) {
|
||||||
return R.ok(this.buildInVivoDocFile(entrustInfo, materialType), "生成成功!");
|
return R.ok(this.buildInVivoDocFile(entrustInfo, materialType), "生成成功!");
|
||||||
}
|
}
|
||||||
return R.ok(this.generateCommonDrugInpectRecord(entrustId));
|
return R.ok(this.generateCommonDrugInpectRecord(businessId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void previewInspectionRecord(String businessId, String materialType, HttpServletResponse servletResponse) throws Exception {
|
||||||
|
|
||||||
|
String path = (String) this.buildInspectionRecord(businessId, materialType).getData();
|
||||||
|
java.io.ByteArrayOutputStream fosWord = new java.io.ByteArrayOutputStream();
|
||||||
|
ossFile.fileGet(path, fosWord);
|
||||||
|
ByteArrayInputStream fisWord = new ByteArrayInputStream(fosWord.toByteArray());
|
||||||
|
fosWord.close();
|
||||||
|
// 转换临时目录中的 word 文档为 PDF
|
||||||
|
MockMultipartFile mockMultipartFile = new MockMultipartFile("file", "检验记录" + ".docx", "image/jpg", fisWord);
|
||||||
|
String pdfFilePath = path.substring(0, path.lastIndexOf(".")) + ".pdf";
|
||||||
|
Response response = remoteWord2PDFService.word2pdf(mockMultipartFile);
|
||||||
|
fisWord.close();
|
||||||
|
org.apache.commons.io.output.ByteArrayOutputStream outPDF = new org.apache.commons.io.output.ByteArrayOutputStream();
|
||||||
|
IoUtil.copy(response.body().asInputStream(), outPDF, IoUtil.DEFAULT_MIDDLE_BUFFER_SIZE);
|
||||||
|
ByteArrayInputStream isPDF = new ByteArrayInputStream(outPDF.toByteArray());
|
||||||
|
outPDF.close();
|
||||||
|
ossFile.fileSave(pdfFilePath, isPDF);
|
||||||
|
isPDF.close();
|
||||||
|
ossFile.fileGet(pdfFilePath, servletResponse.getOutputStream());
|
||||||
|
System.out.println(String.format("转换为 PDF 结束"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user