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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations