use of com.itrus.portal.db.EvidenceHisCertificateExample in project portal by ixinportal.
the class HisCertificateController method outpdf.
/**
* 出证盖章
*
* @param serialnumber
* @param request
* @param uiModel
* @return
* @throws Exception
*/
/*@RequestMapping(value = "/{serialnumber}", method = RequestMethod.POST, produces = "text/html")
@ResponseBody
public String seal(@PathVariable("serialnumber") String serialnumber, HttpServletRequest request,
Model uiModel) throws Exception {
// EvidenceHisCertificate hisCertificate = new EvidenceHisCertificate();
Map<String, Object> result = new HashMap<String, Object>();
// 根据流水号得到出证信息表
EvidenceHisCertificateExample hiscer = new EvidenceHisCertificateExample();
EvidenceHisCertificateExample.Criteria tificate = hiscer.createCriteria();
tificate.andSerialnumberEqualTo(serialnumber);
EvidenceHisCertificate hisCertificate = sqlSession
.selectOne("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByExample", hiscer);
//得到模板信息
EvidenceOutTemplate outTemplate = sqlSession.selectOne(
"com.itrus.portal.db.EvidenceOutTemplateMapper.selectByPrimaryKey", hisCertificate.getOutTemplate());
// 整合证书需要的要素
String[] factorArr = outTemplate.getFactor().split(",");
//得到出证关系表
EvidenceHisRelationshipExample hisrelation = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria shipEx = hisrelation.createCriteria();
shipEx.andHisCertificateEqualTo(hisCertificate.getId());
List<EvidenceHisRelationship> hisrelationship = sqlSession
.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", hisrelation);
// 要素核验
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne(
"com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
result = saveSericece.verifyFactor(basic.getEvidenceSn());
if (!"1".equals(result.get("status").toString())) {
result.put("message", result.get("message").toString());
hisCertificate.setOutState(1);
hisCertificate.setHisCauseFailure(result.get("message").toString());
sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey",
hisCertificate);
return result.get("message").toString();
}
// 得到证据附件信息
EvidenceEnclosureExample enclosureExample = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria eec = enclosureExample.createCriteria();
eec.andEvidenceSnEqualTo(basic.getEvidenceSn());
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)) {
hisCertificate.setOutState(1);
hisCertificate.setHisCauseFailure("证据编号:" + basic.getEvidenceSn() + ",缺少必要要素信息:" + lackFactor);
sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey",
hisCertificate);
return "证据编号:" + basic.getEvidenceSn() + ",缺少必要要素信息:" + lackFactor;
}
}
result = rtlService.certificationReport(serialnumber);
if ("0".equals(result.get("status").toString())) {
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne(
"com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
basic.setStatus(2);
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basic);
}
hisCertificate.setHisway("2");
hisCertificate.setHisState("0");
hisCertificate.setOutState(0);
sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey", hisCertificate);
} else {
// hisCertificate.setHisway("2");
hisCertificate.setOutState(1);
hisCertificate.setHisCauseFailure(result.get("message").toString());
sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey",
hisCertificate);
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne(
"com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
basic.setStatus(4);
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basic);
}
}
return "核验成功";
}*/
/**
* 下载pdf
*
* @param serialnumber
* @param request
* @param response
* @return
* @throws IOException
*/
@RequestMapping(value = "/outpdf/{serialnumber}")
public String outpdf(@PathVariable("serialnumber") String serialnumber, HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
EvidenceHisCertificateExample hiscer = new EvidenceHisCertificateExample();
EvidenceHisCertificateExample.Criteria tificate = hiscer.createCriteria();
tificate.andSerialnumberEqualTo(serialnumber);
EvidenceHisCertificate hisCertificate = sqlSession.selectOne("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByExample", hiscer);
// 得到服务编码
AppService appservice = appService.selectById(hisCertificate.getHisAppService());
// 得到出证服务配置
EvidenceOutServiceConfigExample saveService = new EvidenceOutServiceConfigExample();
EvidenceOutServiceConfigExample.Criteria saveServiceEx = saveService.createCriteria();
saveServiceEx.andAppServiceEqualTo(appservice.getId());
EvidenceOutServiceConfig outService = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutServiceConfigMapper.selectByExample", saveService);
String footer = getClass().getClassLoader().getResource("").getPath() + File.separator + "footer.html";
String header = getClass().getClassLoader().getResource("").getPath() + File.separator + "header.html";
// 得到出证模板信息
EvidenceOutTemplate outTmplate = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutTemplateMapper.selectByPrimaryKey", outService.getOutReportTemplate());
// 拼接url路径
String url = systemConfigService.getTsAddress() + "/" + outTmplate.getFile() + "/" + serialnumber;
log.error("123url321=" + url);
/*
* String base64 = Pdf.html2pdf(outTmplate.getFile(),
* systemConfigService.getpdfurl() + "/" + serialnumber + ".pdf",
* header, footer);// 下载未签章证书
*/
String base64 = Pdf.html2pdf(url, systemConfigService.getpdfurl() + "/" + serialnumber + ".pdf", header, // 下载未签章证书
footer);
String fileName = "" + Calendar.getInstance().getTimeInMillis();
fileName = reportTemplate.chineseUtf(fileName, request);
// String filename = "存证服务统计信息" + new
// SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".pdf";
response.addHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".pdf").getBytes("utf-8"), "iso-8859-1"));
// response.setHeader("Content-disposition", "attachment;filename="
// +
// fileName);
response.setCharacterEncoding("utf-8");
response.setContentType("application/pdf");
if (base64 == null)
return null;
BASE64Decoder decoder = new BASE64Decoder();
// Base64解码
byte[] bytes = decoder.decodeBuffer(base64);
for (int i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) {
// 调整异常数据
bytes[i] += 256;
}
}
// 生成文件的路径
OutputStream out = response.getOutputStream();
out.write(bytes);
out.flush();
out.close();
return null;
} catch (Exception e) {
return null;
}
}
use of com.itrus.portal.db.EvidenceHisCertificateExample in project portal by ixinportal.
the class ReceiptContoller method outhis.
/**
* 预览出证信息
*
* @param serialnumber
* @param type
* @param uiModel
* @return
*/
@RequestMapping(value = "/outhis/{serialnumber}", produces = "text/html")
public String outhis(@PathVariable("serialnumber") String serialnumber, Model uiModel) {
// 得到证据基本信息表
List<EvidenceBasicInformation> blist = new ArrayList<EvidenceBasicInformation>();
// 得到企业平台信息
Map<Long, EvidenceCompaniesSubmit> companiesSubmit = new HashMap<Long, EvidenceCompaniesSubmit>();
// 得到天威企业信息
Map<Long, List<RealNameRecord>> realnameRecor = new HashMap<Long, List<RealNameRecord>>();
// 得到天威个人信息
Map<Long, PersonalName> personalName = new HashMap<Long, PersonalName>();
// 得到个人平台信息
Map<Long, EvidenceIndividual> denceid = new HashMap<Long, EvidenceIndividual>();
// 得到得到身份意愿信息
Map<Long, EvidenceDesireIdentify> mdesire = new HashMap<Long, EvidenceDesireIdentify>();
// 得到事件内容信息
Map<Long, EvidenceEventContent> eventcontent = new HashMap<Long, EvidenceEventContent>();
// 得到时间对象
Map<Long, List<EvidenceTrustedIdentity>> trusid = new HashMap<Long, List<EvidenceTrustedIdentity>>();
// 得到身份标识信息
Map<Long, List<EvidenceTrustedIdentity>> trusted = new HashMap<Long, List<EvidenceTrustedIdentity>>();
// 得到事件时间信息
Map<Long, List<EvidenceEventTime>> enenttime = new HashMap<Long, List<EvidenceEventTime>>();
// 得到事件行为认证信息
Map<Long, List<EvidenceEventBehavior>> enenbehavior = new HashMap<Long, List<EvidenceEventBehavior>>();
// 得到事件意愿认证信息
Map<Long, List<EvidenceEventDesire>> evendesire = new HashMap<Long, List<EvidenceEventDesire>>();
// 得到平台提交信息代表人
Map<Long, EvidenceRepresentative> erepresetative = new HashMap<Long, EvidenceRepresentative>();
// 得到平台提交信息代理人
Map<Long, EvidenceTheAgent> etheagent = new HashMap<Long, EvidenceTheAgent>();
// 得到营业执照
Map<Long, Licenseinformation> licensein = new HashMap<Long, Licenseinformation>();
// 得到企业银行信息
Map<Long, Enterprisebank> enterpris = new HashMap<Long, Enterprisebank>();
// 得到组织机构代码
Map<Long, Organization> organiza = new HashMap<Long, Organization>();
// 得到法定代表人信息
Map<Long, Corporateinformation> corporat = new HashMap<Long, Corporateinformation>();
// 得到代理人信息
Map<Long, Agentinformation> agemtom = new HashMap<Long, Agentinformation>();
// 得到银行三四要素信息
Map<Long, Bankcardelements> bankcardele = new HashMap<Long, Bankcardelements>();
// 证据基本信息,放入多个基本信息
List<EvidenceBasicInformation> basicinfos = new ArrayList<EvidenceBasicInformation>();
// 得到出证信息
EvidenceHisCertificateExample hiscer = new EvidenceHisCertificateExample();
EvidenceHisCertificateExample.Criteria tificate = hiscer.createCriteria();
tificate.andSerialnumberEqualTo(serialnumber);
EvidenceHisCertificate hisCertificate = sqlSession.selectOne("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByExample", hiscer);
// 得到出证存证中间表
EvidenceHisRelationshipExample hisrelation = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria shipEx = hisrelation.createCriteria();
shipEx.andHisCertificateEqualTo(hisCertificate.getId());
List<EvidenceHisRelationship> hisrelationship = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", hisrelation);
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
basicinfos.add(basic);
// 得到身份意愿信息
EvidenceDesireIdentifyExample desireIdentify = new EvidenceDesireIdentifyExample();
EvidenceDesireIdentifyExample.Criteria desireExample = desireIdentify.createCriteria();
desireExample.andEvidenceSnEqualTo(basic.getEvidenceSn());
EvidenceDesireIdentify desire = sqlSession.selectOne("com.itrus.portal.db.EvidenceDesireIdentifyMapper.selectByExample", desireIdentify);
mdesire.put(basic.getId(), desire);
EvidenceRealNameExample realnameE = new EvidenceRealNameExample();
EvidenceRealNameExample.Criteria realnameEx = realnameE.createCriteria();
realnameEx.andBasicInformationEqualTo(basic.getId());
EvidenceRealName erealname = sqlSession.selectOne("com.itrus.portal.db.EvidenceRealNameMapper.selectByExample", realnameE);
if (erealname != null) {
if (!"1".equals(erealname.getEventVerifierType())) {
if ("1".equals(erealname.getType())) {
EvidenceCompaniesSubmit companiesSubmit1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceCompaniesSubmitMapper.selectByPrimaryKey", erealname.getCompaniesSubmit());
companiesSubmit.put(basic.getId(), companiesSubmit1);
// 得到法定代表人
EvidenceRepresentative representative = sqlSession.selectOne("com.itrus.portal.db.EvidenceRepresentativeMapper.selectByPrimaryKey", companiesSubmit1.getRepresentative());
erepresetative.put(basic.getId(), representative);
// 得到代理人
EvidenceTheAgent theAgen = sqlSession.selectOne("com.itrus.portal.db.EvidenceTheAgentMapper.selectByPrimaryKey", companiesSubmit1.getTheAgent());
etheagent.put(basic.getId(), theAgen);
uiModel.addAttribute("companiesSubmit", companiesSubmit);
uiModel.addAttribute("realname", companiesSubmit);
} else {
EvidenceIndividual dic = sqlSession.selectOne("com.itrus.portal.db.EvidenceIndividualMapper.selectByPrimaryKey", erealname.getIndividual());
denceid.put(basic.getId(), dic);
uiModel.addAttribute("denceid", denceid);
uiModel.addAttribute("realname", denceid);
}
} else {
if ("1".equals(erealname.getType())) {
String serialnamber = erealname.getSerialnumber();
String[] namber = serialnamber.split(",");
// List<RealNameRecord> listReal = new ArrayList<RealNameRecord>();
List<String> listString = new ArrayList<String>();
for (int i = 0; i < namber.length; i++) {
listString.add(namber[i]);
}
RealNameRecordExample realname = new RealNameRecordExample();
RealNameRecordExample.Criteria recor = realname.createCriteria();
// recor.andSerialnumberEqualTo(erealname.getSerialnumber());
recor.andSerialnumberIn(listString);
List<RealNameRecord> realnameRecor1 = sqlSession.selectList("com.itrus.portal.db.RealNameRecordMapper.selectByExample", realname);
realnameRecor.put(basic.getId(), realnameRecor1);
for (RealNameRecord real : realnameRecor1) {
// 得到营业执照
if (real.getLicenseinformation() != null) {
Licenseinformation information = sqlSession.selectOne("com.itrus.portal.db.LicenseinformationMapper.selectByPrimaryKey", real.getLicenseinformation());
licensein.put(basic.getId(), information);
}
// 得到企业银行信息
if (real.getEnterprisebank() != null) {
Enterprisebank enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterprisebankMapper.selectByPrimaryKey", real.getEnterprisebank());
enterpris.put(basic.getId(), enterprise);
}
// 得到组织机构代码信息
if (real.getOrganization() != null) {
Organization organization = sqlSession.selectOne("com.itrus.portal.db.OrganizationMapper.selectByPrimaryKey", real.getOrganization());
organiza.put(basic.getId(), organization);
}
// 得到法定代表人信息
if (real.getCorporateinformation() != null) {
Corporateinformation enterprise = sqlSession.selectOne("com.itrus.portal.db.CorporateinformationMapper.selectByPrimaryKey", real.getCorporateinformation());
corporat.put(basic.getId(), enterprise);
}
// 得到代理人信息
if (real.getAgentinformation() != null) {
Agentinformation enterprise = sqlSession.selectOne("com.itrus.portal.db.AgentinformationMapper.selectByPrimaryKey", real.getAgentinformation());
agemtom.put(basic.getId(), enterprise);
}
}
uiModel.addAttribute("realname", realnameRecor);
} else {
PersonalNameExample personal = new PersonalNameExample();
PersonalNameExample.Criteria personalname = personal.createCriteria();
personalname.andSerialnumberEqualTo(erealname.getSerialnumber());
PersonalName personalName1 = sqlSession.selectOne("com.itrus.portal.db.PersonalNameMapper.selectByExample", personal);
personalName.put(basic.getId(), personalName1);
// 得到银行三四要素信息
Bankcardelements bank = sqlSession.selectOne("com.itrus.portal.db.BankcardelementsMapper.selectByPrimaryKey", personalName1.getBankcardelements());
bankcardele.put(basic.getId(), bank);
uiModel.addAttribute("personalName", personalName);
uiModel.addAttribute("realname", personalName);
}
}
}
// 事件内容
EvidenceEventContentExample evencontent = new EvidenceEventContentExample();
EvidenceEventContentExample.Criteria countent = evencontent.createCriteria();
// countent.andBasicInformationEqualTo(basic.getId());
countent.andEvidenceSnEqualTo(basic.getEvidenceSn());
List<EvidenceEventContent> mevencontent = sqlSession.selectList("com.itrus.portal.db.EvidenceEventContentMapper.selectByExample", evencontent);
eventcontent.put(basic.getId(), mevencontent.get(0));
// 得到身份可信标识
EvidenceTrustedIdentityExample trusten = new EvidenceTrustedIdentityExample();
EvidenceTrustedIdentityExample.Criteria identityex = trusten.createCriteria();
identityex.andBasicInformationEqualTo(basic.getEvidenceSn());
identityex.andEventContentIsNull();
List<EvidenceTrustedIdentity> trustedidentity = sqlSession.selectList("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trusten);
trusted.put(basic.getId(), trustedidentity);
// 事件对象认证
EvidenceTrustedIdentityExample trustenid = new EvidenceTrustedIdentityExample();
EvidenceTrustedIdentityExample.Criteria identitye = trustenid.createCriteria();
identitye.andEventContentEqualTo(mevencontent.get(0).getIdCode());
List<EvidenceTrustedIdentity> trustedidentit = sqlSession.selectList("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trustenid);
trusid.put(basic.getId(), trustedidentit);
// 事件时间认证
EvidenceEventTimeExample eventime = new EvidenceEventTimeExample();
EvidenceEventTimeExample.Criteria eventimeEx = eventime.createCriteria();
eventimeEx.andEventContentEqualTo(mevencontent.get(0).getIdCode());
List<EvidenceEventTime> meventime = sqlSession.selectList("com.itrus.portal.db.EvidenceEventTimeMapper.selectByExample", eventime);
enenttime.put(basic.getId(), meventime);
// 事件行为认证
EvidenceEventBehaviorExample eventbehaciorEx = new EvidenceEventBehaviorExample();
EvidenceEventBehaviorExample.Criteria eventbe = eventbehaciorEx.createCriteria();
eventbe.andEventContentEqualTo(mevencontent.get(0).getIdCode());
List<EvidenceEventBehavior> eventbehacior = sqlSession.selectList("com.itrus.portal.db.EvidenceEventBehaviorMapper.selectByExample", eventbehaciorEx);
enenbehavior.put(basic.getId(), eventbehacior);
// 事件意愿认证
EvidenceEventDesireExample desireEx = new EvidenceEventDesireExample();
EvidenceEventDesireExample.Criteria eventdesire = desireEx.createCriteria();
// eventdesire.andMainInformationEqualTo(basic.getId());
eventdesire.andEventContenteEqualTo(mevencontent.get(0).getIdCode());
List<EvidenceEventDesire> meventdesire = sqlSession.selectList("com.itrus.portal.db.EvidenceEventDesireMapper.selectByExample", desireEx);
evendesire.put(basic.getId(), meventdesire);
blist.add(basic);
// 判断图片是否存在
if (mevencontent.get(0).getIsimg() == null) {
// EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", mevencontent.getBasicInformation());
// 得到证据附件表,用于获取信息
EvidenceEnclosureExample envlosureE = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria envlosureEx = envlosureE.createCriteria();
envlosureEx.andEvidenceSnEqualTo(basic.getEvidenceSn());
envlosureEx.andPdfTypeEqualTo("2");
EvidenceEnclosure envlosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", envlosureE);
// 判断是否为用户上传pdf
if (envlosure != null) {
String urlFile = systemConfigService.getpdfurl() + File.separator + envlosure.getBucketName() + File.separator + envlosure.getEvidenceSn();
File filePathStr = new File(urlFile, envlosure.getObjectName());
int pdfToPng = 0;
if (filePathStr != null && filePathStr.getPath() != null) {
try {
pdfToPng = Pdf.pdf2png(filePathStr.getPath());
} catch (Exception e) {
e.printStackTrace();
}
}
// 判断生成图片是否成功
if (pdfToPng > 0) {
// 修改内容表信息,表示生成图片
mevencontent.get(0).setIsimg(1);
mevencontent.get(0).setImgCount(pdfToPng);
sqlSession.update("com.itrus.portal.db.EvidenceEventContentMapper.updateByPrimaryKey", mevencontent);
String oper = "原文图片生成成功";
String info = "图片地址:" + urlFile;
LogUtil.evidencelog(sqlSession, null, oper, info);
} else {
String oper = "原文图片生成失败";
String info = "失败原因:" + systemConfigService.getpdfurl() + File.separator + envlosure.getBucketName();
LogUtil.evidencelog(sqlSession, null, oper, info);
}
}
}
}
uiModel.addAttribute("basicinfos", basicinfos);
// 平台代表人
uiModel.addAttribute("erepresetative", erepresetative);
// 平台代理人
uiModel.addAttribute("etheagent", etheagent);
// 营业执照信息
uiModel.addAttribute("licensein", licensein);
// 企业银行信息
uiModel.addAttribute("enterpris", enterpris);
// 住址机构代码
uiModel.addAttribute("organiza", organiza);
// 法定代表人
uiModel.addAttribute("corporat", corporat);
// 法定代理人
uiModel.addAttribute("agemtom", agemtom);
// 银行卡三四要素
uiModel.addAttribute("bankcardele", bankcardele);
// 得到得到身份意愿信息
uiModel.addAttribute("mdesire", mdesire);
// 得到事件时间信息
uiModel.addAttribute("enenttime", enenttime);
// 得到事件行为认证信息
uiModel.addAttribute("enenbehavior", enenbehavior);
// 得到时间对象
uiModel.addAttribute("trusid", trusid);
// 得到身份标识信息
uiModel.addAttribute("trusted", trusted);
// 得到证据基本信息表
uiModel.addAttribute("blist", blist);
// 得到事件内容信息
uiModel.addAttribute("eventcontent", eventcontent);
// 得到出证信息
uiModel.addAttribute("hisCertificate", hisCertificate);
// 出证时间
uiModel.addAttribute("datetime", new Date());
return "reporttemplate/certificationReport1";
}
use of com.itrus.portal.db.EvidenceHisCertificateExample in project portal by ixinportal.
the class EvidenceSaveServiceApi method searchGenerated.
/**
* 查询出证
* @param signature
* 签名值
* @param appId
* 应用标识
* @param orderNumber
* 服务流水号
* @param request
* @return
*/
@RequestMapping(value = "/searchGenerated")
@ResponseBody
public Map<String, Object> searchGenerated(@RequestHeader("Content-Signature") String signature, @RequestParam(value = "appId", required = true) String appId, @RequestParam(value = "orderNumber", required = true) String orderNumber, HttpServletRequest request) {
// TODO : 查询出证接口
Map<String, Object> result = new HashMap<String, Object>();
// 验证参数是否完整
if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(orderNumber)) {
result.put("status", 0);
result.put("message", "提交的参数信息不完整");
return result;
}
// 得到应用信息 改成service
Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
ApplicationInfo applicationInfo = appInfoMap.get(appId);
if (applicationInfo == null) {
ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
appInfoExampleCriteria.andAppIdEqualTo(appId);
applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
}
if (applicationInfo == null) {
result.put("status", -11);
result.put("message", "应用标识不存在");
return result;
}
if (applicationInfo.getIsAppStatus() == 0) {
result.put("status", -12);
result.put("message", "应用状态已关闭");
return result;
}
// 核验ip限制
if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
result.put("status", -1);
result.put("message", "没有此服务权限");
log.debug("EvidenceSaveSeriveceTest_AccsessIp : " + request.getRemoteAddr());
return result;
}
// 验证hmac有效性
try {
String macVal = Base64.encode(HMACSHA1.getHmacSHA1(appId + orderNumber, applicationInfo.getSecretKey()), false);
if (!signature.equals("HMAC-SHA1 " + macVal)) {
result.put("status", -2);
result.put("message", "服务密钥错误");
return result;
}
} catch (Exception e) {
result.put("status", -3);
result.put("message", "Hmac验证错误");
e.printStackTrace();
return result;
}
EvidenceHisCertificateExample hisCertificateExample = new EvidenceHisCertificateExample();
EvidenceHisCertificateExample.Criteria hec = hisCertificateExample.createCriteria();
hec.andSerialnumberEqualTo(orderNumber);
List<EvidenceHisCertificate> hisCertificates = sqlSession.selectList("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByExample", hisCertificateExample);
if (hisCertificates.size() == 0 || hisCertificates.isEmpty()) {
result.put("status", 0);
result.put("message", "流水号信息有误");
return result;
}
EvidenceHisCertificate hisCertificate = hisCertificates.get(0);
if (StringUtils.isNotEmpty(hisCertificate.getHisCauseFailure())) {
result.put("status", 0);
result.put("message", hisCertificate.getHisCauseFailure());
return result;
}
EvidenceHisRelationshipExample hisRelationshipExample = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria rec = hisRelationshipExample.createCriteria();
rec.andHisCertificateEqualTo(hisCertificate.getId());
List<EvidenceHisRelationship> hisRelationships = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", hisCertificates);
for (EvidenceHisRelationship hisRelationship : hisRelationships) {
EvidenceBasicInformation basicInformation = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", hisRelationship.getBasicInformation());
Map<String, Object> map = evidenceSaveService.verifyFactor(basicInformation.getEvidenceSn());
if ((int) map.get("status") != 1) {
result.put("status", map.get("status"));
result.put("message", map.get("message"));
return result;
}
}
// 通过流水号得到证据附件信息
EvidenceEnclosureExample enclosurExample = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria ec = enclosurExample.createCriteria();
ec.andSerialnumberEqualTo(orderNumber);
ec.andPdfTypeEqualTo("4");
List<EvidenceEnclosure> enclosurs = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosurExample);
// 判断证据是否已出
if ("0".equals(hisCertificate.getHisState()) && enclosurs != null) {
EvidenceEnclosure enclosure = enclosurs.get(0);
try {
// 获取密码服务
RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
if (realNameAuthentication == null) {
realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
}
if (realNameAuthentication == null) {
result.put("status", -6);
result.put("message", "缺少服务配置,请联系管理员");
return result;
}
// 下载出证报告base64
String str = decryptedAndDownload(sqlSession, enclosure.getBuid(), realNameAuthentication.getRealNameddress());
} catch (Exception e) {
result.put("status", -5);
result.put("message", "服务器出错,请联系管理员");
String oper = "查询出证接口-异常";
String info = "服务流水号: " + orderNumber + ",错误原因:" + e.toString();
LogUtil.evidencelog(sqlSession, null, oper, info);
}
} else {
// 生成出证报告
Map<String, Object> mapRet = null;
// 判断是否为自动出证
if (hisCertificate.getHisway().equals("1")) {
// 生成出证报告
try {
mapRet = reportTemplate.certificationReport(hisCertificate.getSerialnumber());
} catch (Exception e) {
result.put("status", 0);
result.put("message", "出证失败");
return result;
}
} else {
result.put("status", 0);
result.put("message", "无法自动出证");
return result;
}
// 判断出证报告是否生成成功
if (mapRet != null && (int) mapRet.get("status") == 0) {
result.put("status", 1);
result.put("message", "出证成功");
result.put("orderNumber", hisCertificate.getSerialnumber());
result.put("pdfBase64", mapRet.get("pdfBase64"));
hisCertificate.setHisState("0");
} else {
result.put("status", 0);
result.put("message", "出证失败");
hisCertificate.setHisCauseFailure(mapRet.get("message").toString());
// 判断为自动出证失败后 转人工出证
if (hisCertificate.getHisway().equals("1")) {
hisCertificate.setHisway("3");
result.put("message", "出证失败,已自动转人工出证");
}
}
sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey", hisCertificate);
}
return result;
}
use of com.itrus.portal.db.EvidenceHisCertificateExample in project portal by ixinportal.
the class HisCertificateController method preview.
/**
* 预览出证信息
*
* @param serialnumber
* @param type
* @param uiModel
* @return
*/
@RequestMapping(value = "/outhis/{serialnumber}", produces = "text/html")
public String preview(@PathVariable("serialnumber") String serialnumber, Model uiModel) {
// 得到证据基本信息表
List<EvidenceBasicInformation> blist = new ArrayList<EvidenceBasicInformation>();
// 得到企业平台信息
Map<Long, EvidenceCompaniesSubmit> companiesSubmit = new HashMap<Long, EvidenceCompaniesSubmit>();
// 得到天威企业信息
Map<Long, List<RealNameRecord>> realnameRecor = new HashMap<Long, List<RealNameRecord>>();
// 得到天威个人信息
Map<Long, PersonalName> personalName = new HashMap<Long, PersonalName>();
// 得到个人平台信息
Map<Long, EvidenceIndividual> denceid = new HashMap<Long, EvidenceIndividual>();
// 得到得到身份意愿信息
Map<Long, EvidenceDesireIdentify> mdesire = new HashMap<Long, EvidenceDesireIdentify>();
// 得到事件内容信息
Map<Long, EvidenceEventContent> eventcontent = new HashMap<Long, EvidenceEventContent>();
// 得到时间对象
Map<Long, List<EvidenceTrustedIdentity>> trusid = new HashMap<Long, List<EvidenceTrustedIdentity>>();
// 得到身份标识信息
Map<Long, List<EvidenceTrustedIdentity>> trusted = new HashMap<Long, List<EvidenceTrustedIdentity>>();
// 得到事件时间信息
Map<Long, List<EvidenceEventTime>> enenttime = new HashMap<Long, List<EvidenceEventTime>>();
// 得到事件行为认证信息
Map<Long, List<EvidenceEventBehavior>> enenbehavior = new HashMap<Long, List<EvidenceEventBehavior>>();
// 得到事件意愿认证信息
Map<Long, List<EvidenceEventDesire>> evendesire = new HashMap<Long, List<EvidenceEventDesire>>();
// 得到平台提交信息代表人
Map<Long, EvidenceRepresentative> erepresetative = new HashMap<Long, EvidenceRepresentative>();
// 得到平台提交信息代理人
Map<Long, EvidenceTheAgent> etheagent = new HashMap<Long, EvidenceTheAgent>();
// 得到营业执照
Map<Long, Licenseinformation> licensein = new HashMap<Long, Licenseinformation>();
// 得到企业银行信息
Map<Long, Enterprisebank> enterpris = new HashMap<Long, Enterprisebank>();
// 得到组织机构代码
Map<Long, Organization> organiza = new HashMap<Long, Organization>();
// 得到法定代表人信息
Map<Long, Corporateinformation> corporat = new HashMap<Long, Corporateinformation>();
// 得到代理人信息
Map<Long, Agentinformation> agemtom = new HashMap<Long, Agentinformation>();
// 得到银行三四要素信息
Map<Long, Bankcardelements> bankcardele = new HashMap<Long, Bankcardelements>();
// 证据基本信息,放入多个基本信息
List<EvidenceBasicInformation> basicinfos = new ArrayList<EvidenceBasicInformation>();
// 得到出证信息
EvidenceHisCertificateExample hiscer = new EvidenceHisCertificateExample();
EvidenceHisCertificateExample.Criteria tificate = hiscer.createCriteria();
tificate.andSerialnumberEqualTo(serialnumber);
EvidenceHisCertificate hisCertificate = sqlSession.selectOne("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByExample", hiscer);
// 出征流水号
contractNumber = hisCertificate.getSerialnumber();
// 得到出证存证中间表
EvidenceHisRelationshipExample hisrelation = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria shipEx = hisrelation.createCriteria();
shipEx.andHisCertificateEqualTo(hisCertificate.getId());
List<EvidenceHisRelationship> hisrelationship = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", hisrelation);
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
basicinfos.add(basic);
// 得到身份意愿信息
EvidenceDesireIdentifyExample desireIdentify = new EvidenceDesireIdentifyExample();
EvidenceDesireIdentifyExample.Criteria desireExample = desireIdentify.createCriteria();
desireExample.andEvidenceSnEqualTo(basic.getEvidenceSn());
EvidenceDesireIdentify desire = sqlSession.selectOne("com.itrus.portal.db.EvidenceDesireIdentifyMapper.selectByExample", desireIdentify);
mdesire.put(basic.getId(), desire);
// 得到身份信息表
EvidenceRealNameExample realnameE = new EvidenceRealNameExample();
EvidenceRealNameExample.Criteria realnameEx = realnameE.createCriteria();
realnameEx.andBasicInformationEqualTo(basic.getId());
EvidenceRealName erealname = sqlSession.selectOne("com.itrus.portal.db.EvidenceRealNameMapper.selectByExample", realnameE);
if (erealname != null) {
// 判断身份信息是否为空
if (!"1".equals(erealname.getEventVerifierType())) {
// 判断平台认证
if ("1".equals(erealname.getType())) {
// 判断平台企业认证
EvidenceCompaniesSubmit companiesSubmit1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceCompaniesSubmitMapper.selectByPrimaryKey", erealname.getCompaniesSubmit());
companiesSubmit.put(basic.getId(), companiesSubmit1);
// 得到法定代表人
EvidenceRepresentative representative = sqlSession.selectOne("com.itrus.portal.db.EvidenceRepresentativeMapper.selectByPrimaryKey", companiesSubmit1.getRepresentative());
erepresetative.put(basic.getId(), representative);
// 得到代理人
EvidenceTheAgent theAgen = sqlSession.selectOne("com.itrus.portal.db.EvidenceTheAgentMapper.selectByPrimaryKey", companiesSubmit1.getTheAgent());
etheagent.put(basic.getId(), theAgen);
uiModel.addAttribute("companiesSubmit", companiesSubmit);
uiModel.addAttribute("realname", companiesSubmit);
} else {
// 平台个人认证
EvidenceIndividual dic = sqlSession.selectOne("com.itrus.portal.db.EvidenceIndividualMapper.selectByPrimaryKey", erealname.getIndividual());
denceid.put(basic.getId(), dic);
uiModel.addAttribute("denceid", denceid);
uiModel.addAttribute("realname", denceid);
}
} else {
// 天威认证
if ("1".equals(erealname.getType())) {
// 天威企业认证
String serialnamber = erealname.getSerialnumber();
String[] namber = serialnamber.split(",");
// List<RealNameRecord> listReal = new
// ArrayList<RealNameRecord>();
List<String> listString = new ArrayList<String>();
for (int i = 0; i < namber.length; i++) {
listString.add(namber[i]);
}
RealNameRecordExample realname = new RealNameRecordExample();
RealNameRecordExample.Criteria recor = realname.createCriteria();
// recor.andSerialnumberEqualTo(erealname.getSerialnumber());
recor.andSerialnumberIn(listString);
List<RealNameRecord> realnameRecor1 = sqlSession.selectList("com.itrus.portal.db.RealNameRecordMapper.selectByExample", realname);
realnameRecor.put(basic.getId(), realnameRecor1);
for (RealNameRecord real : realnameRecor1) {
// 得到营业执照
if (real.getLicenseinformation() != null) {
Licenseinformation information = sqlSession.selectOne("com.itrus.portal.db.LicenseinformationMapper.selectByPrimaryKey", real.getLicenseinformation());
licensein.put(basic.getId(), information);
}
// 得到企业银行信息
if (real.getEnterprisebank() != null) {
Enterprisebank enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterprisebankMapper.selectByPrimaryKey", real.getEnterprisebank());
enterpris.put(basic.getId(), enterprise);
}
// 得到组织机构代码信息
if (real.getOrganization() != null) {
Organization organization = sqlSession.selectOne("com.itrus.portal.db.OrganizationMapper.selectByPrimaryKey", real.getOrganization());
organiza.put(basic.getId(), organization);
}
// 得到法定代表人信息
if (real.getCorporateinformation() != null) {
Corporateinformation enterprise = sqlSession.selectOne("com.itrus.portal.db.CorporateinformationMapper.selectByPrimaryKey", real.getCorporateinformation());
corporat.put(basic.getId(), enterprise);
}
// 得到代理人信息
if (real.getAgentinformation() != null) {
Agentinformation enterprise = sqlSession.selectOne("com.itrus.portal.db.AgentinformationMapper.selectByPrimaryKey", real.getAgentinformation());
agemtom.put(basic.getId(), enterprise);
}
}
uiModel.addAttribute("realname", realnameRecor);
} else {
// 天威个人认证
PersonalNameExample personal = new PersonalNameExample();
PersonalNameExample.Criteria personalname = personal.createCriteria();
personalname.andSerialnumberEqualTo(erealname.getSerialnumber());
PersonalName personalName1 = sqlSession.selectOne("com.itrus.portal.db.PersonalNameMapper.selectByExample", personal);
personalName.put(basic.getId(), personalName1);
// 得到银行三四要素信息
Bankcardelements bank = sqlSession.selectOne("com.itrus.portal.db.BankcardelementsMapper.selectByPrimaryKey", personalName1.getBankcardelements());
bankcardele.put(basic.getId(), bank);
uiModel.addAttribute("personalName", personalName);
uiModel.addAttribute("realname", personalName);
}
}
}
// 事件内容
EvidenceEventContentExample evencontent = new EvidenceEventContentExample();
EvidenceEventContentExample.Criteria countent = evencontent.createCriteria();
// countent.andBasicInformationEqualTo(basic.getEvidenceSn());
countent.andEvidenceSnEqualTo(basic.getEvidenceSn());
List<EvidenceEventContent> mevencontent = sqlSession.selectList("com.itrus.portal.db.EvidenceEventContentMapper.selectByExample", evencontent);
eventcontent.put(basic.getId(), mevencontent.get(0));
// 得到身份可信标识
EvidenceTrustedIdentityExample trusten = new EvidenceTrustedIdentityExample();
EvidenceTrustedIdentityExample.Criteria identityex = trusten.createCriteria();
identityex.andBasicInformationEqualTo(basic.getEvidenceSn());
identityex.andEventContentIsNull();
List<EvidenceTrustedIdentity> trustedidentity = sqlSession.selectList("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trusten);
trusted.put(basic.getId(), trustedidentity);
// 事件对象认证
EvidenceTrustedIdentityExample trustenid = new EvidenceTrustedIdentityExample();
EvidenceTrustedIdentityExample.Criteria identitye = trustenid.createCriteria();
identitye.andEventContentEqualTo(mevencontent.get(0).getIdCode());
List<EvidenceTrustedIdentity> trustedidentit = sqlSession.selectList("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trustenid);
trusid.put(basic.getId(), trustedidentit);
// 事件时间认证
EvidenceEventTimeExample eventime = new EvidenceEventTimeExample();
EvidenceEventTimeExample.Criteria eventimeEx = eventime.createCriteria();
eventimeEx.andEventContentEqualTo(mevencontent.get(0).getIdCode());
List<EvidenceEventTime> meventime = sqlSession.selectList("com.itrus.portal.db.EvidenceEventTimeMapper.selectByExample", eventime);
enenttime.put(basic.getId(), meventime);
// 事件行为认证
EvidenceEventBehaviorExample eventbehaciorEx = new EvidenceEventBehaviorExample();
EvidenceEventBehaviorExample.Criteria eventbe = eventbehaciorEx.createCriteria();
eventbe.andEventContentEqualTo(mevencontent.get(0).getIdCode());
List<EvidenceEventBehavior> eventbehacior = sqlSession.selectList("com.itrus.portal.db.EvidenceEventBehaviorMapper.selectByExample", eventbehaciorEx);
enenbehavior.put(basic.getId(), eventbehacior);
// 事件意愿认证
EvidenceEventDesireExample desireEx = new EvidenceEventDesireExample();
EvidenceEventDesireExample.Criteria eventdesire = desireEx.createCriteria();
// eventdesire.andMainInformationEqualTo(basic.getId());
eventdesire.andEventContenteEqualTo(mevencontent.get(0).getIdCode());
List<EvidenceEventDesire> meventdesire = sqlSession.selectList("com.itrus.portal.db.EvidenceEventDesireMapper.selectByExample", desireEx);
evendesire.put(basic.getId(), meventdesire);
blist.add(basic);
// 判断图片是否存在
if (mevencontent.get(0).getIsimg() == null) {
// 得到证据附件表,用于获取信息
EvidenceEnclosureExample envlosureE = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria envlosureEx = envlosureE.createCriteria();
envlosureEx.andEvidenceSnEqualTo(basic.getEvidenceSn());
envlosureEx.andPdfTypeEqualTo("2");
EvidenceEnclosure envlosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", envlosureE);
// 判断是否为用户上传pdf
if (envlosure != null) {
String urlFile = systemConfigService.getpdfurl() + File.separator + envlosure.getBucketName() + File.separator + envlosure.getEvidenceSn();
File filePathStr = new File(urlFile, envlosure.getObjectName());
int pdfToPng = 0;
if (filePathStr != null && filePathStr.getPath() != null) {
try {
// 调用生成图片方法生成图片
pdfToPng = Pdf.pdf2png(filePathStr.getPath());
} catch (Exception e) {
e.printStackTrace();
}
}
// 判断生成图片是否成功
if (pdfToPng > 0) {
// 修改内容表信息,表示生成图片
log.error("pdfToPng=" + pdfToPng);
mevencontent.get(0).setIsimg(1);
mevencontent.get(0).setImgCount(pdfToPng);
sqlSession.update("com.itrus.portal.db.EvidenceEventContentMapper.updateByPrimaryKey", mevencontent);
String oper = "原文图片生成成功";
String info = "图片地址:" + urlFile;
LogUtil.evidencelog(sqlSession, null, oper, info);
} else {
String oper = "原文图片生成失败";
String info = "失败原因:" + systemConfigService.getpdfurl() + File.separator + envlosure.getBucketName();
LogUtil.evidencelog(sqlSession, null, oper, info);
}
}
}
}
uiModel.addAttribute("basicinfos", basicinfos);
// 平台代表人
uiModel.addAttribute("erepresetative", erepresetative);
// 平台代理人
uiModel.addAttribute("etheagent", etheagent);
// 营业执照信息
uiModel.addAttribute("licensein", licensein);
// 企业银行信息
uiModel.addAttribute("enterpris", enterpris);
// 住址机构代码
uiModel.addAttribute("organiza", organiza);
// 法定代表人
uiModel.addAttribute("corporat", corporat);
// 法定代理人
uiModel.addAttribute("agemtom", agemtom);
// 银行卡三四要素
uiModel.addAttribute("bankcardele", bankcardele);
// 得到得到身份意愿信息
uiModel.addAttribute("mdesire", mdesire);
// 得到事件时间信息
uiModel.addAttribute("enenttime", enenttime);
// 得到事件行为认证信息
uiModel.addAttribute("enenbehavior", enenbehavior);
// 得到时间对象
uiModel.addAttribute("trusid", trusid);
// 得到身份标识信息
uiModel.addAttribute("trusted", trusted);
// 得到证据基本信息表
uiModel.addAttribute("blist", blist);
// 得到事件内容信息
uiModel.addAttribute("eventcontent", eventcontent);
// 得到出证信息
uiModel.addAttribute("hisCertificate", hisCertificate);
// 出证时间
uiModel.addAttribute("datetime", new Date());
return "reporttemplate/certificationReport";
}
use of com.itrus.portal.db.EvidenceHisCertificateExample in project portal by ixinportal.
the class HisCertificateController method savepdf.
@RequestMapping(params = "uploadPDF", method = RequestMethod.POST, produces = "text/html")
public String savepdf(MultipartFile excelFile, int id, int type, HttpServletRequest request, Model uiModel) throws Exception {
JSONObject ret_data = null;
BufferedInputStream bin = null;
ByteArrayOutputStream baos = null;
BufferedOutputStream bout = null;
String fileName = excelFile.getOriginalFilename();
// 文件类型
String fileType = FilenameUtils.getExtension(fileName);
if ((!fileType.toLowerCase().equals("pdf"))) {
error = "上传失败,上传的文件不是以‘.pdf’文件名结尾";
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
}
// 得到出征信息
EvidenceHisCertificateExample hiscer = new EvidenceHisCertificateExample();
EvidenceHisCertificateExample.Criteria tificate = hiscer.createCriteria();
tificate.andSerialnumberEqualTo(contractNumber);
EvidenceHisCertificate hisCertificate = sqlSession.selectOne("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByExample", hiscer);
// 得到出证关系表
EvidenceHisRelationshipExample hisrelation = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria shipEx = hisrelation.createCriteria();
shipEx.andHisCertificateEqualTo(hisCertificate.getId());
List<EvidenceHisRelationship> hisrelationship = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", hisrelation);
try {
// 建立读取文件的文件输出流
// fin = new FileInputStream(excelFile.getName());
// 在文件输出流上安装节点流(更大效率读取)
// 读取文件流
bin = new BufferedInputStream(excelFile.getInputStream());
// 创建一个新的 byte 数组输出流,它具有指定大小的缓冲区容量
baos = new ByteArrayOutputStream();
// 创建一个新的缓冲输出流,以将数据写入指定的底层输出流
bout = new BufferedOutputStream(baos);
byte[] buffer = new byte[1024];
int len = bin.read(buffer);
while (len != -1) {
bout.write(buffer, 0, len);
len = bin.read(buffer);
}
// 刷新此输出流并强制写出所有缓冲的输出字节,必须这行代码,否则有可能有问题
bout.flush();
byte[] bytes = baos.toByteArray();
// sun公司的API
// return encoder.encodeBuffer(bytes).trim();
// apache公司的API
String base64 = Base64.encodeBase64String(bytes);
RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
if (realNameAuthentication == null) {
realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
}
if (realNameAuthentication == null) {
error = "无服务路径";
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
}
// 得到服务编码
AppService appservice = appService.selectById(hisCertificate.getHisAppService());
// 得到出证服务配置
EvidenceOutServiceConfigExample saveService = new EvidenceOutServiceConfigExample();
EvidenceOutServiceConfigExample.Criteria saveServiceEx = saveService.createCriteria();
saveServiceEx.andAppServiceEqualTo(appservice.getId());
EvidenceOutServiceConfig outService = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutServiceConfigMapper.selectByExample", saveService);
// 得到出证名称
if (outService == null) {
error = "无服务配置";
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
}
// 得到证书信息
EvidenceCertificate certificate = sqlSession.selectOne("com.itrus.portal.db.EvidenceCertificateMapper.selectByPrimaryKey", outService.getEvidenceCertificate());
if (certificate == null) {
error = "无证书信息";
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
}
// 得到密钥信息
EvidenceSecretKey secrerkey = sqlSession.selectOne("com.itrus.portal.db.EvidenceSecretKeyMapper.selectByPrimaryKey", certificate.getEvidenceSecretKey());
EvidenceEnclosure enclosure = new EvidenceEnclosure();
// 得到签章位置配置信息
EvidenceSignetPlaceConfigExample signet = new EvidenceSignetPlaceConfigExample();
EvidenceSignetPlaceConfigExample.Criteria palace = signet.createCriteria();
palace.andEvidenceOutServiceConfigEqualTo(outService.getId());
List<EvidenceSignetPlaceConfig> configlist = sqlSession.selectList("com.itrus.portal.db.EvidenceSignetPlaceConfigMapper.selectByExample", signet);
// 得到接口路径
String urlAgent = realNameAuthentication.getRealNameddress() + PDF_SIGN;
Map<String, Object> paramsAgent = new HashMap<String, Object>();
// 参数信息
paramsAgent.put("alias", secrerkey.getAlias());
paramsAgent.put("pdfContent", base64);
for (EvidenceSignetPlaceConfig config : configlist) {
// 获取签章信息
List<Map> list = new ArrayList<Map>();
Map<String, String> map = new HashMap<String, String>();
if (config != null) {
if (config.getType() == 2) {
// 参数信息
map.put("y", config.getDistanceToDown());
// 参数信息
map.put("width", config.getWidthOfImage());
// 参数信息
map.put("height", config.getHeightOfImage());
list.add(map);
paramsAgent.put("pagingSeal", JSON.toJSONString(list));
} else if (config.getType() == 3) {
// 参数信息
map.put("page", config.getPage());
// 参数信息
map.put("x", config.getDistanceToLeft());
// 参数信息
map.put("y", config.getDistanceToDown());
// 参数信息
map.put("width", config.getWidthOfImage());
// 参数信息
map.put("height", config.getHeightOfImage());
list.add(map);
paramsAgent.put("multiPagesSeal", JSON.toJSONString(list));
} else if (config.getType() == 1) {
// 参数信息
map.put("keyWord", config.getKeyword());
// 参数信息
map.put("page", config.getPage());
// 参数信息
map.put("width", config.getWidthOfImage());
// 参数信息
map.put("height", config.getHeightOfImage());
list.add(map);
paramsAgent.put("keyWordSeal", JSON.toJSONString(list));
}
}
}
boolean isbool = true;
String signedPdf = null;
if (outService.getIsAddTimestamp() == 2) {
isbool = false;
}
// 参数信息
paramsAgent.put("timeStamp", isbool);
// paramsAgent.put("resultType",2L);//参数信息
// 调用签章接口返回数据
String repAgent = HttpClientUtil.postForm(urlAgent, AuthService.getHeader(), paramsAgent);
// 把数据转换为json格式
ret_data = JSONObject.parseObject(repAgent);
if (ret_data.getIntValue("code") != 0) {
// 判断是否成功
String oper = "出证报告失败-pdf签章失败";
String info = "错误原因:" + ret_data.getString("message");
LogUtil.evidencelog(sqlSession, null, oper, info);
error = ret_data.getString("message");
// 修改证据中的出证状态
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
basic.setStatus(4);
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basic);
}
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
} else {
// 证书base编码
signedPdf = ret_data.getString("signedPdf");
// 正式系统将hood替换为/**/重的值
String retpdf = EvidenceSaveServiceApi.storageSave("ST_O", "hood", /*realNameAuthentication.getKeyCode()*/
hisCertificate.getSerialnumber() + ".pdf", "CT_MESSAGE", signedPdf, null, null, null, null, null, false, null, realNameAuthentication.getRealNameddress());
// 把数据转换为json格式
ret_data = JSONObject.parseObject(retpdf);
if (ret_data.getInteger("code") == 0) {
// 获取证据附件表
EvidenceEnclosureExample envlosureE = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria envlosureEx = envlosureE.createCriteria();
envlosureEx.andSerialnumberEqualTo(hisCertificate.getSerialnumber());
envlosureEx.andPdfTypeEqualTo("4");
EvidenceEnclosure envlosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", envlosureE);
if (envlosure != null && envlosure.getPdfType() != null) {
envlosure.setPdfType("4");
envlosure.setEvidenceSn(null);
envlosure.setSerialnumber(hisCertificate.getSerialnumber());
envlosure.setType("ST_E");
envlosure.setContentType("CT_BASE64_DATA");
envlosure.setBucketName(realNameAuthentication.getKeyCode());
envlosure.setObjectName(fileName);
envlosure.setAlias(secrerkey.getAlias());
envlosure.setFilesize(null);
envlosure.setApplicationTime(new Date());
envlosure.setFixationTime(new Date());
envlosure.setSaveFactor(null);
envlosure.setBuid(ret_data.getString("buid").toString());
// ret_data.remove("saveFactor");
sqlSession.update("com.itrus.portal.db.EvidenceEnclosureMapper.updateByPrimaryKey", envlosure);
} else {
enclosure.setPdfType("4");
enclosure.setEvidenceSn(null);
enclosure.setSerialnumber(hisCertificate.getSerialnumber());
enclosure.setType("ST_E");
enclosure.setContentType("CT_BASE64_DATA");
enclosure.setBucketName(realNameAuthentication.getKeyCode());
enclosure.setObjectName(fileName);
enclosure.setAlias(secrerkey.getAlias());
enclosure.setFilesize(null);
enclosure.setApplicationTime(new Date());
enclosure.setFixationTime(new Date());
enclosure.setSaveFactor(null);
enclosure.setBuid(ret_data.getString("buid").toString());
// ret_data.remove("saveFactor");
sqlSession.insert("com.itrus.portal.db.EvidenceEnclosureMapper.insert", enclosure);
}
hisCertificate.setHisTime(new Date());
hisCertificate.setHisway("2");
hisCertificate.setHisState("0");
hisCertificate.setOutState(0);
sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey", hisCertificate);
// 修改证据中的出证状态
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
basic.setStatus(2);
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basic);
}
error = "上传pdf成功";
String oper = "pdf上传成功";
String info = "存储编号:" + ret_data.getString("buid").toString() + "pdf名称:" + hisCertificate.getSerialnumber();
LogUtil.evidencelog(sqlSession, null, oper, info);
}
}
} catch (FileNotFoundException e) {
// 修改证据中的出证状态
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
basic.setStatus(4);
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basic);
}
e.printStackTrace();
String oper = "pdf上传失败";
String info = "失败原因:" + e.getMessage();
LogUtil.evidencelog(sqlSession, null, oper, info);
error = e.getMessage();
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
} catch (IOException e) {
// 修改证据中的出证状态
for (EvidenceHisRelationship h : hisrelationship) {
// 得到基本信息表
EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", h.getBasicInformation());
basic.setStatus(4);
sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basic);
}
e.printStackTrace();
String oper = "pdf上传失败";
String info = "失败原因:" + e.getMessage();
LogUtil.evidencelog(sqlSession, null, oper, info);
error = e.getMessage();
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
} finally {
try {
bin.close();
// 关闭 ByteArrayOutputStream 无效。此类中的方法在关闭此流后仍可被调用,而不会产生任何
// IOException
// 暂时关闭掉
baos.close();
bout.close();
} catch (IOException e) {
e.printStackTrace();
error = e.getMessage();
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
}
}
return "redirect:/hiscertificate/showpdf/" + id + "/" + type;
}
Aggregations