Search in sources :

Example 6 with ServiceName

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

the class ServiceNameServiceImpl 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 7 with ServiceName

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

the class ServiceNameServiceImpl method checkSurplusNumberIsEn.

/**
 * 判断当前的计费规则是否适用(判断totalNumber+本次用量是否处于最大值和最小值之间,处于返回true,不处于返回false).
 * @param serviceNameId
 * @param chargingPrice
 * @param number
 * @return
 */
public boolean checkSurplusNumberIsEn(Long serviceNameId, ChargingPrice chargingPrice, Integer number) {
    boolean flag = false;
    // 用数据库中的数据做对比
    ServiceName oldsServiceName = getServiceNameById(serviceNameId);
    flag = (chargingPrice.getMaximumNumber() > (oldsServiceName.getTotalNumber() + number)) && (chargingPrice.getMinimumNumber() <= (oldsServiceName.getTotalNumber() + number));
    return flag;
}
Also used : ServiceName(com.itrus.portal.db.ServiceName)

Example 8 with ServiceName

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

the class StoreServiceNameServiceImpl method saveOrUpdateServiceName.

/**
 * 新增或修改存证服务计费服务名称和服务类型表
 * @param serviceName
 * @param certificationCharging
 * @return
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 */
public Map<String, Object> saveOrUpdateServiceName(ServiceName serviceName, CertificationCharging certificationCharging, CertificationCharging oldCertificationCharging) throws ClassNotFoundException, IllegalAccessException {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("flag", false);
    // 参数检查
    boolean check = (null != serviceName.getCertificationServiceId());
    if (!check) {
        retMap.put("retMsg", "服务名称子表参数不合法,请检查修改后重新提交");
        return retMap;
    }
    ServiceName oldServiceName = new ServiceName();
    // 获取修改之前,获取该CertificationCharging下的services信息
    List<ServiceName> serviceNames = new ArrayList<ServiceName>();
    // 新增
    if (null != serviceName && null == serviceName.getId()) {
        retMap = checkSave(serviceName, certificationCharging);
        boolean flag = (boolean) retMap.get("flag");
        if (flag) {
            serviceName.setCreateTime(new Date());
            serviceName.setModifyTime(new Date());
            serviceName.setTotalNumber(0);
            serviceName.setIsValidity(true);
            serviceName = save(serviceName);
        } else {
            return retMap;
        }
    } else {
        // 修改
        serviceNames = getServiceNamesByCertificationCharging(certificationCharging.getId(), null, true);
        retMap = checkSave(serviceName, certificationCharging);
        boolean flag = (boolean) retMap.get("flag");
        if (flag) {
            oldServiceName = getServiceNameById(serviceName.getId());
            serviceName = setOldValueInto(serviceName, oldServiceName);
            List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
            list = CompareTwoObjectUtils.compareTwoClass(serviceName, oldServiceName);
            if (list.size() > 0) {
                LogUtil.adminlog(sqlSession, "修改存证服务计费规则", "服务名称表中,id为:" + serviceName.getId() + ",进行了修改,修改内容为:" + list.toString());
            }
            Date date = new Date();
            serviceName.setModifyTime(date);
            oldServiceName.setModifyTime(date);
            serviceName = update(serviceName);
        } else {
            return retMap;
        }
    }
    retMap.put("flag", true);
    retMap.put("serviceName", serviceName);
    retMap.put("oldServiceName", oldServiceName);
    retMap.put("serviceNames", serviceNames);
    return retMap;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ServiceName(com.itrus.portal.db.ServiceName) ArrayList(java.util.ArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Example 9 with ServiceName

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

the class StoreServiceNameServiceImpl method checkNumber.

/**
 * 判断当前的计费规则是否适用(判断totalNumber是否处于最大值和最小值之间,处于返回true,不处于返回false).
 *
 * @param serviceName
 * @param chargingPrice
 * @return
 */
public boolean checkNumber(Long serviceNameId, ChargingPrice chargingPrice) {
    boolean flag = false;
    // 用数据库中的数据做对比
    ServiceName oldsServiceName = getServiceNameById(serviceNameId);
    flag = (chargingPrice.getMaximumNumber() > oldsServiceName.getTotalNumber()) && (chargingPrice.getMinimumNumber() <= oldsServiceName.getTotalNumber());
    return flag;
}
Also used : ServiceName(com.itrus.portal.db.ServiceName)

Example 10 with ServiceName

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

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