use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class TakeChargingServiceImpl method checkTakeCharing.
/**
* 根据输入的appid和appserviceId,查看是否有有效的计费规则,能计费则返回true,不能则返回false,请注意,要保证输入的参数都不能为null,且应用和服务存在
*
* @param applicationInfo
* ,应用appid对应的applicationInfo对象
* @param appService
* ,服务编码对应的appService对象
* @param number,证据份数
* @return
*/
public boolean checkTakeCharing(ApplicationInfo applicationInfo, AppService appService, Integer number) {
String key = applicationInfo.getId() + "," + appService.getId();
ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = CacheCustomer.TAKE_CHARGERULE_MAP;
List<ChargingPrice> chargingPrices = chargeRuleMap.get(key);
ConcurrentHashMap<Long, ServiceName> serviceNameMap = CacheCustomer.getSERVICENAMEMAP();
if (null != chargingPrices && !chargingPrices.isEmpty()) {
for (ChargingPrice chargingPrice : chargingPrices) {
// 校验计费规则对应的时间,是否处于当前时间内,如果不是,则进行下一个计费规则
CertificationCharging certificationCharging = CacheCustomer.getCERTIFICATIONCHARGINGMAP().get(chargingPrice.getCertificationCharging());
boolean dateFlag = compareDate(new Date(), certificationCharging.getStartTime(), certificationCharging.getEndTime());
if (dateFlag) {
continue;
}
ServiceName serviceName = serviceNameMap.get(chargingPrice.getServiceName());
// 判断是否处于某个证据份数的区间内,如果都不处于,则返回错误
if (null != serviceName && (chargingPrice.getMinimumNumber() < number && number <= chargingPrice.getMaximumNumber())) {
return true;
}
}
}
return false;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class TakeServiceNameServiceImpl method selectListByCertificationCharging.
/**
* 取出所有属于该计费规则的服务名称
*
* @param certificationCharging
* @return
*/
public List<ServiceName> selectListByCertificationCharging(CertificationCharging certificationChargings) {
List<ServiceName> list = new ArrayList<ServiceName>();
ServiceNameExample serviceNameExample = new ServiceNameExample();
ServiceNameExample.Criteria criteria = serviceNameExample.or();
criteria.andCertificationChargingEqualTo(certificationChargings.getId());
list = sqlSession.selectList("com.itrus.portal.db.ServiceNameMapper.selectByExample", serviceNameExample);
return list;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class TakeServiceNameServiceImpl method getServiceNamesByCertificationCharging.
/**
* 根据输入的条件,获取serviceNameList
*
* @param certificationChargingId
* @param certificationServiceId
* @return
*/
public List<ServiceName> getServiceNamesByCertificationCharging(Long certificationChargingId, Long certificationServiceId, boolean isValidity) {
List<ServiceName> list = new ArrayList<ServiceName>();
ServiceNameExample serviceNameExample = new ServiceNameExample();
ServiceNameExample.Criteria criteria = serviceNameExample.or();
if (null != certificationChargingId) {
criteria.andCertificationChargingEqualTo(certificationChargingId);
}
if (null != certificationServiceId) {
criteria.andCertificationServiceIdEqualTo(certificationServiceId);
}
criteria.andIsValidityEqualTo(isValidity);
list = sqlSession.selectList("com.itrus.portal.db.ServiceNameMapper.selectByExample", serviceNameExample);
return list;
}
use of com.itrus.portal.db.ServiceName in project portal by ixinportal.
the class TakeServiceNameServiceImpl method selectListByCertificationChargings.
/**
* 取出所有属于该计费规则的服务名称
*
* @param certificationCharging
* @return
*/
public List<ServiceName> selectListByCertificationChargings(List<CertificationCharging> certificationChargings) {
List<Long> ccIdList = new ArrayList<Long>();
for (int i = 0; i < certificationChargings.size(); i++) {
ccIdList.add(certificationChargings.get(i).getId());
}
List<ServiceName> list = new ArrayList<ServiceName>();
ServiceNameExample serviceNameExample = new ServiceNameExample();
ServiceNameExample.Criteria criteria = serviceNameExample.or();
criteria.andCertificationChargingIn(ccIdList);
list = sqlSession.selectList("com.itrus.portal.db.ServiceNameMapper.selectByExample", serviceNameExample);
return list;
}
use of com.itrus.portal.db.ServiceName 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;
}
Aggregations