use of com.itrus.portal.db.EvidenceSaveService in project portal by ixinportal.
the class EvidenceSaveServiceApi method saveContract.
/**
* 存证接口 (合同原文)
* @param signature
* 签名值
* @param request
* @return
*/
@RequestMapping("/saveContract")
@ResponseBody
public Map<String, Object> saveContract(@RequestHeader("Content-Signature") String signature, @RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "serviceCode", required = false) String serviceCode, @RequestParam(value = "evidenceSn", required = false) String evidenceSn, @RequestParam(value = "hashAlg", required = false) String hashAlg, @RequestParam(value = "signedBase64", required = false) String signedBase64, @RequestParam(value = "evidencePackage", required = false) String evidencePackage, HttpServletRequest request) {
// 返回值
Map<String, Object> result = new HashMap<String, Object>();
result.put("status", 1);
Long startTime = System.currentTimeMillis();
// 申请时间
Date date = new Date();
// 验证参数是否完整
if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(serviceCode) || StringUtils.isEmpty(evidencePackage) || StringUtils.isEmpty(hashAlg) || StringUtils.isEmpty(signedBase64)) {
result.put("status", 0);
result.put("message", "提交的参数信息不完整");
return result;
}
if (StringUtils.isNotEmpty(evidenceSn)) {
evidenceSn = null;
}
// 获取对应应用信息
ApplicationInfo applicationInfo = applicationInfoService.getApplicationInfo(appId);
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 + serviceCode + evidenceSn + hashAlg + signedBase64 + evidencePackage, 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;
}
// 获取对应应用信息
EvidenceSaveService evidenceSaveService = null;
AppService appService = appServiceExt.getAppService(serviceCode);
if (appService != null && "EvidenceSaveService".equals(appService.getServiceConfigName())) {
evidenceSaveService = saveServiceImpl.selectById(appService.getServiceConfigId());
} else {
result.put("status", -21);
result.put("message", "应用服务不存在");
return result;
}
if (evidenceSaveService == null) {
result.put("status", -21);
result.put("message", "应用服务不存在");
return result;
}
if (appService.getIsAppServiceStatus() == 0) {
result.put("status", -22);
result.put("message", "服务已关闭");
return result;
}
// 获取存证回执模版
if (evidenceSaveService.getAppServiceName() != null) {
AppService appServiceOut = appServiceExt.selectById(evidenceSaveService.getAppServiceName());
if (appServiceOut == null) {
result.put("status", -22);
result.put("message", "回执模版不存在");
return result;
}
}
if (StringUtils.isNotEmpty(evidenceSn)) {
EvidenceBasicInformation basicInformation = basicInformationService.getInformationBySn(evidenceSn, 1);
if (basicInformation != null) {
result.put("status", 0);
result.put("message", "该证据不可补交");
return result;
}
}
log.error("verifyConfig time is [" + (System.currentTimeMillis() - startTime) + "]");
RealNameAuthentication realNameAuthentication = null;
RealNameAuthentication realNameAuthenticationTime = null;
RealNameAuthentication realNameAuthenticationOss = null;
try {
Long getConfigTime = System.currentTimeMillis();
// 获取原子服务地址 1.实名认证 2.密码服务 3.时间戳 4.OSS
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;
}
// 获取原子服务地址 1.实名认证 2.密码服务 3.时间戳 4.OSS
realNameAuthenticationTime = CacheCustomer.getAUTH_CONFIG_MAP().get(3);
if (realNameAuthenticationTime == null) {
realNameAuthenticationTime = realNameAuthenticationSerivce.getRealNameAuthenticationByThree();
}
if (realNameAuthenticationTime == null) {
result.put("status", -6);
result.put("message", "缺少时间戳服务配置,请联系管理员");
return result;
}
// 获取原子服务地址 1.实名认证 2.密码服务 3.时间戳 4.OSS
realNameAuthenticationOss = CacheCustomer.getAUTH_CONFIG_MAP().get(4);
if (realNameAuthenticationOss == null) {
realNameAuthenticationOss = realNameAuthenticationSerivce.getRealNameAuthenticationByOss();
}
if (realNameAuthenticationOss == null) {
result.put("status", -6);
result.put("message", "缺少OSS配置,请联系管理员");
return result;
}
// 本次证据包大小
int fileSize = evidencePackage.getBytes("utf-8").length;
log.error("getConfig time is [" + (System.currentTimeMillis() - getConfigTime) + "]");
// 存证计费校验接口
Map<String, Object> mapCharging = storeChargingService.checkStoreCharging(StringUtils.isBlank(evidenceSn), applicationInfo, appService, evidenceSaveService.getBaseSpace(), getSize(fileSize));
if ((int) mapCharging.get("retCode") == 0) {
// result.put("status", -4);
if (mapCharging.get("retMsg") != null)
result.put("message", mapCharging.get("retMsg"));
else
result.put("message", "服务计费失败");
// return result;
}
// 证据包申请
String hashvalue = HMACSHA1.getDigest(hashAlg, evidencePackage);
// 1.验签之后返回
long verifySignTime = System.currentTimeMillis();
List<String> certs = verifySign(result, applicationInfo, evidenceSaveService, hashvalue, signedBase64, realNameAuthentication, 1);
log.error("verifySignTime time is [" + (System.currentTimeMillis() - verifySignTime) + "]");
Date dateVp = (Date) result.get("dateVp");
Date dateVc = (Date) result.get("dateVc");
result.remove("dateVp");
result.remove("dateVc");
if (null != certs) {
String genSn = null;
if (StringUtils.isEmpty(evidenceSn)) {
// 生成证据编码
genSn = UniqueIDUtils.genAppServiceUID(applicationInfo, appService.getAppServiceName(), sqlSession, 3);
}
// 存证处理核心方法
long saveBodyTime = System.currentTimeMillis();
result = saveContractService.saveBody(result, applicationInfo, appService, evidenceSaveService, date, evidenceSn, genSn, signedBase64, evidencePackage, hashAlg, hashvalue, dateVp, dateVc, certs, realNameAuthentication, realNameAuthenticationTime, realNameAuthenticationOss, mapCharging);
log.error("saveBodyTime time is [" + (System.currentTimeMillis() - saveBodyTime) + "]");
if ((int) result.get("status") == 1) {
result.put("message", "申请存证成功,请稍后通过查询存证接口查看存证结果!");
if (StringUtils.isNotEmpty(evidenceSn))
result.put("evidenceSn", evidenceSn);
else
result.put("evidenceSn", genSn);
}
} else {
result.put("status", -8);
result.put("message", "验证证书失败");
}
log.error("saveContract time is " + (System.currentTimeMillis() - startTime));
return result;
} catch (Exception e) {
e.printStackTrace();
if (e instanceof IllegalStateException) {
result.put("status", -100);
result.put("message", "当前系统忙,请稍后再尝试!");
return result;
}
StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length - 2];
String info = stackTraceElement.getClassName() + stackTraceElement.getLineNumber() + e.toString();
LogUtil.evidencelog(sqlSession, null, "存证接口", "申请存证失败,失败原因:" + info);
result = new HashMap<String, Object>();
result.put("status", -5);
result.put("message", "系统服务错误,请联系管理员");
return result;
} finally {
if (realNameAuthentication != null) {
realNameAuthentication = null;
}
if (realNameAuthenticationOss != null) {
realNameAuthenticationOss = null;
}
if (realNameAuthenticationTime != null) {
realNameAuthenticationTime = null;
}
}
}
use of com.itrus.portal.db.EvidenceSaveService in project portal by ixinportal.
the class EvidenceSaveServiceApi method save.
// @Autowired
// private ProducerService producerService;
// 回执报告缓存Map key:证据编号 value:回执base64
// public static ConcurrentHashMap<String, String> cacheReportBySnMap = new ConcurrentHashMap<>();
/**
* 存证接口
* @param signature
* 签名值
* @param appId
* 应用id
* @param serviceCode
* 服务编号
* @param evidenceSn
* 证据编号
* @param signedBase64
* 签名值base64
* @param evidencePackage
* 证据包
* @param request
* @return
*/
@RequestMapping("/save")
@ResponseBody
public Map<String, Object> save(@RequestHeader("Content-Signature") String signature, @RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "serviceCode", required = false) String serviceCode, @RequestParam(value = "evidenceSn", required = false) String evidenceSn, @RequestParam(value = "hashAlg", required = false) String hashAlg, @RequestParam(value = "signedBase64", required = false) String signedBase64, @RequestParam(value = "evidencePackage", required = false) String evidencePackage, HttpServletRequest request) {
// 返回值
Map<String, Object> result = new HashMap<String, Object>();
result.put("status", 1);
// 申请时间
Date date = new Date();
// 验证参数是否完整
if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(serviceCode) || StringUtils.isEmpty(evidencePackage) || StringUtils.isEmpty(hashAlg) || StringUtils.isEmpty(signedBase64)) {
result.put("status", 0);
result.put("message", "提交的参数信息不完整");
return result;
}
// 获取对应应用信息
ApplicationInfo applicationInfo = applicationInfoService.getApplicationInfo(appId);
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 + serviceCode + evidenceSn + hashAlg + signedBase64 + evidencePackage, 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;
}
// 获取对应应用信息
EvidenceSaveService evidenceSaveService = null;
AppService appService = appServiceExt.getAppService(serviceCode);
if (appService != null && "EvidenceSaveService".equals(appService.getServiceConfigName())) {
evidenceSaveService = saveServiceImpl.selectById(appService.getServiceConfigId());
} else {
result.put("status", -21);
result.put("message", "应用服务不存在");
return result;
}
if (evidenceSaveService == null) {
result.put("status", -21);
result.put("message", "应用服务不存在");
return result;
}
if (appService.getIsAppServiceStatus() == 0) {
result.put("status", -22);
result.put("message", "服务已关闭");
return result;
}
// 获取存证回执模版
if (evidenceSaveService.getAppServiceName() != null) {
AppService appServiceOut = CacheCustomer.APP_SERVICE_MAP_BY_ID().get(evidenceSaveService.getAppServiceName());
if (appServiceOut == null) {
appServiceOut = appServiceExt.selectById(evidenceSaveService.getAppServiceName());
if (appServiceOut == null) {
result.put("status", -22);
result.put("message", "回执模版不存在");
return result;
}
}
}
if (StringUtils.isNotEmpty(evidenceSn)) {
EvidenceBasicInformation basicInformation = basicInformationService.getInformationBySn(evidenceSn, 1);
if (basicInformation != null) {
result.put("status", 0);
result.put("message", "该证据不可补交");
return result;
}
}
RealNameAuthentication realNameAuthentication = null;
RealNameAuthentication realNameAuthenticationTime = null;
RealNameAuthentication realNameAuthenticationOss = null;
try {
// 获取原子服务地址 1.实名认证 2.密码服务 3.时间戳 4.OSS
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;
}
// 获取原子服务地址 1.实名认证 2.密码服务 3.时间戳 4.OSS
realNameAuthenticationTime = CacheCustomer.getAUTH_CONFIG_MAP().get(3);
if (realNameAuthenticationTime == null) {
realNameAuthenticationTime = realNameAuthenticationSerivce.getRealNameAuthenticationByThree();
}
if (realNameAuthenticationTime == null) {
result.put("status", -6);
result.put("message", "缺少时间戳服务配置,请联系管理员");
return result;
}
// 获取原子服务地址 1.实名认证 2.密码服务 3.时间戳 4.OSS
realNameAuthenticationOss = CacheCustomer.getAUTH_CONFIG_MAP().get(4);
if (realNameAuthenticationOss == null) {
realNameAuthenticationOss = realNameAuthenticationSerivce.getRealNameAuthenticationByOss();
}
if (realNameAuthenticationOss == null) {
result.put("status", -6);
result.put("message", "缺少OSS配置,请联系管理员");
return result;
}
// 本次证据包大小
int fileSize = evidencePackage.getBytes("utf-8").length;
// 存证计费校验接口
Map<String, Object> mapCharging = storeChargingService.checkStoreCharging(StringUtils.isBlank(evidenceSn), applicationInfo, appService, evidenceSaveService.getBaseSpace(), getSize(fileSize));
// log.debug("存证计费校验 mapCharging__ : " + mapCharging);
if ((int) mapCharging.get("retCode") == 0) {
result.put("status", -4);
if (mapCharging.get("retMsg") != null)
result.put("message", mapCharging.get("retMsg"));
else
result.put("message", "服务计费失败");
return result;
}
// 证据包申请
String hashvalue = HMACSHA1.getDigest(hashAlg, evidencePackage);
// 1.验签之后返回
List<String> certs = verifySign(result, applicationInfo, evidenceSaveService, hashvalue, signedBase64, realNameAuthentication);
Date dateVp = (Date) result.get("dateVp");
Date dateVc = (Date) result.get("dateVc");
result.remove("dateVp");
result.remove("dateVc");
if (null != certs) {
String genSn = null;
if (StringUtils.isEmpty(evidenceSn)) {
genSn = UniqueIDUtils.genAppServiceUID(applicationInfo, appService.getAppServiceName(), sqlSession, 3);
}
result = saveTask.saveBody(result, applicationInfo, appService, evidenceSaveService, date, evidenceSn, genSn, signedBase64, evidencePackage, hashAlg, hashvalue, dateVp, dateVc, certs, realNameAuthentication, realNameAuthenticationTime, realNameAuthenticationOss, mapCharging);
if ((int) result.get("status") == 1) {
result.put("message", "申请存证成功,请稍后通过查询存证接口查看存证结果!");
if (StringUtils.isNotEmpty(evidenceSn))
result.put("evidenceSn", evidenceSn);
else
result.put("evidenceSn", genSn);
}
} else {
result.put("status", -8);
result.put("message", "验证证书失败");
}
return result;
} catch (Exception e) {
e.printStackTrace();
if (e instanceof IllegalStateException) {
result.put("status", -100);
result.put("message", "当前系统忙,请稍后再尝试!");
return result;
}
StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length - 2];
String info = stackTraceElement.getClassName() + stackTraceElement.getLineNumber() + e.toString();
LogUtil.evidencelog(sqlSession, null, "存证接口", "申请存证失败,失败原因:" + info);
result = new HashMap<String, Object>();
result.put("status", -5);
result.put("message", "系统服务错误,请联系管理员");
return result;
} finally {
if (realNameAuthentication != null) {
realNameAuthentication = null;
}
if (realNameAuthenticationOss != null) {
realNameAuthenticationOss = null;
}
if (realNameAuthenticationTime != null) {
realNameAuthenticationTime = null;
}
}
}
use of com.itrus.portal.db.EvidenceSaveService 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.EvidenceSaveService 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;
}
use of com.itrus.portal.db.EvidenceSaveService in project portal by ixinportal.
the class SaveServiceImpl method getEvidenceSaveServiceMap.
public Map<Long, EvidenceSaveService> getEvidenceSaveServiceMap() {
Map<Long, EvidenceSaveService> map = new HashMap<>();
List<EvidenceSaveService> saveServices = sqlSession.selectList("com.itrus.portal.db.EvidenceSaveServiceMapper.selectByExample", new EvidenceSaveServiceExample());
for (EvidenceSaveService saveService : saveServices) {
map.put(saveService.getId(), saveService);
}
return map;
}
Aggregations