打印预览

master
jian.wang 2 years ago
parent b6a80b852c
commit ffff80d402

@ -1130,7 +1130,7 @@ public class TemplateSearchController {
@OptionalLog(module = "下载图片转换pdf压缩包", methods = "病案查询页面")
@RequestMapping(value = "downloadBloodZip", produces = {"text/json;charset=UTF-8"}, method = RequestMethod.POST)
@ResponseBody
public void downloadBloodZip(HttpServletResponse response, String patientIds, String flag) {
public void downloadBloodZip(HttpServletResponse response, String patientIds, String flag, String dataSource) {
if (StringUtils.isNoneBlank(patientIds)) {
try {
@ -1150,9 +1150,12 @@ public class TemplateSearchController {
if (scanPathVo.getPatientId().equals(patinetId)) {
vo.setName(scanPathVo.getName());
vo.setInpatientNo(scanPathVo.getInpatientNo());
vo.setSubjectNo(scanPathVo.getSubjectNo());
String disDate = scanPathVo.getDisDate();
if(!ObjectUtils.isEmpty(disDate)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
vo.setDisDate(sdf.parse(disDate));
}
String fileRealPath = scanPathVo.getFileRealPath();
if (StringUtils.isNoneBlank(fileRealPath) && new File(fileRealPath).exists()) {
filePaths.add(fileRealPath);
@ -1165,7 +1168,7 @@ public class TemplateSearchController {
}
}
String zipName = "档案pdf压缩包";
downloadPdfZip(response, zipName, list);
downloadPdfZip(response, zipName, list, dataSource);
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
@ -1335,66 +1338,50 @@ public class TemplateSearchController {
//封装下载pdf压缩包方法
private void downloadPdfZip(HttpServletResponse response, String zipName, Set<ScanPathForPatientListVo> list) {
private void downloadPdfZip(HttpServletResponse response, String zipName, Set<ScanPathForPatientListVo> list, String dataSource) throws UnsupportedEncodingException {
response.reset();
response.setContentType("application/zip;charset=UTF-8");
ZipOutputStream zos = null;
BufferedOutputStream bos = null;
ByteArrayOutputStream out = null;
BufferedInputStream bis = null;
try {
zipName = java.net.URLEncoder.encode(zipName, "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + zipName + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ").zip");
zos = new ZipOutputStream(response.getOutputStream());
bos = new BufferedOutputStream(zos);
String filePdfName = "";
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())){
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
for (ScanPathForPatientListVo vo : list) {
String disDate = "";
if (null != vo.getDisDate()) {
String disDate = "";
if (!ObjectUtils.isEmpty(vo.getDisDate())) {
disDate = fmt.format(vo.getDisDate());
}
List<String> scanPathList = vo.getScanPathList();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
//每个文件名
String fileName = vo.getInpatientNo().trim() + "-" + vo.getName().trim() + "-" + disDate.trim() + "_" + fmt.format(new Date());
String inpatientNo = ObjectUtils.isEmpty(vo.getInpatientNo()) ? "无" : vo.getInpatientNo().trim();
String name = ObjectUtils.isEmpty(vo.getName()) ? "无" : vo.getName().trim();
if("3".equals(dataSource)){
//药学楼
filePdfName = vo.getSubjectNo().trim() + "-" + name + "_" + fmt.format(new Date());
}else{
filePdfName = inpatientNo + "-" + name + "-" + disDate.trim() + "_" + fmt.format(new Date());
}
String fileName = hospitaInfo + "_" + filePdfName;
zos.putNextEntry(new ZipEntry(fileName + ".pdf"));
//合成pdf
out = new ByteArrayOutputStream();
img2PdfUtil.imageToPdfToBuffOut(out, scanPathList, emrPdfWaterSet);
byte[] file = out.toByteArray(); //这个zip文件的字节
bis = new BufferedInputStream(new ByteArrayInputStream(file));
try (BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(out.toByteArray()))) {
//输出
int len = 0;
byte[] buf = new byte[1024 * 1024];
while ((len = bis.read(buf, 0, buf.length)) != -1) {
bos.write(buf, 0, len);
zos.write(buf, 0, len);
}
bis.close(); // 及时关闭流,避免资源泄露
out.reset();
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
} finally {
try {
if (null != bos) {
bos.flush();
bos.close();
}
if (null != bis) {
bis.close();
}
out.flush();
out.close();
if (null != zos) {
zos.flush();
zos.close();
}
} catch (IOException e) {
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
}
}
}
/**
/**
@ -1560,8 +1547,8 @@ public class TemplateSearchController {
JSONObject jsonObject= (JSONObject) JSONObject.toJSON(scanPathVo);
List<String> patientInfoList = Arrays.asList(patientInfo.split(","));
for (String list:patientInfoList){
String contents = jsonObject.getString(list).trim();
if (list.equals("disDate")){
String contents = ObjectUtils.isEmpty(jsonObject.getString(list)) ? "无" : jsonObject.getString(list).trim();
if ("disDate".equals(list) && !ObjectUtils.isEmpty(jsonObject.getString(list))){
String dateString = jsonObject.getString(list);
SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat targetFormat = new SimpleDateFormat("yyyyMMdd");

@ -12,6 +12,15 @@ public class ScanPathForPatientListVo {
private Date disDate;
private String subjectNo;
public String getSubjectNo() {
return subjectNo;
}
public void setSubjectNo(String subjectNo) {
this.subjectNo = subjectNo;
}
public Date getDisDate() {
return disDate;
}

@ -31,6 +31,16 @@ public class ScanPathVo {
private String assortName;
private String subjectNo;
public String getSubjectNo() {
return subjectNo;
}
public void setSubjectNo(String subjectNo) {
this.subjectNo = subjectNo;
}
public String getAssortName() {
return assortName;
}

@ -9,6 +9,7 @@
<result column="dis_date" property="disDate" jdbcType="VARCHAR"/>
<result column="fileRealPath" property="fileRealPath" jdbcType="VARCHAR"/>
<result column="assort_name" property="assortName" jdbcType="VARCHAR"/>
<result column="subject_no" property="subjectNo" jdbcType="VARCHAR"/>
</resultMap>
<!--湛江、英德根据patientId集合查询图片路径-->
<select id="selectScanFileByPatientIds" resultMap="BaseResultMap" parameterType="java.lang.String">
@ -40,6 +41,7 @@
commomtable.name,
commomtable.inpatient_no,
commomtable.dis_date,
commomtable.subject_no,
dbo.t_scan_assort.assort_id,
dbo.t_scan_assort.scan_page,
case

@ -52,7 +52,7 @@
<mvc:resources mapping="/reloadE/**" location="file:E:/" />
<mvc:resources mapping="/reloadF/**" location="file:F:/" />
<mvc:resources mapping="/reloadG/**" location="file:G:/" />
<mvc:resources mapping="/reloadH/**" location="file:D:/" />
<mvc:resources mapping="/reloadH/**" location="file:H:/" />
<mvc:resources mapping="/reloadI/**" location="file:I:/" />
<mvc:resources mapping="/reloadJ/**" location="file:J:/" />
<mvc:resources mapping="/reloadK/**" location="file:K:/" />

@ -552,6 +552,7 @@ function updateCommomInfo() {
* @param typeId
*/
function downloadZip(typeId){
var dataSource = $("#dataSource").val();
var patientIds = "";
getChecked();
var checks = $("#checks").val();
@ -559,7 +560,7 @@ function downloadZip(typeId){
patientIds = powerPotient(checks, true,typeId);
if(patientIds != ''){
patientIds = patientIds.substring(0,patientIds.length-1);
post(path+'/template/downloadBloodZip',{"patientIds":patientIds,
post(path+'/template/downloadBloodZip',{"patientIds":patientIds,"dataSource": dataSource,
"flag":$("#flag").val()});
}else{
toastr.warning("必须申请通过!")

@ -26,6 +26,7 @@
Print.prototype = {
init: function () {
var content = this.getStyle() + this.getHtml();
console.log("----------打印预览图片路径------------", this.getHtml())
this.writeIframe(content);
},
extend: function (obj, obj2) {

@ -450,7 +450,7 @@ if (typeof PDFJS === 'undefined') {
if ('language' in navigator) {
return;
}
PDFJS.locale = navigator.userLanguage || 'en-US';
PDFJS.locale = navigator.userLanguage || 'zh-CN' || 'en-US';
})();
(function checkRangeRequests() {

Loading…
Cancel
Save