use of com.itrus.portal.db.CertificationChargingExample in project portal by ixinportal.
the class TakeChargingServiceImpl method initTakeCharging.
/**
* 初始化出证计费规则 取出当前有效的计费规则.并存入系统缓存中
*/
public ConcurrentHashMap<String, List<ChargingPrice>> initTakeCharging() {
ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = new ConcurrentHashMap<String, List<ChargingPrice>>();
CertificationChargingExample cce = new CertificationChargingExample();
CertificationChargingExample.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_TAKE_3);
List<CertificationCharging> certificationChargings = new ArrayList<CertificationCharging>();
certificationChargings = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectByExample", cce);
if (null == certificationChargings) {
return chargeRuleMap;
}
for (int i = 0; i < certificationChargings.size(); i++) {
List<ServiceName> serviceNames = serviceNameService.selectListByCertificationChargingId(certificationChargings.get(i).getId());
if (null != serviceNames && serviceNames.size() > 0) {
for (int j = 0; j < serviceNames.size(); j++) {
List<ChargingPrice> chargingPrices = new ArrayList<ChargingPrice>();
chargingPrices = chargingPriceService.selectListByServiceName(serviceNames.get(j));
String key = certificationChargings.get(i).getApp() + "," + serviceNames.get(j).getCertificationServiceId();
chargeRuleMap.put(key, chargingPrices);
}
}
}
return chargeRuleMap;
}
use of com.itrus.portal.db.CertificationChargingExample in project portal by ixinportal.
the class TakeChargingServiceImpl method selectListByAppId.
/**
* 根据输入的信息,查找对实名认证计费的List
*
* @param appId
* @param isValidity
* @param userGe
* @return
*/
public List<CertificationCharging> selectListByAppId(Long appId, Long userGe, Long chargingType) {
List<CertificationCharging> list = new ArrayList<CertificationCharging>();
CertificationChargingExample cce = new CertificationChargingExample();
CertificationChargingExample.Criteria criteria = cce.or();
if (null != appId) {
criteria.andAppEqualTo(appId);
}
// criteria.andIsValidityEqualTo(isValidity);
if (null != userGe) {
criteria.andUserGeEqualTo(userGe);
}
if (null != chargingType) {
criteria.andChargingTypeEqualTo(chargingType);
}
list = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectByExample", cce);
return list;
}
use of com.itrus.portal.db.CertificationChargingExample in project portal by ixinportal.
the class TakeServiceNameServiceImpl method initServiceNameMap.
/**
* 初始化当前时间内有效的serviceName
* @return
*/
public ConcurrentHashMap<Long, ServiceName> initServiceNameMap() {
ConcurrentHashMap<Long, ServiceName> serviceNameMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = new ConcurrentHashMap<String, List<ChargingPrice>>();
CertificationChargingExample cce = new CertificationChargingExample();
CertificationChargingExample.Criteria criteria = cce.or();
Date nowDate = new Date();
criteria.andEndTimeGreaterThan(nowDate);
cce.setOrderByClause("start_time asc");
// 将入以下条件之后,只会加载当前时间处于计费起始终止时间内的计费规则,起始时间比当前时间还晚的就不加载
// 加载一个小时以后也有效的计费规则,避免定时任务的空白期出现无可用计费的规则的情况
Date laterDate = takeChargingService.getHourLaterDate(nowDate);
criteria.andStartTimeLessThanOrEqualTo(laterDate);
List<CertificationCharging> certificationChargings = new ArrayList<CertificationCharging>();
certificationChargings = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectByExample", cce);
if (null == certificationChargings) {
return serviceNameMap;
}
for (int i = 0; i < certificationChargings.size(); i++) {
List<ServiceName> serviceNames = selectListByCertificationChargingId(certificationChargings.get(i).getId());
if (null != serviceNames && !serviceNames.isEmpty()) {
for (ServiceName serviceName : serviceNames) {
serviceNameMap.put(serviceName.getId(), serviceName);
}
}
}
return serviceNameMap;
}
use of com.itrus.portal.db.CertificationChargingExample in project portal by ixinportal.
the class StoreChargingServiceImpl method selectList.
public List<CertificationCharging> selectList(Long appId, Long chargingType) {
List<CertificationCharging> list = new ArrayList<CertificationCharging>();
CertificationChargingExample cce = new CertificationChargingExample();
CertificationChargingExample.Criteria criteria = cce.or();
if (null != appId) {
criteria.andAppEqualTo(appId);
}
if (null != chargingType) {
criteria.andChargingTypeEqualTo(chargingType);
}
list = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectByExample", cce);
return list;
}
use of com.itrus.portal.db.CertificationChargingExample in project portal by ixinportal.
the class ChargingRuleTask 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------------处理双机互斥----------
CertificationChargingExample cce = new CertificationChargingExample();
CertificationChargingExample.Criteria criteria = cce.or();
Date now = new Date();
criteria.andEndTimeLessThan(now);
List<CertificationCharging> list = certificationChargingService.selectByExample(cce);
if (null != list && list.size() > 0) {
List<ServiceName> serviceNames = serviceNameService.selectListByCertificationChargings(list);
if (null != serviceNames && serviceNames.size() > 0) {
for (ServiceName serviceName : serviceNames) {
if (serviceName.getIsValidity() == true) {
serviceName.setIsValidity(false);
serviceNameService.update(serviceName);
LogUtil.syslog(sqlSession, "将计费规则置为无效", "计费规则id为:" + serviceName.getCertificationCharging() + ", 服务表id为:" + serviceName.getId());
}
}
}
}
}
Aggregations