Search in sources :

Example 1 with MobileAppserviceName

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

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

the class MobileAppserviceNameService method checkValidAppserviceCharging.

/**
 * 如果该MobileAppserviceCharging下所有的MobileAppserviceName都已经无效了.那么就不校验改MobileAppserviceCharging
 * 校验该MobileAppserviceCharging
 * @param ccList
 * @return
 */
private List<MobileAppserviceCharging> checkValidAppserviceCharging(List<MobileAppserviceCharging> acList) {
    if (null == acList || acList.size() == 0) {
        return acList;
    }
    Iterator<MobileAppserviceCharging> iterator = acList.iterator();
    while (iterator.hasNext()) {
        MobileAppserviceCharging appserviceCharging = iterator.next();
        MobileAppserviceNameExample appserviceNameExample = new MobileAppserviceNameExample();
        MobileAppserviceNameExample.Criteria criteria = appserviceNameExample.or();
        criteria.andAppserviceChargingEqualTo(appserviceCharging.getId());
        criteria.andIsValidityEqualTo(true);
        List<MobileAppserviceName> appserviceNames = selectListByExample(appserviceNameExample);
        if (null == appserviceNames || appserviceNames.size() == 0) {
            iterator.remove();
        }
    }
    return acList;
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) MobileAppserviceNameExample(com.itrus.portal.db.MobileAppserviceNameExample)

Example 3 with MobileAppserviceName

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

the class MobileChargingServiceImpl method insertOneIntoCharging.

/**
 * 向移动端计费表中插入一条计费记录
 *
 * @param applicationInfoId
 * @param appServiceId
 * @param chargingPrice,计费以及价格区间
 * @return
 */
public Map<String, Object> insertOneIntoCharging(Long applicationInfoId, /*Long appServiceId,*/
MobileChargingPrice chargingPrice, /*Long transinfoPrimaryId,*/
String transinfoTableName, Long chargingFlow) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("flag", false);
    MobileAppserviceName serviceName = appServiceNameService.getMobileAppServiceNameById(chargingPrice.getAppserviceName());
    MobileAppserviceCharging cc = appserviceChargingService.getCertificationChargingById(chargingPrice.getAppserviceCharging());
    Date date = new Date();
    MobileCharging charging = new MobileCharging();
    charging.setApplicationInfo(applicationInfoId);
    // charging.setAppService(appServiceId);
    charging.setCertificationCharging(chargingPrice.getAppserviceCharging());
    charging.setCreateTime(date);
    charging.setChargingPrice(chargingPrice.getId());
    charging.setIsValidity(true);
    charging.setModifyTime(date);
    charging.setServiceName(chargingPrice.getAppserviceName());
    charging.setServieType(Long.parseLong(String.valueOf(serviceName.getServiceType())));
    charging.setUnitPrice(chargingPrice.getUnitPrice());
    charging.setUserGe(cc.getUserGe());
    charging = getYearMonthQuarter(date, charging);
    // charging.setTransinfoName(transinfoName);
    // charging.setTransinfoId(transinfoId);
    charging.setChargingType(ComNames.SERVICE_TYPE_FOUR);
    // charging.setTransinfoPrimaryId(transinfoPrimaryId);
    charging.setTransinfoTableName(transinfoTableName);
    charging.setChargingId(UniqueIDUtils.genCertificationTransInfoUID(sqlSession));
    charging.setChargingFlow(chargingFlow);
    // 认证组合名称:组合字段的值是:应用id+','+服务id+','+服务类别+','+年份+','+计费策略
    String combinationName = applicationInfoId + /*+ "," + appServiceId*/
    "," + serviceName.getServiceType() + "," + charging.getYear1() + "," + cc.getUserGe();
    charging.setCombinationName(combinationName);
    try {
        charging = insertOne(charging);
        serviceName.setTotalNumber(serviceName.getTotalNumber() + 1);
        appServiceNameService.updateTotalNum(serviceName);
    } catch (Exception e) {
        // TODO: handle exception
        retMap.put("retMsg", e.getMessage());
        retMap.put("flag", false);
        return retMap;
    }
    retMap.put("flag", true);
    retMap.put("charging", charging);
    return retMap;
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) MobileCharging(com.itrus.portal.db.MobileCharging) HashMap(java.util.HashMap) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) Date(java.util.Date)

Example 4 with MobileAppserviceName

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

the class MobileAppserviceChargingController method show.

// 根据应用id,查询应用下的所有计费规则信息
@RequestMapping(value = "/show/{id}")
public String show(@PathVariable("id") Long id, Model uiModel, HttpServletRequest request) {
    ApplicationInfo applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByPrimaryKey", id);
    uiModel.addAttribute("applicationInfo", applicationInfo);
    // 系统配置的实名认证服务集合
    // List<AppService> appServices = new ArrayList<AppService>();
    // AppServiceExample appServiceExample = new AppServiceExample();
    // AppServiceExample.Criteria criteria = appServiceExample.or();
    // criteria.andTypeEqualTo(ComNames.SERVICE_TYPE_CERTIFICATION);
    // appServices = sqlSession.selectList(
    // "com.itrus.portal.db.AppServiceMapper.selectByExample", appServiceExample);
    // uiModel.addAttribute("appServices", appServices);
    List<MobileAppserviceCharging> appserviceChargings = new ArrayList<MobileAppserviceCharging>();
    appserviceChargings = appserviceChargingService.selectList(id);
    AppserviceChargingWrap appserviceChargingWrap = new AppserviceChargingWrap();
    List<AppserviceChargingList> appserviceChargingLists = new ArrayList<AppserviceChargingList>();
    for (int i = 0; i < appserviceChargings.size(); i++) {
        AppserviceChargingList appserviceChargingList = new AppserviceChargingList();
        List<MobileAppserviceName> serviceNames = new ArrayList<MobileAppserviceName>();
        serviceNames = appserviceNameService.selectListByAppserviceCharging(appserviceChargings.get(i));
        List<AppserviceNameList> serviceNameLists = new ArrayList<AppserviceNameList>();
        for (int j = 0; j < serviceNames.size(); j++) {
            List<MobileChargingPrice> chargingPrices = chargingPriceService.selectListByOneAppserviceName(serviceNames.get(j));
            AppserviceNameList appserviceNameList = new AppserviceNameList();
            ChargingPriceList chargingPriceList = new ChargingPriceList();
            // 1
            chargingPriceList.setChargingPriceLists(chargingPrices);
            // 2
            appserviceNameList.setAppserviceName(serviceNames.get(j));
            appserviceNameList.setChargingPriceList(chargingPriceList);
            serviceNameLists.add(appserviceNameList);
        }
        appserviceChargingList.setAppserviceCharging(appserviceChargings.get(i));
        appserviceChargingList.setAppserviceNameLists(serviceNameLists);
        appserviceChargingLists.add(appserviceChargingList);
    }
    appserviceChargingWrap.setAppserviceChargingLists(appserviceChargingLists);
    System.out.println(appserviceChargingWrap);
    uiModel.addAttribute("acw", appserviceChargingWrap);
    Map<Long, AppService> appServiceMap = sqlSession.selectMap("com.itrus.portal.db.AppServiceMapper.selectByExample", null, "id");
    uiModel.addAttribute("appServiceMap", appServiceMap);
    // 返回页面上的表单数据
    returnParam(request, uiModel);
    return "appservicecharging/show";
}
Also used : MobileAppserviceCharging(com.itrus.portal.db.MobileAppserviceCharging) AppService(com.itrus.portal.db.AppService) AppserviceNameList(com.itrus.portal.mobile.entity.AppserviceNameList) MobileChargingPrice(com.itrus.portal.db.MobileChargingPrice) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) ArrayList(java.util.ArrayList) ChargingPriceList(com.itrus.portal.mobile.entity.ChargingPriceList) AppserviceChargingWrap(com.itrus.portal.mobile.entity.AppserviceChargingWrap) MobileAppserviceName(com.itrus.portal.db.MobileAppserviceName) AppserviceChargingList(com.itrus.portal.mobile.entity.AppserviceChargingList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with MobileAppserviceName

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

Aggregations

MobileAppserviceName (com.itrus.portal.db.MobileAppserviceName)16 ArrayList (java.util.ArrayList)11 MobileAppserviceCharging (com.itrus.portal.db.MobileAppserviceCharging)10 MobileChargingPrice (com.itrus.portal.db.MobileChargingPrice)6 Date (java.util.Date)6 MobileAppserviceNameExample (com.itrus.portal.db.MobileAppserviceNameExample)5 AppserviceNameList (com.itrus.portal.mobile.entity.AppserviceNameList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 MobileAppserviceChargingExample (com.itrus.portal.db.MobileAppserviceChargingExample)3 AppserviceChargingList (com.itrus.portal.mobile.entity.AppserviceChargingList)3 AppserviceChargingWrap (com.itrus.portal.mobile.entity.AppserviceChargingWrap)3 ChargingPriceList (com.itrus.portal.mobile.entity.ChargingPriceList)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)2 AppService (com.itrus.portal.db.AppService)1 MobileCharging (com.itrus.portal.db.MobileCharging)1 SysConfig (com.itrus.portal.db.SysConfig)1 CertificationChargingList (com.itrus.portal.entity.CertificationChargingList)1