Search in sources :

Example 1 with MobileAppserviceChargingExample

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

the class MobileChargingRuleTask 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------------处理双机互斥----------
    MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
    MobileAppserviceChargingExample.Criteria criteria = cce.or();
    Date now = new Date();
    criteria.andEndTimeLessThan(now);
    List<MobileAppserviceCharging> list = appSeviceChargingService.selectByExample(cce);
    if (null != list && list.size() > 0) {
        List<MobileAppserviceName> serviceNames = appServiceNameService.selectListByCertificationChargings(list);
        if (null != serviceNames && serviceNames.size() > 0) {
            for (MobileAppserviceName serviceName : serviceNames) {
                if (serviceName.getIsValidity() == true) {
                    serviceName.setIsValidity(false);
                    appServiceNameService.update(serviceName);
                    LogUtil.syslog(sqlSession, "将计费规则置为无效", "计费规则id为:" + serviceName.getAppserviceCharging() + ", 服务表id为:" + serviceName.getId());
                }
            }
        }
    }
}
Also used : SysConfig(com.itrus.portal.db.SysConfig) MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) UnknownHostException(java.net.UnknownHostException) MobileAppserviceChargingExample(com.itrus.portal.db.MobileAppserviceChargingExample) Date(java.util.Date) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) InetAddress(java.net.InetAddress) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 2 with MobileAppserviceChargingExample

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

the class MobileAppserviceChargingService method initAppCertificationCharging.

/**
 * 初始化移动端计费规则 取出当前有效的计费规则.并存入系统缓存中
 */
public ConcurrentHashMap<Long, List<MobileChargingPrice>> initAppCertificationCharging() {
    ConcurrentHashMap<Long, List<MobileChargingPrice>> chargeRuleMap = new ConcurrentHashMap<Long, List<MobileChargingPrice>>();
    MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
    MobileAppserviceChargingExample.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_SMRZ_1);
    List<MobileAppserviceCharging> certificationChargings = new ArrayList<MobileAppserviceCharging>();
    certificationChargings = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceChargingMapper.selectByExample", cce);
    if (null == certificationChargings) {
        return chargeRuleMap;
    }
    for (int i = 0; i < certificationChargings.size(); i++) {
        List<MobileAppserviceName> appserviceName = appServiceNameService.selectListByAppserviceCharging(certificationChargings.get(i));
        if (null != appserviceName && appserviceName.size() > 0) {
            for (int j = 0; j < appserviceName.size(); j++) {
                List<MobileChargingPrice> chargingPrices = new ArrayList<MobileChargingPrice>();
                chargingPrices = chargingPriceService.selectListByServiceName(appserviceName.get(j));
                /*String key = certificationChargings.get(i).getApp() + ","
						+ appserviceName.get(j).getAppserviceCharging();*/
                // .getCertificationServiceId();
                chargeRuleMap.put(certificationChargings.get(i).getApp(), chargingPrices);
            }
        }
    }
    return chargeRuleMap;
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) MobileChargingPrice(com.itrus.portal.db.MobileChargingPrice) ArrayList(java.util.ArrayList) MobileAppserviceChargingExample(com.itrus.portal.db.MobileAppserviceChargingExample) Date(java.util.Date) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) ArrayList(java.util.ArrayList) List(java.util.List) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 3 with MobileAppserviceChargingExample

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

the class MobileAppserviceChargingService method initMobileCertificationChargingMap.

/**
 * 初始化CertificationChargingMap
 */
public ConcurrentHashMap<Long, MobileAppserviceCharging> initMobileCertificationChargingMap() {
    ConcurrentHashMap<Long, MobileAppserviceCharging> certificationChargingMap = new ConcurrentHashMap<Long, MobileAppserviceCharging>();
    MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
    MobileAppserviceChargingExample.Criteria criteria = cce.or();
    Date nowDate = new Date();
    criteria.andEndTimeGreaterThan(nowDate);
    cce.setOrderByClause("start_time asc");
    // 将入以下条件之后,只会加载当前时间处于计费起始终止时间内的计费规则,起始时间比当前时间还晚的就不加载
    // 加载一个小时以后也有效的计费规则,避免定时任务的空白期出现无可用计费的规则的情况
    Date laterDate = getHourLaterDate(nowDate);
    criteria.andStartTimeLessThanOrEqualTo(laterDate);
    List<MobileAppserviceCharging> certificationChargings = new ArrayList<MobileAppserviceCharging>();
    certificationChargings = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceChargingMapper.selectByExample", cce);
    if (null != certificationChargings && !certificationChargings.isEmpty()) {
        for (MobileAppserviceCharging certificationCharging : certificationChargings) {
            certificationChargingMap.put(certificationCharging.getId(), certificationCharging);
        }
    }
    return certificationChargingMap;
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) ArrayList(java.util.ArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MobileAppserviceChargingExample(com.itrus.portal.db.MobileAppserviceChargingExample) Date(java.util.Date)

Example 4 with MobileAppserviceChargingExample

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

the class MobileAppserviceChargingService method selectList.

public List<MobileAppserviceCharging> selectList(Long appId) {
    List<MobileAppserviceCharging> list = new ArrayList<MobileAppserviceCharging>();
    MobileAppserviceChargingExample ace = new MobileAppserviceChargingExample();
    MobileAppserviceChargingExample.Criteria criteria = ace.or();
    if (null != appId) {
        criteria.andAppEqualTo(appId);
    }
    list = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceChargingMapper.selectByExample", ace);
    return list;
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) ArrayList(java.util.ArrayList) MobileAppserviceChargingExample(com.itrus.portal.db.MobileAppserviceChargingExample)

Example 5 with MobileAppserviceChargingExample

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

the class MobileAppserviceNameService method initAppServiceNameMap.

/**
 * 初始化当前时间内有效的serviceName
 * @return
 */
public ConcurrentHashMap<Long, MobileAppserviceName> initAppServiceNameMap() {
    ConcurrentHashMap<Long, MobileAppserviceName> serviceNameMap = new ConcurrentHashMap<>();
    ConcurrentHashMap<String, List<MobileChargingPrice>> chargeRuleMap = new ConcurrentHashMap<String, List<MobileChargingPrice>>();
    MobileAppserviceChargingExample cce = new MobileAppserviceChargingExample();
    MobileAppserviceChargingExample.Criteria criteria = cce.or();
    Date nowDate = new Date();
    criteria.andEndTimeGreaterThan(nowDate);
    cce.setOrderByClause("start_time asc");
    // 将入以下条件之后,只会加载当前时间处于计费起始终止时间内的计费规则,起始时间比当前时间还晚的就不加载
    // 加载一个小时以后也有效的计费规则,避免定时任务的空白期出现无可用计费的规则的情况
    Date laterDate = appserviceChargingService.getHourLaterDate(nowDate);
    criteria.andStartTimeLessThanOrEqualTo(laterDate);
    List<MobileAppserviceCharging> certificationChargings = new ArrayList<MobileAppserviceCharging>();
    certificationChargings = sqlSession.selectList("com.itrus.portal.db.MobileAppserviceChargingMapper.selectByExample", cce);
    if (null == certificationChargings) {
        return serviceNameMap;
    }
    for (int i = 0; i < certificationChargings.size(); i++) {
        List<MobileAppserviceName> serviceNames = selectListByCertificationChargingId(certificationChargings.get(i).getId());
        if (null != serviceNames && !serviceNames.isEmpty()) {
            for (MobileAppserviceName serviceName : serviceNames) {
                serviceNameMap.put(serviceName.getId(), serviceName);
            }
        }
    }
    return serviceNameMap;
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) MobileChargingPrice(com.itrus.portal.db.MobileChargingPrice) ArrayList(java.util.ArrayList) MobileAppserviceChargingExample(com.itrus.portal.db.MobileAppserviceChargingExample) Date(java.util.Date) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) AppserviceNameList(com.itrus.portal.mobile.entity.AppserviceNameList) ArrayList(java.util.ArrayList) List(java.util.List) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

MobileAppserviceCharging (com.itrus.portal.db.MobileAppserviceCharging)6 MobileAppserviceChargingExample (com.itrus.portal.db.MobileAppserviceChargingExample)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)4 MobileAppserviceName (com.itrus.portal.db.MobileAppserviceName)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 MobileChargingPrice (com.itrus.portal.db.MobileChargingPrice)2 List (java.util.List)2 SysConfig (com.itrus.portal.db.SysConfig)1 AppserviceNameList (com.itrus.portal.mobile.entity.AppserviceNameList)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1