Search in sources :

Example 21 with ChargingPrice

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

the class ChargingPriceServiceImpl method selectListByServiceName.

/**
 * 获取该服务下的有效的计费价格区间(最大值大于total,按照最小值升序排序)
 *
 * @param serviceName
 * @return
 */
public List<ChargingPrice> selectListByServiceName(ServiceName serviceName) {
    List<ChargingPrice> list = new ArrayList<ChargingPrice>();
    ChargingPriceExample chargingPriceExample = new ChargingPriceExample();
    ChargingPriceExample.Criteria criteria = chargingPriceExample.or();
    criteria.andServiceNameEqualTo(serviceName.getId());
    criteria.andMaximumNumberGreaterThan(serviceName.getTotalNumber());
    chargingPriceExample.setOrderByClause("minimum_number asc");
    list = sqlSession.selectList("com.itrus.portal.db.ChargingPriceMapper.selectByExample", chargingPriceExample);
    return list;
}
Also used : ChargingPriceExample(com.itrus.portal.db.ChargingPriceExample) ArrayList(java.util.ArrayList) ChargingPrice(com.itrus.portal.db.ChargingPrice)

Example 22 with ChargingPrice

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

the class ChargingPriceServiceImpl method checkSave.

/**
 * 新增约束检测,通过则返true,不通过则false
 *
 * @param serviceName
 * @param chargingPrice
 * @return
 */
private Map<String, Object> checkSave(ServiceName serviceName, ChargingPrice chargingPrice) {
    List<ChargingPrice> chargingPrices = selectChargingPriceList(serviceName);
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("flag", false);
    if (null != chargingPrices && chargingPrices.size() != 0) {
        // 找到规则点
        ChargingPrice checkChargingPrice = null;
        for (int i = 0; i < chargingPrices.size(); i++) {
            // 先根据新插入的记录的最大值是不是最大的,如果是,这个就插入点;如果不是,则证明要插入的是中间位置,中间位置的最大值要==某个最小值
            if (chargingPrices.get(i).getMaximumNumber() <= chargingPrice.getMinimumNumber()) {
                // 判断了最大值比记录中的都大了之后,应该判断最小值跟记录中的某条记录的最大值相等.形成阶梯关系
                if (chargingPrices.get(i).getMaximumNumber().equals(chargingPrice.getMinimumNumber())) {
                    checkChargingPrice = chargingPrices.get(i);
                    retMap.put("flag", true);
                    return retMap;
                }
            } else if (chargingPrices.get(i).getMinimumNumber().equals(chargingPrice.getMaximumNumber())) {
                checkChargingPrice = chargingPrices.get(i);
                retMap.put("flag", true);
                return retMap;
            } else {
                retMap.put("retMsg", "新增的计费以及价格区间不符合规则,请检查后再提交");
            }
        }
        retMap.put("retMsg", "新增的计费以及价格区间不连贯,请注意最大值和最小值之间的链接关系,请检查后再提交");
        return retMap;
    } else {
        // 如果是第一次增加一个记录,那么它的最小值是0
        retMap.put("flag", true);
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) ChargingPrice(com.itrus.portal.db.ChargingPrice)

Example 23 with ChargingPrice

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

the class ChargingPriceServiceImpl method checkUpdate.

/**
 * 修改约束检测
 *
 * @param certificationCharging
 * @param serviceName
 * @param chargingPrice
 * @return
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 */
private Map<String, Object> checkUpdate(CertificationCharging certificationCharging, ServiceName serviceName, ChargingPrice chargingPrice, CertificationCharging oldCC, ServiceName oldServiceName) throws ClassNotFoundException, IllegalAccessException {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("flag", false);
    ChargingPrice oldChargingPrice = getChargingPriceById(chargingPrice.getId());
    Date nowDate = new Date();
    /*
		 * 1(1)当前时间在“实际计费时间”设置区间内,不能修改 “实际计费时间”的开始时间、 “认证组合名称”,
		 * 可以修改“实际计费时间”的终止时间,但终止时间不能修改到小于当前的时间,可以修改“状态”。
		 * 2另外,若当前已提交数据的次数处于“计费价格及区间
		 * ”规定的某个阶梯时,该阶梯的最大次数值可以修改,但不能修改到小于当前已提交的次数,价钱不能修改;
		 * 3前一个阶梯的次数及价钱均不能修改,后面阶梯的次数以及价钱可以修改。
		 */
    List<Map<String, Object>> ccList = CompareTwoObjectUtils.compareTwoClass(oldCC, certificationCharging);
    // 判断当前时间是否处于原数据的两个时间之间
    boolean compareDate = certificationChargingService.compareDate(nowDate, oldCC.getStartTime(), oldCC.getEndTime());
    // CertificationCharging有修改
    if (null != ccList && ccList.size() != 0) {
        // 若开始时间被修改
        if (oldCC.getStartTime().compareTo(certificationCharging.getStartTime()) != 0) {
            if (!compareDate) {
                retMap.put("flag", false);
                retMap.put("retMsg", "当前时间处于有效期内,不能修改计费的起始时间");
                return retMap;
            }
        }
        // 若结束时间被修改
        if (oldCC.getEndTime().compareTo(certificationCharging.getEndTime()) != 0) {
            // 修改后的时间和当前时间做对比
            int compareNow = certificationCharging.getEndTime().compareTo(nowDate);
            // 判断不是因为被改为无效,导致时间被修改,而引起的时间判断不对
            boolean isValidityFlag = serviceName.getIsValidity() == false && oldServiceName.getIsValidity() == true;
            // 判断当前时间是否处于原数据的两个时间之间
            if (!compareDate) {
                if (compareNow == -1) {
                    retMap.put("flag", false);
                    retMap.put("retMsg", "当前时间处于有效期内,计费的终止时间不能小于当前时间");
                    if (!isValidityFlag) {
                        return retMap;
                    }
                }
            }
        }
    }
    List<Map<String, Object>> serviceNameList = CompareTwoObjectUtils.compareTwoClass(oldServiceName, serviceName);
    // servicename有修改
    if (null != serviceNameList && serviceNameList.size() != 0) {
        // 当前时间处于原数据的有效期内
        if (!compareDate) {
            // 判断服务类型,服务名称是否被修改
            boolean ssFlag = serviceName.getCertificationServiceId().equals(oldServiceName.getCertificationServiceId()) && serviceName.getServieType().equals(oldServiceName.getServieType());
            if (!ssFlag) {
                retMap.put("flag", false);
                retMap.put("retMsg", "当前时间处于有效期内,计费的服务类型或者服务名称不能被修改");
                return retMap;
            }
        }
    }
    /*
		 * 2另外,若当前已提交数据的次数处于“计费价格及区间”规定的某个阶梯时,该阶梯的最大次数值可以修改,但不能修改到小于当前已提交的次数,价钱不能修改
		 * 3前一个阶梯的次数及价钱均不能修改,后面阶梯的次数以及价钱可以修改。
		 */
    List<Map<String, Object>> cpList = CompareTwoObjectUtils.compareTwoClass(oldChargingPrice, chargingPrice);
    // chargingPrice有修改
    if (null != cpList && cpList.size() != 0) {
        int cpNumber = compareNumber(oldServiceName, oldChargingPrice);
        // 处于该阶梯时:处于当前阶梯,可以修改最大值,但是最大值不能比当前总值还小
        if (cpNumber == 2) {
            // 修改了最小值
            if (!oldChargingPrice.getMinimumNumber().equals(chargingPrice.getMinimumNumber())) {
                retMap.put("flag", false);
                retMap.put("retMsg", "当前计费区间处于有效区间内,不能修改区间的最小值");
                return retMap;
            }
            // 修改了价格
            if (!oldChargingPrice.getUnitPrice().equals(chargingPrice.getUnitPrice())) {
                retMap.put("flag", false);
                retMap.put("retMsg", "当前计费区间处于有效区间内,不能修改区间的价格");
                return retMap;
            }
            // 修改了最大值
            if (!oldChargingPrice.getMaximumNumber().equals(chargingPrice.getMaximumNumber())) {
                if (chargingPrice.getMaximumNumber() < serviceName.getTotalNumber()) {
                    retMap.put("flag", false);
                    retMap.put("retMsg", "当前计费区间处于有效区间内,不能修改区间的最大值比已记录的使用总数还小");
                    return retMap;
                }
            }
        } else if (cpNumber == 3) {
            // 3 处于上一个阶梯,什么都不能修改了
            retMap.put("flag", false);
            retMap.put("retMsg", "该区间已经过期,不能修改任何参数");
            return retMap;
        }
    }
    retMap.put("flag", true);
    return retMap;
}
Also used : HashMap(java.util.HashMap) ChargingPrice(com.itrus.portal.db.ChargingPrice) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Example 24 with ChargingPrice

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

the class ChargingPriceServiceImpl method selectList.

public List<ChargingPrice> selectList() {
    List<ChargingPrice> list = new ArrayList<ChargingPrice>();
    ChargingPriceExample chargingPriceExample = new ChargingPriceExample();
    ChargingPriceExample.Criteria criteria = chargingPriceExample.or();
    list = sqlSession.selectList("com.itrus.portal.db.ChargingPriceMapper.selectByExample", chargingPriceExample);
    return list;
}
Also used : ChargingPriceExample(com.itrus.portal.db.ChargingPriceExample) ArrayList(java.util.ArrayList) ChargingPrice(com.itrus.portal.db.ChargingPrice)

Example 25 with ChargingPrice

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

the class CertificationChargingController method update.

// 返回修改页面
@RequestMapping(value = "/update/{id}")
public String update(@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 ase = new AppServiceExample();
    AppServiceExample.Criteria criteria = ase.or();
    // 筛选实名认证类型的服务
    criteria.andTypeEqualTo(ComNames.SERVICE_TYPE_CERTIFICATION);
    appServices = sqlSession.selectList("com.itrus.portal.db.AppServiceMapper.selectByExample", ase);
    uiModel.addAttribute("appServices", appServices);
    Map<String, Object> map = new HashMap<>();
    map.put("serviceType", 1);
    // 系统配置的实名认证服务集合-企业
    List<AppService> appServices_e = new ArrayList<AppService>();
    appServices_e = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectAppServiceByServiceType", map);
    // 系统配置的实名认证服务集合-个人
    map.put("serviceType", 2);
    List<AppService> appServices_p = new ArrayList<AppService>();
    appServices_p = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectAppServiceByServiceType", map);
    uiModel.addAttribute("appServices_e", appServices_e);
    uiModel.addAttribute("appServices_p", appServices_p);
    List<CertificationCharging> certificationChargings = new ArrayList<CertificationCharging>();
    certificationChargings = certificationChargingService.selectList(id, ComNames.CHARGING_TYPE_SMRZ_1);
    CertificationChargingWrap certificationChargingWrap = new CertificationChargingWrap();
    List<CertificationChargingList> certificationChargingLists = new ArrayList<CertificationChargingList>();
    for (int i = 0; i < certificationChargings.size(); i++) {
        CertificationChargingList certificationChargingList = new CertificationChargingList();
        List<ServiceName> serviceNames = new ArrayList<ServiceName>();
        serviceNames = serviceNameService.selectListByCertificationCharging(certificationChargings.get(i));
        List<ServiceNameList> serviceNameLists = new ArrayList<ServiceNameList>();
        for (int j = 0; j < serviceNames.size(); j++) {
            List<ChargingPrice> chargingPrices = chargingPriceService.selectListByOneServiceName(serviceNames.get(j));
            ServiceNameList serviceNameList = new ServiceNameList();
            ChargingPriceList chargingPriceList = new ChargingPriceList();
            // 1
            chargingPriceList.setChargingPriceLists(chargingPrices);
            // 2
            serviceNameList.setServiceName(serviceNames.get(j));
            serviceNameList.setChargingPriceList(chargingPriceList);
            serviceNameLists.add(serviceNameList);
        }
        certificationChargingList.setCertificationCharging(certificationChargings.get(i));
        certificationChargingList.setServiceNameLists(serviceNameLists);
        certificationChargingLists.add(certificationChargingList);
    }
    certificationChargingWrap.setCertificationChargingLists(certificationChargingLists);
    uiModel.addAttribute("ccw", certificationChargingWrap);
    Map<Long, AppService> appServiceMap = sqlSession.selectMap("com.itrus.portal.db.AppServiceMapper.selectByExample", null, "id");
    uiModel.addAttribute("appServiceMap", appServiceMap);
    returnParam(request, uiModel);
    return "certificationcharging/update";
}
Also used : HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) ArrayList(java.util.ArrayList) ChargingPriceList(com.itrus.portal.entity.ChargingPriceList) CertificationChargingList(com.itrus.portal.entity.CertificationChargingList) AppServiceExample(com.itrus.portal.db.AppServiceExample) ServiceNameList(com.itrus.portal.entity.ServiceNameList) AppService(com.itrus.portal.db.AppService) CertificationCharging(com.itrus.portal.db.CertificationCharging) CertificationChargingWrap(com.itrus.portal.entity.CertificationChargingWrap) ServiceName(com.itrus.portal.db.ServiceName) ChargingPrice(com.itrus.portal.db.ChargingPrice) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ChargingPrice (com.itrus.portal.db.ChargingPrice)45 ArrayList (java.util.ArrayList)35 Date (java.util.Date)23 CertificationCharging (com.itrus.portal.db.CertificationCharging)21 ServiceName (com.itrus.portal.db.ServiceName)18 ChargingPriceExample (com.itrus.portal.db.ChargingPriceExample)15 HashMap (java.util.HashMap)15 List (java.util.List)15 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)11 ServiceNameList (com.itrus.portal.entity.ServiceNameList)9 CertificationChargingExample (com.itrus.portal.db.CertificationChargingExample)7 Map (java.util.Map)7 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 Test (org.junit.Test)4 Charging (com.itrus.portal.db.Charging)3 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3