use of sun.misc.BASE64Decoder 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 sun.misc.BASE64Decoder in project portal by ixinportal.
the class InvoiceTask method execute.
/**
* 开票推送
*/
public void execute() {
if (!isRun()) {
return;
}
// 获取配置信息
List<ReceiptConfig> list = sqlSession.selectList("com.itrus.portal.db.ReceiptConfigMapper.selectByExample", new ReceiptConfigExample());
ReceiptConfig rc = list.get(0);
// ReceiptConfig rc = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByExample");
if (null == rc || rc.getSend() != 1 || null == rc.getSpan()) {
// 未配置信息、未开启、未配置时间间隔
log.debug("未配置信息、未开启、未配置时间间隔");
return;
}
// 上次时间为空,或者上次时间大于当前时间,则重新设置上次时间为当前时间的毫秒数
if (null == rc.getCreateTime() || rc.getCreateTime().getTime() > System.currentTimeMillis()) {
rc.setCreateTime(new Date());
sqlSession.update("com.itrus.portal.db.ReceiptConfigMapper.updateByPrimaryKeySelective", rc);
}
// 判断是否在时间间隔内(当前时间小于 上次时间加上时间间隔)
if (System.currentTimeMillis() < rc.getCreateTime().getTime() + (Integer.parseInt(rc.getSpan()) * 1000)) {
log.debug("不在时间内");
return;
}
rc.setCreateTime(new Date());
sqlSession.update("com.itrus.portal.db.ReceiptConfigMapper.updateByPrimaryKeySelective", rc);
log.debug("任务开始");
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus ts = null;
try {
/**
* 进入test.cer所在目录,执行如下操作(注意配置环境变量),生成testclient.truststore文件:
* keytool -import -file test.cer -storepass 123456 -keystore testclient.truststore
* keytool -import -file fapiao_ceshi.cer -storepass ixin21060921 -keystore fapiao.truststore
* 然后输入“y”,回车
* 命令说明:
* keytool JDK提供的证书生成工具,所有参数的用法参见keytool –help
* -import 执行导入
* -file test.cer 要导入的证书,即从ie上导出的证书
* -storepass 123456 证书的存取密码
* -keystore testclient.truststore 保存路径及文件名
*/
// SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", SystemConfigService.TRUST_IMG);
// 执行命令后,会生成该testclient.truststore
String ssl_store = getClass().getClassLoader().getResource("").getPath() + File.separator + "fapiao.truststore";
// 证书的存取密码,即执行命令时填写的密码
String ssl_pwd = "ixin21060921";
System.setProperty("javax.net.ssl.trustStore", ssl_store);
System.setProperty("javax.net.ssl.keyStorePassword", ssl_pwd);
// String url = "https://218.17.158.39:8999/fpt_dsqz/services/DZFPService?wsdl";
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hv);
/*xml = "<?xml version='1.0' encoding='UTF-8' ?><interface xmlns=\"\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:schemaLocation=\"http://www.chinatax.gov.cn/tirip/dataspec/interfaces.xsd\" version=\"WLFP1.0\"> <globalInfo><appId>DZFP</appId><interfaceId></interfaceId><interfaceCode>DFXJ1001</interfaceCode><requestCode>DS</requestCode><requestTime>2015-12-28 10:05:17</requestTime><responseCode>DZFPQZ</responseCode><dataExchangeId>DZFPQZDFXJ10012015-12-28139070229</dataExchangeId></globalInfo><returnStateInfo><returnCode></returnCode><returnMessage>MDAwMA=="
+"</returnMessage></returnStateInfo><Data><dataDescription><zipCode>0</zipCode><encryptCode>1</encryptCode><codeType /></dataDescription><content>PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxSRVFVRVNUX0NPTU1PTl9GUEtKIGNsYXNzPSJSRVFVRVNU"
+"X0NPTU1PTl9GUEtKIiB4bWxuczpuczI9Imh0dHA6Ly9kc3F6amsuZHpmcHF6IiB4bWxucz0iaHR0"
+"cDovL3d3dy5mZWluaXUuY29tL2R6ZnAiPgogICAgPEZQUVFMU0g+MjAxNTEyMjgxNTAxMjI8L0ZQ"
+"UVFMU0g+CiAgICA8S1BMWD4wPC9LUExYPgogICAgPFhTRl9OU1JTQkg+NDQwMzAwNTY4NTE5NzM3"
+"PC9YU0ZfTlNSU0JIPgogICAgPFhTRl9NQz7nlLXlrZDlj5HnpajmtYvor5U8L1hTRl9NQz4KICAg"
+"IDxYU0ZfRFpESD7ljZflsbHljLrom4flj6PjgIE4MzQ4NDk0OTwvWFNGX0RaREg+CiAgICA8WFNG"
+"X1lIWkg+NDQwMzAwNTY4NTE5NzM3PC9YU0ZfWUhaSD4KICAgIDxHTUZfTlNSU0JIPjwvR01GX05T"
+"UlNCSD4KICAgIDxHTUZfTUM+5byg5LiJPC9HTUZfTUM+CiAgICA8R01GX0RaREg+PC9HTUZfRFpE"
+"SD4KICAgIDxHTUZfWUhaSD48L0dNRl9ZSFpIPgogICAgPEdNRl9TSkg+MTU5MjAwNjYzNDUsMTg5"
+"NjQ3ODc4NzY8L0dNRl9TSkg+CiAgICA8R01GX0RaWVg+ZmVuZ2Zhbl95YW5AMTM5LmNvbTwvR01G"
+"X0RaWVg+CiAgICA8RlBUX1pIPjwvRlBUX1pIPgogICAgPEtQUj7lsI/mmI48L0tQUj4KICAgIDxT"
+"S1I+5p2O5ZubPC9TS1I+CiAgICA8RkhSPuWwj+eOizwvRkhSPgogICAgPFlGUF9ETT48L1lGUF9E"
+"TT4KICAgIDxZRlBfSE0+PC9ZRlBfSE0+CiAgICA8SlNISj4xMTc8L0pTSEo+CiAgICA8SEpKRT4x"
+"MDA8L0hKSkU+CiAgICA8SEpTRT4xNzwvSEpTRT4KICAgIDxCWj7lpIfms6g8L0JaPgogICAgPEhZ"
+"TFg+MDwvSFlMWD4KICAgIDxCWTE+PC9CWTE+CiAgICA8QlkyPjwvQlkyPgogICAgPEJZMz48L0JZ"
+"Mz4KICAgIDxCWTQ+PC9CWTQ+CiAgICA8Qlk1PjwvQlk1PgogICAgPEJZNj48L0JZNj4KICAgIDxC"
+"WTc+PC9CWTc+CiAgICA8Qlk4PjwvQlk4PgogICAgPEJZOT48L0JZOT4KICAgIDxCWTEwPjwvQlkx"
+"MD4KICAgIDxDT01NT05fRlBLSl9YTVhYUyBjbGFzcz0iQ09NTU9OX0ZQS0pfWE1YWCIgc2l6ZT0i"
+"MiI+CiAgICAgICAgPENPTU1PTl9GUEtKX1hNWFg+CiAgICAgICAgICAgIDxGUEhYWj4wPC9GUEhY"
+"Wj4KICAgICAgICAgICAgPFhNTUM+5rSX6KGj5rayPC9YTU1DPgogICAgICAgICAgICA8R0dYSD41"
+"MDDlhYs8L0dHWEg+CiAgICAgICAgICAgIDxEVz7ooos8L0RXPgogICAgICAgICAgICA8WE1TTD4x"
+"PC9YTVNMPgogICAgICAgICAgICA8WE1ESj41MDwvWE1ESj4KICAgICAgICAgICAgPFhNSkU+NTA8"
+"L1hNSkU+CiAgICAgICAgICAgIDxTTD4wLjE3PC9TTD4KICAgICAgICAgICAgPFNFPjguNTwvU0U+"
+"CiAgICAgICAgICAgIDxCWTE+PC9CWTE+CiAgICAgICAgICAgIDxCWTI+PC9CWTI+CiAgICAgICAg"
+"ICAgIDxCWTM+PC9CWTM+CiAgICAgICAgICAgIDxCWTQ+PC9CWTQ+CiAgICAgICAgICAgIDxCWTU+"
+"PC9CWTU+CiAgICAgICAgPC9DT01NT05fRlBLSl9YTVhYPgogICAgICAgIDxDT01NT05fRlBLSl9Y"
+"TVhYPgogICAgICAgICAgICA8RlBIWFo+MDwvRlBIWFo+CiAgICAgICAgICAgIDxYTU1DPua0l+ih"
+"o+a2sjwvWE1NQz4KICAgICAgICAgICAgPEdHWEg+NTAw5YWLPC9HR1hIPgogICAgICAgICAgICA8"
+"RFc+6KKLPC9EVz4KICAgICAgICAgICAgPFhNU0w+MTwvWE1TTD4KICAgICAgICAgICAgPFhNREo+"
+"NTA8L1hNREo+CiAgICAgICAgICAgIDxYTUpFPjUwPC9YTUpFPgogICAgICAgICAgICA8U0w+MC4x"
+"NzwvU0w+CiAgICAgICAgICAgIDxTRT44LjU8L1NFPgogICAgICAgICAgICA8QlkxPjwvQlkxPgog"
+"ICAgICAgICAgICA8QlkyPjwvQlkyPgogICAgICAgICAgICA8QlkzPjwvQlkzPgogICAgICAgICAg"
+"ICA8Qlk0PjwvQlk0PgogICAgICAgICAgICA8Qlk1PjwvQlk1PgogICAgICAgIDwvQ09NTU9OX0ZQ"
+"S0pfWE1YWD4KICAgIDwvQ09NTU9OX0ZQS0pfWE1YWFM+CjwvUkVRVUVTVF9DT01NT05fRlBLSj4="
+"</content></Data></interface>]";*/
org.apache.axis.client.Service s = new org.apache.axis.client.Service();
Call call = (Call) s.createCall();
call.setTargetEndpointAddress(new URL(rc.getAddress()));
call.setOperation("doService");
// log.error("*********rc.getAddress()*********="+rc.getAddress());
// Client client = null;
// String timeOut = "6000";
// client = new Client(new URL(rc.getAddress()));
// client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, timeOut);
List<Map<String, Object>> billexall3 = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByBillEreceipt", null);
String xml;
String val;
Bill bill;
Einvoice einvoice = null;
Ereceipt ereceipt;
Map<String, String> temp;
String content;
ReceiptConfig rcNew = null;
int count = 0;
for (Map<String, Object> data : billexall3) {
ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", data.get("eid"));
if (ereceipt.getConfig() != rc.getId()) {
rcNew = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByPrimaryKey", ereceipt.getConfig());
} else {
rcNew = rc;
}
content = getContent(data, ereceipt);
log.error("[input0]{}", content);
xml = getCommonXml("DFXJ1001", new BASE64Encoder().encodeBuffer(content.getBytes("UTF-8")), rcNew.getAppId());
log.error("[input1]{}", xml);
Object[] fn01 = { xml };
val = (String) call.invoke(fn01);
log.error("[output]{}", val);
temp = parseXml(val);
if (!temp.get("returnCode").equals("0000")) {
LogUtil.syslog(sqlSession, "开票推送", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
log.error("ERRORLOG电子发票 {}", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
continue;
}
temp = parseXml(new String(new BASE64Decoder().decodeBuffer(temp.get("content")), "UTF-8"));
einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", data.get("e_invoice"));
einvoice.setInvoiceId(temp.get("FPQQLSH"));
einvoice.setInvoiceCode(temp.get("FP_DM"));
einvoice.setInvoiceNo(temp.get("FP_HM"));
einvoice.setCheckCode(temp.get("JYM"));
einvoice.setConfirmTime(sdf.parse(temp.get("KPRQ")));
einvoice.setDlAddress(temp.get("PDF_URL"));
einvoice.setStatus(1);
einvoice.setInvoiceSum(Double.valueOf(String.valueOf(data.get("bill_sum"))));
ts = transactionManager.getTransaction(def);
sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKeySelective", einvoice);
bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", data.get("id"));
bill.setIsInvoiced(1);
bill.setBillTime(new Date());
if (null == bill.getDelivery() && bill.getBillStatus() == 6) {
bill.setBillStatus(ComNames.BILL_STATUS_8);
}
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
transactionManager.commit(ts);
count++;
}
LogUtil.syslog(sqlSession, "开票推送", "开票推送成功,推送" + billexall3.size() + "条,成功" + count + "条。");
// 增值订单开票推送
List<Map<String, Object>> extraBills = extraBillService.selectByBillEreceipt(null);
ExtraBill extraBill;
Integer count2 = 0;
for (Map<String, Object> data : extraBills) {
// hgh-4-电子发票的发票模版信息
ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", data.get("eid"));
if (ereceipt.getConfig() != rc.getId()) {
rcNew = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByPrimaryKey", ereceipt.getConfig());
} else {
rcNew = rc;
}
// hgh-5-封装电票平台开票所需部分xml数据
content = getContentInExtraBill(data, ereceipt);
log.error("[input0]{}", content);
// hgh-6-封装电票平台开票所需全部的xml数据
xml = getCommonXml("DFXJ1001", new BASE64Encoder().encodeBuffer(content.getBytes("UTF-8")), rcNew.getAppId());
log.error("[input1]{}", xml);
Object[] fn01 = { xml };
// hgh-7-发送开票数据到开票平台,并获得返回值信息
val = (String) call.invoke(fn01);
log.error("[output]{}", val);
temp = parseXml(val);
// 判断开票是否失败,如果开票失败,则记录失败原因
if (!temp.get("returnCode").equals("0000")) {
LogUtil.syslog(sqlSession, "开票推送", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
log.error("ERRORLOG电子发票 {}", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
continue;
}
// hgh-8-解析获得的内容信息,并记录到本地的电子开票记录表中
temp = parseXml(new String(new BASE64Decoder().decodeBuffer(temp.get("content")), "UTF-8"));
einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", data.get("e_invoice"));
einvoice.setInvoiceId(temp.get("FPQQLSH"));
einvoice.setInvoiceCode(temp.get("FP_DM"));
einvoice.setInvoiceNo(temp.get("FP_HM"));
einvoice.setCheckCode(temp.get("JYM"));
einvoice.setConfirmTime(sdf.parse(temp.get("KPRQ")));
einvoice.setDlAddress(temp.get("PDF_URL"));
einvoice.setStatus(1);
einvoice.setInvoiceSum(Double.valueOf(String.valueOf(data.get("bill_sum"))));
ts = transactionManager.getTransaction(def);
sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKeySelective", einvoice);
extraBill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByPrimaryKey", data.get("id"));
extraBill.setIsInvoiced(true);
extraBill.setBillTime(new Date());
extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
extraBill.setFinishTime(new Date());
extraBillService.updateByPrimaryKeySelective(extraBill);
transactionManager.commit(ts);
count2++;
}
LogUtil.syslog(sqlSession, "开票推送增值订单", "开票推送成功,推送" + extraBills.size() + "条,成功" + count2 + "条。");
log.debug("任务结束");
} catch (Exception e) {
LogUtil.syslog(sqlSession, "开票推送", "开票推送失败,错误:" + e.toString());
log.error("ERRORLOG电子发票 {}", "开票推送失败,错误:" + e.toString());
e.printStackTrace();
} finally {
if (ts != null && !ts.isCompleted()) {
transactionManager.rollback(ts);
}
}
}
use of sun.misc.BASE64Decoder in project portal by ixinportal.
the class Base64Util method genFileFromBase64.
public static boolean genFileFromBase64(String base64, String filePath) {
if (base64 == null) {
return false;
}
BASE64Decoder decoder = new BASE64Decoder();
try {
// Base64解码
byte[] bytes = decoder.decodeBuffer(base64);
for (int i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) {
// 调整异常数据
bytes[i] += 256;
}
}
OutputStream out = new FileOutputStream(filePath);
out.write(bytes);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
}
use of sun.misc.BASE64Decoder in project portal by ixinportal.
the class CompressImageUtils method getThumbPicture.
/**
* 根据传入的图片数据获得缩略图数据
* @param imgData base64编码后的数据
* @return
*/
public static String getThumbPicture(String imgData, int width, int height) {
String thumb = "";
ByteArrayOutputStream byteOut = null;
try {
BASE64Decoder decoder = new BASE64Decoder();
byte[] bytes = decoder.decodeBuffer(imgData);
InputStream in = new ByteArrayInputStream(bytes);
byteOut = new ByteArrayOutputStream();
Thumbnails.of(in).size(width, height).toOutputStream(byteOut);
byte[] rBytes = byteOut.toByteArray();
byte[] code = Base64.encodeBase64(rBytes);
thumb = new String(code);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (byteOut != null) {
byteOut.flush();
byteOut.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return thumb;
}
use of sun.misc.BASE64Decoder in project portal by ixinportal.
the class SignTool method verifyP1.
public boolean verifyP1(String signature, byte[] data) throws Exception {
Signature verify = Signature.getInstance(signingAlgorithm);
verify.initVerify(rootCertificate);
byte[] sign = new BASE64Decoder().decodeBuffer(signature);
verify.update(sign);
return verify.verify(data);
}
Aggregations