JAVA查询数据作为本地缓存map映射

查询数据库数据源转化map映射

// 查询结果,用户源map
		Map pricingModelMap = zqSitePricingModelMapper.getAllList().stream().collect(Collectors.toMap(
				it -> (it.getYear() + "_" + it.getMonth() + "_" + it.geteId() + "_" + it.getStartHours().toString() + "_" + it.getEndHours() + "_" +
						(it.getStartMinutes()==0?"00":it.getStartMinutes()) + "_" + (it.getEndMinutes()==0?"00":it.getEndMinutes())), Function.identity()
		));

获取key

			// key格式:年_月_站_开始小时_结束小时_开始分钟_结束分钟
			String[] str = zqSitePeakValley2.getSendTime().split("-");
			String key = DateUtils.getYearNow() + "_" + DateUtils.getMonth(zqSitePeakValley2.getSendDate()) + "_" + zqSitePeakValley2.getEId() + "_" +
					str[0].split(":")[0] + "_" + str[1].split(":")[0] + "_" + str[0].split(":")[1] + "_" +str[1].split(":")[1];
			ZqSitePricingModel model = pricingModelMap.get(key);

你可能感兴趣的:(java,缓存,spring)