use of com.itrus.portal.db.EvidenceOutTemplateExample in project portal by ixinportal.
the class EvidenceOutTask method outBody.
/**
* 自动出证
* @param hisCertificate
* @param orderNumber
*/
private void outBody(String orderNumber, EvidenceOutServiceConfig outServiceConfig, ApplicationInfo applicationInfo, AppService appService, String evidenceSns, String businessSn, Date date, String code, Integer count) {
try {
// 定义错误原因字段
String hisCauseFailure = null;
// 得到出证模板信息
EvidenceOutTemplateExample outTemplateExample = new EvidenceOutTemplateExample();
EvidenceOutTemplateExample.Criteria tec = outTemplateExample.createCriteria();
tec.andIdEqualTo(outServiceConfig.getOutReportTemplate());
EvidenceOutTemplate outTemplate = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutTemplateMapper.selectByExample", outTemplateExample);
// 整合证书需要的要素
String[] factorArr = outTemplate.getFactor().split(",");
// 整合出证信息表
EvidenceHisCertificate hisCertificate = new EvidenceHisCertificate();
hisCertificate.setServiceRequestPlatform(applicationInfo.getName());
hisCertificate.setApplicationInfo(applicationInfo.getId());
hisCertificate.setSisServiceName(appService.getAppServiceName());
hisCertificate.setSerialnumber(orderNumber);
hisCertificate.setHisAppService(appService.getId());
hisCertificate.setApplicationTime(date);
hisCertificate.setHisApplicant(code);
hisCertificate.setHisState("1");
hisCertificate.setOutState(0);
hisCertificate.setOutTemplate(outServiceConfig.getOutReportTemplate());
hisCertificate.setHisway(outServiceConfig.getOutWay().toString());
sqlSession.insert("com.itrus.portal.db.EvidenceHisCertificateMapper.insert", hisCertificate);
sqlSession.flushStatements();
// int count = 0;
if (StringUtils.isNotEmpty(evidenceSns)) {
String[] evidenceSnArr = evidenceSns.split(",");
for (String evidenceSn : evidenceSnArr) {
// 获得对应证据编号的信息
EvidenceBasicInformation basicInformation = basicInformationService.getInformationBySn(evidenceSn, 2);
if (basicInformation == null) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "提交的" + evidenceSn + "证据编号为无效的证据编码";
else
hisCauseFailure = hisCauseFailure + "," + "提交的" + evidenceSn + "证据编号为无效的证据编码";
continue;
}
// count++;
if (basicInformation.getEvidenceStatus() == 0 || StringUtils.isNotEmpty(basicInformation.getLackMainContent())) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "证据编号:" + evidenceSn + "核验未通过,不满足出证要求";
else
hisCauseFailure = hisCauseFailure + "," + "证据编号:" + evidenceSn + "核验未通过,不满足出证要求";
}
// 得到证据附件信息
EvidenceEnclosureExample enclosureExample = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria eec = enclosureExample.createCriteria();
eec.andEvidenceSnEqualTo(evidenceSn);
eec.andPdfTypeEqualTo("1");
List<EvidenceEnclosure> enclosures = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosureExample);
// 核验事件证据提交的要素
String subFactor = null;
String lackFactor = null;
for (EvidenceEnclosure enclosure : enclosures) {
if (StringUtils.isEmpty(subFactor))
subFactor = enclosure.getSaveFactor();
else
subFactor = subFactor + "," + enclosure.getSaveFactor();
}
for (String factor : factorArr) {
if (!subFactor.contains(factor) && !(factor.contains("主体身份") || factor.contains("身份实名认证") || factor.contains("身份意愿鉴别"))) {
if (StringUtils.isEmpty(lackFactor))
lackFactor = factor;
else
lackFactor = lackFactor + "," + factor;
}
}
if (StringUtils.isNotEmpty(lackFactor)) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "证据编号:" + evidenceSn + ",缺少必要要素信息:" + lackFactor;
else
hisCauseFailure = hisCauseFailure + "," + "证据编号:" + evidenceSn + ",缺少必要要素信息:" + lackFactor;
}
// 核验身份提交的要素
String idFactor = null;
for (String factor : factorArr) {
if (factor.contains("主体身份") || factor.contains("身份实名认证") || factor.contains("身份意愿鉴别")) {
if (StringUtils.isEmpty(idFactor))
idFactor = factor;
else
idFactor = idFactor + "," + factor;
}
}
log.debug("idFactor__ : " + idFactor);
if (StringUtils.isNotEmpty(idFactor)) {
EvidenceTrustedIdentityExample trustedIdentityExample = new EvidenceTrustedIdentityExample();
EvidenceTrustedIdentityExample.Criteria ttc = trustedIdentityExample.createCriteria();
ttc.andBasicInformationEqualTo(basicInformation.getId().toString());
ttc.andEventContentIsNull();
List<EvidenceTrustedIdentity> trustedIdentities = sqlSession.selectList("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trustedIdentityExample);
if (trustedIdentities == null || trustedIdentities.isEmpty()) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "证据编号:" + evidenceSn + ",缺少必要要素信息:可信身份标识";
else
hisCauseFailure = hisCauseFailure + "," + "证据编号:" + evidenceSn + ",缺少必要要素信息:可信身份标识";
} else {
for (EvidenceTrustedIdentity trustedIdentity : trustedIdentities) {
// 得到主体身份信息
EvidenceMainInformationExample informationExample = new EvidenceMainInformationExample();
EvidenceMainInformationExample.Criteria iec = informationExample.createCriteria();
// iec.andIdEqualTo(trustedIdentity.getMainInformation());
EvidenceMainInformation mainInformation = sqlSession.selectOne("com.itrus.portal.db.EvidenceMainInformationMapper.selectByExample", informationExample);
// 整合没关联主体身份证据的信息
if (StringUtils.isEmpty(trustedIdentity.getEvidenceSn())) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "证据主体:" + mainInformation.getSubjectName() + ",编号:" + evidenceSn + ",缺少必要要素信息:" + idFactor;
else
hisCauseFailure = hisCauseFailure + "," + "证据主体:" + mainInformation.getSubjectName() + ",编号:" + evidenceSn + ",缺少必要要素信息:" + idFactor;
} else {
// 得到证据附件信息
EvidenceEnclosureExample enclosureExample1 = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria eec1 = enclosureExample1.createCriteria();
eec1.andEvidenceSnEqualTo(trustedIdentity.getEvidenceSn());
eec1.andPdfTypeEqualTo("1");
List<EvidenceEnclosure> enclosures1 = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosureExample1);
String subFactorId = null;
String lackFactorId = null;
for (EvidenceEnclosure enclosure : enclosures1) {
if (StringUtils.isEmpty(subFactorId))
subFactorId = enclosure.getSaveFactor();
else
subFactorId = subFactorId + "," + enclosure.getSaveFactor();
}
log.debug("subFactorId__ : " + subFactorId);
String[] factorIdArr = idFactor.split(",");
for (String factor : factorIdArr) {
if (!subFactorId.contains(factor)) {
if (StringUtils.isEmpty(lackFactorId))
lackFactorId = factor;
else
lackFactorId = lackFactorId + "," + factor;
}
}
log.debug("lackFactorId__ : " + lackFactorId);
if (StringUtils.isNotEmpty(lackFactorId)) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "证据主体:" + mainInformation.getSubjectName() + ",编号:" + evidenceSn + ",缺少必要要素信息:" + lackFactorId;
else
hisCauseFailure = hisCauseFailure + "," + "证据主体:" + mainInformation.getSubjectName() + ",编号:" + evidenceSn + ",缺少必要要素信息:" + lackFactorId;
}
}
}
}
}
// 存储出证与证据关系
EvidenceHisRelationship hisRelationship = new EvidenceHisRelationship();
hisRelationship.setBasicInformation(basicInformation.getId());
hisRelationship.setHisCertificate(hisCertificate.getId());
sqlSession.insert("com.itrus.portal.db.EvidenceHisRelationshipMapper.insert", hisRelationship);
}
} else {
List<EvidenceBasicInformation> basicInformations = basicInformationService.getInformationByBusinessSn(businessSn, 2);
if (basicInformations == null || basicInformations.isEmpty()) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "提交的业务单号有误";
else
hisCauseFailure = hisCauseFailure + "," + "提交的业务单号有误";
}
for (EvidenceBasicInformation basicInformation : basicInformations) {
// 得到证据附件信息
EvidenceEnclosureExample enclosureExample = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria eec = enclosureExample.createCriteria();
eec.andBasicInformationEqualTo(basicInformation.getId());
eec.andPdfTypeEqualTo("1");
List<EvidenceEnclosure> enclosures = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosureExample);
// 得到提交的要素
String subFactor = null;
String lackFactor = null;
for (EvidenceEnclosure enclosure : enclosures) {
if (StringUtils.isEmpty(subFactor))
subFactor = enclosure.getSaveFactor();
else
subFactor = subFactor + "," + enclosure.getSaveFactor();
}
for (String factor : factorArr) {
if (!subFactor.contains(factor)) {
if (StringUtils.isEmpty(lackFactor))
lackFactor = factor;
else
lackFactor = lackFactor + "," + factor;
}
}
if (StringUtils.isNotEmpty(lackFactor)) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "证据编号:" + basicInformation.getEvidenceSn() + ",缺少必要要素信息:" + lackFactor;
else
hisCauseFailure = hisCauseFailure + "," + "证据编号:" + basicInformation.getEvidenceSn() + ",缺少必要要素信息:" + lackFactor;
}
// count++;
if (basicInformation.getEvidenceStatus() == 0 || StringUtils.isNotEmpty(basicInformation.getLackMainContent())) {
if (StringUtils.isEmpty(hisCauseFailure))
hisCauseFailure = "证据编号:" + basicInformation.getEvidenceSn() + ",不满足出证要求";
else
hisCauseFailure = hisCauseFailure + "," + "证据编号:" + basicInformation.getEvidenceSn() + ",不满足出证要求";
}
// 存储出证与证据关系
EvidenceHisRelationship hisRelationship = new EvidenceHisRelationship();
hisRelationship.setBasicInformation(basicInformation.getId());
hisRelationship.setHisCertificate(hisCertificate.getId());
sqlSession.insert("com.itrus.portal.db.EvidenceHisRelationshipMapper.insert", hisRelationship);
}
}
// 判断出证模式
if (count == 1)
hisCertificate.setHis("0");
else
hisCertificate.setHis("1");
// 判断出证是否有错
if (StringUtils.isNotEmpty(hisCauseFailure)) {
// hisCertificate.setHisway("3");
hisCertificate.setOutState(1);
hisCertificate.setHisCauseFailure(hisCauseFailure);
}
sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey", hisCertificate);
sqlSession.flushStatements();
// 判断是否为自动出证
if ("1".equals(hisCertificate.getHisway()) && hisCertificate.getOutState() == 0) {
String oper1 = "出证接口";
String info1 = "出证申请成功,流水号:" + orderNumber;
LogUtil.evidencelog(sqlSession, null, oper1, info1);
Map<String, Object> mapRet = null;
// 生成出证报告
try {
mapRet = reportTemplate.certificationReport(hisCertificate.getSerialnumber());
} catch (Exception e) {
StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length - 3];
String infoErr = stackTraceElement.getClassName() + stackTraceElement.getLineNumber() + e.toString();
String oper = "出证接口";
String info = "生成出证报告失败,流水号:" + orderNumber + ",失败原因:" + infoErr;
LogUtil.evidencelog(sqlSession, null, oper, info);
e.printStackTrace();
}
// 判断出证报告是否生成成功
if (mapRet != null) {
if ((int) mapRet.get("status") == 0) {
// hisCertificate.setOutState(0);
String oper = "出证接口";
String info = "生成出证报告成功,流水号:" + orderNumber;
LogUtil.evidencelog(sqlSession, null, oper, info);
hisCertificate.setHisState("0");
} else {
// hisCertificate.setOutState(1);
String oper = "出证接口";
String info = null;
if (mapRet.get("message") != null) {
info = "生成出证报告失败,流水号:" + orderNumber + ",失败原因:" + mapRet.get("message").toString();
// hisCertificate.setHisCauseFailure(mapRet.get("message").toString());
} else {
info = "生成出证报告失败,流水号:" + orderNumber;
// hisCertificate.setHisCauseFailure("出证失败");
}
LogUtil.evidencelog(sqlSession, null, oper, info);
}
}
} else {
String oper = "出证接口";
String info = "出证失败,流水号:" + orderNumber;
// 判断为自动出证失败后 转人工出证
if (hisCertificate.getHisway().equals("1")) {
hisCertificate.setHisway("3");
info = info + ",已自动转人工出证";
}
LogUtil.evidencelog(sqlSession, null, oper, info);
}
sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKeySelective", hisCertificate);
// 出证计费加流水
takeChargingService.takeCharing(appService.getServiceConfigName(), appService.getServiceConfigId(), applicationInfo, appService, hisCertificate.getId(), "EvidenceHisCertificate", count, applicationInfo.getName(), hisCertificate.getHisApplicant());
} catch (Exception e) {
e.printStackTrace();
StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length - 3];
String info = "出证失败,错误详情:" + stackTraceElement.getClassName() + stackTraceElement.getLineNumber() + e.toString();
String oper = "出证接口";
LogUtil.evidencelog(sqlSession, null, oper, info);
}
}
Aggregations