use of com.itrus.portal.db.SysConfig in project portal by ixinportal.
the class SystemConfigService method getRainfoHost.
public SysConfig getRainfoHost() {
String type = SystemConfigService.RAINFO_HOST;
SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", type);
if (sysConfig != null) {
return sysConfig;
} else {
return null;
}
}
use of com.itrus.portal.db.SysConfig in project portal by ixinportal.
the class GetRaInfoTask method getRaInfo.
/**
* 定时获取RA信息的定时器 心跳更新。启动时执行一次,之后每一天执行一次 1000*60*60*24
* @Scheduled(fixedRate = 1000 * 60 * 60 * 24)
* 设置为每天凌晨2点触发
* @Scheduled(cron = "0 0 2 * * ?")
*/
@Scheduled(cron = "0 0 2 * * ?")
public void getRaInfo() {
// 系统是否配置同步ra信息主机
SysConfig sysConfigHost = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoHost");
if (null == sysConfigHost) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
String host = sysConfigHost.getConfig();
host = host.replaceAll(" ", "");
String[] hosts = host.split(",");
// 获取本机主机名称
InetAddress ia = null;
try {
ia = ia.getLocalHost();
} catch (UnknownHostException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return;
}
String hostName = ia.getHostName();
boolean flag = false;
for (String str : hosts) {
if (hostName.equals(str.replaceAll(" ", ""))) {
flag = true;
}
}
// 判断本地主机名称是否与系统配置的ra信息同步主机名称一致,不一致则返回
if (!flag) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
// 系统是否配置同步ra信息开关
SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "openGetRaInfo");
if (null == sysConfig) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
if (sysConfig.getConfig().equals("false")) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
// 系统是否配置同步ra信息地址
SysConfig sysConfigurl = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoUrl");
if (null == sysConfigurl) {
String type = "同步RA信息错误";
String info = "系统未配置RA信息同步地址";
LogUtil.syslog(sqlSession, type, info);
return;
}
// if(!isSyncGetRa()){
// return;
// }
// 证书ID的最大值
Integer maxCertId = 0;
// 每次更新的数目,默认是1000
Integer limit = 1000;
// 每天同步的数量
Integer everyDayNum = 1;
// 每天需要同步的次数
Integer count = 0;
// 每天成功同步的信息数量
successNum = new AtomicInteger(0);
SysConfig sysConfigNum = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoNum");
if (null != sysConfigNum && StringUtils.isNotBlank(sysConfigNum.getConfig())) {
everyDayNum = Integer.parseInt(sysConfigNum.getConfig());
} else {
String type = "同步RA信息";
String info = "系统未配置RA信息同步数量";
LogUtil.syslog(sqlSession, type, info);
}
// 请求的url
String url = sysConfigurl.getConfig() + "/getRaList.jsp";
String limitString = limit.toString();
// 计算需要同步的次数
count = (everyDayNum + limit - 1) / limit;
for (int i = 0; i < count; i++) {
maxCertId = sqlSession.selectOne("com.itrus.portal.db.RaInfoMapper.selectMaxCertId");
if (null == maxCertId || maxCertId < 1) {
maxCertId = 0;
}
String maxCertIdString = maxCertId.toString();
// 设置请求参数
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("certId", maxCertIdString);
map.add("limit", limitString);
try {
// 发送请求
String resStr = restTemplate.postForObject(url, map, String.class);
// 解析响应信息
List<Map<String, Object>> list = jsonTool.readValue(resStr, List.class);
// 获取状态信息,0为错误,1为成功
Map<String, Object> statusMap = list.get(list.size() - 1);
Integer status = (Integer) statusMap.get("status");
if (0 == status) {
String type = "同步RA信息错误";
String info = (String) statusMap.get("message");
LogUtil.syslog(sqlSession, type, info);
return;
} else {
insertRaInfosIntoDB(list);
}
} catch (Exception e) {
e.printStackTrace();
String type = "同步RA信息出现异常";
String info = "成功同步:" + successNum + "条信息,异常信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
log.error("ERRORLOG同步RA信息 {}", info);
return;
}
}
String type = "同步RA信息成功";
String info = "成功同步:" + successNum + "条信息";
LogUtil.syslog(sqlSession, type, info);
}
use of com.itrus.portal.db.SysConfig in project portal by ixinportal.
the class GetRaInfoTask method isSyncGetRa.
/**
* true表示可以往下执行,false表示不能继续往下执行
*
* @return
*/
public boolean isSyncGetRa() {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String timeStr = format.format(new Date());
String random = getRandomStr();
String syncRaInfo = timeStr + "_" + random;
SysConfig conf = new SysConfig();
conf.setConfig(syncRaInfo);
Map<String, Object> retmap = new HashMap<String, Object>();
retmap.put("record", conf);
SysConfigExample example = new SysConfigExample();
SysConfigExample.Criteria criteria = example.or();
criteria.andTypeEqualTo("syncRaInfo");
criteria.andConfigNotLike(timeStr + "_%");
retmap.put("example", example);
sqlSession.update("com.itrus.portal.db.SysConfigMapper.updateByExampleSelective", retmap);
example = new SysConfigExample();
criteria = example.or();
criteria.andTypeEqualTo("syncRaInfo");
criteria.andConfigEqualTo(syncRaInfo);
SysConfig config = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByExample", example);
if (null == config) {
return false;
} else {
return true;
}
}
use of com.itrus.portal.db.SysConfig in project portal by ixinportal.
the class MobileChargingFailTask method ChargingAgain.
/**
* 遍历所有计费失败的记录,重新计费
*
* @Scheduled(fixedRate = 1000 * 60 * 60 * 24) 设置为每天凌晨2点触发
* @Scheduled(cron = "0 0 2 * * ?")
*/
@Scheduled(cron = "0 0/45 * * * ?")
public void ChargingAgain() {
// 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_check = false;
for (String str : hosts) {
if (hostName.equals(str.replaceAll(" ", ""))) {
flag_check = true;
}
}
// 判断本地主机名称是否与系统配置的同步主机名称一致,不一致则返回
if (!flag_check) {
return;
}
// end------------处理双机互斥----------
List<MobileChargingFail> chargingFails = chargingFailService.geChargingFails();
if (null == chargingFails || chargingFails.size() == 0) {
return;
}
for (int i = 0; i < chargingFails.size(); i++) {
MobileChargingFail chargingFail = chargingFails.get(i);
Map<String, Object> retMap = new HashMap<String, Object>();
ApplicationInfo applicationInfo = appServiceChargingService.getApplicationInfoByAppId(chargingFail.getAppId());
// AppService appService = certificationChargingService.getAppServiceByAppServiceId(chargingFail.getAppServiceId());
retMap = appServiceChargingService.charging(chargingFail.getAppId(), /* chargingFail.getAppServiceId(),
chargingFail.getTransinfoName(),
chargingFail.getTransinfoId(),*/
applicationInfo, /*chargingFail.getTransinfoPrimaryId(),*/
chargingFail.getTransinfoTableName());
Integer flag = (Integer) retMap.get("retCode");
// 若插入成功
if (null != flag && flag == 1) {
chargingFail.setIsValidity(false);
chargingFail.setModifyTime(new Date());
Charging charging = (Charging) retMap.get("charging");
chargingFail.setChargingId(charging.getChargingId());
chargingFailService.update(chargingFail);
}
}
}
use of com.itrus.portal.db.SysConfig in project portal by ixinportal.
the class MobileChargingRuleTask method setChargingRuleToInvalid.
/**
* 定时任务,将过期的计费规则置为无效
*
* @Scheduled(fixedRate = 1000 * 60 * 60 * 24)
* @Scheduled(cron = "0 0 2 * * ?")设置为每天凌晨2点触发
*/
@Scheduled(cron = "0 0/35 * * * ?")
public void setChargingRuleToInvalid() {
// 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_check = false;
for (String str : hosts) {
if (hostName.equals(str.replaceAll(" ", ""))) {
flag_check = true;
}
}
// 判断本地主机名称是否与系统配置的同步主机名称一致,不一致则返回
if (!flag_check) {
return;
}
// end------------处理双机互斥----------
MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
MobileAppserviceChargingExample.Criteria criteria = cce.or();
Date now = new Date();
criteria.andEndTimeLessThan(now);
List<MobileAppserviceCharging> list = appSeviceChargingService.selectByExample(cce);
if (null != list && list.size() > 0) {
List<MobileAppserviceName> serviceNames = appServiceNameService.selectListByCertificationChargings(list);
if (null != serviceNames && serviceNames.size() > 0) {
for (MobileAppserviceName serviceName : serviceNames) {
if (serviceName.getIsValidity() == true) {
serviceName.setIsValidity(false);
appServiceNameService.update(serviceName);
LogUtil.syslog(sqlSession, "将计费规则置为无效", "计费规则id为:" + serviceName.getAppserviceCharging() + ", 服务表id为:" + serviceName.getId());
}
}
}
}
}
Aggregations