use of com.itrus.portal.db.SysConfig in project portal by ixinportal.
the class GetRaInfoTask method getRaInfoByCertSerialNumber.
/**
* 根据证书序列号,从本地数据库或者远程数据库获取证书对应的RA信息
*
* @param CertSerialNumber
* :证书序列号
* @return
* @throws UserInfoServiceException
*/
public String getRaInfoByCertSerialNumber(String CertSerialNumber) throws UserInfoServiceException {
// 从本地数据库中查询是否存在该证书对应的ra哈希值
RaInfoExample raInfoExample = new RaInfoExample();
RaInfoExample.Criteria criteria = raInfoExample.or();
criteria.andCertSerialnumberEqualTo(CertSerialNumber);
RaInfo raInfo = sqlSession.selectOne("com.itrus.portal.db.RaInfoMapper.selectByExample", raInfoExample);
Map<String, Object> retmMap = new HashMap<String, Object>();
if (null != raInfo && !raInfo.getAccountHash().equals("")) {
return raInfo.getAccountHash();
} else {
// 判断系统是否配置了RA信息同步地址
SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoUrl");
if (null == sysConfig) {
throw new UserInfoServiceException("未配置RA信息同步地址");
}
// http://localhost:8080/raInfo/getRa.jsp
String url = sysConfig.getConfig() + "/getRa.jsp";
// 从远程数据库中获取证书对应的RA哈希值
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("certSn", CertSerialNumber);
try {
String resStr = restTemplate.postForObject(url, map, String.class);
Map<String, Object> remap = jsonTool.readValue(resStr, Map.class);
Integer status = (Integer) remap.get("status");
if (0 == status) {
String type = "查询证书RA信息出错";
String info = "查询出现错误的证书序列号:" + CertSerialNumber + ",错误信息:" + (String) remap.get("message");
LogUtil.syslog(sqlSession, type, info);
throw new UserInfoServiceException("查询RA信息出错,请联系管理员");
} else {
raInfo = insertOneRaInfoIntoDB(remap, raInfo);
retmMap.put("accountHash", raInfo.getAccountHash());
String type = "查询证书归属的RA信息成功";
String info = "查询证书:" + CertSerialNumber + "的RA信息成功,归属RA:" + raInfo.getAccountHash();
LogUtil.syslog(sqlSession, type, info);
return raInfo.getAccountHash();
}
} catch (Exception e) {
e.printStackTrace();
String type = "查询证书RA信息出错";
String info = "查询出现错误的证书序列号:" + CertSerialNumber + ",错误信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
throw new UserInfoServiceException("查询证书RA信息出错,请联系管理员");
}
}
}
use of com.itrus.portal.db.SysConfig in project portal by ixinportal.
the class SubmitReviewTask method audit.
/**
* 送审
*/
public synchronized void audit() {
// start------------处理双机互斥----------
// 系统是否配置同步任务的主机名
SysConfig sysConfigHost = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoHost");
if (null == sysConfigHost) {
// 没有配置,直接返回
return;
}
String host = sysConfigHost.getConfig();
host = host.replaceAll(" ", "");
String[] hosts = host.split(",");
// 获取本机主机名称
InetAddress ia = null;
try {
ia = ia.getLocalHost();
} catch (UnknownHostException e1) {
e1.printStackTrace();
return;
}
String hostName = ia.getHostName();
boolean flag = false;
for (String str : hosts) {
if (hostName.equals(str.replaceAll(" ", ""))) {
flag = true;
}
}
// 判断本地主机名称是否与系统配置的同步主机名称一致,不一致则返回
if (!flag) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
// end------------处理双机互斥----------
// 获取第三方鉴证配置信息
AuditSystemConfig auditSystemConfig = auditSystemConfigService.getAuditSystemConfig(new AuditSystemConfigExample());
// 未配置第三方鉴证信息、未开启送审、未配置送审时间间隔,直接返回
if (null == auditSystemConfig || !auditSystemConfig.getIsAudit() || null == auditSystemConfig.getAuditInterval()) {
log.debug("未配置第三方鉴证信息、未开启送审、未配置送审时间间隔--返回");
return;
}
// 上次送审时间为空,或者上次送审时间大于当前时间,则重新设置上次送审时间为当前时间的毫秒数
if (null == auditSystemConfig.getAudiStartTime() || auditSystemConfig.getAudiStartTime() > System.currentTimeMillis()) {
auditSystemConfig.setAudiStartTime(System.currentTimeMillis());
auditSystemConfigService.updateAuditSystemConfig(auditSystemConfig);
}
// 判断是否在送审的时间间隔内(当前时间小于 上次送审时间加上送审时间间隔)
if (System.currentTimeMillis() < auditSystemConfig.getAudiStartTime() + (auditSystemConfig.getAuditInterval() * 1000)) {
log.debug("不在送审时间内");
return;
}
log.debug("送审任务开始--");
// 设置本次送审时间
auditSystemConfig.setAudiStartTime(System.currentTimeMillis());
auditSystemConfigService.updateAuditSystemConfig(auditSystemConfig);
try {
// 获取需要送审的订单
Map<Long, List<Bill>> billListMap = submitReviewService.getAuditBill(submitReviewService.getAuditProduct());
if (billListMap.isEmpty() || billListMap.size() == 0) {
// 没有需要送审的订单
return;
}
// 根据产品来批量提交企业的认证信息
for (Long productId : billListMap.keySet()) {
// 发送给送审系统的json数据
List<Bill> billList = billListMap.get(productId);
String jsonString = submitReviewService.getAuditJsonParams(billList);
String appsecret = submitReviewService.getProductAppsecret(productId);
String result = RequestUtils.post(auditSystemConfig.getAuditSystemUrl() + auditUrl, jsonString, appsecret);
// 将返回信息同步至订单状态
JsonNode respNode = jsonTool.readTree(result);
for (int i = 0; i < respNode.size(); i++) {
if (200 == respNode.get(i).get("status").asInt()) {
String dataId = respNode.get(i).get("result").get("dataid").toString();
if (dataId.indexOf("\"") == 0)
// 去掉第一个
dataId = dataId.substring(1, dataId.length());
if (dataId.lastIndexOf("\"") == (dataId.length() - 1))
// 去掉最后一个
dataId = dataId.substring(0, dataId.length() - 1);
// 提交成功
Bill bill = billList.get(i);
// 设置为送审中的状态
bill.setBillStatus(ComNames.BILL_STATUS_10);
// 设置送审系统中返回的企业的唯一标识
bill.setDataId(dataId);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
}
}
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId);
LogUtil.syslog(sqlSession, "批量送审", "产品名称" + product.getName() + ",订单" + billList.size() + "条");
log.debug("送审结束");
}
} catch (Exception e) {
log.error("ERRORLOG送审 {}", e.getMessage());
e.printStackTrace();
return;
}
}
use of com.itrus.portal.db.SysConfig in project portal by ixinportal.
the class UserBillServiceTask method isRun.
private boolean isRun() {
// 系统是否配置同步ra信息主机
SysConfig sysConfigHost = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoHost");
if (null == sysConfigHost) {
// LogUtil.syslog(sqlSession, type, info);
return false;
}
String host = sysConfigHost.getConfig();
host = host.replaceAll(" ", "");
String[] hosts = host.split(",");
// 获取本机主机名称
InetAddress ia = null;
String hostName = null;
try {
ia = ia.getLocalHost();
hostName = ia.getHostName();
} catch (UnknownHostException e1) {
e1.printStackTrace();
// return false;
}
if (hostName == null) {
return true;
}
boolean flag = false;
for (String str : hosts) {
if (hostName.equals(str.replaceAll(" ", ""))) {
flag = true;
}
}
// }
return flag;
}
Aggregations