Search in sources :

Example 41 with ChargingPrice

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

the class StoreChargingServiceImpl method initStoreCharging.

/**
 * 初始化存证计费规则 取出当前有效的计费规则.并存入系统缓存中
 */
public ConcurrentHashMap<String, List<ChargingPrice>> initStoreCharging() {
    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_STORE_2);
    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() + "," + certificationChargings.get(i).getAccountingStrategy();
                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)

Example 42 with ChargingPrice

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

the class StoreChargingServiceImpl method initAllStoreCharging.

/**
 * 初始化所有的存证计费
 */
public ConcurrentHashMap<String, List<ChargingPrice>> initAllStoreCharging() {
    ConcurrentHashMap<String, List<ChargingPrice>> chargeRuleMap = new ConcurrentHashMap<String, List<ChargingPrice>>();
    CertificationChargingExample cce = new CertificationChargingExample();
    CertificationChargingExample.Criteria criteria = cce.or();
    Date nowDate = new Date();
    cce.setOrderByClause("start_time asc");
    criteria.andChargingTypeEqualTo(ComNames.CHARGING_TYPE_STORE_2);
    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() + "," + certificationChargings.get(i).getAccountingStrategy();
                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)

Example 43 with ChargingPrice

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

the class ServiceNameServiceImpl method initServiceNameMap.

/**
 * 初始化当前时间内有效的serviceName
 * @return
 */
public ConcurrentHashMap<Long, ServiceName> initServiceNameMap() {
    ConcurrentHashMap<Long, ServiceName> serviceNameMap = new ConcurrentHashMap<>();
    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 = certificationChargingService.getHourLaterDate(nowDate);
    criteria.andStartTimeLessThanOrEqualTo(laterDate);
    List<CertificationCharging> certificationChargings = new ArrayList<CertificationCharging>();
    certificationChargings = sqlSession.selectList("com.itrus.portal.db.CertificationChargingMapper.selectByExample", cce);
    if (null == certificationChargings) {
        return serviceNameMap;
    }
    for (int i = 0; i < certificationChargings.size(); i++) {
        List<ServiceName> serviceNames = selectListByCertificationChargingId(certificationChargings.get(i).getId());
        if (null != serviceNames && !serviceNames.isEmpty()) {
            for (ServiceName serviceName : serviceNames) {
                serviceNameMap.put(serviceName.getId(), serviceName);
            }
        }
    }
    return serviceNameMap;
}
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) ServiceNameList(com.itrus.portal.entity.ServiceNameList) ArrayList(java.util.ArrayList) List(java.util.List) ChargingPrice(com.itrus.portal.db.ChargingPrice) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 44 with ChargingPrice

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

the class ChargingPriceControllerTest method testSendCode2.

/*
	
	@Test
	public void testSendCode() {
		String url = "http://127.0.0.1:8080/portal/certificationcharging/createOrUpdate";
		LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
		
		String str = "";
		ChargingPrice cp = new ChargingPrice();
		ChargingPrice cp2 = new ChargingPrice();
		cp.setMaximumNumber(Integer.valueOf(100));
		cp.setMinimumNumber(Integer.valueOf(0));
		cp2.setMaximumNumber(Integer.valueOf(1000));
		cp2.setMinimumNumber(Integer.valueOf(10));
		ChargingPriceList chargingPriceList = new ChargingPriceList();
		ChargingPriceList chargingPriceList2 = new ChargingPriceList();
		List<ChargingPrice> chargingPrices = new ArrayList<>();
		chargingPriceList.setChargingPriceLists(chargingPrices);
		chargingPriceList.getChargingPriceLists().add(cp);
		chargingPriceList.getChargingPriceLists().add(cp2);
		chargingPriceList2.setChargingPriceLists(chargingPrices);
		chargingPriceList2.getChargingPriceLists().add(cp);
		chargingPriceList2.getChargingPriceLists().add(cp2);
		
		ServiceNameList serviceNameList = new ServiceNameList();
		ServiceNameList serviceNameList2 = new ServiceNameList();
		ServiceName serviceName = new ServiceName();
		ServiceName serviceName2 = new ServiceName();
		serviceName.setServieType(Long.valueOf(1));
		serviceName2.setServieType(Long.valueOf(2));
		List<ServiceName> serviceNames = new ArrayList<>();
		serviceNames.add(serviceName);
		serviceNames.add(serviceName2);
		serviceNameList.setChargingPriceList(chargingPriceList);
		serviceNameList.setServiceName(serviceName);
		serviceNameList2.setChargingPriceList(chargingPriceList2);
		serviceNameList2.setServiceName(serviceName2);
		
		List<ServiceNameList> list =new ArrayList<ServiceNameList>();
		list.add(serviceNameList);
		list.add(serviceNameList2);
		CertificationCharging certificationCharging = new CertificationCharging();
		certificationCharging.setApp(Long.valueOf(1));
		CertificationChargingList certificationChargingList = new CertificationChargingList();
		CertificationChargingList certificationChargingList2 = new CertificationChargingList();
		certificationChargingList.setCertificationCharging(certificationCharging);
		certificationChargingList.setServiceNameLists(list);
		certificationChargingList2.setCertificationCharging(certificationCharging);
		certificationChargingList2.setServiceNameLists(list);
		
		List<CertificationChargingList> cList = new ArrayList<CertificationChargingList>();
		cList.add(certificationChargingList);
		cList.add(certificationChargingList2);
		CertificationChargingWrap certificationChargingWrap = new CertificationChargingWrap();
		certificationChargingWrap.setCertificationChargingLists(cList);
		
		
		ObjectMapper json = new ObjectMapper();
		try {
			str = json.writeValueAsString(certificationChargingWrap);
//			CertificationChargingWrap certificationChargingWrap2 = json.readValue(str, CertificationChargingWrap.class);
//			List<CertificationChargingList> chargingPriceLists = certificationChargingWrap2.getCertificationChargingLists();
//			CertificationChargingList certificationChargingList3 = chargingPriceLists.get(0);
			
			//System.out.println(certificationChargingWrap2.toString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		map.add("certificationChargingStr", str);
		try {
			//Map<String, Object> retMap  = restTemplate.postForObject(url, map, Map.class);
			//System.out.println(retMap.toString());
			String retMap  = restTemplate.postForObject(url, map, String.class);
			System.out.println(retMap);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	*/
@Test
public void testSendCode2() {
    String str = "";
    ChargingPrice cp = new ChargingPrice();
    ChargingPrice cp2 = new ChargingPrice();
    cp.setMaximumNumber(Integer.valueOf(100));
    cp.setMinimumNumber(Integer.valueOf(0));
    cp.setCreateTime(new Date());
    cp.setUnitPrice(Double.valueOf(0.6));
    cp2.setCreateTime(new Date());
    cp2.setUnitPrice(Double.valueOf(0.5));
    cp2.setMaximumNumber(Integer.valueOf(1000));
    cp2.setMinimumNumber(Integer.valueOf(100));
    ChargingPriceList chargingPriceList = new ChargingPriceList();
    ChargingPriceList chargingPriceList2 = new ChargingPriceList();
    List<ChargingPrice> chargingPrices = new ArrayList<>();
    chargingPriceList.setChargingPriceLists(chargingPrices);
    chargingPriceList.getChargingPriceLists().add(cp);
    chargingPriceList2.setChargingPriceLists(chargingPrices);
    chargingPriceList2.getChargingPriceLists().add(cp2);
    ServiceNameList serviceNameList = new ServiceNameList();
    ServiceNameList serviceNameList2 = new ServiceNameList();
    ServiceName serviceName = new ServiceName();
    ServiceName serviceName2 = new ServiceName();
    serviceName.setCreateTime(new Date());
    serviceName.setCertificationCharging(null);
    serviceName.setCertificationServiceId(Long.valueOf(1));
    serviceName.setServieType(Long.valueOf(1));
    serviceName.setTotalNumber(Integer.valueOf(0));
    serviceName2.setCreateTime(new Date());
    serviceName2.setCertificationCharging(null);
    serviceName2.setCertificationServiceId(Long.valueOf(1));
    serviceName2.setServieType(Long.valueOf(1));
    serviceName2.setTotalNumber(Integer.valueOf(0));
    List<ServiceName> serviceNames = new ArrayList<>();
    serviceNames.add(serviceName);
    serviceNames.add(serviceName2);
    serviceNameList.setChargingPriceList(chargingPriceList);
    serviceNameList.setServiceName(serviceName);
    serviceNameList2.setChargingPriceList(chargingPriceList2);
    serviceNameList2.setServiceName(serviceName2);
    List<ServiceNameList> list = new ArrayList<ServiceNameList>();
    list.add(serviceNameList);
    list.add(serviceNameList2);
    /**
     * 		// 参数检查,参数不能为null,且结束时间大于起始时间
     *		boolean check = (null != certificationCharging
     *				&& null != certificationCharging.getApp()
     *				&& null != certificationCharging.getAccountingStrategy()
     *				&& null != certificationCharging.getUserGe() && (1 == certificationCharging
     *				.getEndTime().compareTo(certificationCharging.getStartTime())));
     */
    CertificationCharging certificationCharging = new CertificationCharging();
    certificationCharging.setApp(Long.valueOf(1));
    certificationCharging.setAccountingStrategy(Double.valueOf(1));
    certificationCharging.setUserGe(Long.valueOf(2));
    certificationCharging.setStartTime(new Date(2016, 5, 3));
    certificationCharging.setEndTime(new Date(2017, 3, 2));
    // certificationCharging.setIsValidity(true);
    certificationCharging.setCreateTime(new Date());
    CertificationChargingList certificationChargingList = new CertificationChargingList();
    CertificationChargingList certificationChargingList2 = new CertificationChargingList();
    certificationChargingList.setCertificationCharging(certificationCharging);
    certificationChargingList.setServiceNameLists(list);
    certificationChargingList2.setCertificationCharging(certificationCharging);
    certificationChargingList2.setServiceNameLists(list);
    List<CertificationChargingList> cList = new ArrayList<CertificationChargingList>();
    cList.add(certificationChargingList);
    cList.add(certificationChargingList2);
    CertificationChargingWrap certificationChargingWrap = new CertificationChargingWrap();
    certificationChargingWrap.setCertificationChargingLists(cList);
    ObjectMapper json = new ObjectMapper();
    try {
        str = json.writeValueAsString(certificationChargingWrap);
    // CertificationChargingWrap certificationChargingWrap2 = json.readValue(str, CertificationChargingWrap.class);
    // List<CertificationChargingList> chargingPriceLists = certificationChargingWrap2.getCertificationChargingLists();
    // CertificationChargingList certificationChargingList3 = chargingPriceLists.get(0);
    // System.out.println(certificationChargingWrap2.toString());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        // CertificationChargingController certificationChargingController = new CertificationChargingController();
        Map<String, Object> retmap = certificationChargingController.createOrUpdate(str);
        System.out.println(retmap.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ServiceNameList(com.itrus.portal.entity.ServiceNameList) CertificationCharging(com.itrus.portal.db.CertificationCharging) ChargingPriceList(com.itrus.portal.entity.ChargingPriceList) ArrayList(java.util.ArrayList) CertificationChargingList(com.itrus.portal.entity.CertificationChargingList) IOException(java.io.IOException) Date(java.util.Date) IOException(java.io.IOException) CertificationChargingWrap(com.itrus.portal.entity.CertificationChargingWrap) ServiceName(com.itrus.portal.db.ServiceName) ChargingPrice(com.itrus.portal.db.ChargingPrice) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 45 with ChargingPrice

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

the class ChargingPriceControllerTest method test.

/*
	 * 
	 * 
单条数据的结构

{"serviceNameList":
	[
		{
			"chargingPriceList":{
									"chargingPrices":[
														{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},
														{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null},
														{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},
														{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null}
													]
								},
			"serviceName":{"id":null,"certificationServiceId":null,"createTime":null,"modifyTime":null,"servieType":1,"totalNumber":null,"certificationCharging":null}
		},
		
		{"chargingPriceList":{"chargingPrices":[{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null}]},
		"serviceName":{"id":null,"certificationServiceId":null,"createTime":null,"modifyTime":null,"servieType":2,"totalNumber":null,"certificationCharging":null}}
	],

"certificationCharging":{"id":null,"app":1,"accountingStrategy":null,"createTime":null,"endTime":null,"isValidity":null,"modifyTime":null,"startTime":null,"userGe":null}
}



多条的数据结构
{"certificationChargingLists":[{"serviceNameLists":[{"chargingPriceList":{"chargingPriceLists":[{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null}]},"serviceName":{"id":null,"certificationServiceId":null,"createTime":null,"modifyTime":null,"servieType":1,"totalNumber":null,"certificationCharging":null}},{"chargingPriceList":{"chargingPriceLists":[{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null}]},"serviceName":{"id":null,"certificationServiceId":null,"createTime":null,"modifyTime":null,"servieType":2,"totalNumber":null,"certificationCharging":null}}],"certificationCharging":{"id":null,"app":1,"accountingStrategy":null,"createTime":null,"endTime":null,"isValidity":null,"modifyTime":null,"startTime":null,"userGe":null}},{"serviceNameLists":[{"chargingPriceList":{"chargingPriceLists":[{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null}]},"serviceName":{"id":null,"certificationServiceId":null,"createTime":null,"modifyTime":null,"servieType":1,"totalNumber":null,"certificationCharging":null}},{"chargingPriceList":{"chargingPriceLists":[{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":100,"minimumNumber":0,"modifyTime":null,"serviceName":null,"certificationCharging":null},{"id":null,"unitPrice":null,"createTime":null,"maximumNumber":1000,"minimumNumber":10,"modifyTime":null,"serviceName":null,"certificationCharging":null}]},"serviceName":{"id":null,"certificationServiceId":null,"createTime":null,"modifyTime":null,"servieType":2,"totalNumber":null,"certificationCharging":null}}],"certificationCharging":{"id":null,"app":1,"accountingStrategy":null,"createTime":null,"endTime":null,"isValidity":null,"modifyTime":null,"startTime":null,"userGe":null}}]}



	 */
@Test
public void test() {
    String str = "";
    ChargingPrice cp = new ChargingPrice();
    ChargingPrice cp2 = new ChargingPrice();
    cp.setMaximumNumber(Integer.valueOf(100));
    cp.setMinimumNumber(Integer.valueOf(0));
    cp2.setMaximumNumber(Integer.valueOf(1000));
    cp2.setMinimumNumber(Integer.valueOf(10));
    ChargingPriceList chargingPriceList = new ChargingPriceList();
    ChargingPriceList chargingPriceList2 = new ChargingPriceList();
    List<ChargingPrice> chargingPrices = new ArrayList<>();
    chargingPriceList.setChargingPriceLists(chargingPrices);
    chargingPriceList.getChargingPriceLists().add(cp);
    chargingPriceList.getChargingPriceLists().add(cp2);
    chargingPriceList2.setChargingPriceLists(chargingPrices);
    chargingPriceList2.getChargingPriceLists().add(cp);
    chargingPriceList2.getChargingPriceLists().add(cp2);
    ServiceNameList serviceNameList = new ServiceNameList();
    ServiceNameList serviceNameList2 = new ServiceNameList();
    ServiceName serviceName = new ServiceName();
    ServiceName serviceName2 = new ServiceName();
    serviceName.setServieType(Long.valueOf(1));
    serviceName2.setServieType(Long.valueOf(2));
    List<ServiceName> serviceNames = new ArrayList<>();
    serviceNames.add(serviceName);
    serviceNames.add(serviceName2);
    serviceNameList.setChargingPriceList(chargingPriceList);
    serviceNameList.setServiceName(serviceName);
    serviceNameList2.setChargingPriceList(chargingPriceList2);
    serviceNameList2.setServiceName(serviceName2);
    List<ServiceNameList> list = new ArrayList<ServiceNameList>();
    list.add(serviceNameList);
    list.add(serviceNameList2);
    CertificationCharging certificationCharging = new CertificationCharging();
    certificationCharging.setApp(Long.valueOf(1));
    CertificationChargingList certificationChargingList = new CertificationChargingList();
    CertificationChargingList certificationChargingList2 = new CertificationChargingList();
    certificationChargingList.setCertificationCharging(certificationCharging);
    certificationChargingList.setServiceNameLists(list);
    certificationChargingList2.setCertificationCharging(certificationCharging);
    certificationChargingList2.setServiceNameLists(list);
    List<CertificationChargingList> cList = new ArrayList<CertificationChargingList>();
    cList.add(certificationChargingList);
    cList.add(certificationChargingList2);
    CertificationChargingWrap certificationChargingWrap = new CertificationChargingWrap();
    certificationChargingWrap.setCertificationChargingLists(cList);
    ObjectMapper json = new ObjectMapper();
    try {
        str = json.writeValueAsString(certificationChargingWrap);
        CertificationChargingWrap certificationChargingWrap2 = json.readValue(str, CertificationChargingWrap.class);
        List<CertificationChargingList> chargingPriceLists = certificationChargingWrap2.getCertificationChargingLists();
        CertificationChargingList certificationChargingList3 = chargingPriceLists.get(0);
        System.out.println(certificationChargingList3.toString());
    // System.out.println(certificationChargingWrap2.toString());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.out.println(str);
}
Also used : ServiceNameList(com.itrus.portal.entity.ServiceNameList) CertificationCharging(com.itrus.portal.db.CertificationCharging) ChargingPriceList(com.itrus.portal.entity.ChargingPriceList) ArrayList(java.util.ArrayList) CertificationChargingList(com.itrus.portal.entity.CertificationChargingList) IOException(java.io.IOException) CertificationChargingWrap(com.itrus.portal.entity.CertificationChargingWrap) ServiceName(com.itrus.portal.db.ServiceName) ChargingPrice(com.itrus.portal.db.ChargingPrice) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

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