Compare commits
2 Commits
54f40ff021
...
e172a4eae4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e172a4eae4 | ||
|
|
93f9542678 |
@ -57,6 +57,11 @@
|
||||
<groupId>com.czlis</groupId>
|
||||
<artifactId>lisresources</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox-tools</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.czlis.interfaceCommon.utils;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
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.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@ -15,39 +19,43 @@ import java.util.*;
|
||||
public class LisUtil {
|
||||
// 换行符常量(跨平台)
|
||||
public static final String LINE_SEPARATOR = System.lineSeparator();
|
||||
|
||||
/**
|
||||
* 生日格式为:yyyy-MM-dd
|
||||
* 根据出生日期计算年龄
|
||||
*
|
||||
* @param birthday
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> getAgeFromBirthDay(String birthday){
|
||||
public static Map<String, String> getAgeFromBirthDay(String birthday) {
|
||||
return AgeUtils.getAgeFromBirthDay(birthday);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据年龄获取出生日期
|
||||
*
|
||||
* @param nl
|
||||
* @return
|
||||
*/
|
||||
public static Date getBirthDayFromAge(int nl, String nldw) {
|
||||
return AgeUtils.getBirthDayFromAge(nl,nldw);
|
||||
return AgeUtils.getBirthDayFromAge(nl, nldw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按GBK编码的字节宽度截取字符串,最多取cutlens个字节(避免截取半个汉字)
|
||||
* @param str 原始字符串
|
||||
*
|
||||
* @param str 原始字符串
|
||||
* @param beginidx 起始位置
|
||||
* @param cutlens 截取长度
|
||||
* @param cutlens 截取长度
|
||||
* @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()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int targetWidth = cutlens; // 目标字节宽度
|
||||
int currentWidth =beginidx; // 当前累计字节宽度
|
||||
int currentWidth = beginidx; // 当前累计字节宽度
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
for (char c : str.toCharArray()) {
|
||||
@ -81,10 +89,11 @@ public class LisUtil {
|
||||
|
||||
/**
|
||||
* 查询字符串GBK编码的长度
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static int getGbkByteLength(String str){
|
||||
public static int getGbkByteLength(String str) {
|
||||
if (str == null) {
|
||||
return 0;
|
||||
}
|
||||
@ -95,10 +104,12 @@ public class LisUtil {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转ASCII值
|
||||
* 中文:返回GBK编码第一个字节的ASCII值(无符号)
|
||||
* 英文及其他单字节字符:直接返回其ASCII值
|
||||
*
|
||||
* @param strdata 要处理的字符串
|
||||
* @return 对应的ASCII值
|
||||
*/
|
||||
@ -135,8 +146,10 @@ public class LisUtil {
|
||||
}
|
||||
return ascValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算以10为底的对数
|
||||
*
|
||||
* @param x 输入值(必须大于0)
|
||||
* @return 以10为底的对数值
|
||||
*/
|
||||
@ -147,8 +160,10 @@ public class LisUtil {
|
||||
// 利用换底公式:log10(x) = ln(x) / ln(10)
|
||||
return Math.log(x) / Math.log(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符是否为中文字符
|
||||
*
|
||||
* @param c 要判断的字符
|
||||
* @return 是中文字符返回true,否则返回false
|
||||
*/
|
||||
@ -158,6 +173,7 @@ public class LisUtil {
|
||||
|| (c >= 0x3400 && c <= 0x4DBF) // 扩展A
|
||||
|| (c >= 0x20000 && c <= 0x2A6DF); // 扩展B
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用正则表达式判断字符串是否为数字
|
||||
* 支持:整数(123)、小数(123.45)、正负号(-123、+45.6)
|
||||
@ -170,6 +186,7 @@ public class LisUtil {
|
||||
String regex = "^[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)$";
|
||||
return str.matches(regex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用正则表达式判断字符串是否为数字
|
||||
* 支持:整数(123)、小数(123.45),不包括带正负号的情况
|
||||
@ -185,9 +202,11 @@ public class LisUtil {
|
||||
String regex = "^[0-9]+(\\.[0-9]*)?|\\.[0-9]+$";
|
||||
return str.matches(regex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将包含比较运算符的字符串转换为特定格式的数值字符串
|
||||
* 不支持的格式或非数字内容将返回原值
|
||||
*
|
||||
* @param input 输入字符串,如">=123", ">123", "<=123", "<123"
|
||||
* @return 转换后的字符串或原值
|
||||
*/
|
||||
@ -239,37 +258,38 @@ public class LisUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
保留指定小数位数(四舍五入)
|
||||
支持比较符号 (<=、>=、<、>) 和负号 (-) 同时存在的情况
|
||||
@param input 输入字符串,如 "123.1234"、">123.252"、"<=123.252"、"-45.67"、">=-89.01"
|
||||
@param decimalPlaces 要保留的小数位数,需为非负整数
|
||||
@return 格式化后的字符串,无法处理时返回原值
|
||||
* 保留指定小数位数(四舍五入)
|
||||
* 支持比较符号 (<=、>=、<、>) 和负号 (-) 同时存在的情况
|
||||
*
|
||||
* @param input 输入字符串,如 "123.1234"、">123.252"、"<=123.252"、"-45.67"、">=-89.01"
|
||||
* @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;
|
||||
}
|
||||
// 定义比较运算符前缀(按长度排序,确保正确识别)
|
||||
String [] comparisonPrefixes = {"<=", ">=", "<", ">"};
|
||||
String[] comparisonPrefixes = {"<=", ">=", "<", ">"};
|
||||
String comparisonPrefix = "";
|
||||
String remainingPart = input.trim (); // 去除首尾空格
|
||||
String remainingPart = input.trim(); // 去除首尾空格
|
||||
// 提取比较运算符前缀
|
||||
for (String prefix : comparisonPrefixes) {
|
||||
if (remainingPart.startsWith (prefix)) {
|
||||
if (remainingPart.startsWith(prefix)) {
|
||||
comparisonPrefix = prefix;
|
||||
remainingPart = remainingPart.substring (prefix.length ()).trim (); // 去除前缀后的空格
|
||||
remainingPart = remainingPart.substring(prefix.length()).trim(); // 去除前缀后的空格
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 尝试解析剩余部分为数字(使用 BigDecimal 避免精度问题)
|
||||
try {
|
||||
// 解析为 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) {
|
||||
// 数字部分无法解析时返回原值
|
||||
return input;
|
||||
@ -278,6 +298,7 @@ public class LisUtil {
|
||||
|
||||
/**
|
||||
* 根据天数返回日期,正数往后推,负数往前推
|
||||
*
|
||||
* @param day
|
||||
* @return
|
||||
*/
|
||||
@ -286,15 +307,16 @@ public class LisUtil {
|
||||
Calendar calendar = Calendar.getInstance(); // 当前时间
|
||||
calendar.add(Calendar.DAY_OF_MONTH, day);
|
||||
// 2重置时间为00:00:00
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
// 3. 返回推算的出生日期
|
||||
return calendar.getTime();
|
||||
}
|
||||
public static Date relativeDate(Date date,int day) {
|
||||
|
||||
public static Date relativeDate(Date date, int day) {
|
||||
// 1. 获取当前时间(基于Calendar)
|
||||
Calendar calendar =Calendar.getInstance();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, day);
|
||||
// 2重置时间为00:00:00
|
||||
@ -304,8 +326,10 @@ public class LisUtil {
|
||||
// 3. 返回推算的出生日期
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据天数返回日期时间,正数往后推,负数往前推
|
||||
*
|
||||
* @param day
|
||||
* @return
|
||||
*/
|
||||
@ -317,7 +341,8 @@ public class LisUtil {
|
||||
// 3. 返回推算的时间
|
||||
return calendar.getTime();
|
||||
}
|
||||
public static Date relativeDateTime(Date date,int day) {
|
||||
|
||||
public static Date relativeDateTime(Date date, int day) {
|
||||
// 1. 获取当前时间(基于Calendar)
|
||||
Calendar calendar = Calendar.getInstance(); // 当前时间
|
||||
calendar.setTime(date);
|
||||
@ -329,11 +354,12 @@ public class LisUtil {
|
||||
|
||||
/**
|
||||
* 判断前一个时间与后面时间间隔几分钟
|
||||
*
|
||||
* @param pastDate
|
||||
* @param datenow
|
||||
* @return
|
||||
*/
|
||||
public static long relativeMinute(Date pastDate,Date datenow) {
|
||||
public static long relativeMinute(Date pastDate, Date datenow) {
|
||||
LocalDateTime pastTime = pastDate.toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime();
|
||||
@ -346,49 +372,51 @@ public class LisUtil {
|
||||
|
||||
/**
|
||||
* 判断一个时间与当前时间间隔几分钟
|
||||
*
|
||||
* @param pastDate
|
||||
* @return
|
||||
*/
|
||||
public static long relativeMinute(Date pastDate) {
|
||||
return relativeMinute(pastDate,new Date());
|
||||
return relativeMinute(pastDate, new Date());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取实体类中指定字段的属性和值
|
||||
* @param obj 实体类对象
|
||||
* @param fieldName 要查询的字段名
|
||||
* @return 字段信息字符串
|
||||
*/
|
||||
public static String getFieldValue(Object obj, String fieldName) {
|
||||
if (obj == null || fieldName == null || fieldName.isEmpty()) {
|
||||
return "参数不能为空";
|
||||
}
|
||||
Class<?> clazz = obj.getClass();
|
||||
try {
|
||||
// 获取指定字段(包括私有字段)
|
||||
Field field = clazz.getDeclaredField(fieldName);
|
||||
// 设置访问权限(私有字段需要开启)
|
||||
field.setAccessible(true);
|
||||
// 1. 获取字段属性信息
|
||||
String fieldType = field.getType().getSimpleName(); // 字段类型(如String、Integer)
|
||||
// 2. 获取字段值
|
||||
Object fieldValue = field.get(obj); // 获取字段值
|
||||
String valueStr;
|
||||
// 处理特殊类型(如Date格式化)
|
||||
if (fieldValue instanceof Date) {
|
||||
valueStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) fieldValue);
|
||||
} else {
|
||||
valueStr = (fieldValue != null) ? fieldValue.toString() : "null";
|
||||
}
|
||||
return valueStr;
|
||||
} catch (NoSuchFieldException e) {
|
||||
return "字段不存在:" + fieldName;
|
||||
} catch (IllegalAccessException e) {
|
||||
return "无法访问字段:" + fieldName + ",原因:" + e.getMessage();
|
||||
}
|
||||
/**
|
||||
* 获取实体类中指定字段的属性和值
|
||||
*
|
||||
* @param obj 实体类对象
|
||||
* @param fieldName 要查询的字段名
|
||||
* @return 字段信息字符串
|
||||
*/
|
||||
public static String getFieldValue(Object obj, String fieldName) {
|
||||
if (obj == null || fieldName == null || fieldName.isEmpty()) {
|
||||
return "参数不能为空";
|
||||
}
|
||||
Class<?> clazz = obj.getClass();
|
||||
try {
|
||||
// 获取指定字段(包括私有字段)
|
||||
Field field = clazz.getDeclaredField(fieldName);
|
||||
// 设置访问权限(私有字段需要开启)
|
||||
field.setAccessible(true);
|
||||
// 1. 获取字段属性信息
|
||||
String fieldType = field.getType().getSimpleName(); // 字段类型(如String、Integer)
|
||||
// 2. 获取字段值
|
||||
Object fieldValue = field.get(obj); // 获取字段值
|
||||
String valueStr;
|
||||
// 处理特殊类型(如Date格式化)
|
||||
if (fieldValue instanceof Date) {
|
||||
valueStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) fieldValue);
|
||||
} else {
|
||||
valueStr = (fieldValue != null) ? fieldValue.toString() : "null";
|
||||
}
|
||||
return valueStr;
|
||||
} catch (NoSuchFieldException e) {
|
||||
return "字段不存在:" + fieldName;
|
||||
} catch (IllegalAccessException e) {
|
||||
return "无法访问字段:" + fieldName + ",原因:" + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFieldType(Object obj, String fieldName) {
|
||||
if (obj == null || fieldName == null || fieldName.isEmpty()) {
|
||||
return "参数不能为空";
|
||||
@ -400,10 +428,78 @@ public class LisUtil {
|
||||
// 设置访问权限(私有字段需要开启)
|
||||
field.setAccessible(true);
|
||||
// 1. 获取字段属性信息
|
||||
return field.getType().getSimpleName(); // 字段类型(如String、Integer)
|
||||
return field.getType().getSimpleName(); // 字段类型(如String、Integer)
|
||||
} catch (NoSuchFieldException e) {
|
||||
return "字段不存在:" + fieldName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并多个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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ package com.czlis.interfaceCommon.utils;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czlis.common.config.RuoYiConfig;
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstr;
|
||||
import com.czlis.common.utils.ip.IpUtils;
|
||||
import com.czlis.interfaceCommon.mapper.BackPaperMapper;
|
||||
import com.czlis.interfaceCommon.pojo.entity.BackPaperDetail;
|
||||
|
||||
@ -47,6 +47,7 @@ public class DictController extends BaseController {
|
||||
|
||||
@ApiOperation("查询字典列表(不分页)")
|
||||
@GetMapping("/getComDicts")
|
||||
@Anonymous
|
||||
public Result getComDicts(String zdlb) {
|
||||
log.info("调用查询字典列表不分页,{}",zdlb);
|
||||
return comDictService.getComDicts(zdlb);
|
||||
|
||||
7
pom.xml
7
pom.xml
@ -44,6 +44,7 @@
|
||||
<itext.version>2.1.7</itext.version>
|
||||
<barbecue.version>1.5-beta1</barbecue.version>
|
||||
<pdfbox.version>2.0.29</pdfbox.version>
|
||||
<pdfboxTools.version>2.0.29</pdfboxTools.version>
|
||||
|
||||
<!-- override dependency version -->
|
||||
<tomcat.version>9.0.98</tomcat.version>
|
||||
@ -337,6 +338,12 @@
|
||||
<version>${pdfbox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox-tools</artifactId>
|
||||
<version>${pdfboxTools.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ public class ZybgcxController extends BaseController {
|
||||
@PostMapping("/ReportList")
|
||||
@Anonymous
|
||||
public Result getPatReportList(@RequestBody Web_getReportsList webGetReportsList){
|
||||
log.info("获取报告信息列表:{}",webGetReportsList);
|
||||
return zybgcxService.getPatList(webGetReportsList);
|
||||
}
|
||||
|
||||
@ -85,8 +86,8 @@ public class ZybgcxController extends BaseController {
|
||||
*/
|
||||
@Anonymous
|
||||
@ApiOperation("打印报告单")
|
||||
@GetMapping("/print")
|
||||
public Result printReport(String bgdh){
|
||||
@PostMapping("/print")
|
||||
public Result printReport(@RequestBody String[] bgdh){
|
||||
return zybgcxService.printReport(bgdh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ public interface ZybgcxService {
|
||||
Result getPatList(Web_getReportsList webGetReportsList);
|
||||
List<Web_getResultMed> getResultMed(Web_getResultMed webGetResultMed);
|
||||
|
||||
Result printReport(String bgdh);
|
||||
Result printReport(String[] bgdh);
|
||||
|
||||
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.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czlis.common.config.RuoYiConfig;
|
||||
import com.czlis.common.core.domain.Result;
|
||||
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.LisUtil;
|
||||
import com.czlis.interfaceCommon.utils.ReportUtil;
|
||||
import com.czlis.zybgcx.mapper.ZybgcxMapper;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
|
||||
import javax.print.PrintException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -35,7 +44,6 @@ public class ZybgcxServcieImpl implements ZybgcxService {
|
||||
@Autowired
|
||||
private CommonUtil commonUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 获取报告信息
|
||||
* @param webGetReportsList
|
||||
@ -63,27 +71,35 @@ public class ZybgcxServcieImpl implements ZybgcxService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result printReport(String bgdh) {
|
||||
String[] strings = StrUtil.splitToArray(bgdh, "_");
|
||||
if(strings.length != 3) return new Result("-1","传入的报告单号不对!");
|
||||
String jyrqStr = strings[0];
|
||||
String yq = strings[1];
|
||||
String ybh = strings[2];
|
||||
LabReqreportPdffile labReqreportPdffileOne = commonUtil.getLabReqreportPdffileOne(DateUtil.parse(jyrqStr, "yyyyMMdd"), yq, ybh);
|
||||
byte[] decode = Base64.decode(labReqreportPdffileOne.getBASE64PDF());
|
||||
String pdfName = bgdh+".pdf";
|
||||
String path = RuoYiConfig.getProfile() +"/printPDF/"+pdfName;
|
||||
log.info("打印目录文件为:{}",path);
|
||||
FileUtil.writeBytes(decode, path);
|
||||
public Result printReport(String[] bgdh) {
|
||||
List<String> bgdhBase64List = new ArrayList<>();
|
||||
for (String string : bgdh) {
|
||||
String[] stringParam = StrUtil.splitToArray(string, "_");
|
||||
if(stringParam.length != 3) return new Result("-1","传入的报告单号不对!");
|
||||
String jyrqStr = stringParam[0];
|
||||
String yq = stringParam[1];
|
||||
String ybh = stringParam[2];
|
||||
LabReqreportPdffile labReqreportPdffileOne = commonUtil.getLabReqreportPdffileOne(DateUtil.parse(jyrqStr, "yyyyMMdd"), yq, ybh);
|
||||
if(labReqreportPdffileOne == null) continue;
|
||||
String base64PDF = labReqreportPdffileOne.getBASE64PDF();
|
||||
if(base64PDF == null || base64PDF.equals("")) continue;
|
||||
bgdhBase64List.add(base64PDF);
|
||||
}
|
||||
String pdfName = UUID.randomUUID().toString();
|
||||
String path = RuoYiConfig.getProfile() +"/config/static/printPDF/"+pdfName+".pdf";
|
||||
//合并pdf
|
||||
try {
|
||||
ReportUtil.printPdf(path,"");
|
||||
LisUtil.mergeToFile(bgdhBase64List,path);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("打印pdf报告失败:",e);
|
||||
return new Result("-1","打印pdf报告失败:"+e.getMessage());
|
||||
log.error("合并pdf:{}报告失败:{}",bgdh,e);
|
||||
return new Result("-1",e.getMessage());
|
||||
}
|
||||
|
||||
return new Result("0","打印成功!");
|
||||
//String httpPath = reportUtil.getPrintURL(pdfName);
|
||||
//转成base64字符串
|
||||
File file = new File(path);
|
||||
String encode = Base64.encode(file);
|
||||
return new Result("0","打印成功!",encode);
|
||||
}
|
||||
|
||||
@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="dybz != null and dybz != ''"> AND dybz = #{dybz}</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 id="getResultMed" resultType="com.czlis.zybgcx.pojo.Web_getResultMed">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user