|
|
@@ -1,14 +1,9 @@
|
|
|
package com.fs.his.service.impl;
|
|
|
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
+
|
|
|
import com.fs.his.domain.FsPrescribeDrug;
|
|
|
-import com.fs.his.domain.FsStoreOrder;
|
|
|
-import com.fs.his.dto.FsPrescribeUsageDTO;
|
|
|
import com.fs.his.param.PrescribeXyImgParam;
|
|
|
-import com.fs.his.param.PrescribeZyImgParam;
|
|
|
import com.fs.his.service.PrescriptionImageService;
|
|
|
-import com.fs.his.vo.FsInquiryOrderVO;
|
|
|
-import com.fs.his.vo.FsPrescribeVO;
|
|
|
import com.fs.system.oss.CloudStorageService;
|
|
|
import com.fs.system.oss.OSSFactory;
|
|
|
import com.github.benmanes.caffeine.cache.Cache;
|
|
|
@@ -52,6 +47,10 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
|
|
|
*/
|
|
|
private static final String TEMPLATE_CACHE_KEY = "prescription_template";
|
|
|
|
|
|
+ private static final String OFFICIAL_SEAL_CACHE_KEY = "official_seal";
|
|
|
+
|
|
|
+ private static final String USED_SEAL_CACHE_KEY = "used_seal";
|
|
|
+
|
|
|
/**
|
|
|
* 图片缓存(模板永久,签名24小时)
|
|
|
*/
|
|
|
@@ -64,6 +63,8 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
|
|
|
public void init() {
|
|
|
try {
|
|
|
getTemplateImage();
|
|
|
+ getOfficialSealImage();
|
|
|
+ getUsedSealImage();
|
|
|
log.info("处方模板图片预加载成功");
|
|
|
} catch (Exception e) {
|
|
|
log.error("处方模板图片预加载失败", e);
|
|
|
@@ -143,6 +144,42 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ // 官方印章加载方法
|
|
|
+ public BufferedImage getOfficialSealImage() {
|
|
|
+ return imageCache.get(OFFICIAL_SEAL_CACHE_KEY, key -> {
|
|
|
+ try {
|
|
|
+ File file = new File(TEMPLATE_PATH_OFFICIAL);
|
|
|
+ if (!file.exists()) {
|
|
|
+ throw new RuntimeException("官方印章图片不存在: " + TEMPLATE_PATH_OFFICIAL);
|
|
|
+ }
|
|
|
+ BufferedImage image = ImageIO.read(file);
|
|
|
+ log.info("官方印章图片加载成功, 尺寸: {}x{}", image.getWidth(), image.getHeight());
|
|
|
+ return image;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("加载官方印章图片失败", e);
|
|
|
+ throw new RuntimeException("加载官方印章图片失败", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 已使用印章加载方法
|
|
|
+ public BufferedImage getUsedSealImage() {
|
|
|
+ return imageCache.get(USED_SEAL_CACHE_KEY, key -> {
|
|
|
+ try {
|
|
|
+ File file = new File(TEMPLATE_PATH_USED);
|
|
|
+ if (!file.exists()) {
|
|
|
+ throw new RuntimeException("已使用印章图片不存在: " + TEMPLATE_PATH_USED);
|
|
|
+ }
|
|
|
+ BufferedImage image = ImageIO.read(file);
|
|
|
+ log.info("已使用印章图片加载成功, 尺寸: {}x{}", image.getWidth(), image.getHeight());
|
|
|
+ return image;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("加载已使用印章图片失败", e);
|
|
|
+ throw new RuntimeException("加载已使用印章图片失败", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 深拷贝图片
|
|
|
@@ -256,6 +293,7 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
|
|
|
|
|
|
/**
|
|
|
* 绘制药品列表(每药两行:第一行药名规格数量,第二行用法用量)
|
|
|
+ * @return 返回最后一行的Y坐标
|
|
|
*/
|
|
|
public int drawDrugList(Graphics2D pen, List<FsPrescribeDrug> drugs) {
|
|
|
if (drugs == null || drugs.isEmpty()) {
|
|
|
@@ -325,18 +363,13 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
|
|
|
/**
|
|
|
* 预处理处方药品列表(满足三个需求):
|
|
|
* 1. 药名中“赠品”二字被移除;
|
|
|
- * 2. 若药名或规格含“食品”、“保健”、“仪器”,整条剔除;
|
|
|
- * 3. 按(药名+规格)合并重复项,数量累加。
|
|
|
+ * 2. 按(药名+规格)合并重复项,数量累加。
|
|
|
*/
|
|
|
private List<FsPrescribeDrug> preprocessDrugsForPrescription(List<FsPrescribeDrug> originalDrugs) {
|
|
|
if (originalDrugs == null || originalDrugs.isEmpty()) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
-// Set<String> bannedKeywords = Collections.unmodifiableSet(
|
|
|
-// new HashSet<>(Arrays.asList("食品", "保健", "仪器","器械"))
|
|
|
-// );
|
|
|
-
|
|
|
|
|
|
// key: cleanedName + "|" + baseSpec(不含×N部分)
|
|
|
Map<String, FsPrescribeDrug> drugMap = new LinkedHashMap<>();
|
|
|
@@ -350,11 +383,6 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
|
|
|
|
|
|
String spec = StringUtils.defaultString(drug.getDrugSpec()).trim();
|
|
|
|
|
|
- // 黑名单检查(用原始 cleanedName 和 spec)
|
|
|
-// if (bannedKeywords.stream().anyMatch(kw -> cleanedName.contains(kw) || spec.contains(kw))) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-
|
|
|
// 解析规格:分离基础规格和盒数
|
|
|
SpecParseResult parsed = parseSpec(spec);
|
|
|
String baseSpec = parsed.baseSpec;
|
|
|
@@ -469,58 +497,6 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
|
|
|
return currentY;
|
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
-// * 绘制药品列表
|
|
|
-// * @return 返回最后一行的Y坐标
|
|
|
-// */
|
|
|
-// public int drawDrugList(Graphics2D pen, List<FsPrescribeDrug> drugs) {
|
|
|
-// if (drugs == null || drugs.isEmpty()) {
|
|
|
-// return 330;
|
|
|
-// }
|
|
|
-//
|
|
|
-// int x = 133;
|
|
|
-// int y = 728;
|
|
|
-// int lineHeight = 30;
|
|
|
-//
|
|
|
-// for (FsPrescribeDrug drug : drugs) {
|
|
|
-// // 格式: 药品名 规格 用法 频次 每次用量 x 数量
|
|
|
-// StringBuilder sb = new StringBuilder();
|
|
|
-//
|
|
|
-// if (StringUtils.isNotBlank(drug.getDrugName())) {
|
|
|
-// sb.append(drug.getDrugName()).append(" ");
|
|
|
-// }
|
|
|
-// if (StringUtils.isNotBlank(drug.getDrugSpec())) {
|
|
|
-// sb.append(drug.getDrugSpec()).append(" ");
|
|
|
-// }
|
|
|
-// if (StringUtils.isNotBlank(drug.getUsageMethod())) {
|
|
|
-// sb.append(drug.getUsageMethod()).append(" ");
|
|
|
-// }
|
|
|
-// if (StringUtils.isNotBlank(drug.getUsageFrequencyUnit())) {
|
|
|
-// sb.append(drug.getUsageFrequencyUnit()).append(" ");
|
|
|
-// }
|
|
|
-// if (StringUtils.isNotBlank(drug.getUsagePerUseCount())) {
|
|
|
-// sb.append(drug.getUsagePerUseCount());
|
|
|
-// }
|
|
|
-// if (StringUtils.isNotBlank(drug.getUsagePerUseUnit())) {
|
|
|
-// sb.append(drug.getUsagePerUseUnit()).append(" ");
|
|
|
-// }
|
|
|
-// if (drug.getDrugNum() != null) {
|
|
|
-// sb.append("x ").append(drug.getDrugNum());
|
|
|
-// }
|
|
|
-// if (StringUtils.isNotBlank(drug.getDrugUnit())) {
|
|
|
-// sb.append(drug.getDrugUnit());
|
|
|
-// }
|
|
|
-//
|
|
|
-// String drugInfo = sb.toString().trim();
|
|
|
-// if (StringUtils.isNotBlank(drugInfo)) {
|
|
|
-// y = drawMultiLineText(pen, drugInfo, x, y, 760);
|
|
|
-// y += lineHeight;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// return y;
|
|
|
-// }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 绘制医嘱
|
|
|
@@ -730,4 +706,56 @@ public class PrescriptionImageServiceImpl implements PrescriptionImageService {
|
|
|
|
|
|
return url;
|
|
|
}
|
|
|
+
|
|
|
+ // /**
|
|
|
+// * 绘制药品列表
|
|
|
+// * @return 返回最后一行的Y坐标
|
|
|
+// */
|
|
|
+// public int drawDrugList(Graphics2D pen, List<FsPrescribeDrug> drugs) {
|
|
|
+// if (drugs == null || drugs.isEmpty()) {
|
|
|
+// return 330;
|
|
|
+// }
|
|
|
+//
|
|
|
+// int x = 133;
|
|
|
+// int y = 728;
|
|
|
+// int lineHeight = 30;
|
|
|
+//
|
|
|
+// for (FsPrescribeDrug drug : drugs) {
|
|
|
+// // 格式: 药品名 规格 用法 频次 每次用量 x 数量
|
|
|
+// StringBuilder sb = new StringBuilder();
|
|
|
+//
|
|
|
+// if (StringUtils.isNotBlank(drug.getDrugName())) {
|
|
|
+// sb.append(drug.getDrugName()).append(" ");
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(drug.getDrugSpec())) {
|
|
|
+// sb.append(drug.getDrugSpec()).append(" ");
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(drug.getUsageMethod())) {
|
|
|
+// sb.append(drug.getUsageMethod()).append(" ");
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(drug.getUsageFrequencyUnit())) {
|
|
|
+// sb.append(drug.getUsageFrequencyUnit()).append(" ");
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(drug.getUsagePerUseCount())) {
|
|
|
+// sb.append(drug.getUsagePerUseCount());
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(drug.getUsagePerUseUnit())) {
|
|
|
+// sb.append(drug.getUsagePerUseUnit()).append(" ");
|
|
|
+// }
|
|
|
+// if (drug.getDrugNum() != null) {
|
|
|
+// sb.append("x ").append(drug.getDrugNum());
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(drug.getDrugUnit())) {
|
|
|
+// sb.append(drug.getDrugUnit());
|
|
|
+// }
|
|
|
+//
|
|
|
+// String drugInfo = sb.toString().trim();
|
|
|
+// if (StringUtils.isNotBlank(drugInfo)) {
|
|
|
+// y = drawMultiLineText(pen, drugInfo, x, y, 760);
|
|
|
+// y += lineHeight;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// return y;
|
|
|
+// }
|
|
|
}
|