Search in sources :

Example 11 with ServiceName

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;
}
Also used : CertificationCharging(com.itrus.portal.db.CertificationCharging) ServiceName(com.itrus.portal.db.ServiceName) ArrayList(java.util.ArrayList) List(java.util.List) ChargingPrice(com.itrus.portal.db.ChargingPrice) Date(java.util.Date)

Example 12 with ServiceName

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;
}
Also used : ServiceName(com.itrus.portal.db.ServiceName) ServiceNameExample(com.itrus.portal.db.ServiceNameExample) ArrayList(java.util.ArrayList)

Example 13 with ServiceName

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;
}
Also used : ServiceName(com.itrus.portal.db.ServiceName) ServiceNameExample(com.itrus.portal.db.ServiceNameExample) ArrayList(java.util.ArrayList)

Example 14 with ServiceName

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;
}
Also used : ServiceName(com.itrus.portal.db.ServiceName) ServiceNameExample(com.itrus.portal.db.ServiceNameExample) ArrayList(java.util.ArrayList)

Example 15 with ServiceName

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;
}
Also used : CertificationChargingExample(com.itrus.portal.db.CertificationChargingExample) CertificationCharging(com.itrus.portal.db.CertificationCharging) ArrayList(java.util.ArrayList) Date(java.util.Date) ServiceName(com.itrus.portal.db.ServiceName) ServiceNameList(com.itrus.portal.entity.ServiceNameList) ArrayList(java.util.ArrayList) List(java.util.List) ChargingPrice(com.itrus.portal.db.ChargingPrice) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

ServiceName (com.itrus.portal.db.ServiceName)44 ArrayList (java.util.ArrayList)33 CertificationCharging (com.itrus.portal.db.CertificationCharging)25 ChargingPrice (com.itrus.portal.db.ChargingPrice)18 Date (java.util.Date)18 ServiceNameExample (com.itrus.portal.db.ServiceNameExample)15 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)15 List (java.util.List)13 HashMap (java.util.HashMap)10 ServiceNameList (com.itrus.portal.entity.ServiceNameList)9 CertificationChargingExample (com.itrus.portal.db.CertificationChargingExample)8 CertificationChargingList (com.itrus.portal.entity.CertificationChargingList)6 CertificationChargingWrap (com.itrus.portal.entity.CertificationChargingWrap)6 ChargingPriceList (com.itrus.portal.entity.ChargingPriceList)6 IOException (java.io.IOException)4 Map (java.util.Map)3 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 Test (org.junit.Test)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 AppService (com.itrus.portal.db.AppService)2