use of com.itrus.portal.db.MobileAppserviceChargingExample 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());
}
}
}
}
}
use of com.itrus.portal.db.MobileAppserviceChargingExample in project portal by ixinportal.
the class MobileAppserviceChargingService method initAppCertificationCharging.
/**
* 初始化移动端计费规则 取出当前有效的计费规则.并存入系统缓存中
*/
public ConcurrentHashMap<Long, List<MobileChargingPrice>> initAppCertificationCharging() {
ConcurrentHashMap<Long, List<MobileChargingPrice>> chargeRuleMap = new ConcurrentHashMap<Long, List<MobileChargingPrice>>();
MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
MobileAppserviceChargingExample.Criteria criteria = cce.or();
Date nowDate = new Date();
criteria.andEndTimeGreaterThan(nowDate);
cce.setOrderByClause("start_time asc");
// 将入以下条件之后,只会加载当前时间处于计费起始终止时间内的计费规则,起始时间比当前时间还晚的就不加载
// 加载一个小时以后也有效的计费规则,避免定时任务的空白期出现无可用计费的规则的情况
Date laterDate = getHourLaterDate(nowDate);
criteria.andStartTimeLessThanOrEqualTo(laterDate);
// criteria.andChargingTypeEqualTo(ComNames.CHARGING_TYPE_SMRZ_1);
List<MobileAppserviceCharging> certificationChargings = new ArrayList<MobileAppserviceCharging>();
certificationChargings = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceChargingMapper.selectByExample", cce);
if (null == certificationChargings) {
return chargeRuleMap;
}
for (int i = 0; i < certificationChargings.size(); i++) {
List<MobileAppserviceName> appserviceName = appServiceNameService.selectListByAppserviceCharging(certificationChargings.get(i));
if (null != appserviceName && appserviceName.size() > 0) {
for (int j = 0; j < appserviceName.size(); j++) {
List<MobileChargingPrice> chargingPrices = new ArrayList<MobileChargingPrice>();
chargingPrices = chargingPriceService.selectListByServiceName(appserviceName.get(j));
/*String key = certificationChargings.get(i).getApp() + ","
+ appserviceName.get(j).getAppserviceCharging();*/
// .getCertificationServiceId();
chargeRuleMap.put(certificationChargings.get(i).getApp(), chargingPrices);
}
}
}
return chargeRuleMap;
}
use of com.itrus.portal.db.MobileAppserviceChargingExample in project portal by ixinportal.
the class MobileAppserviceChargingService method initMobileCertificationChargingMap.
/**
* 初始化CertificationChargingMap
*/
public ConcurrentHashMap<Long, MobileAppserviceCharging> initMobileCertificationChargingMap() {
ConcurrentHashMap<Long, MobileAppserviceCharging> certificationChargingMap = new ConcurrentHashMap<Long, MobileAppserviceCharging>();
MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
MobileAppserviceChargingExample.Criteria criteria = cce.or();
Date nowDate = new Date();
criteria.andEndTimeGreaterThan(nowDate);
cce.setOrderByClause("start_time asc");
// 将入以下条件之后,只会加载当前时间处于计费起始终止时间内的计费规则,起始时间比当前时间还晚的就不加载
// 加载一个小时以后也有效的计费规则,避免定时任务的空白期出现无可用计费的规则的情况
Date laterDate = getHourLaterDate(nowDate);
criteria.andStartTimeLessThanOrEqualTo(laterDate);
List<MobileAppserviceCharging> certificationChargings = new ArrayList<MobileAppserviceCharging>();
certificationChargings = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceChargingMapper.selectByExample", cce);
if (null != certificationChargings && !certificationChargings.isEmpty()) {
for (MobileAppserviceCharging certificationCharging : certificationChargings) {
certificationChargingMap.put(certificationCharging.getId(), certificationCharging);
}
}
return certificationChargingMap;
}
use of com.itrus.portal.db.MobileAppserviceChargingExample in project portal by ixinportal.
the class MobileAppserviceChargingService method selectList.
public List<MobileAppserviceCharging> selectList(Long appId) {
List<MobileAppserviceCharging> list = new ArrayList<MobileAppserviceCharging>();
MobileAppserviceChargingExample ace = new MobileAppserviceChargingExample();
MobileAppserviceChargingExample.Criteria criteria = ace.or();
if (null != appId) {
criteria.andAppEqualTo(appId);
}
list = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceChargingMapper.selectByExample", ace);
return list;
}
use of com.itrus.portal.db.MobileAppserviceChargingExample in project portal by ixinportal.
the class MobileAppserviceNameService method initAppServiceNameMap.
/**
* 初始化当前时间内有效的serviceName
* @return
*/
public ConcurrentHashMap<Long, MobileAppserviceName> initAppServiceNameMap() {
ConcurrentHashMap<Long, MobileAppserviceName> serviceNameMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, List<MobileChargingPrice>> chargeRuleMap = new ConcurrentHashMap<String, List<MobileChargingPrice>>();
MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
MobileAppserviceChargingExample.Criteria criteria = cce.or();
Date nowDate = new Date();
criteria.andEndTimeGreaterThan(nowDate);
cce.setOrderByClause("start_time asc");
// 将入以下条件之后,只会加载当前时间处于计费起始终止时间内的计费规则,起始时间比当前时间还晚的就不加载
// 加载一个小时以后也有效的计费规则,避免定时任务的空白期出现无可用计费的规则的情况
Date laterDate = appserviceChargingService.getHourLaterDate(nowDate);
criteria.andStartTimeLessThanOrEqualTo(laterDate);
List<MobileAppserviceCharging> certificationChargings = new ArrayList<MobileAppserviceCharging>();
certificationChargings = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceChargingMapper.selectByExample", cce);
if (null == certificationChargings) {
return serviceNameMap;
}
for (int i = 0; i < certificationChargings.size(); i++) {
List<MobileAppserviceName> serviceNames = selectListByCertificationChargingId(certificationChargings.get(i).getId());
if (null != serviceNames && !serviceNames.isEmpty()) {
for (MobileAppserviceName serviceName : serviceNames) {
serviceNameMap.put(serviceName.getId(), serviceName);
}
}
}
return serviceNameMap;
}
Aggregations