use of com.itrus.portal.db.EvidenceEventTime in project portal by ixinportal.
the class EvidencePdfVerifyService method savePdfVerify.
private void savePdfVerify(String data) {
JSONObject jsonPdfVerify = JSONObject.parseObject(data);
try {
if (data == null) {
throw new Exception("返回值为空");
}
if (jsonPdfVerify.getInteger("code") == 0) {
eventContent.setEventStatus(1);
} else {
eventContent.setEventStatus(0);
eventContent.setFailureReason(jsonPdfVerify.getString("message"));
}
String retVerifyTi = null;
String retVerifyBehavior = null;
String retVerifyTime = null;
if (StringUtils.isNotEmpty(data) && StringUtils.isNotEmpty(jsonPdfVerify.getString("signInfos"))) {
// 解析pdf验章返回信息
JSONArray jsonArraySignInfos = jsonPdfVerify.getJSONArray("signInfos");
List<String> listStr = new ArrayList<>();
int noId = 0;
for (int k = 0; k < jsonArraySignInfos.size(); k++) {
// 循环得到pdf验章返回数据
JSONObject json = jsonArraySignInfos.getJSONObject(k);
// 对应可信身份
EvidenceTrustedIdentity trustedIdentity1 = null;
// 判断验章是否包含证书
if (StringUtils.isNotEmpty(json.getString("signerCert"))) {
// 解析签名者证书base64编码
UserCert userCert1 = CertUtil.getCertFromBase64(json.getString("signerCert"));
EvidenceCertUser certUser = certUserService.getCertBySn(userCert1.getCertSn());
if (certUser == null) {
certUser = new EvidenceCertUser();
certUser.setCertBase64(json.getString("signerCert"));
certUser.setCertSerialnumber(userCert1.getCertSn());
certUser.setSubjectdn(userCert1.getCertDn());
certUser.setIssuerdn(userCert1.getIssuerDn());
certUser.setIssuer(EvidenceSaveServiceApi.getCertCn(userCert1.getIssuerDn()));
if (userCert1.getCertBuf() != null) {
certUser.setEvidenceBuf(userCert1.getCertBuf().toString());
}
certUser.setStartTime(userCert1.getCertStartTime());
certUser.setEndTime(userCert1.getCertEndTime());
certUser.setCreateTime(new Date());
certUser.setIdCode(UniqueIDUtils.getUID());
queueThread.putObjectQueue(certUser);
}
boolean blt = true;
// 循环已经存在的证书序列号 判断证书序列号是否存在
for (String strCertSn : listStr) {
if (userCert1 != null && strCertSn.equals(userCert1.getCertSn())) {
blt = false;
}
}
// 循环可信身份list缓存 判断证书序列号是否相同
if (!tiCacheList.isEmpty() && tiCacheList != null) {
for (EvidenceTrustedIdentity identity : tiCacheList) {
if (identity.getCertSerialnumber().equals(userCert1.getCertSn())) {
trustedIdentity1 = identity;
}
}
}
if (trustedIdentity1 == null) {
noId--;
}
if (blt) {
// 事件对象定义
EvidenceTrustedIdentity trustedIdentity = new EvidenceTrustedIdentity();
trustedIdentity.setBasicInformation(eventContent.getEvidenceSn());
trustedIdentity.setEventContent(eventContent.getIdCode());
if (trustedIdentity1 != null) {
trustedIdentity.setMainInformation(trustedIdentity1.getMainInformation());
// 整合证书信息存储到对应可信身份表
trustedIdentity1.setCertBase64(certUser.getIdCode());
queueThread.putObjectQueue(trustedIdentity1);
} else {
trustedIdentity.setMainInformation(noId + "");
}
trustedIdentity.setCertBase64(certUser.getIdCode());
trustedIdentity.setCreateTime(new Date());
trustedIdentity.setIdentiType("1");
if (userCert1.getCertBuf() != null) {
trustedIdentity.setEvidenceBuf(userCert1.getCertBuf().toString());
}
trustedIdentity.setStartTime(userCert1.getCertStartTime());
trustedIdentity.setEndTime(userCert1.getCertEndTime());
// 事件对象核验结果
trustedIdentity.setCheckTime(new Date());
if (json.getIntValue("vcResult") == 0) {
trustedIdentity.setCheckStatus("1");
trustedIdentity.setCheckSuccessTime(new Date());
} else {
if (StringUtils.isEmpty(retVerifyTi))
retVerifyTi = "事件对象核验失败";
trustedIdentity.setCheckStatus("0");
if (json.getIntValue("vcResult") == 30006)
trustedIdentity.setUnreason("未找到对应的受信任CA证书");
else if (json.getIntValue("vcResult") == 30007)
trustedIdentity.setUnreason("证书已吊销");
else if (json.getIntValue("vcResult") == 30008)
trustedIdentity.setUnreason("证书不在有效期内");
else if (json.getIntValue("vcResult") == 30009)
trustedIdentity.setUnreason("无效的证书签名");
else if (json.getIntValue("vcResult") == 300010)
trustedIdentity.setUnreason("其他证书验证错误");
else
trustedIdentity.setUnreason("非正常其他证书验证错误");
}
trustedIdentity.setVewestCheckTime(new Date());
queueThread.putObjectQueue(trustedIdentity);
}
listStr.add(userCert1.getCertSn());
} else {
retVerifyTi = "事件对象核验失败";
}
// 事件行为定义
EvidenceEventBehavior eventBehavior = new EvidenceEventBehavior();
// 判断时间戳是否存在
if (StringUtils.isNotEmpty(json.getString("timeStamp")) && !json.getString("timeStamp").equals("{}")) {
// 验证时间戳
EvidenceEventTime eventTime = new EvidenceEventTime();
if (trustedIdentity1 != null) {
eventTime.setMainInformation(trustedIdentity1.getMainInformation());
} else {
eventTime.setMainInformation(noId + "");
}
eventTime.setIdentiType("1");
eventTime.setEventContent(eventContent.getIdCode());
eventTime.setCertificate(json.getJSONObject("timeStamp").getString("signature"));
eventTime.setHashAlgorithm(json.getJSONObject("timeStamp").getString("hashAlg"));
eventTime.setHashvalue(json.getJSONObject("timeStamp").getString("hashData"));
eventTime.setCertBase64(json.getJSONObject("timeStamp").getString("tsCert"));
if (StringUtils.isNotEmpty(json.getJSONObject("timeStamp").getString("time"))) {
eventTime.setSignatureTime(json.getJSONObject("timeStamp").getDate("time"));
} else {
eventTime.setSignatureTime(json.getDate("stampTime"));
}
eventTime.setCreateTime(new Date());
// 解析时间戳证书 Base64
if (json.getJSONObject("timeStamp").getString("tsCert") != null) {
UserCert userCert = CertUtil.getCertFromBase64(json.getJSONObject("timeStamp").getString("tsCert"));
eventTime.setCertificateDn(userCert.getCertDn());
eventTime.setIssuerdn(userCert.getIssuerDn());
}
// 时间核验结果
eventTime.setCheckTime(new Date());
if (json.getIntValue("vtsResult") == 0) {
eventTime.setCheckStatus("1");
eventTime.setCheckSuccessTime(new Date());
} else {
if (StringUtils.isEmpty(retVerifyTime)) {
retVerifyTime = "事件时间核验失败";
}
eventTime.setCheckStatus("0");
if (json.getIntValue("vtsResult") == 60002) {
eventTime.setUnreason("验证时戳失败");
} else {
eventTime.setUnreason("其他验证时戳错误");
}
}
eventTime.setVewestCheckTime(new Date());
// eventTime.setCheckContent("签名原文完整、真实、是否被篡改");
queueThread.putObjectQueue(eventTime);
} else {
eventBehavior.setVerificationTime(json.getDate("stampTime"));
}
// 判断事件行为是否返回为空
if (StringUtils.isNotEmpty(json.getString("signature"))) {
eventBehavior.setHashAlgorithm(json.getString("hashAlg"));
eventBehavior.setSignaturevalue(json.getString("signature"));
eventBehavior.setHashBackSigning(json.getString("msgDigest"));
eventBehavior.setEventContent(eventContent.getIdCode());
eventBehavior.setIdentiType("1");
if (trustedIdentity1 != null) {
eventBehavior.setMainInformation(trustedIdentity1.getMainInformation());
} else {
eventBehavior.setMainInformation(noId + "");
}
// 事件行为核验结果
eventBehavior.setCheckTime(new Date());
if (json.getIntValue("vdsResult") == 0) {
eventBehavior.setCheckStatus("1");
eventBehavior.setCheckSuccessTime(new Date());
} else {
if (StringUtils.isEmpty(retVerifyBehavior)) {
retVerifyBehavior = "事件行为核验失败";
}
eventBehavior.setCheckStatus("0");
if (json.getIntValue("vdsResult") == 40002) {
eventBehavior.setUnreason("验证签名失败");
} else {
eventBehavior.setUnreason("其他验证签名错误");
}
}
eventBehavior.setVewestCheckTime(new Date());
queueThread.putObjectQueue(eventBehavior);
} else {
retVerifyBehavior = "事件行为核验失败";
}
}
if (jsonArraySignInfos.size() == 0) {
// eventContent.setEventStatus(0);
// if(StringUtils.isNotEmpty(eventContent.getFailureReason())) {
// eventContent.setFailureReason(eventContent.getFailureReason() + ",pdf签章失败:返回集合为空。");
// } else {
// eventContent.setFailureReason("pdf签章失败:返回集合为空。");
// }
// result.put("status", 0);
// result.put("message", "pdf签章失败:返回集合为空。");
// return result;
}
if (StringUtils.isNotEmpty(retVerifyTi)) {
if (StringUtils.isNotEmpty(eventContent.getFailureReason()))
eventContent.setFailureReason(eventContent.getFailureReason() + "," + retVerifyTi);
else
eventContent.setFailureReason(retVerifyTi);
}
if (StringUtils.isNotEmpty(retVerifyBehavior)) {
if (StringUtils.isNotEmpty(eventContent.getFailureReason()))
eventContent.setFailureReason(retVerifyBehavior);
else
eventContent.setFailureReason(eventContent.getFailureReason() + "," + retVerifyBehavior);
}
if (StringUtils.isNotEmpty(retVerifyTime)) {
if (StringUtils.isNotEmpty(eventContent.getFailureReason()))
eventContent.setFailureReason(retVerifyTime);
else
eventContent.setFailureReason(eventContent.getFailureReason() + "," + retVerifyTime);
}
}
queueThread.putObjectQueue(eventContent);
} catch (Exception e) {
e.printStackTrace();
String ret = null;
if (jsonPdfVerify != null) {
ret = jsonPdfVerify.getString("message");
}
LogUtil.evidencelog(sqlSession, eventContent.getEvidenceSn(), "存证接口_天威签名", "PDF验章失败,证据编号:" + eventContent.getEvidenceSn() + ", 请求参数:" + (StringUtils.isEmpty(pdfContent) ? "空值" : "有值").toString() + ", 请求地址:" + url + ", 返回结果:" + ret + ", 失败原因" + e);
}
}
use of com.itrus.portal.db.EvidenceEventTime in project portal by ixinportal.
the class EvidenceQueueThread method run.
@Override
public void run() {
boolean isException = false;
while (true) {
// long startDate = System.currentTimeMillis();
log.debug("EvidenceQueueThread execute run,the queue size is [" + OBJECT_QUEUE.size() + "]");
if (OBJECT_QUEUE.isEmpty()) {
try {
// 若队列中没有信息则等待10秒
sleep(10 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
}
log.debug("EvidenceQueueThread execute run,the queue size is [" + OBJECT_QUEUE.size() + "]");
// 存证记录信息
List<EvidenceBasicInformation> basicInformations = new ArrayList<EvidenceBasicInformation>();
// 事件内容记录
List<EvidenceEventContent> eventContents = new ArrayList<EvidenceEventContent>();
// 主体
Map<String, EvidenceMainInformation> mainInformationMap = new HashMap<>();
// 主体与记录关联
List<EvidenceSubjectIdentity> subjectIdentites = new ArrayList<EvidenceSubjectIdentity>();
// 日志记录
List<EvidenceLog> logs = new ArrayList<EvidenceLog>();
// 签名服务信息记录
List<EvidenceClientSignature> signatures = new ArrayList<EvidenceClientSignature>();
// 时间戳服务信息记录
List<EvidenceClientTimeStamp> clientTimeStamps = new ArrayList<EvidenceClientTimeStamp>();
// 附件信息记录
List<EvidenceEnclosure> enclosures = new ArrayList<EvidenceEnclosure>();
// 身份意愿鉴别信息记录
List<EvidenceDesireIdentify> desireIdentifies = new ArrayList<EvidenceDesireIdentify>();
// 身份实名信息记录
List<EvidenceRealName> realNames = new ArrayList<EvidenceRealName>();
// 身份个人实名提交信息
List<EvidenceIndividual> individuals = new ArrayList<EvidenceIndividual>();
// 身份企业法人实名提交信息
List<EvidenceRepresentative> representatives = new ArrayList<EvidenceRepresentative>();
// 身份企业代理人实名提交信息
List<EvidenceTheAgent> agents = new ArrayList<EvidenceTheAgent>();
// 身份企业实名提交信息
List<EvidenceCompaniesSubmit> companiesSubmits = new ArrayList<EvidenceCompaniesSubmit>();
// 事件意愿认证信息
List<EvidenceEventDesire> eventDesires = new ArrayList<EvidenceEventDesire>();
// 事件地点认证信息
List<EvidenceEventNetworkAddress> addresses = new ArrayList<EvidenceEventNetworkAddress>();
// 事件对象认证信息
List<EvidenceTrustedIdentity> trustedIdentities = new ArrayList<EvidenceTrustedIdentity>();
// 事件行为信息
List<EvidenceEventBehavior> eventBehaviors = new ArrayList<EvidenceEventBehavior>();
// 事件时间戳信息
List<EvidenceEventTime> eventTimes = new ArrayList<EvidenceEventTime>();
// 用户上传证书信息
List<EvidenceCertUser> certUsers = new ArrayList<EvidenceCertUser>();
for (int i = 0; !OBJECT_QUEUE.isEmpty() && i < 1000; i++) {
Object object = OBJECT_QUEUE.poll();
isOver = false;
if (object instanceof EvidenceBasicInformation) {
EvidenceBasicInformation ebi = (EvidenceBasicInformation) object;
basicInformations.add(ebi);
} else if (object instanceof EvidenceEventContent) {
EvidenceEventContent eec = (EvidenceEventContent) object;
eventContents.add(eec);
} else if (object instanceof EvidenceMainInformation) {
EvidenceMainInformation emi = (EvidenceMainInformation) object;
mainInformationMap.put(emi.getSubjectName() + emi.getIdentification(), emi);
} else if (object instanceof EvidenceSubjectIdentity) {
EvidenceSubjectIdentity esi = (EvidenceSubjectIdentity) object;
subjectIdentites.add(esi);
} else if (object instanceof EvidenceLog) {
EvidenceLog eLog = (EvidenceLog) object;
eLog.setInfo(StringUtils.replaceHtml(eLog.getInfo()));
logs.add(eLog);
} else if (object instanceof EvidenceClientSignature) {
EvidenceClientSignature ecs = (EvidenceClientSignature) object;
signatures.add(ecs);
} else if ((object instanceof EvidenceClientTimeStamp)) {
EvidenceClientTimeStamp ects = (EvidenceClientTimeStamp) object;
clientTimeStamps.add(ects);
} else if ((object instanceof EvidenceEnclosure)) {
EvidenceEnclosure ee = (EvidenceEnclosure) object;
enclosures.add(ee);
} else if ((object instanceof EvidenceDesireIdentify)) {
EvidenceDesireIdentify edi = (EvidenceDesireIdentify) object;
desireIdentifies.add(edi);
} else if ((object instanceof EvidenceEnclosure)) {
EvidenceEnclosure ee = (EvidenceEnclosure) object;
enclosures.add(ee);
} else if ((object instanceof EvidenceRealName)) {
EvidenceRealName erl = (EvidenceRealName) object;
realNames.add(erl);
} else if ((object instanceof EvidenceIndividual)) {
EvidenceIndividual ei = (EvidenceIndividual) object;
individuals.add(ei);
} else if ((object instanceof EvidenceRepresentative)) {
EvidenceRepresentative er = (EvidenceRepresentative) object;
representatives.add(er);
} else if ((object instanceof EvidenceTheAgent)) {
EvidenceTheAgent eta = (EvidenceTheAgent) object;
agents.add(eta);
} else if ((object instanceof EvidenceCompaniesSubmit)) {
EvidenceCompaniesSubmit ecs = (EvidenceCompaniesSubmit) object;
companiesSubmits.add(ecs);
} else if ((object instanceof EvidenceEventDesire)) {
EvidenceEventDesire eed = (EvidenceEventDesire) object;
eventDesires.add(eed);
} else if ((object instanceof EvidenceEventNetworkAddress)) {
EvidenceEventNetworkAddress eena = (EvidenceEventNetworkAddress) object;
addresses.add(eena);
} else if ((object instanceof EvidenceTrustedIdentity)) {
EvidenceTrustedIdentity eti = (EvidenceTrustedIdentity) object;
trustedIdentities.add(eti);
} else if ((object instanceof EvidenceEventBehavior)) {
EvidenceEventBehavior eeb = (EvidenceEventBehavior) object;
eventBehaviors.add(eeb);
} else if ((object instanceof EvidenceEventTime)) {
EvidenceEventTime eet = (EvidenceEventTime) object;
eventTimes.add(eet);
} else if ((object instanceof EvidenceCertUser)) {
EvidenceCertUser ecu = (EvidenceCertUser) object;
certUsers.add(ecu);
}
}
// 保存事件内容记录
if (!eventContents.isEmpty())
try {
sqlSession.insert("com.itrus.portal.db.EvidenceEventContentMapper.insertOrUpdate", eventContents.toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
this.log.error("EvidenceQueueThread add eventContents " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(eventContents.toArray());
String fileName = "EvidenceEventContent" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证事件内容");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
eventContents = null;
}
// 保存证据主体记录
if (!mainInformationMap.isEmpty())
try {
sqlSession.insert("com.itrus.portal.db.EvidenceMainInformationMapper.insertOrUpdate", mainInformationMap.values().toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
this.log.error("EvidenceQueueThread add mainInformations " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(mainInformationMap.values().toArray());
String fileName = "EvidenceMainInformation" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证主体");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
mainInformationMap.clear();
}
// 保存主体与记录关联记录
if (!subjectIdentites.isEmpty())
try {
sqlSession.insert("com.itrus.portal.db.EvidenceSubjectIdentityMapper.insertOrUpdate", subjectIdentites.toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
this.log.error("EvidenceQueueThread add subjectIdentites " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(subjectIdentites.toArray());
String fileName = "EvidenceSubjectIdentity" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证主体");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
subjectIdentites = null;
}
// 保存签名服务信息记录
if (!signatures.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceClientSignatureMapper.insertOrUpdate", signatures.toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
this.log.error("EvidenceQueueThread add signatures " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(signatures.toArray());
String fileName = "EvidenceClientSignature" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证签名服务");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
signatures = null;
}
}
// 保存时间戳服务信息
if (!clientTimeStamps.isEmpty()) {
try {
this.sqlSession.insert("com.itrus.portal.db.EvidenceClientTimeStampMapper.insertOrUpdate", clientTimeStamps.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add clientTimeStamps " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(clientTimeStamps.toArray());
String fileName = "EvidenceClientTimeStamp" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证时间戳服务");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
clientTimeStamps = null;
}
}
// 保存附件信息
if (!enclosures.isEmpty()) {
try {
this.sqlSession.insert("com.itrus.portal.db.EvidenceEnclosureMapper.insertOrUpdate", enclosures.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add enclosures " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(enclosures.toArray());
String fileName = "EvidenceEnclosure" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证附件");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
enclosures = null;
}
}
// 保存身份意愿信息
if (!desireIdentifies.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceDesireIdentifyMapper.insertOrUpdate", desireIdentifies.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add desireIdentifies " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(desireIdentifies.toArray());
String fileName = "EvidenceDesireIdentify" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证身份意愿");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
desireIdentifies = null;
}
}
// 保存身份个人实名提交信息
if (!individuals.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceIndividualMapper.insertOrUpdate", individuals.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add individuals " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(individuals.toArray());
String fileName = "EvidenceIndividual" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证身份个人实名提交信息");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
individuals = null;
}
}
// 保存身份实名信息
if (!realNames.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceRealNameMapper.insertOrUpdate", realNames.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add realNames " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(realNames.toArray());
String fileName = "EvidenceRealName" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证身份实名");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
realNames = null;
}
}
// 保存身份企业法人实名提交信息
if (!representatives.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceRepresentativeMapper.insertOrUpdate", representatives.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add representatives " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(representatives.toArray());
String fileName = "EvidenceRepresentative" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证身份企业法人实名");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
representatives = null;
}
}
// 保存身份企业代理人实名提交信息
if (!agents.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceTheAgentMapper.insertOrUpdate", agents.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add agents " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(agents.toArray());
String fileName = "EvidenceTheAgent" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证身份企业代理人");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
agents = null;
}
}
// 保存身份企业实名提交信息
if (!companiesSubmits.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceCompaniesSubmitMapper.insertOrUpdate", companiesSubmits.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add companiesSubmits " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(companiesSubmits.toArray());
String fileName = "EvidenceCompaniesSubmit" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证身份企业实名");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
companiesSubmits = null;
}
}
// 保存事件意愿认证信息
if (!eventDesires.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceEventDesireMapper.insertOrUpdate", eventDesires.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add eventDesires " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(eventDesires.toArray());
String fileName = "EvidenceEventDesire" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证事件意愿认证");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
eventDesires = null;
}
}
// 保存事件地点认证信息
if (!addresses.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceEventNetworkAddressMapper.insertOrUpdate", addresses.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add addresses " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(addresses.toArray());
String fileName = "EvidenceEventNetworkAddress" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证事件地点认证");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
addresses = null;
}
}
// 保存事件对象认证信息
if (!trustedIdentities.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceTrustedIdentityMapper.insertOrUpdate", trustedIdentities.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add trustedIdentities " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(trustedIdentities.toArray());
String fileName = "EvidenceTrustedIdentity" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证事件对象认证");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
trustedIdentities = null;
}
}
// 保存事件行为信息
if (!eventBehaviors.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceEventBehaviorMapper.insertOrUpdate", eventBehaviors.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add eventBehaviors " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(eventBehaviors.toArray());
String fileName = "EvidenceEventBehavior" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证事件行为");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
eventBehaviors = null;
}
}
// 保存事件时间戳信息
if (!eventTimes.isEmpty()) {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceEventTimeMapper.insertOrUpdate", eventTimes.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add eventTimes " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(eventTimes.toArray());
String fileName = "EvidenceEventTime" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证事件时间戳");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
eventTimes = null;
}
}
// 保存用户上传证书信息
if (!certUsers.isEmpty()) {
// TODO
try {
sqlSession.insert("com.itrus.portal.db.EvidenceCertUserMapper.insertOrUpdate", certUsers.toArray());
} catch (Exception e) {
isException = true;
this.log.error("EvidenceQueueThread add certUsers " + e);
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(certUsers.toArray());
String fileName = "EvidenceCertUser" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证用户上传证书");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
}
} finally {
certUsers = null;
}
}
// 保存存证记录信息
if (!basicInformations.isEmpty()) {
try {
try {
sqlSession.insert("com.itrus.portal.db.EvidenceBasicInformationMapper.insertOrUpdate", basicInformations.toArray());
// 调用回调方法
if (evidenceQueryQueue != null) {
try {
evidenceQueryQueue.putObjectList(basicInformations);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
} catch (Exception e) {
Calendar cal = Calendar.getInstance();
String content = JSONObject.toJSONString(basicInformations.toArray());
String fileName = "EvidenceBasicInformation" + "_" + cal.get(Calendar.YEAR) + cal.get(Calendar.MONTH) + cal.get(Calendar.DATE) + cal.get(Calendar.HOUR) + cal.get(Calendar.MINUTE) + cal.get(Calendar.SECOND);
try {
saveContent(content, fileName);
} catch (Exception e2) {
EvidenceLog log = new EvidenceLog();
log.setCreateTime(new Date());
log.setType("存储入库异常_存证基础信息");
log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
log.setIp(null);
logs.add(log);
throw new Exception("失败原因:" + e2);
}
}
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
this.log.error("EvidenceQueueThread add basicInformations " + e);
} finally {
basicInformations = null;
}
}
// 保存日志记录
if (!logs.isEmpty())
try {
sqlSession.insert("com.itrus.portal.db.EvidenceLogMapper.insertOrUpdate", logs.toArray());
} catch (Exception e) {
isException = true;
// 将错误信息显示,不进行操作
this.log.error("EvidenceQueueThread add logs " + e);
// Calendar cal = Calendar.getInstance();
// String content = JSONObject.toJSONString(logs.toArray());
// String fileName = "EvidenceLog"
// + "_"
// + cal.get(Calendar.YEAR)
// + cal.get(Calendar.MONTH)
// + cal.get(Calendar.DATE)
// + cal.get(Calendar.HOUR)
// + cal.get(Calendar.MINUTE)
// + cal.get(Calendar.SECOND);
// try {
// saveContent(content, fileName);
// } catch (Exception e2) {
// EvidenceLog log = new EvidenceLog();
// log.setCreateTime(new Date());
// log.setType("存储入库异常_存证日志");
// log.setInfo("失败原因:" + e2 + ",失败数据:" + content);
// log.setIp(null);
// logs.add(log);
// }
} finally {
logs = null;
}
log.debug("EvidenceQueueThread the exception is [" + isException + "]");
// 若出现异常则暂停10秒钟
if (isException) {
try {
// 若队列中没有信息则等待10秒
sleep(10 * 1000);
} catch (InterruptedException e) {
log.error(e);
} finally {
isException = false;
}
}
isOver = true;
// log.error("Queue 耗时:" + (System.currentTimeMillis() - startDate));
}
}
Aggregations