Search in sources :

Example 6 with CertificationCharging

use of com.itrus.portal.db.CertificationCharging 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;
}
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) ArrayList(java.util.ArrayList) List(java.util.List) ChargingPrice(com.itrus.portal.db.ChargingPrice) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 7 with CertificationCharging

use of com.itrus.portal.db.CertificationCharging 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;
}
Also used : CertificationChargingExample(com.itrus.portal.db.CertificationChargingExample) CertificationCharging(com.itrus.portal.db.CertificationCharging) ArrayList(java.util.ArrayList)

Example 8 with CertificationCharging

use of com.itrus.portal.db.CertificationCharging 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 9 with CertificationCharging

use of com.itrus.portal.db.CertificationCharging in project portal by ixinportal.

the class TakeChargingServiceImpl method getAllAppId.

/**
 * 获取计费下所有的应用id
 * @return
 */
public Set<Long> getAllAppId() {
    Set<Long> set = new TreeSet<Long>();
    List<CertificationCharging> ccList = selectByExample(null);
    if (null != ccList && ccList.size() > 0) {
        for (CertificationCharging certificationCharging : ccList) {
            set.add(certificationCharging.getApp());
        }
    }
    return set;
}
Also used : CertificationCharging(com.itrus.portal.db.CertificationCharging) TreeSet(java.util.TreeSet)

Example 10 with CertificationCharging

use of com.itrus.portal.db.CertificationCharging 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

CertificationCharging (com.itrus.portal.db.CertificationCharging)43 ArrayList (java.util.ArrayList)34 ServiceName (com.itrus.portal.db.ServiceName)25 Date (java.util.Date)23 ChargingPrice (com.itrus.portal.db.ChargingPrice)21 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)19 CertificationChargingExample (com.itrus.portal.db.CertificationChargingExample)16 List (java.util.List)15 HashMap (java.util.HashMap)13 ServiceNameList (com.itrus.portal.entity.ServiceNameList)9 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)4 Test (org.junit.Test)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 AppService (com.itrus.portal.db.AppService)3 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)3 Charging (com.itrus.portal.db.Charging)3