Search in sources :

Example 16 with CertificationChargingExample

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

the class ServiceNameServiceImpl 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 = certificationChargingService.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)16 CertificationChargingExample (com.itrus.portal.db.CertificationChargingExample)16 ArrayList (java.util.ArrayList)15 Date (java.util.Date)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)9 ServiceName (com.itrus.portal.db.ServiceName)8 ChargingPrice (com.itrus.portal.db.ChargingPrice)7 List (java.util.List)7 ServiceNameList (com.itrus.portal.entity.ServiceNameList)3 SysConfig (com.itrus.portal.db.SysConfig)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1