use of com.itrus.portal.db.AppService 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;
}
use of com.itrus.portal.db.AppService in project portal by ixinportal.
the class OutServiceConfigController method delete.
// 删除处理
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
EvidenceOutServiceConfig outServiceConfig = outServiceConfigService.selectById(id);
if (outServiceConfig == null) {
// uiModel.addAttribute("message", "未找到要删除的实名认证服务");
return "未找到要删除的存证服务";
}
AppService appService = appServiceImpl.selectById(outServiceConfig.getAppService());
int count = appServiceImpl.selectAppInfoConuntById(appService.getId());
if (count > 0) {
// uiModel.addAttribute("message", "此条服务与计费配置存在关联,不能删除");
return "此条服务与计费配置存在关联,不能删除";
}
try {
outServiceConfigService.deleteOutServiceConfig(appService.getId(), outServiceConfig.getId());
String oper = "删除出证服务";
String info = "出证服务名称: " + appService.getAppServiceName();
LogUtil.evidencelog(sqlSession, null, oper, info);
return null;
} catch (Exception e) {
// + "】存在关联,无法删除");
return "要删除应用【" + appService.getAppServiceName() + "】存在关联,无法删除";
}
}
use of com.itrus.portal.db.AppService in project portal by ixinportal.
the class SaveServiceController method delete.
// 删除处理
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
EvidenceSaveService saveService = saveServiceImpl.selectServiceById(id);
if (saveService == null) {
// uiModel.addAttribute("message", "未找到要删除的实名认证服务");
return "未找到要删除的存证服务";
}
AppService appService = appServiceImpl.selectById(saveService.getAppService());
int count = appServiceImpl.selectAppInfoConuntById(appService.getId());
if (count > 0) {
// uiModel.addAttribute("message", "此条服务与计费配置存在关联,不能删除");
return "此条服务与计费配置存在关联,不能删除";
}
try {
saveServiceImpl.deleteAppServiceAuthentication(appService.getId(), saveService.getId());
String oper = "删除存证服务";
String info = "存证服务名称: " + appService.getAppServiceName();
LogUtil.evidencelog(sqlSession, null, oper, info);
return null;
} catch (Exception e) {
// + "】存在关联,无法删除");
return "要删除应用【" + appService.getAppServiceName() + "】存在关联,无法删除";
}
}
use of com.itrus.portal.db.AppService in project portal by ixinportal.
the class SaveServiceController method create.
// 新建处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@ModelAttribute("evidenceSaveService") EvidenceSaveService evidenceSaveService, @ModelAttribute("appService") AppService appService, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
if (bindingResult.hasErrors()) {
AppServiceExample ase = new AppServiceExample();
AppServiceExample.Criteria asec = ase.createCriteria();
asec.andTypeEqualTo(3L);
asec.andServiceConfigNameEqualTo("EvidenceOutServiceConfig");
List<AppService> appServiceList = sqlSession.selectList("com.itrus.portal.db.AppServiceMapper.selectByExample", ase);
uiModel.addAttribute("appServiceList", appServiceList);
return "saveservice/create";
}
String factor = getFactorContent(evidenceSaveService);
evidenceSaveService.setFactorContent(factor);
if (evidenceSaveService.getEncryptionWay() == 0) {
evidenceSaveService.setEncryptionWay(null);
}
if (evidenceSaveService.getFixationWay() == 0) {
evidenceSaveService.setFixationWay(null);
}
if (evidenceSaveService.getSaveTime() == 0) {
evidenceSaveService.setSaveTime(null);
}
if (evidenceSaveService.getAppServiceName() == 0) {
evidenceSaveService.setAppServiceName(null);
}
saveServiceImpl.saveEvidenceSaveService(evidenceSaveService, appService, getAdmin().getId());
String oper = "添加存证服务配置";
String info = "存证服务配置名称: " + appService.getAppServiceName();
LogUtil.evidencelog(sqlSession, null, oper, info);
return "redirect:saveservice/" + evidenceSaveService.getId();
}
use of com.itrus.portal.db.AppService in project portal by ixinportal.
the class BasicInformationController method show1.
/**
* 查看详细内容(事件详细)
*
* @param id
* @param type
* @param uiModel
* @return
*/
@RequestMapping(value = "show1/{id}/{mid}/{type}", produces = "text/html")
public String show1(@PathVariable("id") Long id, @PathVariable("mid") Long mid, @PathVariable("type") int type, Model uiModel) {
/*
* if (type == 1) {// 身份意愿鉴别信息 EvidenceDesireIdentify desire =
* sqlSession .selectOne(
* "com.itrus.portal.db.EvidenceDesireIdentifyMapper.selectByPrimaryKey",
* id); EvidenceMainInformation mainInfo = sqlSession.selectOne(
* "com.itrus.portal.db.EvidenceMainInformationMapper.selectByPrimaryKey",
* desire.getMainInformation()); uiModel.addAttribute("desire", desire);
* uiModel.addAttribute("mainInfo", mainInfo); return
* "basicinformation/desireIdentify"; } else if (type == 2) {// 获取实名认证信息
* EvidenceCompaniesSubmit companiesSubmit = sqlSession .selectOne(
* "com.itrus.portal.db.EvidenceCompaniesSubmitMapper.selectByPrimaryKey",
* id); String cid = companiesSubmit.getId().toString(); int evid =
* Integer.parseInt(cid); EvidenceRealNameExample realnameE = new
* EvidenceRealNameExample(); EvidenceRealNameExample.Criteria
* realnameEx = realnameE.createCriteria();
* realnameEx.andCompaniesSubmitEqualTo(evid); EvidenceRealName
* erealname = sqlSession .selectOne(
* "com.itrus.portal.db.EvidenceRealNameMapper.selectByExample",
* realnameE); EvidenceMainInformation mainInfo = sqlSession.selectOne(
* "com.itrus.portal.db.EvidenceMainInformationMapper.selectByPrimaryKey",
* erealname.getMainInformation()); if
* (companiesSubmit.getRepresentative() != null) {// 法定代表人
* EvidenceRepresentative representative = sqlSession.selectOne(
* "com.itrus.portal.db.EvidenceRepresentativeMapper.selectByPrimaryKey",
* companiesSubmit.getRepresentative());
* uiModel.addAttribute("representative", representative); } if
* (companiesSubmit.getTheAgent() != null) {// 代理人 EvidenceTheAgent
* theagent = sqlSession.selectOne(
* "com.itrus.portal.db.EvidenceTheAgentMapper.selectByPrimaryKey",
* companiesSubmit.getTheAgent()); uiModel.addAttribute("theagent",
* theagent); } uiModel.addAttribute("erealname", erealname);
* uiModel.addAttribute("companiesSubmit", companiesSubmit);
* uiModel.addAttribute("mainInfo", mainInfo); return
* "basicinformation/companiesSubmit";
*
* } else
*/
if (type == 3) {
// 可信身份标识
// EvidenceTrustedIdentity trusted = sqlSession
// .selectOne("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByPrimaryKey", id);
// EvidenceMainInformation mainInfo = sqlSession.selectOne(
// "com.itrus.portal.db.EvidenceMainInformationMapper.selectByPrimaryKey",
// trusted.getMainInformation());
// uiModel.addAttribute("trusted", trusted);
// uiModel.addAttribute("mainInfo", mainInfo);
EvidenceTrustedIdentity trusted = sqlSession.selectOne("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByPrimaryKey", id);
String idCode = trusted.getMainInformation().split(";")[1];
String idName = trusted.getMainInformation().split(";")[0];
EvidenceMainInformationExample maininfor = new EvidenceMainInformationExample();
EvidenceMainInformationExample.Criteria mation = maininfor.createCriteria();
mation.andIdentificationEqualTo(idCode);
mation.andSubjectNameEqualTo(idName);
List<EvidenceMainInformation> mainInfo = sqlSession.selectList("com.itrus.portal.db.EvidenceMainInformationMapper.selectByExample", maininfor);
uiModel.addAttribute("trusted", trusted);
/*EvidenceCertExample basicEx = new EvidenceCertExample();
EvidenceCertExample.Criteria information = basicEx.createCriteria();
information.andCertSerialnumberEqualTo(trusted.getCertSerialnumber().trim());
EvidenceCert cert = sqlSession.selectOne("com.itrus.portal.db.EvidenceCertMapper.selectByExample", basicEx);
uiModel.addAttribute("cert", cert);
if(cert!=null && cert.getIssuerdn()!=null){
uiModel.addAttribute("Issuerdn", EvidenceSaveServiceApi.getCertCn(cert.getIssuerdn()));
}*/
uiModel.addAttribute("mainInfo", mainInfo.get(0));
return "basicinformation/trustedIdentity";
} else if (type == 4) {
// 事件内容
EvidenceEventContent mevencontent = sqlSession.selectOne("com.itrus.portal.db.EvidenceEventContentMapper.selectByPrimaryKey", id);
// 得到基本信息
/*EvidenceBasicInformation basicinfor = sqlSession
.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", mevencontent.getBasicInformation());*/
EvidenceBasicInformationExample basicEx = new EvidenceBasicInformationExample();
EvidenceBasicInformationExample.Criteria information = basicEx.createCriteria();
information.andEvidenceSnEqualTo(mevencontent.getEvidenceSn());
EvidenceBasicInformation basicinfor = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByExample", basicEx);
// 得到服务表信息
AppService appservice = appService.selectById(basicinfor.getAppService());
EvidenceSaveServiceExample save = new EvidenceSaveServiceExample();
EvidenceSaveServiceExample.Criteria saveEx = save.createCriteria();
saveEx.andAppServiceEqualTo(appservice.getId());
EvidenceSaveService evidenceSave = sqlSession.selectOne("com.itrus.portal.db.EvidenceSaveServiceMapper.selectByExample", save);
// String js = evidenceSave.getFactorBusinessInfo();
String evidenceType = null;
try {
JSONArray jsonArray = new JSONArray(evidenceSave.getFactorBusinessInfo());
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsob = JSONObject.parseObject(jsonArray.get(i).toString());
if ("业务类型".equals(jsob.getString("b_factor"))) {
evidenceType = jsob.getString("b_category");
}
}
if ("电子合同PDF".equals(evidenceType)) {
// 判断图片是否存在
if (mevencontent.getIsimg() == null) {
// EvidenceBasicInformation basic = sqlSession.selectOne(
// "com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey",
// mevencontent.getEvidenceSn());
// 得到证据附件表,用于获取信息
EvidenceEnclosureExample envlosureE = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria envlosureEx = envlosureE.createCriteria();
envlosureEx.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
envlosureEx.andPdfTypeEqualTo("1");
EvidenceEnclosure envlosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", envlosureE);
RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
if (realNameAuthentication == null) {
try {
realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String pdfbase64 = null;
String urlAgent = realNameAuthentication.getRealNameddress();
if (envlosure != null && envlosure.getBuid() != null) {
log.error("Buid======" + envlosure.getBuid());
pdfbase64 = EvidenceSaveServiceApi.decryptedAndDownload(sqlSession, envlosure.getBuid(), urlAgent);
}
if (pdfbase64 != null) {
log.error("*******pdfbase64不为空*********");
// 得到证据包的json
JSONObject jsonEvidenceContent = JSONObject.parseObject(pdfbase64);
String authEvent = jsonEvidenceContent.getString("authEvent");
JSONObject authEvent1 = JSONObject.parseObject(authEvent);
String jsonpdf = authEvent1.getString("eventContent");
JSONObject jsonpdf1 = JSONObject.parseObject(jsonpdf);
// 得到pdf的base64编码
String jsonbase64 = jsonpdf1.getString("contCode");
BufferedInputStream bin = null;
FileOutputStream fout = null;
BufferedOutputStream bout = null;
try {
BASE64Decoder decoder = new sun.misc.BASE64Decoder();
// 将base64编码的字符串解码成字节数组
byte[] bytes = decoder.decodeBuffer(jsonbase64);
// apache公司的API
// byte[] bytes = Base64.decodeBase64(base64sString);
// 创建一个将bytes作为其缓冲区的ByteArrayInputStream对象
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
// 创建从底层输入流中读取数据的缓冲输入流对象
bin = new BufferedInputStream(bais);
// 指定输出的文件
log.error("路径地址=" + systemConfigService.getpdfurl() + File.separator + envlosure.getBucketName() + File.separator + envlosure.getEvidenceSn() + ".pdf");
File file = new File(systemConfigService.getpdfurl() + File.separator + envlosure.getBucketName() + File.separator + envlosure.getEvidenceSn() + ".pdf");
// 创建到指定文件的输出流
fout = new FileOutputStream(file);
// 为文件输出流对接缓冲输出流对象
bout = new BufferedOutputStream(fout);
byte[] buffers = new byte[1024];
int len = bin.read(buffers);
while (len != -1) {
bout.write(buffers, 0, len);
len = bin.read(buffers);
}
// 刷新此输出流并强制写出所有缓冲的输出字节,必须这行代码,否则有可能有问题
bout.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bin != null) {
bin.close();
}
if (fout != null) {
fout.close();
}
if (bout != null) {
bout.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
// 判断是否为用户上传pdf
if (envlosure != null) {
String urlFile = systemConfigService.getpdfurl() + File.separator + envlosure.getBucketName();
File filePathStr = new File(urlFile, envlosure.getEvidenceSn() + ".pdf");
log.error("***********filePathStr=" + filePathStr.getPath());
int pdfToPng = 0;
if (filePathStr != null && filePathStr.getPath() != null) {
try {
pdfToPng = Pdf.pdf2png(filePathStr.getPath());
} catch (Exception e) {
e.printStackTrace();
}
}
log.error("是否生成,数量****pdfToPng=" + pdfToPng);
// 判断生成图片是否成功
if (pdfToPng > 0) {
// 修改内容表信息,表示生成图片
mevencontent.setIsimg(1);
mevencontent.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("selectType", 1);
} else if ("合同摘要数据".equals(evidenceType)) {
uiModel.addAttribute("selectType", 2);
} else if ("图片摘要数据".equals(evidenceType)) {
uiModel.addAttribute("selectType", 3);
} else if ("信息摘要数据".equals(evidenceType)) {
uiModel.addAttribute("selectType", 4);
}
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
uiModel.addAttribute("mevencontent", mevencontent);
return "basicinformation/evenconrent";
} else if (type == 5) {
// 事件详细
EvidenceEventContent mevencontent = sqlSession.selectOne("com.itrus.portal.db.EvidenceEventContentMapper.selectByPrimaryKey", id);
// EvidenceBasicInformation basicInformation = basicInformationimpl.selectById(mevencontent.getEvidenceSn());
EvidenceBasicInformationExample basicEx = new EvidenceBasicInformationExample();
EvidenceBasicInformationExample.Criteria information = basicEx.createCriteria();
information.andEvidenceSnEqualTo(mevencontent.getEvidenceSn());
EvidenceBasicInformation basicInformation = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByExample", basicEx);
EvidenceMainInformation mainInfo = new EvidenceMainInformation();
// 事件对象
EvidenceTrustedIdentityExample trustenid = new EvidenceTrustedIdentityExample();
EvidenceTrustedIdentityExample.Criteria identitye = trustenid.createCriteria();
// identitye.andBasicInformationEqualTo(mevencontent.getEvidenceSn());// 获取事件对象
identitye.andEventContentEqualTo(mevencontent.getIdCode());
// identitye.andMainInformationEqualTo(mid);
EvidenceTrustedIdentity trusted = sqlSession.selectOne("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trustenid);
if (trusted != null) {
String mainName = trusted.getMainInformation().split(";")[0];
String mainIdentity = trusted.getMainInformation().split(";")[1];
// 证据主体信息
EvidenceMainInformationExample infomationE = new EvidenceMainInformationExample();
EvidenceMainInformationExample.Criteria tionE = infomationE.createCriteria();
tionE.andIdentificationEqualTo(mainIdentity);
if (mainName != null) {
tionE.andSubjectNameEqualTo(mainName);
}
List<EvidenceMainInformation> ainInfo = sqlSession.selectList("com.itrus.portal.db.EvidenceMainInformationMapper.selectByExample", infomationE);
mainInfo = ainInfo.get(0);
/*mainInfo = sqlSession.selectOne("com.itrus.portal.db.EvidenceMainInformationMapper.selectByPrimaryKey",
trusted.getMainInformation());*/
}
// 事件行为
EvidenceEventBehaviorExample eventbehaciorEx = new EvidenceEventBehaviorExample();
EvidenceEventBehaviorExample.Criteria eventbe = eventbehaciorEx.createCriteria();
eventbe.andEventContentEqualTo(mevencontent.getIdCode());
// eventbe.andMainInformationEqualTo(mid);
List<EvidenceEventBehavior> elist = sqlSession.selectList("com.itrus.portal.db.EvidenceEventBehaviorMapper.selectByExample", eventbehaciorEx);
// 事件时间
EvidenceEventTimeExample eventime = new EvidenceEventTimeExample();
EvidenceEventTimeExample.Criteria eventimeEx = eventime.createCriteria();
eventimeEx.andEventContentEqualTo(mevencontent.getIdCode());
// eventimeEx.andMainInformationEqualTo(mid);
List<EvidenceEventTime> meventime = sqlSession.selectList("com.itrus.portal.db.EvidenceEventTimeMapper.selectByExample", eventime);
// 事件意愿
EvidenceEventDesireExample desireEx = new EvidenceEventDesireExample();
EvidenceEventDesireExample.Criteria eventdesire = desireEx.createCriteria();
eventdesire.andEventContenteEqualTo(mevencontent.getIdCode());
// eventdesire.andMainInformationEqualTo(mid);
EvidenceEventDesire meventdesire = sqlSession.selectOne("com.itrus.portal.db.EvidenceEventDesireMapper.selectByExample", desireEx);
// 事件网络地址
EvidenceEventNetworkAddressExample network = new EvidenceEventNetworkAddressExample();
EvidenceEventNetworkAddressExample.Criteria address = network.createCriteria();
address.andEventContentEqualTo(mevencontent.getIdCode());
// address.andMainInformationEqualTo(mid);
EvidenceEventNetworkAddress networkaddress = sqlSession.selectOne("com.itrus.portal.db.EvidenceEventNetworkAddressMapper.selectByExample", network);
uiModel.addAttribute("mevencontent", mevencontent);
uiModel.addAttribute("meventdesire", meventdesire);
uiModel.addAttribute("networkaddress", networkaddress);
uiModel.addAttribute("basicInformation", basicInformation);
uiModel.addAttribute("trusted", trusted);
uiModel.addAttribute("mainInfo", mainInfo);
uiModel.addAttribute("elist", elist);
uiModel.addAttribute("meventime", meventime);
return "basicinformation/certificationdetails";
} else if (type == 6) {
// 服务委托人签名信息
EvidenceClientSignature cliensig = sqlSession.selectOne("com.itrus.portal.db.EvidenceClientSignatureMapper.selectByPrimaryKey", id);
EvidenceEnclosureExample enclo = new EvidenceEnclosureExample();
EvidenceEnclosureExample.Criteria enclosureEx = enclo.createCriteria();
enclosureEx.andEvidenceSnEqualTo(cliensig.getEvidenceSn());
enclosureEx.andPdfTypeEqualTo("1");
EvidenceEnclosure enclosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclo);
// 天威签名信息
EvidenceClientSignatureExample cilentsign = new EvidenceClientSignatureExample();
EvidenceClientSignatureExample.Criteria signature = cilentsign.createCriteria();
signature.andEvidenceSnEqualTo(enclosure.getEvidenceSn());
signature.andNameEqualTo("1");
EvidenceClientSignature cilentsignature = sqlSession.selectOne("com.itrus.portal.db.EvidenceClientSignatureMapper.selectByExample", cilentsign);
EvidenceCert oneCert = new EvidenceCert();
EvidenceCheck oneCheck = new EvidenceCheck();
if (cilentsignature != null) {
// 天威证书信息
/*EvidenceCertExample certE = new EvidenceCertExample();
EvidenceCertExample.Criteria evidenceCertE = certE.createCriteria();
evidenceCertE.andClientSignatureEqualTo(cilentsignature.getId());
oneCert = sqlSession.selectOne("com.itrus.portal.db.EvidenceCertMapper.selectByExample",certE);*/
oneCert = sqlSession.selectOne("com.itrus.portal.db.EvidenceCertMapper.selectByPrimaryKey", cilentsignature.getCertId());
// 天威核验信息
EvidenceCheckExample checkE = new EvidenceCheckExample();
EvidenceCheckExample.Criteria evidenceCheckE = checkE.createCriteria();
evidenceCheckE.andClientSignatureEqualTo(cilentsignature.getId());
oneCheck = sqlSession.selectOne("com.itrus.portal.db.EvidenceCheckMapper.selectByExample", checkE);
}
// 服务委托人时间戳信息
EvidenceClientTimeStampExample clientTime = new EvidenceClientTimeStampExample();
EvidenceClientTimeStampExample.Criteria stamp = clientTime.createCriteria();
stamp.andEvidenceSnEqualTo(enclosure.getEvidenceSn());
stamp.andNameEqualTo("0");
EvidenceClientTimeStamp clientTimestamp = sqlSession.selectOne("com.itrus.portal.db.EvidenceClientTimeStampMapper.selectByExample", clientTime);
// 天威时间戳信息
EvidenceClientTimeStampExample tclientTime = new EvidenceClientTimeStampExample();
EvidenceClientTimeStampExample.Criteria tstamp = tclientTime.createCriteria();
tstamp.andEvidenceSnEqualTo(enclosure.getEvidenceSn());
tstamp.andNameEqualTo("1");
EvidenceClientTimeStamp tclientTimestamp = sqlSession.selectOne("com.itrus.portal.db.EvidenceClientTimeStampMapper.selectByExample", tclientTime);
// 服务委托人证书信息
/*EvidenceCertExample certEx = new EvidenceCertExample();
EvidenceCertExample.Criteria evidenceCert = certEx.createCriteria();
evidenceCert.andClientSignatureEqualTo(cliensig.getId());
List<EvidenceCert> listCert = sqlSession
.selectList("com.itrus.portal.db.EvidenceCertMapper.selectByExample", certEx);*/
List<EvidenceCert> listCert = sqlSession.selectList("com.itrus.portal.db.EvidenceCertMapper.selectByPrimaryKey", cliensig.getCertId());
// 服务委托人核验信息
EvidenceCheckExample checkEx = new EvidenceCheckExample();
EvidenceCheckExample.Criteria evidenceCheck = checkEx.createCriteria();
evidenceCheck.andClientSignatureEqualTo(cliensig.getId());
EvidenceCheck listCheck = sqlSession.selectOne("com.itrus.portal.db.EvidenceCheckMapper.selectByExample", checkEx);
Map<Long, EvidenceCheck> mapCheck = new HashMap<Long, EvidenceCheck>();
// 服务委托人证书核验信息
for (EvidenceCert c : listCert) {
EvidenceCheckExample certcheckEx = new EvidenceCheckExample();
EvidenceCheckExample.Criteria certCheck = certcheckEx.createCriteria();
certCheck.andEvidenceCertEqualTo(c.getId());
EvidenceCheck listCertCheck = sqlSession.selectOne("com.itrus.portal.db.EvidenceCheckMapper.selectByExample", certcheckEx);
mapCheck.put(c.getId(), listCertCheck);
}
// 服务委托人证书信息
uiModel.addAttribute("listCert", listCert);
// 服务委托人核验信息
uiModel.addAttribute("listCheck", listCheck);
// 天威证书信息
uiModel.addAttribute("oneCert", oneCert);
// 天威核验信息
uiModel.addAttribute("oneCheck", oneCheck);
// 服务委托人证书核验信息
uiModel.addAttribute("mapCheck", mapCheck);
// 服务委托人签名信息
uiModel.addAttribute("cliensig", cliensig);
// 天威签名信息
uiModel.addAttribute("cilentsignature", cilentsignature);
// 服务委托人时间戳信息
uiModel.addAttribute("clientTimestamp", clientTimestamp);
// 天威时间戳信息
uiModel.addAttribute("tclientTimestamp", tclientTimestamp);
return "basicinformation/evidenceexists";
}
/*
* else if (type == 7) { EvidenceIndividual indiv = sqlSession
* .selectOne(
* "com.itrus.portal.db.EvidenceIndividualMapper.selectByPrimaryKey",
* id); String cid = indiv.getId().toString(); int evid =
* Integer.parseInt(cid); EvidenceRealNameExample realnameE = new
* EvidenceRealNameExample(); EvidenceRealNameExample.Criteria
* realnameEx = realnameE.createCriteria();
* realnameEx.andIndividualEqualTo(evid); EvidenceRealName erealname
* = sqlSession .selectOne(
* "com.itrus.portal.db.EvidenceRealNameMapper.selectByExample",
* realnameE); EvidenceMainInformation mainInfo =
* sqlSession.selectOne(
* "com.itrus.portal.db.EvidenceMainInformationMapper.selectByPrimaryKey",
* erealname.getMainInformation()); uiModel.addAttribute("indiv",
* indiv); uiModel.addAttribute("mainInfo", mainInfo); return
* "basicinformation/ineividual"; }
*/
return null;
}
Aggregations