|
@@ -1,6 +1,7 @@
|
|
|
package thyyxxk.webserver.service.ca;
|
|
|
|
|
|
import cn.hutool.core.codec.Base64;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.IdcardUtil;
|
|
@@ -30,7 +31,7 @@ import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.ca.*;
|
|
|
import thyyxxk.webserver.entity.login.UserInfo;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrPatientData;
|
|
|
-import thyyxxk.webserver.service.hutoolcache.RedisServer;
|
|
|
+import thyyxxk.webserver.service.hutoolcache.CaCache;
|
|
|
import thyyxxk.webserver.service.hutoolcache.RedisLikeService;
|
|
|
import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrServer;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
@@ -48,23 +49,28 @@ public class CaServer implements Assertion {
|
|
|
private final CaData caData;
|
|
|
private final String SUCCRSS = "success";
|
|
|
private final RedisLikeService redisLikeService;
|
|
|
- private final RedisServer redisServer;
|
|
|
private final EmrPatientDao emrPatientDao;
|
|
|
private final String archivePath;
|
|
|
private final static String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKAc+jzqVKHsjNdyuDGL7u6zZR55j87l+0GGT4/yEV+K8ZtL1GoIgOD6vv6eEg2iOwl6Wh6hq8XR4cIyzVyvMZ35dIw3oGN89ObtuCha7gLOmWYUIGVnkUBkLFeIdwe4F8bq1q15o7azsTVekSyNJf/wnxWMp8ibtvO41T8DIzZPAgMBAAECgYAeeLVVD4Gw2VyKij4sy8Var1CQxrDMPu+c7ktJCVguFzrZA8r2rQyeBIqB2aJ07smOibcJ+lm/Ca0N8O4tc/gcm4g/JsjBALFUmqyCkLQpRyIbz8V9uAmrLcchT74GS727Uv4KVTmQNDZTPIDdSZWSJ8S+WKmj8q3wUF1HLF1eXQJBAOC7D6xIB2XNS6Voa7C7m8aeg53lfcDUVJ6m0YFdvMbsU2cnlxnCSX1OsghFuVQLKcGeN+aXiTEileb3pAl2RC0CQQC2ZDtDb+1OmLmRNugp29Pmm8MM8KpktfqiBFi92Q747XwEeMgLi3qetq1wDT4dgvyURs2McsbF7diVtFv7DMXrAkAoYzXj3mYF86k+ps+DyZOrVF2PCOlauE4k3RIVz8TXcy1iAolzRalzbastNWqjIgZ1F3wwYtdzDyYlhifi03BZAkEArkgidPMbwDGhiAf+WhkrZz1JaTECsM9PGcergGVLsENFcQR0qstxtPz7x4lv5EVI0urA+Man93OptIsuJTr0VwJAd86EbHyOn5Lah7ptPGsmsqkrdMZcJ3chRj6pDtvb0A2lhaJfDRxmAiWCnviPhTApH6/1WRzBqc1ZTymyRTF9kA==";
|
|
|
private final static String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgHPo86lSh7IzXcrgxi+7us2UeeY/O5ftBhk+P8hFfivGbS9RqCIDg+r7+nhINojsJeloeoavF0eHCMs1crzGd+XSMN6BjfPTm7bgoWu4CzplmFCBlZ5FAZCxXiHcHuBfG6tateaO2s7E1XpEsjSX/8J8VjKfIm7bzuNU/AyM2TwIDAQAB";
|
|
|
+ private final CaCache cache;
|
|
|
+
|
|
|
RSA idCardRsa = new RSA(privateKey, publicKey);
|
|
|
|
|
|
private String getRedisKey(String documentId) {
|
|
|
return "ca-emr-" + documentId;
|
|
|
}
|
|
|
|
|
|
- public CaServer(CaData caData, RedisLikeService redisLikeService, RedisServer redisServer, EmrPatientDao emrPatientDao, ArchiveConfig archive) {
|
|
|
+ public CaServer(CaData caData,
|
|
|
+ RedisLikeService redisLikeService,
|
|
|
+ EmrPatientDao emrPatientDao,
|
|
|
+ ArchiveConfig archive,
|
|
|
+ CaCache cache) {
|
|
|
this.caData = caData;
|
|
|
this.redisLikeService = redisLikeService;
|
|
|
- this.redisServer = redisServer;
|
|
|
this.emrPatientDao = emrPatientDao;
|
|
|
archivePath = archive.getPath() + "/emr";
|
|
|
+ this.cache = cache;
|
|
|
}
|
|
|
|
|
|
public List<CaReturn.CaData> sendBatchByCode(CaSignClass.Send send) {
|
|
@@ -278,11 +284,16 @@ public class CaServer implements Assertion {
|
|
|
item.setIdCard(idCardRsa.decryptStr(item.getIdCard(), KeyType.PrivateKey));
|
|
|
});
|
|
|
String redisKey = getRedisKey(moreEventSign.getDocumentId());
|
|
|
- String redisData = redisServer.getData(redisKey, () -> null);
|
|
|
+
|
|
|
+
|
|
|
+ String redisData = Convert.toStr(cache.get(redisKey), null);
|
|
|
+
|
|
|
if (redisData != null) {
|
|
|
cancelSignature(redisData);
|
|
|
}
|
|
|
- redisServer.delData(redisKey);
|
|
|
+
|
|
|
+ cache.del(redisKey);
|
|
|
+
|
|
|
String uuid = IdUtil.simpleUUID();
|
|
|
JSONObject data = getMoreEventSignData(moreEventSign, uuid);
|
|
|
String execute = Forest.post(caData.getHBoardSign().getUrl() + "/mobile/hBoardSign")
|
|
@@ -294,7 +305,7 @@ public class CaServer implements Assertion {
|
|
|
String decode = URLUtil.decode(msg);
|
|
|
log.info("返回值:{},\n错误信息:{}", execute, decode);
|
|
|
if (rst.getInt("ret_code") == 0) {
|
|
|
- redisServer.setData(redisKey, uuid, 30);
|
|
|
+ cache.setData(redisKey, uuid);
|
|
|
return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, "发送成功。");
|
|
|
} else {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请联系管理员" + decode);
|
|
@@ -456,8 +467,8 @@ public class CaServer implements Assertion {
|
|
|
.execute(String.class);
|
|
|
|
|
|
redisData.setUuid(value.getUuid());
|
|
|
+ cache.put("ca-emr-" + value.getDocumentId(), redisData);
|
|
|
|
|
|
- redisServer.setData("ca-emr-" + value.getDocumentId(), redisData, 30);
|
|
|
return getStringResultVo(execute, caDocumentId, value.getUuid());
|
|
|
}
|
|
|
|
|
@@ -467,10 +478,10 @@ public class CaServer implements Assertion {
|
|
|
// 如果 uuid 是空的就是第一次
|
|
|
if (StrUtil.isBlank(value.getUuid())) {
|
|
|
value.setUuid(IdUtil.simpleUUID());
|
|
|
- redisServer.delData(redisKey);
|
|
|
+ cache.del(redisKey);
|
|
|
redisData.setPdf(EmrServer.getPdfBase(value.getDocumentId()));
|
|
|
} else {
|
|
|
- redisData = redisServer.getData(redisKey);
|
|
|
+ redisData = (CaSignClass.H5EventSignRedis) cache.get(redisKey);
|
|
|
if (redisData == null) {
|
|
|
throw new BizException(ExceptionEnum.LOGICAL_ERROR, "签名超时请重新签名。");
|
|
|
}
|
|
@@ -530,7 +541,7 @@ public class CaServer implements Assertion {
|
|
|
}
|
|
|
JSONObject rst = res.getData();
|
|
|
String key = getRedisKey(documentId);
|
|
|
- CaSignClass.H5EventSignRedis redisData = redisServer.getData(key);
|
|
|
+ CaSignClass.H5EventSignRedis redisData = (CaSignClass.H5EventSignRedis) cache.get(key);
|
|
|
if (redisData == null) {
|
|
|
throw new BizException(ExceptionEnum.LOGICAL_ERROR, "签名错误,文书不存在。");
|
|
|
}
|
|
@@ -550,7 +561,7 @@ public class CaServer implements Assertion {
|
|
|
redisData.setData(new ArrayList<>());
|
|
|
}
|
|
|
redisData.getData().add(saveData);
|
|
|
- redisServer.setData(key, redisData, 30);
|
|
|
+ cache.setData(key, redisData);
|
|
|
return ResultVoUtil.success(true);
|
|
|
}
|
|
|
|
|
@@ -561,7 +572,7 @@ public class CaServer implements Assertion {
|
|
|
public void completeQrCode(String documentId) {
|
|
|
EmrPatientData data = emrPatientDao.selectById(documentId);
|
|
|
String redisKey = getRedisKey(documentId);
|
|
|
- CaSignClass.H5EventSignRedis redisServerData = redisServer.getData(redisKey);
|
|
|
+ CaSignClass.H5EventSignRedis redisServerData = (CaSignClass.H5EventSignRedis) cache.get(redisKey);
|
|
|
CaSignClass.Upload upload = CaSignClass.Upload.builder()
|
|
|
.file(redisServerData.getPdf())
|
|
|
.fileName(documentId)
|
|
@@ -578,7 +589,7 @@ public class CaServer implements Assertion {
|
|
|
.archivePath(path)
|
|
|
.build();
|
|
|
emrPatientDao.updateById(build);
|
|
|
- redisServer.delData(redisKey);
|
|
|
+ cache.del(redisKey);
|
|
|
}
|
|
|
|
|
|
public void cancelSignature(String id) {
|
|
@@ -607,7 +618,8 @@ public class CaServer implements Assertion {
|
|
|
log.info("回调:{},数据:{}", document, data);
|
|
|
EmrPatientData emrData = emrPatientDao.selectById(document);
|
|
|
String redisKey = getRedisKey(document);
|
|
|
- String redisData = redisServer.getData(redisKey, () -> null);
|
|
|
+ String redisData = (String) cache.getDefaultValue(redisKey, null);
|
|
|
+
|
|
|
if (emrData == null || redisData == null) {
|
|
|
return R(-1, "病历文档不存在");
|
|
|
}
|
|
@@ -630,7 +642,7 @@ public class CaServer implements Assertion {
|
|
|
.signComplete(true)
|
|
|
.archivePath(path)
|
|
|
.build();
|
|
|
- redisServer.delData(redisKey);
|
|
|
+ cache.del(redisKey);
|
|
|
emrPatientDao.updateById(update);
|
|
|
return R(1, "success");
|
|
|
}
|