打印预览

master
jian.wang 2 years ago
parent b6a80b852c
commit ffff80d402

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

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

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

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

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

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

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

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

Loading…
Cancel
Save