use of com.itrus.portal.db.EvidenceOutServiceConfigExample in project portal by ixinportal.
the class HisCertificateController method showpdf.
/**
* 查看详情 导入PDF跳转详情方法
*
* @param id
* @param type
* @param uiModel
* @return
*/
@RequestMapping(value = "/showpdf/{id}/{type}", produces = "text/html")
public String showpdf(@PathVariable("id") Long id, @PathVariable("type") int type, Model uiModel) {
EvidenceHisCertificate hisCertificate = hiscertificate.selectById(id);
// 得到服务编码
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);
// 得到出证模板信息
EvidenceOutTemplate outtemp = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutTemplateMapper.selectByPrimaryKey", outService.getSaveRetTemplate());
uiModel.addAttribute("hisCertificate", hisCertificate);
uiModel.addAttribute("outtemp", outtemp);
Map<Long, List<EvidenceMainInformation>> minfo = new HashMap<Long, List<EvidenceMainInformation>>();
List<EvidenceBasicInformation> blists = new ArrayList<EvidenceBasicInformation>();
// 得到出证关联表信息
EvidenceHisRelationshipExample relation = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria hisreation = relation.createCriteria();
hisreation.andHisCertificateEqualTo(hisCertificate.getId());
List<EvidenceHisRelationship> hisRelation = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", relation);
// 获取证据附件表
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);
uiModel.addAttribute("envlosure", envlosure);
for (int j = 0; j < hisRelation.size(); j++) {
List<EvidenceMainInformation> mlist = new ArrayList<EvidenceMainInformation>();
// 得到证据基本信息
EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", hisRelation.get(j).getBasicInformation());
blists.add(basic);
// 得到证据身份主题关联信息
EvidenceSubjectIdentityExample subjectExample = new EvidenceSubjectIdentityExample();
EvidenceSubjectIdentityExample.Criteria identity = subjectExample.createCriteria();
identity.andBasicInformationEqualTo(basic.getEvidenceSn());
List<EvidenceSubjectIdentity> subjectIdentity = sqlSession.selectList("com.itrus.portal.db.EvidenceSubjectIdentityMapper.selectByExample", subjectExample);
for (int g = 0; g < subjectIdentity.size(); g++) {
// 得到主题身份信息
EvidenceMainInformation mainInfo = sqlSession.selectOne("com.itrus.portal.db.EvidenceMainInformationMapper.selectByPrimaryKey", subjectIdentity.get(g).getMainInformation());
mlist.add(mainInfo);
}
minfo.put(basic.getId(), mlist);
}
uiModel.addAttribute("mainInfo", minfo);
uiModel.addAttribute("blists", blists);
if (type == 1) {
uiModel.addAttribute("error", error);
return "hiscertificate/show";
} else if (type == 2) {
return "hiscertificate/show1";
}
return null;
}
use of com.itrus.portal.db.EvidenceOutServiceConfigExample 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.EvidenceOutServiceConfigExample in project portal by ixinportal.
the class BasicInformationController method show.
/**
* 查看详情
*
* @param id
* @param uiModel
* @return
*/
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
Date time = new Date();
// 得到方法开始的时间
log.error("---------------------------" + time);
basid = id;
int coutn = 0;
int size = 0;
int cousize = 0;
EvidenceBasicInformation basicinfor = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", id);
List<EvidenceMainInformation> mlist = new ArrayList<EvidenceMainInformation>();
Map<Long, EvidenceCompaniesSubmit> companiesSubmit = new HashMap<Long, EvidenceCompaniesSubmit>();
Map<Long, List<RealNameRecord>> realnameRecor = new HashMap<Long, List<RealNameRecord>>();
Map<Long, List<PersonalName>> personalName = new HashMap<Long, List<PersonalName>>();
Map<Long, EvidenceIndividual> denceid = new HashMap<Long, EvidenceIndividual>();
Map<Long, EvidenceRealName> realName = new HashMap<Long, EvidenceRealName>();
// 事件对象认证
Map<Long, EvidenceTrustedIdentity> trustedidentit = new HashMap<Long, EvidenceTrustedIdentity>();
// 事件时间认证
Map<Long, EvidenceEventTime> meventime = new HashMap<Long, EvidenceEventTime>();
// 事件行为认证
Map<Long, EvidenceEventBehavior> eventbehacior = new HashMap<Long, EvidenceEventBehavior>();
// 无主体 事件对象认证
Map<Integer, EvidenceTrustedIdentity> maintrustedidentit = new HashMap<Integer, EvidenceTrustedIdentity>();
// 无主体事件时间认证
Map<Integer, EvidenceEventTime> mainmeventime = new HashMap<Integer, EvidenceEventTime>();
// 无主体事件行为认证
Map<Integer, EvidenceEventBehavior> maineventbehacior = new HashMap<Integer, EvidenceEventBehavior>();
// 事件意愿认证
Map<Long, EvidenceEventDesire> meventdesire = new HashMap<Long, EvidenceEventDesire>();
// 事件网络地址
Map<Long, EvidenceEventNetworkAddress> networkaddress = new HashMap<Long, EvidenceEventNetworkAddress>();
// 得到主体身份信息
EvidenceSubjectIdentityExample subjectExample = new EvidenceSubjectIdentityExample();
EvidenceSubjectIdentityExample.Criteria identity = subjectExample.createCriteria();
// subjectExample.isDistinct();
identity.andBasicInformationEqualTo(basicinfor.getEvidenceSn());
List<EvidenceSubjectIdentity> subjectIdentity = sqlSession.selectList("com.itrus.portal.db.EvidenceSubjectIdentityMapper.selectByExample", subjectExample);
for (int i = 0; i < subjectIdentity.size(); i++) {
// 得到主体信息
EvidenceMainInformationExample infomationE = new EvidenceMainInformationExample();
EvidenceMainInformationExample.Criteria tionE = infomationE.createCriteria();
tionE.andIdentificationEqualTo(subjectIdentity.get(i).getMainInformation());
// infomationE.isDistinct();
if (subjectIdentity.get(i).getMainName() != null) {
tionE.andSubjectNameEqualTo(subjectIdentity.get(i).getMainName());
}
List<EvidenceMainInformation> mainInfo = sqlSession.selectList("com.itrus.portal.db.EvidenceMainInformationMapper.selectByExample", infomationE);
if (mainInfo.size() != 0) {
mlist.add(mainInfo.get(0));
}
}
for (int i = 0; i < mlist.size() - 1; i++) {
for (int j = mlist.size() - 1; j > i; j--) {
if (mlist.get(j).getIdentification().equals(mlist.get(i).getIdentification()) && mlist.get(j).getSubjectName().equals(mlist.get(i).getSubjectName())) {
mlist.remove(j);
}
}
}
log.error("主题数量**********" + mlist.size());
// 得到主题的时间
Date time1 = new Date();
Long Ltime = time1.getTime() - time.getTime();
log.error("得到主题身份的毫秒数,Ltime" + Ltime);
// 得到身份可信标识
EvidenceTrustedIdentityExample trusten = new EvidenceTrustedIdentityExample();
EvidenceTrustedIdentityExample.Criteria identityex = trusten.createCriteria();
identityex.andBasicInformationEqualTo(basicinfor.getEvidenceSn());
identityex.andEventContentIsNull();
Map<Long, EvidenceTrustedIdentity> trustedidentity = sqlSession.selectMap("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trusten, "mainInformation");
// 得到主题的时间
Date time2 = new Date();
Long Ltime1 = time2.getTime() - time.getTime();
log.error("得到身份可信标识的毫秒数,Ltime1=" + Ltime1);
// 身份意愿map
Map<Long, EvidenceDesireIdentify> desire = new HashMap<Long, EvidenceDesireIdentify>();
// 证据基本信息map
Map<Long, EvidenceBasicInformation> basi = new HashMap<Long, EvidenceBasicInformation>();
EvidenceRealName erealname = new EvidenceRealName();
// 循环主题信息
for (EvidenceMainInformation m : mlist) {
// 判断可信身份标识是否为空
if (/*trustedidentity!=null && trustedidentity.size()!=0&&*/
trustedidentity.get(m.getId()) != null && trustedidentity.get(m.getId()).getEvidenceSn() != null) {
// 得到可信身份标识关联的身份证据编号
String evidenceSn = trustedidentity.get(m.getId()).getEvidenceSn().toString();
if (StringUtils.isNotEmpty(evidenceSn)) {
EvidenceBasicInformationExample basicinforE = new EvidenceBasicInformationExample();
EvidenceBasicInformationExample.Criteria critbasic = basicinforE.createCriteria();
critbasic.andEvidenceSnEqualTo(evidenceSn);
EvidenceBasicInformation basicinfor1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByExample", basicinforE);
// 得到身份意愿信息
EvidenceDesireIdentifyExample desireIdentify = new EvidenceDesireIdentifyExample();
EvidenceDesireIdentifyExample.Criteria desireExample = desireIdentify.createCriteria();
desireExample.andEvidenceSnEqualTo(basicinfor1.getEvidenceSn());
EvidenceDesireIdentify desire1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceDesireIdentifyMapper.selectByExample", desireIdentify);
desire.put(m.getId(), desire1);
// 将身份认证信息放入map
basi.put(m.getId(), basicinfor1);
// 得到实名认证信息
EvidenceRealNameExample realnameE = new EvidenceRealNameExample();
EvidenceRealNameExample.Criteria realnameEx = realnameE.createCriteria();
realnameEx.andMainInformationEqualTo(m.getSubjectName() + ";" + m.getIdentification());
// realnameEx.andBasicInformationEqualTo(basicinfor1.getId());
realnameEx.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
erealname = sqlSession.selectOne("com.itrus.portal.db.EvidenceRealNameMapper.selectByExample", realnameE);
realName.put(m.getId(), erealname);
}
if (erealname != null) {
if ("2".equals(erealname.getEventVerifierType()) || "3".equals(erealname.getEventVerifierType())) {
if ("1".equals(erealname.getType())) {
EvidenceCompaniesSubmitExample evidenceCompanies = new EvidenceCompaniesSubmitExample();
EvidenceCompaniesSubmitExample.Criteria submit = evidenceCompanies.createCriteria();
submit.andIdCodeEqualTo(erealname.getCompaniesSubmit());
EvidenceCompaniesSubmit companiesSubmit1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceCompaniesSubmitMapper.selectByExample", evidenceCompanies);
companiesSubmit.put(m.getId(), companiesSubmit1);
} else {
// 天威
EvidenceIndividualExample evidenceIndividual = new EvidenceIndividualExample();
EvidenceIndividualExample.Criteria individual = evidenceIndividual.createCriteria();
individual.andIdCodeEqualTo(erealname.getIndividual());
EvidenceIndividual dic = sqlSession.selectOne("com.itrus.portal.db.EvidenceIndividualMapper.selectByExample", evidenceIndividual);
denceid.put(m.getId(), dic);
}
} else if ("1".equals(erealname.getEventVerifierType())) {
// 天威
if ("1".equals(erealname.getType())) {
// 获取流水号
String serialnamber = erealname.getSerialnumber();
// 将多个流水号以逗号分隔成一个数组
String[] namber = serialnamber.split(",");
// 声明一个list存储流水号
List<String> listString = new ArrayList<String>();
for (int i = 0; i < namber.length; i++) {
// 将数组中的流水号放入list中
listString.add(namber[i]);
}
// 查询实名认证信息
RealNameRecordExample realname = new RealNameRecordExample();
RealNameRecordExample.Criteria recor = realname.createCriteria();
recor.andSerialnumberIn(listString);
realname.setOrderByClause("returntime");
listReal = sqlSession.selectList("com.itrus.portal.db.RealNameRecordMapper.selectByExample", realname);
realnameRecor.put(m.getId(), listReal);
} else {
String serialnamber = erealname.getSerialnumber();
String[] namber = serialnamber.split(",");
List<String> listString = new ArrayList<String>();
for (int i = 0; i < namber.length; i++) {
listString.add(namber[i]);
// listReal.add(realnameRecor1);
}
PersonalNameExample personal = new PersonalNameExample();
PersonalNameExample.Criteria personalname = personal.createCriteria();
personalname.andSerialnumberIn(listString);
personal.setOrderByClause("returntime");
listPersonal = sqlSession.selectList("com.itrus.portal.db.PersonalNameMapper.selectByExample", personal);
personalName.put(m.getId(), listPersonal);
}
}
}
}
}
// 得到身份的时间
Date time3 = new Date();
Long Ltime2 = time3.getTime() - time.getTime();
log.error("得到身份信息的毫秒数,Ltime2=" + Ltime2);
// 事件内容
/*EvidenceEventContentExample evencontent = new EvidenceEventContentExample();
EvidenceEventContentExample.Criteria countent = evencontent.createCriteria();
//countent.andBasicInformationEqualTo(id);
countent.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
EvidenceEventContent mevencontent = sqlSession
.selectOne("com.itrus.portal.db.EvidenceEventContentMapper.selectByExample", evencontent);*/
EvidenceEventContent mevencontent = sqlSession.selectOne("com.itrus.portal.db.EvidenceEventContentMapper.selecttId", basicinfor.getEvidenceSn());
// 得到事件内容的时间
Date time4 = new Date();
Long Ltime3 = time4.getTime() - time.getTime();
log.error("得到事件内容的毫秒数,Ltime3=" + Ltime3);
if (mevencontent != null && mevencontent.getIdCode() != null) {
// 事件对象认证
EvidenceTrustedIdentityExample trustenid = new EvidenceTrustedIdentityExample();
EvidenceTrustedIdentityExample.Criteria identitye = trustenid.createCriteria();
identitye.andEventContentEqualTo(mevencontent.getIdCode());
trustedidentit = sqlSession.selectMap("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trustenid, "mainInformation");
// 事件时间认证
EvidenceEventTimeExample eventime = new EvidenceEventTimeExample();
EvidenceEventTimeExample.Criteria eventimeEx = eventime.createCriteria();
eventimeEx.andEventContentEqualTo(mevencontent.getIdCode());
meventime = sqlSession.selectMap("com.itrus.portal.db.EvidenceEventTimeMapper.selectByExample", eventime, "mainInformation");
// 事件行为认证
EvidenceEventBehaviorExample eventbehaciorEx = new EvidenceEventBehaviorExample();
EvidenceEventBehaviorExample.Criteria eventbe = eventbehaciorEx.createCriteria();
eventbe.andEventContentEqualTo(mevencontent.getIdCode());
eventbehacior = sqlSession.selectMap("com.itrus.portal.db.EvidenceEventBehaviorMapper.selectByExample", eventbehaciorEx, "mainInformation");
// 事件意愿认证
EvidenceEventDesireExample desireEx = new EvidenceEventDesireExample();
EvidenceEventDesireExample.Criteria eventdesire = desireEx.createCriteria();
eventdesire.andEventContenteEqualTo(mevencontent.getIdCode());
meventdesire = sqlSession.selectMap("com.itrus.portal.db.EvidenceEventDesireMapper.selectByExample", desireEx, "mainInformation");
// 事件网络地址
EvidenceEventNetworkAddressExample network = new EvidenceEventNetworkAddressExample();
EvidenceEventNetworkAddressExample.Criteria address = network.createCriteria();
address.andEventContentEqualTo(mevencontent.getIdCode());
networkaddress = sqlSession.selectMap("com.itrus.portal.db.EvidenceEventNetworkAddressMapper.selectByExample", network, "mainInformation");
// 得到证据附件表,用于获取信息
EvidenceEnclosure envlosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByPrimaryKey", mevencontent.getEvidenceEnclosure());
uiModel.addAttribute("enclosure", envlosure);
}
// 得到事件的时间
Date time5 = new Date();
Long Ltime4 = time5.getTime() - time.getTime();
log.error("得到事件详情的毫秒数,Ltime4=" + Ltime4);
// 得到证据附件信息,用于查询服务委托人等信息
EvidenceEnclosureExample enclou = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria sure = enclou.createCriteria();
sure.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
;
sure.andPdfTypeEqualTo("1");
List<EvidenceEnclosure> enclosure = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclou);
// 得到事件的时间
Date qtime = new Date();
Long qLtime = qtime.getTime() - time5.getTime();
log.error("***得到证据附件信息1的毫秒数,qLtime=" + qLtime);
EvidenceEnclosureExample enclouE = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria sureEX = enclouE.createCriteria();
sureEX.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
;
sureEX.andPdfTypeEqualTo("3");
EvidenceEnclosure enclosurepdf = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclouE);
// 得到事件的时间
Date wtime = new Date();
Long wLtime = wtime.getTime() - qtime.getTime();
log.error("---得到证据附件信息2的毫秒数,wLtime=" + wLtime);
// 得到无主题信息的数量
int evencount = 0;
if (trustedidentit.size() > 0) {
evencount = trustedidentit.size();
} else if (meventime.size() > 0) {
evencount = meventime.size();
} else if (maineventbehacior.size() > 0) {
evencount = maineventbehacior.size();
}
Map<Integer, Integer> mapcoune = new HashMap<Integer, Integer>();
// 用于得到无主题信息和数量
for (int g = 0; g < evencount; g++) {
int intsize = 0;
// 得到无主题信息的key
long z = g - evencount;
String s = String.valueOf(z);
// 将long类型转换为int类型,作为map的key进行重组
int f = Integer.parseInt(s);
if (trustedidentit.get(z) != null) {
// System.out.println(trustedidentit.get(z).getMainInformation());
// if(trustedidentit.get(z).getMainInformation()<0){
maintrustedidentit.put(f, trustedidentit.get(z));
cousize++;
intsize++;
// }
}
if (meventime.get(z) != null) {
// if(meventime.get(z).getMainInformation()<0){
mainmeventime.put(f, meventime.get(z));
cousize++;
intsize++;
// }
}
if (eventbehacior.get(z) != null) {
// if(eventbehacior.get(z).getMainInformation()<0){
maineventbehacior.put(f, eventbehacior.get(z));
cousize++;
intsize++;
// }
}
mapcoune.put(f, intsize);
}
uiModel.addAttribute("mapcoune", mapcoune);
uiModel.addAttribute("enclosurepdf", enclosurepdf);
uiModel.addAttribute("maintrustedidentit", maintrustedidentit);
uiModel.addAttribute("mainmeventime", mainmeventime);
uiModel.addAttribute("maineventbehacior", maineventbehacior);
// 得到事件的时间
Date time6 = new Date();
Long Ltime5 = time6.getTime() - time.getTime();
log.error("得到无主题信息的毫秒数,Ltime5=" + Ltime5);
// 服务委托人签名信息
Map<Long, EvidenceClientSignature> cilentsignat = new HashMap<Long, EvidenceClientSignature>();
// 天威签名信息
Map<Long, EvidenceClientSignature> cilentsignature = new HashMap<Long, EvidenceClientSignature>();
// 服务委托人时间戳信息
Map<Long, EvidenceClientTimeStamp> clientTimestamp = new HashMap<Long, EvidenceClientTimeStamp>();
// 天威时间戳信息
Map<Long, EvidenceClientTimeStamp> tclientTimestamp = new HashMap<Long, EvidenceClientTimeStamp>();
// 服务委托人证书信息
Map<Long, List<EvidenceCert>> listcert = new HashMap<Long, List<EvidenceCert>>();
// 服务委托人核验信息
Map<Long, EvidenceCheck> check = new HashMap<Long, EvidenceCheck>();
// 天威核验信息
Map<Long, EvidenceCheck> tcheck = new HashMap<Long, EvidenceCheck>();
int ensize = 0;
Map<Long, Integer> mint = new HashMap<Long, Integer>();
// 循环附件信息取得服务委托人和天威签名时间戳信息
for (EvidenceEnclosure en : enclosure) {
Date time11 = new Date();
int encount = 0;
// 服务委托人签名信息
/*EvidenceClientSignatureExample cilent = new EvidenceClientSignatureExample();
EvidenceClientSignatureExample.Criteria signat = cilent.createCriteria();
signat.andEvidenceSnEqualTo(en.getEvidenceSn());*/
// signat.andNameEqualTo("0");
List<EvidenceClientSignature> listclient = sqlSession.selectList("com.itrus.portal.db.EvidenceClientSignatureMapper.selectcertId", en.getEvidenceSn());
EvidenceClientSignature clien1 = new EvidenceClientSignature();
EvidenceClientSignature clien2 = new EvidenceClientSignature();
for (int i = 0; i < listclient.size(); i++) {
if ("0".equals(listclient.get(i).getName())) {
clien1 = listclient.get(i);
}
if ("1".equals(listclient.get(i).getName())) {
clien2 = listclient.get(i);
}
}
cilentsignat.put(en.getId(), clien1);
if (clien1.getId() != null) {
ensize++;
encount++;
// 服务委托人证书信息
/*EvidenceCertExample certEx = new EvidenceCertExample();
EvidenceCertExample.Criteria evidenceCert = certEx.createCriteria();
evidenceCert.andClientSignatureEqualTo(listclient.getId());*/
List<EvidenceCert> listCert = sqlSession.selectList("com.itrus.portal.db.EvidenceCertMapper.selectByPrimaryKey", clien1.getCertId());
listcert.put(en.getId(), listCert);
// 服务委托人核验信息
EvidenceCheckExample checkEx = new EvidenceCheckExample();
EvidenceCheckExample.Criteria evidenceCheck = checkEx.createCriteria();
evidenceCheck.andClientSignatureEqualTo(clien1.getId());
EvidenceCheck listCheck = sqlSession.selectOne("com.itrus.portal.db.EvidenceCheckMapper.selectByExample", checkEx);
check.put(en.getId(), listCheck);
}
Date time12 = new Date();
Long gettime = time12.getTime() - time11.getTime();
log.error("-----------gettime0--------------" + gettime);
// 天威签名信息
/*EvidenceClientSignatureExample cilentsign = new EvidenceClientSignatureExample();
EvidenceClientSignatureExample.Criteria signature = cilentsign.createCriteria();
signature.andEvidenceSnEqualTo(en.getEvidenceSn());
signature.andNameEqualTo("1");
EvidenceClientSignature clientlist = sqlSession
.selectOne("com.itrus.portal.db.EvidenceClientSignatureMapper.selectByExample", cilentsign);*/
cilentsignature.put(en.getId(), clien2);
if (clien2.getId() != null) {
ensize++;
encount++;
// 服务委托人核验信息
EvidenceCheckExample checkEx = new EvidenceCheckExample();
EvidenceCheckExample.Criteria evidenceCheck = checkEx.createCriteria();
evidenceCheck.andClientSignatureEqualTo(clien2.getId());
EvidenceCheck listCheck = sqlSession.selectOne("com.itrus.portal.db.EvidenceCheckMapper.selectByExample", checkEx);
tcheck.put(en.getId(), listCheck);
}
Date time13 = new Date();
Long gettime1 = time13.getTime() - time12.getTime();
log.error("-----------gettime1--------------" + gettime1);
// 服务委托人时间戳信息
/*EvidenceClientTimeStampExample clientTime = new EvidenceClientTimeStampExample();
EvidenceClientTimeStampExample.Criteria stamp = clientTime.createCriteria();
stamp.andEvidenceSnEqualTo(en.getEvidenceSn());*/
// stamp.andNameEqualTo("0");
log.error("证据编号=======" + en.getEvidenceSn());
List<EvidenceClientTimeStamp> listtime = sqlSession.selectList("com.itrus.portal.db.EvidenceClientTimeStampMapper.selectTimeStamp", en.getEvidenceSn());
EvidenceClientTimeStamp timestamp1 = new EvidenceClientTimeStamp();
EvidenceClientTimeStamp timestamp2 = new EvidenceClientTimeStamp();
log.error("时间戳listtime==--**" + listtime);
for (int j = 0; j < listtime.size(); j++) {
if ("0".equals(listtime.get(j).getName())) {
timestamp1 = listtime.get(j);
log.error("服务委托人时间-----------" + timestamp1);
}
/*else if("1".equals(listtime.get(j).getName())){
timestamp2 = listtime.get(j);
}*/
log.error("服务委托人时间***********" + listtime.get(j).getName());
if ("1".equals(listtime.get(j).getName())) {
timestamp2 = listtime.get(j);
log.error("服务委托人时间-----------" + timestamp2);
}
/*else if("0".equals(listtime.get(j).getName())){
timestamp1 = listtime.get(j);
}*/
}
clientTimestamp.put(en.getId(), timestamp1);
if (timestamp1 != null) {
ensize++;
encount++;
}
Date time14 = new Date();
Long gettime2 = time14.getTime() - time13.getTime();
log.error("-----------gettime2--------------" + gettime2);
// 天威时间戳信息
/*EvidenceClientTimeStampExample tclientTime = new EvidenceClientTimeStampExample();
EvidenceClientTimeStampExample.Criteria tstamp = tclientTime.createCriteria();
tstamp.andEvidenceSnEqualTo(en.getEvidenceSn());
tstamp.andNameEqualTo("1");
EvidenceClientTimeStamp timelist = sqlSession
.selectOne("com.itrus.portal.db.EvidenceClientTimeStampMapper.selectByExample", tclientTime);*/
tclientTimestamp.put(en.getId(), timestamp2);
if (timestamp2 != null) {
ensize++;
encount++;
}
mint.put(en.getId(), encount);
Date time15 = new Date();
Long gettime3 = time15.getTime() - time14.getTime();
log.error("-----------gettime3--------------" + gettime3);
}
// 得到事件的时间
Date time7 = new Date();
Long Ltime6 = time7.getTime() - time.getTime();
log.error("得到证据申请信息和申请时间戳的毫秒数,Ltime6=" + Ltime6);
Long Ltime10 = time7.getTime() - time6.getTime();
log.error("+++++++++++*********---------,Ltime10++++++++++++++=" + Ltime10);
uiModel.addAttribute("ensize", ensize);
uiModel.addAttribute("mint", mint);
List<EvidenceHisCertificate> hisCertificete = new ArrayList<EvidenceHisCertificate>();
EvidenceHisRelationshipExample relation = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria hisreation = relation.createCriteria();
hisreation.andBasicInformationEqualTo(id);
List<EvidenceHisRelationship> hisRelation = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", relation);
for (int g = 0; g < hisRelation.size(); g++) {
// 得到证据基本信息
/*EvidenceBasicInformation basic = sqlSession.selectOne(
"com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey",
hisRelation.get(g).getBasicInformation());*/
EvidenceHisCertificate eh = sqlSession.selectOne("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByPrimaryKey", hisRelation.get(g).getHisCertificate());
hisCertificete.add(eh);
}
// 出证信息
// List<Map<String, Object>> hisCertificete = hiscertificate.selectHisCertificateEnt();
Map<Long, EvidenceOutTemplate> mout = new HashMap<Long, EvidenceOutTemplate>();
Map<Long, EvidenceEnclosure> closure = new HashMap<Long, EvidenceEnclosure>();
Map<Long, List<EvidenceBasicInformation>> mbasilist = new HashMap<Long, List<EvidenceBasicInformation>>();
// ArrayList<EvidenceBasicInformation>();
for (int j = 0; j < hisCertificete.size(); j++) {
List<EvidenceBasicInformation> blist = new ArrayList<EvidenceBasicInformation>();
Long hidId = hisCertificete.get(j).getId();
String serialnumber = hisCertificete.get(j).getSerialnumber();
if (hisCertificete.get(j).getHisAppService() != null && hisCertificete.get(j).getHisAppService() > 0) {
Long appServiceId = hisCertificete.get(j).getHisAppService();
// 得到服务编码
AppService happservice = appService.selectById(appServiceId);
// 得到出证服务配置
EvidenceOutServiceConfigExample outsaveService = new EvidenceOutServiceConfigExample();
EvidenceOutServiceConfigExample.Criteria saveServiceEx = outsaveService.createCriteria();
saveServiceEx.andAppServiceEqualTo(happservice.getId());
EvidenceOutServiceConfig outService = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutServiceConfigMapper.selectByExample", outsaveService);
// 得到出证模板信息
EvidenceOutTemplate outtemp = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutTemplateMapper.selectByPrimaryKey", outService.getSaveRetTemplate());
mout.put(hidId, outtemp);
// 获取证据附件表
EvidenceEnclosureExample envlosureE = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria envlosureEx = envlosureE.createCriteria();
envlosureEx.andSerialnumberEqualTo(serialnumber);
envlosureEx.andPdfTypeEqualTo("4");
EvidenceEnclosure envlosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", envlosureE);
closure.put(hidId, envlosure);
}
uiModel.addAttribute("closure", closure);
/*long hid = Long.parseLong(hisCertificete.get(j).get("id").toString());
EvidenceHisRelationshipExample relation = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria hisreation = relation.createCriteria();
hisreation.andHisCertificateEqualTo(hid);
List<EvidenceHisRelationship> hisRelation = sqlSession
.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", relation);
for (int g = 0; g < hisRelation.size(); g++) {
// 得到证据基本信息
EvidenceBasicInformation basic = sqlSession.selectOne(
"com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey",
hisRelation.get(g).getBasicInformation());
blist.add(basic);
}
mbasilist.put(hidId, blist);*/
}
uiModel.addAttribute("basi", basi);
uiModel.addAttribute("check", check);
uiModel.addAttribute("listcert", listcert);
uiModel.addAttribute("realName", realName);
uiModel.addAttribute("mbasilist", mbasilist);
uiModel.addAttribute("mout", mout);
uiModel.addAttribute("envlosure", enclosure);
uiModel.addAttribute("hisCertificete", hisCertificete);
uiModel.addAttribute("basicinfor", basicinfor);
uiModel.addAttribute("tclientTimestamp", tclientTimestamp);
uiModel.addAttribute("clientTimestamp", clientTimestamp);
uiModel.addAttribute("cilentsignature", cilentsignature);
uiModel.addAttribute("cilentsignat", cilentsignat);
uiModel.addAttribute("networkaddress", networkaddress);
uiModel.addAttribute("meventdesire", meventdesire);
uiModel.addAttribute("eventbehacior", eventbehacior);
uiModel.addAttribute("meventime", meventime);
uiModel.addAttribute("trustedidentit", trustedidentit);
uiModel.addAttribute("mevencontent", mevencontent);
uiModel.addAttribute("trustedidentity", trustedidentity);
uiModel.addAttribute("companiesSubmit", companiesSubmit);
uiModel.addAttribute("realnameRecor", realnameRecor);
uiModel.addAttribute("denceid", denceid);
uiModel.addAttribute("personalName", personalName);
uiModel.addAttribute("mainInfo", mlist);
uiModel.addAttribute("milist", mlist);
Map<Long, Integer> msize = new HashMap<Long, Integer>();
// 得到认证数量
for (EvidenceMainInformation m : mlist) {
int showsize = 0;
// 身份认证
if (companiesSubmit.get(m.getId()) != null) {
coutn++;
}
if (realnameRecor.get(m.getId()) != null) {
coutn++;
}
if (personalName.get(m.getId()) != null) {
coutn++;
}
if (desire.get(m.getId()) != null) {
coutn++;
}
if (trustedidentity.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
coutn++;
}
if (denceid.get(m.getId()) != null) {
coutn++;
}
// 事件认证
if (trustedidentit.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
size++;
showsize++;
}
if (meventime.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
size++;
showsize++;
}
if (eventbehacior.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
size++;
showsize++;
}
if (meventdesire.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
size++;
showsize++;
}
if (networkaddress.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
size++;
showsize++;
}
msize.put(m.getId(), showsize);
}
uiModel.addAttribute("cousize", cousize);
uiModel.addAttribute("rowsize", size + 1 + cousize);
uiModel.addAttribute("showsize", msize);
uiModel.addAttribute("rowcoutn", coutn);
uiModel.addAttribute("desire", desire);
// 得到事件的时间
Date time8 = new Date();
// 方法结束时间
log.error("******************time8=" + time8);
Long Ltime7 = time8.getTime() - time.getTime();
log.error("方法结束的毫秒数,Ltime7=" + Ltime7);
return "basicinformation/show";
}
use of com.itrus.portal.db.EvidenceOutServiceConfigExample in project portal by ixinportal.
the class HisCertificateController method show.
/**
* 查看详情
*
* @param id
* @param type
* @param uiModel
* @return
*/
@RequestMapping(value = "/{id}/{type}", produces = "text/html")
public String show(@PathVariable("id") Long id, @PathVariable("type") int type, Model uiModel) {
EvidenceHisCertificate hisCertificate = hiscertificate.selectById(id);
// 出征流水号
contractNumber = hisCertificate.getSerialnumber();
// 得到服务编码
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);
// 得到出证模板信息
EvidenceOutTemplate outtemp = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutTemplateMapper.selectByPrimaryKey", outService.getSaveRetTemplate());
uiModel.addAttribute("hisCertificate", hisCertificate);
uiModel.addAttribute("outtemp", outtemp);
// 获取证据附件表
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);
uiModel.addAttribute("envlosure", envlosure);
Map<Long, List<EvidenceMainInformation>> minfo = new HashMap<Long, List<EvidenceMainInformation>>();
// Map<Long, List<EvidenceBasicInformation>> mbasi = new HashMap<Long,
// List<EvidenceBasicInformation>>();
List<EvidenceBasicInformation> blists = new ArrayList<EvidenceBasicInformation>();
// 得到出证关联表信息
EvidenceHisRelationshipExample relation = new EvidenceHisRelationshipExample();
EvidenceHisRelationshipExample.Criteria hisreation = relation.createCriteria();
hisreation.andHisCertificateEqualTo(hisCertificate.getId());
List<EvidenceHisRelationship> hisRelation = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", relation);
for (int j = 0; j < hisRelation.size(); j++) {
List<EvidenceMainInformation> mlist = new ArrayList<EvidenceMainInformation>();
// 得到证据基本信息
EvidenceBasicInformation basic = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", hisRelation.get(j).getBasicInformation());
blists.add(basic);
// 得到证据身份主题关联信息
EvidenceSubjectIdentityExample subjectExample = new EvidenceSubjectIdentityExample();
EvidenceSubjectIdentityExample.Criteria identity = subjectExample.createCriteria();
identity.andBasicInformationEqualTo(basic.getEvidenceSn());
List<EvidenceSubjectIdentity> subjectIdentity = sqlSession.selectList("com.itrus.portal.db.EvidenceSubjectIdentityMapper.selectByExample", subjectExample);
for (int g = 0; g < subjectIdentity.size(); g++) {
// 得到主题身份信息
EvidenceMainInformation mainInfo = sqlSession.selectOne("com.itrus.portal.db.EvidenceMainInformationMapper.selectByPrimaryKey", subjectIdentity.get(g).getMainInformation());
mlist.add(mainInfo);
}
minfo.put(basic.getId(), mlist);
}
uiModel.addAttribute("mainInfo", minfo);
uiModel.addAttribute("blists", blists);
if (type == 1) {
// 待出证
return "hiscertificate/show";
} else if (type == 2) {
// 已出证
return "hiscertificate/show1";
}
return null;
}
use of com.itrus.portal.db.EvidenceOutServiceConfigExample 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