住院报告查询功能
This commit is contained in:
parent
b3171392c6
commit
93f9542678
@ -57,6 +57,11 @@
|
|||||||
<groupId>com.czlis</groupId>
|
<groupId>com.czlis</groupId>
|
||||||
<artifactId>lisresources</artifactId>
|
<artifactId>lisresources</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>pdfbox-tools</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
package com.czlis.interfaceCommon.utils;
|
package com.czlis.interfaceCommon.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Base64;
|
||||||
import com.czlis.common.utils.DateUtils;
|
import com.czlis.common.utils.DateUtils;
|
||||||
|
import com.lowagie.text.Document;
|
||||||
|
import com.lowagie.text.pdf.PdfCopy;
|
||||||
|
import com.lowagie.text.pdf.PdfReader;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
@ -15,39 +19,43 @@ import java.util.*;
|
|||||||
public class LisUtil {
|
public class LisUtil {
|
||||||
// 换行符常量(跨平台)
|
// 换行符常量(跨平台)
|
||||||
public static final String LINE_SEPARATOR = System.lineSeparator();
|
public static final String LINE_SEPARATOR = System.lineSeparator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生日格式为:yyyy-MM-dd
|
* 生日格式为:yyyy-MM-dd
|
||||||
* 根据出生日期计算年龄
|
* 根据出生日期计算年龄
|
||||||
|
*
|
||||||
* @param birthday
|
* @param birthday
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Map<String,String> getAgeFromBirthDay(String birthday){
|
public static Map<String, String> getAgeFromBirthDay(String birthday) {
|
||||||
return AgeUtils.getAgeFromBirthDay(birthday);
|
return AgeUtils.getAgeFromBirthDay(birthday);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据年龄获取出生日期
|
* 根据年龄获取出生日期
|
||||||
|
*
|
||||||
* @param nl
|
* @param nl
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Date getBirthDayFromAge(int nl, String nldw) {
|
public static Date getBirthDayFromAge(int nl, String nldw) {
|
||||||
return AgeUtils.getBirthDayFromAge(nl,nldw);
|
return AgeUtils.getBirthDayFromAge(nl, nldw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按GBK编码的字节宽度截取字符串,最多取cutlens个字节(避免截取半个汉字)
|
* 按GBK编码的字节宽度截取字符串,最多取cutlens个字节(避免截取半个汉字)
|
||||||
|
*
|
||||||
* @param str 原始字符串
|
* @param str 原始字符串
|
||||||
* @param beginidx 起始位置
|
* @param beginidx 起始位置
|
||||||
* @param cutlens 截取长度
|
* @param cutlens 截取长度
|
||||||
* @return 截取后的字符串
|
* @return 截取后的字符串
|
||||||
*/
|
*/
|
||||||
public static String substringByGbkWidth(String str,int beginidx,int cutlens) {
|
public static String substringByGbkWidth(String str, int beginidx, int cutlens) {
|
||||||
if (str == null || str.isEmpty()) {
|
if (str == null || str.isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int targetWidth = cutlens; // 目标字节宽度
|
int targetWidth = cutlens; // 目标字节宽度
|
||||||
int currentWidth =beginidx; // 当前累计字节宽度
|
int currentWidth = beginidx; // 当前累计字节宽度
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
for (char c : str.toCharArray()) {
|
for (char c : str.toCharArray()) {
|
||||||
@ -81,10 +89,11 @@ public class LisUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询字符串GBK编码的长度
|
* 查询字符串GBK编码的长度
|
||||||
|
*
|
||||||
* @param str
|
* @param str
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static int getGbkByteLength(String str){
|
public static int getGbkByteLength(String str) {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -95,10 +104,12 @@ public class LisUtil {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串转ASCII值
|
* 字符串转ASCII值
|
||||||
* 中文:返回GBK编码第一个字节的ASCII值(无符号)
|
* 中文:返回GBK编码第一个字节的ASCII值(无符号)
|
||||||
* 英文及其他单字节字符:直接返回其ASCII值
|
* 英文及其他单字节字符:直接返回其ASCII值
|
||||||
|
*
|
||||||
* @param strdata 要处理的字符串
|
* @param strdata 要处理的字符串
|
||||||
* @return 对应的ASCII值
|
* @return 对应的ASCII值
|
||||||
*/
|
*/
|
||||||
@ -135,8 +146,10 @@ public class LisUtil {
|
|||||||
}
|
}
|
||||||
return ascValue;
|
return ascValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算以10为底的对数
|
* 计算以10为底的对数
|
||||||
|
*
|
||||||
* @param x 输入值(必须大于0)
|
* @param x 输入值(必须大于0)
|
||||||
* @return 以10为底的对数值
|
* @return 以10为底的对数值
|
||||||
*/
|
*/
|
||||||
@ -147,8 +160,10 @@ public class LisUtil {
|
|||||||
// 利用换底公式:log10(x) = ln(x) / ln(10)
|
// 利用换底公式:log10(x) = ln(x) / ln(10)
|
||||||
return Math.log(x) / Math.log(10);
|
return Math.log(x) / Math.log(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断字符是否为中文字符
|
* 判断字符是否为中文字符
|
||||||
|
*
|
||||||
* @param c 要判断的字符
|
* @param c 要判断的字符
|
||||||
* @return 是中文字符返回true,否则返回false
|
* @return 是中文字符返回true,否则返回false
|
||||||
*/
|
*/
|
||||||
@ -158,6 +173,7 @@ public class LisUtil {
|
|||||||
|| (c >= 0x3400 && c <= 0x4DBF) // 扩展A
|
|| (c >= 0x3400 && c <= 0x4DBF) // 扩展A
|
||||||
|| (c >= 0x20000 && c <= 0x2A6DF); // 扩展B
|
|| (c >= 0x20000 && c <= 0x2A6DF); // 扩展B
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用正则表达式判断字符串是否为数字
|
* 使用正则表达式判断字符串是否为数字
|
||||||
* 支持:整数(123)、小数(123.45)、正负号(-123、+45.6)
|
* 支持:整数(123)、小数(123.45)、正负号(-123、+45.6)
|
||||||
@ -170,6 +186,7 @@ public class LisUtil {
|
|||||||
String regex = "^[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)$";
|
String regex = "^[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)$";
|
||||||
return str.matches(regex);
|
return str.matches(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用正则表达式判断字符串是否为数字
|
* 使用正则表达式判断字符串是否为数字
|
||||||
* 支持:整数(123)、小数(123.45),不包括带正负号的情况
|
* 支持:整数(123)、小数(123.45),不包括带正负号的情况
|
||||||
@ -185,9 +202,11 @@ public class LisUtil {
|
|||||||
String regex = "^[0-9]+(\\.[0-9]*)?|\\.[0-9]+$";
|
String regex = "^[0-9]+(\\.[0-9]*)?|\\.[0-9]+$";
|
||||||
return str.matches(regex);
|
return str.matches(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将包含比较运算符的字符串转换为特定格式的数值字符串
|
* 将包含比较运算符的字符串转换为特定格式的数值字符串
|
||||||
* 不支持的格式或非数字内容将返回原值
|
* 不支持的格式或非数字内容将返回原值
|
||||||
|
*
|
||||||
* @param input 输入字符串,如">=123", ">123", "<=123", "<123"
|
* @param input 输入字符串,如">=123", ">123", "<=123", "<123"
|
||||||
* @return 转换后的字符串或原值
|
* @return 转换后的字符串或原值
|
||||||
*/
|
*/
|
||||||
@ -239,37 +258,38 @@ public class LisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
保留指定小数位数(四舍五入)
|
* 保留指定小数位数(四舍五入)
|
||||||
支持比较符号 (<=、>=、<、>) 和负号 (-) 同时存在的情况
|
* 支持比较符号 (<=、>=、<、>) 和负号 (-) 同时存在的情况
|
||||||
@param input 输入字符串,如 "123.1234"、">123.252"、"<=123.252"、"-45.67"、">=-89.01"
|
*
|
||||||
@param decimalPlaces 要保留的小数位数,需为非负整数
|
* @param input 输入字符串,如 "123.1234"、">123.252"、"<=123.252"、"-45.67"、">=-89.01"
|
||||||
@return 格式化后的字符串,无法处理时返回原值
|
* @param decimalPlaces 要保留的小数位数,需为非负整数
|
||||||
|
* @return 格式化后的字符串,无法处理时返回原值
|
||||||
*/
|
*/
|
||||||
public static String round (String input, int decimalPlaces) {
|
public static String round(String input, int decimalPlaces) {
|
||||||
// 处理空输入或无效小数位数
|
// 处理空输入或无效小数位数
|
||||||
if (input == null || input.trim ().isEmpty () || decimalPlaces < 0) {
|
if (input == null || input.trim().isEmpty() || decimalPlaces < 0) {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
// 定义比较运算符前缀(按长度排序,确保正确识别)
|
// 定义比较运算符前缀(按长度排序,确保正确识别)
|
||||||
String [] comparisonPrefixes = {"<=", ">=", "<", ">"};
|
String[] comparisonPrefixes = {"<=", ">=", "<", ">"};
|
||||||
String comparisonPrefix = "";
|
String comparisonPrefix = "";
|
||||||
String remainingPart = input.trim (); // 去除首尾空格
|
String remainingPart = input.trim(); // 去除首尾空格
|
||||||
// 提取比较运算符前缀
|
// 提取比较运算符前缀
|
||||||
for (String prefix : comparisonPrefixes) {
|
for (String prefix : comparisonPrefixes) {
|
||||||
if (remainingPart.startsWith (prefix)) {
|
if (remainingPart.startsWith(prefix)) {
|
||||||
comparisonPrefix = prefix;
|
comparisonPrefix = prefix;
|
||||||
remainingPart = remainingPart.substring (prefix.length ()).trim (); // 去除前缀后的空格
|
remainingPart = remainingPart.substring(prefix.length()).trim(); // 去除前缀后的空格
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 尝试解析剩余部分为数字(使用 BigDecimal 避免精度问题)
|
// 尝试解析剩余部分为数字(使用 BigDecimal 避免精度问题)
|
||||||
try {
|
try {
|
||||||
// 解析为 BigDecimal(支持正负号和小数)
|
// 解析为 BigDecimal(支持正负号和小数)
|
||||||
BigDecimal number = new BigDecimal (remainingPart);
|
BigDecimal number = new BigDecimal(remainingPart);
|
||||||
// 设置四舍五入模式并保留指定小数位数
|
// 设置四舍五入模式并保留指定小数位数
|
||||||
BigDecimal rounded = number.setScale (decimalPlaces, RoundingMode.HALF_UP);
|
BigDecimal rounded = number.setScale(decimalPlaces, RoundingMode.HALF_UP);
|
||||||
// 拼接比较前缀和格式化后的数字
|
// 拼接比较前缀和格式化后的数字
|
||||||
return comparisonPrefix + rounded.toPlainString (); //toPlainString 避免科学计数法
|
return comparisonPrefix + rounded.toPlainString(); //toPlainString 避免科学计数法
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// 数字部分无法解析时返回原值
|
// 数字部分无法解析时返回原值
|
||||||
return input;
|
return input;
|
||||||
@ -278,6 +298,7 @@ public class LisUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据天数返回日期,正数往后推,负数往前推
|
* 根据天数返回日期,正数往后推,负数往前推
|
||||||
|
*
|
||||||
* @param day
|
* @param day
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -292,9 +313,10 @@ public class LisUtil {
|
|||||||
// 3. 返回推算的出生日期
|
// 3. 返回推算的出生日期
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
public static Date relativeDate(Date date,int day) {
|
|
||||||
|
public static Date relativeDate(Date date, int day) {
|
||||||
// 1. 获取当前时间(基于Calendar)
|
// 1. 获取当前时间(基于Calendar)
|
||||||
Calendar calendar =Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(date);
|
calendar.setTime(date);
|
||||||
calendar.add(Calendar.DAY_OF_MONTH, day);
|
calendar.add(Calendar.DAY_OF_MONTH, day);
|
||||||
// 2重置时间为00:00:00
|
// 2重置时间为00:00:00
|
||||||
@ -304,8 +326,10 @@ public class LisUtil {
|
|||||||
// 3. 返回推算的出生日期
|
// 3. 返回推算的出生日期
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据天数返回日期时间,正数往后推,负数往前推
|
* 根据天数返回日期时间,正数往后推,负数往前推
|
||||||
|
*
|
||||||
* @param day
|
* @param day
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -317,7 +341,8 @@ public class LisUtil {
|
|||||||
// 3. 返回推算的时间
|
// 3. 返回推算的时间
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
public static Date relativeDateTime(Date date,int day) {
|
|
||||||
|
public static Date relativeDateTime(Date date, int day) {
|
||||||
// 1. 获取当前时间(基于Calendar)
|
// 1. 获取当前时间(基于Calendar)
|
||||||
Calendar calendar = Calendar.getInstance(); // 当前时间
|
Calendar calendar = Calendar.getInstance(); // 当前时间
|
||||||
calendar.setTime(date);
|
calendar.setTime(date);
|
||||||
@ -329,11 +354,12 @@ public class LisUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断前一个时间与后面时间间隔几分钟
|
* 判断前一个时间与后面时间间隔几分钟
|
||||||
|
*
|
||||||
* @param pastDate
|
* @param pastDate
|
||||||
* @param datenow
|
* @param datenow
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static long relativeMinute(Date pastDate,Date datenow) {
|
public static long relativeMinute(Date pastDate, Date datenow) {
|
||||||
LocalDateTime pastTime = pastDate.toInstant()
|
LocalDateTime pastTime = pastDate.toInstant()
|
||||||
.atZone(ZoneId.systemDefault())
|
.atZone(ZoneId.systemDefault())
|
||||||
.toLocalDateTime();
|
.toLocalDateTime();
|
||||||
@ -346,17 +372,18 @@ public class LisUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断一个时间与当前时间间隔几分钟
|
* 判断一个时间与当前时间间隔几分钟
|
||||||
|
*
|
||||||
* @param pastDate
|
* @param pastDate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static long relativeMinute(Date pastDate) {
|
public static long relativeMinute(Date pastDate) {
|
||||||
return relativeMinute(pastDate,new Date());
|
return relativeMinute(pastDate, new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取实体类中指定字段的属性和值
|
* 获取实体类中指定字段的属性和值
|
||||||
|
*
|
||||||
* @param obj 实体类对象
|
* @param obj 实体类对象
|
||||||
* @param fieldName 要查询的字段名
|
* @param fieldName 要查询的字段名
|
||||||
* @return 字段信息字符串
|
* @return 字段信息字符串
|
||||||
@ -389,6 +416,7 @@ public class LisUtil {
|
|||||||
return "无法访问字段:" + fieldName + ",原因:" + e.getMessage();
|
return "无法访问字段:" + fieldName + ",原因:" + e.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFieldType(Object obj, String fieldName) {
|
public static String getFieldType(Object obj, String fieldName) {
|
||||||
if (obj == null || fieldName == null || fieldName.isEmpty()) {
|
if (obj == null || fieldName == null || fieldName.isEmpty()) {
|
||||||
return "参数不能为空";
|
return "参数不能为空";
|
||||||
@ -406,4 +434,72 @@ public class LisUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并多个Base64编码的PDF为字节数组
|
||||||
|
*
|
||||||
|
* @param base64PdfList Base64字符串列表
|
||||||
|
* @return 合并后的PDF字节数组
|
||||||
|
* @throws Exception 处理异常
|
||||||
|
*/
|
||||||
|
private static byte[] mergeBase64Pdfs(List<String> base64PdfList) throws Exception {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
Document document = null;
|
||||||
|
PdfCopy pdfCopy = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < base64PdfList.size(); i++) {
|
||||||
|
// 解码Base64为PDF字节数组
|
||||||
|
String base64Str = base64PdfList.get(i);
|
||||||
|
byte[] pdfBytes = Base64.decode(base64Str); // 使用Hutool解码
|
||||||
|
InputStream inputStream = new ByteArrayInputStream(pdfBytes);
|
||||||
|
|
||||||
|
// 读取PDF文件
|
||||||
|
PdfReader reader = new PdfReader(inputStream);
|
||||||
|
|
||||||
|
// 初始化文档(仅第一次循环时)
|
||||||
|
if (i == 0) {
|
||||||
|
document = new Document(reader.getPageSizeWithRotation(1));
|
||||||
|
pdfCopy = new PdfCopy(document, outputStream);
|
||||||
|
document.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 合并所有页面
|
||||||
|
for (int pageNum = 1; pageNum <= reader.getNumberOfPages(); pageNum++) {
|
||||||
|
pdfCopy.addPage(pdfCopy.getImportedPage(reader, pageNum));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放资源
|
||||||
|
pdfCopy.freeReader(reader);
|
||||||
|
reader.close();
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// 关闭文档和输出流
|
||||||
|
if (document != null) {
|
||||||
|
document.close();
|
||||||
|
}
|
||||||
|
if (outputStream != null) {
|
||||||
|
outputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputStream.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并多个Base64编码的PDF为一个PDF文件
|
||||||
|
* @param base64PdfList 包含多个PDF的Base64字符串列表
|
||||||
|
* @param outputFilePath 合并后PDF的输出路径(如:D:/merged.pdf)
|
||||||
|
* @throws Exception 处理过程中的异常
|
||||||
|
*/
|
||||||
|
public static void mergeToFile(List<String> base64PdfList, String outputFilePath) throws Exception {
|
||||||
|
// 1. 合并所有PDF字节流为一个字节数组
|
||||||
|
byte[] mergedBytes = mergeBase64Pdfs(base64PdfList);
|
||||||
|
|
||||||
|
// 2. 将合并后的字节数组写入文件
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(outputFilePath)) {
|
||||||
|
fos.write(mergedBytes);
|
||||||
|
}
|
||||||
|
System.out.println("PDF合并完成,输出路径:" + outputFilePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -238,16 +238,22 @@ public class ReportUtil {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error("打印条码失败,参数{}",barCodeParam,e);
|
log.error("打印条码失败,参数{}",barCodeParam,e);
|
||||||
}
|
}
|
||||||
String httpPath = "";
|
String httpPath = getPrintURL(pdfName);
|
||||||
if(printURL == null || printURL.equals("")){
|
|
||||||
httpPath = "http://"+ IpUtils.getHostIp() +":" + port + "/"+pdfName+".pdf";
|
|
||||||
}else{
|
|
||||||
httpPath = "http://"+ printURL +":" + port + "/"+pdfName+".pdf";
|
|
||||||
}
|
|
||||||
log.info("传给前端的pdf地址:{}",httpPath);
|
log.info("传给前端的pdf地址:{}",httpPath);
|
||||||
return new Result("0","打印成功!",httpPath);
|
return new Result("0","打印成功!",httpPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPrintURL(String pdfName){
|
||||||
|
String httpPath = "";
|
||||||
|
if(printURL == null || printURL.equals("")){
|
||||||
|
httpPath = "http://"+ IpUtils.getHostIp() +":" + port + "/printPDF/"+pdfName+".pdf";
|
||||||
|
}else{
|
||||||
|
httpPath = "http://"+ printURL +":" + port + "/printPDF/"+pdfName+".pdf";
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*** 获取服务器当前的数据库连接事务对象
|
/*** 获取服务器当前的数据库连接事务对象
|
||||||
* 通过@Qualifier获取实际当前连接事务对象,一般是DynamicDataSource
|
* 通过@Qualifier获取实际当前连接事务对象,一般是DynamicDataSource
|
||||||
|
|||||||
@ -47,6 +47,7 @@ public class DictController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("查询字典列表(不分页)")
|
@ApiOperation("查询字典列表(不分页)")
|
||||||
@GetMapping("/getComDicts")
|
@GetMapping("/getComDicts")
|
||||||
|
@Anonymous
|
||||||
public Result getComDicts(String zdlb) {
|
public Result getComDicts(String zdlb) {
|
||||||
log.info("调用查询字典列表不分页,{}",zdlb);
|
log.info("调用查询字典列表不分页,{}",zdlb);
|
||||||
return comDictService.getComDicts(zdlb);
|
return comDictService.getComDicts(zdlb);
|
||||||
|
|||||||
7
pom.xml
7
pom.xml
@ -44,6 +44,7 @@
|
|||||||
<itext.version>2.1.7</itext.version>
|
<itext.version>2.1.7</itext.version>
|
||||||
<barbecue.version>1.5-beta1</barbecue.version>
|
<barbecue.version>1.5-beta1</barbecue.version>
|
||||||
<pdfbox.version>2.0.29</pdfbox.version>
|
<pdfbox.version>2.0.29</pdfbox.version>
|
||||||
|
<pdfboxTools.version>2.0.29</pdfboxTools.version>
|
||||||
|
|
||||||
<!-- override dependency version -->
|
<!-- override dependency version -->
|
||||||
<tomcat.version>9.0.98</tomcat.version>
|
<tomcat.version>9.0.98</tomcat.version>
|
||||||
@ -337,6 +338,12 @@
|
|||||||
<version>${pdfbox.version}</version>
|
<version>${pdfbox.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>pdfbox-tools</artifactId>
|
||||||
|
<version>${pdfboxTools.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ public class ZybgcxController extends BaseController {
|
|||||||
@PostMapping("/ReportList")
|
@PostMapping("/ReportList")
|
||||||
@Anonymous
|
@Anonymous
|
||||||
public Result getPatReportList(@RequestBody Web_getReportsList webGetReportsList){
|
public Result getPatReportList(@RequestBody Web_getReportsList webGetReportsList){
|
||||||
|
log.info("获取报告信息列表:{}",webGetReportsList);
|
||||||
return zybgcxService.getPatList(webGetReportsList);
|
return zybgcxService.getPatList(webGetReportsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +86,8 @@ public class ZybgcxController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@Anonymous
|
@Anonymous
|
||||||
@ApiOperation("打印报告单")
|
@ApiOperation("打印报告单")
|
||||||
@GetMapping("/print")
|
@PostMapping("/print")
|
||||||
public Result printReport(String bgdh){
|
public Result printReport(@RequestBody String[] bgdh){
|
||||||
return zybgcxService.printReport(bgdh);
|
return zybgcxService.printReport(bgdh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ public interface ZybgcxService {
|
|||||||
Result getPatList(Web_getReportsList webGetReportsList);
|
Result getPatList(Web_getReportsList webGetReportsList);
|
||||||
List<Web_getResultMed> getResultMed(Web_getResultMed webGetResultMed);
|
List<Web_getResultMed> getResultMed(Web_getResultMed webGetResultMed);
|
||||||
|
|
||||||
Result printReport(String bgdh);
|
Result printReport(String[] bgdh);
|
||||||
|
|
||||||
Result getPDFReportOne(Date jyrq, String yq, String ybh);
|
Result getPDFReportOne(Date jyrq, String yq, String ybh);
|
||||||
|
|
||||||
|
|||||||
@ -3,11 +3,15 @@ package com.czlis.zybgcx.service.impl;
|
|||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.czlis.common.config.RuoYiConfig;
|
import com.czlis.common.config.RuoYiConfig;
|
||||||
import com.czlis.common.core.domain.Result;
|
import com.czlis.common.core.domain.Result;
|
||||||
import com.czlis.common.core.domain.entity.lis.LabReqreportPdffile;
|
import com.czlis.common.core.domain.entity.lis.LabReqreportPdffile;
|
||||||
|
import com.czlis.common.utils.ip.IpUtils;
|
||||||
|
import com.czlis.common.utils.uuid.UUID;
|
||||||
import com.czlis.interfaceCommon.utils.CommonUtil;
|
import com.czlis.interfaceCommon.utils.CommonUtil;
|
||||||
|
import com.czlis.interfaceCommon.utils.LisUtil;
|
||||||
import com.czlis.interfaceCommon.utils.ReportUtil;
|
import com.czlis.interfaceCommon.utils.ReportUtil;
|
||||||
import com.czlis.zybgcx.mapper.ZybgcxMapper;
|
import com.czlis.zybgcx.mapper.ZybgcxMapper;
|
||||||
import com.czlis.zybgcx.pojo.Web_fs_printReport;
|
import com.czlis.zybgcx.pojo.Web_fs_printReport;
|
||||||
@ -17,10 +21,15 @@ import com.czlis.zybgcx.pojo.Web_result;
|
|||||||
import com.czlis.zybgcx.service.ZybgcxService;
|
import com.czlis.zybgcx.service.ZybgcxService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
|
||||||
import javax.print.PrintException;
|
import javax.print.PrintException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -35,7 +44,6 @@ public class ZybgcxServcieImpl implements ZybgcxService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CommonUtil commonUtil;
|
private CommonUtil commonUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取报告信息
|
* 获取报告信息
|
||||||
* @param webGetReportsList
|
* @param webGetReportsList
|
||||||
@ -63,27 +71,35 @@ public class ZybgcxServcieImpl implements ZybgcxService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Result printReport(String bgdh) {
|
public Result printReport(String[] bgdh) {
|
||||||
String[] strings = StrUtil.splitToArray(bgdh, "_");
|
List<String> bgdhBase64List = new ArrayList<>();
|
||||||
if(strings.length != 3) return new Result("-1","传入的报告单号不对!");
|
for (String string : bgdh) {
|
||||||
String jyrqStr = strings[0];
|
String[] stringParam = StrUtil.splitToArray(string, "_");
|
||||||
String yq = strings[1];
|
if(stringParam.length != 3) return new Result("-1","传入的报告单号不对!");
|
||||||
String ybh = strings[2];
|
String jyrqStr = stringParam[0];
|
||||||
|
String yq = stringParam[1];
|
||||||
|
String ybh = stringParam[2];
|
||||||
LabReqreportPdffile labReqreportPdffileOne = commonUtil.getLabReqreportPdffileOne(DateUtil.parse(jyrqStr, "yyyyMMdd"), yq, ybh);
|
LabReqreportPdffile labReqreportPdffileOne = commonUtil.getLabReqreportPdffileOne(DateUtil.parse(jyrqStr, "yyyyMMdd"), yq, ybh);
|
||||||
byte[] decode = Base64.decode(labReqreportPdffileOne.getBASE64PDF());
|
if(labReqreportPdffileOne == null) continue;
|
||||||
String pdfName = bgdh+".pdf";
|
String base64PDF = labReqreportPdffileOne.getBASE64PDF();
|
||||||
String path = RuoYiConfig.getProfile() +"/printPDF/"+pdfName;
|
if(base64PDF == null || base64PDF.equals("")) continue;
|
||||||
log.info("打印目录文件为:{}",path);
|
bgdhBase64List.add(base64PDF);
|
||||||
FileUtil.writeBytes(decode, path);
|
}
|
||||||
|
String pdfName = UUID.randomUUID().toString();
|
||||||
|
String path = RuoYiConfig.getProfile() +"/config/static/printPDF/"+pdfName+".pdf";
|
||||||
|
//合并pdf
|
||||||
try {
|
try {
|
||||||
ReportUtil.printPdf(path,"");
|
LisUtil.mergeToFile(bgdhBase64List,path);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error("打印pdf报告失败:",e);
|
log.error("合并pdf:{}报告失败:{}",bgdh,e);
|
||||||
return new Result("-1","打印pdf报告失败:"+e.getMessage());
|
return new Result("-1",e.getMessage());
|
||||||
}
|
}
|
||||||
|
//String httpPath = reportUtil.getPrintURL(pdfName);
|
||||||
return new Result("0","打印成功!");
|
//转成base64字符串
|
||||||
|
File file = new File(path);
|
||||||
|
String encode = Base64.encode(file);
|
||||||
|
return new Result("0","打印成功!",encode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -150,4 +166,5 @@ public class ZybgcxServcieImpl implements ZybgcxService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="sqh != null and sqh != ''"> AND sqh like '%'+#{sqh}+'%'</if>
|
<if test="sqh != null and sqh != ''"> AND sqh like '%'+#{sqh}+'%'</if>
|
||||||
<if test="dybz != null and dybz != ''"> AND dybz = #{dybz}</if>
|
<if test="dybz != null and dybz != ''"> AND dybz = #{dybz}</if>
|
||||||
<if test="ksdh !=null and ksdh != ''"> and ksdh = #{ksdh}</if>
|
<if test="ksdh !=null and ksdh != ''"> and ksdh = #{ksdh}</if>
|
||||||
<if test="alarmflag != null and alarmflag = '1'"> <![CDATA[AND alarmflag <> '0']]></if>
|
<if test="alarmflag != null"> <![CDATA[AND alarmflag = #{alarmflag}]]></if>
|
||||||
|
<if test="ch != null and ch !=''"> and ch = #{ch}</if>
|
||||||
|
<if test="jzbz != null">and jzbz = #{jzbz}</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getResultMed" resultType="com.czlis.zybgcx.pojo.Web_getResultMed">
|
<select id="getResultMed" resultType="com.czlis.zybgcx.pojo.Web_getResultMed">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user